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