From 6fb0937c3c87baa03316cd0524d09577e914b0e8 Mon Sep 17 00:00:00 2001 From: Luciano Ciccariello Date: Thu, 6 Jul 2023 12:20:53 +0100 Subject: [PATCH] Fix RoomDimensions struct --- include/common.h | 2 ++ include/game.h | 5 ++--- src/st/dre/14214.c | 2 +- src/st/mad/D8C8.c | 2 +- src/st/no3/3E134.c | 2 +- src/st/np3/390BC.c | 2 +- src/st/nz0/36DE4.c | 2 +- src/st/st0/30030.c | 2 +- src/st/wrp/6FD0.c | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/common.h b/include/common.h index 2a99f51d8..26615030b 100644 --- a/include/common.h +++ b/include/common.h @@ -23,7 +23,9 @@ #define STRCPY(dst, src) __builtin_memcpy(dst, src, sizeof(src)) #define LOH(x) (*(s16*)&(x)) +#define LOHU(x) (*(u16*)&(x)) #define LOW(x) (*(s32*)&(x)) +#define LOWU(x) (*(u32*)&(x)) #if defined(HACKS) && !defined(PERMUTER) #define ALIGNED4 __attribute__((aligned(4))) diff --git a/include/game.h b/include/game.h index 2ec89b361..2b3160b3f 100644 --- a/include/game.h +++ b/include/game.h @@ -936,8 +936,7 @@ typedef struct { typedef struct { /* 800730A0 0x00 */ s32 unk00; /* 800730A4 0x04 */ s32 hSize; - /* 800730A8 0x08 */ u16 vSize; - /* 800730AA 0x0A */ u16 _padding06; + /* 800730A8 0x08 */ s32 vSize; /* 800730AC 0x0C */ s32 unk8; /* 800730B0 0x10 */ s32 left; /* 800730B4 0x14 */ s32 top; @@ -947,7 +946,7 @@ typedef struct { /* 800730C4 0x24 */ s32 y; /* 800730C8 0x28 */ s32 width; /* 800730CC 0x2C */ s32 height; - /* 800730D0 0x30 */ s32 _padding30; + /* 800730D0 0x30 */ s32 unk30; /* 800730D4 0x34 */ s32 D_800730D4; /* 800730D8 0x38 */ BgLayer bg[MAX_BG_LAYER_COUNT]; } RoomDimensions; diff --git a/src/st/dre/14214.c b/src/st/dre/14214.c index 4e06d20d7..a5a2f89a0 100644 --- a/src/st/dre/14214.c +++ b/src/st/dre/14214.c @@ -265,7 +265,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue; diff --git a/src/st/mad/D8C8.c b/src/st/mad/D8C8.c index 168555bf2..11dab4e2f 100644 --- a/src/st/mad/D8C8.c +++ b/src/st/mad/D8C8.c @@ -199,7 +199,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue; diff --git a/src/st/no3/3E134.c b/src/st/no3/3E134.c index baa25baaf..c3743f6d3 100644 --- a/src/st/no3/3E134.c +++ b/src/st/no3/3E134.c @@ -354,7 +354,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue; diff --git a/src/st/np3/390BC.c b/src/st/np3/390BC.c index ce6ce1a0b..96a80feac 100644 --- a/src/st/np3/390BC.c +++ b/src/st/np3/390BC.c @@ -48,7 +48,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue; diff --git a/src/st/nz0/36DE4.c b/src/st/nz0/36DE4.c index f98400b6b..2dad818cf 100644 --- a/src/st/nz0/36DE4.c +++ b/src/st/nz0/36DE4.c @@ -207,7 +207,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue; diff --git a/src/st/st0/30030.c b/src/st/st0/30030.c index 0fec4929c..2497d95e6 100644 --- a/src/st/st0/30030.c +++ b/src/st/st0/30030.c @@ -161,7 +161,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue; diff --git a/src/st/wrp/6FD0.c b/src/st/wrp/6FD0.c index 7f5ddb620..fbeead832 100644 --- a/src/st/wrp/6FD0.c +++ b/src/st/wrp/6FD0.c @@ -1719,7 +1719,7 @@ void Update(void) { if ((unk34 & 0x02000000)) { s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi; - s16 test = (g_CurrentRoom.vSize * 256) + 128; + s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128; if (posY > test) { DestroyEntity(entity); continue;