From 233f4b7514a4f27bbaaa365057cea7d8559b4cdf Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 15 Sep 2023 20:31:24 +0200 Subject: [PATCH] port: fall back to copy if a zipped file is not zipped --- src/game/file.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/game/file.c b/src/game/file.c index 6bad0b536..acaf552bd 100644 --- a/src/game/file.c +++ b/src/game/file.c @@ -12,6 +12,7 @@ #include "types.h" #ifndef PLATFORM_N64 #include "romdata.h" +#include "system.h" #endif /** @@ -4190,7 +4191,18 @@ void fileLoad(u8 *dst, u32 allocationlen, romptr_t *romaddrptr, struct fileinfo dmaExec(scratch, *romaddrptr, romsize); result = rzipInflate(scratch, dst, buffer); -#if VERSION < VERSION_NTSC_1_0 +#ifndef PLATFORM_N64 + if (result == 0) { + // probably not zipped, just copy it over if there's enough space + if (romsize < allocationlen) { + dmaExec(dst, *romaddrptr, romsize); + result = romsize; + } else { + // by this point we've already written out of bounds in the previous dmaExec call but oh well + sysFatalError("File %d is larger than its allocation: %u > %u", filenum); + } + } +#elif VERSION < VERSION_NTSC_1_0 if (result == 0) { sprintf(sp54, "DMA-Crash %s %d Ram: %02x%02x%02x%02x%02x%02x%02x%02x", "ob.c", 204, scratch[0], scratch[1], scratch[2], scratch[3],