Skip to content

Commit a28b779

Browse files
committed
Fix ROMs with odd ROM sizes not booting
Hacks like Another Super Mario 3D works again.
1 parent c4025ca commit a28b779

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cardengine_arm9/source/cardEngine.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,17 @@ int cardRead (u32* cacheStruct) {
384384
u32 ARM9_LEN = tempNdsHeader[0x02C>>2];
385385
// Check ROM size in ROM header...
386386
u32 romSize = tempNdsHeader[0x080>>2];
387+
if((romSize & 0x0000000F) == 0x1
388+
|| (romSize & 0x0000000F) == 0x3
389+
|| (romSize & 0x0000000F) == 0x5
390+
|| (romSize & 0x0000000F) == 0x7
391+
|| (romSize & 0x0000000F) == 0x9
392+
|| (romSize & 0x0000000F) == 0xB
393+
|| (romSize & 0x0000000F) == 0xD
394+
|| (romSize & 0x0000000F) == 0xF)
395+
{
396+
romSize--; // If ROM size is at an odd number, subtract 1 from it.
397+
}
387398
romSize -= 0x4000;
388399
romSize -= ARM9_LEN;
389400

0 commit comments

Comments
 (0)