From 633d6abbec381a6b42b7a2c560384de8488fb8d2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 25 Jan 2025 08:55:08 +1100 Subject: [PATCH] DS: Try to fix crash when generating 64x64x64 world --- src/Platform_NDS.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Platform_NDS.c b/src/Platform_NDS.c index b78628377..feca34e2d 100644 --- a/src/Platform_NDS.c +++ b/src/Platform_NDS.c @@ -585,6 +585,14 @@ void Platform_Init(void) { Platform_Log1("Running in %c mode with NDS wifi", dsiMode ? "DSi" : "DS"); #endif + // By default, the "heap limit" is calculated in `sbrk` based on current + // stack pointer value - however this does not reliably in ClassiCube's + // case as e.g. map gen and bitmap decoding use much more stack space + // So to avoid having the stack overlapping the heap when more stack space + // is used, manually reduce the heap limit by 32 kb + extern char* fake_heap_end; + fake_heap_end -= 32768; + InitFilesystem(); InitNetworking(); cpuStartTiming(1);