diff --git a/include/mgba/internal/gb/io.h b/include/mgba/internal/gb/io.h index 92917d70a..169199230 100644 --- a/include/mgba/internal/gb/io.h +++ b/include/mgba/internal/gb/io.h @@ -87,6 +87,7 @@ enum GBIORegisters { REG_KEY0 = 0x4C, REG_KEY1 = 0x4D, REG_VBK = 0x4F, + REG_BANK = 0x50, REG_HDMA1 = 0x51, REG_HDMA2 = 0x52, REG_HDMA3 = 0x53, diff --git a/src/gb/io.c b/src/gb/io.c index ea9eb7b2e..280ca1ddf 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -56,6 +56,7 @@ MGBA_EXPORT const char* const GBIORegisterNames[] = { [REG_KEY0] = "KEY0", [REG_KEY1] = "KEY1", [REG_VBK] = "VBK", + [REG_BANK] = "BANK", [REG_HDMA1] = "HDMA1", [REG_HDMA2] = "HDMA2", [REG_HDMA3] = "HDMA3", @@ -185,10 +186,10 @@ void GBIOReset(struct GB* gb) { GBIOWrite(gb, REG_NR51, 0xF3); if (!gb->biosVf) { GBIOWrite(gb, REG_LCDC, 0x91); - gb->memory.io[0x50] = 1; + gb->memory.io[REG_BANK] = 1; } else { GBIOWrite(gb, REG_LCDC, 0x00); - gb->memory.io[0x50] = 0xFF; + gb->memory.io[REG_BANK] = 0xFF; } GBIOWrite(gb, REG_SCY, 0x00); GBIOWrite(gb, REG_SCX, 0x00); @@ -459,8 +460,8 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { GBVideoWriteSTAT(&gb->video, value); value = gb->video.stat; break; - case 0x50: - if (gb->memory.io[0x50] != 0xFF) { + case REG_BANK: + if (gb->memory.io[REG_BANK] != 0xFF) { break; } GBUnmapBIOS(gb); diff --git a/src/gb/serialize.c b/src/gb/serialize.c index e6b053b9b..002b5a650 100644 --- a/src/gb/serialize.c +++ b/src/gb/serialize.c @@ -139,7 +139,7 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) { mLOG(GB_STATE, WARN, "Savestate is corrupted: OCPS is out of range"); } bool differentBios = !gb->biosVf || gb->model != state->model; - if (state->io[0x50] == 0xFF) { + if (state->io[REG_BANK] == 0xFF) { if (differentBios) { mLOG(GB_STATE, WARN, "Incompatible savestate, please restart with correct BIOS in %s mode", GBModelToName(state->model)); error = true; @@ -206,7 +206,7 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) { GBTimerDeserialize(&gb->timer, state); GBAudioDeserialize(&gb->audio, state); - if (gb->memory.io[0x50] == 0xFF) { + if (gb->memory.io[REG_BANK] == 0xFF) { GBMapBIOS(gb); } else { GBUnmapBIOS(gb);