GBA Memory: Modernize constant names

This commit is contained in:
Vicki Pfau 2023-01-26 18:59:35 -08:00
parent 6b63e42146
commit 8545271e9e
31 changed files with 882 additions and 882 deletions

View File

@ -21,60 +21,60 @@ CXX_GUARD_START
#include <mgba/internal/gba/cart/vfame.h>
enum GBAMemoryRegion {
REGION_BIOS = 0x0,
REGION_WORKING_RAM = 0x2,
REGION_WORKING_IRAM = 0x3,
REGION_IO = 0x4,
REGION_PALETTE_RAM = 0x5,
REGION_VRAM = 0x6,
REGION_OAM = 0x7,
REGION_CART0 = 0x8,
REGION_CART0_EX = 0x9,
REGION_CART1 = 0xA,
REGION_CART1_EX = 0xB,
REGION_CART2 = 0xC,
REGION_CART2_EX = 0xD,
REGION_CART_SRAM = 0xE,
REGION_CART_SRAM_MIRROR = 0xF
GBA_REGION_BIOS = 0x0,
GBA_REGION_EWRAM = 0x2,
GBA_REGION_IWRAM = 0x3,
GBA_REGION_IO = 0x4,
GBA_REGION_PALETTE_RAM = 0x5,
GBA_REGION_VRAM = 0x6,
GBA_REGION_OAM = 0x7,
GBA_REGION_ROM0 = 0x8,
GBA_REGION_ROM0_EX = 0x9,
GBA_REGION_ROM1 = 0xA,
GBA_REGION_ROM1_EX = 0xB,
GBA_REGION_ROM2 = 0xC,
GBA_REGION_ROM2_EX = 0xD,
GBA_REGION_SRAM = 0xE,
GBA_REGION_SRAM_MIRROR = 0xF
};
enum GBAMemoryBase {
BASE_BIOS = 0x00000000,
BASE_WORKING_RAM = 0x02000000,
BASE_WORKING_IRAM = 0x03000000,
BASE_IO = 0x04000000,
BASE_PALETTE_RAM = 0x05000000,
BASE_VRAM = 0x06000000,
BASE_OAM = 0x07000000,
BASE_CART0 = 0x08000000,
BASE_CART0_EX = 0x09000000,
BASE_CART1 = 0x0A000000,
BASE_CART1_EX = 0x0B000000,
BASE_CART2 = 0x0C000000,
BASE_CART2_EX = 0x0D000000,
BASE_CART_SRAM = 0x0E000000,
BASE_CART_SRAM_MIRROR = 0x0F000000
GBA_BASE_BIOS = 0x00000000,
GBA_BASE_EWRAM = 0x02000000,
GBA_BASE_IWRAM = 0x03000000,
GBA_BASE_IO = 0x04000000,
GBA_BASE_PALETTE_RAM = 0x05000000,
GBA_BASE_VRAM = 0x06000000,
GBA_BASE_OAM = 0x07000000,
GBA_BASE_ROM0 = 0x08000000,
GBA_BASE_ROM0_EX = 0x09000000,
GBA_BASE_ROM1 = 0x0A000000,
GBA_BASE_ROM1_EX = 0x0B000000,
GBA_BASE_ROM2 = 0x0C000000,
GBA_BASE_ROM2_EX = 0x0D000000,
GBA_BASE_SRAM = 0x0E000000,
GBA_BASE_SRAM_MIRROR = 0x0F000000
};
enum {
SIZE_BIOS = 0x00004000,
SIZE_WORKING_RAM = 0x00040000,
SIZE_WORKING_IRAM = 0x00008000,
SIZE_IO = 0x00000400,
SIZE_PALETTE_RAM = 0x00000400,
SIZE_VRAM = 0x00018000,
SIZE_OAM = 0x00000400,
SIZE_CART0 = 0x02000000,
SIZE_CART1 = 0x02000000,
SIZE_CART2 = 0x02000000,
SIZE_CART_SRAM = 0x00008000,
SIZE_CART_SRAM512 = 0x00010000,
SIZE_CART_FLASH512 = 0x00010000,
SIZE_CART_FLASH1M = 0x00020000,
SIZE_CART_EEPROM = 0x00002000,
SIZE_CART_EEPROM512 = 0x00000200,
GBA_SIZE_BIOS = 0x00004000,
GBA_SIZE_EWRAM = 0x00040000,
GBA_SIZE_IWRAM = 0x00008000,
GBA_SIZE_IO = 0x00000400,
GBA_SIZE_PALETTE_RAM = 0x00000400,
GBA_SIZE_VRAM = 0x00018000,
GBA_SIZE_OAM = 0x00000400,
GBA_SIZE_ROM0 = 0x02000000,
GBA_SIZE_ROM1 = 0x02000000,
GBA_SIZE_ROM2 = 0x02000000,
GBA_SIZE_SRAM = 0x00008000,
GBA_SIZE_SRAM512 = 0x00010000,
GBA_SIZE_FLASH512 = 0x00010000,
GBA_SIZE_FLASH1M = 0x00020000,
GBA_SIZE_EEPROM = 0x00002000,
GBA_SIZE_EEPROM512 = 0x00000200,
SIZE_AGB_PRINT = 0x10000
GBA_SIZE_AGB_PRINT = 0x10000
};
enum {

View File

@ -407,12 +407,12 @@ struct GBASerializedState {
uint32_t reserved[12];
uint16_t io[SIZE_IO >> 1];
uint16_t pram[SIZE_PALETTE_RAM >> 1];
uint16_t oam[SIZE_OAM >> 1];
uint16_t vram[SIZE_VRAM >> 1];
uint8_t iwram[SIZE_WORKING_IRAM];
uint8_t wram[SIZE_WORKING_RAM];
uint16_t io[GBA_SIZE_IO >> 1];
uint16_t pram[GBA_SIZE_PALETTE_RAM >> 1];
uint16_t oam[GBA_SIZE_OAM >> 1];
uint16_t vram[GBA_SIZE_VRAM >> 1];
uint8_t iwram[GBA_SIZE_IWRAM];
uint8_t wram[GBA_SIZE_EWRAM];
};
static_assert(sizeof(struct GBASerializedState) == 0x61000, "GBA savestate struct sized wrong");

View File

@ -17,7 +17,7 @@
#ifdef M_CORE_GBA
#include <mgba/internal/gba/memory.h>
#define TEST_PLATFORM mPLATFORM_GBA
#define RAM_BASE BASE_WORKING_IRAM
#define RAM_BASE GBA_BASE_IWRAM
#elif defined(M_CORE_GB)
#include <mgba/internal/gb/memory.h>
#define TEST_PLATFORM mPLATFORM_GB

View File

@ -118,10 +118,10 @@ void GBAAudioScheduleFifoDma(struct GBAAudio* audio, int number, struct GBADMA*
info->reg = GBADMARegisterSetDestControl(info->reg, GBA_DMA_FIXED);
info->reg = GBADMARegisterSetWidth(info->reg, 1);
switch (info->dest) {
case BASE_IO | REG_FIFO_A_LO:
case GBA_BASE_IO | REG_FIFO_A_LO:
audio->chA.dmaSource = number;
break;
case BASE_IO | REG_FIFO_B_LO:
case GBA_BASE_IO | REG_FIFO_B_LO:
audio->chB.dmaSource = number;
break;
default:

View File

@ -49,11 +49,11 @@ static void _SoftReset(struct GBA* gba) {
cpu->gprs[ARM_LR] = 0;
cpu->gprs[ARM_SP] = GBA_SP_BASE_SYSTEM;
int8_t flag = ((int8_t*) gba->memory.iwram)[0x7FFA];
memset(((int8_t*) gba->memory.iwram) + SIZE_WORKING_IRAM - 0x200, 0, 0x200);
memset(((int8_t*) gba->memory.iwram) + GBA_SIZE_IWRAM - 0x200, 0, 0x200);
if (flag) {
cpu->gprs[ARM_PC] = BASE_WORKING_RAM;
cpu->gprs[ARM_PC] = GBA_BASE_EWRAM;
} else {
cpu->gprs[ARM_PC] = BASE_CART0;
cpu->gprs[ARM_PC] = GBA_BASE_ROM0;
}
_ARMSetMode(cpu, MODE_ARM);
ARMWritePC(cpu);
@ -62,120 +62,120 @@ static void _SoftReset(struct GBA* gba) {
static void _RegisterRamReset(struct GBA* gba) {
uint32_t registers = gba->cpu->gprs[0];
struct ARMCore* cpu = gba->cpu;
cpu->memory.store16(cpu, BASE_IO | REG_DISPCNT, 0x0080, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DISPCNT, 0x0080, 0);
if (registers & 0x01) {
memset(gba->memory.wram, 0, SIZE_WORKING_RAM);
memset(gba->memory.wram, 0, GBA_SIZE_EWRAM);
}
if (registers & 0x02) {
memset(gba->memory.iwram, 0, SIZE_WORKING_IRAM - 0x200);
memset(gba->memory.iwram, 0, GBA_SIZE_IWRAM - 0x200);
}
if (registers & 0x04) {
memset(gba->video.palette, 0, SIZE_PALETTE_RAM);
memset(gba->video.palette, 0, GBA_SIZE_PALETTE_RAM);
}
if (registers & 0x08) {
memset(gba->video.vram, 0, SIZE_VRAM);
memset(gba->video.vram, 0, GBA_SIZE_VRAM);
}
if (registers & 0x10) {
memset(gba->video.oam.raw, 0, SIZE_OAM);
memset(gba->video.oam.raw, 0, GBA_SIZE_OAM);
}
if (registers & 0x20) {
cpu->memory.store16(cpu, BASE_IO | REG_SIOCNT, 0x0000, 0);
cpu->memory.store16(cpu, BASE_IO | REG_RCNT, RCNT_INITIAL, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SIOMLT_SEND, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_JOYCNT, 0, 0);
cpu->memory.store32(cpu, BASE_IO | REG_JOY_RECV_LO, 0, 0);
cpu->memory.store32(cpu, BASE_IO | REG_JOY_TRANS_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SIOCNT, 0x0000, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_RCNT, RCNT_INITIAL, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SIOMLT_SEND, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_JOYCNT, 0, 0);
cpu->memory.store32(cpu, GBA_BASE_IO | REG_JOY_RECV_LO, 0, 0);
cpu->memory.store32(cpu, GBA_BASE_IO | REG_JOY_TRANS_LO, 0, 0);
}
if (registers & 0x40) {
cpu->memory.store16(cpu, BASE_IO | REG_SOUND1CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND1CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND1CNT_X, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND2CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND2CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND3CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND3CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND3CNT_X, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND4CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUND4CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUNDCNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUNDCNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUNDCNT_X, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_SOUNDBIAS, 0x200, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND1CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND1CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND1CNT_X, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND2CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND2CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND3CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND3CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND3CNT_X, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND4CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUND4CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUNDCNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUNDCNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUNDCNT_X, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_SOUNDBIAS, 0x200, 0);
memset(gba->audio.psg.ch3.wavedata32, 0, sizeof(gba->audio.psg.ch3.wavedata32));
}
if (registers & 0x80) {
cpu->memory.store16(cpu, BASE_IO | REG_DISPSTAT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_VCOUNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG0CNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG1CNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2CNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3CNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG0HOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG0VOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG1HOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG1VOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2HOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2VOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3HOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3VOFS, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2PA, 0x100, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2PB, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2PC, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG2PD, 0x100, 0);
cpu->memory.store32(cpu, BASE_IO | REG_BG2X_LO, 0, 0);
cpu->memory.store32(cpu, BASE_IO | REG_BG2Y_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3PA, 0x100, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3PB, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3PC, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BG3PD, 0x100, 0);
cpu->memory.store32(cpu, BASE_IO | REG_BG3X_LO, 0, 0);
cpu->memory.store32(cpu, BASE_IO | REG_BG3Y_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WIN0H, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WIN1H, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WIN0V, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WIN1V, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WININ, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WINOUT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_MOSAIC, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BLDCNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BLDALPHA, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_BLDY, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA0SAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA0SAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA0DAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA0DAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA0CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA0CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA1SAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA1SAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA1DAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA1DAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA1CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA1CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA2SAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA2SAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA2DAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA2DAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA2CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA2CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA3SAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA3SAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA3DAD_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA3DAD_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA3CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_DMA3CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM0CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM0CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM1CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM1CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM2CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM2CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM3CNT_LO, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_TM3CNT_HI, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_IE, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_IF, 0xFFFF, 0);
cpu->memory.store16(cpu, BASE_IO | REG_WAITCNT, 0, 0);
cpu->memory.store16(cpu, BASE_IO | REG_IME, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DISPSTAT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_VCOUNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG0CNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG1CNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2CNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3CNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG0HOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG0VOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG1HOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG1VOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2HOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2VOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3HOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3VOFS, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2PA, 0x100, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2PB, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2PC, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG2PD, 0x100, 0);
cpu->memory.store32(cpu, GBA_BASE_IO | REG_BG2X_LO, 0, 0);
cpu->memory.store32(cpu, GBA_BASE_IO | REG_BG2Y_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3PA, 0x100, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3PB, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3PC, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BG3PD, 0x100, 0);
cpu->memory.store32(cpu, GBA_BASE_IO | REG_BG3X_LO, 0, 0);
cpu->memory.store32(cpu, GBA_BASE_IO | REG_BG3Y_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WIN0H, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WIN1H, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WIN0V, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WIN1V, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WININ, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WINOUT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_MOSAIC, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BLDCNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BLDALPHA, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_BLDY, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA0SAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA0SAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA0DAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA0DAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA0CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA0CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA1SAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA1SAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA1DAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA1DAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA1CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA1CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA2SAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA2SAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA2DAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA2DAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA2CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA2CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA3SAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA3SAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA3DAD_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA3DAD_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA3CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_DMA3CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM0CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM0CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM1CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM1CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM2CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM2CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM3CNT_LO, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_TM3CNT_HI, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_IE, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_IF, 0xFFFF, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_WAITCNT, 0, 0);
cpu->memory.store16(cpu, GBA_BASE_IO | REG_IME, 0, 0);
}
if (registers & 0x9C) {
gba->video.renderer->reset(gba->video.renderer);
@ -267,7 +267,7 @@ static void _MidiKey2Freq(struct GBA* gba) {
struct ARMCore* cpu = gba->cpu;
int oldRegion = gba->memory.activeRegion;
gba->memory.activeRegion = REGION_BIOS;
gba->memory.activeRegion = GBA_REGION_BIOS;
uint32_t key = cpu->memory.load32(cpu, cpu->gprs[0] + 4, 0);
gba->memory.activeRegion = oldRegion;
@ -486,7 +486,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
break;
case GBA_SWI_CPU_SET:
case GBA_SWI_CPU_FAST_SET:
if (cpu->gprs[0] >> BASE_OFFSET < REGION_WORKING_RAM) {
if (cpu->gprs[0] >> BASE_OFFSET < GBA_REGION_EWRAM) {
mLOG(GBA_BIOS, GAME_ERROR, "Cannot CpuSet from BIOS");
break;
}
@ -501,7 +501,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
case GBA_SWI_GET_BIOS_CHECKSUM:
cpu->gprs[0] = GBA_BIOS_CHECKSUM;
cpu->gprs[1] = 1;
cpu->gprs[3] = SIZE_BIOS;
cpu->gprs[3] = GBA_SIZE_BIOS;
break;
case GBA_SWI_BG_AFFINE_SET:
_BgAffineSet(gba);
@ -510,7 +510,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
_ObjAffineSet(gba);
break;
case GBA_SWI_BIT_UNPACK:
if (cpu->gprs[0] < BASE_WORKING_RAM) {
if (cpu->gprs[0] < GBA_BASE_EWRAM) {
mLOG(GBA_BIOS, GAME_ERROR, "Bad BitUnPack source");
break;
}
@ -518,9 +518,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
default:
mLOG(GBA_BIOS, GAME_ERROR, "Bad BitUnPack destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
case GBA_REGION_EWRAM:
case GBA_REGION_IWRAM:
case GBA_REGION_VRAM:
_unBitPack(gba);
break;
}
@ -535,9 +535,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
default:
mLOG(GBA_BIOS, GAME_ERROR, "Bad LZ77 destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
case GBA_REGION_EWRAM:
case GBA_REGION_IWRAM:
case GBA_REGION_VRAM:
useStall = true;
_unLz77(gba, immediate == GBA_SWI_LZ77_UNCOMP_WRAM ? 1 : 2);
break;
@ -552,9 +552,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
default:
mLOG(GBA_BIOS, GAME_ERROR, "Bad Huffman destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
case GBA_REGION_EWRAM:
case GBA_REGION_IWRAM:
case GBA_REGION_VRAM:
_unHuffman(gba);
break;
}
@ -569,9 +569,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
default:
mLOG(GBA_BIOS, GAME_ERROR, "Bad RL destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
case GBA_REGION_EWRAM:
case GBA_REGION_IWRAM:
case GBA_REGION_VRAM:
_unRl(gba, immediate == GBA_SWI_RL_UNCOMP_WRAM ? 1 : 2);
break;
}
@ -587,9 +587,9 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
default:
mLOG(GBA_BIOS, GAME_ERROR, "Bad UnFilter destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
case GBA_REGION_EWRAM:
case GBA_REGION_IWRAM:
case GBA_REGION_VRAM:
_unFilter(gba, immediate == GBA_SWI_DIFF_16BIT_UNFILTER ? 2 : 1, immediate == GBA_SWI_DIFF_8BIT_UNFILTER_WRAM ? 1 : 2);
break;
}

View File

@ -246,7 +246,7 @@ void GBAVFameSramWrite(struct GBAVFameCart* cart, uint32_t address, uint8_t valu
// if mode has been set - the address and value of the SRAM write will be modified
address = _modifySramAddress(cart->cartType, address, cart->sramMode);
value = _modifySramValue(cart->cartType, value, cart->sramMode);
address &= (SIZE_CART_SRAM - 1);
address &= (GBA_SIZE_SRAM - 1);
sramData[address] = value;
}

View File

@ -323,49 +323,49 @@ static void GBACheatDumpDirectives(struct mCheatSet* set, struct StringList* dir
int GBACheatAddressIsReal(uint32_t address) {
switch (address >> BASE_OFFSET) {
case REGION_BIOS:
case GBA_REGION_BIOS:
return -0x80;
break;
case REGION_WORKING_RAM:
if ((address & OFFSET_MASK) > SIZE_WORKING_RAM) {
case GBA_REGION_EWRAM:
if ((address & OFFSET_MASK) > GBA_SIZE_EWRAM) {
return -0x40;
}
return 0x20;
case REGION_WORKING_IRAM:
if ((address & OFFSET_MASK) > SIZE_WORKING_IRAM) {
case GBA_REGION_IWRAM:
if ((address & OFFSET_MASK) > GBA_SIZE_IWRAM) {
return -0x40;
}
return 0x20;
case REGION_IO:
if ((address & OFFSET_MASK) > SIZE_IO) {
case GBA_REGION_IO:
if ((address & OFFSET_MASK) > GBA_SIZE_IO) {
return -0x80;
}
return 0x10;
case REGION_OAM:
if ((address & OFFSET_MASK) > SIZE_OAM) {
case GBA_REGION_OAM:
if ((address & OFFSET_MASK) > GBA_SIZE_OAM) {
return -0x80;
}
return -0x8;
case REGION_VRAM:
if ((address & OFFSET_MASK) > SIZE_VRAM) {
case GBA_REGION_VRAM:
if ((address & OFFSET_MASK) > GBA_SIZE_VRAM) {
return -0x80;
}
return -0x8;
case REGION_PALETTE_RAM:
if ((address & OFFSET_MASK) > SIZE_PALETTE_RAM) {
case GBA_REGION_PALETTE_RAM:
if ((address & OFFSET_MASK) > GBA_SIZE_PALETTE_RAM) {
return -0x80;
}
return -0x8;
case REGION_CART0:
case REGION_CART0_EX:
case REGION_CART1:
case REGION_CART1_EX:
case REGION_CART2:
case REGION_CART2_EX:
case GBA_REGION_ROM0:
case GBA_REGION_ROM0_EX:
case GBA_REGION_ROM1:
case GBA_REGION_ROM1_EX:
case GBA_REGION_ROM2:
case GBA_REGION_ROM2_EX:
return -0x8;
case REGION_CART_SRAM:
case REGION_CART_SRAM_MIRROR:
if ((address & OFFSET_MASK) > SIZE_CART_FLASH512) {
case GBA_REGION_SRAM:
case GBA_REGION_SRAM_MIRROR:
if ((address & OFFSET_MASK) > GBA_SIZE_FLASH512) {
return -0x80;
}
return -0x8;

View File

@ -215,7 +215,7 @@ bool GBACheatAddCodeBreaker(struct GBACheatSet* cheats, uint32_t op1, uint16_t o
return false;
}
cheats->hook = malloc(sizeof(*cheats->hook));
cheats->hook->address = BASE_CART0 | (op1 & (SIZE_CART0 - 1));
cheats->hook->address = GBA_BASE_ROM0 | (op1 & (GBA_SIZE_ROM0 - 1));
cheats->hook->mode = MODE_THUMB;
cheats->hook->refs = 1;
cheats->hook->reentries = 0;
@ -278,7 +278,7 @@ bool GBACheatAddCodeBreaker(struct GBACheatSet* cheats, uint32_t op1, uint16_t o
cheat = mCheatListAppend(&cheats->d.list);
cheat->type = CHEAT_IF_NAND;
cheat->width = 2;
cheat->address = BASE_IO | REG_KEYINPUT;
cheat->address = GBA_BASE_IO | REG_KEYINPUT;
cheat->operand = op2;
cheat->repeat = 1;
return true;

View File

@ -150,7 +150,7 @@ bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t
break;
case GSA_PATCH:
romPatch = mCheatPatchListAppend(&cheats->d.romPatches);
romPatch->address = BASE_CART0 | ((op1 & 0xFFFFFF) << 1);
romPatch->address = GBA_BASE_ROM0 | ((op1 & 0xFFFFFF) << 1);
romPatch->value = op2;
romPatch->applied = false;
romPatch->width = 2;
@ -207,7 +207,7 @@ bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t
return false;
}
cheats->hook = malloc(sizeof(*cheats->hook));
cheats->hook->address = BASE_CART0 | (op1 & (SIZE_CART0 - 1));
cheats->hook->address = GBA_BASE_ROM0 | (op1 & (GBA_SIZE_ROM0 - 1));
cheats->hook->mode = MODE_THUMB;
cheats->hook->refs = 1;
cheats->hook->reentries = 0;

View File

@ -233,7 +233,7 @@ static bool _addPAR3Special(struct GBACheatSet* cheats, uint32_t op2) {
}
if (romPatch >= 0) {
struct mCheatPatch* patch = mCheatPatchListAppend(&cheats->d.romPatches);
patch->address = BASE_CART0 | ((op2 & 0xFFFFFF) << 1);
patch->address = GBA_BASE_ROM0 | ((op2 & 0xFFFFFF) << 1);
patch->applied = false;
patch->check = false;
patch->width = 2;
@ -282,7 +282,7 @@ bool GBACheatAddProActionReplayRaw(struct GBACheatSet* cheats, uint32_t op1, uin
return false;
}
cheats->hook = malloc(sizeof(*cheats->hook));
cheats->hook->address = BASE_CART0 | (op1 & (SIZE_CART0 - 2));
cheats->hook->address = GBA_BASE_ROM0 | (op1 & (GBA_SIZE_ROM0 - 2));
cheats->hook->mode = MODE_THUMB;
cheats->hook->refs = 1;
cheats->hook->reentries = 0;
@ -320,7 +320,7 @@ bool GBACheatAddProActionReplayRaw(struct GBACheatSet* cheats, uint32_t op1, uin
case PAR3_BASE_OTHER:
width = ((op1 >> 24) & 1) + 1;
cheat->type = CHEAT_ASSIGN;
cheat->address = BASE_IO | (op1 & OFFSET_MASK);
cheat->address = GBA_BASE_IO | (op1 & OFFSET_MASK);
break;
}
if (op1 & 0x01000000 && (op1 & 0xFE000000) != 0xC6000000) {

View File

@ -57,76 +57,76 @@ static const struct mCoreChannelInfo _GBAAudioChannels[] = {
static const struct mCoreMemoryBlock _GBAMemoryBlocks[] = {
{ -1, "mem", "All", "All", 0, 0x10000000, 0x10000000, mCORE_MEMORY_VIRTUAL },
{ REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", BASE_BIOS, SIZE_BIOS, SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_RAM, "wram", "EWRAM", "Working RAM (256kiB)", BASE_WORKING_RAM, BASE_WORKING_RAM + SIZE_WORKING_RAM, SIZE_WORKING_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_IRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", BASE_WORKING_IRAM, BASE_WORKING_IRAM + SIZE_WORKING_IRAM, SIZE_WORKING_IRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_IO, "io", "MMIO", "Memory-Mapped I/O", BASE_IO, BASE_IO + SIZE_IO, SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", BASE_PALETTE_RAM, BASE_PALETTE_RAM + SIZE_PALETTE_RAM, SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", BASE_VRAM, BASE_VRAM + SIZE_VRAM, SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", BASE_OAM, BASE_OAM + SIZE_OAM, SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_CART0, "cart0", "ROM", "Game Pak (32MiB)", BASE_CART0, BASE_CART0 + SIZE_CART0, SIZE_CART0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", BASE_CART1, BASE_CART1 + SIZE_CART1, SIZE_CART1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", BASE_CART2, BASE_CART2 + SIZE_CART2, SIZE_CART2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", GBA_BASE_BIOS, GBA_SIZE_BIOS, GBA_SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ GBA_REGION_EWRAM, "wram", "EWRAM", "Working RAM (256kiB)", GBA_BASE_EWRAM, GBA_BASE_EWRAM + GBA_SIZE_EWRAM, GBA_SIZE_EWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IWRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", GBA_BASE_IWRAM, GBA_BASE_IWRAM + GBA_SIZE_IWRAM, GBA_SIZE_IWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IO, "io", "MMIO", "Memory-Mapped I/O", GBA_BASE_IO, GBA_BASE_IO + GBA_SIZE_IO, GBA_SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", GBA_BASE_PALETTE_RAM, GBA_BASE_PALETTE_RAM + GBA_SIZE_PALETTE_RAM, GBA_SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", GBA_BASE_VRAM, GBA_BASE_VRAM + GBA_SIZE_VRAM, GBA_SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", GBA_BASE_OAM, GBA_BASE_OAM + GBA_SIZE_OAM, GBA_SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM0, "cart0", "ROM", "Game Pak (32MiB)", GBA_BASE_ROM0, GBA_BASE_ROM0 + GBA_SIZE_ROM0, GBA_SIZE_ROM0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", GBA_BASE_ROM1, GBA_BASE_ROM1 + GBA_SIZE_ROM1, GBA_SIZE_ROM1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", GBA_BASE_ROM2, GBA_BASE_ROM2 + GBA_SIZE_ROM2, GBA_SIZE_ROM2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
};
static const struct mCoreMemoryBlock _GBAMemoryBlocksSRAM[] = {
{ -1, "mem", "All", "All", 0, 0x10000000, 0x10000000, mCORE_MEMORY_VIRTUAL },
{ REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", BASE_BIOS, SIZE_BIOS, SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_RAM, "wram", "EWRAM", "Working RAM (256kiB)", BASE_WORKING_RAM, BASE_WORKING_RAM + SIZE_WORKING_RAM, SIZE_WORKING_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_IRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", BASE_WORKING_IRAM, BASE_WORKING_IRAM + SIZE_WORKING_IRAM, SIZE_WORKING_IRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_IO, "io", "MMIO", "Memory-Mapped I/O", BASE_IO, BASE_IO + SIZE_IO, SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", BASE_PALETTE_RAM, BASE_PALETTE_RAM + SIZE_PALETTE_RAM, SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", BASE_VRAM, BASE_VRAM + SIZE_VRAM, SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", BASE_OAM, BASE_OAM + SIZE_OAM, SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_CART0, "cart0", "ROM", "Game Pak (32MiB)", BASE_CART0, BASE_CART0 + SIZE_CART0, SIZE_CART0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", BASE_CART1, BASE_CART1 + SIZE_CART1, SIZE_CART1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", BASE_CART2, BASE_CART2 + SIZE_CART2, SIZE_CART2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART_SRAM, "sram", "SRAM", "Static RAM (64kiB)", BASE_CART_SRAM, BASE_CART_SRAM + SIZE_CART_SRAM, SIZE_CART_SRAM, true },
{ GBA_REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", GBA_BASE_BIOS, GBA_SIZE_BIOS, GBA_SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ GBA_REGION_EWRAM, "wram", "EWRAM", "Working RAM (256kiB)", GBA_BASE_EWRAM, GBA_BASE_EWRAM + GBA_SIZE_EWRAM, GBA_SIZE_EWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IWRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", GBA_BASE_IWRAM, GBA_BASE_IWRAM + GBA_SIZE_IWRAM, GBA_SIZE_IWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IO, "io", "MMIO", "Memory-Mapped I/O", GBA_BASE_IO, GBA_BASE_IO + GBA_SIZE_IO, GBA_SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", GBA_BASE_PALETTE_RAM, GBA_BASE_PALETTE_RAM + GBA_SIZE_PALETTE_RAM, GBA_SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", GBA_BASE_VRAM, GBA_BASE_VRAM + GBA_SIZE_VRAM, GBA_SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", GBA_BASE_OAM, GBA_BASE_OAM + GBA_SIZE_OAM, GBA_SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM0, "cart0", "ROM", "Game Pak (32MiB)", GBA_BASE_ROM0, GBA_BASE_ROM0 + GBA_SIZE_ROM0, GBA_SIZE_ROM0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", GBA_BASE_ROM1, GBA_BASE_ROM1 + GBA_SIZE_ROM1, GBA_SIZE_ROM1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", GBA_BASE_ROM2, GBA_BASE_ROM2 + GBA_SIZE_ROM2, GBA_SIZE_ROM2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_SRAM, "sram", "SRAM", "Static RAM (64kiB)", GBA_BASE_SRAM, GBA_BASE_SRAM + GBA_SIZE_SRAM, GBA_SIZE_SRAM, true },
};
static const struct mCoreMemoryBlock _GBAMemoryBlocksFlash512[] = {
{ -1, "mem", "All", "All", 0, 0x10000000, 0x10000000, mCORE_MEMORY_VIRTUAL },
{ REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", BASE_BIOS, SIZE_BIOS, SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_RAM, "wram", "EWRAM", "Working RAM (256kiB)", BASE_WORKING_RAM, BASE_WORKING_RAM + SIZE_WORKING_RAM, SIZE_WORKING_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_IRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", BASE_WORKING_IRAM, BASE_WORKING_IRAM + SIZE_WORKING_IRAM, SIZE_WORKING_IRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_IO, "io", "MMIO", "Memory-Mapped I/O", BASE_IO, BASE_IO + SIZE_IO, SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", BASE_PALETTE_RAM, BASE_PALETTE_RAM + SIZE_PALETTE_RAM, SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", BASE_VRAM, BASE_VRAM + SIZE_VRAM, SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", BASE_OAM, BASE_OAM + SIZE_OAM, SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_CART0, "cart0", "ROM", "Game Pak (32MiB)", BASE_CART0, BASE_CART0 + SIZE_CART0, SIZE_CART0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", BASE_CART1, BASE_CART1 + SIZE_CART1, SIZE_CART1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", BASE_CART2, BASE_CART2 + SIZE_CART2, SIZE_CART2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART_SRAM, "sram", "Flash", "Flash Memory (64kiB)", BASE_CART_SRAM, BASE_CART_SRAM + SIZE_CART_FLASH512, SIZE_CART_FLASH512, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", GBA_BASE_BIOS, GBA_SIZE_BIOS, GBA_SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ GBA_REGION_EWRAM, "wram", "EWRAM", "Working RAM (256kiB)", GBA_BASE_EWRAM, GBA_BASE_EWRAM + GBA_SIZE_EWRAM, GBA_SIZE_EWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IWRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", GBA_BASE_IWRAM, GBA_BASE_IWRAM + GBA_SIZE_IWRAM, GBA_SIZE_IWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IO, "io", "MMIO", "Memory-Mapped I/O", GBA_BASE_IO, GBA_BASE_IO + GBA_SIZE_IO, GBA_SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", GBA_BASE_PALETTE_RAM, GBA_BASE_PALETTE_RAM + GBA_SIZE_PALETTE_RAM, GBA_SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", GBA_BASE_VRAM, GBA_BASE_VRAM + GBA_SIZE_VRAM, GBA_SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", GBA_BASE_OAM, GBA_BASE_OAM + GBA_SIZE_OAM, GBA_SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM0, "cart0", "ROM", "Game Pak (32MiB)", GBA_BASE_ROM0, GBA_BASE_ROM0 + GBA_SIZE_ROM0, GBA_SIZE_ROM0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", GBA_BASE_ROM1, GBA_BASE_ROM1 + GBA_SIZE_ROM1, GBA_SIZE_ROM1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", GBA_BASE_ROM2, GBA_BASE_ROM2 + GBA_SIZE_ROM2, GBA_SIZE_ROM2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_SRAM, "sram", "Flash", "Flash Memory (64kiB)", GBA_BASE_SRAM, GBA_BASE_SRAM + GBA_SIZE_FLASH512, GBA_SIZE_FLASH512, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
};
static const struct mCoreMemoryBlock _GBAMemoryBlocksFlash1M[] = {
{ -1, "mem", "All", "All", 0, 0x10000000, 0x10000000, mCORE_MEMORY_VIRTUAL },
{ REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", BASE_BIOS, SIZE_BIOS, SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_RAM, "wram", "EWRAM", "Working RAM (256kiB)", BASE_WORKING_RAM, BASE_WORKING_RAM + SIZE_WORKING_RAM, SIZE_WORKING_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_IRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", BASE_WORKING_IRAM, BASE_WORKING_IRAM + SIZE_WORKING_IRAM, SIZE_WORKING_IRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_IO, "io", "MMIO", "Memory-Mapped I/O", BASE_IO, BASE_IO + SIZE_IO, SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", BASE_PALETTE_RAM, BASE_PALETTE_RAM + SIZE_PALETTE_RAM, SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", BASE_VRAM, BASE_VRAM + SIZE_VRAM, SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", BASE_OAM, BASE_OAM + SIZE_OAM, SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_CART0, "cart0", "ROM", "Game Pak (32MiB)", BASE_CART0, BASE_CART0 + SIZE_CART0, SIZE_CART0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", BASE_CART1, BASE_CART1 + SIZE_CART1, SIZE_CART1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", BASE_CART2, BASE_CART2 + SIZE_CART2, SIZE_CART2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART_SRAM, "sram", "Flash", "Flash Memory (64kiB)", BASE_CART_SRAM, BASE_CART_SRAM + SIZE_CART_FLASH512, SIZE_CART_FLASH1M, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED, 1 },
{ GBA_REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", GBA_BASE_BIOS, GBA_SIZE_BIOS, GBA_SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ GBA_REGION_EWRAM, "wram", "EWRAM", "Working RAM (256kiB)", GBA_BASE_EWRAM, GBA_BASE_EWRAM + GBA_SIZE_EWRAM, GBA_SIZE_EWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IWRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", GBA_BASE_IWRAM, GBA_BASE_IWRAM + GBA_SIZE_IWRAM, GBA_SIZE_IWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IO, "io", "MMIO", "Memory-Mapped I/O", GBA_BASE_IO, GBA_BASE_IO + GBA_SIZE_IO, GBA_SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", GBA_BASE_PALETTE_RAM, GBA_BASE_PALETTE_RAM + GBA_SIZE_PALETTE_RAM, GBA_SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", GBA_BASE_VRAM, GBA_BASE_VRAM + GBA_SIZE_VRAM, GBA_SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", GBA_BASE_OAM, GBA_BASE_OAM + GBA_SIZE_OAM, GBA_SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM0, "cart0", "ROM", "Game Pak (32MiB)", GBA_BASE_ROM0, GBA_BASE_ROM0 + GBA_SIZE_ROM0, GBA_SIZE_ROM0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", GBA_BASE_ROM1, GBA_BASE_ROM1 + GBA_SIZE_ROM1, GBA_SIZE_ROM1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", GBA_BASE_ROM2, GBA_BASE_ROM2 + GBA_SIZE_ROM2, GBA_SIZE_ROM2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_SRAM, "sram", "Flash", "Flash Memory (64kiB)", GBA_BASE_SRAM, GBA_BASE_SRAM + GBA_SIZE_FLASH512, GBA_SIZE_FLASH1M, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED, 1 },
};
static const struct mCoreMemoryBlock _GBAMemoryBlocksEEPROM[] = {
{ -1, "mem", "All", "All", 0, 0x10000000, 0x10000000, mCORE_MEMORY_VIRTUAL },
{ REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", BASE_BIOS, SIZE_BIOS, SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_RAM, "wram", "EWRAM", "Working RAM (256kiB)", BASE_WORKING_RAM, BASE_WORKING_RAM + SIZE_WORKING_RAM, SIZE_WORKING_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_WORKING_IRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", BASE_WORKING_IRAM, BASE_WORKING_IRAM + SIZE_WORKING_IRAM, SIZE_WORKING_IRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_IO, "io", "MMIO", "Memory-Mapped I/O", BASE_IO, BASE_IO + SIZE_IO, SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", BASE_PALETTE_RAM, BASE_PALETTE_RAM + SIZE_PALETTE_RAM, SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", BASE_VRAM, BASE_VRAM + SIZE_VRAM, SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", BASE_OAM, BASE_OAM + SIZE_OAM, SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ REGION_CART0, "cart0", "ROM", "Game Pak (32MiB)", BASE_CART0, BASE_CART0 + SIZE_CART0, SIZE_CART0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", BASE_CART1, BASE_CART1 + SIZE_CART1, SIZE_CART1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", BASE_CART2, BASE_CART2 + SIZE_CART2, SIZE_CART2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ REGION_CART_SRAM_MIRROR, "eeprom", "EEPROM", "EEPROM (8kiB)", 0, SIZE_CART_EEPROM, SIZE_CART_EEPROM, mCORE_MEMORY_RW },
{ GBA_REGION_BIOS, "bios", "BIOS", "BIOS (16kiB)", GBA_BASE_BIOS, GBA_SIZE_BIOS, GBA_SIZE_BIOS, mCORE_MEMORY_READ | mCORE_MEMORY_MAPPED },
{ GBA_REGION_EWRAM, "wram", "EWRAM", "Working RAM (256kiB)", GBA_BASE_EWRAM, GBA_BASE_EWRAM + GBA_SIZE_EWRAM, GBA_SIZE_EWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IWRAM, "iwram", "IWRAM", "Internal Working RAM (32kiB)", GBA_BASE_IWRAM, GBA_BASE_IWRAM + GBA_SIZE_IWRAM, GBA_SIZE_IWRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_IO, "io", "MMIO", "Memory-Mapped I/O", GBA_BASE_IO, GBA_BASE_IO + GBA_SIZE_IO, GBA_SIZE_IO, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_PALETTE_RAM, "palette", "Palette", "Palette RAM (1kiB)", GBA_BASE_PALETTE_RAM, GBA_BASE_PALETTE_RAM + GBA_SIZE_PALETTE_RAM, GBA_SIZE_PALETTE_RAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_VRAM, "vram", "VRAM", "Video RAM (96kiB)", GBA_BASE_VRAM, GBA_BASE_VRAM + GBA_SIZE_VRAM, GBA_SIZE_VRAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_OAM, "oam", "OAM", "OBJ Attribute Memory (1kiB)", GBA_BASE_OAM, GBA_BASE_OAM + GBA_SIZE_OAM, GBA_SIZE_OAM, mCORE_MEMORY_RW | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM0, "cart0", "ROM", "Game Pak (32MiB)", GBA_BASE_ROM0, GBA_BASE_ROM0 + GBA_SIZE_ROM0, GBA_SIZE_ROM0, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM1, "cart1", "ROM WS1", "Game Pak (Waitstate 1)", GBA_BASE_ROM1, GBA_BASE_ROM1 + GBA_SIZE_ROM1, GBA_SIZE_ROM1, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_ROM2, "cart2", "ROM WS2", "Game Pak (Waitstate 2)", GBA_BASE_ROM2, GBA_BASE_ROM2 + GBA_SIZE_ROM2, GBA_SIZE_ROM2, mCORE_MEMORY_READ | mCORE_MEMORY_WORM | mCORE_MEMORY_MAPPED },
{ GBA_REGION_SRAM_MIRROR, "eeprom", "EEPROM", "EEPROM (8kiB)", 0, GBA_SIZE_EEPROM, GBA_SIZE_EEPROM, mCORE_MEMORY_RW },
};
static const struct mCoreRegisterInfo _GBARegisters[] = {
@ -512,7 +512,7 @@ static bool _GBACoreLoadROM(struct mCore* core, struct VFile* vf) {
#ifdef USE_ELF
struct ELF* elf = ELFOpen(vf);
if (elf) {
if (GBAVerifyELFEntry(elf, BASE_CART0)) {
if (GBAVerifyELFEntry(elf, GBA_BASE_ROM0)) {
GBALoadNull(core->board);
}
bool success = mCoreLoadELF(core, elf);
@ -907,36 +907,36 @@ void* _GBACoreGetMemoryBlock(struct mCore* core, size_t id, size_t* sizeOut) {
switch (id) {
default:
return NULL;
case REGION_BIOS:
*sizeOut = SIZE_BIOS;
case GBA_REGION_BIOS:
*sizeOut = GBA_SIZE_BIOS;
return gba->memory.bios;
case REGION_WORKING_RAM:
*sizeOut = SIZE_WORKING_RAM;
case GBA_REGION_EWRAM:
*sizeOut = GBA_SIZE_EWRAM;
return gba->memory.wram;
case REGION_WORKING_IRAM:
*sizeOut = SIZE_WORKING_IRAM;
case GBA_REGION_IWRAM:
*sizeOut = GBA_SIZE_IWRAM;
return gba->memory.iwram;
case REGION_PALETTE_RAM:
*sizeOut = SIZE_PALETTE_RAM;
case GBA_REGION_PALETTE_RAM:
*sizeOut = GBA_SIZE_PALETTE_RAM;
return gba->video.palette;
case REGION_VRAM:
*sizeOut = SIZE_VRAM;
case GBA_REGION_VRAM:
*sizeOut = GBA_SIZE_VRAM;
return gba->video.vram;
case REGION_OAM:
*sizeOut = SIZE_OAM;
case GBA_REGION_OAM:
*sizeOut = GBA_SIZE_OAM;
return gba->video.oam.raw;
case REGION_CART0:
case REGION_CART1:
case REGION_CART2:
case GBA_REGION_ROM0:
case GBA_REGION_ROM1:
case GBA_REGION_ROM2:
*sizeOut = gba->memory.romSize;
return gba->memory.rom;
case REGION_CART_SRAM:
case GBA_REGION_SRAM:
if (gba->memory.savedata.type == SAVEDATA_FLASH1M) {
*sizeOut = SIZE_CART_FLASH1M;
*sizeOut = GBA_SIZE_FLASH1M;
return gba->memory.savedata.currentBank;
}
// Fall through
case REGION_CART_SRAM_MIRROR:
case GBA_REGION_SRAM_MIRROR:
*sizeOut = GBASavedataSize(&gba->memory.savedata);
return gba->memory.savedata.data;
}
@ -1153,7 +1153,7 @@ static bool _GBACoreLookupIdentifier(struct mCore* core, const char* name, int32
for (i = 0; i < REG_MAX; i += 2) {
const char* reg = GBAIORegisterNames[i >> 1];
if (reg && strcasecmp(reg, name) == 0) {
*value = BASE_IO | i;
*value = GBA_BASE_IO | i;
return true;
}
}
@ -1321,7 +1321,7 @@ static void _GBACoreStartVideoLog(struct mCore* core, struct mVideoLogContext* c
struct GBASerializedState* state = mVideoLogContextInitialState(context, NULL);
state->id = 0;
state->cpu.gprs[ARM_PC] = BASE_WORKING_RAM;
state->cpu.gprs[ARM_PC] = GBA_BASE_EWRAM;
int channelId = mVideoLoggerAddChannel(context);
gbacore->vlProxy.logger = malloc(sizeof(struct mVideoLogger));
@ -1490,8 +1490,8 @@ static void _GBAVLPReset(struct mCore* core) {
// Make sure CPU loop never spins
GBAHalt(gba);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IE, 0, NULL);
gba->cpu->memory.store16(gba->cpu, GBA_BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, GBA_BASE_IO | REG_IE, 0, NULL);
}
static bool _GBAVLPLoadROM(struct mCore* core, struct VFile* vf) {
@ -1510,13 +1510,13 @@ static bool _GBAVLPLoadState(struct mCore* core, const void* state) {
struct GBA* gba = (struct GBA*) core->board;
gba->timing.root = NULL;
gba->cpu->gprs[ARM_PC] = BASE_WORKING_RAM;
gba->cpu->gprs[ARM_PC] = GBA_BASE_EWRAM;
gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]);
// Make sure CPU loop never spins
GBAHalt(gba);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IE, 0, NULL);
gba->cpu->memory.store16(gba->cpu, GBA_BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, GBA_BASE_IO | REG_IE, 0, NULL);
GBAVideoDeserialize(&gba->video, state);
GBAIODeserialize(gba, state);
GBAAudioReset(&gba->audio);

View File

@ -33,14 +33,14 @@ void GBADMAReset(struct GBA* gba) {
gba->memory.activeDMA = -1;
}
static bool _isValidDMASAD(int dma, uint32_t address) {
if (dma == 0 && address >= BASE_CART0 && address < BASE_CART_SRAM) {
if (dma == 0 && address >= GBA_BASE_ROM0 && address < GBA_BASE_SRAM) {
return false;
}
return address >= BASE_WORKING_RAM;
return address >= GBA_BASE_EWRAM;
}
static bool _isValidDMADAD(int dma, uint32_t address) {
return dma == 3 || address < BASE_CART0;
return dma == 3 || address < GBA_BASE_ROM0;
}
uint32_t GBADMAWriteSAD(struct GBA* gba, int dma, uint32_t address) {
@ -274,14 +274,14 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
}
cpu->memory.store32(cpu, dest, memory->dmaTransferRegister, 0);
} else {
if (sourceRegion == REGION_CART2_EX && (memory->savedata.type == SAVEDATA_EEPROM || memory->savedata.type == SAVEDATA_EEPROM512)) {
if (sourceRegion == GBA_REGION_ROM2_EX && (memory->savedata.type == SAVEDATA_EEPROM || memory->savedata.type == SAVEDATA_EEPROM512)) {
memory->dmaTransferRegister = GBASavedataReadEEPROM(&memory->savedata);
memory->dmaTransferRegister |= memory->dmaTransferRegister << 16;
} else if (source) {
memory->dmaTransferRegister = cpu->memory.load16(cpu, source, 0);
memory->dmaTransferRegister |= memory->dmaTransferRegister << 16;
}
if (destRegion == REGION_CART2_EX) {
if (destRegion == GBA_REGION_ROM2_EX) {
if (memory->savedata.type == SAVEDATA_AUTODETECT) {
mLOG(GBA_MEM, INFO, "Detected EEPROM savegame");
GBASavedataInitEEPROM(&memory->savedata);
@ -296,7 +296,7 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
gba->bus = memory->dmaTransferRegister;
int sourceOffset;
if (info->nextSource >= BASE_CART0 && info->nextSource < BASE_CART_SRAM && GBADMARegisterGetSrcControl(info->reg) < 3) {
if (info->nextSource >= GBA_BASE_ROM0 && info->nextSource < GBA_BASE_SRAM && GBADMARegisterGetSrcControl(info->reg) < 3) {
sourceOffset = width;
} else {
sourceOffset = DMA_OFFSET[GBADMARegisterGetSrcControl(info->reg)] * width;
@ -321,7 +321,7 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
if (!info->nextCount) {
info->nextCount |= 0x80000000;
if (sourceRegion < REGION_CART0 || destRegion < REGION_CART0) {
if (sourceRegion < GBA_REGION_ROM0 || destRegion < GBA_REGION_ROM0) {
info->when += 2;
}
}

View File

@ -245,7 +245,7 @@ static void _mp2kReload(struct GBAAudioMixer* mixer) {
}
bool _mp2kEngage(struct GBAAudioMixer* mixer, uint32_t address) {
if (address < BASE_WORKING_RAM) {
if (address < GBA_BASE_EWRAM) {
return false;
}
if (address != mixer->contextAddress) {

View File

@ -63,9 +63,9 @@ void GBAVideoProxyRendererCreate(struct GBAVideoProxyRenderer* renderer, struct
renderer->logger->parsePacket = _parsePacket;
renderer->logger->handleEvent = _handleEvent;
renderer->logger->vramBlock = _vramBlock;
renderer->logger->paletteSize = SIZE_PALETTE_RAM;
renderer->logger->vramSize = SIZE_VRAM;
renderer->logger->oamSize = SIZE_OAM;
renderer->logger->paletteSize = GBA_SIZE_PALETTE_RAM;
renderer->logger->vramSize = GBA_SIZE_VRAM;
renderer->logger->oamSize = GBA_SIZE_OAM;
renderer->backend = backend;
}
@ -82,9 +82,9 @@ static void _init(struct GBAVideoProxyRenderer* proxyRenderer) {
}
static void _reset(struct GBAVideoProxyRenderer* proxyRenderer) {
memcpy(proxyRenderer->logger->oam, &proxyRenderer->d.oam->raw, SIZE_OAM);
memcpy(proxyRenderer->logger->palette, proxyRenderer->d.palette, SIZE_PALETTE_RAM);
memcpy(proxyRenderer->logger->vram, proxyRenderer->d.vram, SIZE_VRAM);
memcpy(proxyRenderer->logger->oam, &proxyRenderer->d.oam->raw, GBA_SIZE_OAM);
memcpy(proxyRenderer->logger->palette, proxyRenderer->d.palette, GBA_SIZE_PALETTE_RAM);
memcpy(proxyRenderer->logger->vram, proxyRenderer->d.vram, GBA_SIZE_VRAM);
mVideoLoggerRendererReset(proxyRenderer->logger);
}
@ -199,19 +199,19 @@ static bool _parsePacket(struct mVideoLogger* logger, const struct mVideoLoggerD
proxyRenderer->backend->writeVideoRegister(proxyRenderer->backend, item->address, item->value);
break;
case DIRTY_PALETTE:
if (item->address < SIZE_PALETTE_RAM) {
if (item->address < GBA_SIZE_PALETTE_RAM) {
STORE_16LE(item->value, item->address, logger->palette);
proxyRenderer->backend->writePalette(proxyRenderer->backend, item->address, item->value);
}
break;
case DIRTY_OAM:
if (item->address < SIZE_OAM) {
if (item->address < GBA_SIZE_OAM) {
STORE_16LE(item->value, item->address << 1, logger->oam);
proxyRenderer->backend->writeOAM(proxyRenderer->backend, item->address);
}
break;
case DIRTY_VRAM:
if (item->address <= SIZE_VRAM - 0x1000) {
if (item->address <= GBA_SIZE_VRAM - 0x1000) {
logger->readData(logger, &logger->vram[item->address >> 1], 0x1000, true);
proxyRenderer->backend->writeVRAM(proxyRenderer->backend, item->address);
} else {

View File

@ -108,7 +108,7 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) {
gba->keyCallback = NULL;
mCoreCallbacksListInit(&gba->coreCallbacks, 0);
gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
gba->biosChecksum = GBAChecksum(gba->memory.bios, GBA_SIZE_BIOS);
gba->idleOptimization = IDLE_LOOP_REMOVE;
gba->idleLoop = IDLE_LOOP_NONE;
@ -137,7 +137,7 @@ void GBAUnloadROM(struct GBA* gba) {
gba->yankedRomSize = 0;
}
#ifndef FIXED_ROM_BUFFER
mappedMemoryFree(gba->memory.rom, SIZE_CART0);
mappedMemoryFree(gba->memory.rom, GBA_SIZE_ROM0);
#endif
}
@ -172,7 +172,7 @@ void GBADestroy(struct GBA* gba) {
GBAUnloadMB(gba);
if (gba->biosVf) {
gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS);
gba->biosVf->unmap(gba->biosVf, gba->memory.bios, GBA_SIZE_BIOS);
gba->biosVf->close(gba->biosVf);
gba->biosVf = 0;
}
@ -247,7 +247,7 @@ void GBAReset(struct ARMCore* cpu) {
if (GBAIsMB(gba->mbVf) && !isELF) {
gba->mbVf->seek(gba->mbVf, 0, SEEK_SET);
gba->mbVf->read(gba->mbVf, gba->memory.wram, SIZE_WORKING_RAM);
gba->mbVf->read(gba->mbVf, gba->memory.wram, GBA_SIZE_EWRAM);
}
gba->lastJump = 0;
@ -259,7 +259,7 @@ void GBAReset(struct ARMCore* cpu) {
memset(gba->debugString, 0, sizeof(gba->debugString));
if (gba->romVf && gba->romVf->size(gba->romVf) > SIZE_CART0) {
if (gba->romVf && gba->romVf->size(gba->romVf) > GBA_SIZE_ROM0) {
char ident;
gba->romVf->seek(gba->romVf, 0xAC, SEEK_SET);
gba->romVf->read(gba->romVf, &ident, 1);
@ -274,11 +274,11 @@ void GBASkipBIOS(struct GBA* gba) {
struct ARMCore* cpu = gba->cpu;
if (cpu->gprs[ARM_PC] == BASE_RESET + WORD_SIZE_ARM) {
if (gba->memory.rom) {
cpu->gprs[ARM_PC] = BASE_CART0;
cpu->gprs[ARM_PC] = GBA_BASE_ROM0;
} else if (gba->memory.wram[0x30]) {
cpu->gprs[ARM_PC] = BASE_WORKING_RAM + 0xC0;
cpu->gprs[ARM_PC] = GBA_BASE_EWRAM + 0xC0;
} else {
cpu->gprs[ARM_PC] = BASE_WORKING_RAM;
cpu->gprs[ARM_PC] = GBA_BASE_EWRAM;
}
gba->video.vcount = 0x7E;
gba->memory.io[REG_VCOUNT >> 1] = 0x7E;
@ -360,14 +360,14 @@ bool GBALoadNull(struct GBA* gba) {
gba->romVf = NULL;
gba->pristineRomSize = 0;
#ifndef FIXED_ROM_BUFFER
gba->memory.rom = anonymousMemoryMap(SIZE_CART0);
gba->memory.rom = anonymousMemoryMap(GBA_SIZE_ROM0);
#else
gba->memory.rom = romBuffer;
#endif
gba->isPristine = false;
gba->yankedRomSize = 0;
gba->memory.romSize = SIZE_CART0;
gba->memory.romMask = SIZE_CART0 - 1;
gba->memory.romSize = GBA_SIZE_ROM0;
gba->memory.romMask = GBA_SIZE_ROM0 - 1;
gba->romCrc32 = 0;
if (gba->cpu) {
@ -381,9 +381,9 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf) {
GBAUnloadMB(gba);
gba->mbVf = vf;
vf->seek(vf, 0, SEEK_SET);
memset(gba->memory.wram, 0, SIZE_WORKING_RAM);
vf->read(vf, gba->memory.wram, SIZE_WORKING_RAM);
if (gba->cpu && gba->memory.activeRegion == REGION_WORKING_RAM) {
memset(gba->memory.wram, 0, GBA_SIZE_EWRAM);
vf->read(vf, gba->memory.wram, GBA_SIZE_EWRAM);
if (gba->cpu && gba->memory.activeRegion == GBA_REGION_IWRAM) {
gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]);
}
return true;
@ -405,7 +405,7 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
gba->isPristine = true;
gba->pristineRomSize = vf->size(vf);
vf->seek(vf, 0, SEEK_SET);
if (gba->pristineRomSize > SIZE_CART0) {
if (gba->pristineRomSize > GBA_SIZE_ROM0) {
char ident;
vf->seek(vf, 0xAC, SEEK_SET);
vf->read(vf, &ident, 1);
@ -415,13 +415,13 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
#ifdef FIXED_ROM_BUFFER
gba->memory.rom = romBuffer;
#else
gba->memory.rom = anonymousMemoryMap(SIZE_CART0);
gba->memory.rom = anonymousMemoryMap(GBA_SIZE_ROM0);
#endif
} else {
gba->memory.rom = vf->map(vf, SIZE_CART0, MAP_READ);
gba->memory.romSize = SIZE_CART0;
gba->memory.rom = vf->map(vf, GBA_SIZE_ROM0, MAP_READ);
gba->memory.romSize = GBA_SIZE_ROM0;
}
gba->pristineRomSize = SIZE_CART0;
gba->pristineRomSize = GBA_SIZE_ROM0;
} else if (gba->pristineRomSize == 0x00100000) {
// 1 MiB ROMs (e.g. Classic NES) all appear as 4x mirrored, but not more
gba->isPristine = false;
@ -429,7 +429,7 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
#ifdef FIXED_ROM_BUFFER
gba->memory.rom = romBuffer;
#else
gba->memory.rom = anonymousMemoryMap(SIZE_CART0);
gba->memory.rom = anonymousMemoryMap(GBA_SIZE_ROM0);
#endif
vf->read(vf, gba->memory.rom, gba->pristineRomSize);
memcpy(&gba->memory.rom[0x40000], gba->memory.rom, 0x00100000);
@ -450,15 +450,15 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
if (popcount32(gba->memory.romSize) != 1) {
// This ROM is either a bad dump or homebrew. Emulate flash cart behavior.
#ifndef FIXED_ROM_BUFFER
void* newRom = anonymousMemoryMap(SIZE_CART0);
void* newRom = anonymousMemoryMap(GBA_SIZE_ROM0);
memcpy(newRom, gba->memory.rom, gba->pristineRomSize);
gba->memory.rom = newRom;
#endif
gba->memory.romSize = SIZE_CART0;
gba->memory.romMask = SIZE_CART0 - 1;
gba->memory.romSize = GBA_SIZE_ROM0;
gba->memory.romMask = GBA_SIZE_ROM0 - 1;
gba->isPristine = false;
}
if (gba->cpu && gba->memory.activeRegion >= REGION_CART0) {
if (gba->cpu && gba->memory.activeRegion >= GBA_REGION_ROM0) {
gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]);
}
GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]);
@ -485,23 +485,23 @@ void GBAYankROM(struct GBA* gba) {
}
void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
if (vf->size(vf) != SIZE_BIOS) {
if (vf->size(vf) != GBA_SIZE_BIOS) {
mLOG(GBA, WARN, "Incorrect BIOS size");
return;
}
uint32_t* bios = vf->map(vf, SIZE_BIOS, MAP_READ);
uint32_t* bios = vf->map(vf, GBA_SIZE_BIOS, MAP_READ);
if (!bios) {
mLOG(GBA, WARN, "Couldn't map BIOS");
return;
}
if (gba->biosVf) {
gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS);
gba->biosVf->unmap(gba->biosVf, gba->memory.bios, GBA_SIZE_BIOS);
gba->biosVf->close(gba->biosVf);
}
gba->biosVf = vf;
gba->memory.bios = bios;
gba->memory.fullBios = 1;
uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
uint32_t checksum = GBAChecksum(gba->memory.bios, GBA_SIZE_BIOS);
mLOG(GBA, DEBUG, "BIOS Checksum: 0x%X", checksum);
if (checksum == GBA_BIOS_CHECKSUM) {
mLOG(GBA, INFO, "Official GBA BIOS detected");
@ -511,7 +511,7 @@ void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
mLOG(GBA, WARN, "BIOS checksum incorrect");
}
gba->biosChecksum = checksum;
if (gba->memory.activeRegion == REGION_BIOS) {
if (gba->memory.activeRegion == GBA_REGION_BIOS) {
gba->cpu->memory.activeRegion = gba->memory.bios;
}
// TODO: error check
@ -519,18 +519,18 @@ void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
void GBAApplyPatch(struct GBA* gba, struct Patch* patch) {
size_t patchedSize = patch->outputSize(patch, gba->memory.romSize);
if (!patchedSize || patchedSize > SIZE_CART0) {
if (!patchedSize || patchedSize > GBA_SIZE_ROM0) {
return;
}
void* newRom = anonymousMemoryMap(SIZE_CART0);
void* newRom = anonymousMemoryMap(GBA_SIZE_ROM0);
if (!patch->applyPatch(patch, gba->memory.rom, gba->pristineRomSize, newRom, patchedSize)) {
mappedMemoryFree(newRom, SIZE_CART0);
mappedMemoryFree(newRom, GBA_SIZE_ROM0);
return;
}
if (gba->romVf) {
#ifndef FIXED_ROM_BUFFER
if (!gba->isPristine) {
mappedMemoryFree(gba->memory.rom, SIZE_CART0);
mappedMemoryFree(gba->memory.rom, GBA_SIZE_ROM0);
} else {
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->pristineRomSize);
}
@ -666,7 +666,7 @@ bool GBAIsROM(struct VFile* vf) {
uint32_t entry = ELFEntry(elf);
bool isGBA = true;
isGBA = isGBA && ELFMachine(elf) == EM_ARM;
isGBA = isGBA && (GBAVerifyELFEntry(elf, BASE_CART0) || GBAVerifyELFEntry(elf, BASE_WORKING_RAM + 0xC0));
isGBA = isGBA && (GBAVerifyELFEntry(elf, GBA_BASE_ROM0) || GBAVerifyELFEntry(elf, GBA_BASE_EWRAM + 0xC0));
ELFClose(elf);
return isGBA;
}
@ -722,12 +722,12 @@ bool GBAIsMB(struct VFile* vf) {
#ifdef USE_ELF
struct ELF* elf = ELFOpen(vf);
if (elf) {
bool isMB = GBAVerifyELFEntry(elf, BASE_WORKING_RAM + 0xC0);
bool isMB = GBAVerifyELFEntry(elf, GBA_BASE_EWRAM + 0xC0);
ELFClose(elf);
return isMB;
}
#endif
if (vf->size(vf) > SIZE_WORKING_RAM) {
if (vf->size(vf) > GBA_SIZE_EWRAM) {
return false;
}
if (vf->seek(vf, GBA_MB_MAGIC_OFFSET, SEEK_SET) < 0) {
@ -764,10 +764,10 @@ bool GBAIsMB(struct VFile* vf) {
}
pc += 4;
LOAD_32(opcode, 0, &signature);
if ((opcode & ~0x1FFFF) == BASE_WORKING_RAM) {
if ((opcode & ~0x1FFFF) == GBA_BASE_EWRAM) {
++wramAddrs;
}
if ((opcode & ~0x1FFFF) == BASE_CART0) {
if ((opcode & ~0x1FFFF) == GBA_BASE_ROM0) {
++romAddrs;
}
ARMDecodeARM(opcode, &info);
@ -790,10 +790,10 @@ bool GBAIsMB(struct VFile* vf) {
if (vf->seek(vf, pc, SEEK_SET) < 0) {
break;
}
if ((immediate & ~0x1FFFF) == BASE_WORKING_RAM) {
if ((immediate & ~0x1FFFF) == GBA_BASE_EWRAM) {
++wramLoads;
}
if ((immediate & ~0x1FFFF) == BASE_CART0) {
if ((immediate & ~0x1FFFF) == GBA_BASE_ROM0) {
++romLoads;
}
}

View File

@ -2,7 +2,7 @@
#include <mgba/internal/gba/memory.h>
const uint8_t hleBios[SIZE_BIOS] = {
const uint8_t hleBios[GBA_SIZE_BIOS] = {
0xd3, 0x00, 0x00, 0xea, 0x66, 0x00, 0x00, 0xea, 0x0c, 0x00, 0x00, 0xea,
0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1,
0x59, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0x00, 0x00,

View File

@ -15,4 +15,4 @@ hle-bios.c: hle-bios.bin
echo >> $@
echo '#include <mgba/internal/gba/memory.h>' >> $@
echo >> $@
xxd -i $< | sed -e 's/unsigned char hle_bios_bin\[\]/const uint8_t hleBios[SIZE_BIOS]/' -e 's/^ \+/\t/' | grep -v hle_bios_bin_len >> $@
xxd -i $< | sed -e 's/unsigned char hle_bios_bin\[\]/const uint8_t hleBios[GBA_SIZE_BIOS]/' -e 's/^ \+/\t/' | grep -v hle_bios_bin_len >> $@

View File

@ -625,18 +625,18 @@ void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value) {
return;
}
if (address == REG_POSTFLG) {
gba->memory.io[(address & (SIZE_IO - 1)) >> 1] = value;
gba->memory.io[(address & (GBA_SIZE_IO - 1)) >> 1] = value;
return;
}
if (address >= REG_DEBUG_STRING && address - REG_DEBUG_STRING < sizeof(gba->debugString)) {
gba->debugString[address - REG_DEBUG_STRING] = value;
return;
}
if (address > SIZE_IO) {
if (address > GBA_SIZE_IO) {
return;
}
uint16_t value16 = value << (8 * (address & 1));
value16 |= (gba->memory.io[(address & (SIZE_IO - 1)) >> 1]) & ~(0xFF << (8 * (address & 1)));
value16 |= (gba->memory.io[(address & (GBA_SIZE_IO - 1)) >> 1]) & ~(0xFF << (8 * (address & 1)));
GBAIOWrite(gba, address & 0xFFFFFFFE, value16);
}

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ void GBAVideoCacheAssociate(struct mCacheSet* cache, struct GBAVideo* video) {
mCacheSetAssignVRAM(cache, video->vram);
video->renderer->cache = cache;
size_t i;
for (i = 0; i < SIZE_PALETTE_RAM / 2; ++i) {
for (i = 0; i < GBA_SIZE_PALETTE_RAM / 2; ++i) {
mCacheSetWritePalette(cache, i, mColorFrom555(video->palette[i]));
}
GBAVideoCacheWriteVideoRegister(cache, REG_DISPCNT, video->p->memory.io[REG_DISPCNT >> 1]);

View File

@ -69,22 +69,22 @@ void GBASavedataDeinit(struct GBASavedata* savedata) {
} else {
switch (savedata->type) {
case SAVEDATA_SRAM:
mappedMemoryFree(savedata->data, SIZE_CART_SRAM);
mappedMemoryFree(savedata->data, GBA_SIZE_SRAM);
break;
case SAVEDATA_SRAM512:
mappedMemoryFree(savedata->data, SIZE_CART_SRAM512);
mappedMemoryFree(savedata->data, GBA_SIZE_SRAM512);
break;
case SAVEDATA_FLASH512:
mappedMemoryFree(savedata->data, SIZE_CART_FLASH512);
mappedMemoryFree(savedata->data, GBA_SIZE_FLASH512);
break;
case SAVEDATA_FLASH1M:
mappedMemoryFree(savedata->data, SIZE_CART_FLASH1M);
mappedMemoryFree(savedata->data, GBA_SIZE_FLASH1M);
break;
case SAVEDATA_EEPROM:
mappedMemoryFree(savedata->data, SIZE_CART_EEPROM);
mappedMemoryFree(savedata->data, GBA_SIZE_EEPROM);
break;
case SAVEDATA_EEPROM512:
mappedMemoryFree(savedata->data, SIZE_CART_EEPROM512);
mappedMemoryFree(savedata->data, GBA_SIZE_EEPROM512);
break;
case SAVEDATA_FORCE_NONE:
case SAVEDATA_AUTODETECT:
@ -129,17 +129,17 @@ bool GBASavedataClone(struct GBASavedata* savedata, struct VFile* out) {
if (savedata->data) {
switch (savedata->type) {
case SAVEDATA_SRAM:
return out->write(out, savedata->data, SIZE_CART_SRAM) == SIZE_CART_SRAM;
return out->write(out, savedata->data, GBA_SIZE_SRAM) == GBA_SIZE_SRAM;
case SAVEDATA_SRAM512:
return out->write(out, savedata->data, SIZE_CART_SRAM512) == SIZE_CART_SRAM512;
return out->write(out, savedata->data, GBA_SIZE_SRAM512) == GBA_SIZE_SRAM512;
case SAVEDATA_FLASH512:
return out->write(out, savedata->data, SIZE_CART_FLASH512) == SIZE_CART_FLASH512;
return out->write(out, savedata->data, GBA_SIZE_FLASH512) == GBA_SIZE_FLASH512;
case SAVEDATA_FLASH1M:
return out->write(out, savedata->data, SIZE_CART_FLASH1M) == SIZE_CART_FLASH1M;
return out->write(out, savedata->data, GBA_SIZE_FLASH1M) == GBA_SIZE_FLASH1M;
case SAVEDATA_EEPROM:
return out->write(out, savedata->data, SIZE_CART_EEPROM) == SIZE_CART_EEPROM;
return out->write(out, savedata->data, GBA_SIZE_EEPROM) == GBA_SIZE_EEPROM;
case SAVEDATA_EEPROM512:
return out->write(out, savedata->data, SIZE_CART_EEPROM512) == SIZE_CART_EEPROM512;
return out->write(out, savedata->data, GBA_SIZE_EEPROM512) == GBA_SIZE_EEPROM512;
case SAVEDATA_AUTODETECT:
case SAVEDATA_FORCE_NONE:
return true;
@ -160,17 +160,17 @@ bool GBASavedataClone(struct GBASavedata* savedata, struct VFile* out) {
size_t GBASavedataSize(const struct GBASavedata* savedata) {
switch (savedata->type) {
case SAVEDATA_SRAM:
return SIZE_CART_SRAM;
return GBA_SIZE_SRAM;
case SAVEDATA_SRAM512:
return SIZE_CART_SRAM512;
return GBA_SIZE_SRAM512;
case SAVEDATA_FLASH512:
return SIZE_CART_FLASH512;
return GBA_SIZE_FLASH512;
case SAVEDATA_FLASH1M:
return SIZE_CART_FLASH1M;
return GBA_SIZE_FLASH1M;
case SAVEDATA_EEPROM:
return SIZE_CART_EEPROM;
return GBA_SIZE_EEPROM;
case SAVEDATA_EEPROM512:
return SIZE_CART_EEPROM512;
return GBA_SIZE_EEPROM512;
case SAVEDATA_FORCE_NONE:
return 0;
case SAVEDATA_AUTODETECT:
@ -262,14 +262,14 @@ void GBASavedataInitFlash(struct GBASavedata* savedata) {
mLOG(GBA_SAVE, WARN, "Can't re-initialize savedata");
return;
}
int32_t flashSize = SIZE_CART_FLASH512;
int32_t flashSize = GBA_SIZE_FLASH512;
if (savedata->type == SAVEDATA_FLASH1M) {
flashSize = SIZE_CART_FLASH1M;
flashSize = GBA_SIZE_FLASH1M;
}
off_t end;
if (!savedata->vf) {
end = 0;
savedata->data = anonymousMemoryMap(SIZE_CART_FLASH1M);
savedata->data = anonymousMemoryMap(GBA_SIZE_FLASH1M);
} else {
end = savedata->vf->size(savedata->vf);
if (end < flashSize) {
@ -279,7 +279,7 @@ void GBASavedataInitFlash(struct GBASavedata* savedata) {
}
savedata->currentBank = savedata->data;
if (end < SIZE_CART_FLASH512) {
if (end < GBA_SIZE_FLASH512) {
memset(&savedata->data[end], 0xFF, flashSize - end);
}
}
@ -291,14 +291,14 @@ void GBASavedataInitEEPROM(struct GBASavedata* savedata) {
mLOG(GBA_SAVE, WARN, "Can't re-initialize savedata");
return;
}
int32_t eepromSize = SIZE_CART_EEPROM512;
int32_t eepromSize = GBA_SIZE_EEPROM512;
if (savedata->type == SAVEDATA_EEPROM) {
eepromSize = SIZE_CART_EEPROM;
eepromSize = GBA_SIZE_EEPROM;
}
off_t end;
if (!savedata->vf) {
end = 0;
savedata->data = anonymousMemoryMap(SIZE_CART_EEPROM);
savedata->data = anonymousMemoryMap(GBA_SIZE_EEPROM);
} else {
end = savedata->vf->size(savedata->vf);
if (end < eepromSize) {
@ -306,8 +306,8 @@ void GBASavedataInitEEPROM(struct GBASavedata* savedata) {
}
savedata->data = savedata->vf->map(savedata->vf, eepromSize, savedata->mapMode);
}
if (end < SIZE_CART_EEPROM512) {
memset(&savedata->data[end], 0xFF, SIZE_CART_EEPROM512 - end);
if (end < GBA_SIZE_EEPROM512) {
memset(&savedata->data[end], 0xFF, GBA_SIZE_EEPROM512 - end);
}
}
@ -321,17 +321,17 @@ void GBASavedataInitSRAM(struct GBASavedata* savedata) {
off_t end;
if (!savedata->vf) {
end = 0;
savedata->data = anonymousMemoryMap(SIZE_CART_SRAM);
savedata->data = anonymousMemoryMap(GBA_SIZE_SRAM);
} else {
end = savedata->vf->size(savedata->vf);
if (end < SIZE_CART_SRAM) {
savedata->vf->truncate(savedata->vf, SIZE_CART_SRAM);
if (end < GBA_SIZE_SRAM) {
savedata->vf->truncate(savedata->vf, GBA_SIZE_SRAM);
}
savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_SRAM, savedata->mapMode);
savedata->data = savedata->vf->map(savedata->vf, GBA_SIZE_SRAM, savedata->mapMode);
}
if (end < SIZE_CART_SRAM) {
memset(&savedata->data[end], 0xFF, SIZE_CART_SRAM - end);
if (end < GBA_SIZE_SRAM) {
memset(&savedata->data[end], 0xFF, GBA_SIZE_SRAM - end);
}
}
@ -345,17 +345,17 @@ void GBASavedataInitSRAM512(struct GBASavedata* savedata) {
off_t end;
if (!savedata->vf) {
end = 0;
savedata->data = anonymousMemoryMap(SIZE_CART_SRAM512);
savedata->data = anonymousMemoryMap(GBA_SIZE_SRAM512);
} else {
end = savedata->vf->size(savedata->vf);
if (end < SIZE_CART_SRAM512) {
savedata->vf->truncate(savedata->vf, SIZE_CART_SRAM512);
if (end < GBA_SIZE_SRAM512) {
savedata->vf->truncate(savedata->vf, GBA_SIZE_SRAM512);
}
savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_SRAM512, savedata->mapMode);
savedata->data = savedata->vf->map(savedata->vf, GBA_SIZE_SRAM512, savedata->mapMode);
}
if (end < SIZE_CART_SRAM512) {
memset(&savedata->data[end], 0xFF, SIZE_CART_SRAM512 - end);
if (end < GBA_SIZE_SRAM512) {
memset(&savedata->data[end], 0xFF, GBA_SIZE_SRAM512 - end);
}
}
@ -465,7 +465,7 @@ void GBASavedataWriteFlash(struct GBASavedata* savedata, uint16_t address, uint8
}
static void _ensureEeprom(struct GBASavedata* savedata, uint32_t size) {
if (size < SIZE_CART_EEPROM512) {
if (size < GBA_SIZE_EEPROM512) {
return;
}
if (savedata->type == SAVEDATA_EEPROM) {
@ -475,13 +475,13 @@ static void _ensureEeprom(struct GBASavedata* savedata, uint32_t size) {
if (!savedata->vf) {
return;
}
savedata->vf->unmap(savedata->vf, savedata->data, SIZE_CART_EEPROM512);
if (savedata->vf->size(savedata->vf) < SIZE_CART_EEPROM) {
savedata->vf->truncate(savedata->vf, SIZE_CART_EEPROM);
savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_EEPROM, savedata->mapMode);
memset(&savedata->data[SIZE_CART_EEPROM512], 0xFF, SIZE_CART_EEPROM - SIZE_CART_EEPROM512);
savedata->vf->unmap(savedata->vf, savedata->data, GBA_SIZE_EEPROM512);
if (savedata->vf->size(savedata->vf) < GBA_SIZE_EEPROM) {
savedata->vf->truncate(savedata->vf, GBA_SIZE_EEPROM);
savedata->data = savedata->vf->map(savedata->vf, GBA_SIZE_EEPROM, savedata->mapMode);
memset(&savedata->data[GBA_SIZE_EEPROM512], 0xFF, GBA_SIZE_EEPROM - GBA_SIZE_EEPROM512);
} else {
savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_EEPROM, savedata->mapMode);
savedata->data = savedata->vf->map(savedata->vf, GBA_SIZE_EEPROM, savedata->mapMode);
}
}
@ -509,7 +509,7 @@ void GBASavedataWriteEEPROM(struct GBASavedata* savedata, uint16_t value, uint32
savedata->writeAddress |= (value & 0x1) << 6;
} else if (writeSize == 1) {
savedata->command = EEPROM_COMMAND_NULL;
} else if ((savedata->writeAddress >> 3) < SIZE_CART_EEPROM) {
} else if ((savedata->writeAddress >> 3) < GBA_SIZE_EEPROM) {
_ensureEeprom(savedata, savedata->writeAddress >> 3);
uint8_t current = savedata->data[savedata->writeAddress >> 3];
current &= ~(1 << (0x7 - (savedata->writeAddress & 0x7)));
@ -551,7 +551,7 @@ uint16_t GBASavedataReadEEPROM(struct GBASavedata* savedata) {
int step = 63 - savedata->readBitsRemaining;
uint32_t address = (savedata->readAddress + step) >> 3;
_ensureEeprom(savedata, address);
if (address >= SIZE_CART_EEPROM) {
if (address >= GBA_SIZE_EEPROM) {
mLOG(GBA_SAVE, GAME_ERROR, "Reading beyond end of EEPROM: %08X", address);
return 0xFF;
}
@ -699,13 +699,13 @@ void _flashSwitchBank(struct GBASavedata* savedata, int bank) {
mLOG(GBA_SAVE, INFO, "Updating flash chip from 512kb to 1Mb");
savedata->type = SAVEDATA_FLASH1M;
if (savedata->vf) {
savedata->vf->unmap(savedata->vf, savedata->data, SIZE_CART_FLASH512);
if (savedata->vf->size(savedata->vf) < SIZE_CART_FLASH1M) {
savedata->vf->truncate(savedata->vf, SIZE_CART_FLASH1M);
savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_FLASH1M, MAP_WRITE);
memset(&savedata->data[SIZE_CART_FLASH512], 0xFF, SIZE_CART_FLASH512);
savedata->vf->unmap(savedata->vf, savedata->data, GBA_SIZE_FLASH512);
if (savedata->vf->size(savedata->vf) < GBA_SIZE_FLASH1M) {
savedata->vf->truncate(savedata->vf, GBA_SIZE_FLASH1M);
savedata->data = savedata->vf->map(savedata->vf, GBA_SIZE_FLASH1M, MAP_WRITE);
memset(&savedata->data[GBA_SIZE_FLASH512], 0xFF, GBA_SIZE_FLASH512);
} else {
savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_FLASH1M, MAP_WRITE);
savedata->data = savedata->vf->map(savedata->vf, GBA_SIZE_FLASH1M, MAP_WRITE);
}
}
}
@ -715,9 +715,9 @@ void _flashSwitchBank(struct GBASavedata* savedata, int bank) {
void _flashErase(struct GBASavedata* savedata) {
mLOG(GBA_SAVE, DEBUG, "Performing flash chip erase");
savedata->dirty |= mSAVEDATA_DIRT_NEW;
size_t size = SIZE_CART_FLASH512;
size_t size = GBA_SIZE_FLASH512;
if (savedata->type == SAVEDATA_FLASH1M) {
size = SIZE_CART_FLASH1M;
size = GBA_SIZE_FLASH1M;
}
memset(savedata->data, 0xFF, size);
}

View File

@ -102,7 +102,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
mLOG(GBA_STATE, WARN, "Savestate created using a different version of the BIOS: expected %08X, got %08X", gba->biosChecksum, ucheck);
uint32_t pc;
LOAD_32(pc, ARM_PC * sizeof(state->cpu.gprs[0]), state->cpu.gprs);
if ((ucheck == GBA_BIOS_CHECKSUM || gba->biosChecksum == GBA_BIOS_CHECKSUM) && pc < SIZE_BIOS && pc >= 0x20) {
if ((ucheck == GBA_BIOS_CHECKSUM || gba->biosChecksum == GBA_BIOS_CHECKSUM) && pc < GBA_SIZE_BIOS && pc >= 0x20) {
error = true;
}
}
@ -128,7 +128,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
}
LOAD_32(check, ARM_PC * sizeof(state->cpu.gprs[0]), state->cpu.gprs);
int region = (check >> BASE_OFFSET);
if ((region == REGION_CART0 || region == REGION_CART1 || region == REGION_CART2) && ((check - WORD_SIZE_ARM) & SIZE_CART0) >= gba->memory.romSize - WORD_SIZE_ARM) {
if ((region == GBA_REGION_ROM0 || region == GBA_REGION_ROM1 || region == GBA_REGION_ROM2) && ((check - WORD_SIZE_ARM) & GBA_SIZE_ROM0) >= gba->memory.romSize - WORD_SIZE_ARM) {
mLOG(GBA_STATE, WARN, "Savestate created using a differently sized version of the ROM");
error = true;
}

View File

@ -19,7 +19,7 @@ static bool _importSavedata(struct GBA* gba, void* payload, size_t size) {
bool success = false;
switch (gba->memory.savedata.type) {
case SAVEDATA_FLASH512:
if (size > SIZE_CART_FLASH512) {
if (size > GBA_SIZE_FLASH512) {
GBASavedataForceType(&gba->memory.savedata, SAVEDATA_FLASH1M);
}
// Fall through
@ -33,7 +33,7 @@ static bool _importSavedata(struct GBA* gba, void* payload, size_t size) {
goto cleanup;
}
if (size == SIZE_CART_EEPROM || size == SIZE_CART_EEPROM512) {
if (size == GBA_SIZE_EEPROM || size == GBA_SIZE_EEPROM512) {
size_t i;
for (i = 0; i < size; i += 8) {
uint32_t lo, hi;
@ -119,7 +119,7 @@ int GBASavedataSharkPortPayloadSize(struct VFile* vf) {
void* GBASavedataSharkPortGetPayload(struct VFile* vf, size_t* osize, uint8_t* oheader, bool testChecksum) {
int32_t size = GBASavedataSharkPortPayloadSize(vf);
if (size < 0x1C || size > SIZE_CART_FLASH1M + 0x1C) {
if (size < 0x1C || size > GBA_SIZE_FLASH1M + 0x1C) {
return NULL;
}
size -= 0x1C;
@ -336,15 +336,15 @@ int GBASavedataGSVPayloadSize(struct VFile* vf) {
LOAD_32(type, 0, &header.type);
switch (type) {
case 2:
return SIZE_CART_SRAM;
return GBA_SIZE_SRAM;
case 3:
return SIZE_CART_EEPROM512;
return GBA_SIZE_EEPROM512;
case 4:
return SIZE_CART_EEPROM;
return GBA_SIZE_EEPROM;
case 5:
return SIZE_CART_FLASH512;
return GBA_SIZE_FLASH512;
case 6:
return SIZE_CART_FLASH1M; // Unconfirmed
return GBA_SIZE_FLASH1M; // Unconfirmed
default:
return vf->size(vf) - GSV_PAYLOAD_OFFSET;
}
@ -352,7 +352,7 @@ int GBASavedataGSVPayloadSize(struct VFile* vf) {
void* GBASavedataGSVGetPayload(struct VFile* vf, size_t* osize, uint8_t* ident, bool testChecksum) {
int32_t size = GBASavedataGSVPayloadSize(vf);
if (!size || size > SIZE_CART_FLASH1M) {
if (!size || size > GBA_SIZE_FLASH1M) {
return NULL;
}

View File

@ -54,7 +54,7 @@ MGBA_EXPORT const int GBAVideoObjSizes[16][2] = {
void GBAVideoInit(struct GBAVideo* video) {
video->renderer = NULL;
video->vram = anonymousMemoryMap(SIZE_VRAM);
video->vram = anonymousMemoryMap(GBA_SIZE_VRAM);
video->frameskip = 0;
video->event.name = "GBA Video";
video->event.callback = NULL;
@ -93,7 +93,7 @@ void GBAVideoReset(struct GBAVideo* video) {
void GBAVideoDeinit(struct GBAVideo* video) {
video->renderer->deinit(video->renderer);
mappedMemoryFree(video->vram, SIZE_VRAM);
mappedMemoryFree(video->vram, GBA_SIZE_VRAM);
}
void GBAVideoDummyRendererCreate(struct GBAVideoRenderer* renderer) {
@ -325,9 +325,9 @@ static void GBAVideoDummyRendererPutPixels(struct GBAVideoRenderer* renderer, si
}
void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState* state) {
memcpy(state->vram, video->vram, SIZE_VRAM);
memcpy(state->oam, video->oam.raw, SIZE_OAM);
memcpy(state->pram, video->palette, SIZE_PALETTE_RAM);
memcpy(state->vram, video->vram, GBA_SIZE_VRAM);
memcpy(state->oam, video->oam.raw, GBA_SIZE_OAM);
memcpy(state->pram, video->palette, GBA_SIZE_PALETTE_RAM);
STORE_32(video->event.when - mTimingCurrentTime(&video->p->timing), 0, &state->video.nextEvent);
int32_t flags = 0;
if (video->event.callback == _startHdraw) {
@ -340,16 +340,16 @@ void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState*
}
void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState* state) {
memcpy(video->vram, state->vram, SIZE_VRAM);
memcpy(video->vram, state->vram, GBA_SIZE_VRAM);
uint16_t value;
int i;
for (i = 0; i < SIZE_OAM; i += 2) {
for (i = 0; i < GBA_SIZE_OAM; i += 2) {
LOAD_16(value, i, state->oam);
GBAStore16(video->p->cpu, BASE_OAM | i, value, 0);
GBAStore16(video->p->cpu, GBA_BASE_OAM | i, value, 0);
}
for (i = 0; i < SIZE_PALETTE_RAM; i += 2) {
for (i = 0; i < GBA_SIZE_PALETTE_RAM; i += 2) {
LOAD_16(value, i, state->pram);
GBAStore16(video->p->cpu, BASE_PALETTE_RAM | i, value, 0);
GBAStore16(video->p->cpu, GBA_BASE_PALETTE_RAM | i, value, 0);
}
LOAD_32(video->frameCounter, 0, &state->video.frameCounter);

View File

@ -676,66 +676,66 @@ static void _setupMaps(struct mCore* core) {
/* Map internal working RAM */
descs[0].ptr = gba->memory.iwram;
descs[0].start = BASE_WORKING_IRAM;
descs[0].len = SIZE_WORKING_IRAM;
descs[0].start = GBA_BASE_IWRAM;
descs[0].len = GBA_SIZE_IWRAM;
descs[0].select = 0xFF000000;
/* Map working RAM */
descs[1].ptr = gba->memory.wram;
descs[1].start = BASE_WORKING_RAM;
descs[1].len = SIZE_WORKING_RAM;
descs[1].start = GBA_BASE_EWRAM;
descs[1].len = GBA_SIZE_EWRAM;
descs[1].select = 0xFF000000;
/* Map save RAM */
/* TODO: if SRAM is flash, use start=0 addrspace="S" instead */
descs[2].ptr = savedataSize ? savedata : NULL;
descs[2].start = BASE_CART_SRAM;
descs[2].start = GBA_BASE_SRAM;
descs[2].len = savedataSize;
/* Map ROM */
descs[3].ptr = gba->memory.rom;
descs[3].start = BASE_CART0;
descs[3].start = GBA_BASE_ROM0;
descs[3].len = romSize;
descs[3].flags = RETRO_MEMDESC_CONST;
descs[4].ptr = gba->memory.rom;
descs[4].start = BASE_CART1;
descs[4].start = GBA_BASE_ROM1;
descs[4].len = romSize;
descs[4].flags = RETRO_MEMDESC_CONST;
descs[5].ptr = gba->memory.rom;
descs[5].start = BASE_CART2;
descs[5].start = GBA_BASE_ROM2;
descs[5].len = romSize;
descs[5].flags = RETRO_MEMDESC_CONST;
/* Map BIOS */
descs[6].ptr = gba->memory.bios;
descs[6].start = BASE_BIOS;
descs[6].len = SIZE_BIOS;
descs[6].start = GBA_BASE_BIOS;
descs[6].len = GBA_SIZE_BIOS;
descs[6].flags = RETRO_MEMDESC_CONST;
/* Map VRAM */
descs[7].ptr = gba->video.vram;
descs[7].start = BASE_VRAM;
descs[7].len = SIZE_VRAM;
descs[7].start = GBA_BASE_VRAM;
descs[7].len = GBA_SIZE_VRAM;
descs[7].select = 0xFF000000;
/* Map palette RAM */
descs[8].ptr = gba->video.palette;
descs[8].start = BASE_PALETTE_RAM;
descs[8].len = SIZE_PALETTE_RAM;
descs[8].start = GBA_BASE_PALETTE_RAM;
descs[8].len = GBA_SIZE_PALETTE_RAM;
descs[8].select = 0xFF000000;
/* Map OAM */
descs[9].ptr = &gba->video.oam; /* video.oam is a structure */
descs[9].start = BASE_OAM;
descs[9].len = SIZE_OAM;
descs[9].start = GBA_BASE_OAM;
descs[9].len = GBA_SIZE_OAM;
descs[9].select = 0xFF000000;
/* Map mmapped I/O */
descs[10].ptr = gba->memory.io;
descs[10].start = BASE_IO;
descs[10].len = SIZE_IO;
descs[10].start = GBA_BASE_IO;
descs[10].len = GBA_SIZE_IO;
mmaps.descriptors = descs;
mmaps.num_descriptors = sizeof(descs) / sizeof(descs[0]);

View File

@ -123,19 +123,19 @@ class GBAMemory(Memory):
def __init__(self, core, romSize=lib.SIZE_CART0):
super(GBAMemory, self).__init__(core, 0x100000000)
self.bios = Memory(core, lib.SIZE_BIOS, lib.BASE_BIOS)
self.wram = Memory(core, lib.SIZE_WORKING_RAM, lib.BASE_WORKING_RAM)
self.iwram = Memory(core, lib.SIZE_WORKING_IRAM, lib.BASE_WORKING_IRAM)
self.io = Memory(core, lib.SIZE_IO, lib.BASE_IO) # pylint: disable=invalid-name
self.palette = Memory(core, lib.SIZE_PALETTE_RAM, lib.BASE_PALETTE_RAM)
self.vram = Memory(core, lib.SIZE_VRAM, lib.BASE_VRAM)
self.oam = Memory(core, lib.SIZE_OAM, lib.BASE_OAM)
self.bios = Memory(core, lib.GBA_SIZE_BIOS, lib.GBA_BASE_BIOS)
self.wram = Memory(core, lib.GBA_SIZE_EWRAM, lib.GBA_BASE_EWRAM)
self.iwram = Memory(core, lib.GBA_SIZE_IWRAM, lib.GBA_BASE_IWRAM)
self.io = Memory(core, lib.GBA_SIZE_IO, lib.GBA_BASE_IO) # pylint: disable=invalid-name
self.palette = Memory(core, lib.GBA_SIZE_PALETTE_RAM, lib.GBA_BASE_PALETTE_RAM)
self.vram = Memory(core, lib.GBA_SIZE_VRAM, lib.GBA_BASE_VRAM)
self.oam = Memory(core, lib.GBA_SIZE_OAM, lib.GBA_BASE_OAM)
self.cart0 = Memory(core, romSize, lib.BASE_CART0)
self.cart1 = Memory(core, romSize, lib.BASE_CART1)
self.cart2 = Memory(core, romSize, lib.BASE_CART2)
self.cart = self.cart0
self.rom = self.cart0
self.sram = Memory(core, lib.SIZE_CART_SRAM, lib.BASE_CART_SRAM)
self.sram = Memory(core, lib.GBA_SIZE_SRAM, lib.GBA_BASE_SRAM)
class GBASprite(Sprite):

View File

@ -51,8 +51,8 @@ void AssetTile::setController(std::shared_ptr<CoreController> controller) {
#ifdef M_CORE_GBA
case mPLATFORM_GBA:
m_addressWidth = 8;
m_addressBase = BASE_VRAM;
m_boundaryBase = BASE_VRAM | 0x10000;
m_addressBase = GBA_BASE_VRAM;
m_boundaryBase = GBA_BASE_VRAM | 0x10000;
break;
#endif
#ifdef M_CORE_GB

View File

@ -1580,7 +1580,7 @@ IOViewer::IOViewer(std::shared_ptr<CoreController> controller, QWidget* parent)
case mPLATFORM_GBA:
regs = GBAIORegisterNames;
maxRegs = REG_MAX >> 1;
m_base = BASE_IO;
m_base = GBA_BASE_IO;
m_width = 1;
break;
#endif

View File

@ -43,7 +43,7 @@ MapView::MapView(std::shared_ptr<CoreController> controller, QWidget* parent)
case mPLATFORM_GBA:
m_boundary = 2048;
m_ui.tile->setMaxTile(3096);
m_addressBase = BASE_VRAM;
m_addressBase = GBA_BASE_VRAM;
m_addressWidth = 8;
m_ui.bgInfo->addCustomProperty("priority", tr("Priority"));
m_ui.bgInfo->addCustomProperty("screenBase", tr("Map base"));

View File

@ -157,7 +157,7 @@ void ObjView::updateTilesGBA(bool force) {
m_ui.w->setText(QString::number(newInfo.width * 8));
m_ui.h->setText(QString::number(newInfo.height * 8));
m_ui.address->setText(tr("0x%0").arg(BASE_OAM + m_objId * sizeof(*obj), 8, 16, QChar('0')));
m_ui.address->setText(tr("0x%0").arg(GBA_BASE_OAM + m_objId * sizeof(*obj), 8, 16, QChar('0')));
m_ui.priority->setText(QString::number(newInfo.priority));
m_ui.flippedH->setChecked(newInfo.hflip);
m_ui.flippedV->setChecked(newInfo.vflip);

View File

@ -197,20 +197,20 @@ void SaveConverter::detectFromSavestate(VFile* vf) {
void SaveConverter::detectFromSize(std::shared_ptr<VFileDevice> vf) {
#ifdef M_CORE_GBA
switch (vf->size()) {
case SIZE_CART_SRAM:
case GBA_SIZE_SRAM:
m_validSaves.append(AnnotatedSave{SAVEDATA_SRAM, vf});
break;
case SIZE_CART_FLASH512:
case GBA_SIZE_FLASH512:
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH512, vf});
break;
case SIZE_CART_FLASH1M:
case GBA_SIZE_FLASH1M:
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH1M, vf});
break;
case SIZE_CART_EEPROM:
case GBA_SIZE_EEPROM:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, vf, Endian::LITTLE});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, vf, Endian::BIG});
break;
case SIZE_CART_EEPROM512:
case GBA_SIZE_EEPROM512:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, vf, Endian::LITTLE});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, vf, Endian::BIG});
break;
@ -267,13 +267,13 @@ void SaveConverter::detectFromHeaders(std::shared_ptr<VFileDevice> vf) {
if (data) {
QByteArray bytes = QByteArray::fromRawData(static_cast<const char*>(data), size);
bytes.data(); // Trigger a deep copy before we delete the backing
if (size == SIZE_CART_FLASH1M) {
if (size == GBA_SIZE_FLASH1M) {
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH1M, std::make_shared<VFileDevice>(bytes), Endian::NONE, Container::SHARKPORT});
} else {
m_validSaves.append(AnnotatedSave{SAVEDATA_SRAM, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_SRAM)), Endian::NONE, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH512, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_FLASH512)), Endian::NONE, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_EEPROM)), Endian::BIG, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_EEPROM512)), Endian::BIG, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_SRAM, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_SRAM)), Endian::NONE, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH512, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_FLASH512)), Endian::NONE, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_EEPROM)), Endian::BIG, Container::SHARKPORT});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_EEPROM512)), Endian::BIG, Container::SHARKPORT});
}
free(data);
}
@ -284,21 +284,21 @@ void SaveConverter::detectFromHeaders(std::shared_ptr<VFileDevice> vf) {
QByteArray bytes = QByteArray::fromRawData(static_cast<const char*>(data), size);
bytes.data(); // Trigger a deep copy before we delete the backing
switch (size) {
case SIZE_CART_FLASH1M:
case GBA_SIZE_FLASH1M:
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH1M, std::make_shared<VFileDevice>(bytes), Endian::NONE, Container::GSV});
break;
case SIZE_CART_FLASH512:
case GBA_SIZE_FLASH512:
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH512, std::make_shared<VFileDevice>(bytes), Endian::NONE, Container::GSV});
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH1M, std::make_shared<VFileDevice>(bytes), Endian::NONE, Container::GSV});
break;
case SIZE_CART_SRAM:
m_validSaves.append(AnnotatedSave{SAVEDATA_SRAM, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_SRAM)), Endian::NONE, Container::GSV});
case GBA_SIZE_SRAM:
m_validSaves.append(AnnotatedSave{SAVEDATA_SRAM, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_SRAM)), Endian::NONE, Container::GSV});
break;
case SIZE_CART_EEPROM:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_EEPROM)), Endian::BIG, Container::GSV});
case GBA_SIZE_EEPROM:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_EEPROM)), Endian::BIG, Container::GSV});
break;
case SIZE_CART_EEPROM512:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, std::make_shared<VFileDevice>(bytes.left(SIZE_CART_EEPROM512)), Endian::BIG, Container::GSV});
case GBA_SIZE_EEPROM512:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, std::make_shared<VFileDevice>(bytes.left(GBA_SIZE_EEPROM512)), Endian::BIG, Container::GSV});
break;
}
free(data);