From c007bee536fecc2e387cf4f673d3f286df1d3e74 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 13 Aug 2023 01:12:56 +0200 Subject: [PATCH] port: don't use s32s for texture pointers --- src/game/explosions.c | 2 +- src/game/texdecompress.c | 6 +++--- src/include/game/texdecompress.h | 2 +- src/include/types.h | 12 +++++++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/game/explosions.c b/src/game/explosions.c index 329ea74c0..361dadb65 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -1336,7 +1336,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass) } else { static u32 var8007e93c = 0xffffffff; mainOverrideVariable("ecol", &var8007e93c); - colours[0].word = PD_BE32(0xffffffff); + colours[0].word = 0xffffffff; colours[0].word = var8007e93c; } diff --git a/src/game/texdecompress.c b/src/game/texdecompress.c index 5ff6a2d80..3aa056ba6 100644 --- a/src/game/texdecompress.c +++ b/src/game/texdecompress.c @@ -2079,7 +2079,7 @@ void texLoadFromDisplayList(Gfx *gdl, struct texpool *pool, s32 arg2) while (bytes[GFX_W0_BYTE(0)] != (u8)G_ENDDL) { // Look for GBI sequence: fd...... abcd.... if (bytes[GFX_W0_BYTE(0)] == G_SETTIMG && bytes[GFX_W1_BYTE(0)] == 0xab && bytes[GFX_W1_BYTE(1)] == 0xcd) { - texLoad((s32 *)((uintptr_t)bytes + 4), pool, arg2); + texLoad((texnum_t *)((uintptr_t)bytes + 4), pool, arg2); } bytes += 8; @@ -2123,7 +2123,7 @@ extern u8 EXT_SEG _texturesdataSegmentRomStart; * z = texture is compressed with zlib * l = number of levels of detail within the texture */ -void texLoad(s32 *updateword, struct texpool *pool, bool arg2) +void texLoad(texnum_t *updateword, struct texpool *pool, bool arg2) { u8 compbuffer[4 * 1024 + 0x40]; u8 *compptr; @@ -2305,7 +2305,7 @@ void texLoadFromConfigs(struct textureconfig *configs, s32 numconfigs, struct te void texLoadFromTextureNum(u32 texturenum, struct texpool *pool) { - s32 texturenumcopy = texturenum; + texnum_t texturenumcopy = texturenum; texLoad(&texturenumcopy, pool, true); } diff --git a/src/include/game/texdecompress.h b/src/include/game/texdecompress.h index cbecd9a80..5c2c70d5d 100644 --- a/src/include/game/texdecompress.h +++ b/src/include/game/texdecompress.h @@ -32,7 +32,7 @@ struct tex *texFindInPool(s32 texturenum, struct texpool *pool); s32 texGetPoolFreeBytes(struct texpool *pool); u8 *texGetPoolLeftPos(struct texpool *pool); void texLoadFromDisplayList(Gfx *gdl, struct texpool *pool, s32 arg2); -void texLoad(s32 *updateword, struct texpool *pool, bool arg2); +void texLoad(texnum_t *updateword, struct texpool *pool, bool arg2); void texLoadFromConfigs(struct textureconfig *configs, s32 numconfigs, struct texpool *pool, s32 arg3); void texLoadFromTextureNum(u32 arg0, struct texpool *pool); diff --git a/src/include/types.h b/src/include/types.h index 4e3f8737f..09027d877 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -30,6 +30,12 @@ typedef s32 MenuDialogHandlerResult; typedef intptr_t MenuItemHandlerResult; typedef s16 RoomNum; +#ifdef PLATFORM_N64 +#define texnum_t s32 +#else +#define texnum_t uintptr_t +#endif + // Float version of a graphics matrix, which has higher precision than an Mtx. // Matrices are stored as Mtxfs then converted to an Mtx when passed to the GPU. // Mtxs use a union and a long long int to force alignments. Mtxfs are not @@ -3829,7 +3835,7 @@ struct menudata_training { struct textureconfig { union { - s32 texturenum; + texnum_t texturenum; u8 *textureptr; }; u8 width; @@ -5767,8 +5773,8 @@ struct var8009dd78 { }; struct texturepair { - s32 texturenum1; - s32 texturenum2; + texnum_t texturenum1; + texnum_t texturenum2; }; struct collision {