From 3756f3cb1f1434ed06c96e8bd36139c1f53525ff Mon Sep 17 00:00:00 2001 From: Arisotura Date: Mon, 14 Mar 2022 18:08:29 +0100 Subject: [PATCH] make invalid SPI memory commands return 0xFF. fixes #1366 (Dementium II checks the results of RDSR, RDID and cmd 00 to determine what kind of backup memory is present) --- src/NDSCart.cpp | 14 +++++++------- src/SPI.cpp | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index e97da70d..fe02cb17 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -529,17 +529,17 @@ u8 CartRetail::SPIWrite(u8 val, u32 pos, bool last) { case 0x04: // write disable SRAMStatus &= ~(1<<1); - break; + return 0; case 0x06: // write enable SRAMStatus |= (1<<1); - break; + return 0; default: SRAMCmd = val; SRAMAddr = 0; } - return 0; + return 0xFF; } switch (SRAMType) @@ -547,7 +547,7 @@ u8 CartRetail::SPIWrite(u8 val, u32 pos, bool last) case 1: return SRAMWrite_EEPROMTiny(val, pos, last); case 2: return SRAMWrite_EEPROM(val, pos, last); case 3: return SRAMWrite_FLASH(val, pos, last); - default: return 0; + default: return 0xFF; } } @@ -628,7 +628,7 @@ u8 CartRetail::SRAMWrite_EEPROMTiny(u8 val, u32 pos, bool last) default: if (pos == 1) printf("unknown tiny EEPROM save command %02X\n", SRAMCmd); - return 0; + return 0xFF; } } @@ -694,7 +694,7 @@ u8 CartRetail::SRAMWrite_EEPROM(u8 val, u32 pos, bool last) default: if (pos == 1) printf("unknown EEPROM save command %02X\n", SRAMCmd); - return 0; + return 0xFF; } } @@ -838,7 +838,7 @@ u8 CartRetail::SRAMWrite_FLASH(u8 val, u32 pos, bool last) default: if (pos == 1) printf("unknown FLASH save command %02X\n", SRAMCmd); - return 0; + return 0xFF; } } diff --git a/src/SPI.cpp b/src/SPI.cpp index f46e68e0..613ca693 100644 --- a/src/SPI.cpp +++ b/src/SPI.cpp @@ -564,6 +564,7 @@ void Write(u8 val, u32 hold) default: printf("unknown firmware SPI command %02X\n", CurCmd); + Data = 0xFF; break; }