From 5841fb9afa58a205abd0926ab2839ce8e3200453 Mon Sep 17 00:00:00 2001 From: Raf <> Date: Mon, 12 Aug 2024 18:56:49 +0800 Subject: [PATCH] portx64: fixes #4 - jpn/pal versions crashing on startup --- src/game/lang.c | 2 +- src/game/langreset.c | 5 +++++ src/game/utils.c | 4 ++-- src/include/game/utils.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/game/lang.c b/src/game/lang.c index 65565b496..f7d61f336 100644 --- a/src/game/lang.c +++ b/src/game/lang.c @@ -377,7 +377,7 @@ s32 langGetFileId(s32 bank) void langLoad(s32 bank) { #if VERSION >= VERSION_PAL_BETA - s32 len = fileGetInflatedSize(langGetFileId(bank), LOADTYPE_LANG); + s32 len = fileGetInflatedSize(langGetFileId(bank), FT_LANG); if ((uintptr_t)g_LangBuffer + len + g_LangBufferSize - (uintptr_t)g_LangBufferPos >= 0) { s32 len2 = (uintptr_t)g_LangBuffer + g_LangBufferSize - (uintptr_t)g_LangBufferPos; diff --git a/src/game/langreset.c b/src/game/langreset.c index 0f64e8cec..a85afd8dd 100644 --- a/src/game/langreset.c +++ b/src/game/langreset.c @@ -6,6 +6,7 @@ #include "lib/memp.h" #include "data.h" #include "types.h" +#include "platform.h" extern u8 *g_LangBuffer; extern s32 g_LangBufferSize; @@ -45,6 +46,10 @@ void langReset(s32 stagenum) } } +#ifdef PLATFORM_64BIT + size *= 2; +#endif + g_LangBuffer = mempAlloc(ALIGN16(size), MEMPOOL_STAGE); g_LangBufferSize = size; diff --git a/src/game/utils.c b/src/game/utils.c index 0432870f4..fa00c2e0e 100644 --- a/src/game/utils.c +++ b/src/game/utils.c @@ -69,10 +69,10 @@ u32 align16(u32 arg0) return arg0; } -u32 align32(u32 arg0) +uintptr_t align32(uintptr_t arg0) { if (arg0 & 0x1f) { - arg0 = (arg0 & 0xffffffe0) + 0x20; + arg0 = (arg0 & ((intptr_t)~0x1f)) + 0x20; } return arg0; diff --git a/src/include/game/utils.h b/src/include/game/utils.h index 5e992a212..83ada1f98 100644 --- a/src/include/game/utils.h +++ b/src/include/game/utils.h @@ -7,7 +7,7 @@ void func0f176d70(s32 arg0); u32 align4(u32 arg0); u32 align16(u32 arg0); -u32 align32(u32 arg0); +uintptr_t align32(uintptr_t arg0); void utilsInit(void); void func0f1770ac(struct coord *a, struct coord *b, struct coord *out); bool func0f177164(struct coord *arg0, struct coord *arg1, u32 line, char *file);