From b9fcd7fa543ec4cec1f4d47b0bd648741b90556b Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Sat, 9 Oct 2021 19:58:14 -0600 Subject: [PATCH] Properly allocate memory for RAM drive 1 --- arm9/source/driveOperations.cpp | 3 ++- arm9/source/ramd.c | 7 +++++-- arm9/source/ramd.h | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arm9/source/driveOperations.cpp b/arm9/source/driveOperations.cpp index 617c281..f112e6f 100644 --- a/arm9/source/driveOperations.cpp +++ b/arm9/source/driveOperations.cpp @@ -339,7 +339,8 @@ void flashcardUnmount(void) { } TWL_CODE void ramdrive1Mount(void) { - LZ77_Decompress((u8*)__9MB_lz77, (u8*)0x02500000); + ramdLoc = new u8[0x900200]; + LZ77_Decompress((u8*)__9MB_lz77, ramdLoc); fatMountSimple("ram1", &io_ram_drive); ramdrive1Mounted = (access("ram1:/", F_OK) == 0); } diff --git a/arm9/source/ramd.c b/arm9/source/ramd.c index 03ed524..f28c3e1 100644 --- a/arm9/source/ramd.c +++ b/arm9/source/ramd.c @@ -1,10 +1,13 @@ #include +#include #include #include "tonccpy.h" #define SECTOR_SIZE 512 +u8* ramdLoc = (u8*)NULL; + bool ramd_startup() { return true; } @@ -14,12 +17,12 @@ bool ramd_is_inserted() { } bool ramd_read_sectors(sec_t sector, sec_t numSectors, void *buffer) { - tonccpy(buffer, (void*)0x02500000+(sector << 9), numSectors << 9); + tonccpy(buffer, ramdLoc+(sector << 9), numSectors << 9); return true; } bool ramd_write_sectors(sec_t sector, sec_t numSectors, const void *buffer) { - tonccpy((void*)0x02500000+(sector << 9), buffer, numSectors << 9); + tonccpy(ramdLoc+(sector << 9), buffer, numSectors << 9); return true; } diff --git a/arm9/source/ramd.h b/arm9/source/ramd.h index 8b2e40d..99e8d01 100644 --- a/arm9/source/ramd.h +++ b/arm9/source/ramd.h @@ -1,7 +1,10 @@ #pragma once #include +#include #include +extern u8* ramdLoc; + extern const DISC_INTERFACE io_ram_drive; extern const DISC_INTERFACE io_ram_drive2;