From 568c4dde5f0186e7e96ccba7f013c30e98a856eb Mon Sep 17 00:00:00 2001 From: Pk11 Date: Tue, 2 Nov 2021 18:39:46 -0500 Subject: [PATCH] Fix overdumping GBA ROMs Thanks to gba-link-cable-dumper https://github.com/FIX94/gba-link-cable-dumper/blob/master/gba/source/main.c#L19-L40 --- arm9/source/dumpOperations.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arm9/source/dumpOperations.cpp b/arm9/source/dumpOperations.cpp index e7d324c..705ac6b 100644 --- a/arm9/source/dumpOperations.cpp +++ b/arm9/source/dumpOperations.cpp @@ -932,14 +932,20 @@ void gbaCartDump(void) { font->update(false); // Determine ROM size - u32 romSize = 0x02000000; - for (u32 i = 0x09FE0000; i > 0x08000000; i -= 0x20000) { - if (*(u32*)(i) == 0xFFFE0000) { - romSize -= 0x20000; - } else { - break; + u32 romSize; + for (romSize = (1 << 20); romSize < (1 << 25); romSize <<= 1) { + vu16 *rompos = (vu16*)(0x08000000 + romSize); + bool romend = true; + for (int j = 0; j < 0x1000; j++) { + if (rompos[j] != j) { + romend = false; + break; + } } + if (romend) + break; } + // Dump! remove(destPath); // Reset data at virtual address