From c4b7dce9f7bc0a85150f7a5e1d8a2c135ce043a5 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Mon, 17 Oct 2022 20:13:26 -0500 Subject: [PATCH 1/8] Stopped deleting the Mario files and test level in clean, since it was taking forever to rebuild as a result. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ca34fef..12aec67 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,6 @@ run: test ./$(TEST_FILE) clean: - rm -rf $(BUILD_DIR) $(DIST_DIR) src/decomp/mario test/level.? $(TEST_FILE) + rm -rf $(BUILD_DIR) $(DIST_DIR) $(TEST_FILE) -include $(DEP_FILES) From ede1c4db2c07408375d3a08a212e6b6615940a15 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Tue, 18 Oct 2022 19:18:35 -0500 Subject: [PATCH 2/8] Seem to have fixed 32-bit mode! --- src/cpu_type.h | 8 ++++++++ src/decomp/game/object_stuff.c | 4 ++++ src/gfx_adapter.c | 35 +++++++++++++++++----------------- src/gfx_macros.h | 13 +++++++------ 4 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 src/cpu_type.h diff --git a/src/cpu_type.h b/src/cpu_type.h new file mode 100644 index 0000000..138b7fe --- /dev/null +++ b/src/cpu_type.h @@ -0,0 +1,8 @@ +#pragma once + +#ifdef WIN32 + #define DL_INT_SIZE int32_t +#endif +#ifdef WIN64 + #define DL_INT_SIZE int64_t +#endif \ No newline at end of file diff --git a/src/decomp/game/object_stuff.c b/src/decomp/game/object_stuff.c index f5e1bdc..e0f4615 100644 --- a/src/decomp/game/object_stuff.c +++ b/src/decomp/game/object_stuff.c @@ -81,8 +81,12 @@ static struct Object *allocate_object(void) { obj->numCollidedObjs = 0; for (i = 0; i < 0x50; i++) { +#ifdef _WIN32 obj->rawData.asS32[i] = 0; +#endif +#ifdef _WIN64 obj->ptrData.asVoidPtr[i] = NULL; +#endif } obj->unused1 = 0; diff --git a/src/gfx_adapter.c b/src/gfx_adapter.c index 9265b0e..3698c2b 100644 --- a/src/gfx_adapter.c +++ b/src/gfx_adapter.c @@ -7,6 +7,7 @@ #include "gfx_adapter.h" #include "gfx_adapter_commands.h" #include "load_tex_data.h" +#include "cpu_type.h" static Mat4 s_curMatrix; static float s_curColor[3]; @@ -41,7 +42,7 @@ static void convert_uv_to_atlas( float *atlas_uv_out, short tc[] ) static void process_display_list( void *dl ) { - int64_t *ptr = (int64_t *)dl; + DL_INT_SIZE *ptr = (DL_INT_SIZE *)dl; Vtx *vdata = NULL; for( ;; ) @@ -50,19 +51,19 @@ static void process_display_list( void *dl ) { case GFXCMD_VertexData: { - UNUSED int64_t v = *ptr++; - UNUSED int64_t n = *ptr++; - UNUSED int64_t v0 = *ptr++; + UNUSED DL_INT_SIZE v = *ptr++; + UNUSED DL_INT_SIZE n = *ptr++; + UNUSED DL_INT_SIZE v0 = *ptr++; vdata = (Vtx*)v; break; } case GFXCMD_Triangle: { - int64_t v00 = *ptr++; - int64_t v01 = *ptr++; - int64_t v02 = *ptr++; - UNUSED int64_t flag0 = *ptr++; + DL_INT_SIZE v00 = *ptr++; + DL_INT_SIZE v01 = *ptr++; + DL_INT_SIZE v02 = *ptr++; + UNUSED DL_INT_SIZE flag0 = *ptr++; short x0 = vdata[v00].v.ob[0], y0 = vdata[v00].v.ob[1], z0 = vdata[v00].v.ob[2]; short x1 = vdata[v01].v.ob[0], y1 = vdata[v01].v.ob[1], z1 = vdata[v01].v.ob[2]; @@ -129,8 +130,8 @@ static void process_display_list( void *dl ) case GFXCMD_Light: { - int64_t l = *ptr++; - int64_t n = *ptr++; + DL_INT_SIZE l = *ptr++; + DL_INT_SIZE n = *ptr++; if( n == 1 ) { @@ -145,9 +146,9 @@ static void process_display_list( void *dl ) case GFXCMD_Texture: { - int64_t s = *ptr++; - int64_t t = *ptr++; - int64_t on = *ptr++; + DL_INT_SIZE s = *ptr++; + DL_INT_SIZE t = *ptr++; + DL_INT_SIZE on = *ptr++; s_scaleS = (uint16_t)s; s_scaleT = (uint16_t)t; @@ -158,7 +159,7 @@ static void process_display_list( void *dl ) case GFXCMD_SetTextureImage: { - int64_t i = *ptr++; + DL_INT_SIZE i = *ptr++; s_textureIndex = (int)i; s_texWidth = mario_tex_widths[s_textureIndex]; @@ -169,8 +170,8 @@ static void process_display_list( void *dl ) case GFXCMD_SetTileSize: { - int64_t uls = *ptr++; - int64_t ult = *ptr++; + DL_INT_SIZE uls = *ptr++; + DL_INT_SIZE ult = *ptr++; ptr++; // lrs ptr++; // lrt @@ -182,7 +183,7 @@ static void process_display_list( void *dl ) case GFXCMD_SubDisplayList: { - int64_t dl = *ptr++; + DL_INT_SIZE dl = *ptr++; process_display_list( (void*)dl ); break; } diff --git a/src/gfx_macros.h b/src/gfx_macros.h index 35b2988..e85bb65 100644 --- a/src/gfx_macros.h +++ b/src/gfx_macros.h @@ -2,6 +2,7 @@ #include "decomp/include/types.h" #include "gfx_adapter_commands.h" +#include "cpu_type.h" /* * Vertex (set up for use with colors) @@ -74,11 +75,13 @@ typedef struct { #define G_OFF 0 #define G_TEXTURE_IMAGE_FRAC 2 +typedef DL_INT_SIZE Gfx; + #define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) {{{ {ar,ag,ab},0,{ar,ag,ab},0}}, {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } #define gsSPVertex(v, n, v0) \ GFXCMD_VertexData, \ - (int64_t)v, n, v0 + (DL_INT_SIZE)v, n, v0 #define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ GFXCMD_Triangle, \ @@ -95,11 +98,11 @@ typedef struct { #define gsSPDisplayList(dl) \ GFXCMD_SubDisplayList, \ - (int64_t)dl + (DL_INT_SIZE)dl #define gsSPLight(l, n) \ GFXCMD_Light, \ - (int64_t)l, n + (DL_INT_SIZE)l, n #define gsSPTexture(s, t, level, tile, on) \ GFXCMD_Texture, \ @@ -123,6 +126,4 @@ typedef struct { #define gsDPTileSync() (GFXCMD_None) #define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, maskt, shiftt, cms, masks, shifts) (GFXCMD_None) #define gsDPLoadBlock(tile, uls, ult, lrs, dxt) (GFXCMD_None) -#define gsDPLoadSync() (GFXCMD_None) - -typedef int64_t Gfx; \ No newline at end of file +#define gsDPLoadSync() (GFXCMD_None) \ No newline at end of file From babdc896b50b746996ad774b01071640450be9dd Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Wed, 19 Oct 2022 21:10:25 -0500 Subject: [PATCH 3/8] Pulled out debug print function registering into a separate method from init. --- src/debug_print.h | 3 --- src/libsm64.c | 9 +++++++-- src/libsm64.h | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/debug_print.h b/src/debug_print.h index 913ed42..987cc31 100644 --- a/src/debug_print.h +++ b/src/debug_print.h @@ -10,8 +10,5 @@ extern SM64DebugPrintFunctionPtr g_debug_print_func; char debugStr[1024]; \ sprintf( debugStr, __VA_ARGS__ ); \ g_debug_print_func( debugStr ); \ - } else { \ - printf( __VA_ARGS__ ); \ - printf( "\n" ); \ } \ } while(0) diff --git a/src/libsm64.c b/src/libsm64.c index f184223..6cd4c5b 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -79,13 +79,18 @@ static void free_area( struct Area *area ) free( area ); } -SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction ) +typedef void (*SM64DebugPrintFunctionPtr)( const char * ); +SM64_LIB_FN void sm64_register_debug_print_function( SM64DebugPrintFunctionPtr debugPrintFunction ) +{ + g_debug_print_func = debugPrintFunction; +} + +SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture ) { if( s_init_global ) sm64_global_terminate(); s_init_global = true; - g_debug_print_func = debugPrintFunction; load_mario_textures_from_rom( rom, outTexture ); load_mario_anims_from_rom( rom ); diff --git a/src/libsm64.h b/src/libsm64.h index 6274477..ccb3916 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -60,8 +60,6 @@ struct SM64MarioGeometryBuffers uint16_t numTrianglesUsed; }; -typedef void (*SM64DebugPrintFunctionPtr)( const char * ); - enum { SM64_TEXTURE_WIDTH = 64 * 11, @@ -69,7 +67,10 @@ enum SM64_GEO_MAX_TRIANGLES = 1024, }; -extern SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction ); +typedef void (*SM64DebugPrintFunctionPtr)( const char * ); +extern SM64_LIB_FN void sm64_register_debug_print_function( SM64DebugPrintFunctionPtr debugPrintFunction ); + +extern SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture ); extern SM64_LIB_FN void sm64_global_terminate( void ); extern SM64_LIB_FN void sm64_static_surfaces_load( const struct SM64Surface *surfaceArray, uint32_t numSurfaces ); From a1797468890f12910189932de0a3fcb606348b20 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Wed, 19 Oct 2022 23:46:13 -0500 Subject: [PATCH 4/8] Exposed registering a handler for playing sounds. --- src/decomp/shim.h | 2 +- src/libsm64.c | 7 +++++++ src/libsm64.h | 7 +++++++ src/play_sound.c | 9 +++++++++ src/play_sound.h | 9 +++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/play_sound.c create mode 100644 src/play_sound.h diff --git a/src/decomp/shim.h b/src/decomp/shim.h index c0df3ab..11c762e 100644 --- a/src/decomp/shim.h +++ b/src/decomp/shim.h @@ -4,6 +4,7 @@ #include "game/area.h" #include "game/level_update.h" #include "../libsm64.h" +#include "../play_sound.h" #include "global_state.h" #define COURSE_MIN 0 @@ -36,7 +37,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" -static void play_sound(s32 soundBits, f32 *pos) {} static void enable_time_stop() {} static void disable_time_stop() {} static void *segmented_to_virtual(const void *addr) { return (void*)addr; } diff --git a/src/libsm64.c b/src/libsm64.c index 6cd4c5b..f83013c 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -85,6 +85,13 @@ SM64_LIB_FN void sm64_register_debug_print_function( SM64DebugPrintFunctionPtr d g_debug_print_func = debugPrintFunction; } +typedef void (*SM64PlaySoundFunctionPtr)( uint32_t soundBits, f32 *pos ); +SM64_LIB_FN void sm64_register_play_sound_function( SM64PlaySoundFunctionPtr playSoundFunction ) +{ + g_play_sound_func = playSoundFunction; +} + + SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture ) { if( s_init_global ) diff --git a/src/libsm64.h b/src/libsm64.h index ccb3916..51f6b44 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -5,6 +5,8 @@ #include #include +#include "decomp/include/types.h" + #ifdef _WIN32 #ifdef SM64_LIB_EXPORT #define SM64_LIB_FN __declspec(dllexport) @@ -67,9 +69,14 @@ enum SM64_GEO_MAX_TRIANGLES = 1024, }; + typedef void (*SM64DebugPrintFunctionPtr)( const char * ); extern SM64_LIB_FN void sm64_register_debug_print_function( SM64DebugPrintFunctionPtr debugPrintFunction ); +typedef void (*SM64PlaySoundFunctionPtr)( uint32_t soundBits, f32 *pos ); +extern SM64_LIB_FN void sm64_register_play_sound_function( SM64PlaySoundFunctionPtr playSoundFunction ); + + extern SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture ); extern SM64_LIB_FN void sm64_global_terminate( void ); diff --git a/src/play_sound.c b/src/play_sound.c new file mode 100644 index 0000000..0560ba3 --- /dev/null +++ b/src/play_sound.c @@ -0,0 +1,9 @@ +#include "play_sound.h" + +SM64PlaySoundFunctionPtr g_play_sound_func = NULL; + +extern void play_sound( uint32_t soundBits, f32 *pos ) { + if ( g_play_sound_func ) { + g_play_sound_func(soundBits, pos); + } +} \ No newline at end of file diff --git a/src/play_sound.h b/src/play_sound.h new file mode 100644 index 0000000..ab486b3 --- /dev/null +++ b/src/play_sound.h @@ -0,0 +1,9 @@ +#pragma once + +#include "decomp/include/types.h" +#include "libsm64.h" +#include + +extern SM64PlaySoundFunctionPtr g_play_sound_func; + +extern void play_sound( uint32_t soundBits, f32 *pos ); \ No newline at end of file From 478d28ed7dab9ae08f43c4d2f399d3ee16074541 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Thu, 20 Oct 2022 00:01:51 -0500 Subject: [PATCH 5/8] Carried over a NPE fix from @ckosmic's fork. --- src/decomp/game/mario.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/decomp/game/mario.c b/src/decomp/game/mario.c index 34f2fc0..bb33cc2 100644 --- a/src/decomp/game/mario.c +++ b/src/decomp/game/mario.c @@ -1329,7 +1329,9 @@ void update_mario_geometry_inputs(struct MarioState *m) { m->floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &m->floor); - m->curTerrain = m->floor->terrain; + if(m->floor != NULL) { + m->curTerrain = m->floor->terrain; + } // If Mario is OOB, move his position to his graphical position (which was not updated) // and check for the floor there. From c035455ff730f77e11ccc3362101e1cef2176d13 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Thu, 20 Oct 2022 00:18:43 -0500 Subject: [PATCH 6/8] Copied a fix that extends the region Mario can explore beyond shorts from @ckosmic's fork. --- src/decomp/game/area.h | 2 +- src/decomp/game/mario.c | 2 +- src/libsm64.c | 2 +- src/libsm64.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/decomp/game/area.h b/src/decomp/game/area.h index fee150b..84b05d6 100644 --- a/src/decomp/game/area.h +++ b/src/decomp/game/area.h @@ -35,7 +35,7 @@ struct InstantWarp struct SpawnInfo { - /*0x00*/ Vec3s startPos; + /*0x00*/ Vec3f startPos; /*0x06*/ Vec3s startAngle; /*0x0C*/ s8 areaIndex; /*0x0D*/ s8 activeAreaIndex; diff --git a/src/decomp/game/mario.c b/src/decomp/game/mario.c index bb33cc2..2cd16c1 100644 --- a/src/decomp/game/mario.c +++ b/src/decomp/game/mario.c @@ -1838,7 +1838,7 @@ int init_mario(void) { vec3s_copy(gMarioState->faceAngle, gMarioSpawnInfo->startAngle); vec3s_set(gMarioState->angleVel, 0, 0, 0); - vec3s_to_vec3f(gMarioState->pos, gMarioSpawnInfo->startPos); + vec3f_copy(gMarioState->pos, gMarioSpawnInfo->startPos); vec3f_set(gMarioState->vel, 0, 0, 0); gMarioState->floorHeight = diff --git a/src/libsm64.c b/src/libsm64.c index f83013c..003837a 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -139,7 +139,7 @@ SM64_LIB_FN void sm64_static_surfaces_load( const struct SM64Surface *surfaceArr surfaces_load_static( surfaceArray, numSurfaces ); } -SM64_LIB_FN int32_t sm64_mario_create( int16_t x, int16_t y, int16_t z ) +SM64_LIB_FN int32_t sm64_mario_create( float x, float y, float z ) { int32_t marioIndex = obj_pool_alloc_index( &s_mario_instance_pool, sizeof( struct MarioInstance )); struct MarioInstance *newInstance = s_mario_instance_pool.objects[marioIndex]; diff --git a/src/libsm64.h b/src/libsm64.h index 51f6b44..2a10146 100644 --- a/src/libsm64.h +++ b/src/libsm64.h @@ -22,7 +22,7 @@ struct SM64Surface int16_t type; int16_t force; uint16_t terrain; - int16_t vertices[3][3]; + int32_t vertices[3][3]; }; struct SM64MarioInputs @@ -82,7 +82,7 @@ extern SM64_LIB_FN void sm64_global_terminate( void ); extern SM64_LIB_FN void sm64_static_surfaces_load( const struct SM64Surface *surfaceArray, uint32_t numSurfaces ); -extern SM64_LIB_FN int32_t sm64_mario_create( int16_t x, int16_t y, int16_t z ); +extern SM64_LIB_FN int32_t sm64_mario_create( float x, float y, float z ); extern SM64_LIB_FN void sm64_mario_tick( int32_t marioId, const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers ); extern SM64_LIB_FN void sm64_mario_delete( int32_t marioId ); From fda94524217ee35c2782f8bd6886c58d7ae22a42 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Thu, 20 Oct 2022 00:54:05 -0500 Subject: [PATCH 7/8] Fixed how DLs are rendered past the bounds of short values. --- Makefile | 2 +- src/decomp/engine/guMtxF2L.c | 3 +++ src/gfx_adapter.c | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 12aec67..b3fc266 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ else CC := cc LDFLAGS := -lm -shared endif -CFLAGS := -g -Wall -fPIC -DSM64_LIB_EXPORT +CFLAGS := -g -Wall -fPIC -DSM64_LIB_EXPORT -DGBI_FLOATS SRC_DIRS := src src/decomp src/decomp/engine src/decomp/game src/decomp/mario src/decomp/tools BUILD_DIR := build diff --git a/src/decomp/engine/guMtxF2L.c b/src/decomp/engine/guMtxF2L.c index 7d89761..246336b 100644 --- a/src/decomp/engine/guMtxF2L.c +++ b/src/decomp/engine/guMtxF2L.c @@ -44,6 +44,9 @@ void guMtxL2F(float mf[4][4], Mtx *m) { void guMtxF2L(float mf[4][4], Mtx *m) { memcpy(m, mf, sizeof(Mtx)); } +void guMtxL2F(float mf[4][4], Mtx *m) { + memcpy(mf, m, sizeof(Mtx)); +} #endif void guMtxIdentF(float mf[4][4]) { diff --git a/src/gfx_adapter.c b/src/gfx_adapter.c index 3698c2b..9a23e1c 100644 --- a/src/gfx_adapter.c +++ b/src/gfx_adapter.c @@ -65,9 +65,9 @@ static void process_display_list( void *dl ) DL_INT_SIZE v02 = *ptr++; UNUSED DL_INT_SIZE flag0 = *ptr++; - short x0 = vdata[v00].v.ob[0], y0 = vdata[v00].v.ob[1], z0 = vdata[v00].v.ob[2]; - short x1 = vdata[v01].v.ob[0], y1 = vdata[v01].v.ob[1], z1 = vdata[v01].v.ob[2]; - short x2 = vdata[v02].v.ob[0], y2 = vdata[v02].v.ob[1], z2 = vdata[v02].v.ob[2]; + float x0 = vdata[v00].v.ob[0], y0 = vdata[v00].v.ob[1], z0 = vdata[v00].v.ob[2]; + float x1 = vdata[v01].v.ob[0], y1 = vdata[v01].v.ob[1], z1 = vdata[v01].v.ob[2]; + float x2 = vdata[v02].v.ob[0], y2 = vdata[v02].v.ob[1], z2 = vdata[v02].v.ob[2]; Vec3f p0 = { (float)x0, (float)y0, (float)z0 }; Vec3f p1 = { (float)x1, (float)y1, (float)z1 }; Vec3f p2 = { (float)x2, (float)y2, (float)z2 }; From 2e2b6de15d4c2152e5e468ef4685f6e8a8480f4c Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Thu, 20 Oct 2022 12:53:32 -0500 Subject: [PATCH 8/8] Switched needless "DL_INT_SIZE" define to intptr_t. --- src/cpu_type.h | 8 -------- src/gfx_adapter.c | 35 +++++++++++++++++------------------ src/gfx_macros.h | 9 ++++----- 3 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 src/cpu_type.h diff --git a/src/cpu_type.h b/src/cpu_type.h deleted file mode 100644 index 138b7fe..0000000 --- a/src/cpu_type.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#ifdef WIN32 - #define DL_INT_SIZE int32_t -#endif -#ifdef WIN64 - #define DL_INT_SIZE int64_t -#endif \ No newline at end of file diff --git a/src/gfx_adapter.c b/src/gfx_adapter.c index 9a23e1c..ba7fc1d 100644 --- a/src/gfx_adapter.c +++ b/src/gfx_adapter.c @@ -7,7 +7,6 @@ #include "gfx_adapter.h" #include "gfx_adapter_commands.h" #include "load_tex_data.h" -#include "cpu_type.h" static Mat4 s_curMatrix; static float s_curColor[3]; @@ -42,7 +41,7 @@ static void convert_uv_to_atlas( float *atlas_uv_out, short tc[] ) static void process_display_list( void *dl ) { - DL_INT_SIZE *ptr = (DL_INT_SIZE *)dl; + intptr_t *ptr = (intptr_t *)dl; Vtx *vdata = NULL; for( ;; ) @@ -51,19 +50,19 @@ static void process_display_list( void *dl ) { case GFXCMD_VertexData: { - UNUSED DL_INT_SIZE v = *ptr++; - UNUSED DL_INT_SIZE n = *ptr++; - UNUSED DL_INT_SIZE v0 = *ptr++; + UNUSED intptr_t v = *ptr++; + UNUSED intptr_t n = *ptr++; + UNUSED intptr_t v0 = *ptr++; vdata = (Vtx*)v; break; } case GFXCMD_Triangle: { - DL_INT_SIZE v00 = *ptr++; - DL_INT_SIZE v01 = *ptr++; - DL_INT_SIZE v02 = *ptr++; - UNUSED DL_INT_SIZE flag0 = *ptr++; + intptr_t v00 = *ptr++; + intptr_t v01 = *ptr++; + intptr_t v02 = *ptr++; + UNUSED intptr_t flag0 = *ptr++; float x0 = vdata[v00].v.ob[0], y0 = vdata[v00].v.ob[1], z0 = vdata[v00].v.ob[2]; float x1 = vdata[v01].v.ob[0], y1 = vdata[v01].v.ob[1], z1 = vdata[v01].v.ob[2]; @@ -130,8 +129,8 @@ static void process_display_list( void *dl ) case GFXCMD_Light: { - DL_INT_SIZE l = *ptr++; - DL_INT_SIZE n = *ptr++; + intptr_t l = *ptr++; + intptr_t n = *ptr++; if( n == 1 ) { @@ -146,9 +145,9 @@ static void process_display_list( void *dl ) case GFXCMD_Texture: { - DL_INT_SIZE s = *ptr++; - DL_INT_SIZE t = *ptr++; - DL_INT_SIZE on = *ptr++; + intptr_t s = *ptr++; + intptr_t t = *ptr++; + intptr_t on = *ptr++; s_scaleS = (uint16_t)s; s_scaleT = (uint16_t)t; @@ -159,7 +158,7 @@ static void process_display_list( void *dl ) case GFXCMD_SetTextureImage: { - DL_INT_SIZE i = *ptr++; + intptr_t i = *ptr++; s_textureIndex = (int)i; s_texWidth = mario_tex_widths[s_textureIndex]; @@ -170,8 +169,8 @@ static void process_display_list( void *dl ) case GFXCMD_SetTileSize: { - DL_INT_SIZE uls = *ptr++; - DL_INT_SIZE ult = *ptr++; + intptr_t uls = *ptr++; + intptr_t ult = *ptr++; ptr++; // lrs ptr++; // lrt @@ -183,7 +182,7 @@ static void process_display_list( void *dl ) case GFXCMD_SubDisplayList: { - DL_INT_SIZE dl = *ptr++; + intptr_t dl = *ptr++; process_display_list( (void*)dl ); break; } diff --git a/src/gfx_macros.h b/src/gfx_macros.h index e85bb65..3bbe1d0 100644 --- a/src/gfx_macros.h +++ b/src/gfx_macros.h @@ -2,7 +2,6 @@ #include "decomp/include/types.h" #include "gfx_adapter_commands.h" -#include "cpu_type.h" /* * Vertex (set up for use with colors) @@ -75,13 +74,13 @@ typedef struct { #define G_OFF 0 #define G_TEXTURE_IMAGE_FRAC 2 -typedef DL_INT_SIZE Gfx; +typedef intptr_t Gfx; #define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) {{{ {ar,ag,ab},0,{ar,ag,ab},0}}, {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } #define gsSPVertex(v, n, v0) \ GFXCMD_VertexData, \ - (DL_INT_SIZE)v, n, v0 + (intptr_t)v, n, v0 #define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ GFXCMD_Triangle, \ @@ -98,11 +97,11 @@ typedef DL_INT_SIZE Gfx; #define gsSPDisplayList(dl) \ GFXCMD_SubDisplayList, \ - (DL_INT_SIZE)dl + (intptr_t)dl #define gsSPLight(l, n) \ GFXCMD_Light, \ - (DL_INT_SIZE)l, n + (intptr_t)l, n #define gsSPTexture(s, t, level, tile, on) \ GFXCMD_Texture, \