From 868dd8f97b9e4f66d508aaccc021ed6db6a660db Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Tue, 28 Sep 2021 19:08:34 -0700 Subject: [PATCH] Some small fixes + cleanup --- data/behavior_data.c | 2 +- src/audio/external.c | 8 ++--- src/audio/heap.c | 2 +- src/audio/internal.h | 12 ------- src/audio/port_sh.c | 5 ++- src/engine/surface_collision.c | 4 +-- src/game/behaviors/dorrie.inc.c | 7 ++-- src/game/behaviors/fish.inc.c | 26 +++------------ src/game/behaviors/sliding_platform_2.inc.c | 4 +-- src/game/game_init.c | 5 +-- src/game/interaction.c | 4 +-- src/game/level_update.c | 35 ++++++++++---------- src/game/mario.c | 6 ++-- src/game/mario_actions_airborne.c | 7 ++-- src/game/mario_actions_cutscene.c | 4 +-- src/game/mario_actions_submerged.c | 6 ++-- src/game/obj_behaviors_2.c | 5 +-- src/game/save_file.c | 36 +++++++++------------ src/goddard/draw_objects.c | 3 -- src/goddard/joints.c | 1 - src/goddard/particles.c | 1 - src/goddard/renderer.c | 5 --- 22 files changed, 64 insertions(+), 124 deletions(-) diff --git a/data/behavior_data.c b/data/behavior_data.c index ebbe6f66..fc7fc59e 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -3198,7 +3198,7 @@ const BehaviorScript bhvSmallWhomp[] = { BEGIN(OBJ_LIST_SURFACE), SET_INT(oNumLootCoins, 5), // Whomp - common: - OR_INT(oFlags, (OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)), + OR_LONG(oFlags, (OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE | OBJ_FLAG_UCODE_LARGE)), LOAD_ANIMATIONS(oAnimations, whomp_seg6_anims_06020A04), LOAD_COLLISION_DATA(whomp_seg6_collision_06020A0C), ANIMATE(0), diff --git a/src/audio/external.c b/src/audio/external.c index 7fd7f231..efd5b9bb 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -228,8 +228,8 @@ struct MusicDynamic sMusicDynamics[8] = { { 0x0e43, 127, 200, 0x0000, 0, 200 }, // SEQ_LEVEL_WATER { 0x02ff, 127, 100, 0x0100, 0, 100 }, // SEQ_LEVEL_UNDERGROUND { 0x03f7, 127, 100, 0x0008, 0, 100 }, // SEQ_LEVEL_UNDERGROUND - { 0x0070, 127, 10, 0x0000, 0, 100 }, // SEQ_LEVEL_SPOOKY - { 0x0000, 127, 100, 0x0070, 0, 10 }, // SEQ_LEVEL_SPOOKY + { 0x0070, 127, 10, 0x0000, 0, 100 }, // SEQ_LEVEL_SPOOKY + { 0x0000, 127, 100, 0x0070, 0, 10 }, // SEQ_LEVEL_SPOOKY { 0xffff, 127, 100, 0x0000, 0, 100 }, // any (unused) }; @@ -256,11 +256,7 @@ u16 sLevelAcousticReaches[LEVEL_COUNT] = { #define AUDIO_MAX_DISTANCE US_FLOAT(22000.0) -#ifdef VERSION_JP -#define LOW_VOLUME_REVERB 48.0 -#else #define LOW_VOLUME_REVERB 40.0f -#endif #ifdef VERSION_JP #define VOLUME_RANGE_UNK1 0.8f diff --git a/src/audio/heap.c b/src/audio/heap.c index 33c848e5..9562bf26 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -1742,7 +1742,7 @@ void func_sh_802f23ec(void) { s32 drumId; struct Drum *drum; struct Instrument *inst; - struct UnkEntry *entry; //! @bug: not initialized but nevertheless used + struct UnkEntry *entry = NULL; //! @bug: not initialized but nevertheless used seqCount = gAlCtlHeader->seqCount; for (idx = 0; idx < seqCount; idx++) { diff --git a/src/audio/internal.h b/src/audio/internal.h index fb38a43e..3bc42e0f 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -46,27 +46,15 @@ #define CODEC_S8 1 #define CODEC_SKIP 2 -#ifdef VERSION_JP -#define TEMPO_SCALE 1 -#else #define TEMPO_SCALE TATUMS_PER_BEAT -#endif // TODO: US_FLOAT should probably be renamed to JP_DOUBLE since eu seems to use floats too -#ifdef VERSION_JP -#define US_FLOAT(x) x -#else #define US_FLOAT(x) x ## f -#endif // Convert u8 or u16 to f32. On JP, this uses a u32->f32 conversion, // resulting in more bloated codegen, while on US it goes through s32. // Since u8 and u16 fit losslessly in both, behavior is the same. -#ifdef VERSION_JP -#define FLOAT_CAST(x) (f32) (x) -#else #define FLOAT_CAST(x) (f32) (s32) (x) -#endif #if defined(ISVPRINT) || defined(UNF) #define stubbed_printf osSyncPrintf diff --git a/src/audio/port_sh.c b/src/audio/port_sh.c index 899cbb38..31e9d936 100644 --- a/src/audio/port_sh.c +++ b/src/audio/port_sh.c @@ -398,9 +398,8 @@ void func_802ad7ec(u32 arg0) { } break; case 5: - //! @bug u8 s8 comparison (but harmless) - if (chan->reverbVol != cmd->u2.as_s8) { - chan->reverbVol = cmd->u2.as_s8; + if (chan->reverbVol != cmd->u2.as_u8) { + chan->reverbVol = cmd->u2.as_u8; } break; case 6: diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 2ba89e53..11b474db 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -561,7 +561,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { struct Surface *floor, *dynamicFloor; struct SurfaceNode *surfaceList; - f32 height = FLOOR_LOWER_LIMIT; + f32 height = FLOOR_LOWER_LIMIT; f32 dynamicHeight = FLOOR_LOWER_LIMIT; //! (Parallel Universes) Because position is casted to an s16, reaching higher @@ -575,7 +575,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { if (is_outside_level_bounds(x, z)) { #if PUPPYPRINT_DEBUG - collisionTime[perfIteration] += osGetTime()-first; + collisionTime[perfIteration] += osGetTime() - first; #endif return height; } diff --git a/src/game/behaviors/dorrie.inc.c b/src/game/behaviors/dorrie.inc.c index adc6b669..ab0e4206 100644 --- a/src/game/behaviors/dorrie.inc.c +++ b/src/game/behaviors/dorrie.inc.c @@ -104,15 +104,14 @@ void bhv_dorrie_update(void) { if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { o->oDorrieForwardDistToMario = o->oDistanceToMario * coss(o->oAngleToMario - o->oMoveAngleYaw); - obj_perform_position_op(0); + obj_perform_position_op(POS_OP_SAVE_POSITION); cur_obj_move_using_fvel_and_gravity(); o->oDorrieAngleToHome = cur_obj_angle_to_home(); o->oDorrieDistToHome = cur_obj_lateral_dist_to_home(); // Shift dorrie's bounds to account for her neck - boundsShift = - 440.0f * coss(o->oDorrieNeckAngle) * coss(o->oMoveAngleYaw - o->oDorrieAngleToHome); + boundsShift = 440.0f * coss(o->oDorrieNeckAngle) * coss(o->oMoveAngleYaw - o->oDorrieAngleToHome); if (clamp_f32(&o->oDorrieDistToHome, 1650.0f + boundsShift, 2300.0f + boundsShift)) { o->oPosX = o->oHomeX - o->oDorrieDistToHome * sins(o->oDorrieAngleToHome); @@ -154,6 +153,6 @@ void bhv_dorrie_update(void) { break; } - obj_perform_position_op(1); + obj_perform_position_op(POS_OP_COMPUTE_VELOCITY); } } diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index bad68ecf..f72291d7 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -16,29 +16,13 @@ static void fish_spawner_act_spawn(void) { struct Object *fishObject; switch (o->oBehParams2ndByte) { - - // Cases need to be on one line to match with and without optimizations. - case FISH_SPAWNER_BP_MANY_BLUE: - model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; - break; - - case FISH_SPAWNER_BP_FEW_BLUE: - model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; - break; - - case FISH_SPAWNER_BP_MANY_CYAN: - model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; - break; - - case FISH_SPAWNER_BP_FEW_CYAN: - model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; - break; - - default: - return; + case FISH_SPAWNER_BP_MANY_BLUE: model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; + case FISH_SPAWNER_BP_FEW_BLUE: model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; + case FISH_SPAWNER_BP_MANY_CYAN: model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; break; + case FISH_SPAWNER_BP_FEW_CYAN: model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; break; + default: return; } - // Spawn and animate the schoolQuantity of fish if Mario enters render distance // or the stage is Secret Aquarium. // Fish moves randomly within a range of 700.0f. diff --git a/src/game/behaviors/sliding_platform_2.inc.c b/src/game/behaviors/sliding_platform_2.inc.c index 55946e7d..ede3ea31 100644 --- a/src/game/behaviors/sliding_platform_2.inc.c +++ b/src/game/behaviors/sliding_platform_2.inc.c @@ -42,7 +42,7 @@ void bhv_sliding_plat_2_loop(void) { } } - obj_perform_position_op(0); + obj_perform_position_op(POS_OP_SAVE_POSITION); if (o->oBackAndForthPlatformDirection != 0.0f) { o->oPosY = o->oHomeY + o->oBackAndForthPlatformDistance * o->oBackAndForthPlatformDirection; @@ -50,5 +50,5 @@ void bhv_sliding_plat_2_loop(void) { obj_set_dist_from_home(o->oBackAndForthPlatformDistance); } - obj_perform_position_op(1); + obj_perform_position_op(POS_OP_COMPUTE_VELOCITY); } diff --git a/src/game/game_init.c b/src/game/game_init.c index 689aace3..344c2e74 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -347,8 +347,9 @@ void draw_reset_bars(void) { fbPtr += gNmiResetBarsTimer++ * (SCREEN_WIDTH / 4); for (width = 0; width < ((SCREEN_HEIGHT / 16) + 1); width++) { - // Loop must be one line to match on -O2 - for (height = 0; height < (SCREEN_WIDTH / 4); height++) *fbPtr++ = 0; + for (height = 0; height < (SCREEN_WIDTH / 4); height++) { + *fbPtr++ = 0; + } fbPtr += ((SCREEN_WIDTH / 4) * 14); } } diff --git a/src/game/interaction.c b/src/game/interaction.c index 902ef299..78f9c941 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1445,9 +1445,7 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O play_shell_music(); mario_drop_held_object(m); - //! Puts Mario in ground action even when in air, making it easy to - // escape air actions into crouch slide (shell cancel) - return set_mario_action(m, ACT_RIDING_SHELL_GROUND, 0); + return set_mario_action(m, ((m->pos[0] > m->floorHeight) ? ACT_RIDING_SHELL_FALL : ACT_RIDING_SHELL_GROUND), 0); } push_mario_out_of_object(m, obj, 2.0f); diff --git a/src/game/level_update.c b/src/game/level_update.c index 3036436c..07a81885 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -715,11 +715,12 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { switch (warpOp) { case WARP_OP_DEMO_NEXT: - case WARP_OP_DEMO_END: sDelayedWarpTimer = 20; // Must be one line to match on -O2 + case WARP_OP_DEMO_END: + sDelayedWarpTimer = 20; sSourceWarpNodeId = WARP_NODE_F0; gSavedCourseNum = COURSE_NONE; fadeMusic = FALSE; - play_transition(WARP_TRANSITION_FADE_INTO_STAR, 0x14, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_STAR, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_CREDITS_END: @@ -727,14 +728,14 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { sSourceWarpNodeId = WARP_NODE_F0; fadeMusic = FALSE; gSavedCourseNum = COURSE_NONE; - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x3C, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_STAR_EXIT: sDelayedWarpTimer = 32; sSourceWarpNodeId = WARP_NODE_F0; gSavedCourseNum = COURSE_NONE; - play_transition(WARP_TRANSITION_FADE_INTO_MARIO, 0x20, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_MARIO, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_DEATH: @@ -745,7 +746,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { #endif sDelayedWarpTimer = 48; sSourceWarpNodeId = WARP_NODE_DEATH; - play_transition(WARP_TRANSITION_FADE_INTO_BOWSER, 0x30, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_BOWSER, sDelayedWarpTimer, 0x00, 0x00, 0x00); play_sound(SOUND_MENU_BOWSER_LAUGH, gGlobalSoundSource); break; @@ -764,13 +765,13 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { } sDelayedWarpTimer = 20; - play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_LOOK_UP: // enter totwc sDelayedWarpTimer = 30; sSourceWarpNodeId = WARP_NODE_LOOK_UP; - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0xFF, 0xFF, 0xFF); #ifndef VERSION_JP play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); #endif @@ -779,14 +780,14 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { case WARP_OP_SPIN_SHRINK: // bbh enter sDelayedWarpTimer = 30; sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16; - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0xFF, 0xFF, 0xFF); break; case WARP_OP_TELEPORT: sDelayedWarpTimer = 20; sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16; fadeMusic = !music_unchanged_through_warp(sSourceWarpNodeId); - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x14, 0xFF, 0xFF, 0xFF); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0xFF, 0xFF, 0xFF); break; case WARP_OP_WARP_DOOR: @@ -794,28 +795,28 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { sDelayedWarpArg = m->actionArg; sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16; fadeMusic = !music_unchanged_through_warp(sSourceWarpNodeId); - play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, 0x14, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_CIRCLE, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_WARP_OBJECT: sDelayedWarpTimer = 20; sSourceWarpNodeId = (m->usedObj->oBehParams & 0x00FF0000) >> 16; fadeMusic = !music_unchanged_through_warp(sSourceWarpNodeId); - play_transition(WARP_TRANSITION_FADE_INTO_STAR, 0x14, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_STAR, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_CREDITS_START: sDelayedWarpTimer = 30; - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0x00, 0x00, 0x00); break; case WARP_OP_CREDITS_NEXT: if (gCurrCreditsEntry == &sCreditsSequence[0]) { sDelayedWarpTimer = 60; - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x3C, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0x00, 0x00, 0x00); } else { sDelayedWarpTimer = 20; - play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x14, 0x00, 0x00, 0x00); + play_transition(WARP_TRANSITION_FADE_INTO_COLOR, sDelayedWarpTimer, 0x00, 0x00, 0x00); } fadeMusic = FALSE; break; @@ -856,8 +857,7 @@ void initiate_delayed_warp(void) { case WARP_OP_CREDITS_END: warp_special(WARP_SPECIAL_ENDING); - sound_banks_enable(SEQ_PLAYER_SFX, - SOUND_BANKS_ALL & ~SOUND_BANKS_DISABLED_AFTER_CREDITS); + sound_banks_enable(SEQ_PLAYER_SFX, SOUND_BANKS_ALL & ~SOUND_BANKS_DISABLED_AFTER_CREDITS); break; case WARP_OP_DEMO_NEXT: @@ -881,8 +881,7 @@ void initiate_delayed_warp(void) { destWarpNode = WARP_NODE_CREDITS_NEXT; } - initiate_warp(gCurrCreditsEntry->levelNum, gCurrCreditsEntry->areaIndex, - destWarpNode, 0); + initiate_warp(gCurrCreditsEntry->levelNum, gCurrCreditsEntry->areaIndex, destWarpNode, WARP_FLAGS_NONE); break; default: diff --git a/src/game/mario.c b/src/game/mario.c index 11be2998..2afe2f0a 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -692,10 +692,8 @@ void update_mario_sound_and_camera(struct MarioState *m) { raise_background_noise(2); } - if (!(action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER))) { - if (camPreset == CAMERA_MODE_BEHIND_MARIO || camPreset == CAMERA_MODE_WATER_SURFACE) { - set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - } + if (!(action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) && (camPreset == CAMERA_MODE_BEHIND_MARIO || camPreset == CAMERA_MODE_WATER_SURFACE)) { + set_camera_mode(m->area->camera, m->area->camera->defMode, 1); } } diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 9f79162e..2ee09de5 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -617,10 +617,9 @@ s32 act_side_flip(struct MarioState *m) { m->marioObj->header.gfx.angle[1] += 0x8000; } - // This must be one line to match on -O2 - // clang-format off - if (m->marioObj->header.gfx.animInfo.animFrame == 6) play_sound(SOUND_ACTION_SIDE_FLIP_UNK, m->marioObj->header.gfx.cameraToObject); - // clang-format on + if (m->marioObj->header.gfx.animInfo.animFrame == 6) { + play_sound(SOUND_ACTION_SIDE_FLIP_UNK, m->marioObj->header.gfx.cameraToObject); + } return FALSE; } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 2ddb17cb..8a5ff6c5 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1525,9 +1525,7 @@ s32 act_squished(struct MarioState *m) { play_sound_if_no_flag(m, SOUND_MARIO_ATTACKED, MARIO_MARIO_SOUND_PLAYED); } - // Both of the 1.8's are really floats, but one of them has to - // be written as a double for this to match on -O2. - vec3f_set(m->marioObj->header.gfx.scale, 1.8, 0.05f, 1.8f); + vec3f_set(m->marioObj->header.gfx.scale, 1.8f, 0.05f, 1.8f); #if ENABLE_RUMBLE queue_rumble_data(10, 80); #endif diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 85bfadc1..583de0b3 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -482,9 +482,9 @@ static void common_swimming_step(struct MarioState *m, s16 swimStrength) { static void play_swimming_noise(struct MarioState *m) { s16 animFrame = m->marioObj->header.gfx.animInfo.animFrame; - - // This must be one line to match on -O2 - if (animFrame == 0 || animFrame == 12) play_sound(SOUND_ACTION_UNKNOWN434, m->marioObj->header.gfx.cameraToObject); + if (animFrame == 0 || animFrame == 12) { + play_sound(SOUND_ACTION_UNKNOWN434, m->marioObj->header.gfx.cameraToObject); + } } static s32 check_water_jump(struct MarioState *m) { diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index 2be8540f..dd1d1a7b 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -89,8 +89,7 @@ static s16 obj_get_pitch_from_vel(void) { * move again. */ static s32 obj_update_race_proposition_dialog(s16 dialogID) { - s32 dialogResponse = - cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, + s32 dialogResponse = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, (DIALOG_FLAG_TURN_TO_MARIO | DIALOG_FLAG_TIME_STOP_ENABLED), CUTSCENE_RACE_DIALOG, dialogID); if (dialogResponse == DIALOG_RESPONSE_NO) { @@ -110,8 +109,6 @@ static s32 obj_is_near_to_and_facing_mario(f32 maxDist, s16 maxAngleDiff) { return (o->oDistanceToMario < maxDist && abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) < maxAngleDiff); } -//! Although having no return value, this function -//! must be u32 to match other functions on -O2. static void obj_perform_position_op(s32 op) { switch (op) { case POS_OP_SAVE_POSITION: vec3_copy(sObjSavedPos, &o->oPosVec); break; diff --git a/src/game/save_file.c b/src/game/save_file.c index d1647256..b36b48f2 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -33,7 +33,7 @@ s8 gSaveFileModified; u8 gLastCompletedCourseNum = COURSE_NONE; u8 gLastCompletedStarNum = 0; -s8 sUnusedGotGlobalCoinHiScore = 0; +s8 sUnusedGotGlobalCoinHiScore = FALSE; u8 gGotFileCoinHiScore = FALSE; u8 gCurrCourseStarFlags = 0; @@ -457,17 +457,17 @@ void save_file_collect_star_or_key(s16 coinScore, s16 starIndex) { s32 starFlag = 1 << starIndex; #endif - gLastCompletedCourseNum = courseIndex + 1; - gLastCompletedStarNum = starIndex + 1; - sUnusedGotGlobalCoinHiScore = 0; - gGotFileCoinHiScore = FALSE; + gLastCompletedCourseNum = courseIndex + 1; + gLastCompletedStarNum = starIndex + 1; + sUnusedGotGlobalCoinHiScore = FALSE; + gGotFileCoinHiScore = FALSE; if (courseIndex >= 0 && courseIndex < COURSE_STAGES_COUNT) { //! Compares the coin score as a 16 bit value, but only writes the 8 bit // truncation. This can allow a high score to decrease. if (coinScore > ((u16) save_file_get_max_coin_score(courseIndex) & 0xFFFF)) { - sUnusedGotGlobalCoinHiScore = 1; + sUnusedGotGlobalCoinHiScore = TRUE; } if (coinScore > save_file_get_course_coin_score(fileIndex, courseIndex)) { @@ -475,7 +475,7 @@ void save_file_collect_star_or_key(s16 coinScore, s16 starIndex) { touch_coin_score_age(fileIndex, courseIndex); gGotFileCoinHiScore = TRUE; - gSaveFileModified = TRUE; + gSaveFileModified = TRUE; } } @@ -521,7 +521,7 @@ s32 save_file_exists(s32 fileIndex) { u32 save_file_get_max_coin_score(s32 courseIndex) { s32 fileIndex; s32 maxCoinScore = -1; - s32 maxScoreAge = -1; + s32 maxScoreAge = -1; s32 maxScoreFileNum = 0; for (fileIndex = 0; fileIndex < NUM_SAVE_FILES; fileIndex++) { @@ -683,15 +683,9 @@ u16 save_file_get_sound_mode(void) { void save_file_move_cap_to_default_location(void) { if (save_file_get_flags() & SAVE_FLAG_CAP_ON_GROUND) { switch (gSaveBuffer.files[gCurrSaveFileNum - 1][0].capLevel) { - case LEVEL_SSL: - save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO); - break; - case LEVEL_SL: - save_file_set_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD); - break; - case LEVEL_TTM: - save_file_set_flags(SAVE_FLAG_CAP_ON_UKIKI); - break; + case LEVEL_SSL: save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO ); break; + case LEVEL_SL: save_file_set_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD); break; + case LEVEL_TTM: save_file_set_flags(SAVE_FLAG_CAP_ON_UKIKI ); break; } save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND); } @@ -721,11 +715,11 @@ void disable_warp_checkpoint(void) { void check_if_should_set_warp_checkpoint(struct WarpNode *warpNode) { if (warpNode->destLevel & 0x80) { // Overwrite the warp checkpoint variables. - gWarpCheckpoint.actNum = gCurrActNum; + gWarpCheckpoint.actNum = gCurrActNum; gWarpCheckpoint.courseNum = gCurrCourseNum; - gWarpCheckpoint.levelID = warpNode->destLevel & 0x7F; - gWarpCheckpoint.areaNum = warpNode->destArea; - gWarpCheckpoint.warpNode = warpNode->destNode; + gWarpCheckpoint.levelID = warpNode->destLevel & 0x7F; + gWarpCheckpoint.areaNum = warpNode->destArea; + gWarpCheckpoint.warpNode = warpNode->destNode; } } diff --git a/src/goddard/draw_objects.c b/src/goddard/draw_objects.c index 95c19812..f9137093 100644 --- a/src/goddard/draw_objects.c +++ b/src/goddard/draw_objects.c @@ -506,7 +506,6 @@ void draw_camera(struct ObjCamera *cam) { sp44.x += cam->lookAt.x; sp44.y += cam->lookAt.y; sp44.z += cam->lookAt.z; - ; // needed to match } else { sp44.x = cam->lookAt.x; sp44.y = cam->lookAt.y; @@ -692,7 +691,6 @@ void draw_particle(struct GdObj *obj) { sLightColours.r = (white->r - black->r) * brightness + black->r; sLightColours.g = (white->g - black->g) * brightness + black->g; sLightColours.b = (white->b - black->b) * brightness + black->b; - ; // needed to match } else { sLightColours.r = 0.0f; sLightColours.g = 0.0f; @@ -765,7 +763,6 @@ void draw_plane(struct GdObj *obj) { if (obj->drawFlags & OBJ_HIGHLIGHTED) { obj->drawFlags &= ~OBJ_HIGHLIGHTED; - ; // needed to match; presumably setting up the color to draw the plane with } else { sUseSelectedColor = FALSE; } diff --git a/src/goddard/joints.c b/src/goddard/joints.c index df0950b6..e6d4d793 100644 --- a/src/goddard/joints.c +++ b/src/goddard/joints.c @@ -61,7 +61,6 @@ void grabbable_joint_update_func(struct ObjJoint *self) { self->velocity.z = offset.z * -0.25f; self->flags |= 0x2000; - ; // needed to match } else { if (gGdCtrl.trgR == FALSE) // R trigger is released { diff --git a/src/goddard/particles.c b/src/goddard/particles.c index d9daac30..9d7d22b7 100644 --- a/src/goddard/particles.c +++ b/src/goddard/particles.c @@ -339,7 +339,6 @@ void move_particle(struct ObjParticle *ptc) { if (sp4C->unk18C->pickedObj != NULL) { set_cur_dynobj(sp4C->unk18C->pickedObj); ptc->flags |= 0x20; - ; // needed to match } else { ptc->flags &= ~0x10; ptc->flags &= ~0x20; diff --git a/src/goddard/renderer.c b/src/goddard/renderer.c index e89ebddb..0de64537 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -2,10 +2,6 @@ #include #include -#if defined(VERSION_JP) || defined(VERSION_US) -#include "prevent_bss_reordering.h" -#endif - #include "debug_utils.h" #include "draw_objects.h" #include "dynlist_proc.h" @@ -858,7 +854,6 @@ void gd_printf(const char *format, ...) { csr++; *csr = '\0'; break; - break; // needed to match case 'f': val.f = (f32) va_arg(args, double); csr = sprint_val_withspecifiers(csr, val, spec);