From 8d1e2ba89e1a6dfa73747644acbb103b02335569 Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Sat, 14 Dec 2024 15:26:07 -0700 Subject: [PATCH] Bug fix --- retail/bootloaderi/source/arm7/ips.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/retail/bootloaderi/source/arm7/ips.c b/retail/bootloaderi/source/arm7/ips.c index f3727b0d7..e102fe89a 100644 --- a/retail/bootloaderi/source/arm7/ips.c +++ b/retail/bootloaderi/source/arm7/ips.c @@ -56,9 +56,7 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only } else { rombyte -= ndsHeader->arm9overlaySource; } - if ((u32)rombyte == (consoleModel > 0 ? 0x0E000000 : 0x0D000000)) { - rombyte = (void*)0x03708000; - } else if (isSdk5 || (dsiBios && !isESdk2)) { + if (isSdk5 || (dsiBios && !isESdk2)) { if (romLocation < (ndsHeader->unitCode > 0 ? 0x0C7E0000 : 0x0C800000) && (u32)rombyte >= 0x0C7C4000) { rombyte += (ndsHeader->unitCode > 0 ? 0x1C000 : 0x3C000); } else if (ndsHeader->unitCode == 0) { @@ -77,6 +75,9 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only } else if (romLocation < 0x0C800000 && (u32)rombyte >= 0x0C7C0000) { rombyte += 0x40000; } + if ((u32)rombyte == (consoleModel > 0 ? 0x0E000000 : 0x0D000000)) { + rombyte = (void*)0x03708000; + } } else { rombyte = (void*)CACHE_ADRESS_START_DSIMODE; rombyte -= (ndsHeader->arm9overlaySource/cacheBlockSize)*cacheBlockSize; @@ -97,9 +98,7 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only *rombyteOffset = repeatbyte[i]; rombyteOffset++; if (ROMinRAM && (ndsHeader->unitCode == 0 || !dsiModeConfirmed)) { - if ((u32)rombyteOffset == (consoleModel > 0 ? 0x0E000000 : 0x0D000000)) { - rombyteOffset = (u8*)0x03708000; - } else if (isSdk5 || (dsiBios && !isESdk2)) { + if (isSdk5 || (dsiBios && !isESdk2)) { if ((u32)rombyteOffset == 0x0C7C4000) { rombyteOffset += (ndsHeader->unitCode > 0 ? 0x1C000 : 0x3C000); } else if (ndsHeader->unitCode == 0) { @@ -118,6 +117,9 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only } else if ((u32)rombyteOffset == 0x0C7C0000) { rombyteOffset += 0x40000; } + if ((u32)rombyteOffset == (consoleModel > 0 ? 0x0E000000 : 0x0D000000)) { + rombyteOffset = (u8*)0x03708000; + } } } ipson++; @@ -130,9 +132,7 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only *rombyteOffset = ipsbyte[ipson+i]; rombyteOffset++; if (ROMinRAM && (ndsHeader->unitCode == 0 || !dsiModeConfirmed)) { - if ((u32)rombyteOffset == (consoleModel > 0 ? 0x0E000000 : 0x0D000000)) { - rombyteOffset = (u8*)0x03708000; - } else if (isSdk5 || (dsiBios && !isESdk2)) { + if (isSdk5 || (dsiBios && !isESdk2)) { if ((u32)rombyteOffset == 0x0C7C4000) { rombyteOffset += (ndsHeader->unitCode > 0 ? 0x1C000 : 0x3C000); } else if (ndsHeader->unitCode == 0) { @@ -151,6 +151,9 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only } else if ((u32)rombyteOffset == 0x0C7C0000) { rombyteOffset += 0x40000; } + if ((u32)rombyteOffset == (consoleModel > 0 ? 0x0E000000 : 0x0D000000)) { + rombyteOffset = (u8*)0x03708000; + } } } ipson += totalrepeats;