src/gba/gba-io.h (view raw)
1#ifndef GBA_IO_H
2#define GBA_IO_H
3
4#include "gba.h"
5
6enum GBAIORegisters {
7 REG_DISPCNT = 0x000,
8 REG_GREENSWP = 0x002,
9 REG_DISPSTAT = 0x004,
10 REG_VCOUNT = 0x006,
11 REG_BG0CNT = 0x008,
12 REG_BG1CNT = 0x00A,
13 REG_BG2CNT = 0x00C,
14 REG_BG3CNT = 0x00E,
15 REG_BG0HOFS = 0x010,
16 REG_BG0VOFS = 0x012,
17 REG_BG1HOFS = 0x014,
18 REG_BG1VOFS = 0x016,
19 REG_BG2HOFS = 0x018,
20 REG_BG2VOFS = 0x01A,
21 REG_BG3HOFS = 0x01C,
22 REG_BG3VOFS = 0x01E,
23 REG_BG2PA = 0x020,
24 REG_BG2PB = 0x022,
25 REG_BG2PC = 0x024,
26 REG_BG2PD = 0x026,
27 REG_BG2X_LO = 0x028,
28 REG_BG2X_HI = 0x02A,
29 REG_BG2Y_LO = 0x02C,
30 REG_BG2Y_HI = 0x02E,
31 REG_BG3PA = 0x030,
32 REG_BG3PB = 0x032,
33 REG_BG3PC = 0x034,
34 REG_BG3PD = 0x036,
35 REG_BG3X_LO = 0x038,
36 REG_BG3X_HI = 0x03A,
37 REG_BG3Y_LO = 0x03C,
38 REG_BG3Y_HI = 0x03E,
39 REG_WIN0H = 0x040,
40 REG_WIN1H = 0x042,
41 REG_WIN0V = 0x044,
42 REG_WIN1V = 0x046,
43 REG_WININ = 0x048,
44 REG_WINOUT = 0x04A,
45 REG_MOSAIC = 0x04C,
46 REG_BLDCNT = 0x050,
47 REG_BLDALPHA = 0x052,
48 REG_BLDY = 0x054,
49
50 // Sound
51 REG_SOUND1CNT_LO = 0x060,
52 REG_SOUND1CNT_HI = 0x062,
53 REG_SOUND1CNT_X = 0x064,
54 REG_SOUND2CNT_LO = 0x068,
55 REG_SOUND2CNT_HI = 0x06C,
56 REG_SOUND3CNT_LO = 0x070,
57 REG_SOUND3CNT_HI = 0x072,
58 REG_SOUND3CNT_X = 0x074,
59 REG_SOUND4CNT_LO = 0x078,
60 REG_SOUND4CNT_HI = 0x07C,
61 REG_SOUNDCNT_LO = 0x080,
62 REG_SOUNDCNT_HI = 0x082,
63 REG_SOUNDCNT_X = 0x084,
64 REG_SOUNDBIAS = 0x088,
65 REG_WAVE_RAM0_LO = 0x090,
66 REG_WAVE_RAM0_HI = 0x092,
67 REG_WAVE_RAM1_LO = 0x094,
68 REG_WAVE_RAM1_HI = 0x096,
69 REG_WAVE_RAM2_LO = 0x098,
70 REG_WAVE_RAM2_HI = 0x09A,
71 REG_WAVE_RAM3_LO = 0x09C,
72 REG_WAVE_RAM3_HI = 0x09E,
73 REG_FIFO_A_LO = 0x0A0,
74 REG_FIFO_A_HI = 0x0A2,
75 REG_FIFO_B_LO = 0x0A4,
76 REG_FIFO_B_HI = 0x0A6,
77
78 // DMA
79 REG_DMA0SAD_LO = 0x0B0,
80 REG_DMA0SAD_HI = 0x0B2,
81 REG_DMA0DAD_LO = 0x0B4,
82 REG_DMA0DAD_HI = 0x0B6,
83 REG_DMA0CNT_LO = 0x0B8,
84 REG_DMA0CNT_HI = 0x0BA,
85 REG_DMA1SAD_LO = 0x0BC,
86 REG_DMA1SAD_HI = 0x0BE,
87 REG_DMA1DAD_LO = 0x0C0,
88 REG_DMA1DAD_HI = 0x0C2,
89 REG_DMA1CNT_LO = 0x0C4,
90 REG_DMA1CNT_HI = 0x0C6,
91 REG_DMA2SAD_LO = 0x0C8,
92 REG_DMA2SAD_HI = 0x0CA,
93 REG_DMA2DAD_LO = 0x0CC,
94 REG_DMA2DAD_HI = 0x0CE,
95 REG_DMA2CNT_LO = 0x0D0,
96 REG_DMA2CNT_HI = 0x0D2,
97 REG_DMA3SAD_LO = 0x0D4,
98 REG_DMA3SAD_HI = 0x0D6,
99 REG_DMA3DAD_LO = 0x0D8,
100 REG_DMA3DAD_HI = 0x0DA,
101 REG_DMA3CNT_LO = 0x0DC,
102 REG_DMA3CNT_HI = 0x0DE,
103
104 // Timers
105 REG_TM0CNT_LO = 0x100,
106 REG_TM0CNT_HI = 0x102,
107 REG_TM1CNT_LO = 0x104,
108 REG_TM1CNT_HI = 0x106,
109 REG_TM2CNT_LO = 0x108,
110 REG_TM2CNT_HI = 0x10A,
111 REG_TM3CNT_LO = 0x10C,
112 REG_TM3CNT_HI = 0x10E,
113
114 // SIO (note: some of these are repeated)
115 REG_SIODATA32_LO = 0x120,
116 REG_SIOMULTI0 = 0x120,
117 REG_SIODATA32_HI = 0x122,
118 REG_SIOMULTI1 = 0x122,
119 REG_SIOMULTI2 = 0x124,
120 REG_SIOMULTI3 = 0x126,
121 REG_SIOCNT = 0x128,
122 REG_SIOMLT_SEND = 0x12A,
123 REG_SIODATA8 = 0x12A,
124 REG_RCNT = 0x134,
125 REG_JOYCNT = 0x140,
126 REG_JOY_RECV = 0x150,
127 REG_JOY_TRANS = 0x154,
128 REG_JOYSTAT = 0x158,
129
130 // Keypad
131 REG_KEYINPUT = 0x130,
132 REG_KEYCNT = 0x132,
133
134 // Interrupts, etc
135 REG_IE = 0x200,
136 REG_IF = 0x202,
137 REG_WAITCNT = 0x204,
138 REG_IME = 0x208,
139
140 REG_POSTFLG = 0x300,
141 REG_HALTCNT = 0x301
142};
143
144void GBAIOInit(struct GBA* gba);
145void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value);
146void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value);
147uint16_t GBAIORead(struct GBA* gba, uint32_t address);
148
149#endif