Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Dec 14, 2024
1 parent 7cc8507 commit 8d1e2ba
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions retail/bootloaderi/source/arm7/ips.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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++;
Expand All @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 8d1e2ba

Please sign in to comment.