Add store callbacks
Jeffrey Pfau jeffrey@endrift.com
Sat, 06 Apr 2013 04:20:44 -0700
M
src/gba.c
→
src/gba.c
@@ -4,6 +4,7 @@ #include <sys/mman.h>
void GBAInit(struct GBA* gba) { ARMInit(&gba->cpu); + gba->memory.p = gba; GBAMemoryInit(&gba->memory); }@@ -17,6 +18,9 @@ memory->d.load16 = GBALoad16;
memory->d.loadU16 = GBALoadU16; memory->d.load8 = GBALoad8; memory->d.loadU8 = GBALoadU8; + memory->d.store32 = GBAStore32; + memory->d.store16 = GBAStore16; + memory->d.store8 = GBAStore8; memory->bios = 0; memory->wram = mmap(0, SIZE_WORKING_RAM, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);@@ -197,4 +201,85 @@ break;
} return 0; +} + +void GBAStore32(struct ARMMemory* memory, uint32_t address, int32_t value) { + struct GBAMemory* gbaMemory = (struct GBAMemory*) memory; + + switch (address & OFFSET_MASK) { + case REGION_WORKING_RAM: + break; + case REGION_WORKING_IRAM: + break; + case REGION_IO: + break; + case REGION_PALETTE_RAM: + break; + case REGION_VRAM: + break; + case REGION_OAM: + break; + case REGION_CART0: + break; + case REGION_CART2_EX: + break; + case REGION_CART_SRAM: + break; + default: + break; + } +} + +void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value) { + struct GBAMemory* gbaMemory = (struct GBAMemory*) memory; + + switch (address & OFFSET_MASK) { + case REGION_WORKING_RAM: + break; + case REGION_WORKING_IRAM: + break; + case REGION_IO: + break; + case REGION_PALETTE_RAM: + break; + case REGION_VRAM: + break; + case REGION_OAM: + break; + case REGION_CART0: + break; + case REGION_CART2_EX: + break; + case REGION_CART_SRAM: + break; + default: + break; + } +} + +void GBAStore8(struct ARMMemory* memory, uint32_t address, int8_t value) { + struct GBAMemory* gbaMemory = (struct GBAMemory*) memory; + + switch (address & OFFSET_MASK) { + case REGION_WORKING_RAM: + break; + case REGION_WORKING_IRAM: + break; + case REGION_IO: + break; + case REGION_PALETTE_RAM: + break; + case REGION_VRAM: + break; + case REGION_OAM: + break; + case REGION_CART0: + break; + case REGION_CART2_EX: + break; + case REGION_CART_SRAM: + break; + default: + break; + } }
M
src/gba.h
→
src/gba.h
@@ -43,6 +43,7 @@ };
struct GBAMemory { struct ARMMemory d; + struct GBA* p; int32_t* bios; int32_t* wram;@@ -71,5 +72,9 @@ int16_t GBALoad16(struct ARMMemory* memory, uint32_t address);
uint16_t GBALoadU16(struct ARMMemory* memory, uint32_t address); int8_t GBALoad8(struct ARMMemory* memory, uint32_t address); uint8_t GBALoadU8(struct ARMMemory* memory, uint32_t address); + +void GBAStore32(struct ARMMemory* memory, uint32_t address, int32_t value); +void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value); +void GBAStore8(struct ARMMemory* memory, uint32_t address, int8_t value); #endif