Skip to content

Commit

Permalink
Forgot DLDI runs on arm7 in libnds2 homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Nov 14, 2024
1 parent 2a2b2c7 commit e1bf1d1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions settings/bootloader/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
const bool largeDldi = (pDH[DO_driverSize] > pAH[DO_allocatedSpace]);

if (largeDldi) {
if (memOffset < 0x02000000 || memOffset >= 0x03000000) {
const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

if (!libnds2 && (memOffset < 0x02000000 || memOffset >= 0x03000000)) {
// Not enough space for patch in arm7 WRAM
return false;
}
Expand All @@ -168,12 +172,8 @@ 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 ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down
12 changes: 6 additions & 6 deletions title/bootloader/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
const bool largeDldi = (pDH[DO_driverSize] > pAH[DO_allocatedSpace]);

if (largeDldi) {
if (memOffset < 0x02000000 || memOffset >= 0x03000000) {
const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

if (!libnds2 && (memOffset < 0x02000000 || memOffset >= 0x03000000)) {
// Not enough space for patch in arm7 WRAM
return false;
}
Expand All @@ -168,12 +172,8 @@ 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 ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down
12 changes: 6 additions & 6 deletions universal/bootloader_app/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
const bool largeDldi = (pDH[DO_driverSize] > pAH[DO_allocatedSpace]);

if (largeDldi) {
if (memOffset < 0x02000000 || memOffset >= 0x03000000) {
const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

if (!libnds2 && (memOffset < 0x02000000 || memOffset >= 0x03000000)) {
// Not enough space for patch in arm7 WRAM
return false;
}
Expand All @@ -168,12 +172,8 @@ 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 ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down
12 changes: 6 additions & 6 deletions universal/bootloader_menu/source/dldi_patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ bool dldiPatchBinary (data_t *binData, u32 binSize) {
const bool largeDldi = (pDH[DO_driverSize] > pAH[DO_allocatedSpace]);

if (largeDldi) {
if (memOffset < 0x02000000 || memOffset >= 0x03000000) {
const u32 a9exeAddress = *(u32*)0x02FFFE24;
u32* a9exe = (u32*)a9exeAddress;
const bool libnds2 = (a9exe[0] == 0xEA000007 && a9exe[1] == 0x39444F4D);

if (!libnds2 && (memOffset < 0x02000000 || memOffset >= 0x03000000)) {
// Not enough space for patch in arm7 WRAM
return false;
}
Expand All @@ -168,12 +172,8 @@ 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 ? (libnds2 ? 0x02FE8000 : 0x02FF4180) : 0x023F4180);
pAH = (data_t*)(dsiMode&&!dsMode ? 0x02FF4180 : 0x023F4180);
toncset (pAH, 0, 0x8000);

memOffset = (addr_t)pAH;
Expand Down

0 comments on commit e1bf1d1

Please sign in to comment.