mirror of https://github.com/mgba-emu/mgba.git
GB: Improve emulation of DMG-on-CGB register reads
This commit is contained in:
parent
d5e434c684
commit
e050a2ae3d
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 853 B |
23
src/gb/io.c
23
src/gb/io.c
|
@ -104,6 +104,7 @@ static const uint8_t _registerMask[] = {
|
|||
[GB_REG_BCPS] = 0x40,
|
||||
[GB_REG_OPRI] = 0xFE,
|
||||
[GB_REG_SVBK] = 0xF8,
|
||||
[GB_REG_UNK75] = 0x8F,
|
||||
[GB_REG_IE] = 0xE0,
|
||||
};
|
||||
|
||||
|
@ -531,12 +532,9 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
|
|||
goto success;
|
||||
}
|
||||
failed:
|
||||
mLOG(GB_IO, STUB, "Writing to unknown register FF%02X:%02X", address, value);
|
||||
if (address >= GB_SIZE_IO) {
|
||||
mLOG(GB_IO, GAME_ERROR, "Writing to unknown register FF%02X:%02X", address, value);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
success:
|
||||
gb->memory.io[address] = value;
|
||||
}
|
||||
|
@ -662,9 +660,6 @@ uint8_t GBIORead(struct GB* gb, unsigned address) {
|
|||
case GB_REG_WX:
|
||||
// Handled transparently by the registers
|
||||
break;
|
||||
default:
|
||||
if (gb->model >= GB_MODEL_CGB) {
|
||||
switch (address) {
|
||||
case GB_REG_KEY1:
|
||||
case GB_REG_VBK:
|
||||
case GB_REG_HDMA1:
|
||||
|
@ -677,16 +672,20 @@ uint8_t GBIORead(struct GB* gb, unsigned address) {
|
|||
case GB_REG_OCPS:
|
||||
case GB_REG_OCPD:
|
||||
case GB_REG_SVBK:
|
||||
case GB_REG_UNK72:
|
||||
case GB_REG_UNK73:
|
||||
case GB_REG_UNK75:
|
||||
// Handled transparently by the registers
|
||||
goto success;
|
||||
default:
|
||||
if (gb->model < GB_MODEL_CGB) {
|
||||
// In DMG mode, these all get initialized to 0xFF during reset
|
||||
// But in DMG-on-CGB mode, they get initialized by the CGB reset so they can be non-zero
|
||||
mLOG(GB_IO, GAME_ERROR, "Reading from CGB register FF%02X in DMG mode", address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
mLOG(GB_IO, STUB, "Reading from unknown register FF%02X", address);
|
||||
return 0xFF;
|
||||
}
|
||||
success:
|
||||
return gb->memory.io[address] | _registerMask[address];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue