Skip to content

Commit

Permalink
Completely fix Pokemon Wii connection support
Browse files Browse the repository at this point in the history
TODO: Port over to B4DS mode
  • Loading branch information
RocketRobz committed Dec 14, 2024
1 parent 7764388 commit fe5aa97
Show file tree
Hide file tree
Showing 20 changed files with 346 additions and 282 deletions.
5 changes: 3 additions & 2 deletions retail/bootloaderi/include/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ u32* findWaitSysCyclesOffset(const tNDSHeader* ndsHeader);
u32* findSleepOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, bool usesThumb, u32* 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);
u32* findResetOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, bool* softResetMb);
u32* findSrlStartOffset9(const tNDSHeader* ndsHeader);
u32* findResetOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams, const bool softResetMb);
u32* findNandTmpJumpFuncOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams);
u32* findMbkWramBOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams);
u16* findMbkWramBOffsetThumb(const tNDSHeader* ndsHeader, const module_params_t* moduleParams);
Expand Down Expand Up @@ -140,6 +141,6 @@ u32* findCardIrqEnableOffset(const tNDSHeader* ndsHeader, const module_params_t*
u32* findSdCardResetOffset(const tNDSHeader* ndsHeader, const module_params_t* moduleParams);
u32* findSdCardFuncsOffset(const tNDSHeader* ndsHeader);
u32* findAutoPowerOffOffset(const tNDSHeader* ndsHeader);
u32* findResetOffset7(const tNDSHeader* ndsHeader);
u32* findSrlStartOffset7(const tNDSHeader* ndsHeader);

#endif // FIND_H
6 changes: 3 additions & 3 deletions retail/bootloaderi/include/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

//extern bool cardReadFound; // patch_arm9.c

#define patchOffsetCacheFileVersion 111 // Change when new functions are being patched, some offsets removed,
#define patchOffsetCacheFileVersion 112 // Change when new functions are being patched, some offsets removed,
// the offset order changed, and/or the function signatures changed (not added)

typedef struct patchOffsetCacheContents {
Expand All @@ -65,7 +65,6 @@ typedef struct patchOffsetCacheContents {
u32* heapPointerOffset;
u32 a9IsThumb;
u32* cardHashInitOffset;
u32* cardRomInitOffset; // Unused, remove when updating cache version
u32* cardReadStartOffset;
u32* cardReadEndOffset;
u32* cardPullOutOffset;
Expand Down Expand Up @@ -93,8 +92,9 @@ typedef struct patchOffsetCacheContents {
u32* fileIoReadOffset;
u32* a9CardIrqEnableOffset;
u32 a9CardIrqIsThumb;
u32* srlStartOffset9;
u32 srlStartOffsetChecked;
u32* resetOffset;
u32 resetMb;
u32 resetChecked;
u32* nandTmpJumpFuncOffset;
u32 nandTmpJumpFuncChecked;
Expand Down
23 changes: 11 additions & 12 deletions retail/bootloaderi/source/arm7/find_arm7.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ static const u16 irqEnableStartSignatureThumb[5] = {0xB530, 0xB081, 0x4D07, 0x8
static const u16 irqEnableStartSignatureThumb3[5] = {0xB510, 0x1C04, 0xF7FF, 0xFFF4, 0x4B05}; // SDK 3
static const u16 irqEnableStartSignatureThumb5[5] = {0xB510, 0x1C04, 0xF7FF, 0xFFE4, 0x4B05}; // SDK 5

// Reset
static const u32 resetSignature3Eoo[] = {0xE92D4070, 0xE59F0098, 0xE5904004, 0xE3540000}; // eoo.dat (Pokemon)
// SRL start
static const u32 srlStartSignature3[4] = {0xE92D4070, 0xE59F0098, 0xE5904004, 0xE3540000}; // eoo.dat (Pokemon)

// ARM7i start (SDK 5)
//static const u32 a7iStartSignatureConstant[3] = {0x6F696473, 0x616C775F, 0x0000006E}; // 'sdio_wlan'
Expand Down Expand Up @@ -1407,23 +1407,22 @@ u32* findCardIrqEnableOffset(const tNDSHeader* ndsHeader, const module_params_t*
return cardIrqEnableOffset;
}

u32* findResetOffset7(const tNDSHeader* ndsHeader) {
// dbg_printf("findResetOffset\n");
u32* findSrlStartOffset7(const tNDSHeader* ndsHeader) {
dbg_printf("findSrlStartOffset7\n");

u32* resetOffset = findOffset(
u32* offset = findOffset(
ndsHeader->arm7destination, newArm7ibinarySize,
resetSignature3Eoo, 4
srlStartSignature3, 4
);

if (resetOffset) {
dbg_printf("Reset found\n");
dbg_printf("\n");
return resetOffset;
if (offset) {
dbg_printf("SRL start function found\n");
} else {
dbg_printf("Reset not found\n");
dbg_printf("SRL start function not found\n");
}

return NULL;
dbg_printf("\n");
return offset;
}

/*u32* findA7iStartOffset(void) {
Expand Down
Loading

0 comments on commit fe5aa97

Please sign in to comment.