Skip to content

Commit

Permalink
Update patcher in ce7i
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Dec 25, 2023
1 parent c5ff18b commit 3f49b01
Show file tree
Hide file tree
Showing 10 changed files with 1,752 additions and 395 deletions.
8 changes: 4 additions & 4 deletions retail/bootloaderi/source/arm7/find_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@ u32* findCardEndReadDma(const tNDSHeader* ndsHeader, const module_params_t* modu

if (moduleParams->sdk_version > 0x5000000) {
return findCardEndReadDmaSdk5(ndsHeader,moduleParams,usesThumb);
}
}

const u32* offsetDmaHandler = NULL;
if (moduleParams->sdk_version < 0x4000000) {
Expand Down Expand Up @@ -2736,11 +2736,11 @@ u32* findCardSetDmaSdk5(const tNDSHeader* ndsHeader, const module_params_t* modu

u32* findCardSetDma(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, bool usesThumb) {
dbg_printf("findCardSetDma\n");

if (moduleParams->sdk_version > 0x5000000) {
return findCardSetDmaSdk5(ndsHeader,moduleParams,usesThumb);
}
}

//const u16* cardSetDmaSignatureStartThumb = cardSetDmaSignatureStartThumb4;
const u32* cardSetDmaSignatureStart = cardSetDmaSignatureStart4;
int cardSetDmaSignatureStartLen = 3;
Expand Down
4 changes: 2 additions & 2 deletions retail/bootloaderi/source/arm7/patch_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -2518,9 +2518,9 @@ u32 patchCardNdsArm9(cardengineArm9* ce9, const tNDSHeader* ndsHeader, const mod
if (strncmp(romTid, "UOR", 3) == 0) { // Start at 0x2003800 for "WarioWare: DIY"
startOffset = (u32)ndsHeader->arm9destination + 0x3800;
} else if (strncmp(romTid, "UXB", 3) == 0) { // Start at 0x2080000 for "Jam with the Band"
startOffset = (u32)ndsHeader->arm9destination + 0x80000;
startOffset = (u32)ndsHeader->arm9destination + 0x80000;
} else if (strncmp(romTid, "USK", 3) == 0) { // Start at 0x20E8000 for "Face Training"
startOffset = (u32)ndsHeader->arm9destination + 0xE4000;
startOffset = (u32)ndsHeader->arm9destination + 0xE4000;
}

dbg_printf("startOffset : ");
Expand Down
22 changes: 22 additions & 0 deletions retail/cardenginei/arm7/include/patcher/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,54 @@
// COMMON
//u8* memsearch(const u8* start, u32 dataSize, const u8* find, u32 findSize);
u32* memsearch32(const u32* start, u32 dataSize, const u32* find, u32 findSize, bool forward);
u32* memsearch32_2(const u32* start, u32 dataSize, const u32* find, const u32* find2, u32 findSize, bool forward);
u32* memsearch32_3(const u32* start, u32 dataSize, const u32* find, const u32* find2, const u32* find3, u32 findSize, bool forward);
u16* memsearch16(const u16* start, u32 dataSize, const u16* find, u32 findSize, bool forward);
u16* memsearch16_4(const u16* start, u32 dataSize, const u16* find, const u16* find2, const u16* find3, const u16* find4, u32 findSize, bool forward);

inline u32* findOffset(const u32* start, u32 dataSize, const u32* find, u32 findLen) {
return memsearch32(start, dataSize, find, findLen*sizeof(u32), true);
}
inline u32* findOffsetBackwards(const u32* start, u32 dataSize, const u32* find, u32 findLen) {
return memsearch32(start, dataSize, find, findLen*sizeof(u32), false);
}
inline u32* findOffsetBackwards2(const u32* start, u32 dataSize, const u32* find, const u32* find2, u32 findLen) {
return memsearch32_2(start, dataSize, find, find2, findLen*sizeof(u32), false);
}
inline u32* findOffsetBackwards3(const u32* start, u32 dataSize, const u32* find, const u32* find2, const u32* find3, u32 findLen) {
return memsearch32_3(start, dataSize, find, find2, find3, findLen*sizeof(u32), false);
}
inline u16* findOffsetThumb(const u16* start, u32 dataSize, const u16* find, u32 findLen) {
return memsearch16(start, dataSize, find, findLen*sizeof(u16), true);
}
inline u16* findOffsetBackwardsThumb(const u16* start, u32 dataSize, const u16* find, u32 findLen) {
return memsearch16(start, dataSize, find, findLen*sizeof(u16), false);
}
inline u16* findOffsetBackwardsThumb4(const u16* start, u32 dataSize, const u16* find, const u16* find2, const u16* find3, const u16* find4, u32 findLen) {
return memsearch16_4(start, dataSize, find, find2, find3, find4, findLen*sizeof(u16), false);
}

// ARM9
u32* a9_findSwi12Offset(const tNDSHeader* ndsHeader);
u32* findModuleParamsOffset(const tNDSHeader* ndsHeader);
u32* findCardReadEndOffsetType0(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, u32 startOffset);
u32* findCardReadEndOffsetType1(const tNDSHeader* ndsHeader, u32 startOffset);
u16* findCardReadEndOffsetThumb(const tNDSHeader* ndsHeader, u32 startOffset);
u16* findCardReadEndOffsetThumb5Type0(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, u32 startOffset); // SDK 5
u16* findCardReadEndOffsetThumb5Type1(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, u32 startOffset); // SDK 5
u32* findCardReadStartOffsetType0(const module_params_t* moduleParams, const u32* cardReadEndOffset);
u32* findCardReadStartOffsetType1(const u32* cardReadEndOffset);
u32* findCardReadStartOffset5(const module_params_t* moduleParams, const u32* cardReadEndOffset); // SDK 5
u32* findCardReadCheckOffsetMvDK4(u32 startOffset);
u16* findCardReadStartOffsetThumb(const u16* cardReadEndOffset);
u16* findCardReadStartOffsetThumb5Type0(const module_params_t* moduleParams, const u16* cardReadEndOffset); // SDK 5
u16* findCardReadStartOffsetThumb5Type1(const module_params_t* moduleParams, const u16* cardReadEndOffset); // SDK 5
u32* findCardReadCachedEndOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams);
u32* findCardReadCachedStartOffset(const module_params_t* moduleParams, const u32* cardReadCachedEndOffset);
u32* findCardPullOutOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams);
u16* findCardPullOutOffsetThumb(const tNDSHeader* ndsHeader);
u16* findCardPullOutOffsetThumb5Type0(const tNDSHeader* ndsHeader, const module_params_t* moduleParams); // SDK 5
u16* findCardPullOutOffsetThumb5Type1(const tNDSHeader* ndsHeader, const module_params_t* moduleParams); // SDK 5
u32* findCardIdEndOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, const u32* cardReadEndOffset);
u16* findCardIdEndOffsetThumb(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, const u16* cardReadEndOffset);
u32* findCardIdStartOffset(const module_params_t* moduleParams, const u32* cardIdEndOffset);
Expand All @@ -52,9 +72,11 @@ const u32* getMpuInitRegionSignature(u32 patchMpuRegion);
u32* findMpuStartOffset(const tNDSHeader* ndsHeader, u32 patchMpuRegion);
u32* findMpuDataOffset(const module_params_t* moduleParams, u32 patchMpuRegion, const u32* mpuStartOffset);
u32* findMpuDataOffsetAlt(const tNDSHeader* ndsHeader);
u32* findMpuChange(const tNDSHeader* ndsHeader);
u32* findHeapPointerOffset(const module_params_t* moduleParams, const tNDSHeader* ndsHeader);
u32* findHeapPointer2Offset(const module_params_t* moduleParams, const tNDSHeader* ndsHeader);
u32* findRandomPatchOffset(const tNDSHeader* ndsHeader);
u32* findRandomPatchOffset5Second(const tNDSHeader* ndsHeader); // SDK 5
u32* findSleepOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, bool usesThumb, bool* usesThumbPtr);
u32* findCardEndReadDma(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, bool usesThumb, const u32* cardReadDmaEndOffset, u32* offsetDmaHandler);
u32* findCardSetDma(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, bool usesThumb);
Expand Down
Loading

0 comments on commit 3f49b01

Please sign in to comment.