all repos — mgba @ a01fc986a34e6f0f32aa91640c0f673d2332cb28

mGBA Game Boy Advance Emulator

src/gba.h (view raw)

 1#ifndef GBA_MEMORY_H
 2#define GBA_MEMORY_H
 3
 4#include "arm.h"
 5
 6enum GBAMemoryRegion {
 7	REGION_BIOS = 0x0,
 8	REGION_WORKING_RAM = 0x2,
 9	REGION_WORKING_IRAM = 0x3,
10	REGION_IO = 0x4,
11	REGION_PALETTE_RAM = 0x5,
12	REGION_VRAM = 0x6,
13	REGION_OAM = 0x7,
14	REGION_CART0 = 0x8,
15	REGION_CART0_EX = 0x9,
16	REGION_CART1 = 0xA,
17	REGION_CART1_EX = 0xB,
18	REGION_CART2 = 0xC,
19	REGION_CART2_EX = 0xD,
20	REGION_CART_SRAM = 0xE
21};
22
23enum {
24	SIZE_BIOS = 0x00004000,
25	SIZE_WORKING_RAM = 0x00040000,
26	SIZE_WORKING_IRAM = 0x00008000,
27	SIZE_IO = 0x00000400,
28	SIZE_PALETTE_RAM = 0x00000400,
29	SIZE_VRAM = 0x00018000,
30	SIZE_OAM = 0x00000400,
31	SIZE_CART0 = 0x02000000,
32	SIZE_CART1 = 0x02000000,
33	SIZE_CART2 = 0x02000000,
34	SIZE_CART_SRAM = 0x00008000,
35	SIZE_CART_FLASH512 = 0x00010000,
36	SIZE_CART_FLASH1M = 0x00020000,
37	SIZE_CART_EEPROM = 0x00002000
38};
39
40enum {
41	OFFSET_MASK = 0x00FFFFFF
42};
43
44struct GBAMemory {
45	struct ARMMemory d;
46
47	int32_t* bios;
48	int32_t* wram;
49	int32_t* iwram;
50	int32_t* rom;
51};
52
53struct GBABoard {
54	struct ARMBoard board;
55};
56
57struct GBA {
58	struct ARMCore cpu;
59	struct GBABoard board;
60	struct GBAMemory memory;
61};
62
63void GBAInit(struct GBA* gba);
64void GBADeinit(struct GBA* gba);
65
66void GBAMemoryInit(struct GBAMemory* memory);
67void GBAMemoryDeinit(struct GBAMemory* memory);
68
69int32_t GBALoad32(struct ARMMemory* memory, uint32_t address);
70int16_t GBALoad16(struct ARMMemory* memory, uint32_t address);
71uint16_t GBALoadU16(struct ARMMemory* memory, uint32_t address);
72int8_t GBALoad8(struct ARMMemory* memory, uint32_t address);
73uint8_t GBALoadU8(struct ARMMemory* memory, uint32_t address);
74
75#endif