From c7694df14c2c5098482b4e9068e8de374d94f596 Mon Sep 17 00:00:00 2001 From: Pk11 Date: Wed, 15 Sep 2021 17:31:57 -0500 Subject: [PATCH] Fix restoring to ID 0xC22017 cards (#107) --- arm9/source/dumpOperations.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arm9/source/dumpOperations.cpp b/arm9/source/dumpOperations.cpp index ed14efe..2437aed 100644 --- a/arm9/source/dumpOperations.cpp +++ b/arm9/source/dumpOperations.cpp @@ -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];