Skip to content

Commit

Permalink
make invalid SPI memory commands return 0xFF. fixes melonDS-emu#1366
Browse files Browse the repository at this point in the history
…(Dementium II checks the results of RDSR, RDID and cmd 00 to determine what kind of backup memory is present)
  • Loading branch information
Arisotura committed Mar 14, 2022
1 parent 5415f8a commit 3756f3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/NDSCart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,25 +529,25 @@ 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)
{
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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ void Write(u8 val, u32 hold)

default:
printf("unknown firmware SPI command %02X\n", CurCmd);
Data = 0xFF;
break;
}

Expand Down

0 comments on commit 3756f3c

Please sign in to comment.