Fix restoring to ID 0xC22017 cards (#107)

This commit is contained in:
Pk11 2021-09-15 17:31:57 -05:00 committed by GitHub
parent 520327dcdf
commit c7694df14c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,7 @@ int cardEepromGetTypeFixed(void) {
//---------------------------------------------------------------------------------
// https://github.com/devkitPro/libnds/blob/master/source/common/cardEeprom.c#L88
// with type 2 fixed if the first word and another % 8192 location are 0x00000000
// and type 3 with ID 0xC22017 added
uint32 cardEepromGetSizeFixed() {
//---------------------------------------------------------------------------------
@ -142,6 +143,20 @@ uint32 cardEepromGetSizeFixed() {
return 0;
}
//---------------------------------------------------------------------------------
// https://github.com/devkitPro/libnds/blob/master/source/common/cardEeprom.c#L263
// but using our fixed size function
//---------------------------------------------------------------------------------
void cardEepromChipEraseFixed(void) {
//---------------------------------------------------------------------------------
int sz, sector;
sz=cardEepromGetSizeFixed();
for ( sector = 0; sector < sz; sector+=0x10000) {
cardEepromSectorErase(sector);
}
}
void ndsCardSaveDump(const char* filename) {
FILE *out = fopen(filename, "wb");
if(out) {
@ -264,7 +279,7 @@ void ndsCardSaveRestore(const char *filename) {
if(auxspi)
auxspi_erase(card_type);
else
cardEepromChipErase();
cardEepromChipEraseFixed();
}
if(auxspi){
buffer = new unsigned char[LEN];