Skip to content

Commit

Permalink
Increase DSi/3DS RAM drive size by 8 sectors for the header
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Dec 30, 2024
1 parent 08433e7 commit ba2e6be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions arm9/source/driveOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ void flashcardUnmount(void) {

void ramdriveMount(bool ram32MB) {
if (isDSiMode() || REG_SCFG_EXT != 0) {
ramdSectors = ram32MB ? 0xE000 : 0x6000; // Main Memory
ramdSectors += 0x40; // Shared WRAM
ramdSectors = 0x8 + (ram32MB ? 0xE000 : 0x6000) + 0x40; // Main Memory + Shared WRAM

WRAM_CR = 3;

Expand All @@ -510,7 +509,7 @@ void ramdriveMount(bool ram32MB) {
} else {
ramdSectors += 0x400;

REG_MBK6=0x080037C0;
REG_MBK6 = 0x080037C0;
*((vu32*)REG_MBK1) = 0x8C888480;

*(vu32*)0x037C0000 = 0x49394D47;
Expand Down
42 changes: 21 additions & 21 deletions arm9/source/ramd.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void ramd_setSize(const bool ram32MB) {

bool ramd_startup() {
if(isDSiMode() || REG_SCFG_EXT != 0) {
ramdLoc = (u8*)malloc(0x6000 * SECTOR_SIZE);
ramdLoc = (u8*)malloc(0x6008 * SECTOR_SIZE);
} else {
ramdLoc = (u8*)calloc(0x8 * SECTOR_SIZE, 1);
toncset(ramdLocMep, 0, (ramdSectors - 0x8) * SECTOR_SIZE); // Fill MEP with 00 to avoid displaying weird files
Expand All @@ -46,20 +46,20 @@ bool ramd_read_sectors(sec_t sector, sec_t numSectors, void *buffer) {
for(int i = 0; i < numSectors; i++, sector++) {
if(isDSiMode() || REG_SCFG_EXT != 0) {
if (largeSize) {
if(sector >= 0xE440) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x037C0000 + ((sector - 0xE440) * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0xE000) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x036F8000 + ((sector - 0xE000) * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6000) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x0D000000 + ((sector - 0x6000) * SECTOR_SIZE), SECTOR_SIZE);
if(sector >= 0xE448) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x037C0000 + ((sector - 0xE448) * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0xE008) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x036F8000 + ((sector - 0xE008) * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6008) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x0D000000 + ((sector - 0x6008) * SECTOR_SIZE), SECTOR_SIZE);
} else {
tonccpy(buffer + (i * SECTOR_SIZE), ramdLoc + (sector * SECTOR_SIZE), SECTOR_SIZE);
}
} else {
if(sector >= 0x6440) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x037C0000 + ((sector - 0x6440) * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6000) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x036F8000 + ((sector - 0x6000) * SECTOR_SIZE), SECTOR_SIZE);
if(sector >= 0x6448) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x037C0000 + ((sector - 0x6448) * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6008) {
tonccpy(buffer + (i * SECTOR_SIZE), (void*)0x036F8000 + ((sector - 0x6008) * SECTOR_SIZE), SECTOR_SIZE);
} else {
tonccpy(buffer + (i * SECTOR_SIZE), ramdLoc + (sector * SECTOR_SIZE), SECTOR_SIZE);
}
Expand All @@ -80,20 +80,20 @@ bool ramd_write_sectors(sec_t sector, sec_t numSectors, const void *buffer) {
for(int i = 0; i < numSectors; i++, sector++) {
if(isDSiMode() || REG_SCFG_EXT != 0) {
if (largeSize) {
if(sector >= 0xE440) {
tonccpy((void*)0x037C0000 + ((sector - 0xE440) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0xE000) {
tonccpy((void*)0x036F8000 + ((sector - 0xE000) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6000) {
tonccpy((void*)0x0D000000 + ((sector - 0x6000) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
if(sector >= 0xE448) {
tonccpy((void*)0x037C0000 + ((sector - 0xE448) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0xE008) {
tonccpy((void*)0x036F8000 + ((sector - 0xE008) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6008) {
tonccpy((void*)0x0D000000 + ((sector - 0x6008) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else {
tonccpy(ramdLoc + (sector * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
}
} else {
if(sector >= 0x6440) {
tonccpy((void*)0x037C0000 + ((sector - 0x6440) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6000) {
tonccpy((void*)0x036F8000 + ((sector - 0x6000) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
if(sector >= 0x6448) {
tonccpy((void*)0x037C0000 + ((sector - 0x6448) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else if(sector >= 0x6008) {
tonccpy((void*)0x036F8000 + ((sector - 0x6008) * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
} else {
tonccpy(ramdLoc + (sector * SECTOR_SIZE), buffer + (i * SECTOR_SIZE), SECTOR_SIZE);
}
Expand Down

0 comments on commit ba2e6be

Please sign in to comment.