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