GB I/O: Add BANK register name

This commit is contained in:
Vicki Pfau 2020-09-09 22:23:11 -07:00
parent 94fc963c89
commit ad7146a801
3 changed files with 8 additions and 6 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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);