GBDK 2020 Docs  4.3.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 __BYTES extern UBYTE
11 #define __BYTE_REG extern volatile UBYTE
12 
13 static volatile SFR AT(0x7E) VCOUNTER;
14 
15 static volatile SFR AT(0x7F) PSG;
16 
17 #define PSG_LATCH 0x80
18 
19 #define PSG_CH0 0b00000000
20 #define PSG_CH1 0b00100000
21 #define PSG_CH2 0b01000000
22 #define PSG_CH3 0b01100000
23 
24 #define PSG_VOLUME 0b00010000
25 
26 static volatile SFR AT(0x7F) HCOUNTER;
27 
28 static volatile SFR AT(0x98) VDP_DATA;
29 static volatile SFR AT(0x99) VDP_CMD;
30 static volatile SFR AT(0x99) VDP_STATUS;
31 
32 #define STATF_INT_VBL 0b10000000
33 #define STATF_9_SPR 0b01000000
34 #define STATF_SPR_COLL 0b00100000
35 
36 #define VDP_REG_MASK 0b10000000
37 #define VDP_R0 0b10000000
38 extern UBYTE shadow_VDP_R0;
39 
40 #define R0_DEFAULT 0b00000000
41 #define R0_CB_OUTPUT 0b00000000
42 #define R0_CB_INPUT 0b01000000
43 #define R0_IE2_OFF 0b00000000
44 #define R0_IE2 0b00100000
45 #define R0_IE1_OFF 0b00000000
46 #define R0_IE1 0b00010000
47 #define R0_SCR_MODE1 0b00000000
48 #define R0_SCR_MODE2 0b00000010
49 #define R0_SCR_MODE3 0b00000100
50 #define R0_ES_OFF 0b00000000
51 #define R0_ES 0b00000001
52 
53 #define VDP_R1 0b10000001
54 extern UBYTE shadow_VDP_R1;
55 
56 #define R1_DEFAULT 0b10000000
57 #define R1_DISP_OFF 0b00000000
58 #define R1_DISP_ON 0b01000000
59 #define R1_IE_OFF 0b00000000
60 #define R1_IE 0b00100000
61 #define R1_SCR_MODE1 0b00010000
62 #define R1_SCR_MODE2 0b00000000
63 #define R1_SCR_MODE3 0b00000000
64 #define R1_SPR_8X8 0b00000000
65 #define R1_SPR_16X16 0b00000010
66 #define R1_SPR_MAG 0b00000001
67 #define R1_SPR_MAG_OFF 0b00000000
68 
69 #define VDP_R2 0b10000010
70 extern UBYTE shadow_VDP_R2;
71 
72 #define R2_MAP_0x3800 0xFF
73 #define R2_MAP_0x3000 0xFD
74 #define R2_MAP_0x2800 0xFB
75 #define R2_MAP_0x2000 0xF9
76 #define R2_MAP_0x1800 0xF7
77 #define R2_MAP_0x1000 0xF5
78 #define R2_MAP_0x0800 0xF3
79 #define R2_MAP_0x0000 0xF1
80 
81 #define VDP_R3 0b10000011
82 extern UBYTE shadow_VDP_R3;
83 #define VDP_R4 0b10000100
84 extern UBYTE shadow_VDP_R4;
85 #define VDP_R5 0b10000101
86 extern UBYTE shadow_VDP_R5;
87 
88 #define R5_SAT_0x3F00 0xFF
89 #define R5_SAT_MASK 0b10000001
90 
91 #define VDP_R6 0b10000110
92 extern UBYTE shadow_VDP_R6;
93 
94 #define R6_BANK0 0xFB
95 #define R6_DATA_0x0000 0xFB
96 #define R6_BANK1 0xFF
97 #define R6_DATA_0x2000 0xFF
98 
99 #define VDP_R7 0b10000111
100 extern UBYTE shadow_VDP_R7;
101 #define VDP_RBORDER 0b10000111
103 
104 #define R7_COLOR_MASK 0b11110000
105 
106 #define VDP_R8 0b10001000
107 extern UBYTE shadow_VDP_R8;
108 #define VDP_RSCX 0b10001000
109 extern UBYTE shadow_VDP_RSCX;
110 
111 #define VDP_R9 0b10001001
112 extern UBYTE shadow_VDP_R9;
113 #define VDP_RSCY 0b10001001
114 extern UBYTE shadow_VDP_RSCY;
115 
116 #define VDP_R10 0b10001010
117 extern UBYTE shadow_VDP_R10;
118 
119 #define R10_INT_OFF 0xFF
120 #define R10_INT_EVERY 0x00
121 
122 static volatile SFR AT(0xF0) FMADDRESS;
123 static volatile SFR AT(0xF1) FMDATA;
124 static volatile SFR AT(0xF2) AUDIOCTRL;
125 
126 static volatile SFR AT(0xfc) MAP_FRAME0;
127 static volatile SFR AT(0xfd) MAP_FRAME1;
128 static volatile SFR AT(0xfe) MAP_FRAME2;
129 static volatile SFR AT(0xff) MAP_FRAME3;
130 
131 extern const UBYTE _SYSTEM;
132 
133 #define SYSTEM_PAL 0x00
134 #define SYSTEM_NTSC 0x01
135 
136 extern volatile UBYTE VDP_ATTR_SHIFT;
137 
138 #define VBK_TILES 0
139 #define VBK_ATTRIBUTES 1
140 
141 #define VDP_SAT_TERM 0xD0
142 
143 #if defined(__TARGET_msxdos)
144 #define DEVICE_SCREEN_X_OFFSET 0
145 #define DEVICE_SCREEN_Y_OFFSET 0
146 #define DEVICE_SCREEN_WIDTH 32
147 #define DEVICE_SCREEN_HEIGHT 24
148 #define DEVICE_SCREEN_BUFFER_WIDTH 32
149 #define DEVICE_SCREEN_BUFFER_HEIGHT 28
150 #define DEVICE_SCREEN_MAP_ENTRY_SIZE 2
151 #define DEVICE_SPRITE_PX_OFFSET_X 0
152 #define DEVICE_SPRITE_PX_OFFSET_Y -1
153 #define DEVICE_WINDOW_PX_OFFSET_X 0
154 #define DEVICE_WINDOW_PX_OFFSET_Y 0
155 #else
156 #error Unrecognized port
157 #endif
158 #define DEVICE_SCREEN_PX_WIDTH (DEVICE_SCREEN_WIDTH * 8)
159 #define DEVICE_SCREEN_PX_HEIGHT (DEVICE_SCREEN_HEIGHT * 8)
160 
161 #endif
UINT8 UBYTE
Definition: types.h:62
#define AT(A)
Definition: types.h:35
#define SFR
Definition: types.h:34
volatile UBYTE VDP_ATTR_SHIFT
UBYTE shadow_VDP_R9
UBYTE shadow_VDP_RBORDER
UBYTE shadow_VDP_R5
UBYTE shadow_VDP_RSCY
UBYTE shadow_VDP_R7
UBYTE shadow_VDP_R1
const UBYTE _SYSTEM
UBYTE shadow_VDP_R2
UBYTE shadow_VDP_R6
UBYTE shadow_VDP_R0
UBYTE shadow_VDP_R3
UBYTE shadow_VDP_R8
UBYTE shadow_VDP_R10
UBYTE shadow_VDP_RSCX
UBYTE shadow_VDP_R4