src/gba/gba.h (view raw)
1#ifndef GBA_H
2#define GBA_H
3
4#include "arm.h"
5
6#include "gba-memory.h"
7#include "gba-video.h"
8
9enum GBAIRQ {
10 IRQ_VBLANK = 0x0,
11 IRQ_HBLANK = 0x1,
12 IRQ_VCOUNTER = 0x2,
13 IRQ_TIMER0 = 0x3,
14 IRQ_TIMER1 = 0x4,
15 IRQ_TIMER2 = 0x5,
16 IRQ_TIMER3 = 0x6,
17 IRQ_SIO = 0x7,
18 IRQ_DMA0 = 0x8,
19 IRQ_DMA1 = 0x9,
20 IRQ_DMA2 = 0xA,
21 IRQ_DMA3 = 0xB,
22 IRQ_KEYPAD = 0xC,
23 IRQ_GAMEPAK = 0xD
24};
25
26enum GBAError {
27 GBA_NO_ERROR = 0,
28 GBA_OUT_OF_MEMORY = -1
29};
30
31enum GBALogLevel {
32 GBA_LOG_STUB
33};
34
35struct GBABoard {
36 struct ARMBoard d;
37 struct GBA* p;
38};
39
40struct GBA {
41 struct ARMCore cpu;
42 struct GBABoard board;
43 struct GBAMemory memory;
44 struct GBAVideo video;
45
46 struct ARMDebugger* debugger;
47
48 int springIRQ;
49
50 enum GBAError errno;
51 const char* errstr;
52};
53
54void GBAInit(struct GBA* gba);
55void GBADeinit(struct GBA* gba);
56
57void GBAMemoryInit(struct GBAMemory* memory);
58void GBAMemoryDeinit(struct GBAMemory* memory);
59
60void GBABoardInit(struct GBABoard* board);
61void GBABoardReset(struct ARMBoard* board);
62
63void GBAWriteIE(struct GBA* gba, uint16_t value);
64void GBAWriteIME(struct GBA* gba, uint16_t value);
65void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq);
66void GBAPollNextEvent(struct GBA* gba);
67int GBATestIRQ(struct GBA* gba);
68int GBAWaitForIRQ(struct GBA* gba);
69
70void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);
71
72void GBALoadROM(struct GBA* gba, int fd);
73
74void GBALog(int level, const char* format, ...);
75
76#endif