GBA Hardware: Scanning now fails successfully
Vicki Pfau vi@endrift.com
Tue, 18 Feb 2020 18:24:00 -0800
2 files changed,
11 insertions(+),
10 deletions(-)
M
src/gba/hardware.c
→
src/gba/hardware.c
@@ -682,7 +682,7 @@ hw->eReaderRegisterReset = 4;
hw->eReaderRegisterControl0 = 0; hw->eReaderRegisterControl1 = 0x80; hw->eReaderRegisterLed = 0; - hw->eReaderState = false; + hw->eReaderState = 0; hw->eReaderActiveRegister = 0; }@@ -738,7 +738,7 @@ }
++hw->eReaderActiveRegister; break; default: - mLOG(GBA_HW, ERROR, "Hit undefined state in e-Reader state machine"); + mLOG(GBA_HW, ERROR, "Hit undefined state %02X in e-Reader state machine", hw->eReaderCommand); break; } hw->eReaderState = EREADER_SERIAL_BIT_0;@@ -761,6 +761,8 @@ }
hw->eReaderRegisterControl0 = control; if (!EReaderControl0IsScan(oldControl) && EReaderControl0IsScan(control)) { _eReaderReadData(hw); + } else if (EReaderControl0IsLedEnable(control) && EReaderControl1IsScanline(hw->eReaderRegisterControl1)) { + GBARaiseIRQ(hw->p, IRQ_GAMEPAK, 0); } mLOG(GBA_HW, STUB, "Unimplemented e-Reader Control0 write: %02X", value); }@@ -775,15 +777,13 @@ mLOG(GBA_HW, STUB, "Unimplemented e-Reader Control1 write: %02X", value);
} void _eReaderReadData(struct GBACartridgeHardware* hw) { - if (!hw->eReaderSource) { - return; + memset(hw->eReaderData, 0xFF, EREADER_BLOCK_SIZE); + if (hw->eReaderSource) { + hw->eReaderSource->readBlock(hw->eReaderSource, hw->eReaderData); } - memset(hw->eReaderData, 0, EREADER_BLOCK_SIZE); - if (hw->eReaderSource->readBlock(hw->eReaderSource, hw->eReaderData)) { - hw->eReaderRegisterControl1 = EReaderControl1FillScanline(hw->eReaderRegisterControl1); - if (EReaderControl0IsLedEnable(hw->eReaderRegisterControl0)) { - GBARaiseIRQ(hw->p, IRQ_GAMEPAK, 0); - } + hw->eReaderRegisterControl1 = EReaderControl1FillScanline(hw->eReaderRegisterControl1); + if (EReaderControl0IsLedEnable(hw->eReaderRegisterControl0)) { + GBARaiseIRQ(hw->p, IRQ_GAMEPAK, -2754); } }
M
src/gba/memory.c
→
src/gba/memory.c
@@ -917,6 +917,7 @@ break;
case REGION_CART2_EX: if ((address & 0x0DFC0000) >= 0x0DF80000 && memory->hw.devices & HW_EREADER) { GBAHardwareEReaderWrite(&memory->hw, address, value); + break; } else if (memory->savedata.type == SAVEDATA_AUTODETECT) { mLOG(GBA_MEM, INFO, "Detected EEPROM savegame"); GBASavedataInitEEPROM(&memory->savedata);