Go to the documentation of this file.
9 #ifndef _PCE_HARDWARE_H_
10 #define _PCE_HARDWARE_H_
20 #define IO_TIMER_COUNTER ((volatile uint8_t *)0x0C00)
22 #define TIMER_OFF 0x00
23 #define IO_TIMER_CONTROL ((volatile uint8_t *)0x0C01)
25 #define JOYPAD_CLR 0x02
26 #define JOYPAD_SEL 0x01
27 #define JOYPAD_COUNTRY 0x40
28 #define JOYPAD_ADDON 0x80
29 #define IO_JOYPAD ((volatile uint8_t *)0x1000)
31 #define IRQ_TIMER 0x04
33 #define IRQ_EXTERNAL 0x01
34 #define IO_IRQ_CONTROL ((volatile uint8_t *)0x1402)
35 #define IO_IRQ_STATUS ((volatile uint8_t *)0x1403)
36 #define IO_IRQ_ACK ((volatile uint8_t *)0x1403)
40 #define VDC_FLAG_SPRITE_COLLIDE 0x01
41 #define VDC_FLAG_SPRITE_OVERFLOW 0x02
42 #define VDC_FLAG_SCANLINE 0x04
43 #define VDC_FLAG_DMA_SATB_DONE 0x08
44 #define VDC_FLAG_DMA_DONE 0x10
45 #define VDC_FLAG_VBLANK 0x20
46 #define IO_VDC_STATUS ((volatile uint8_t *)0x0000)
47 #define IO_VDC_INDEX ((volatile uint8_t *)0x0000)
48 #define IO_VDC_DATA ((volatile uint16_t *)0x0002)
49 #define IO_VDC_DATA_LO ((volatile uint8_t *)0x0002)
50 #define IO_VDC_DATA_HI ((volatile uint8_t *)0x0003)
52 #define VDC_REG_VRAM_WRITE_ADDR 0x00
53 #define VDC_REG_VRAM_READ_ADDR 0x01
54 #define VDC_REG_VRAM_DATA 0x02
56 #define VDC_CONTROL_IRQ_SPRITE_COLLIDE 0x0001
57 #define VDC_CONTROL_IRQ_SPRITE_OVERFLOW 0x0002
58 #define VDC_CONTROL_IRQ_SCANLINE 0x0004
59 #define VDC_CONTROL_IRQ_VBLANK 0x0008
60 #define VDC_CONTROL_HSYNC_INPUT 0x0000
61 #define VDC_CONTROL_HSYNC_OUTPUT 0x0010
62 #define VDC_CONTROL_VSYNC_INPUT 0x0000
63 #define VDC_CONTROL_VSYNC_OUTPUT 0x0020
64 #define VDC_CONTROL_ENABLE_SPRITE 0x0040
65 #define VDC_CONTROL_ENABLE_BG 0x0080
66 #define VDC_CONTROL_DRAM_REFRESH 0x0400
67 #define VDC_CONTROL_VRAM_ADD_1 0x0000
68 #define VDC_CONTROL_VRAM_ADD_32 0x0800
69 #define VDC_CONTROL_VRAM_ADD_64 0x1000
70 #define VDC_CONTROL_VRAM_ADD_128 0x1800
71 #define VDC_REG_CONTROL 0x05
73 #define VDC_REG_SCANLINE 0x06
74 #define VDC_REG_BG_SCROLL_X 0x07
75 #define VDC_REG_BG_SCROLL_Y 0x08
77 #define VDC_VRAM_CYCLE_8_SLOTS 0x00
78 #define VDC_VRAM_CYCLE_4_SLOTS 0x02
79 #define VDC_VRAM_CYCLE_2_SLOTS 0x03
80 #define VDC_VRAM_CYCLE_MASK 0x03
81 #define VDC_SPRITE_CYCLE_8_SLOTS 0x00
82 #define VDC_SPRITE_CYCLE_4_SLOTS_I 0x04
83 #define VDC_SPRITE_CYCLE_4_SLOTS 0x08
84 #define VDC_SPRITE_CYCLE_2_SLOTS 0x0C
85 #define VDC_SPRITE_CYCLE_MASK 0x0C
86 #define VDC_CYCLE_8_SLOTS (VDC_VRAM_CYCLE_8_SLOTS | VDC_SPRITE_CYCLE_8_SLOTS)
87 #define VDC_CYCLE_4_SLOTS (VDC_VRAM_CYCLE_4_SLOTS | VDC_SPRITE_CYCLE_4_SLOTS)
88 #define VDC_CYCLE_MASK 0x0F
89 #define VDC_VRAM_PREFER_CG0 0x00
90 #define VDC_VRAM_PREFER_CG1 0x80
91 #define VDC_BG_WIDTH_32 (0 << 4)
92 #define VDC_BG_WIDTH_64 (1 << 4)
93 #define VDC_BG_WIDTH_128 (2 << 4)
94 #define VDC_BG_WIDTH_MASK (3 << 4)
95 #define VDC_BG_HEIGHT_32 (0 << 6)
96 #define VDC_BG_HEIGHT_64 (1 << 6)
97 #define VDC_BG_HEIGHT_MASK (1 << 6)
98 #define VDC_BG_SIZE_32_32 (VDC_BG_WIDTH_32 | VDC_BG_HEIGHT_32)
99 #define VDC_BG_SIZE_64_32 (VDC_BG_WIDTH_64 | VDC_BG_HEIGHT_32)
100 #define VDC_BG_SIZE_128_32 (VDC_BG_WIDTH_128 | VDC_BG_HEIGHT_32)
101 #define VDC_BG_SIZE_32_64 (VDC_BG_WIDTH_32 | VDC_BG_HEIGHT_64)
102 #define VDC_BG_SIZE_64_64 (VDC_BG_WIDTH_64 | VDC_BG_HEIGHT_64)
103 #define VDC_BG_SIZE_128_64 (VDC_BG_WIDTH_128 | VDC_BG_HEIGHT_64)
104 #define VDC_BG_SIZE_MASK (7 << 4)
105 #define VDC_REG_MEMORY 0x09
107 #define VDC_TIMING_WIDTH(x) (x)
108 #define VDC_TIMING_OFFSET(x) ((x) << 8)
109 #define VDC_TIMING(offset, width) \
110 (VDC_TIMING_OFFSET(offset) | VDC_TIMING_WIDTH(width))
111 #define VDC_REG_TIMING_HSYNC 0x0A
112 #define VDC_REG_TIMING_HDISP 0x0B
113 #define VDC_REG_TIMING_VSYNC 0x0C
114 #define VDC_REG_TIMING_VDISP 0x0D
115 #define VDC_REG_TIMING_VDISPEND 0x0E
117 #define VDC_DMA_IRQ_SATB_DONE 0x01
118 #define VDC_DMA_IRQ_DONE 0x02
119 #define VDC_DMA_SRC_INC 0x00
120 #define VDC_DMA_SRC_DEC 0x04
121 #define VDC_DMA_DEST_INC 0x00
122 #define VDC_DMA_DEST_DEC 0x08
123 #define VDC_DMA_REPEAT_SATB 0x10
124 #define VDC_REG_DMA_CONTROL 0x0F
126 #define VDC_REG_DMA_SRC 0x10
127 #define VDC_REG_DMA_DEST 0x11
128 #define VDC_REG_DMA_LENGTH 0x12
129 #define VDC_REG_SATB_START 0x13
133 #define VCE_PIXEL_CLOCK_5MHZ 0x00
134 #define VCE_PIXEL_CLOCK_7MHZ 0x01
135 #define VCE_PIXEL_CLOCK_10MHZ 0x02
136 #define VCE_PIXEL_CLOCK_MASK 0x03
137 #define VCE_FIELD_EVEN 0x00
138 #define VCE_FIELD_ODD 0x04
139 #define VCE_COLORBURST_ON 0x00
140 #define VCE_COLORBURST_OFF 0x80
141 #define IO_VCE_CONTROL ((volatile uint8_t *)0x0400)
143 #define IO_VCE_COLOR_INDEX ((volatile uint16_t *)0x0402)
144 #define VCE_COLOR(r, g, b) ((b) | ((r) << 3) | ((g) << 6))
145 #define IO_VCE_COLOR_DATA ((volatile uint16_t *)0x0404)
149 #define PSG_VOLUME_LEFT(x) ((x) << 4)
150 #define PSG_VOLUME_RIGHT(x) (x)
152 #define IO_PSG_CH_SELECT ((volatile uint8_t *)0x0800)
153 #define IO_PSG_VOLUME ((volatile uint8_t *)0x0801)
154 #define IO_PSG_CH_FREQ ((volatile uint16_t *)0x0802)
155 #define IO_PSG_CH_FREQ_FINE ((volatile uint8_t *)0x0802)
156 #define IO_PSG_CH_FREQ_COARSE ((volatile uint8_t *)0x0803)
158 #define PSG_CH_ON 0x80
159 #define PSG_CH_OFF 0x00
160 #define PSG_CH_DDA 0x40
161 #define PSG_CH_VOLUME(x) (x)
162 #define IO_PSG_CH_CONTROL ((volatile uint8_t *)0x0804)
163 #define IO_PSG_CH_VOLUME ((volatile uint8_t *)0x0805)
164 #define IO_PSG_CH_SAMPLE ((volatile uint8_t *)0x0806)
166 #define PSG_CH_NOISE_ON 0x80
167 #define PSG_CH_NOISE_OFF 0x00
168 #define PSG_CH_NOISE_FREQ(x) (x)
169 #define IO_PSG_CH_NOISE ((volatile uint8_t *)0x0807)
171 #define IO_PSG_CH_LFO_FREQ ((volatile uint8_t *)0x0808)
173 #define PSG_CH_LFO_ON 0x00
174 #define PSG_CH_LFO_RESET 0x80
175 #define PSG_CH_LFO_OFF 0x80
176 #define PSG_CH_LFO_MODE_ADD 0x01
177 #define PSG_CH_LFO_MODE_ADD16 0x02
178 #define PSG_CH_LFO_MODE_ADD256 0x03
179 #define IO_PSG_CH_LFO ((volatile uint8_t *)0x0809)
183 #define PCD_SCSI_INPUT 0x08
184 #define PCD_SCSI_CONTROL 0x10
185 #define PCD_SCSI_MESSAGE 0x20
186 #define PCD_SCSI_REQUEST 0x40
187 #define PCD_SCSI_BUSY 0x80
188 #define IO_PCD_SCSI_STATUS ((volatile uint8_t *)0x1800)
189 #define IO_PCD_SCSI_SELECT ((volatile uint8_t *)0x1800)
190 #define IO_PCD_SCSI_DATA ((volatile uint8_t *)0x1801)
191 #define IO_PCD_CONTROL ((volatile uint8_t *)0x1802)
192 #define IO_PCD_STATUS ((volatile uint8_t *)0x1803)
193 #define IO_PCD_SCSI_RESET ((volatile uint8_t *)0x1804)
194 #define IO_PCD_CDDA_SAMPLE_LO ((volatile uint8_t *)0x1805)
195 #define IO_PCD_CDDA_SAMPLE_HI ((volatile uint8_t *)0x1806)
197 #define PCD_BRAM_UNLOCK 0x80
198 #define IO_PCD_BRAM_CONTROL ((volatile uint8_t *)0x1807)
200 #define IO_PCD_ADPCM_ADDR_LO ((volatile uint8_t *)0x1808)
201 #define IO_PCD_ADPCM_ADDR_HI ((volatile uint8_t *)0x1809)
202 #define IO_PCD_ADPCM_DATA ((volatile uint8_t *)0x180A)
203 #define IO_PCD_ADPCM_DMA_CONTROL ((volatile uint8_t *)0x180B)
204 #define IO_PCD_ADPCM_STATUS ((volatile uint8_t *)0x180C)
206 #define PCD_ADPCM_WRITE_OFFSET 0x01
207 #define PCD_ADPCM_WRITE_LATCH 0x02
208 #define PCD_ADPCM_READ_OFFSET 0x04
209 #define PCD_ADPCM_READ_LATCH 0x08
210 #define PCD_ADPCM_LENGTH_LATCH 0x10
211 #define PCD_ADPCM_PLAY 0x20
212 #define PCD_ADPCM_REPEAT 0x00
213 #define PCD_ADPCM_ONE_SHOT 0x40
214 #define PCD_ADPCM_RESET 0x80
215 #define IO_PCD_ADPCM_CONTROL ((volatile uint8_t *)0x180D)
216 #define IO_PCD_ADPCM_DIVIDER ((volatile uint8_t *)0x180E)
218 #define PCD_FADER_MODE_CDDA 0x00
219 #define PCD_FADER_MODE_ADPCM 0x02
220 #define PCD_FADER_DURATION_6_SEC 0x00
221 #define PCD_FADER_DURATION_2_5_SEC 0x04
222 #define PCD_FADER_ON 0x08
223 #define PCD_FADER_OFF 0x00
224 #define IO_PCD_FADER ((volatile uint8_t *)0x180F)
228 #define AC_RAM_USE_INCR 0x01
229 #define AC_RAM_USE_OFFSET 0x02
230 #define AC_RAM_INCR_NEGATIVE 0x04
231 #define AC_RAM_INCR_POSITIVE 0x00
232 #define AC_RAM_OFFSET_NEGATIVE 0x08
233 #define AC_RAM_OFFSET_POSITIVE 0x00
234 #define AC_RAM_INCR_BASE 0x10
235 #define AC_RAM_INCR_OFFSET 0x00
236 #define AC_RAM_ADD_OFFSET_ON_LO 0x20
237 #define AC_RAM_ADD_OFFSET_ON_HI 0x40
238 #define AC_RAM_ADD_OFFSET_ON_ANY 0x60
240 #define IO_AC_RAM_PAGES 4
241 #define IO_AC_RAM_PORT0(page) ((volatile uint8_t *)(0x1A00 + (page)))
242 #define IO_AC_RAM_PORT1(page) ((volatile uint8_t *)(0x1A01 + (page)))
243 #define IO_AC_RAM_BASE(page) ((volatile uint16_t *)(0x1A02 + (page)))
244 #define IO_AC_RAM_BASE_LO(page) ((volatile uint8_t *)(0x1A02 + (page)))
245 #define IO_AC_RAM_BASE_MED(page) ((volatile uint8_t *)(0x1A03 + (page)))
246 #define IO_AC_RAM_BASE_HI(page) ((volatile uint8_t *)(0x1A04 + (page)))
247 #define IO_AC_RAM_OFFSET(page) ((volatile uint8_t *)(0x1A05 + (page)))
248 #define IO_AC_RAM_INCR(page) ((volatile uint16_t *)(0x1A07 + (page)))
249 #define IO_AC_RAM_CONTROL(page) ((volatile uint8_t *)(0x1A09 + (page)))
250 #define IO_AC_RAM_MANUAL(page) ((volatile uint8_t *)(0x1A0A + (page)))
252 #define IO_AC_RAM0_PORT0 IO_AC_RAM_PORT0(0)
253 #define IO_AC_RAM0_PORT1 IO_AC_RAM_PORT1(0)
254 #define IO_AC_RAM0_BASE IO_AC_RAM_BASE(0)
255 #define IO_AC_RAM0_BASE_LO IO_AC_RAM_BASE_LO(0)
256 #define IO_AC_RAM0_BASE_MED IO_AC_RAM_BASE_MED(0)
257 #define IO_AC_RAM0_BASE_HI IO_AC_RAM_BASE_HI(0)
258 #define IO_AC_RAM0_OFFSET IO_AC_RAM_OFFSET(0)
259 #define IO_AC_RAM0_INCR IO_AC_RAM_INCR(0)
260 #define IO_AC_RAM0_CONTROL IO_AC_RAM_CONTROL(0)
261 #define IO_AC_RAM0_MANUAL IO_AC_RAM_MANUAL(0)
263 #define IO_AC_RAM1_PORT0 IO_AC_RAM_PORT0(1)
264 #define IO_AC_RAM1_PORT1 IO_AC_RAM_PORT1(1)
265 #define IO_AC_RAM1_BASE IO_AC_RAM_BASE(1)
266 #define IO_AC_RAM1_BASE_LO IO_AC_RAM_BASE_LO(1)
267 #define IO_AC_RAM1_BASE_MED IO_AC_RAM_BASE_MED(1)
268 #define IO_AC_RAM1_BASE_HI IO_AC_RAM_BASE_HI(1)
269 #define IO_AC_RAM1_OFFSET IO_AC_RAM_OFFSET(1)
270 #define IO_AC_RAM1_INCR IO_AC_RAM_INCR(1)
271 #define IO_AC_RAM1_CONTROL IO_AC_RAM_CONTROL(1)
272 #define IO_AC_RAM1_MANUAL IO_AC_RAM_MANUAL(1)
274 #define IO_AC_RAM2_PORT0 IO_AC_RAM_PORT0(2)
275 #define IO_AC_RAM2_PORT1 IO_AC_RAM_PORT1(2)
276 #define IO_AC_RAM2_BASE IO_AC_RAM_BASE(2)
277 #define IO_AC_RAM2_BASE_LO IO_AC_RAM_BASE_LO(2)
278 #define IO_AC_RAM2_BASE_MED IO_AC_RAM_BASE_MED(2)
279 #define IO_AC_RAM2_BASE_HI IO_AC_RAM_BASE_HI(2)
280 #define IO_AC_RAM2_OFFSET IO_AC_RAM_OFFSET(2)
281 #define IO_AC_RAM2_INCR IO_AC_RAM_INCR(2)
282 #define IO_AC_RAM2_CONTROL IO_AC_RAM_CONTROL(2)
283 #define IO_AC_RAM2_MANUAL IO_AC_RAM_MANUAL(2)
285 #define IO_AC_RAM3_PORT0 IO_AC_RAM_PORT0(3)
286 #define IO_AC_RAM3_PORT1 IO_AC_RAM_PORT1(3)
287 #define IO_AC_RAM3_BASE IO_AC_RAM_BASE(3)
288 #define IO_AC_RAM3_BASE_LO IO_AC_RAM_BASE_LO(3)
289 #define IO_AC_RAM3_BASE_MED IO_AC_RAM_BASE_MED(3)
290 #define IO_AC_RAM3_BASE_HI IO_AC_RAM_BASE_HI(3)
291 #define IO_AC_RAM3_OFFSET IO_AC_RAM_OFFSET(3)
292 #define IO_AC_RAM3_INCR IO_AC_RAM_INCR(3)
293 #define IO_AC_RAM3_CONTROL IO_AC_RAM_CONTROL(3)
294 #define IO_AC_RAM3_MANUAL IO_AC_RAM_MANUAL(3)
296 #define IO_AC_ALU_VALUE ((volatile uint32_t *)0x1AE0)
297 #define IO_AC_ALU_VALUE0 ((volatile uint8_t *)0x1AE0)
298 #define IO_AC_ALU_VALUE1 ((volatile uint8_t *)0x1AE1)
299 #define IO_AC_ALU_VALUE2 ((volatile uint8_t *)0x1AE2)
300 #define IO_AC_ALU_VALUE3 ((volatile uint8_t *)0x1AE3)
301 #define IO_AC_ALU_SHIFT ((volatile uint8_t *)0x1AE4)
302 #define IO_AC_ALU_ROTATE ((volatile uint8_t *)0x1AE5)
303 #define IO_AC_VERSION ((volatile uint16_t *)0x1AFD)
304 #define IO_AC_VERSION_MINOR ((volatile uint8_t *)0x1AFD)
305 #define IO_AC_VERSION_MAJOR ((volatile uint8_t *)0x1AFE)
306 #define AC_ID_VALUE 0x51
307 #define IO_AC_ID ((volatile uint8_t *)0x1AFF)
311 #define IO_SSC_REGION1 ((volatile uint8_t *)0x18C5)
312 #define IO_SSC_REGION2 ((volatile uint8_t *)0x18C6)
313 #define IO_SSC_RAM_SIZE ((volatile uint8_t *)0x18C7)
317 #define IO_VDC1_STATUS ((volatile uint8_t *)0x0000)
318 #define IO_VDC1_INDEX ((volatile uint8_t *)0x0000)
319 #define IO_VDC1_DATA ((volatile uint16_t *)0x0002)
320 #define IO_VDC1_DATA_LO ((volatile uint8_t *)0x0002)
321 #define IO_VDC1_DATA_HI ((volatile uint8_t *)0x0003)
322 #define IO_VDC2_STATUS ((volatile uint8_t *)0x0010)
323 #define IO_VDC2_INDEX ((volatile uint8_t *)0x0010)
324 #define IO_VDC2_DATA ((volatile uint16_t *)0x0012)
325 #define IO_VDC2_DATA_LO ((volatile uint8_t *)0x0012)
326 #define IO_VDC2_DATA_HI ((volatile uint8_t *)0x0013)
328 #define VPC_WINDOW_OVERLAP 0
329 #define VPC_WINDOW_2 4
330 #define VPC_WINDOW_1 8
331 #define VPC_WINDOW_NONE 12
332 #define VPC_VDC1_ENABLE(window) (0x1 << (window))
333 #define VPC_VDC2_ENABLE(window) (0x2 << (window))
334 #define VPC_PRIORITY_DEFAULT(window) \
337 #define VPC_PRIORITY_SP1_BG2(window) (0x4 << (window))
338 #define VPC_PRIORITY_BG1_SP2(window) (0x8 << (window))
339 #define VPC_PRIORITY_MASK(window) (0xC << (window))
340 #define VPC_MASK(window) (0xF << (window))
341 #define IO_VPC_CONTROL ((volatile uint16_t *)0x0008)
342 #define IO_VPC_CONTROL_LO ((volatile uint8_t *)0x0008)
343 #define IO_VPC_CONTROL_HI ((volatile uint8_t *)0x0009)
344 #define IO_VPC_WINDOW_1 ((volatile uint16_t *)0x000A)
345 #define IO_VPC_WINDOW_2 ((volatile uint16_t *)0x000C)
347 #define VPC_PORT_VDP1 0x00
348 #define VPC_PORT_VDP2 0x01
349 #define IO_VPC_PORT ((volatile uint16_t *)0x000E)