Skip to content

Commit cc234a4

Browse files
committed
Fix SDK5 games crashing later on
1 parent fba925c commit cc234a4

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

retail/bootloaderi/source/arm7/hook_arm9.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ int hookNdsRetailArm9(
213213
extern u32 dataToPreloadAddr;
214214
extern u32 dataToPreloadSize;
215215
// extern u32 dataToPreloadFrame;
216-
extern bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool dsiBios, u32* romLocation);
216+
extern bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool isSdk5, const bool dsiBios, u32* romLocation);
217217
extern bool dataToPreloadFound(const tNDSHeader* ndsHeader);
218218
const char* romTid = getRomTid(ndsHeader);
219219
const bool laterSdk = ((moduleParams->sdk_version >= 0x2008000 && moduleParams->sdk_version != 0x2012774) || moduleParams->sdk_version == 0x20029A8);
@@ -340,7 +340,7 @@ int hookNdsRetailArm9(
340340
configureRomMap(ce9, ndsHeader, dataToPreloadAddr, dsiMode);
341341
for (u32 i = 0; i < dataToPreloadSize/*+dataToPreloadSize[1]*/; i += cacheBlockSize) {
342342
ce9->cacheAddress += cacheBlockSize;
343-
romLocationAdjust(ndsHeader, laterSdk, (ce9->valueBits & b_dsiBios), &ce9->cacheAddress);
343+
romLocationAdjust(ndsHeader, laterSdk, (ce9->valueBits & b_dsiBios), (ce9->valueBits & b_isSdk5), &ce9->cacheAddress);
344344
dataToPreloadSizeAligned += cacheBlockSize;
345345
}
346346
ce9->cacheSlots -= dataToPreloadSizeAligned/cacheBlockSize;
@@ -385,7 +385,7 @@ int hookNdsRetailArm9(
385385
u32 addr = ce9->cacheAddress;
386386

387387
for (int slot = 0; slot < ce9->cacheSlots; slot++) {
388-
romLocationAdjust(ndsHeader, laterSdk, (ce9->valueBits & b_dsiBios), &addr);
388+
romLocationAdjust(ndsHeader, laterSdk, (ce9->valueBits & b_dsiBios), (ce9->valueBits & b_isSdk5), &addr);
389389
cacheAddressTable[slot] = addr;
390390
addr += cacheBlockSize;
391391
}

retail/bootloaderi/source/arm7/ips.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only
2525

2626
bool armPatched = false;
2727
const bool dsiBios = scfgBios9i();
28-
extern bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool dsiBios, u32* romLocation);
28+
extern bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool isSdk5, const bool dsiBios, u32* romLocation);
2929

3030
int ipson = 5;
3131
int totalrepeats = 0;
@@ -77,7 +77,7 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only
7777
rombyteOffset++;
7878
if (ROMinRAM && (ndsHeader->unitCode == 0 || !dsiModeConfirmed)) {
7979
u32 u32_rombyteOffset = (u32)rombyteOffset;
80-
romLocationAdjust(ndsHeader, laterSdk, dsiBios, &u32_rombyteOffset);
80+
romLocationAdjust(ndsHeader, laterSdk, isSdk5, dsiBios, &u32_rombyteOffset);
8181
rombyteOffset = (u8*)u32_rombyteOffset;
8282
}
8383
}
@@ -92,7 +92,7 @@ bool applyIpsPatch(const tNDSHeader* ndsHeader, u8* ipsbyte, const bool arm9Only
9292
rombyteOffset++;
9393
if (ROMinRAM && (ndsHeader->unitCode == 0 || !dsiModeConfirmed)) {
9494
u32 u32_rombyteOffset = (u32)rombyteOffset;
95-
romLocationAdjust(ndsHeader, laterSdk, dsiBios, &u32_rombyteOffset);
95+
romLocationAdjust(ndsHeader, laterSdk, isSdk5, dsiBios, &u32_rombyteOffset);
9696
rombyteOffset = (u8*)u32_rombyteOffset;
9797
}
9898
}

retail/bootloaderi/source/arm7/main.arm7.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,12 @@ u32 getRomLocation(const tNDSHeader* ndsHeader, const bool isESdk2, const bool i
809809
return getRomPartLocation(ndsHeader, isESdk2, isSdk5, dsiBios);
810810
}
811811

812-
bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool dsiBios, u32* romLocation) {
812+
bool romLocationAdjust(const tNDSHeader* ndsHeader, const bool laterSdk, const bool isSdk5, const bool dsiBios, u32* romLocation) {
813813
const bool ntrType = (ndsHeader->unitCode == 0);
814814
const u32 romLocationOld = *romLocation;
815815
if (*romLocation == 0x0C3FC000) {
816816
*romLocation += 0x4000;
817-
} else if (*romLocation == 0x0C7C0000 && ((laterSdk && !dsiBios) || !laterSdk) && ntrType) {
817+
} else if (*romLocation == 0x0C7C0000 && ((laterSdk && !dsiBios) || !laterSdk) && !isSdk5) {
818818
*romLocation += laterSdk ? 0x8000 : 0x28000;
819819
} else if (*romLocation == 0x0C7C4000) {
820820
*romLocation += 0x4000;
@@ -1167,7 +1167,7 @@ static void buildRomMap(const tNDSHeader* ndsHeader, const module_params_t* modu
11671167
romLocationChangePrep += 0x4000;
11681168
romSizeEdit -= 0x4000;
11691169

1170-
readRom = (romSizeEdit <= 0) ? true : romLocationAdjust(ndsHeader, laterSdk, dsiBios, &romLocationChangePrep);
1170+
readRom = (romSizeEdit <= 0) ? true : romLocationAdjust(ndsHeader, laterSdk, isSdk5(moduleParams), dsiBios, &romLocationChangePrep);
11711171

11721172
// dbg_hexa(romLocationChangePrep);
11731173

0 commit comments

Comments
 (0)