all repos — mgba @ 6608ae282c7830f3a8b13853405b753bc162ad7a

mGBA Game Boy Advance Emulator

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	GBA_LOG_WARN
34};
35
36struct GBABoard {
37	struct ARMBoard d;
38	struct GBA* p;
39};
40
41struct GBA {
42	struct ARMCore cpu;
43	struct GBABoard board;
44	struct GBAMemory memory;
45	struct GBAVideo video;
46
47	struct ARMDebugger* debugger;
48
49	int springIRQ;
50
51	enum GBAError errno;
52	const char* errstr;
53};
54
55void GBAInit(struct GBA* gba);
56void GBADeinit(struct GBA* gba);
57
58void GBAMemoryInit(struct GBAMemory* memory);
59void GBAMemoryDeinit(struct GBAMemory* memory);
60
61void GBABoardInit(struct GBABoard* board);
62void GBABoardReset(struct ARMBoard* board);
63
64void GBAWriteIE(struct GBA* gba, uint16_t value);
65void GBAWriteIME(struct GBA* gba, uint16_t value);
66void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq);
67int GBATestIRQ(struct GBA* gba);
68int GBAWaitForIRQ(struct GBA* gba);
69int GBAHalt(struct GBA* gba);
70
71void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);
72
73void GBALoadROM(struct GBA* gba, int fd);
74
75void GBALog(int level, const char* format, ...);
76
77#endif