Skip to content

Commit

Permalink
B4DS: Add support for 3 proto builds of *Shantae: Risky's Revenge*
Browse files Browse the repository at this point in the history
Builds:
- Publisher Review
- 06/23/10 build
- 10/27/10 build (Normal)
  • Loading branch information
RocketRobz committed Feb 27, 2024
1 parent ab5ea03 commit bdf51b6
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 102 deletions.
6 changes: 5 additions & 1 deletion retail/arm9/source/conf_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
|| strncmp(romTid, "K6T", 3) == 0 // Orion's Odyssey
|| strncmp(romTid, "KPS", 3) == 0 // Phantasy Star 0 Mini
|| strncmp(romTid, "KHR", 3) == 0 // Picture Perfect: Hair Stylist
|| strncmp(romTid, "KS3", 3) == 0 // Shantae: Risky's Revenge
|| ((strncmp(romTid, "KS3", 3) == 0) && (headerCRC == 0x57FE || headerCRC == 0x2BFA)) // Shantae: Risky's Revenge (Non-proto builds and clean ROMs)
|| strncmp(romTid, "KZU", 3) == 0 // Tales to Enjoy!: Little Red Riding Hood
|| strncmp(romTid, "KZV", 3) == 0 // Tales to Enjoy!: Puss in Boots
|| strncmp(romTid, "KZ7", 3) == 0 // Tales to Enjoy!: The Three Little Pigs
Expand Down Expand Up @@ -1981,6 +1981,10 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
}
}

if (!conf->loader2 && (strcmp(romTid, "NTRJ") == 0) && (headerCRC == 0x9B41)) { // Use bootloader2 for Shantae: Risky's Revenge (USA) (Review Build)
conf->loader2 = true;
}

const char *typeToReplace = ".nds";
if (extention(conf->ndsPath, ".dsi")) {
typeToReplace = ".dsi";
Expand Down
252 changes: 196 additions & 56 deletions retail/bootloader/source/arm7/dsi2ds_patches.c
Original file line number Diff line number Diff line change
Expand Up @@ -22085,71 +22085,211 @@ void patchDSiModeToDSMode(cardengineArm9* ce9, const tNDSHeader* ndsHeader) {
}
}

// Shantae: Risky's Revenge (USA)
// Shantae: Risky's Revenge (USA) (Review Build)
// Requires 8MB of RAM, crashes after first battle with 4MB of RAM, but can get past with a save file
// BGM is disabled to stay within RAM limitations
else if (strcmp(romTid, "KS3E") == 0) {
else if ((strcmp(romTid, "NTRJ") == 0) && (ndsHeader->headerCRC16 == 0x9B41)) {
ce9->rumbleFrames[0] = 10;
ce9->rumbleForce[0] = 1;
ce9->patches->rumble_arm9[0][3] = *(u32*)0x02026F68;

// Skip Manual screen
/* *(u32*)0x02016130 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
*(u32*)0x020161C8 = 0xE1A00000; // nop
*(u32*)0x020161D0 = 0xE1A00000; // nop
*(u32*)0x020161DC = 0xE1A00000; // nop
*(u32*)0x020166C8 = 0xE3A06901; // mov r6, #0x4000 */
ce9->patches->rumble_arm9[0][3] = *(u32*)0x02026E44;

// Hide help button
*(u32*)0x02016688 = 0xE1A00000; // nop
*(u32*)0x02015874 = 0xE1A00000; // nop

if (!extendedMemory) {
// Disable pre-load function
/* *(u32*)0x0201FBA0 = 0xE12FFF1E; // bx lr
*(u32*)0x0201FD3C = 0xE12FFF1E; // bx lr
*(u32*)0x0201FDA8 = 0xE12FFF1E; // bx lr
*(u32*)0x0201FE14 = 0xE12FFF1E; // bx lr */
// *(u32*)0x020AB800 = 0xE1A00000; // nop
*(u32*)0x020BCE44 = 0xE12FFF1E; // bx lr
}
*(u32*)0x0201FC20 = 0xE12FFF1E; // bx lr (Disable loading sdat file)
tonccpy((u32*)0x0201FC40, ce9->patches->musicPlay, 0xC);
tonccpy((u32*)0x0201FC78, ce9->patches->musicStopEffect, 0xC);
setBL(0x02026F68, (int)ce9->patches->rumble_arm9[0]); // Rumble when hair is whipped
setBL(0x0209201C, (u32)dsiSaveCreate);
setBL(0x02092040, (u32)dsiSaveGetResultCode);
*(u32*)0x02092050 = 0xE1A00000; // nop
setBL(0x0209205C, (u32)dsiSaveCreate);
*(u32*)0x02092078 = 0xE3A00000; // mov r0, #0
setBL(0x0209291C, (u32)dsiSaveOpen);
*(u32*)0x02092934 = 0xE1A00000; // nop
setBL(0x02092944, (u32)dsiSaveOpen);
setBL(0x02092958, (u32)dsiSaveRead);
setBL(0x02092960, (u32)dsiSaveClose);
*(u32*)0x02092BA8 = 0xE1A00000; // nop
setBL(0x02092BCC, (u32)dsiSaveCreate);
setBL(0x02092BDC, (u32)dsiSaveOpen);
setBL(0x02092DE4, (u32)dsiSaveSetLength);
setBL(0x02092DF4, (u32)dsiSaveWrite);
setBL(0x02092DFC, (u32)dsiSaveClose);
*(u32*)0x02092E08 = 0xE1A00000; // nop
*(u32*)0x02092E0C = 0xE1A00000; // nop
*(u32*)0x02092E10 = 0xE1A00000; // nop
*(u32*)0x02092E14 = 0xE1A00000; // nop
*(u32*)0x02092E20 = 0xE1A00000; // nop
*(u32*)0x02092E24 = 0xE1A00000; // nop
*(u32*)0x020DE420 = 0xE1A00000; // nop
*(u32*)0x020DE548 = 0xE1A00000; // nop
*(u32*)0x020DE55C = 0xE1A00000; // nop
*(u32*)0x020E20C4 = 0xE1A00000; // nop
patchInitDSiWare(0x020E7ED8, heapEndMaxForRetailMus);
*(u32*)0x020E8264 = *(u32*)0x02004FD0;
patchUserSettingsReadDSiWare(0x020E9348);
*(u32*)0x020E977C = 0xE1A00000; // nop
*(u32*)0x020E9780 = 0xE1A00000; // nop
*(u32*)0x020E9784 = 0xE1A00000; // nop
*(u32*)0x020E9788 = 0xE1A00000; // nop
*(u32*)0x020E9794 = 0xE1A00000; // nop (Enable error exception screen)
*(u32*)0x020B80A4 = 0xE12FFF1E; // bx lr
}
*(u32*)0x02020404 = 0xE12FFF1E; // bx lr (Disable loading sdat file)
tonccpy((u32*)0x02020424, ce9->patches->musicPlay, 0xC);
tonccpy((u32*)0x0202045C, ce9->patches->musicStopEffect, 0xC);
setBL(0x02026E44, (int)ce9->patches->rumble_arm9[0]); // Rumble when hair is whipped
setBL(0x0208B9A0, (u32)dsiSaveCreate);
setBL(0x0208B9C4, (u32)dsiSaveGetResultCode);
*(u32*)0x0208B9D4 = 0xE1A00000; // nop
setBL(0x0208B9E0, (u32)dsiSaveCreate);
*(u32*)0x0208B9F0 = 0xE3A00000; // mov r0, #0
setBL(0x0208C054, (u32)dsiSaveOpen);
*(u32*)0x0208C06C = 0xE1A00000; // nop
setBL(0x0208C07C, (u32)dsiSaveOpen);
setBL(0x0208C090, (u32)dsiSaveRead);
setBL(0x0208C098, (u32)dsiSaveClose);
setBL(0x0208C310, (u32)dsiSaveCreate);
setBL(0x0208C320, (u32)dsiSaveOpen);
setBL(0x0208C52C, (u32)dsiSaveSetLength);
setBL(0x0208C53C, (u32)dsiSaveWrite);
setBL(0x0208C544, (u32)dsiSaveClose);
*(u32*)0x020D9E28 = 0xE1A00000; // nop
*(u32*)0x020D9F64 = 0xE1A00000; // nop
*(u32*)0x020D9F78 = 0xE1A00000; // nop
*(u32*)0x020DDCD0 = 0xE1A00000; // nop
patchInitDSiWare(0x020E4610, heapEndMaxForRetailMus);
*(u32*)0x020E499C = *(u32*)0x02005020;
patchUserSettingsReadDSiWare(0x020E5B88);
*(u32*)0x020E607C = 0xE1A00000; // nop
*(u32*)0x020E6080 = 0xE1A00000; // nop
*(u32*)0x020E6084 = 0xE1A00000; // nop
*(u32*)0x020E6088 = 0xE1A00000; // nop
*(u32*)0x020E6094 = 0xE1A00000; // nop (Enable error exception screen)
}

// Shantae: Risky's Revenge (USA)
// Requires 8MB of RAM, crashes after first battle with 4MB of RAM, but can get past with a save file
// BGM is disabled to stay within RAM limitations
else if (strcmp(romTid, "KS3E") == 0) {
ce9->rumbleFrames[0] = 10;
ce9->rumbleForce[0] = 1;

if (ndsHeader->headerCRC16 == 0xC9EC) { // Prototype build: 10/27/10 (Normal)
ce9->patches->rumble_arm9[0][3] = *(u32*)0x0202A548;

// Hide help button
*(u32*)0x02016BE4 = 0xE1A00000; // nop

if (!extendedMemory) {
// Disable pre-load function
*(u32*)0x020C76E0 = 0xE12FFF1E; // bx lr
}
*(u32*)0x02022EF0 = 0xE12FFF1E; // bx lr (Disable loading sdat file)
tonccpy((u32*)0x02022F10, ce9->patches->musicPlay, 0xC);
tonccpy((u32*)0x02022F48, ce9->patches->musicStopEffect, 0xC);
setBL(0x0202A548, (int)ce9->patches->rumble_arm9[0]); // Rumble when hair is whipped
setBL(0x02098B60, (u32)dsiSaveCreate);
setBL(0x02098B84, (u32)dsiSaveGetResultCode);
*(u32*)0x02098B94 = 0xE1A00000; // nop
setBL(0x02098BA0, (u32)dsiSaveCreate);
*(u32*)0x02098BBC = 0xE3A00000; // mov r0, #0
setBL(0x020997C0, (u32)dsiSaveOpen);
*(u32*)0x020997D8 = 0xE1A00000; // nop
setBL(0x020997E8, (u32)dsiSaveOpen);
setBL(0x020997FC, (u32)dsiSaveRead);
setBL(0x02099804, (u32)dsiSaveClose);
*(u32*)0x02099A64 = 0xE1A00000; // nop
setBL(0x02099A88, (u32)dsiSaveCreate);
setBL(0x02099A98, (u32)dsiSaveOpen);
setBL(0x02099CA0, (u32)dsiSaveSetLength);
setBL(0x02099CB0, (u32)dsiSaveWrite);
setBL(0x02099CB8, (u32)dsiSaveClose);
*(u32*)0x02099CC4 = 0xE1A00000; // nop
*(u32*)0x02099CC8 = 0xE1A00000; // nop
*(u32*)0x02099CCC = 0xE1A00000; // nop
*(u32*)0x02099CD0 = 0xE1A00000; // nop
*(u32*)0x02099CDC = 0xE1A00000; // nop
*(u32*)0x02099CE0 = 0xE1A00000; // nop
*(u32*)0x020E9848 = 0xE1A00000; // nop
*(u32*)0x020E9984 = 0xE1A00000; // nop
*(u32*)0x020E9998 = 0xE1A00000; // nop
*(u32*)0x020ED778 = 0xE1A00000; // nop
patchInitDSiWare(0x020F40DC, heapEndMaxForRetailMus);
*(u32*)0x020F4468 = *(u32*)0x02005038;
patchUserSettingsReadDSiWare(0x020F5654);
*(u32*)0x020F5B48 = 0xE1A00000; // nop
*(u32*)0x020F5B4C = 0xE1A00000; // nop
*(u32*)0x020F5B50 = 0xE1A00000; // nop
*(u32*)0x020F5B54 = 0xE1A00000; // nop
*(u32*)0x020F5B60 = 0xE1A00000; // nop (Enable error exception screen)
} else if (ndsHeader->headerCRC16 == 0x4D03) { // Prototype build: 06/23/10
ce9->patches->rumble_arm9[0][3] = *(u32*)0x02029F94;

// Hide help button
*(u32*)0x020167C8 = 0xE1A00000; // nop

if (!extendedMemory) {
// Disable pre-load function
*(u32*)0x020C73F0 = 0xE12FFF1E; // bx lr
}
*(u32*)0x020229D0 = 0xE12FFF1E; // bx lr (Disable loading sdat file)
tonccpy((u32*)0x020229F0, ce9->patches->musicPlay, 0xC);
tonccpy((u32*)0x02022A28, ce9->patches->musicStopEffect, 0xC);
setBL(0x02029F94, (int)ce9->patches->rumble_arm9[0]); // Rumble when hair is whipped
setBL(0x020984C4, (u32)dsiSaveCreate);
setBL(0x020984E8, (u32)dsiSaveGetResultCode);
*(u32*)0x020984F8 = 0xE1A00000; // nop
setBL(0x02098504, (u32)dsiSaveCreate);
*(u32*)0x02098520 = 0xE3A00000; // mov r0, #0
setBL(0x02098E74, (u32)dsiSaveOpen);
*(u32*)0x02098E8C = 0xE1A00000; // nop
setBL(0x02098E9C, (u32)dsiSaveOpen);
setBL(0x02098EB0, (u32)dsiSaveRead);
setBL(0x02098EB8, (u32)dsiSaveClose);
setBL(0x02099130, (u32)dsiSaveCreate);
setBL(0x02099140, (u32)dsiSaveOpen);
setBL(0x0209934C, (u32)dsiSaveSetLength);
setBL(0x0209935C, (u32)dsiSaveWrite);
setBL(0x02099364, (u32)dsiSaveClose);
*(u32*)0x020E95B8 = 0xE1A00000; // nop
*(u32*)0x020E96F4 = 0xE1A00000; // nop
*(u32*)0x020E9708 = 0xE1A00000; // nop
*(u32*)0x020ED460 = 0xE1A00000; // nop
patchInitDSiWare(0x020F3DA0, heapEndMaxForRetailMus);
*(u32*)0x020F412C = *(u32*)0x02005020;
patchUserSettingsReadDSiWare(0x020F5318);
*(u32*)0x020F580C = 0xE1A00000; // nop
*(u32*)0x020F5810 = 0xE1A00000; // nop
*(u32*)0x020F5814 = 0xE1A00000; // nop
*(u32*)0x020F5818 = 0xE1A00000; // nop
*(u32*)0x020F5824 = 0xE1A00000; // nop (Enable error exception screen)
} else { // Final release
ce9->patches->rumble_arm9[0][3] = *(u32*)0x02026F68;

// Skip Manual screen
/* *(u32*)0x02016130 = 0xE1A00000; // nop (Disable NFTR loading from TWLNAND)
*(u32*)0x020161C8 = 0xE1A00000; // nop
*(u32*)0x020161D0 = 0xE1A00000; // nop
*(u32*)0x020161DC = 0xE1A00000; // nop
*(u32*)0x020166C8 = 0xE3A06901; // mov r6, #0x4000 */

// Hide help button
*(u32*)0x02016688 = 0xE1A00000; // nop

if (!extendedMemory) {
// Disable pre-load function
/* *(u32*)0x0201FBA0 = 0xE12FFF1E; // bx lr
*(u32*)0x0201FD3C = 0xE12FFF1E; // bx lr
*(u32*)0x0201FDA8 = 0xE12FFF1E; // bx lr
*(u32*)0x0201FE14 = 0xE12FFF1E; // bx lr */
// *(u32*)0x020AB800 = 0xE1A00000; // nop
*(u32*)0x020BCE44 = 0xE12FFF1E; // bx lr
}
*(u32*)0x0201FC20 = 0xE12FFF1E; // bx lr (Disable loading sdat file)
tonccpy((u32*)0x0201FC40, ce9->patches->musicPlay, 0xC);
tonccpy((u32*)0x0201FC78, ce9->patches->musicStopEffect, 0xC);
setBL(0x02026F68, (int)ce9->patches->rumble_arm9[0]); // Rumble when hair is whipped
setBL(0x0209201C, (u32)dsiSaveCreate);
setBL(0x02092040, (u32)dsiSaveGetResultCode);
*(u32*)0x02092050 = 0xE1A00000; // nop
setBL(0x0209205C, (u32)dsiSaveCreate);
*(u32*)0x02092078 = 0xE3A00000; // mov r0, #0
setBL(0x0209291C, (u32)dsiSaveOpen);
*(u32*)0x02092934 = 0xE1A00000; // nop
setBL(0x02092944, (u32)dsiSaveOpen);
setBL(0x02092958, (u32)dsiSaveRead);
setBL(0x02092960, (u32)dsiSaveClose);
*(u32*)0x02092BA8 = 0xE1A00000; // nop
setBL(0x02092BCC, (u32)dsiSaveCreate);
setBL(0x02092BDC, (u32)dsiSaveOpen);
setBL(0x02092DE4, (u32)dsiSaveSetLength);
setBL(0x02092DF4, (u32)dsiSaveWrite);
setBL(0x02092DFC, (u32)dsiSaveClose);
*(u32*)0x02092E08 = 0xE1A00000; // nop
*(u32*)0x02092E0C = 0xE1A00000; // nop
*(u32*)0x02092E10 = 0xE1A00000; // nop
*(u32*)0x02092E14 = 0xE1A00000; // nop
*(u32*)0x02092E20 = 0xE1A00000; // nop
*(u32*)0x02092E24 = 0xE1A00000; // nop
*(u32*)0x020DE420 = 0xE1A00000; // nop
*(u32*)0x020DE548 = 0xE1A00000; // nop
*(u32*)0x020DE55C = 0xE1A00000; // nop
*(u32*)0x020E20C4 = 0xE1A00000; // nop
patchInitDSiWare(0x020E7ED8, heapEndMaxForRetailMus);
*(u32*)0x020E8264 = *(u32*)0x02004FD0;
patchUserSettingsReadDSiWare(0x020E9348);
*(u32*)0x020E977C = 0xE1A00000; // nop
*(u32*)0x020E9780 = 0xE1A00000; // nop
*(u32*)0x020E9784 = 0xE1A00000; // nop
*(u32*)0x020E9788 = 0xE1A00000; // nop
*(u32*)0x020E9794 = 0xE1A00000; // nop (Enable error exception screen)
}
}

// Shantae: Risky's Revenge (Europe)
Expand Down
48 changes: 27 additions & 21 deletions retail/bootloader/source/arm7/patch_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ static void patchResetTwl(cardengineArm9* ce9, const tNDSHeader* ndsHeader, cons
nandTmpJumpFuncOffset[0] = 0xE59F0000; // ldr r0, =0xFFFFFFFF
nandTmpJumpFuncOffset[1] = generateA7Instr((int)(((u32)nandTmpJumpFuncOffset) + (1 * sizeof(u32))), (int)ce9->patches->reset_arm9);
nandTmpJumpFuncOffset[2] = 0xFFFFFFFF;
} else if (nandTmpJumpFuncOffset[-3] == 0xE8BD8008 && nandTmpJumpFuncOffset[-1] == 0x02FFE230) { // DEBUG
nandTmpJumpFuncOffset[-15] = 0xE59F0000; // ldr r0, =0
nandTmpJumpFuncOffset[-14] = generateA7Instr((int)(((u32)nandTmpJumpFuncOffset) - (14 * sizeof(u32))), (int)ce9->patches->reset_arm9);
nandTmpJumpFuncOffset[-13] = 0;
dbg_printf("Reset (TWL) patched!\n");
} else if (nandTmpJumpFuncOffset[-2] == 0xE8BD8008 && nandTmpJumpFuncOffset[-1] == 0x02FFE230) {
nandTmpJumpFuncOffset[-11] = 0xE59F0000; // ldr r0, =0
nandTmpJumpFuncOffset[-10] = generateA7Instr((int)(((u32)nandTmpJumpFuncOffset) - (10 * sizeof(u32))), (int)ce9->patches->reset_arm9);
Expand Down Expand Up @@ -1024,12 +1029,12 @@ void patchInitLock(const tNDSHeader* ndsHeader, const module_params_t* modulePar
dbg_printf("\n\n");
}

u32 startOffset = (u32)ndsHeader->arm9destination;
u32* newBranchPrepOffset1 = (u32*)(startOffset+0x860);
u32* newBranchPrepOffset2 = (u32*)(startOffset+0x874);
u32 startOffset = (u32)ndsHeader->arm9executeAddress;
u32* newBranchPrepOffset1 = (u32*)(startOffset+0x60);
u32* newBranchPrepOffset2 = (u32*)(startOffset+0x74);
if (moduleParams->sdk_version > 0x5050000) {
newBranchPrepOffset1 = (u32*)(startOffset+0x870);
newBranchPrepOffset2 = (u32*)(startOffset+0x884);
newBranchPrepOffset1 = (u32*)(startOffset+0x70);
newBranchPrepOffset2 = (u32*)(startOffset+0x84);
}

newBranchPrepOffset1[0] = 0xE92D4000; // push {lr}
Expand Down Expand Up @@ -1078,12 +1083,12 @@ void patchInitLock(const tNDSHeader* ndsHeader, const module_params_t* modulePar
dbg_printf("\n\n");
}

u32 startOffset = (u32)ndsHeader->arm9destination;
u16* newBranchPrepOffset1 = (u16*)(startOffset+0x860);
u16* newBranchPrepOffset2 = (u16*)(startOffset+0x86C);
u32 startOffset = (u32)ndsHeader->arm9executeAddress;
u16* newBranchPrepOffset1 = (u16*)(startOffset+0x60);
u16* newBranchPrepOffset2 = (u16*)(startOffset+0x6C);
if (moduleParams->sdk_version > 0x5050000) {
newBranchPrepOffset1 = (u16*)(startOffset+0x870);
newBranchPrepOffset2 = (u16*)(startOffset+0x87C);
newBranchPrepOffset1 = (u16*)(startOffset+0x70);
newBranchPrepOffset2 = (u16*)(startOffset+0x7C);
}

newBranchPrepOffset1[0] = 0xB500; // push {lr}
Expand Down Expand Up @@ -1132,12 +1137,12 @@ void patchInitLock(const tNDSHeader* ndsHeader, const module_params_t* modulePar
dbg_printf("\n\n");
}

u32 startOffset = (u32)ndsHeader->arm9destination;
u32* newBranchPrepOffset1 = (u32*)(startOffset+0x860);
u32* newBranchPrepOffset2 = (u32*)(startOffset+0x874);
u32 startOffset = (u32)ndsHeader->arm9executeAddress;
u32* newBranchPrepOffset1 = (u32*)(startOffset+0x60);
u32* newBranchPrepOffset2 = (u32*)(startOffset+0x74);
if (moduleParams->sdk_version > 0x5050000) {
newBranchPrepOffset1 = (u32*)(startOffset+0x870);
newBranchPrepOffset2 = (u32*)(startOffset+0x884);
newBranchPrepOffset1 = (u32*)(startOffset+0x70);
newBranchPrepOffset2 = (u32*)(startOffset+0x84);
}

newBranchPrepOffset1[0] = 0xE92D4000; // push {lr}
Expand Down Expand Up @@ -2000,11 +2005,12 @@ u32 patchCardNdsArm9(cardengineArm9* ce9, const tNDSHeader* ndsHeader, const mod
|| strncmp(romTid, "DMP", 3) == 0
|| strncmp(romTid, "DHS", 3) == 0
) && arm7mbk == 0x080037C0 && donorFileCluster != CLUSTER_FREE) {
u32 startOffset = (u32)ndsHeader->arm9executeAddress;
if (moduleParams->sdk_version > 0x5050000) {
*(u32*)(startOffset+0x838) = 0xE1A00000; // nop
*(u32*)(startOffset+0x99C) = 0xE1A00000; // nop
*(u32*)(startOffset+0x38) = 0xE1A00000; // nop
*(u32*)(startOffset+0x19C) = 0xE1A00000; // nop
} else if (moduleParams->sdk_version > 0x5020000 && moduleParams->sdk_version < 0x5050000) {
*(u32*)(startOffset+0x98C) = 0xE1A00000; // nop
*(u32*)(startOffset+0x18C) = 0xE1A00000; // nop
}

patchTwlSleepMode(ndsHeader, moduleParams);
Expand Down Expand Up @@ -2083,11 +2089,11 @@ void patchCardNdsArm9Cont(cardengineArm9* ce9, const tNDSHeader* ndsHeader, cons
extern u32 arm7mbk;
extern u32 donorFileCluster;
if (arm7newUnitCode == 0 && arm7mbk == 0x080037C0 && donorFileCluster != CLUSTER_FREE) {
u32 startOffset = (u32)ndsHeader->arm9destination;
u32 startOffset = (u32)ndsHeader->arm9executeAddress;
if (moduleParams->sdk_version > 0x5050000) {
setB(startOffset+0x86C, startOffset+0x8F0);
setB(startOffset+0x6C, startOffset+0xF0);
} else {
setB(startOffset+0x85C, (moduleParams->sdk_version > 0x5020000) ? startOffset+0x8E0 : startOffset+0x8D8);
setB(startOffset+0x5C, (moduleParams->sdk_version > 0x5020000) ? startOffset+0xE0 : startOffset+0xD8);
}

patchInitLock(ndsHeader, moduleParams);
Expand Down
3 changes: 3 additions & 0 deletions retail/bootloaderi/source/arm7/patch_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ void patchResetTwl(cardengineArm9* ce9, const tNDSHeader* ndsHeader, const modul
// Patch
if (moduleParams->sdk_version < 0x5008000) {
*nandTmpJumpFuncOffset = generateA7Instr((int)nandTmpJumpFuncOffset, (int)ce9->patches->reset_arm9);
} else if (nandTmpJumpFuncOffset[-3] == 0xE8BD8008 && nandTmpJumpFuncOffset[-1] == 0x02FFE230) { // DEBUG
nandTmpJumpFuncOffset[-4] = generateA7Instr((int)(((u32)nandTmpJumpFuncOffset) - (4 * sizeof(u32))), (int)ce9->patches->reset_arm9);
dbg_printf("Reset (TWL) patched!\n");
} else if (nandTmpJumpFuncOffset[-2] == 0xE8BD8008 && nandTmpJumpFuncOffset[-1] == 0x02FFE230) {
nandTmpJumpFuncOffset[-3] = generateA7Instr((int)(((u32)nandTmpJumpFuncOffset) - (3 * sizeof(u32))), (int)ce9->patches->reset_arm9);
dbg_printf("Reset (TWL) patched!\n");
Expand Down
Loading

0 comments on commit bdf51b6

Please sign in to comment.