GBA Hardware: Scanning now fails successfully

This commit is contained in:
Vicki Pfau 2020-02-18 18:24:00 -08:00
parent 433759f1fe
commit 32bed3a06f
2 changed files with 11 additions and 10 deletions

View File

@ -682,7 +682,7 @@ void _eReaderReset(struct GBACartridgeHardware* hw) {
hw->eReaderRegisterControl0 = 0;
hw->eReaderRegisterControl1 = 0x80;
hw->eReaderRegisterLed = 0;
hw->eReaderState = false;
hw->eReaderState = 0;
hw->eReaderActiveRegister = 0;
}
@ -738,7 +738,7 @@ void _eReaderWriteControl0(struct GBACartridgeHardware* hw, uint8_t value) {
++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 @@ void _eReaderWriteControl0(struct GBACartridgeHardware* hw, uint8_t value) {
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 @@ void _eReaderWriteControl1(struct GBACartridgeHardware* hw, uint8_t 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);
}
}

View File

@ -917,6 +917,7 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
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);