Skip to content

Commit

Permalink
Fix 32KB DLDI workaround for homebrew made with libnds2
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Nov 14, 2024
1 parent 7d8ec9e commit 2a2b2c7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion settings/bootloader/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
tonccpy (pAH+DO_code, bootloader, bootsize);
*(u32*)0x02FF4010 = (u32)pAH+DO_code;

const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

// Relocate DLDI file to bootstub RAM space
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down
6 changes: 5 additions & 1 deletion title/bootloader/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
tonccpy (pAH+DO_code, bootloader, bootsize);
*(u32*)0x02FF4010 = (u32)pAH+DO_code;

const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

// Relocate DLDI file to bootstub RAM space
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down
6 changes: 5 additions & 1 deletion universal/bootloader_app/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
tonccpy (pAH+DO_code, bootloader, bootsize);
*(u32*)0x02FF4010 = (u32)pAH+DO_code;

const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

// Relocate DLDI file to bootstub RAM space
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down
6 changes: 5 additions & 1 deletion universal/bootloader_menu/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
tonccpy (pAH+DO_code, bootloader, bootsize);
*(u32*)0x02FF4010 = (u32)pAH+DO_code;

const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

// Relocate DLDI file to bootstub RAM space
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down

0 comments on commit 2a2b2c7

Please sign in to comment.