From e1711e2f3325ae914b70b94f0fc8f403cee6b3f2 Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Sat, 28 Dec 2024 18:28:42 -0700 Subject: [PATCH] Do not apply AP-fix for SRL loaded from page file --- retail/bootloader/source/arm7/main.arm7.c | 2 +- retail/bootloaderi/source/arm7/main.arm7.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/retail/bootloader/source/arm7/main.arm7.c b/retail/bootloader/source/arm7/main.arm7.c index a13a8e373..c30ff1725 100644 --- a/retail/bootloader/source/arm7/main.arm7.c +++ b/retail/bootloader/source/arm7/main.arm7.c @@ -1699,7 +1699,7 @@ int arm7_main(void) { fileWrite((char*)&patchOffsetCache, &patchOffsetCacheFile, 0, sizeof(patchOffsetCacheContents)); } - if (srlAddr == 0 && apPatchFileCluster != 0 && !apPatchIsCheat && apPatchSize > 0 && apPatchSize <= 0x40000) { + if (srlAddr == 0 && !srlFromPageFile && apPatchFileCluster != 0 && !apPatchIsCheat && apPatchSize > 0 && apPatchSize <= 0x40000) { aFile apPatchFile; getFileFromCluster(&apPatchFile, apPatchFileCluster); dbg_printf("AP-fix found\n"); diff --git a/retail/bootloaderi/source/arm7/main.arm7.c b/retail/bootloaderi/source/arm7/main.arm7.c index 138f2be14..661f7cc30 100644 --- a/retail/bootloaderi/source/arm7/main.arm7.c +++ b/retail/bootloaderi/source/arm7/main.arm7.c @@ -159,6 +159,7 @@ bool overlaysInRam = false; static aFile patchOffsetCacheFile; u32 waitSysCyclesOffset = 0; static u32 softResetParams[0x50/4] = {0}; +bool srlFromPageFile = false; u32 srlAddr = 0; u32 baseArm9Off = 0; u32 baseArm9Size = 0; @@ -692,8 +693,7 @@ static void loadBinary_ARM7(const tDSiHeader* dsiHeaderTemp, aFile* file) { // Read DSi header (including NDS header) //fileRead((char*)ndsHeader, file, 0, 0x170, 3); //fileRead((char*)dsiHeader, file, 0, 0x2F0, 2); // SDK 5 - bool separateSrl = (softResetParams[2] == 0x44414F4C); // 'LOAD' - if (separateSrl) { + if (srlFromPageFile) { srlAddr = 0xFFFFFFFF; aFile pageFile; getFileFromCluster(&pageFile, pageFileCluster, bootstrapOnFlashcard); @@ -1591,7 +1591,8 @@ int arm7_main(void) { aFile srParamsFile; getFileFromCluster(&srParamsFile, srParamsFileCluster, gameOnFlashcard); fileRead((char*)&softResetParams, &srParamsFile, 0, 0x50); - bool softResetParamsFound = (softResetParams[0] != 0xFFFFFFFF || softResetParams[2] == 0x44414F4C); + srlFromPageFile = (softResetParams[2] == 0x44414F4C); // 'LOAD' + bool softResetParamsFound = (softResetParams[0] != 0xFFFFFFFF || srlFromPageFile || softResetParams[3] != 0); if (softResetParamsFound) { u32 clearBuffer = 0xFFFFFFFF; fileWrite((char*)&clearBuffer, &srParamsFile, 0, 0x4); @@ -2168,7 +2169,7 @@ int arm7_main(void) { tonccpy((char*)SAV_FILE_LOCATION_MAINMEM, savFile, sizeof(aFile)); } - const bool useApPatch = (srlAddr == 0 && apPatchFileCluster != 0 && !apPatchIsCheat && apPatchSize > 0 && apPatchSize <= 0x40000); + const bool useApPatch = (srlAddr == 0 && !srlFromPageFile && apPatchFileCluster != 0 && !apPatchIsCheat && apPatchSize > 0 && apPatchSize <= 0x40000); if (useApPatch) { aFile apPatchFile;