From c3c004ce947696dac886d064fa92cfa1c5bd2d62 Mon Sep 17 00:00:00 2001 From: jaburns Date: Tue, 27 Oct 2020 21:35:18 -0600 Subject: [PATCH] All global state coming from g_state now --- src/decomp/game/interaction.c | 7 +++++-- src/decomp/game/mario_actions_moving.c | 6 ++---- src/decomp/game/mario_actions_submerged.c | 20 +++++++++++++------- src/decomp/global_state.c | 1 + src/decomp/global_state.h | 7 +++---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/decomp/game/interaction.c b/src/decomp/game/interaction.c index 2d5cc79..d538c47 100644 --- a/src/decomp/game/interaction.c +++ b/src/decomp/game/interaction.c @@ -52,8 +52,11 @@ #define INT_ATTACK_NOT_WEAK_FROM_ABOVE \ (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW) -u8 sDelayInvincTimer; -s16 sInvulnerable; + +#define sDelayInvincTimer (g_state->msDelayInvincTimer) +#define sInvulnerable (g_state->msInvulnerable) +// u8 sDelayInvincTimer; +// s16 sInvulnerable; struct InteractionHandler { u32 interactType; diff --git a/src/decomp/game/mario_actions_moving.c b/src/decomp/game/mario_actions_moving.c index 0c128ac..62c9c0e 100644 --- a/src/decomp/game/mario_actions_moving.c +++ b/src/decomp/game/mario_actions_moving.c @@ -65,8 +65,6 @@ struct LandingAction sBackflipLandAction = { 4, 0, ACT_FREEFALL, ACT_BACKFLIP_LAND_STOP, ACT_BACKFLIP, ACT_FREEFALL, ACT_BEGIN_SLIDING, }; -Mat4 sFloorAlignMatrix[2]; - s16 tilt_body_running(struct MarioState *m) { s16 pitch = find_floor_slope(m, 0); pitch = pitch * m->forwardVel / 40.0f; @@ -93,8 +91,8 @@ void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2) { void align_with_floor(struct MarioState *m) { m->pos[1] = m->floorHeight; - mtxf_align_terrain_triangle(sFloorAlignMatrix[m->unk00], m->pos, m->faceAngle[1], 40.0f); - m->marioObj->header.gfx.throwMatrix = &sFloorAlignMatrix[m->unk00]; + mtxf_align_terrain_triangle(g_state->msFloorAlignMatrix, m->pos, m->faceAngle[1], 40.0f); + m->marioObj->header.gfx.throwMatrix = g_state->msFloorAlignMatrix; } s32 begin_walking_action(struct MarioState *m, f32 forwardVel, u32 action, u32 actionArg) { diff --git a/src/decomp/game/mario_actions_submerged.c b/src/decomp/game/mario_actions_submerged.c index d74c7ae..301af87 100644 --- a/src/decomp/game/mario_actions_submerged.c +++ b/src/decomp/game/mario_actions_submerged.c @@ -23,17 +23,23 @@ #include "../include/object_fields.h" #include "../include/mario_geo_switch_case_ids.h" -#define MIN_SWIM_STRENGTH 160 #define MIN_SWIM_SPEED 16.0f -static s16 sWasAtSurface = FALSE; -static s16 sSwimStrength = MIN_SWIM_STRENGTH; + +#define sWasAtSurface (g_state->msWasAtSurface) +#define sSwimStrength (g_state->msSwimStrength) +#define D_80339FD0 (g_state->mD_80339FD0) +#define D_80339FD2 (g_state->mD_80339FD2) +#define D_80339FD4 (g_state->mD_80339FD4) + +//static s16 sWasAtSurface = FALSE; +//static s16 sSwimStrength = MIN_SWIM_STRENGTH; static s16 sWaterCurrentSpeeds[] = { 28, 12, 8, 4 }; +//static s16 D_80339FD0; +//static s16 D_80339FD2; +//static f32 D_80339FD4; -static s16 D_80339FD0; -static s16 D_80339FD2; -static f32 D_80339FD4; - + static void set_swimming_at_surface_particles(struct MarioState *m, u32 particleFlag) { s16 atSurface = m->pos[1] >= m->waterLevel - 130; diff --git a/src/decomp/global_state.c b/src/decomp/global_state.c index 0e74043..3e35589 100644 --- a/src/decomp/global_state.c +++ b/src/decomp/global_state.c @@ -9,6 +9,7 @@ struct GlobalState *global_state_create(void) { struct GlobalState *state = malloc( sizeof( struct GlobalState )); memset( state, 0, sizeof( struct GlobalState )); + state->msSwimStrength = MIN_SWIM_STRENGTH; return state; } diff --git a/src/decomp/global_state.h b/src/decomp/global_state.h index f5fbba0..84d1ee8 100644 --- a/src/decomp/global_state.h +++ b/src/decomp/global_state.h @@ -5,8 +5,6 @@ struct GlobalState { -// Not yet implemented: - // interaction.c u8 msDelayInvincTimer; s16 msInvulnerable; @@ -27,8 +25,6 @@ struct GlobalState // rendering_graph_node.c u16 mgAreaUpdateCounter; -// Implemented and in use: - // platform_displacement.c void *mgMarioPlatform; @@ -50,6 +46,9 @@ struct GlobalState struct MarioState mgMarioStateVal; }; +// From mario_actions_submerged.c, needed to initialize global state +#define MIN_SWIM_STRENGTH 160 + extern struct GlobalState *g_state; extern struct GlobalState *global_state_create(void);