Skip to content

Commit

Permalink
Fix cloneboot not working in DSiWare titles
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Dec 10, 2023
1 parent 3a7b7f3 commit b5c3268
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions retail/bootloader/source/arm7/patch_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ static void patchMpu2(const tNDSHeader* ndsHeader, const module_params_t* module
dbg_hexa((u32)mpuInitOffset);
dbg_printf("\n\n");

/* u32 mpuInitOffsetInSrl = (u32)mpuInitOffset;
mpuInitOffsetInSrl -= (u32)ndsHeader->arm9destination;
if (mpuInitOffsetInSrl >= 0 && mpuInitOffsetInSrl < 0x4000) {
unpatchedFuncs->mpuInitOffset2 = mpuInitOffset;
} */
*mpuInitOffset = 0xE1A00000; // nop

// Try to find it
Expand Down
6 changes: 6 additions & 0 deletions retail/bootloaderi/source/arm7/patch_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,12 @@ void patchMpu2(const tNDSHeader* ndsHeader, const module_params_t* moduleParams)
dbg_hexa((u32)mpuInitOffset);
dbg_printf("\n\n");

u32 mpuInitOffsetInSrl = (u32)mpuInitOffset;
mpuInitOffsetInSrl -= (u32)ndsHeader->arm9destination;

if (mpuInitOffsetInSrl >= 0 && mpuInitOffsetInSrl < 0x4000) {
unpatchedFuncs->mpuInitOffset2 = mpuInitOffset;
}
*mpuInitOffset = 0xE1A00000; // nop

// Try to find it
Expand Down
3 changes: 3 additions & 0 deletions retail/cardengine/arm7/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ void myIrqHandlerVBlank(void) {
}
}

/* if (unpatchedFuncs->mpuInitOffset2) {
*unpatchedFuncs->mpuInitOffset2 = 0xEE060F12;
} */
if (unpatchedFuncs->mpuDataOffset2) {
if (isSdk5Set) {
unpatchedFuncs->mpuDataOffset2[0] = 0xE3A0004A; // mov r0, #0x4A
Expand Down
6 changes: 6 additions & 0 deletions retail/cardenginei/arm7/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,9 @@ void myIrqHandlerVBlank(void) {
*unpatchedFuncs->iCompressedFlagOffset = unpatchedFuncs->ltd_compressed_static_end;
}

if (unpatchedFuncs->mpuInitOffset2) {
*unpatchedFuncs->mpuInitOffset2 = 0xEE060F12;
}
if (unpatchedFuncs->mpuDataOffset2) {
*unpatchedFuncs->mpuDataOffset2 = unpatchedFuncs->mpuInitRegionOldData2;
}
Expand All @@ -1553,6 +1556,9 @@ void myIrqHandlerVBlank(void) {
*unpatchedFuncs->mpuDataOffsetAlt = unpatchedFuncs->mpuInitRegionOldDataAlt;
}

if (unpatchedFuncs->mpuInitOffset2) {
*unpatchedFuncs->mpuInitOffset2 = 0xEE060F12;
}
if (unpatchedFuncs->mpuDataOffset2) {
*unpatchedFuncs->mpuDataOffset2 = unpatchedFuncs->mpuInitRegionOldData2;
}
Expand Down
3 changes: 3 additions & 0 deletions retail/cardenginei/arm7_dsiware/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,9 @@ void myIrqHandlerVBlank(void) {
if (unpatchedFuncs->ltd_compressed_static_end) {
*unpatchedFuncs->iCompressedFlagOffset = unpatchedFuncs->ltd_compressed_static_end;
}
if (unpatchedFuncs->mpuInitOffset2) {
*unpatchedFuncs->mpuInitOffset2 = 0xEE060F12;
}
if (unpatchedFuncs->mpuDataOffset2) {
*unpatchedFuncs->mpuDataOffset2 = unpatchedFuncs->mpuInitRegionOldData2;
}
Expand Down
1 change: 1 addition & 0 deletions retail/common/include/unpatched_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef struct unpatchedFunctions {
u32* iCompressedFlagOffset;
u32 compressed_static_end;
u32 ltd_compressed_static_end;
u32* mpuInitOffset2;
u32* mpuDataOffset;
u32* mpuDataOffsetAlt;
u32* mpuDataOffset2;
Expand Down

0 comments on commit b5c3268

Please sign in to comment.