From b921cb04bb6a32cea647defe955c370568a97e98 Mon Sep 17 00:00:00 2001 From: jaburns Date: Tue, 27 Oct 2020 15:11:12 -0600 Subject: [PATCH] Moved mario global state vars in to struct --- src/debug_print.c | 3 + src/debug_print.h | 13 +++ src/decomp/game/mario.c | 5 +- src/decomp/game/object_stuff.c | 4 - src/decomp/game/platform_displacement.c | 14 +-- src/decomp/game/save_file.h | 10 +- src/decomp/global_state.c | 22 +++- src/decomp/global_state.h | 62 ++++++----- src/decomp/shim.c | 128 ---------------------- src/decomp/shim.h | 137 +++++++++--------------- src/libsm64.c | 16 ++- src/load_anim_data.c | 22 ++-- src/load_anim_data.h | 3 +- src/load_surfaces.c | 4 +- src/load_surfaces.h | 15 +++ 15 files changed, 186 insertions(+), 272 deletions(-) create mode 100644 src/debug_print.c create mode 100644 src/debug_print.h delete mode 100644 src/decomp/shim.c diff --git a/src/debug_print.c b/src/debug_print.c new file mode 100644 index 0000000..4e38327 --- /dev/null +++ b/src/debug_print.c @@ -0,0 +1,3 @@ +#include "debug_print.h" + +SM64DebugPrintFunctionPtr g_debug_print_func = NULL; \ No newline at end of file diff --git a/src/debug_print.h b/src/debug_print.h new file mode 100644 index 0000000..b2eaa7e --- /dev/null +++ b/src/debug_print.h @@ -0,0 +1,13 @@ +#pragma once + +#include "libsm64.h" + +extern SM64DebugPrintFunctionPtr g_debug_print_func; + +#define DEBUG_PRINT( ... ) do { \ + if( g_debug_print_func ) { \ + char debugStr[1024]; \ + sprintf( debugStr, __VA_ARGS__ ); \ + g_debug_print_func( debugStr ); \ + } \ +} while(0) \ No newline at end of file diff --git a/src/decomp/game/mario.c b/src/decomp/game/mario.c index c72d286..90bb8d6 100644 --- a/src/decomp/game/mario.c +++ b/src/decomp/game/mario.c @@ -37,6 +37,7 @@ #include "save_file.h" // #include "sound_init.h" // #include "thread6.h" +#include "../../load_anim_data.h" /************************************************** @@ -67,7 +68,7 @@ s32 is_anim_past_end(struct MarioState *m) { s16 set_mario_animation(struct MarioState *m, s32 targetAnimID) { struct Object *o = m->marioObj; - shim_load_mario_animation(m->animation, targetAnimID); + load_mario_animation(m->animation, targetAnimID); struct Animation *targetAnim = m->animation->targetAnim; //if (load_patchable_table(m->animation, targetAnimID)) { // targetAnim->values = (void *) VIRTUAL_TO_PHYSICAL((u8 *) targetAnim + (uintptr_t) targetAnim->values); @@ -101,7 +102,7 @@ s16 set_mario_animation(struct MarioState *m, s32 targetAnimID) { s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel) { struct Object *o = m->marioObj; - shim_load_mario_animation(m->animation, targetAnimID); + load_mario_animation(m->animation, targetAnimID); struct Animation *targetAnim = m->animation->targetAnim; //if (load_patchable_table(m->animation, targetAnimID)) { // targetAnim->values = (void *) VIRTUAL_TO_PHYSICAL((u8 *) targetAnim + (uintptr_t) targetAnim->values); diff --git a/src/decomp/game/object_stuff.c b/src/decomp/game/object_stuff.c index 7da27e0..9f10fb2 100644 --- a/src/decomp/game/object_stuff.c +++ b/src/decomp/game/object_stuff.c @@ -260,10 +260,6 @@ void bhv_mario_update(void) { // } } - - - - void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2) { f32 spC, sp8, sp4; diff --git a/src/decomp/game/platform_displacement.c b/src/decomp/game/platform_displacement.c index aba3dc5..58447e4 100644 --- a/src/decomp/game/platform_displacement.c +++ b/src/decomp/game/platform_displacement.c @@ -7,8 +7,8 @@ #include "object_stuff.h" #include "platform_displacement.h" #include "../shim.h" - -struct SurfaceObjectTransform *gMarioPlatform = NULL; +#include "../global_state.h" +#include "../../load_surfaces.h" #define absfx( x ) ( (x) < 0.0f ? -(x) : (x) ) @@ -47,16 +47,16 @@ void update_mario_platform(void) { switch (awayFromFloor) { case 1: - gMarioPlatform = NULL; + g_state->mgMarioPlatform = NULL; gMarioObject->platform = NULL; break; case 0: if (floor != NULL && floor->object != NULL) { - gMarioPlatform = (struct SurfaceObjectTransform *)floor->object; + g_state->mgMarioPlatform = floor->object; gMarioObject->platform = floor->object; } else { - gMarioPlatform = NULL; + g_state->mgMarioPlatform = NULL; gMarioObject->platform = NULL; } break; @@ -166,7 +166,7 @@ void apply_platform_displacement(u32 isMario, struct SurfaceObjectTransform *pla * If Mario's platform is not null, apply platform displacement. */ void apply_mario_platform_displacement(void) { - struct SurfaceObjectTransform *platform = gMarioPlatform; + struct SurfaceObjectTransform *platform = g_state->mgMarioPlatform; if (gMarioObject != NULL && platform != NULL) { apply_platform_displacement(TRUE, platform); @@ -177,5 +177,5 @@ void apply_mario_platform_displacement(void) { * Set Mario's platform to NULL. */ void clear_mario_platform(void) { - gMarioPlatform = NULL; + g_state->mgMarioPlatform = NULL; } \ No newline at end of file diff --git a/src/decomp/game/save_file.h b/src/decomp/game/save_file.h index 4cafb32..9d6eb5e 100644 --- a/src/decomp/game/save_file.h +++ b/src/decomp/game/save_file.h @@ -83,7 +83,7 @@ extern u8 gLastCompletedStarNum; extern s8 sUnusedGotGlobalCoinHiScore; extern u8 gGotFileCoinHiScore; extern u8 gCurrCourseStarFlags; -extern u8 gSpecialTripleJump; +//extern u8 gSpecialTripleJump; extern s8 gLevelToCourseNumTable[]; // game progress flags @@ -142,10 +142,10 @@ void save_file_collect_star_or_key(s16 coinScore, s16 starIndex); s32 save_file_exists(s32 fileIndex); u32 save_file_get_max_coin_score(s32 courseIndex); s32 save_file_get_course_star_count(s32 fileIndex, s32 courseIndex); -s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse); -void save_file_set_flags(u32 flags); -void save_file_clear_flags(u32 flags); -u32 save_file_get_flags(void); +//s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse); +//void save_file_set_flags(u32 flags); +//void save_file_clear_flags(u32 flags); +//u32 save_file_get_flags(void); u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex); void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags); s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex); diff --git a/src/decomp/global_state.c b/src/decomp/global_state.c index e25b988..0e74043 100644 --- a/src/decomp/global_state.c +++ b/src/decomp/global_state.c @@ -1,3 +1,23 @@ #include "global_state.h" -struct GlobalState *gState = 0; \ No newline at end of file +#include +#include + +struct GlobalState *g_state = 0; + +struct GlobalState *global_state_create(void) +{ + struct GlobalState *state = malloc( sizeof( struct GlobalState )); + memset( state, 0, sizeof( struct GlobalState )); + return state; +} + +void global_state_bind(struct GlobalState *state) +{ + g_state = state; +} + +void global_state_destroy(struct GlobalState *state) +{ + free( state ); +} \ No newline at end of file diff --git a/src/decomp/global_state.h b/src/decomp/global_state.h index a5ed474..2562369 100644 --- a/src/decomp/global_state.h +++ b/src/decomp/global_state.h @@ -5,44 +5,50 @@ struct GlobalState { +// Not yet implemented: + // interaction.c - u8 sDelayInvincTimer; - s16 sInvulnerable; + u8 msDelayInvincTimer; + s16 msInvulnerable; // mario_actions_moving.c - Mat4 sFloorAlignMatrix; + Mat4 msFloorAlignMatrix; // mario_actions_submerged.c - s16 sWasAtSurface; - s16 sSwimStrength; - s16 D_80339FD0; - s16 D_80339FD2; - f32 D_80339FD4; + s16 msWasAtSurface; + s16 msSwimStrength; + s16 mD_80339FD0; + s16 mD_80339FD2; + f32 mD_80339FD4; // mario_misc.c - struct MarioBodyState gBodyStates[2]; + struct MarioBodyState mgBodyStates[2]; + +// Implemented and in use: // platform_displacement.c - void *gMarioPlatform; + void *mgMarioPlatform; // misc - u32 gGlobalTimer; - u8 gSpecialTripleJump; - s16 gCurrLevelNum; - s16 gCameraMovementFlags; - u32 gAudioRandom; - s8 gShowDebugText; - s8 gDebugLevelSelect; - s16 gCurrSaveFileNum; - struct Controller gController; - struct SpawnInfo gMarioSpawnInfoVal; - struct SpawnInfo *gMarioSpawnInfo; - struct Area *gCurrentArea; - struct Object *gCurrentObject; - struct Object *gMarioObject; - struct MarioAnimation D_80339D10; - struct MarioState gMarioStateVal; - struct MarioState *gMarioState; + u32 mgGlobalTimer; + u8 mgSpecialTripleJump; + s16 mgCurrLevelNum; + s16 mgCameraMovementFlags; + u32 mgAudioRandom; + s8 mgShowDebugText; + s8 mgDebugLevelSelect; + s16 mgCurrSaveFileNum; + struct Controller mgController; + struct SpawnInfo mgMarioSpawnInfoVal; + struct Area *mgCurrentArea; + struct Object *mgCurrentObject; + struct Object *mgMarioObject; + struct MarioAnimation mD_80339D10; + struct MarioState mgMarioStateVal; }; -extern struct GlobalState *gState; \ No newline at end of file +extern struct GlobalState *g_state; + +extern struct GlobalState *global_state_create(void); +extern void global_state_bind(struct GlobalState *state); +extern void global_state_destroy(struct GlobalState *state); \ No newline at end of file diff --git a/src/decomp/shim.c b/src/decomp/shim.c deleted file mode 100644 index caea805..0000000 --- a/src/decomp/shim.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include "shim.h" -#include "../load_anim_data.h" - -u32 gGlobalTimer = 0; -u8 gSpecialTripleJump = FALSE; -s16 gCurrLevelNum = 0; -s16 gCameraMovementFlags = 0; -u32 gAudioRandom = 0; -s8 gShowDebugText = 0; -s8 gDebugLevelSelect = 0; -s16 gCurrSaveFileNum = 1; -struct Controller gController; -struct SpawnInfo gMarioSpawnInfoVal; -struct SpawnInfo *gMarioSpawnInfo = &gMarioSpawnInfoVal; -struct Area *gCurrentArea = NULL; -struct Object *gCurrentObject; -struct Object *gMarioObject = NULL; -struct PlayerCameraState gPlayerCameraState; -struct MarioAnimation D_80339D10; -struct MarioState gMarioStateVal; -struct MarioState *gMarioState = &gMarioStateVal; -SM64DebugPrintFunctionPtr gDebugPrint = NULL; - -void shim_load_mario_animation(struct MarioAnimation *a, u32 index) -{ - if ((u32)a->currentAnimAddr != 1 + index) { - a->currentAnimAddr = (u8*)(1 + index); - a->targetAnim = &g_libsm64_mario_animations[index]; - } -} - -void *segmented_to_virtual(const void *addr) -{ - return (void*)addr; -} - -void *virtual_to_segmented(u32 segment, const void *addr) -{ - return (void*)addr; -} - -void func_80320A4C(u8 bankIndex, u8 arg1) -{ -} - -void lower_background_noise(s32 a) -{ -} - -void raise_background_noise(s32 a) -{ -} - -void set_camera_mode(struct Camera *c, s16 mode, s16 frames) -{ -} - -void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n) -{ -} - -s16 level_trigger_warp(struct MarioState *m, s32 warpOp) -{ - return 0; -} - -void play_cap_music(u16 seqArgs) -{ -} - -void fadeout_cap_music(void) -{ -} - -void stop_cap_music(void) -{ -} - -void play_infinite_stairs_music(void) -{ -} - -s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse) -{ - return 0; -} - -u32 save_file_get_flags(void) -{ - return 0; -} - -void save_file_set_flags(u32 flags) -{ -} - -void save_file_clear_flags(u32 flags) -{ -} - -void spawn_wind_particles(s16 pitch, s16 yaw) -{ -} - -void set_camera_shake_from_hit(s16 shake) -{ -} - -void load_level_init_text(u32 arg) -{ -} - -void spawn_default_star(f32 sp20, f32 sp24, f32 sp28) -{ -} - -void play_shell_music(void) -{ -} - -void stop_shell_music(void) -{ -} - -u16 level_control_timer(s32 timerOp) -{ -} \ No newline at end of file diff --git a/src/decomp/shim.h b/src/decomp/shim.h index a776f60..7e26170 100644 --- a/src/decomp/shim.h +++ b/src/decomp/shim.h @@ -4,93 +4,58 @@ #include "game/area.h" #include "game/level_update.h" #include "../libsm64.h" +#include "global_state.h" -#define COURSE_MIN 0 -#define COURSE_MAX 14 -#define LEVEL_LLL 99 -#define LEVEL_SSL 98 -#define LEVEL_DDD 97 -#define LEVEL_TTC 96 +#define COURSE_MIN 0 +#define COURSE_MAX 14 +#define LEVEL_LLL 99 +#define LEVEL_SSL 98 +#define LEVEL_DDD 97 +#define LEVEL_TTC 96 #define LEVEL_CASTLE 95 -#define LEVEL_THI 94 +#define LEVEL_THI 94 -// From graph_node.h, trying not to pull that in yet -#define GRAPH_RENDER_INVISIBLE (1 << 4) +#define play_sound(a,b) {} +#define enable_time_stop() {} +#define disable_time_stop() {} +#define play_cutscene_music(a) {} +#define segmented_to_virtual(addr) ((void*)(addr)) +#define virtual_to_segmented(seg,addr) ((void*)(addr)) +#define func_80320A4C(bankIndex, arg1) {} +#define raise_background_noise(a) {} +#define lower_background_noise(a) {} +#define set_camera_mode(c, mode, frames) {} +#define print_text_fmt_int(x, y, str, n) {} +#define level_trigger_warp(m, warpOp) 0 +#define play_cap_music(seqArgs) {} +#define fadeout_cap_music() {} +#define stop_cap_music() {} +#define play_infinite_stairs_music() {} +#define spawn_wind_particles(pitch, yaw) {} +#define set_camera_shake_from_hit(shake) {} +#define load_level_init_text(arg) {} +#define spawn_default_star(sp20, sp24, sp28) {} +#define play_shell_music() {} +#define stop_shell_music() {} +#define level_control_timer(timerOp) 0 +#define save_file_get_flags() 0 +#define save_file_set_flags(flags) {} +#define save_file_clear_flags(flags) {} +#define save_file_get_total_star_count(fileIndex, minCourse, maxCourse) 0 -#define play_sound(a,b) ({}) -#define enable_time_stop() ({}) -#define disable_time_stop() ({}) -#define play_cutscene_music(a) ({}) - -struct SurfaceObjectTransform -{ - float aPosX, aPosY, aPosZ; - float aVelX, aVelY, aVelZ; - - s16 aFaceAnglePitch; - s16 aFaceAngleYaw; - s16 aFaceAngleRoll; - - s16 aAngleVelPitch; - s16 aAngleVelYaw; - s16 aAngleVelRoll; -}; - -struct SurfaceNode -{ - struct SurfaceNode *next; - struct Surface *surface; -}; - -extern u32 gGlobalTimer; -extern u8 gSpecialTripleJump; -extern s16 gCurrLevelNum; -extern s16 gCameraMovementFlags; -extern u32 gAudioRandom; -extern s8 gShowDebugText; -extern s8 gDebugLevelSelect; -extern s16 gCurrSaveFileNum; -extern struct Controller gController; -extern struct SpawnInfo gMarioSpawnInfoVal; -extern struct SpawnInfo *gMarioSpawnInfo; -extern struct Area *gCurrentArea; -extern struct Object *gCurrentObject; -extern struct Object *gMarioObject; -extern struct PlayerCameraState gPlayerCameraState; -extern struct MarioAnimation D_80339D10; -extern struct MarioState *gMarioState; -extern SM64DebugPrintFunctionPtr gDebugPrint; - -#define DEBUG_LOG( ... ) do { \ - if( gDebugPrint ) { \ - char debugStr[1024]; \ - sprintf( debugStr, __VA_ARGS__ ); \ - gDebugPrint( debugStr ); \ - } \ -} while(0) - -extern void shim_load_mario_animation(struct MarioAnimation *a, u32 index); - -extern void *segmented_to_virtual(const void *addr); -extern void *virtual_to_segmented(u32 segment, const void *addr); -extern void func_80320A4C(u8 bankIndex, u8 arg1); -extern void raise_background_noise(s32 a); -extern void lower_background_noise(s32 a); -extern void set_camera_mode(struct Camera *c, s16 mode, s16 frames); -extern void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n); -extern s16 level_trigger_warp(struct MarioState *m, s32 warpOp); -extern void play_cap_music(u16 seqArgs); -extern void fadeout_cap_music(void); -extern void stop_cap_music(void); -extern void play_infinite_stairs_music(void); -extern s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse); -extern u32 save_file_get_flags(void); -extern void save_file_set_flags(u32 flags); -extern void save_file_clear_flags(u32 flags); -extern void spawn_wind_particles(s16 pitch, s16 yaw); -extern void set_camera_shake_from_hit(s16 shake); -extern void load_level_init_text(u32 arg); -extern void spawn_default_star(f32 sp20, f32 sp24, f32 sp28); -extern void play_shell_music(void); -extern void stop_shell_music(void); -extern u16 level_control_timer(s32 timerOp); \ No newline at end of file +#define gGlobalTimer (g_state->mgGlobalTimer) +#define gSpecialTripleJump (g_state->mgSpecialTripleJump) +#define gCurrLevelNum (g_state->mgCurrLevelNum) +#define gCameraMovementFlags (g_state->mgCameraMovementFlags) +#define gAudioRandom (g_state->mgAudioRandom) +#define gShowDebugText (g_state->mgShowDebugText) +#define gDebugLevelSelect (g_state->mgDebugLevelSelect) +#define gCurrSaveFileNum (g_state->mgCurrSaveFileNum) +#define gController (g_state->mgController) +#define gMarioSpawnInfoVal (g_state->mgMarioSpawnInfoVal) +#define gMarioSpawnInfo (&g_state->mgMarioSpawnInfoVal) +#define gCurrentArea (g_state->mgCurrentArea) +#define gCurrentObject (g_state->mgCurrentObject) +#define gMarioObject (g_state->mgMarioObject) +#define D_80339D10 (g_state->mD_80339D10) +#define gMarioState (&g_state->mgMarioStateVal) \ No newline at end of file diff --git a/src/libsm64.c b/src/libsm64.c index 0981a13..746b62b 100644 --- a/src/libsm64.c +++ b/src/libsm64.c @@ -11,6 +11,7 @@ #include "decomp/include/sm64.h" #include "decomp/shim.h" #include "decomp/memory.h" +#include "decomp/global_state.h" #include "decomp/game/mario.h" #include "decomp/game/object_stuff.h" #include "decomp/engine/surface_collision.h" @@ -20,6 +21,7 @@ #include "decomp/mario/geo.inc.h" #include "decomp/game/platform_displacement.h" +#include "debug_print.h" #include "load_surfaces.h" #include "gfx_adapter.h" #include "load_anim_data.h" @@ -29,6 +31,8 @@ static struct AllocOnlyPool *s_mario_geo_pool; static struct GraphNode *s_mario_graph_node; static uint32_t s_last_colors_hash; +static struct GlobalState *s_global_state; + static void update_button( bool on, u16 button ) { gController.buttonPressed &= ~button; @@ -83,13 +87,16 @@ static struct Area *hack_build_area( void ) SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction ) { s_last_colors_hash = 0; - gDebugPrint = debugPrintFunction; + g_debug_print_func = debugPrintFunction; load_mario_textures_from_rom( rom, outTexture ); load_mario_anims_from_rom( rom ); memory_init(); + s_global_state = global_state_create(); + global_state_bind( s_global_state ); + gCurrSaveFileNum = 1; gMarioObject = hack_allocate_mario(); gCurrentArea = hack_build_area(); gCurrentObject = gMarioObject; @@ -179,6 +186,13 @@ SM64_LIB_FN void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct S SM64_LIB_FN void sm64_global_terminate( void ) { + //deallocate area, + //deallocate mario object and graph node + + global_state_bind( NULL ); + global_state_destroy( s_global_state ); + s_global_state = NULL; + surfaces_unload_all(); unload_mario_anims(); memory_terminate(); diff --git a/src/load_anim_data.c b/src/load_anim_data.c index de8199e..3c652d6 100644 --- a/src/load_anim_data.c +++ b/src/load_anim_data.c @@ -3,7 +3,7 @@ #include static uint32_t s_num_entries = 0; -struct Animation *g_libsm64_mario_animations = NULL; +static struct Animation *s_libsm64_mario_animations = NULL; #define ANIM_DATA_ADDRESS 0x004EC000 @@ -37,8 +37,8 @@ void load_mario_anims_from_rom( uint8_t *rom ) uint8_t *read_ptr = rom + ANIM_DATA_ADDRESS; s_num_entries = read_u32_be( read_ptr ); - g_libsm64_mario_animations = malloc( s_num_entries * sizeof( struct Animation )); - struct Animation *anims = g_libsm64_mario_animations; + s_libsm64_mario_animations = malloc( s_num_entries * sizeof( struct Animation )); + struct Animation *anims = s_libsm64_mario_animations; for( int i = 0; i < s_num_entries; ++i ) { @@ -80,15 +80,23 @@ void load_mario_anims_from_rom( uint8_t *rom ) #undef GET_SIZE } +void load_mario_animation(struct MarioAnimation *a, u32 index) +{ + if ((u32)a->currentAnimAddr != 1 + index) { + a->currentAnimAddr = (u8*)(1 + index); + a->targetAnim = &s_libsm64_mario_animations[index]; + } +} + void unload_mario_anims( void ) { for( int i = 0; i < s_num_entries; ++i ) { - free( g_libsm64_mario_animations[i].index ); - free( g_libsm64_mario_animations[i].values ); + free( s_libsm64_mario_animations[i].index ); + free( s_libsm64_mario_animations[i].values ); } - free( g_libsm64_mario_animations ); - g_libsm64_mario_animations = NULL; + free( s_libsm64_mario_animations ); + s_libsm64_mario_animations = NULL; s_num_entries = 0; } \ No newline at end of file diff --git a/src/load_anim_data.h b/src/load_anim_data.h index ec40c57..6486193 100644 --- a/src/load_anim_data.h +++ b/src/load_anim_data.h @@ -5,7 +5,6 @@ #include "decomp/include/types.h" -extern struct Animation *g_libsm64_mario_animations; - +extern void load_mario_animation(struct MarioAnimation *a, u32 index); extern void load_mario_anims_from_rom( uint8_t *rom ); extern void unload_mario_anims( void ); \ No newline at end of file diff --git a/src/load_surfaces.c b/src/load_surfaces.c index 141c7ba..28ed865 100644 --- a/src/load_surfaces.c +++ b/src/load_surfaces.c @@ -8,6 +8,8 @@ #include "decomp/engine/math_util.h" #include "decomp/shim.h" +#include "debug_print.h" + struct LoadedSurfaceObject { struct SurfaceObjectTransform transform; @@ -156,7 +158,7 @@ static void engine_surface_from_lib_surface( struct Surface *surface, const stru } if (mag < 0.0001) - DEBUG_LOG("ERROR: normal magnitude is very close to zero"); + DEBUG_PRINT("ERROR: normal magnitude is very close to zero"); mag = (f32)(1.0 / mag); nx *= mag; diff --git a/src/load_surfaces.h b/src/load_surfaces.h index 566e7ed..8633d97 100644 --- a/src/load_surfaces.h +++ b/src/load_surfaces.h @@ -1,7 +1,22 @@ #pragma once +#include "decomp/include/PR/ultratypes.h" #include "libsm64.h" +struct SurfaceObjectTransform +{ + float aPosX, aPosY, aPosZ; + float aVelX, aVelY, aVelZ; + + s16 aFaceAnglePitch; + s16 aFaceAngleYaw; + s16 aFaceAngleRoll; + + s16 aAngleVelPitch; + s16 aAngleVelYaw; + s16 aAngleVelRoll; +}; + extern struct Surface *loaded_surface_get_at_index( uint32_t index ); extern uint32_t loaded_surface_get_count();