Skip to content

Commit

Permalink
nds_loader: switch from vramcpy to memcpy
Browse files Browse the repository at this point in the history
- BlocksDS has a memcpy that is VRAM-safe
- Since that's the whole reason vramcpy existed, let's just use that
  • Loading branch information
lifehackerhansol committed Nov 13, 2023
1 parent d5254b8 commit a4fd15b
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions arm9/source/nds_loader_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,6 @@ static void writeAddr (data_t *mem, addr_t offset, addr_t value) {
((addr_t*)mem)[offset/sizeof(addr_t)] = value;
}

static void vramcpy (void* dst, const void* src, int len)
{
u16* dst16 = (u16*)dst;
u16* src16 = (u16*)src;

//dmaCopy(src, dst, len);

for ( ; len > 0; len -= 2) {
*dst16++ = *src16++;
}
}

static addr_t quickFind (const data_t* data, const data_t* search, size_t dataLen, size_t searchLen) {
const int* dataChunk = (const int*) data;
int searchChunk = ((const int*)search)[0];
Expand Down Expand Up @@ -213,7 +201,7 @@ static bool dldiPatchLoader (data_t *binData, u32 binSize, bool clearBSS)
// Remember how much space is actually reserved
pDH[DO_allocatedSpace] = pAH[DO_allocatedSpace];
// Copy the DLDI patch into the application
vramcpy (pAH, pDH, dldiFileSize);
memcpy (pAH, pDH, dldiFileSize);

// Fix the section pointers in the header
writeAddr (pAH, DO_text_start, readAddr (pAH, DO_text_start) + relocationOffset);
Expand Down Expand Up @@ -280,7 +268,7 @@ eRunNdsRetCode runNds (const void* loader, u32 loaderSize, u32 cluster, bool ini
// Direct CPU access to VRAM bank C
VRAM_C_CR = VRAM_ENABLE | VRAM_C_LCD;
// Load the loader/patcher into the correct address
vramcpy (LCDC_BANK_C, loader, loaderSize);
memcpy (LCDC_BANK_C, loader, loaderSize);

// Set the parameters for the loader
// STORED_FILE_CLUSTER = cluster;
Expand Down

0 comments on commit a4fd15b

Please sign in to comment.