Skip to content

Commit

Permalink
portx64: fixes #4 - jpn/pal versions crashing on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Raf committed Aug 12, 2024
1 parent 077cc67 commit 5841fb9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/game/lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/game/langreset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,6 +46,10 @@ void langReset(s32 stagenum)
}
}

#ifdef PLATFORM_64BIT
size *= 2;
#endif

g_LangBuffer = mempAlloc(ALIGN16(size), MEMPOOL_STAGE);
g_LangBufferSize = size;

Expand Down
4 changes: 2 additions & 2 deletions src/game/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/include/game/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5841fb9

Please sign in to comment.