3DS: Initialize ROM buffer and filesystem in lib
Jeffrey Pfau jeffrey@endrift.com
Fri, 11 Nov 2016 01:53:53 -0800
3 files changed,
25 insertions(+),
6 deletions(-)
M
src/platform/3ds/ctru-heap.c
→
src/platform/3ds/ctru-heap.c
@@ -20,6 +20,12 @@ * This notice may not be removed or altered from any source distribution.
*/ #include <3ds/types.h> +#include <3ds/srv.h> +#include <3ds/gfx.h> +#include <3ds/sdmc.h> +#include <3ds/services/apt.h> +#include <3ds/services/fs.h> +#include <3ds/services/hid.h> #include <3ds/svc.h> #include "util/common.h"@@ -33,10 +39,15 @@ extern u32 __ctru_linear_heap_size;
static u32 __custom_heap_size = 0x02400000; static u32 __custom_linear_heap_size = 0x01400000; -uint32_t* romBuffer; +uint32_t* romBuffer = NULL; size_t romBufferSize; + +FS_Archive sdmcArchive; bool allocateRomBuffer(void) { + if (romBuffer) { + return true; + } romBuffer = malloc(0x02000000); if (romBuffer) { romBufferSize = 0x02000000;@@ -66,3 +77,16 @@ // Set up newlib heap
fake_heap_start = (char*)__ctru_heap; fake_heap_end = fake_heap_start + __ctru_heap_size; } + +void __appInit(void) { + // Initialize services + srvInit(); + aptInit(); + hidInit(); + + fsInit(); + sdmcInit(); + + FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")); + allocateRomBuffer(); +}
M
src/platform/3ds/main.c
→
src/platform/3ds/main.c
@@ -56,8 +56,6 @@ #define AUDIO_SAMPLES 384
#define AUDIO_SAMPLE_BUFFER (AUDIO_SAMPLES * 16) #define DSP_BUFFERS 4 -FS_Archive sdmcArchive; - static struct GBA3DSRotationSource { struct mRotationSource d; accelVector accel;@@ -724,8 +722,6 @@ GX_MemoryFill(
outputTexture.data, 0x0000, outputTextureEnd, GX_FILL_16BIT_DEPTH | GX_FILL_TRIGGER, NULL, 0, NULL, 0); gspWaitForPSC0(); - - FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")); struct GUIFont* font = GUIFontCreate();
M
src/platform/test/perf-main.c
→
src/platform/test/perf-main.c
@@ -69,7 +69,6 @@ consoleInit(GFX_BOTTOM, NULL);
if (!allocateRomBuffer()) { return 1; } - FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")); #else signal(SIGINT, _mPerfShutdown); #endif