GBDK 2020 Docs 4.4.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
20 __SHADOW_REG shadow_PPUCTRL;
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
31 __SHADOW_REG shadow_PPUMASK;
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 #define DEVICE_SCREEN_BUFFER_WIDTH 32
46 #define DEVICE_SCREEN_BUFFER_HEIGHT 30
47 #define DEVICE_SCREEN_MAP_ENTRY_SIZE 1
48 #define DEVICE_SPRITE_PX_OFFSET_X 0
49 #define DEVICE_SPRITE_PX_OFFSET_Y -1
50 #define DEVICE_WINDOW_PX_OFFSET_X 0
51 #define DEVICE_WINDOW_PX_OFFSET_Y 0
52 #define DEVICE_SCREEN_PX_WIDTH (DEVICE_SCREEN_WIDTH * 8)
53 #define DEVICE_SCREEN_PX_HEIGHT (DEVICE_SCREEN_HEIGHT * 8)
54
55 // Scrolling coordinates (will be written to PPUSCROLL at end-of-vblank by NMI handler)
56 __SHADOW_REG bkg_scroll_x;
57 __SHADOW_REG bkg_scroll_y;
58 // LCD scanline - a software-driven version of GB's incrasing 'LY' scanline counter
59 __SHADOW_REG _lcd_scanline;
60
61 extern volatile UBYTE TIMA_REG;
62 extern volatile UBYTE TMA_REG;
63 extern volatile UBYTE TAC_REG;
64
65 // Compatibility defines for GB LY / LYC registers, to allow easier LCD ISR porting
66 #define SCY_REG bkg_scroll_y
67 #define rSCY SCY_REG
68 #define SCX_REG bkg_scroll_x
69 #define rSCX SCX_REG
70 #define LY_REG _lcd_scanline
71 #define rLY LY_REG
72 #define LYC_REG _lcd_scanline
73 #define rLYC LYC_REG
74
75 #endif
UBYTE
UINT8 UBYTE
Definition: types.h:62
TMA_REG
__REG TMA_REG
Definition: hardware.h:92
TAC_REG
__REG TAC_REG
Definition: hardware.h:94
TIMA_REG
__REG TIMA_REG
Definition: hardware.h:90
__REG
#define __REG(addr)
Definition: hardware.h:11
shadow_PPUMASK
__SHADOW_REG shadow_PPUMASK
Definition: hardware.h:31
bkg_scroll_x
__SHADOW_REG bkg_scroll_x
Definition: hardware.h:56
_lcd_scanline
__SHADOW_REG _lcd_scanline
Definition: hardware.h:59
bkg_scroll_y
__SHADOW_REG bkg_scroll_y
Definition: hardware.h:57
__SHADOW_REG
#define __SHADOW_REG
Definition: hardware.h:10
shadow_PPUCTRL
__SHADOW_REG shadow_PPUCTRL
Definition: hardware.h:20