GBDK 2020 Docs  4.5.0
API Documentation for GBDK 2020
hardware.h
Go to the documentation of this file.
1
5#ifndef _HARDWARE_H
6#define _HARDWARE_H
7
8#include <types.h>
9
10#define __SHADOW_REG extern volatile uint8_t
11#define __REG(addr) volatile __at (addr) uint8_t
12
13__REG(0x2000) PPUCTRL;
14#define PPUCTRL_NMI 0b10000000
15#define PPUCTRL_SPR_8X8 0b00000000
16#define PPUCTRL_SPR_8X16 0b00100000
17#define PPUCTRL_BG_CHR 0b00010000
18#define PPUCTRL_SPR_CHR 0b00001000
19#define PPUCTRL_INC32 0b00000100
21
22__REG(0x2001) PPUMASK;
23#define PPUMASK_BLUE 0b10000000
24#define PPUMASK_RED 0b01000000
25#define PPUMASK_GREEN 0b00100000
26#define PPUMASK_SHOW_SPR 0b00010000
27#define PPUMASK_SHOW_BG 0b00001000
28#define PPUMASK_SHOW_SPR_LC 0b00000100
29#define PPUMASK_SHOW_BG_LC 0b00000010
30#define PPUMASK_MONOCHROME 0b00000001
32
33__REG(0x2002) PPUSTATUS;
34__REG(0x2003) OAMADDR;
35__REG(0x2004) OAMDATA;
36__REG(0x2005) PPUSCROLL;
37__REG(0x2006) PPUADDR;
38__REG(0x2007) PPUDATA;
39__REG(0x4014) OAMDMA;
40
41#define DEVICE_SCREEN_X_OFFSET 0
42#define DEVICE_SCREEN_Y_OFFSET 0
43#define DEVICE_SCREEN_WIDTH 32
44#define DEVICE_SCREEN_HEIGHT 30
45
46#if defined(NES_TILEMAP_F)
47// Full tilemap
48#define DEVICE_SCREEN_BUFFER_WIDTH 64
49#define DEVICE_SCREEN_BUFFER_HEIGHT 60
50typedef uint16_t scroll_x_t;
51typedef uint16_t scroll_y_t;
52#elif defined(NES_TILEMAP_H)
53// Horizontally arranged tilemap
54#define DEVICE_SCREEN_BUFFER_WIDTH 64
55#define DEVICE_SCREEN_BUFFER_HEIGHT 30
56typedef uint16_t scroll_x_t;
57typedef uint8_t scroll_y_t;
58#elif defined(NES_TILEMAP_V)
59// Vertically arranged tilemap
60#define DEVICE_SCREEN_BUFFER_WIDTH 32
61#define DEVICE_SCREEN_BUFFER_HEIGHT 60
62typedef uint8_t scroll_x_t;
63typedef uint16_t scroll_y_t;
64#else
65// Single-screen tilemap
66#define DEVICE_SCREEN_BUFFER_WIDTH 32
67#define DEVICE_SCREEN_BUFFER_HEIGHT 30
70#endif
71
72#define DEVICE_SCREEN_MAP_ENTRY_SIZE 1
73#define DEVICE_SPRITE_PX_OFFSET_X 0
74#define DEVICE_SPRITE_PX_OFFSET_Y -1
75#define DEVICE_WINDOW_PX_OFFSET_X 0
76#define DEVICE_WINDOW_PX_OFFSET_Y 0
77#define DEVICE_SCREEN_PX_WIDTH (DEVICE_SCREEN_WIDTH * 8)
78#define DEVICE_SCREEN_PX_HEIGHT (DEVICE_SCREEN_HEIGHT * 8)
79
80// Scrolling coordinates (will be written to PPUSCROLL at end-of-vblank by NMI handler)
83// LCD scanline - a software-driven version of GB's incrasing 'LY' scanline counter
85
86extern volatile UBYTE TIMA_REG;
87extern volatile UBYTE TMA_REG;
88extern volatile UBYTE TAC_REG;
89
90// Compatibility defines for GB LY / LYC registers, to allow easier LCD ISR porting
91#define SCY_REG bkg_scroll_y
92#define rSCY SCY_REG
93#define SCX_REG bkg_scroll_x
94#define rSCX SCX_REG
95#define LY_REG _lcd_scanline
96#define rLY LY_REG
97#define LYC_REG _lcd_scanline
98#define rLYC LYC_REG
99
100#endif
UINT8 UBYTE
Definition: types.h:62
__REG TAC_REG
Definition: hardware.h:94
__REG TIMA_REG
Definition: hardware.h:90
__REG TMA_REG
Definition: hardware.h:92
#define __REG(addr)
Definition: hardware.h:11
#define __SHADOW_REG
Definition: hardware.h:10
__SHADOW_REG _lcd_scanline
Definition: hardware.h:84
__SHADOW_REG bkg_scroll_x
Definition: hardware.h:81
__SHADOW_REG bkg_scroll_y
Definition: hardware.h:82
uint8_t scroll_x_t
Definition: hardware.h:68
uint8_t scroll_y_t
Definition: hardware.h:69
__SHADOW_REG shadow_PPUCTRL
Definition: hardware.h:20
__SHADOW_REG shadow_PPUMASK
Definition: hardware.h:31
unsigned short int uint16_t
Definition: stdint.h:52
unsigned char uint8_t
Definition: stdint.h:51