From ea0fd25a73226d930687fdf2b106937dcec5d41d Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Mon, 27 Sep 2021 13:35:55 -0700 Subject: [PATCH] Some more cleanup --- enhancements/crash.patch | 1 - enhancements/mem_error_screen.patch | 2 +- enhancements/reonucam3.patch | 4 +- src/audio/effects.c | 2 +- src/audio/external.c | 4 - src/audio/load_sh.c | 4 +- src/engine/surface_load.c | 10 +- src/game/behaviors/activated_bf_plat.inc.c | 2 +- .../behaviors/animated_floor_switch.inc.c | 2 +- src/game/behaviors/bubba.inc.c | 2 +- src/game/behaviors/chain_chomp.inc.c | 4 +- src/game/behaviors/clam.inc.c | 2 +- src/game/behaviors/coffin.inc.c | 2 +- src/game/behaviors/end_birds_1.inc.c | 2 +- src/game/behaviors/end_birds_2.inc.c | 2 +- src/game/behaviors/enemy_lakitu.inc.c | 8 +- src/game/behaviors/eyerok.inc.c | 18 +- src/game/behaviors/fire_piranha_plant.inc.c | 6 +- src/game/behaviors/fly_guy.inc.c | 4 +- .../behaviors/flying_bookend_switch.inc.c | 2 +- src/game/behaviors/goomba.inc.c | 4 +- src/game/behaviors/haunted_chair.inc.c | 2 +- src/game/behaviors/intro_lakitu.inc.c | 17 +- src/game/behaviors/intro_peach.inc.c | 6 +- src/game/behaviors/klepto.inc.c | 4 +- src/game/behaviors/koopa.inc.c | 19 +- src/game/behaviors/monty_mole.inc.c | 2 +- src/game/behaviors/mr_blizzard.inc.c | 2 +- src/game/behaviors/mr_i.inc.c | 2 +- src/game/behaviors/pokey.inc.c | 22 +- src/game/behaviors/recovery_heart.inc.c | 2 +- src/game/behaviors/shock_wave.inc.c | 2 +- src/game/behaviors/skeeter.inc.c | 4 +- src/game/behaviors/snufit.inc.c | 2 +- src/game/behaviors/spiny.inc.c | 6 +- src/game/behaviors/swoop.inc.c | 2 +- src/game/behaviors/thi_top.inc.c | 2 +- src/game/behaviors/ttc_2d_rotator.inc.c | 2 +- src/game/behaviors/ttc_moving_bar.inc.c | 4 +- src/game/behaviors/ttc_pendulum.inc.c | 2 +- src/game/behaviors/water_bomb.inc.c | 8 +- src/game/behaviors/water_bomb_cannon.inc.c | 4 +- src/game/behaviors/wiggler.inc.c | 4 +- src/game/camera.c | 26 +- src/game/debug.c | 18 +- src/game/debug_course.c | 7 - src/game/debug_course.h | 6 - src/game/envfx_bubbles.c | 4 +- src/game/interaction.c | 38 +- src/game/level_update.c | 12 +- src/game/mario.c | 15 +- src/game/mario_actions_airborne.c | 2 +- src/game/mario_misc.c | 6 +- src/game/obj_behaviors_2.c | 7 +- src/game/object_list_processor.c | 6 +- src/game/puppycam2.c | 1379 +++++++---------- src/game/spawn_object.c | 3 +- src/goddard/renderer.c | 2 +- src/goddard/shape_helper.c | 2 +- src/menu/file_select.c | 2 +- 60 files changed, 731 insertions(+), 1011 deletions(-) delete mode 100644 src/game/debug_course.c delete mode 100644 src/game/debug_course.h diff --git a/enhancements/crash.patch b/enhancements/crash.patch index e3935d6b..7aa90c0b 100644 --- a/enhancements/crash.patch +++ b/enhancements/crash.patch @@ -182,7 +182,6 @@ index 7d9b5b4a..c7bb81b9 100755 BUILD_DIR/asm/decompress.o(.text); + BUILD_DIR/asm/crash.o(.text); BUILD_DIR/src/game/camera.o(.text); - BUILD_DIR/src/game/debug_course.o(.text); BUILD_DIR/src/game/object_list_processor.o(.text); diff --git a/src/game/crash.c b/src/game/crash.c new file mode 100644 diff --git a/enhancements/mem_error_screen.patch b/enhancements/mem_error_screen.patch index c6c76eef..d2a21024 100644 --- a/enhancements/mem_error_screen.patch +++ b/enhancements/mem_error_screen.patch @@ -258,7 +258,7 @@ index 00000000..f432927c + dl_ia_text_end); // Reset back to default render settings. + gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); + } else { -+ gDelayForErrorMessage += 1; ++ gDelayForErrorMessage++; + } + } + diff --git a/enhancements/reonucam3.patch b/enhancements/reonucam3.patch index efc6aec6..739c253d 100644 --- a/enhancements/reonucam3.patch +++ b/enhancements/reonucam3.patch @@ -394,14 +394,14 @@ index 6cbfd8e1..01dd4de8 100644 + + if (gPlayer1Controller->buttonPressed & R_JPAD) { + if (gCameraSpeed < 4) { -+ gCameraSpeed += 1; ++ gCameraSpeed++; + } else { + gCameraSpeed = 0; + } + save_file_set_camera_speed(gCameraSpeed); + } else if (gPlayer1Controller->buttonPressed & L_JPAD) { + if (gCameraSpeed > 0) { -+ gCameraSpeed -= 1; ++ gCameraSpeed--; + } else { + gCameraSpeed = 4; + } diff --git a/src/audio/effects.c b/src/audio/effects.c index f18af4af..5bfc7c29 100644 --- a/src/audio/effects.c +++ b/src/audio/effects.c @@ -511,7 +511,7 @@ s32 adsr_update(struct AdsrState *adsr) { } case ADSR_STATE_SUSTAIN: - adsr->delay -= 1; + adsr->delay--; if (adsr->delay == 0) { adsr->state = ADSR_STATE_RELEASE; } diff --git a/src/audio/external.c b/src/audio/external.c index ecc12247..7fd7f231 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -1281,9 +1281,6 @@ static u8 get_sound_reverb(UNUSED u8 bank, UNUSED u8 soundIndex, u8 channelIndex return reverb; } -static void noop_8031EEC8(void) { -} - /** * Called from the game loop thread to inform the audio thread that a new game * frame has started. @@ -1295,7 +1292,6 @@ void audio_signal_game_loop_tick(void) { #if defined(VERSION_EU) || defined(VERSION_SH) maybe_tick_game_sound(); #endif - noop_8031EEC8(); } /** diff --git a/src/audio/load_sh.c b/src/audio/load_sh.c index 5a0e293a..b5577c7d 100644 --- a/src/audio/load_sh.c +++ b/src/audio/load_sh.c @@ -1488,7 +1488,7 @@ void func_sh_802f5310(s32 bankId, struct AudioBank *mem, struct PatchStruct *pat if (D_SH_8034F68C != 0 && sp4C == 0) { temp_s0 = D_SH_8034EC88[D_SH_8034F68C - 1].sample; temp = (temp_s0->size >> 12); - temp += 1; + temp++; count = (uintptr_t) temp_s0->sampleAddr; func_sh_802f4cb4( count, @@ -1540,7 +1540,7 @@ next: sampleAddr = sample->sampleAddr; size = sample->size; unk = size >> 0xC; - unk += 1; + unk++; added = ((sampleAddr + size) + sample->medium); if (added != D_SH_8034EC88[D_SH_8034F68C - 1].endAndMediumIdentification) { D_SH_8034EC88[D_SH_8034F68C - 1].isFree = TRUE; diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 9705ac18..83fed388 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -173,7 +173,7 @@ static s32 lower_cell_index(s32 coord) { //! Some wall checks are larger than the buffer, meaning wall checks can // miss walls that are near a cell border. if (coord % CELL_SIZE < 50) { - index -= 1; + index--; } if (index < 0) { @@ -205,7 +205,7 @@ static s32 upper_cell_index(s32 coord) { //! Some wall checks are larger than the buffer, meaning wall checks can // miss walls that are near a cell border. if (coord % CELL_SIZE > CELL_SIZE - 50) { - index += 1; + index++; } if (index > NUM_CELLS_INDEX) { @@ -372,12 +372,12 @@ static void load_static_surfaces(TerrainData **data, TerrainData *vertexData, s3 s32 flags = surf_has_no_cam_collision(surfaceType); numSurfaces = *(*data); - *data += 1; + (*data)++; for (i = 0; i < numSurfaces; i++) { if (*surfaceRooms != NULL) { room = *(*surfaceRooms); - *surfaceRooms += 1; + (*surfaceRooms)++; } surface = read_surface_data(vertexData, data); @@ -404,7 +404,7 @@ static void load_static_surfaces(TerrainData **data, TerrainData *vertexData, s3 #else *data += 3; if (hasForce) { - *data += 1; + (*data)++; } #endif } diff --git a/src/game/behaviors/activated_bf_plat.inc.c b/src/game/behaviors/activated_bf_plat.inc.c index e58205fd..5ed32c98 100644 --- a/src/game/behaviors/activated_bf_plat.inc.c +++ b/src/game/behaviors/activated_bf_plat.inc.c @@ -76,7 +76,7 @@ void bhv_activated_back_and_forth_platform_update(void) { // and one more frame of "lag" after it finally reaches 0 here, // Mario actually has to wait 22 frames before the platform starts moving. if (o->oActivatedBackAndForthPlatformCountdown != 0) { - o->oActivatedBackAndForthPlatformCountdown -= 1; + o->oActivatedBackAndForthPlatformCountdown--; } else { // After the wait period is over, we start moving, by adding the velocity // to the positional offset. diff --git a/src/game/behaviors/animated_floor_switch.inc.c b/src/game/behaviors/animated_floor_switch.inc.c index 7cbe323c..a8577d17 100644 --- a/src/game/behaviors/animated_floor_switch.inc.c +++ b/src/game/behaviors/animated_floor_switch.inc.c @@ -63,7 +63,7 @@ void bhv_animates_on_floor_switch_press_loop(void) { } if (o->oFloorSwitchPressAnimationDoubleFrame < 9) { - o->oFloorSwitchPressAnimationDoubleFrame += 1; + o->oFloorSwitchPressAnimationDoubleFrame++; } } else if ((o->oFloorSwitchPressAnimationDoubleFrame -= 2) < 0) { o->oFloorSwitchPressAnimationDoubleFrame = 0; diff --git a/src/game/behaviors/bubba.inc.c b/src/game/behaviors/bubba.inc.c index d51a4b40..afd4c46f 100644 --- a/src/game/behaviors/bubba.inc.c +++ b/src/game/behaviors/bubba.inc.c @@ -36,7 +36,7 @@ void bubba_act_0(void) { } else if (o->oTimer > 30 && o->oDistanceToMario < 2000.0f) { o->oAction = 1; } else if (o->oBubbaRandomTimer != 0) { - o->oBubbaRandomTimer -= 1; + o->oBubbaRandomTimer--; } else { o->oBubbaTargetYaw = obj_random_fixed_turn(0x2000); o->oBubbaRandomTimer = random_linear_offset(100, 100); diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index 38e97cbc..a4a70ebb 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -190,7 +190,7 @@ static void chain_chomp_sub_act_turn(void) { o->oChainChompTargetPitch = obj_get_pitch_from_vel(); } } else { - o->oTimer -= 1; + o->oTimer--; } } else { o->oForwardVel = 0.0f; @@ -276,7 +276,7 @@ static void chain_chomp_released_lunge_around(void) { if (o->oChainChompNumLunges == 0) { if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x320)) { if (o->oTimer > 60) { - o->oChainChompNumLunges += 1; + o->oChainChompNumLunges++; // enable wall collision o->oWallHitboxRadius = 200.0f; } diff --git a/src/game/behaviors/clam.inc.c b/src/game/behaviors/clam.inc.c index b9ef5038..8679b4b2 100644 --- a/src/game/behaviors/clam.inc.c +++ b/src/game/behaviors/clam.inc.c @@ -24,7 +24,7 @@ void clam_act_0(void) { cur_obj_play_sound_2(SOUND_GENERAL_CLAM_SHELL2); o->oAction = 1; } else if (o->oClamShakeTimer != 0) { - o->oClamShakeTimer -= 1; + o->oClamShakeTimer--; cur_obj_shake_y(3.0f); } } diff --git a/src/game/behaviors/coffin.inc.c b/src/game/behaviors/coffin.inc.c index 5926bff8..8bc95a1f 100644 --- a/src/game/behaviors/coffin.inc.c +++ b/src/game/behaviors/coffin.inc.c @@ -49,7 +49,7 @@ void bhv_coffin_spawner_loop(void) { } } - o->oAction += 1; + o->oAction++; } } else if (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) { o->oAction = COFFIN_SPAWNER_ACT_COFFINS_UNLOADED; diff --git a/src/game/behaviors/end_birds_1.inc.c b/src/game/behaviors/end_birds_1.inc.c index 38deec59..cb39e98a 100644 --- a/src/game/behaviors/end_birds_1.inc.c +++ b/src/game/behaviors/end_birds_1.inc.c @@ -9,7 +9,7 @@ void bhv_end_birds_1_loop(void) { gCurrentObject->oIntroLakituEndBirds1DestX = -554.f; gCurrentObject->oIntroLakituEndBirds1DestY = 3044.f; gCurrentObject->oIntroLakituEndBirds1DestZ = -1314.f; - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 1; break; case 1: vec3f_set(pos, gCurrentObject->oIntroLakituEndBirds1DestX, gCurrentObject->oIntroLakituEndBirds1DestY, diff --git a/src/game/behaviors/end_birds_2.inc.c b/src/game/behaviors/end_birds_2.inc.c index 44fdd0f2..8f5ef9dd 100644 --- a/src/game/behaviors/end_birds_2.inc.c +++ b/src/game/behaviors/end_birds_2.inc.c @@ -10,7 +10,7 @@ void bhv_end_birds_2_loop(void) { switch (gCurrentObject->oAction) { case 0: cur_obj_scale(0.7f); - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 1; break; case 1: vec3f_get_dist_and_angle(gCamera->pos, gCamera->focus, &dist, &pitch, &yaw); diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index 056c3f13..670697e7 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -77,7 +77,7 @@ static void enemy_lakitu_update_speed_and_angle(void) { // Turn toward mario except right after throwing a spiny if (o->oEnemyLakituFaceForwardCountdown != 0) { - o->oEnemyLakituFaceForwardCountdown -= 1; + o->oEnemyLakituFaceForwardCountdown--; } else { obj_face_yaw_approach(o->oAngleToMario, 0x600); } @@ -96,7 +96,7 @@ static void enemy_lakitu_sub_act_no_spiny(void) { cur_obj_init_animation_with_sound(1); if (o->oEnemyLakituSpinyCooldown != 0) { - o->oEnemyLakituSpinyCooldown -= 1; + o->oEnemyLakituSpinyCooldown--; } else if (o->oEnemyLakituNumSpinies < 3 && o->oDistanceToMario < 800.0f && abs_angle_diff(o->oAngleToMario, o->oFaceAngleYaw) < 0x4000) { struct Object *spiny = spawn_object(o, MODEL_SPINY_BALL, bhvSpiny); @@ -105,7 +105,7 @@ static void enemy_lakitu_sub_act_no_spiny(void) { spiny->oAction = SPINY_ACT_HELD_BY_LAKITU; obj_init_animation_with_sound(spiny, spiny_egg_seg5_anims_050157E4, 0); - o->oEnemyLakituNumSpinies += 1; + o->oEnemyLakituNumSpinies++; o->oSubAction = ENEMY_LAKITU_SUB_ACT_HOLD_SPINY; o->oEnemyLakituSpinyCooldown = 30; } @@ -120,7 +120,7 @@ static void enemy_lakitu_sub_act_hold_spiny(void) { cur_obj_init_anim_extend(3); if (o->oEnemyLakituSpinyCooldown != 0) { - o->oEnemyLakituSpinyCooldown -= 1; + o->oEnemyLakituSpinyCooldown--; } // TODO: Check if anything interesting happens if we bypass this with speed else if (o->oDistanceToMario > o->oDrawingDistance - 100.0f diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c index eb7f7c73..33b49610 100644 --- a/src/game/behaviors/eyerok.inc.c +++ b/src/game/behaviors/eyerok.inc.c @@ -44,7 +44,7 @@ static void eyerok_boss_act_wake_up(void) { if (o->oTimer > 5) { if (o->oSubAction == 0) { seq_player_lower_volume(SEQ_PLAYER_LEVEL, 60, 40); - o->oSubAction += 1; + o->oSubAction++; } if (o->oEyerokBossOffsetFromHome == 0.0f && mario_ready_to_speak() != 0) { @@ -79,18 +79,18 @@ static void eyerok_boss_act_fight(void) { o->oEyerokBossAttackCountdown = 1; } } else { - o->oEyerokBossAttackCountdown -= 1; + o->oEyerokBossAttackCountdown--; } if (o->oEyerokBossAttackCountdown != 0 && o->oEyerokBossAttackCountdown != 1) { - o->oEyerokBossAttackPhase += 1; + o->oEyerokBossAttackPhase++; if ((o->oEyerokBossActiveHand = o->oEyerokBossAttackPhase & 0x1) == 0) { o->oEyerokBossActiveHand = -1; } } } } else { - o->oEyerokBossAttackPhase += 1; + o->oEyerokBossAttackPhase++; if (eyerok_check_mario_relative_z(400)) { o->oEyerokBossAttackCountdown = -8; @@ -120,7 +120,7 @@ static void eyerok_boss_act_die(void) { if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_NONE, CUTSCENE_DIALOG, DIALOG_118)) { spawn_default_star(0.0f, -900.0f, -3700.0f); } else { - o->oTimer -= 1; + o->oTimer--; } } else if (o->oTimer > 120) { stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); @@ -156,7 +156,7 @@ static s32 eyerok_hand_check_attacked(void) { o->oAction = EYEROK_HAND_ACT_ATTACKED; o->oVelY = 30.0f; } else { - o->parentObj->oEyerokBossNumHands -= 1; + o->parentObj->oEyerokBossNumHands--; o->oAction = EYEROK_HAND_ACT_DIE; o->oVelY = 50.0f; } @@ -183,7 +183,7 @@ static void eyerok_hand_act_sleep(void) { if (o->parentObj->oAction != EYEROK_BOSS_ACT_SLEEP && ++o->oEyerokHandWakeUpTimer > -3 * o->oBehParams2ndByte) { if (cur_obj_check_if_near_animation_end()) { - o->parentObj->oEyerokBossNumHands += 1; + o->parentObj->oEyerokBossNumHands++; o->oAction = EYEROK_HAND_ACT_IDLE; o->collisionData = segmented_to_virtual(&ssl_seg7_collision_07028274); } else { @@ -268,14 +268,14 @@ static void eyerok_hand_act_show_eye(void) { if (!eyerok_hand_check_attacked()) { if (o->parentObj->oEyerokBossActiveHand == 0) { if (o->oAnimState < 3) { - o->oAnimState += 1; + o->oAnimState++; } else if (cur_obj_check_if_near_animation_end()) { o->oAction = EYEROK_HAND_ACT_CLOSE; } } else { if (o->oEyerokHandEyeShownTimer--) { if (o->oEyerokHandAnimStateIndex != 0) { - o->oEyerokHandAnimStateIndex -= 1; + o->oEyerokHandAnimStateIndex--; } o->oAnimState = sEyerokAnimStatesList[o->oEyerokHandAnimStateIndex]; } else { diff --git a/src/game/behaviors/fire_piranha_plant.inc.c b/src/game/behaviors/fire_piranha_plant.inc.c index 19df9db0..4f9aedcf 100644 --- a/src/game/behaviors/fire_piranha_plant.inc.c +++ b/src/game/behaviors/fire_piranha_plant.inc.c @@ -56,7 +56,7 @@ static void fire_piranha_plant_act_hide(void) { 0.04f * o->oFirePiranhaPlantNeutralScale)) { cur_obj_become_intangible(); if (o->oFirePiranhaPlantActive) { - sNumActiveFirePiranhaPlants -= 1; + sNumActiveFirePiranhaPlants--; o->oFirePiranhaPlantActive = FALSE; if ((u16)(o->oBehParams >> 16) != 0 && o->oHealth == 0) { @@ -72,7 +72,7 @@ static void fire_piranha_plant_act_hide(void) { cur_obj_play_sound_2(SOUND_OBJ_PIRANHA_PLANT_APPEAR); o->oFirePiranhaPlantActive = TRUE; - sNumActiveFirePiranhaPlants += 1; + sNumActiveFirePiranhaPlants++; cur_obj_unhide(); o->oAction = FIRE_PIRANHA_PLANT_ACT_GROW; @@ -127,7 +127,7 @@ void bhv_fire_piranha_plant_update(void) { if (obj_check_attacks(&sFirePiranhaPlantHitbox, o->oAction)) { if (--o->oHealth < 0) { if (o->oFirePiranhaPlantActive) { - sNumActiveFirePiranhaPlants -= 1; + sNumActiveFirePiranhaPlants--; } } else { cur_obj_init_animation_with_sound(2); diff --git a/src/game/behaviors/fly_guy.inc.c b/src/game/behaviors/fly_guy.inc.c index 4ae1f844..c7e24e8a 100644 --- a/src/game/behaviors/fly_guy.inc.c +++ b/src/game/behaviors/fly_guy.inc.c @@ -45,7 +45,7 @@ static void fly_guy_act_idle(void) { o->oAction = FLY_GUY_ACT_APPROACH_MARIO; } else { o->oFlyGuyUnusedJitter = o->oMoveAngleYaw + sFlyGuyJitterAmounts[o->oFlyGuyIdleTimer]; - o->oFlyGuyIdleTimer += 1; + o->oFlyGuyIdleTimer++; } } } @@ -190,7 +190,7 @@ void bhv_fly_guy_update(void) { } // Oscillate up and down - o->oFlyGuyOscTimer += 1; + o->oFlyGuyOscTimer++; o->oPosY += coss(0x400 * o->oFlyGuyOscTimer) * 1.5f; switch (o->oAction) { diff --git a/src/game/behaviors/flying_bookend_switch.inc.c b/src/game/behaviors/flying_bookend_switch.inc.c index 76418346..d401e453 100644 --- a/src/game/behaviors/flying_bookend_switch.inc.c +++ b/src/game/behaviors/flying_bookend_switch.inc.c @@ -270,7 +270,7 @@ void bhv_book_switch_loop(void) { if (o->oAction != 0) { if (o->parentObj->oBookSwitchManagerNumCorrectChoices == o->oBehParams2ndByte) { play_sound(SOUND_GENERAL2_RIGHT_ANSWER, gGlobalSoundSource); - o->parentObj->oBookSwitchManagerNumCorrectChoices += 1; + o->parentObj->oBookSwitchManagerNumCorrectChoices++; } else { rand01 = random_u16() & 0x1; z = gMarioObject->oPosZ + 1.5f * gMarioStates[0].vel[2]; diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c index c1155eca..42583c27 100644 --- a/src/game/behaviors/goomba.inc.c +++ b/src/game/behaviors/goomba.inc.c @@ -95,7 +95,7 @@ void bhv_goomba_triplet_spawner_update(void) { } } - o->oAction += 1; + o->oAction++; } } else if (o->oDistanceToMario > 4000.0f) { // If mario is too far away, enter the unloaded action. The goombas @@ -194,7 +194,7 @@ static void goomba_act_walk(void) { o->oGoombaRelativeSpeed = 4.0f / 3.0f; if (o->oGoombaWalkTimer != 0) { - o->oGoombaWalkTimer -= 1; + o->oGoombaWalkTimer--; } else { if (random_u16() & 3) { o->oGoombaTargetYaw = obj_random_fixed_turn(0x2000); diff --git a/src/game/behaviors/haunted_chair.inc.c b/src/game/behaviors/haunted_chair.inc.c index 4b6a6120..29d8cb47 100644 --- a/src/game/behaviors/haunted_chair.inc.c +++ b/src/game/behaviors/haunted_chair.inc.c @@ -59,7 +59,7 @@ void haunted_chair_act_0(void) { } } else if (o->oHauntedChairSpinTimer != 0) { if (o->oDistanceToMario < 500.0f) { - o->oHauntedChairSpinTimer -= 1; + o->oHauntedChairSpinTimer--; } o->oTimer = 0.0f; } else { diff --git a/src/game/behaviors/intro_lakitu.inc.c b/src/game/behaviors/intro_lakitu.inc.c index 4593f7c5..97428e7c 100644 --- a/src/game/behaviors/intro_lakitu.inc.c +++ b/src/game/behaviors/intro_lakitu.inc.c @@ -45,7 +45,7 @@ s32 intro_lakitu_set_pos_and_focus(struct Object *o, struct CutsceneSplinePoint if ((move_point_along_spline(newFocus, offset, &splineSegment, &(o->oIntroLakituSplineSegmentProgress)) == 1) || (move_point_along_spline(newOffset, focus, &splineSegment, &(o->oIntroLakituSplineSegmentProgress)) == 1)) - splineFinished += 1; + splineFinished++; o->oIntroLakituSplineSegment = splineSegment; intro_lakitu_set_offset_from_camera(o, newOffset); @@ -64,10 +64,11 @@ void bhv_intro_lakitu_loop(void) { gCurrentObject->oIntroLakituSplineSegmentProgress = 0.f; gCurrentObject->oIntroLakituCloud = spawn_object_relative_with_scale(1, 0, 0, 0, 2.f, gCurrentObject, MODEL_MIST, bhvCloud); - if (gCamera->cutscene == CUTSCENE_END_WAVING) + if (gCamera->cutscene == CUTSCENE_END_WAVING) { gCurrentObject->oAction = 100; - else - gCurrentObject->oAction += 1; + } else { + gCurrentObject->oAction = 1; + } break; case 1: @@ -82,7 +83,7 @@ void bhv_intro_lakitu_loop(void) { if (intro_lakitu_set_pos_and_focus(gCurrentObject, gIntroLakituStartToPipeOffsetFromCamera, gIntroLakituStartToPipeFocus) == 1) - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 2; switch (gCurrentObject->oTimer) { #if defined(VERSION_US) || defined(VERSION_SH) @@ -111,7 +112,7 @@ void bhv_intro_lakitu_loop(void) { #else if (gCutsceneTimer > 720) { #endif - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 3; gCurrentObject->oIntroLakituDistToBirdsX = 1400.f; gCurrentObject->oIntroLakituDistToBirdsZ = -4096.f; gCurrentObject->oIntroLakituEndBirds1DestZ = 2048.f; @@ -173,7 +174,7 @@ void bhv_intro_lakitu_loop(void) { gCurrentObject->oMoveAngleYaw = 0x9000; gCurrentObject->oFaceAnglePitch = gCurrentObject->oMoveAnglePitch / 2; gCurrentObject->oFaceAngleYaw = gCurrentObject->oMoveAngleYaw; - gCurrentObject->oAction += 1; + gCurrentObject->oAction++; break; case 101: @@ -186,7 +187,7 @@ void bhv_intro_lakitu_loop(void) { gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric(gCurrentObject->oFaceAngleYaw, yawToCam, 0x200); } if (gCurrentObject->oTimer > 105) { - gCurrentObject->oAction += 1; + gCurrentObject->oAction++; gCurrentObject->oMoveAnglePitch = 0xE00; } gCurrentObject->oFaceAnglePitch = 0; diff --git a/src/game/behaviors/intro_peach.inc.c b/src/game/behaviors/intro_peach.inc.c index 37b40301..3a234657 100644 --- a/src/game/behaviors/intro_peach.inc.c +++ b/src/game/behaviors/intro_peach.inc.c @@ -21,7 +21,7 @@ void intro_peach_set_pos_and_opacity(struct Object *o, f32 targetOpacity, f32 in void bhv_intro_peach_loop(void) { switch (gCurrentObject->oAction) { case 0: - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 1; gCurrentObject->oFaceAnglePitch = 0x400; gCurrentObject->oFaceAngleYaw = 0x7500; gCurrentObject->oFaceAngleRoll = -0x3700; @@ -35,13 +35,13 @@ void bhv_intro_peach_loop(void) { intro_peach_set_pos_and_opacity(gCurrentObject, 0.f, 0.f); if (gCurrentObject->oTimer > 20) - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 2; break; case 2: intro_peach_set_pos_and_opacity(gCurrentObject, 255.f, 3.f); if ((gCurrentObject->oTimer > 100) && (get_dialog_id() == DIALOG_NONE)) - gCurrentObject->oAction += 1; + gCurrentObject->oAction = 3; break; case 3: intro_peach_set_pos_and_opacity(gCurrentObject, 0.f, 8.f); diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c index c7051475..a2adb846 100644 --- a/src/game/behaviors/klepto.inc.c +++ b/src/game/behaviors/klepto.inc.c @@ -63,7 +63,7 @@ static void klepto_anim_dive(void) { obj_move_pitch_approach(o->oKleptoPitchToTarget, 600); if (klepto_set_and_check_if_anim_at_end() != 0) { if (o->oKleptoDiveTimer != 0) { - o->oKleptoDiveTimer += 1; + o->oKleptoDiveTimer++; } else if (o->oKleptoPitchToTarget > -100) { o->oKleptoDiveTimer = random_linear_offset(60, 60); } @@ -234,7 +234,7 @@ static void klepto_act_dive_at_mario(void) { o->oKleptoYawToTarget = o->oAngleToMario; if (dy < 160.0f) { - o->oSubAction += 1; + o->oSubAction++; } } diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 9440dfda..66376f64 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -133,7 +133,7 @@ static void koopa_walk_start(void) { obj_forward_vel_approach(3.0f * o->oKoopaAgility, 0.3f * o->oKoopaAgility); if (cur_obj_init_anim_and_check_if_end(11)) { - o->oSubAction += 1; + o->oSubAction++; o->oKoopaCountdown = random_linear_offset(30, 100); } } @@ -146,9 +146,9 @@ static void koopa_walk(void) { koopa_play_footstep_sound(2, 17); if (o->oKoopaCountdown != 0) { - o->oKoopaCountdown -= 1; + o->oKoopaCountdown--; } else if (cur_obj_check_if_near_animation_end()) { - o->oSubAction += 1; + o->oSubAction++; } } @@ -244,7 +244,7 @@ static void koopa_shelled_act_lying(void) { cur_obj_init_anim_extend(5); koopa_dive_update_speed(0.3f); } else if (o->oKoopaCountdown != 0) { - o->oKoopaCountdown -= 1; + o->oKoopaCountdown--; cur_obj_extend_animation_if_at_end(); } else if (cur_obj_init_anim_and_check_if_end(6)) { o->oAction = KOOPA_SHELLED_ACT_STOPPED; @@ -350,7 +350,7 @@ static void koopa_unshelled_act_run(void) { obj_bounce_off_walls_edges_objects(&o->oKoopaTargetYaw))) { // Otherwise run around randomly if (o->oKoopaUnshelledTimeUntilTurn != 0) { - o->oKoopaUnshelledTimeUntilTurn -= 1; + o->oKoopaUnshelledTimeUntilTurn--; } else { o->oKoopaTargetYaw = obj_random_fixed_turn(0x2000); } @@ -424,7 +424,7 @@ static void koopa_unshelled_act_dive(void) { } koopa_dive_update_speed(0.5f); } else if (o->oKoopaCountdown != 0) { - o->oKoopaCountdown -= 1; + o->oKoopaCountdown--; cur_obj_extend_animation_if_at_end(); } else if (cur_obj_init_anim_and_check_if_end(6)) { o->oAction = KOOPA_UNSHELLED_ACT_RUN; @@ -498,7 +498,7 @@ static void koopa_the_quick_act_wait_before_race(void) { koopa_shelled_act_stopped(); if (o->oKoopaTheQuickInitTextboxCooldown != 0) { - o->oKoopaTheQuickInitTextboxCooldown -= 1; + o->oKoopaTheQuickInitTextboxCooldown--; } else if (cur_obj_can_mario_activate_textbox_2(400.0f, 400.0f)) { //! The next action doesn't execute until next frame, giving mario one // frame where he can jump, and thus no longer be ready to speak. @@ -657,11 +657,10 @@ static void koopa_the_quick_act_race(void) { break; case KOOPA_THE_QUICK_SUB_ACT_JUMP: - // We could perform a goomba double jump if we could deactivate - // ktq + // We could perform a goomba double jump if we could deactivate ktq if (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) { if (cur_obj_init_anim_and_check_if_end(13)) { - o->oSubAction -= 1; + o->oSubAction--; } koopa_the_quick_detect_bowling_ball(); diff --git a/src/game/behaviors/monty_mole.inc.c b/src/game/behaviors/monty_mole.inc.c index 3276cefd..a538a8f7 100644 --- a/src/game/behaviors/monty_mole.inc.c +++ b/src/game/behaviors/monty_mole.inc.c @@ -104,7 +104,7 @@ void bhv_monty_mole_hole_update(void) { sMontyMoleHoleList = link_objects_with_behavior(bhvMontyMoleHole); sMontyMoleKillStreak = 0; } else if (o->oMontyMoleHoleCooldown > 0) { - o->oMontyMoleHoleCooldown -= 1; + o->oMontyMoleHoleCooldown--; } } diff --git a/src/game/behaviors/mr_blizzard.inc.c b/src/game/behaviors/mr_blizzard.inc.c index c761d34e..62d3f46e 100644 --- a/src/game/behaviors/mr_blizzard.inc.c +++ b/src/game/behaviors/mr_blizzard.inc.c @@ -116,7 +116,7 @@ static void mr_blizzard_act_rise_from_ground(void) { // If the timer is not 0, decrement by 1 until it reaches 0. if (o->oMrBlizzardTimer != 0) { - o->oMrBlizzardTimer -= 1; + o->oMrBlizzardTimer--; } else if ((o->oMrBlizzardGraphYOffset += o->oMrBlizzardGraphYVel) > 24.0f) { // Increments GraphYOffset by GraphYVel until it is greater than 24, // moving Mr. Blizzard's graphical position upward each frame. diff --git a/src/game/behaviors/mr_i.inc.c b/src/game/behaviors/mr_i.inc.c index e4a3f177..4483d119 100644 --- a/src/game/behaviors/mr_i.inc.c +++ b/src/game/behaviors/mr_i.inc.c @@ -156,7 +156,7 @@ void mr_i_act_2(void) { o->oMrISpinAngle = 120; if (o->oMrISpinAmount > 1 << 16) o->oAction = 3; - o->oMrISpinAngle -= 1; + o->oMrISpinAngle--; if (!o->oMrISpinAngle) { o->oMrISpinAngle = 120; o->oMrISpinAmount = 0; diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c index df5d11f5..fc29ff56 100644 --- a/src/game/behaviors/pokey.inc.c +++ b/src/game/behaviors/pokey.inc.c @@ -58,15 +58,12 @@ void bhv_pokey_body_part_update(void) { // index by killing two body parts on the frame before a new part // spawns, but one of the body parts shifts upward immediately, // so not very interesting - if (o->oBehParams2ndByte > 1 - && !(o->parentObj->oPokeyAliveBodyPartFlags & (1 << (o->oBehParams2ndByte - 1)))) { - o->parentObj->oPokeyAliveBodyPartFlags = - o->parentObj->oPokeyAliveBodyPartFlags | 1 << (o->oBehParams2ndByte - 1); + if (o->oBehParams2ndByte > 1 && !(o->parentObj->oPokeyAliveBodyPartFlags & (1 << (o->oBehParams2ndByte - 1)))) { + o->parentObj->oPokeyAliveBodyPartFlags |= (1 << (o->oBehParams2ndByte - 1)); - o->parentObj->oPokeyAliveBodyPartFlags = - o->parentObj->oPokeyAliveBodyPartFlags & ((1 << o->oBehParams2ndByte) ^ ~0); + o->parentObj->oPokeyAliveBodyPartFlags &= ((1 << o->oBehParams2ndByte) ^ ~0); - o->oBehParams2ndByte -= 1; + o->oBehParams2ndByte--; } // Set the bottom body part size, and gradually increase it. @@ -109,7 +106,7 @@ void bhv_pokey_body_part_update(void) { // then die after a delay. if (obj_handle_attacks(&sPokeyBodyPartHitbox, o->oAction, sPokeyBodyPartAttackHandlers)) { - o->parentObj->oPokeyNumAliveBodyParts -= 1; + o->parentObj->oPokeyNumAliveBodyParts--; if (o->oBehParams2ndByte == 0) { o->parentObj->oPokeyHeadWasKilled = TRUE; // Last minute change to blue coins - not sure why they didn't @@ -123,7 +120,7 @@ void bhv_pokey_body_part_update(void) { cur_obj_become_intangible(); if (--o->oPokeyBodyPartDeathDelayAfterHeadKilled < 0) { - o->parentObj->oPokeyNumAliveBodyParts -= 1; + o->parentObj->oPokeyNumAliveBodyParts--; obj_die_if_health_non_positive(); } } else { @@ -208,9 +205,8 @@ static void pokey_act_wander(void) { MODEL_POKEY_BODY_PART, bhvPokeyBodyPart); if (bodyPart != NULL) { - o->oPokeyAliveBodyPartFlags = - o->oPokeyAliveBodyPartFlags | (1 << o->oPokeyNumAliveBodyParts); - o->oPokeyNumAliveBodyParts += 1; + o->oPokeyAliveBodyPartFlags |= (1 << o->oPokeyNumAliveBodyParts); + o->oPokeyNumAliveBodyParts++; o->oPokeyBottomBodyPartSize = 0.0f; obj_scale(bodyPart, 0.0f); @@ -234,7 +230,7 @@ static void pokey_act_wander(void) { if (!(o->oPokeyTurningAwayFromWall = obj_bounce_off_walls_edges_objects(&o->oPokeyTargetYaw))) { if (o->oPokeyChangeTargetTimer != 0) { - o->oPokeyChangeTargetTimer -= 1; + o->oPokeyChangeTargetTimer--; } else if (o->oDistanceToMario > 2000.0f) { o->oPokeyTargetYaw = obj_random_fixed_turn(0x2000); o->oPokeyChangeTargetTimer = random_linear_offset(30, 50); diff --git a/src/game/behaviors/recovery_heart.inc.c b/src/game/behaviors/recovery_heart.inc.c index 32f1de05..167011dc 100644 --- a/src/game/behaviors/recovery_heart.inc.c +++ b/src/game/behaviors/recovery_heart.inc.c @@ -16,7 +16,7 @@ void bhv_recovery_heart_loop(void) { if (obj_check_if_collided_with_object(o, gMarioObject)) { if (o->oSpinningHeartPlayedSound == 0) { cur_obj_play_sound_2(SOUND_GENERAL_HEART_SPIN); - o->oSpinningHeartPlayedSound += 1; + o->oSpinningHeartPlayedSound++; } o->oAngleVelYaw = (s32)(200.0f * gMarioStates[0].forwardVel) + 1000; diff --git a/src/game/behaviors/shock_wave.inc.c b/src/game/behaviors/shock_wave.inc.c index 9665f997..fc291726 100644 --- a/src/game/behaviors/shock_wave.inc.c +++ b/src/game/behaviors/shock_wave.inc.c @@ -16,7 +16,7 @@ void bhv_bowser_shock_wave_loop(void) { cur_obj_scale(o->oBowserShockWaveScale); // Slightly reduce opacity each 3 frames if (gGlobalTimer % 3) - o->oOpacity -= 1; + o->oOpacity--; // Reduce opacity faster after 70 frames have passed if (o->oTimer > fadeFrames) o->oOpacity -= 5; diff --git a/src/game/behaviors/skeeter.inc.c b/src/game/behaviors/skeeter.inc.c index f44c749d..0fc3cc6e 100644 --- a/src/game/behaviors/skeeter.inc.c +++ b/src/game/behaviors/skeeter.inc.c @@ -48,7 +48,7 @@ static void skeeter_act_idle(void) { && obj_smooth_turn(&o->oSkeeterAngleVel, &o->oMoveAngleYaw, o->oSkeeterTargetAngle, 0.02f, 5, 50, 200)) { if (o->oSkeeterWaitTime != 0) { - o->oSkeeterWaitTime -= 1; + o->oSkeeterWaitTime--; } else if (cur_obj_check_if_near_animation_end()) { cur_obj_play_sound_2(SOUND_OBJ_WALKING_WATER); o->oAction = SKEETER_ACT_LUNGE; @@ -116,7 +116,7 @@ static void skeeter_act_walk(void) { } else { o->oSkeeterTargetForwardVel = 10.0f; if (o->oSkeeterWaitTime != 0) { - o->oSkeeterWaitTime -= 1; + o->oSkeeterWaitTime--; } else if (cur_obj_check_if_near_animation_end() != 0) { if (random_u16() & 0x0003) { o->oSkeeterTargetAngle = obj_random_fixed_turn(0x2000); diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c index 128527f2..1ea35cd1 100644 --- a/src/game/behaviors/snufit.inc.c +++ b/src/game/behaviors/snufit.inc.c @@ -105,7 +105,7 @@ void snufit_act_shoot(void) { if ((u16) o->oSnufitBodyScalePeriod == 0x8000 && o->oSnufitBodyBaseScale == 167) { o->oAction = SNUFIT_ACT_IDLE; } else if (o->oSnufitBullets < 3 && o->oTimer >= 3) { - o->oSnufitBullets += 1; + o->oSnufitBullets++; cur_obj_play_sound_2(SOUND_OBJ_SNUFIT_SHOOT); spawn_object_relative(0, 0, -20, 40, o, MODEL_BOWLING_BALL, bhvSnufitBalls); o->oSnufitRecoil = -30; diff --git a/src/game/behaviors/spiny.inc.c b/src/game/behaviors/spiny.inc.c index 46c0d838..76339013 100644 --- a/src/game/behaviors/spiny.inc.c +++ b/src/game/behaviors/spiny.inc.c @@ -46,7 +46,7 @@ static s32 spiny_check_active(void) { // behave similar to a regular goomba. // It can also be used on a bob-omb respawner to change its model // to a butterfly or fish. - o->parentObj->oEnemyLakituNumSpinies -= 1; + o->parentObj->oEnemyLakituNumSpinies--; obj_mark_for_deletion(o); return FALSE; } @@ -85,7 +85,7 @@ static void spiny_act_walk(void) { obj_bounce_off_walls_edges_objects(&o->oSpinyTargetYaw))) { // Walk and occasionally randomly change direction if (o->oSpinyTimeUntilTurn != 0) { - o->oSpinyTimeUntilTurn -= 1; + o->oSpinyTimeUntilTurn--; } else { o->oSpinyTargetYaw = o->oMoveAngleYaw + (s16) random_sign() * 0x2000; o->oSpinyTimeUntilTurn = random_linear_offset(100, 100); @@ -171,7 +171,7 @@ static void spiny_act_thrown_by_lakitu(void) { if (obj_check_attacks(&sSpinyHitbox, o->oAction)) { if (o->parentObj != o) { - o->parentObj->oEnemyLakituNumSpinies -= 1; + o->parentObj->oEnemyLakituNumSpinies--; } } } diff --git a/src/game/behaviors/swoop.inc.c b/src/game/behaviors/swoop.inc.c index 8e628cf4..84f0473d 100644 --- a/src/game/behaviors/swoop.inc.c +++ b/src/game/behaviors/swoop.inc.c @@ -61,7 +61,7 @@ static void swoop_act_move(void) { o->oFaceAngleRoll = 0; } else { if (o->oSwoopBonkCountdown != 0) { - o->oSwoopBonkCountdown -= 1; + o->oSwoopBonkCountdown--; } else if (o->oVelY != 0.0f) { // If we're not done swooping, turn toward mario. When between // 0 and 200 units above mario, increase speed and stop swooping diff --git a/src/game/behaviors/thi_top.inc.c b/src/game/behaviors/thi_top.inc.c index 727020d0..fe30463a 100644 --- a/src/game/behaviors/thi_top.inc.c +++ b/src/game/behaviors/thi_top.inc.c @@ -31,7 +31,7 @@ void bhv_thi_tiny_island_top_loop(void) { } else { gTHIWaterDrained |= 1; play_puzzle_jingle(); - o->oAction += 1; + o->oAction++; } } } else { diff --git a/src/game/behaviors/ttc_2d_rotator.inc.c b/src/game/behaviors/ttc_2d_rotator.inc.c index 46c7603e..0124bee1 100644 --- a/src/game/behaviors/ttc_2d_rotator.inc.c +++ b/src/game/behaviors/ttc_2d_rotator.inc.c @@ -51,7 +51,7 @@ void bhv_ttc_2d_rotator_update(void) { s32 startYaw = o->oFaceAngleYaw; if (o->oTTC2DRotatorRandomDirTimer != 0) { - o->oTTC2DRotatorRandomDirTimer -= 1; + o->oTTC2DRotatorRandomDirTimer--; } // Wait until rotated to target yaw diff --git a/src/game/behaviors/ttc_moving_bar.inc.c b/src/game/behaviors/ttc_moving_bar.inc.c index e54e3c42..2bee2193 100644 --- a/src/game/behaviors/ttc_moving_bar.inc.c +++ b/src/game/behaviors/ttc_moving_bar.inc.c @@ -43,7 +43,7 @@ static void ttc_moving_bar_act_wait(void) { // This is zero except on the first cycle, and is used to desync the // bars from each other at the very beginning if (o->oTTCMovingBarStoppedTimer != 0) { - o->oTTCMovingBarStoppedTimer -= 1; + o->oTTCMovingBarStoppedTimer--; } else { if (gTTCSpeedSetting == TTC_SPEED_RANDOM) { // Set the delay for the next cycle @@ -70,7 +70,7 @@ static void ttc_moving_bar_act_pull_back(void) { if ((o->oTTCMovingBarSpeed += 0.73f) > 0.0f) { // Possibly pause after pulling back if (o->oTTCMovingBarStoppedTimer != 0) { - o->oTTCMovingBarStoppedTimer -= 1; + o->oTTCMovingBarStoppedTimer--; o->oTTCMovingBarSpeed = 0.0f; } else { // Begin extending diff --git a/src/game/behaviors/ttc_pendulum.inc.c b/src/game/behaviors/ttc_pendulum.inc.c index 569b4f15..a096c124 100644 --- a/src/game/behaviors/ttc_pendulum.inc.c +++ b/src/game/behaviors/ttc_pendulum.inc.c @@ -42,7 +42,7 @@ void bhv_ttc_pendulum_update(void) { // Stay still for a while if (o->oTTCPendulumDelay != 0) { - o->oTTCPendulumDelay -= 1; + o->oTTCPendulumDelay--; } else { // Accelerate in the direction that moves angle to zero if (o->oTTCPendulumAngle * o->oTTCPendulumAccelDir > 0.0f) { diff --git a/src/game/behaviors/water_bomb.inc.c b/src/game/behaviors/water_bomb.inc.c index 41333803..b4383672 100644 --- a/src/game/behaviors/water_bomb.inc.c +++ b/src/game/behaviors/water_bomb.inc.c @@ -39,7 +39,7 @@ void bhv_water_bomb_spawner_update(void) { if (!o->oWaterBombSpawnerBombActive && latDistToMario < spawnerRadius && gMarioObject->oPosY - o->oPosY < 1000.0f) { if (o->oWaterBombSpawnerTimeToSpawn != 0) { - o->oWaterBombSpawnerTimeToSpawn -= 1; + o->oWaterBombSpawnerTimeToSpawn--; } else { struct Object *waterBomb = spawn_object_relative(0, 0, 2000, 0, o, MODEL_WATER_BOMB, bhvWaterBomb); @@ -50,10 +50,8 @@ void bhv_water_bomb_spawner_update(void) { waterBomb->oAction = WATER_BOMB_ACT_INIT; - waterBomb->oPosX = - gMarioObject->oPosX + waterBombDistToMario * sins(gMarioObject->oMoveAngleYaw); - waterBomb->oPosZ = - gMarioObject->oPosZ + waterBombDistToMario * coss(gMarioObject->oMoveAngleYaw); + waterBomb->oPosX = gMarioObject->oPosX + waterBombDistToMario * sins(gMarioObject->oMoveAngleYaw); + waterBomb->oPosZ = gMarioObject->oPosZ + waterBombDistToMario * coss(gMarioObject->oMoveAngleYaw); spawn_object(waterBomb, MODEL_WATER_BOMB_SHADOW, bhvWaterBombShadow); diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c index a606d48d..8e884452 100644 --- a/src/game/behaviors/water_bomb_cannon.inc.c +++ b/src/game/behaviors/water_bomb_cannon.inc.c @@ -52,14 +52,14 @@ void water_bomb_cannon_act_1(void) { o->oAction = 2; } else if (o->oBehParams2ndByte == 0) { if (o->oWaterCannonIdleTimer != 0) { - o->oWaterCannonIdleTimer -= 1; + o->oWaterCannonIdleTimer--; } else { obj_move_pitch_approach(o->oWaterCannonTargetMovePitch, 0x80); obj_face_yaw_approach(o->oWaterCannonTargetFaceYaw, 0x100); if ((s16) o->oFaceAngleYaw == (s16) o->oWaterCannonTargetFaceYaw) { if (o->oWaterCannonRotationTimer != 0) { - o->oWaterCannonRotationTimer -= 1; + o->oWaterCannonRotationTimer--; } else { cur_obj_play_sound_2(SOUND_OBJ_CANNON4); o->oWaterCannonIdleTimer = 70; diff --git a/src/game/behaviors/wiggler.inc.c b/src/game/behaviors/wiggler.inc.c index 718245af..410297ec 100644 --- a/src/game/behaviors/wiggler.inc.c +++ b/src/game/behaviors/wiggler.inc.c @@ -234,7 +234,7 @@ static void wiggler_act_walk(void) { obj_forward_vel_approach(sWigglerSpeeds[o->oHealth - 1], 1.0f); if (o->oWigglerWalkAwayFromWallTimer != 0) { - o->oWigglerWalkAwayFromWallTimer -= 1; + o->oWigglerWalkAwayFromWallTimer--; } else { if (o->oDistanceToMario >= 25000.0f) { // If >1200 away from home, turn to home @@ -250,7 +250,7 @@ static void wiggler_act_walk(void) { if (o->oHealth < 4) { o->oWigglerTargetYaw = o->oAngleToMario; } else if (o->oWigglerTimeUntilRandomTurn != 0) { - o->oWigglerTimeUntilRandomTurn -= 1; + o->oWigglerTimeUntilRandomTurn--; } else { o->oWigglerTargetYaw = o->oMoveAngleYaw + 0x4000 * (s16) random_sign(); o->oWigglerTimeUntilRandomTurn = random_linear_offset(30, 50); diff --git a/src/game/camera.c b/src/game/camera.c index 3f9f871b..d21c8f20 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -3396,7 +3396,7 @@ s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *s *splineSegment = 0; finished = 1; } - *progress -= 1; + (*progress)--; } return finished; } @@ -5397,17 +5397,17 @@ u32 surface_type_modes(struct Camera *c) { switch (sMarioGeometry.currFloorType) { case SURFACE_CLOSE_CAMERA: transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 90); - modeChanged += 1; + modeChanged++; break; case SURFACE_CAMERA_FREE_ROAM: transition_to_camera_mode(c, CAMERA_MODE_FREE_ROAM, 90); - modeChanged += 1; + modeChanged++; break; case SURFACE_NO_CAM_COL_SLIPPERY: transition_to_camera_mode(c, CAMERA_MODE_CLOSE, 90); - modeChanged += 1; + modeChanged++; break; } return modeChanged; @@ -6255,12 +6255,12 @@ void copy_spline_segment(struct CutsceneSplinePoint dst[], struct CutsceneSpline s32 i = 0; init_spline_point(&dst[i], src[j].index, src[j].speed, src[j].point); - i += 1; + i++; do { do { init_spline_point(&dst[i], src[j].index, src[j].speed, src[j].point); - i += 1; - j += 1; + i++; + j++; } while (src[j].index != -1); } while (j > 16); @@ -6940,12 +6940,6 @@ void cutscene_dance_rotate_move_towards_mario(struct Camera *c) { rotate_and_move_vec3f(c->pos, sMarioCamState->pos, 20.f, 0, 0); } -/** - * Speculated to be dance-related due to its proximity to the other dance functions - */ -UNUSED static void cutscene_dance_unused(UNUSED struct Camera *c) { -} - /** * Slowly turn to the point 100 units in front of Mario */ @@ -8270,7 +8264,7 @@ void cutscene_read_message(struct Camera *c) { // Do nothing until message is gone. case 0: if (get_dialog_id() != DIALOG_NONE) { - sCutsceneVars[0].angle[0] += 1; + sCutsceneVars[0].angle[0]++; set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG); } break; @@ -10305,12 +10299,12 @@ void play_cutscene(struct Camera *c) { if ((cutsceneDuration != 0) && !(gCutsceneTimer & CUTSCENE_STOP)) { if (gCutsceneTimer < CUTSCENE_LOOP) { - gCutsceneTimer += 1; + gCutsceneTimer++; } //! Because gCutsceneTimer is often set to 0x7FFF (CUTSCENE_LOOP), this conditional can only //! check for == due to overflow if (gCutsceneTimer == cutsceneDuration) { - sCutsceneShot += 1; + sCutsceneShot++; gCutsceneTimer = 0; } } else { diff --git a/src/game/debug.c b/src/game/debug.c index 58e38d72..53502e88 100644 --- a/src/game/debug.c +++ b/src/game/debug.c @@ -96,7 +96,7 @@ void print_text_array_info(s16 *printState, const char *str, s32 number) { || (printState[DEBUG_PSTATE_MAX_X_CURSOR] < printState[DEBUG_PSTATE_Y_CURSOR])) { print_text(printState[DEBUG_PSTATE_X_CURSOR], printState[DEBUG_PSTATE_Y_CURSOR], "DPRINT OVER"); - printState[DEBUG_PSTATE_DISABLED] += 1; // why not just = TRUE... + printState[DEBUG_PSTATE_DISABLED] = TRUE; } else { print_text_fmt_int(printState[DEBUG_PSTATE_X_CURSOR], printState[DEBUG_PSTATE_Y_CURSOR], str, number); @@ -201,7 +201,7 @@ void print_string_array_info(const char **strArr) { s32 i; if (!sDebugStringArrPrinted) { - sDebugStringArrPrinted += 1; // again, why not = TRUE... + sDebugStringArrPrinted = TRUE; for (i = 0; i < 8; i++) { // sDebugPage is assumed to be 4 or 5 here. print_debug_top_down_mapinfo(strArr[i], gDebugInfo[sDebugPage][i]); @@ -240,7 +240,7 @@ void update_debug_dpadmask(void) { } else { sDebugInfoDPadMask = 0; } - sDebugInfoDPadUpdID += 1; + sDebugInfoDPadUpdID++; if (sDebugInfoDPadUpdID >= 8) { sDebugInfoDPadUpdID = 6; // rapidly set to 6 from 8 as long as dPadMask is being set. } @@ -249,7 +249,7 @@ void update_debug_dpadmask(void) { void debug_unknown_level_select_check(void) { if (!sDebugLvSelectCheckFlag) { - sDebugLvSelectCheckFlag += 1; // again, just do = TRUE... + sDebugLvSelectCheckFlag = TRUE; if (!gDebugLevelSelect) { gDebugInfoFlags = DEBUG_INFO_NOFLAGS; @@ -291,7 +291,7 @@ UNUSED static void check_debug_button_seq(void) { } else { if ((s16)(cButtonMask = (gPlayer1Controller->buttonPressed & C_BUTTONS))) { if (buttonArr[sDebugInfoButtonSeqID] == cButtonMask) { - sDebugInfoButtonSeqID += 1; + sDebugInfoButtonSeqID++; if (buttonArr[sDebugInfoButtonSeqID] == -1) { if (gDebugInfoFlags == DEBUG_INFO_FLAG_ALL) { gDebugInfoFlags = DEBUG_INFO_FLAG_LSELECT; @@ -314,11 +314,11 @@ UNUSED static void try_change_debug_page(void) { if (gDebugInfoFlags & DEBUG_INFO_FLAG_DPRINT) { if ((gPlayer1Controller->buttonPressed & L_JPAD) && (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) { - sDebugPage += 1; + sDebugPage++; } if ((gPlayer1Controller->buttonPressed & R_JPAD) && (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) { - sDebugPage -= 1; + sDebugPage--; } if (sDebugPage >= (DEBUG_PAGE_MAX + 1)) { sDebugPage = DEBUG_PAGE_MIN; @@ -351,14 +351,14 @@ void try_modify_debug_controls(void) { } if (sDebugInfoDPadMask & U_JPAD) { - sDebugSysCursor -= 1; + sDebugSysCursor--; if (sDebugSysCursor < 0) { sDebugSysCursor = 0; } } if (sDebugInfoDPadMask & D_JPAD) { - sDebugSysCursor += 1; + sDebugSysCursor++; if (sDebugSysCursor >= 8) { sDebugSysCursor = 7; } diff --git a/src/game/debug_course.c b/src/game/debug_course.c deleted file mode 100644 index f3fcc46c..00000000 --- a/src/game/debug_course.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "debug_course.h" - -// This is a seperate file according to Europe/Shindou -// versions. It is unknown what this file was for. - -void nop_change_course(void) { -} diff --git a/src/game/debug_course.h b/src/game/debug_course.h deleted file mode 100644 index 8d094e09..00000000 --- a/src/game/debug_course.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef DEBUG_COURSE_H -#define DEBUG_COURSE_H - -void nop_change_course(void); - -#endif // DEBUG_COURSE_H diff --git a/src/game/envfx_bubbles.c b/src/game/envfx_bubbles.c index 18a30e09..de7eb6b5 100644 --- a/src/game/envfx_bubbles.c +++ b/src/game/envfx_bubbles.c @@ -83,7 +83,7 @@ void envfx_update_flower(Vec3s centerPos) { (gEnvFxBuffer + i)->isAlive = 1; (gEnvFxBuffer + i)->animFrame = random_float() * 5.0f; } else if ((timer & 0x03) == 0) { - (gEnvFxBuffer + i)->animFrame += 1; + (gEnvFxBuffer + i)->animFrame++; if ((gEnvFxBuffer + i)->animFrame > 5) { (gEnvFxBuffer + i)->animFrame = 0; } @@ -154,7 +154,7 @@ void envfx_update_lava(Vec3s centerPos) { envfx_set_lava_bubble_position(i, centerPos); (gEnvFxBuffer + i)->isAlive = 1; } else if ((timer & 0x01) == 0) { - (gEnvFxBuffer + i)->animFrame += 1; + (gEnvFxBuffer + i)->animFrame++; if ((gEnvFxBuffer + i)->animFrame > 8) { (gEnvFxBuffer + i)->isAlive = 0; (gEnvFxBuffer + i)->animFrame = 0; diff --git a/src/game/interaction.c b/src/game/interaction.c index 723e490b..d8ae718e 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1440,8 +1440,8 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O if (interaction == INT_HIT_FROM_ABOVE || m->action == ACT_WALKING || m->action == ACT_HOLD_WALKING) { m->interactObj = obj; - m->usedObj = obj; - m->riddenObj = obj; + m->usedObj = obj; + m->riddenObj = obj; attack_object(obj, interaction); update_mario_sound_and_camera(m); @@ -1503,9 +1503,9 @@ u32 interact_pole(struct MarioState *m, UNUSED u32 interactType, struct Object * #endif m->interactObj = obj; - m->usedObj = obj; - m->vel[1] = 0.0f; - m->forwardVel = 0.0f; + m->usedObj = obj; + m->vel[1] = 0.0f; + m->forwardVel = 0.0f; marioObj->oMarioPoleUnk108 = 0; marioObj->oMarioPoleYawVel = 0; @@ -1651,22 +1651,10 @@ u32 mario_can_talk(struct MarioState *m, u32 arg) { return FALSE; } -#ifdef VERSION_JP -#define READ_MASK (INPUT_B_PRESSED) -#else -#define READ_MASK (INPUT_B_PRESSED | INPUT_A_PRESSED) -#endif - -#ifdef VERSION_JP -#define SIGN_RANGE 0x38E3 -#else -#define SIGN_RANGE 0x4000 -#endif - u32 check_read_sign(struct MarioState *m, struct Object *obj) { - if ((m->input & READ_MASK) && mario_can_talk(m, 0) && object_facing_mario(m, obj, SIGN_RANGE)) { + if ((m->input & (INPUT_B_PRESSED | INPUT_A_PRESSED)) && mario_can_talk(m, 0) && object_facing_mario(m, obj, 0x4000)) { s16 facingDYaw = (s16)(obj->oMoveAngleYaw + 0x8000) - m->faceAngle[1]; - if (facingDYaw >= -SIGN_RANGE && facingDYaw <= SIGN_RANGE) { + if (facingDYaw >= -0x4000 && facingDYaw <= 0x4000) { f32 targetX = obj->oPosX + 105.0f * sins(obj->oMoveAngleYaw); f32 targetZ = obj->oPosZ + 105.0f * coss(obj->oMoveAngleYaw); @@ -1684,7 +1672,7 @@ u32 check_read_sign(struct MarioState *m, struct Object *obj) { } u32 check_npc_talk(struct MarioState *m, struct Object *obj) { - if ((m->input & READ_MASK) && mario_can_talk(m, 1)) { + if ((m->input & (INPUT_B_PRESSED | INPUT_A_PRESSED)) && mario_can_talk(m, 1)) { s16 facingDYaw = mario_obj_angle_to_object(m, obj) - m->faceAngle[1]; if (facingDYaw >= -0x4000 && facingDYaw <= 0x4000) { obj->oInteractStatus = INT_STATUS_INTERACTED; @@ -1765,7 +1753,7 @@ void mario_process_interactions(struct MarioState *m) { } if (m->invincTimer > 0 && !sDelayInvincTimer) { - m->invincTimer -= 1; + m->invincTimer--; } //! If the kick/punch flags are set and an object collision changes Mario's @@ -1847,12 +1835,8 @@ void mario_handle_special_floors(struct MarioState *m) { break; } - if (!(m->action & ACT_FLAG_AIR) && !(m->action & ACT_FLAG_SWIMMING)) { - switch (floorType) { - case SURFACE_BURNING: - check_lava_boost(m); - break; - } + if (!(m->action & ACT_FLAG_AIR) && !(m->action & ACT_FLAG_SWIMMING) && (floorType == SURFACE_BURNING)) { + check_lava_boost(m); } } } diff --git a/src/game/level_update.c b/src/game/level_update.c index 895868c6..318625df 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -19,7 +19,6 @@ #include "ingame_menu.h" #include "obj_behaviors.h" #include "save_file.h" -#include "debug_course.h" #if MULTILANG #include "memory.h" #include "eu_translation.h" @@ -874,7 +873,7 @@ void initiate_delayed_warp(void) { case WARP_OP_CREDITS_NEXT: sound_banks_disable(SEQ_PLAYER_SFX, SOUND_BANKS_ALL); - gCurrCreditsEntry += 1; + gCurrCreditsEntry++; gCurrActNum = gCurrCreditsEntry->actNum & 0x07; if ((gCurrCreditsEntry + 1)->levelNum == LEVEL_NONE) { destWarpNode = WARP_NODE_CREDITS_END; @@ -915,7 +914,7 @@ void update_hud_values(void) { } if (gHudDisplay.coins < gMarioState->numCoins) { - if (gGlobalTimer & 0x00000001) { + if (gGlobalTimer & 0x1) { u32 coinSound; if (gMarioState->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) { coinSound = SOUND_GENERAL_COIN_WATER; @@ -923,7 +922,7 @@ void update_hud_values(void) { coinSound = SOUND_GENERAL_COIN; } - gHudDisplay.coins += 1; + gHudDisplay.coins++; play_sound(coinSound, gMarioState->marioObj->header.gfx.cameraToObject); } } @@ -998,7 +997,7 @@ s32 play_mode_normal(void) { check_instant_warp(); if (sTimerRunning && gHudDisplay.timer < 17999) { - gHudDisplay.timer += 1; + gHudDisplay.timer++; } area_update_objects(); @@ -1098,7 +1097,7 @@ s32 play_mode_change_area(void) { } if (sTransitionTimer > 0) { - sTransitionTimer -= 1; + sTransitionTimer--; } if (sTransitionTimer == 0) { @@ -1341,7 +1340,6 @@ s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum) { if (gSavedCourseNum != gCurrCourseNum) { gSavedCourseNum = gCurrCourseNum; - nop_change_course(); disable_warp_checkpoint(); } diff --git a/src/game/mario.c b/src/game/mario.c index 2d6f7474..273de3b1 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1167,11 +1167,10 @@ void squish_mario_model(struct MarioState *m) { if (m->squishTimer != 0xFF) { // If no longer squished, scale back to default. if (m->squishTimer == 0) { - vec3f_set(m->marioObj->header.gfx.scale, 1.0f, 1.0f, 1.0f); - } + vec3_same(m->marioObj->header.gfx.scale, 1.0f); // If timer is less than 16, rubber-band Mario's size scale up and down. - else if (m->squishTimer <= 16) { - m->squishTimer -= 1; + } else if (m->squishTimer <= 16) { + m->squishTimer--; m->marioObj->header.gfx.scale[1] = 1.0f - ((sSquishScaleOverTime[15 - m->squishTimer] * 0.6f) / 100.0f); @@ -1180,7 +1179,7 @@ void squish_mario_model(struct MarioState *m) { m->marioObj->header.gfx.scale[2] = m->marioObj->header.gfx.scale[0]; } else { - m->squishTimer -= 1; + m->squishTimer--; vec3f_set(m->marioObj->header.gfx.scale, 1.4f, 0.4f, 1.4f); } @@ -1243,13 +1242,13 @@ void update_mario_button_inputs(struct MarioState *m) { if (m->input & INPUT_A_PRESSED) { m->framesSinceA = 0; } else if (m->framesSinceA < 0xFF) { - m->framesSinceA += 1; + m->framesSinceA++; } if (m->input & INPUT_B_PRESSED) { m->framesSinceB = 0; } else if (m->framesSinceB < 0xFF) { - m->framesSinceB += 1; + m->framesSinceB++; } } @@ -1585,7 +1584,7 @@ u32 update_and_return_cap_flags(struct MarioState *m) { if ((m->capTimer <= 60) || ((action != ACT_READING_AUTOMATIC_DIALOG) && (action != ACT_READING_NPC_DIALOG) && (action != ACT_READING_SIGN) && (action != ACT_IN_CANNON))) { - m->capTimer -= 1; + m->capTimer--; } if (m->capTimer == 0) { diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 473ccc43..f935135e 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1545,7 +1545,7 @@ s32 act_lava_boost(struct MarioState *m) { if (m->actionState < 2 && m->vel[1] < 0.0f) { m->vel[1] = -m->vel[1] * 0.4f; mario_set_forward_vel(m, m->forwardVel * 0.5f); - m->actionState += 1; + m->actionState++; } else { set_mario_action(m, ACT_LAVA_BOOST_LAND, 0); } diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 8e6f720a..5740afdd 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -477,12 +477,10 @@ Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED scaleNode->scale = 1.0f; if (asGenerated->parameter == bodyState->punchState >> 6) { if (sMarioAttackAnimCounter != gAreaUpdateCounter && (bodyState->punchState & 0x3F) > 0) { - bodyState->punchState -= 1; + bodyState->punchState--; sMarioAttackAnimCounter = gAreaUpdateCounter; } - scaleNode->scale = - gMarioAttackScaleAnimation[asGenerated->parameter * 6 + (bodyState->punchState & 0x3F)] - / 10.0f; + scaleNode->scale = gMarioAttackScaleAnimation[asGenerated->parameter * 6 + (bodyState->punchState & 0x3F)] / 10.0f; } } return NULL; diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index 63c61322..dab8f3a7 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -146,7 +146,7 @@ static void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 do { prevWaypoint = nextWaypoint; - nextWaypoint += 1; + nextWaypoint++; if (nextWaypoint->flags == WAYPOINT_FLAGS_END) { if (ballIndex == 0) { o->oPlatformOnTrackPrevWaypointFlags = WAYPOINT_FLAGS_END; @@ -470,10 +470,9 @@ static s32 oscillate_toward(s32 *value, f32 *vel, s32 target, f32 velCloseToZero return FALSE; } -static void obj_update_blinking(s32 *blinkTimer, s16 baseCycleLength, s16 cycleLengthRange, - s16 blinkLength) { +static void obj_update_blinking(s32 *blinkTimer, s16 baseCycleLength, s16 cycleLengthRange, s16 blinkLength) { if (*blinkTimer != 0) { - *blinkTimer -= 1; + (*blinkTimer)--; } else { *blinkTimer = random_linear_offset(baseCycleLength, cycleLengthRange); } diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 02b5fefd..62c21907 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -285,7 +285,7 @@ s32 update_objects_starting_at(struct ObjectNode *objList, struct ObjectNode *fi cur_obj_update(); firstObj = firstObj->next; - count += 1; + count++; } return count; @@ -543,7 +543,7 @@ void update_non_terrain_objects(void) { s32 i = 2; while ((listIndex = sObjectListUpdateOrder[i]) != -1) { gObjectCounter += update_objects_in_list(&gObjectLists[listIndex]); - i += 1; + i++; } } @@ -556,7 +556,7 @@ void unload_deactivated_objects(void) { s32 i = 0; while ((listIndex = sObjectListUpdateOrder[i]) != -1) { unload_deactivated_objects_in_list(&gObjectLists[listIndex]); - i += 1; + i++; } // TIME_STOP_UNKNOWN_0 was most likely intended to be used to track whether diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index 057248b6..c53b0397 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -54,7 +54,7 @@ struct MemoryPool *gPuppyMemoryPool; s32 gPuppyError = 0; #if defined(VERSION_EU) -static unsigned char gPCOptionStringsFR[][64] = {{NC_ANALOGUE_FR}, {NC_CAMX_FR}, {NC_CAMY_FR}, {NC_INVERTX_FR}, {NC_INVERTY_FR}, {NC_CAMC_FR}, {NC_SCHEME_FR}, {NC_WIDE_FR}, {OPTION_LANGUAGE_FR}}; +static unsigned char gPCOptionStringsFR[][64] = {{NC_ANALOGUE_FR}, {NC_CAMX_FR}, {NC_CAMY_FR}, {NC_INVERTX_FR}, {NC_INVERTY_FR}, {NC_CAMC_FR}, {NC_SCHEME_FR}, {NC_WIDE_FR}, {OPTION_LANGUAGE_FR}}; static unsigned char gPCOptionStringsDE[][64] = {{NC_ANALOGUE_DE}, {NC_CAMX_DE}, {NC_CAMY_DE}, {NC_INVERTX_DE}, {NC_INVERTY_DE}, {NC_CAMC_DE}, {NC_SCHEME_DE}, {NC_WIDE_DE}, {OPTION_LANGUAGE_DE}}; static unsigned char gPCFlagStringsFR[][64] = {{OPTION_DISABLED_FR}, {OPTION_ENABLED_FR}, {OPTION_SCHEME1_FR}, {OPTION_SCHEME2_FR}, {OPTION_SCHEME3_FR}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},}; static unsigned char gPCFlagStringsDE[][64] = {{OPTION_DISABLED_DE}, {OPTION_ENABLED_DE}, {OPTION_SCHEME1_DE}, {OPTION_SCHEME2_DE}, {OPTION_SCHEME3_DE}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},}; @@ -83,12 +83,12 @@ struct gPCOptionStruct }; static const struct gPCOptionStruct gPCOptions[] = { //If the min and max are 0 and 1, then the value text is used, otherwise it's ignored. - #ifdef WIDE +#ifdef WIDE {/*Option Name*/ 7, /*Option Variable*/ &gConfig.widescreen, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE}, - #endif - #if MULTILANG +#endif +#if MULTILANG {/*Option Name*/ 8, /*Option Variable*/ &gInGameLanguage, /*Option Value Text Start*/ 4, /*Option Minimum*/ 1, /*Option Maximum*/ 3}, - #endif +#endif {/*Option Name*/ 0, /*Option Variable*/ &gPuppyCam.options.analogue, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE}, {/*Option Name*/ 6, /*Option Variable*/ &gPuppyCam.options.inputType, /*Option Value Text Start*/ 2, /*Option Minimum*/ 0, /*Option Maximum*/ 2}, {/*Option Name*/ 1, /*Option Variable*/ &gPuppyCam.options.sensitivityX, /*Option Value Text Start*/ 255, /*Option Minimum*/ 10, /*Option Maximum*/ 500}, @@ -100,97 +100,87 @@ static const struct gPCOptionStruct gPCOptions[] = { //If the min and max are 0 u8 gPCOptionCap = sizeof(gPCOptions) / sizeof(struct gPCOptionStruct); //How many options there are in newcam_uptions. -s16 LENSIN(s16 length, s16 direction) -{ +s16 LENSIN(s16 length, s16 direction) { return (length * sins(direction)); } -s16 LENCOS(s16 length, s16 direction) -{ +s16 LENCOS(s16 length, s16 direction) { return (length * coss(direction)); } -static void puppycam_analogue_stick(void) -{ - #ifdef TARGET_N64 - if (!gPuppyCam.options.analogue) +static void puppycam_analogue_stick(void) { +#ifdef TARGET_N64 + if (!gPuppyCam.options.analogue) { return; - - //I make the X axis negative, so that the movement reflects the Cbuttons. + } + // I make the X axis negative, so that the movement reflects the Cbuttons. gPuppyCam.stick2[0] = -gPlayer2Controller->rawStickX; - gPuppyCam.stick2[1] = gPlayer2Controller->rawStickY; + gPuppyCam.stick2[1] = gPlayer2Controller->rawStickY; - if (ABS(gPuppyCam.stick2[0]) < DEADZONE) - { + if (ABS(gPuppyCam.stick2[0]) < DEADZONE) { gPuppyCam.stick2[0] = 0; gPuppyCam.stickN[0] = 0; } - if (ABS(gPuppyCam.stick2[1]) < DEADZONE) - { + if (ABS(gPuppyCam.stick2[1]) < DEADZONE) { gPuppyCam.stick2[1] = 0; gPuppyCam.stickN[1] = 0; } - #endif +#endif } -void puppycam_default_config(void) -{ - gPuppyCam.options.invertX = 1; - gPuppyCam.options.invertY = 1; - gPuppyCam.options.sensitivityX = 100; - gPuppyCam.options.sensitivityY = 100; +void puppycam_default_config(void) { + gPuppyCam.options.invertX = 1; + gPuppyCam.options.invertY = 1; + gPuppyCam.options.sensitivityX = 100; + gPuppyCam.options.sensitivityY = 100; gPuppyCam.options.turnAggression = 50; - gPuppyCam.options.analogue = 0; - gPuppyCam.options.inputType = 1; + gPuppyCam.options.analogue = 0; + gPuppyCam.options.inputType = 1; } -//Initial setup. Ran at the beginning of the game and never again. -void puppycam_boot(void) -{ +// Initial setup. Ran at the beginning of the game and never again. +void puppycam_boot(void) { gPuppyCam.zoomPoints[0] = 600; gPuppyCam.zoomPoints[1] = 1000; gPuppyCam.zoomPoints[2] = 1500; - gPuppyCam.povHeight = 125; - gPuppyCam.stick2[0] = 0; - gPuppyCam.stick2[1] = 0; - gPuppyCam.stickN[0] = 0; - gPuppyCam.stickN[1] = 0; - gPuppyMemoryPool = mem_pool_init(MAX_PUPPYCAM_VOLUMES * sizeof(struct sPuppyVolume), MEMORY_POOL_LEFT); - gPuppyVolumeCount = 0; - gPuppyCam.enabled = 1; + gPuppyCam.povHeight = 125; + gPuppyCam.stick2[0] = 0; + gPuppyCam.stick2[1] = 0; + gPuppyCam.stickN[0] = 0; + gPuppyCam.stickN[1] = 0; + gPuppyMemoryPool = mem_pool_init(MAX_PUPPYCAM_VOLUMES * sizeof(struct sPuppyVolume), MEMORY_POOL_LEFT); + gPuppyVolumeCount = 0; + gPuppyCam.enabled = 1; puppycam_get_save(); } -//Called when an instant warp is done. -void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ) -{ - gPuppyCam.pos[0] += displacementX; - gPuppyCam.pos[1] += displacementY; - gPuppyCam.pos[2] += displacementZ; - gPuppyCam.targetFloorHeight += displacementY; +// Called when an instant warp is done. +void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ) { + gPuppyCam.pos[0] += displacementX; + gPuppyCam.pos[1] += displacementY; + gPuppyCam.pos[2] += displacementZ; + gPuppyCam.targetFloorHeight += displacementY; gPuppyCam.lastTargetFloorHeight += displacementY; - gPuppyCam.floorY[0] += displacementY; - gPuppyCam.floorY[1] += displacementY; + gPuppyCam.floorY[0] += displacementY; + gPuppyCam.floorY[1] += displacementY; } #if MULTILANG -static void newcam_set_language(void) -{ - switch (gInGameLanguage-1) - { - case 0: +static void newcam_set_language(void) { + switch (gInGameLanguage - 1) { + case LANGUAGE_ENGLISH: gPCOptionStringsPtr = &gPCOptionStringsEN; - gPCFlagStringsPtr = &gPCFlagStringsEN; + gPCFlagStringsPtr = &gPCFlagStringsEN; gPCToggleStringsPtr = &gPCToggleStringsEN; break; - case 1: + case LANGUAGE_FRENCH: gPCOptionStringsPtr = &gPCOptionStringsFR; - gPCFlagStringsPtr = &gPCFlagStringsFR; + gPCFlagStringsPtr = &gPCFlagStringsFR; gPCToggleStringsPtr = &gPCToggleStringsFR; break; - case 2: + case LANGUAGE_GERMAN: gPCOptionStringsPtr = &gPCOptionStringsDE; - gPCFlagStringsPtr = &gPCFlagStringsDE; + gPCFlagStringsPtr = &gPCFlagStringsDE; gPCToggleStringsPtr = &gPCToggleStringsDE; break; } @@ -200,9 +190,9 @@ static void newcam_set_language(void) ///CUTSCENE void puppycam_activate_cutscene(s32 (*scene)(), s32 lockinput) { - gPuppyCam.cutscene = 1; + gPuppyCam.cutscene = 1; gPuppyCam.sceneTimer = 0; - gPuppyCam.sceneFunc = scene; + gPuppyCam.sceneFunc = scene; gPuppyCam.sceneInput = lockinput; } @@ -226,32 +216,34 @@ static void puppycam_evaluate_spline(f32 progress, Vec3s cameraPos, Vec3f spline cameraPos[2] = tempP[0] * spline1[2] + tempP[1] * spline2[2] + tempP[2] * spline3[2] + tempP[3] * spline4[2]; } -s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySpline splineFocus[], s32 mode, s32 index) -{ +s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySpline splineFocus[], s32 mode, s32 index) { Vec3f tempPoints[4]; f32 tempProgress[2] = {0.0f, 0.0f}; f32 progChange = 0.0f; s32 i; Vec3f prevPos; - if (gPuppyCam.splineIndex == 65000) + if (gPuppyCam.splineIndex == 65000) { gPuppyCam.splineIndex = index; - - if (splinePos[gPuppyCam.splineIndex].index == -1 || splinePos[gPuppyCam.splineIndex + 1].index == -1 || splinePos[gPuppyCam.splineIndex + 2].index == -1) + } + if (splinePos[gPuppyCam.splineIndex].index == -1 || splinePos[gPuppyCam.splineIndex + 1].index == -1 || splinePos[gPuppyCam.splineIndex + 2].index == -1) { return 1; - if (mode == PUPPYSPLINE_FOLLOW) - if (splineFocus[gPuppyCam.splineIndex].index == -1 || splineFocus[gPuppyCam.splineIndex + 1].index == -1 || splineFocus[gPuppyCam.splineIndex + 2].index == -1) + } + if (mode == PUPPYSPLINE_FOLLOW) { + if (splineFocus[gPuppyCam.splineIndex].index == -1 || splineFocus[gPuppyCam.splineIndex + 1].index == -1 || splineFocus[gPuppyCam.splineIndex + 2].index == -1) { return 1; - + } + } vec3f_set(prevPos, gPuppyCam.pos[0], gPuppyCam.pos[1], gPuppyCam.pos[2]); - for (i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { vec3f_set(tempPoints[i], splinePos[gPuppyCam.splineIndex + i].pos[0], splinePos[gPuppyCam.splineIndex + i].pos[1], splinePos[gPuppyCam.splineIndex + i].pos[2]); + } puppycam_evaluate_spline(gPuppyCam.splineProgress, gPuppyCam.pos, tempPoints[0], tempPoints[1], tempPoints[2], tempPoints[3]); - if (mode == PUPPYSPLINE_FOLLOW) - { - for (i = 0; i < 4; i++) + if (mode == PUPPYSPLINE_FOLLOW) { + for (i = 0; i < 4; i++) { vec3f_set(tempPoints[i], splineFocus[gPuppyCam.splineIndex + i].pos[0], splineFocus[gPuppyCam.splineIndex + i].pos[1], splineFocus[gPuppyCam.splineIndex + i].pos[2]); + } puppycam_evaluate_spline(gPuppyCam.splineProgress, gPuppyCam.focus, tempPoints[0], tempPoints[1], tempPoints[2], tempPoints[3]); } @@ -265,11 +257,9 @@ s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySpline sp gPuppyCam.splineProgress += progChange; - if (gPuppyCam.splineProgress >= 1.0f) - { + if (gPuppyCam.splineProgress >= 1.0f) { gPuppyCam.splineIndex++; - if (splinePos[gPuppyCam.splineIndex+3].index == -1) - { + if (splinePos[gPuppyCam.splineIndex + 3].index == -1) { gPuppyCam.splineIndex = 0; gPuppyCam.splineProgress = 0; return 1; @@ -280,17 +270,14 @@ s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySpline sp return 0; } -static void puppycam_process_cutscene(void) -{ - if (gPuppyCam.cutscene) - { - if ((gPuppyCam.sceneFunc)() == 1) - { - gPuppyCam.cutscene = 0; - gPuppyCam.sceneInput = 0; - gPuppyCam.flags = gPuppyCam.intendedFlags; - } - gPuppyCam.sceneTimer++; +static void puppycam_process_cutscene(void) { + if (gPuppyCam.cutscene) { + if ((gPuppyCam.sceneFunc)() == 1) { + gPuppyCam.cutscene = 0; + gPuppyCam.sceneInput = 0; + gPuppyCam.flags = gPuppyCam.intendedFlags; + } + gPuppyCam.sceneTimer++; } } @@ -298,83 +285,68 @@ static void puppycam_process_cutscene(void) #define BLANK 0, 0, 0, ENVIRONMENT, 0, 0, 0, ENVIRONMENT -static void puppycam_display_box(s32 x1, s32 y1, s32 x2, s32 y2, u8 r, u8 g, u8 b, u8 a) -{ +static void puppycam_display_box(s32 x1, s32 y1, s32 x2, s32 y2, u8 r, u8 g, u8 b, u8 a) { gDPSetCombineMode(gDisplayListHead++, BLANK, BLANK); - gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); - if (a !=255) - { + gDPSetCycleType( gDisplayListHead++, G_CYC_1CYCLE); + if (a !=255) { gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - } - else - { + } else { gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF); } - gDPSetEnvColor(gDisplayListHead++, r, g, b, a); - gDPFillRectangle(gDisplayListHead++, x1, y1, x2, y2); - gDPPipeSync(gDisplayListHead++); - gDPSetEnvColor(gDisplayListHead++,255,255,255,255); - gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); - gSPDisplayList(gDisplayListHead++,dl_hud_img_end); + gDPSetEnvColor( gDisplayListHead++, r, g, b, a); + gDPFillRectangle( gDisplayListHead++, x1, y1, x2, y2); + gDPPipeSync( gDisplayListHead++); + gDPSetEnvColor( gDisplayListHead++, 255, 255, 255, 255); + gDPSetCycleType( gDisplayListHead++, G_CYC_1CYCLE); + gSPDisplayList( gDisplayListHead++,dl_hud_img_end); } //I actually took the time to redo this, properly. Lmao. Please don't bully me over this anymore :( -void puppycam_change_setting(s8 toggle) -{ - if (gPlayer1Controller->buttonDown & A_BUTTON) - toggle*= 5; - if (gPlayer1Controller->buttonDown & B_BUTTON) - toggle*= 10; +void puppycam_change_setting(s8 toggle) { + if (gPlayer1Controller->buttonDown & A_BUTTON) toggle *= 5; + if (gPlayer1Controller->buttonDown & B_BUTTON) toggle *= 10; - if (gPCOptions[gPCOptionSelected].gPCOptionMin == FALSE && gPCOptions[gPCOptionSelected].gPCOptionMax == TRUE) - { + if (gPCOptions[gPCOptionSelected].gPCOptionMin == FALSE && gPCOptions[gPCOptionSelected].gPCOptionMax == TRUE) { *gPCOptions[gPCOptionSelected].gPCOptionVar ^= 1; - } - else + } else { *gPCOptions[gPCOptionSelected].gPCOptionVar += toggle; - //Forgive me father, for I have sinned. I guess if you wanted a selling point for a 21:9 monitor though, "I can view this line in puppycam's code without scrolling!" can be added to it. + } + // Forgive me father, for I have sinned. I guess if you wanted a selling point for a 21:9 monitor though, "I can view this line in puppycam's code without scrolling!" can be added to it. *gPCOptions[gPCOptionSelected].gPCOptionVar = CLAMP(*gPCOptions[gPCOptionSelected].gPCOptionVar, gPCOptions[gPCOptionSelected].gPCOptionMin, gPCOptions[gPCOptionSelected].gPCOptionMax); - #if defined(VERSION_EU) +#if defined(VERSION_EU) newcam_set_language(); - #endif +#endif } -void puppycam_print_text(s32 x, s32 y, unsigned char *str, s32 col) -{ - s32 textX; - textX = get_str_x_pos_from_center(x,str,10.0f); +void puppycam_print_text(s32 x, s32 y, unsigned char *str, s32 col) { + s32 textX = get_str_x_pos_from_center(x, str, 10.0f); gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 255); - print_generic_string(textX+1,y-1,str); - if (col != 0) - { + print_generic_string(textX + 1, y - 1,str); + if (col != 0) { gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255); - } - else - { - gDPSetEnvColor(gDisplayListHead++, 255, 32, 32, 255); + } else { + gDPSetEnvColor(gDisplayListHead++, 255, 32, 32, 255); } print_generic_string(textX,y,str); } -//Options menu -void puppycam_display_options() -{ +// Options menu +void puppycam_display_options() { s32 i = 0; unsigned char newstring[32]; s32 scroll; s32 scrollpos; u32 var; // should be s16, but gives a build warning otherwise? // s32 vr; - s32 maxvar; - s32 minvar; + s32 minvar, maxvar; f32 newcam_sinpos; - puppycam_display_box(47,83,281,84,0x0,0x0,0x0, 0xFF); - puppycam_display_box(47,218,281,219,0x0,0x0,0x0, 0xFF); - puppycam_display_box(47,83,48,219,0x0,0x0,0x0, 0xFF); - puppycam_display_box(280,83,281,219,0x0,0x0,0x0, 0xFF); - puppycam_display_box(271,83,272,219,0x0,0x0,0x0, 0xFF); + puppycam_display_box( 47, 83, 281, 84, 0x00, 0x00, 0x00, 0xFF); + puppycam_display_box( 47, 218, 281, 219, 0x00, 0x00, 0x00, 0xFF); + puppycam_display_box( 47, 83, 48, 219, 0x00, 0x00, 0x00, 0xFF); + puppycam_display_box(280, 83, 281, 219, 0x00, 0x00, 0x00, 0xFF); + puppycam_display_box(271, 83, 272, 219, 0x00, 0x00, 0x00, 0xFF); puppycam_display_box(48,84,272,218,0x0,0x0,0x0, 0x50); gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin); @@ -382,51 +354,45 @@ void puppycam_display_options() print_hud_lut_string(HUD_LUT_GLOBAL, 112, 40, (*gPCToggleStringsPtr)[2]); gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end); - if (gPCOptionCap>4) - { - puppycam_display_box(272,84,280,218,0x80,0x80,0x80, 0xFF); - scrollpos = (62)*((f32)gPCOptionScroll/(gPCOptionCap-4)); - puppycam_display_box(272,84+scrollpos,280,156+scrollpos,0xFF,0xFF,0xFF, 0xFF); + if (gPCOptionCap > 4) { + puppycam_display_box(272, 84, 280, 218, 0x80, 0x80, 0x80, 0xFF); + scrollpos = (62) * ((f32)gPCOptionScroll / (gPCOptionCap - 4)); + puppycam_display_box(272, 84 + scrollpos, 280, 156 + scrollpos, 0xFF, 0xFF, 0xFF, 0xFF); } gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 80, SCREEN_WIDTH, SCREEN_HEIGHT); - for (i = 0; i < gPCOptionCap; i++) - { - scroll = 140-(32*i)+(gPCOptionScroll*32); - if (scroll <= 140 && scroll > 32) - { + for (i = 0; i < gPCOptionCap; i++) { + scroll = 140 - (32 * i) + (gPCOptionScroll * 32); + if (scroll <= 140 && scroll > 32) { puppycam_print_text(160,scroll,(*gPCOptionStringsPtr)[gPCOptions[i].gPCOptionName],gPCOptionSelected-i); - if (gPCOptions[i].gPCOptionStart != 255) - { + if (gPCOptions[i].gPCOptionStart != 255) { var = *gPCOptions[i].gPCOptionVar+gPCOptions[i].gPCOptionStart; - if (var < sizeof(gPCFlagStringsEN)) //Failsafe for if it somehow indexes an out of bounds array. - puppycam_print_text(160,scroll-12,(*gPCFlagStringsPtr)[var],gPCOptionSelected-i); - } - else - { + if (var < sizeof(gPCFlagStringsEN)) { // Failsafe for if it somehow indexes an out of bounds array. + puppycam_print_text(160, scroll - 12, (*gPCFlagStringsPtr)[var], gPCOptionSelected - i); + } + } else { int_to_str(*gPCOptions[i].gPCOptionVar,newstring); puppycam_print_text(160,scroll-12,newstring,gPCOptionSelected-i); - puppycam_display_box(96,111+(32*i)-(gPCOptionScroll*32),224,117+(32*i)-(gPCOptionScroll*32),0x80,0x80,0x80, 0xFF); + puppycam_display_box(96, 111 + (32 * i) - (gPCOptionScroll * 32), 224, 117 + (32 * i) - (gPCOptionScroll * 32), 0x80, 0x80, 0x80, 0xFF); maxvar = gPCOptions[i].gPCOptionMax - gPCOptions[i].gPCOptionMin; minvar = *gPCOptions[i].gPCOptionVar - gPCOptions[i].gPCOptionMin; - puppycam_display_box(96,111+(32*i)-(gPCOptionScroll*32),96+(((f32)minvar/maxvar)*128),117+(32*i)-(gPCOptionScroll*32),0xFF,0xFF,0xFF, 0xFF); - puppycam_display_box(94+(((f32)minvar/maxvar)*128),109+(32*i)-(gPCOptionScroll*32),98+(((f32)minvar/maxvar)*128),119+(32*i)-(gPCOptionScroll*32),0xFF,0x0,0x0, 0xFF); + puppycam_display_box(96, 111 + (32 * i) - (gPCOptionScroll * 32), 96 + (((f32)minvar / maxvar) * 128), 117 + (32 * i) - (gPCOptionScroll * 32), 0xFF, 0xFF, 0xFF, 0xFF); + puppycam_display_box(94 + (((f32)minvar / maxvar) * 128), 109 + (32 * i) - (gPCOptionScroll * 32), 98 + (((f32)minvar / maxvar) * 128), 119 + (32 * i) - (gPCOptionScroll * 32), 0xFF, 0x00, 0x00, 0xFF); gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); } } } - newcam_sinpos = sins(gGlobalTimer*5000)*4; + newcam_sinpos = sins(gGlobalTimer * 5000) * 4; gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255); - print_generic_string(80-newcam_sinpos, 132-(32*(gPCOptionSelected-gPCOptionScroll)), (*gPCToggleStringsPtr)[3]); - print_generic_string(232+newcam_sinpos, 132-(32*(gPCOptionSelected-gPCOptionScroll)), (*gPCToggleStringsPtr)[4]); + print_generic_string( 80 - newcam_sinpos, 132 - (32 * (gPCOptionSelected - gPCOptionScroll)), (*gPCToggleStringsPtr)[3]); + print_generic_string(232 + newcam_sinpos, 132 - (32 * (gPCOptionSelected - gPCOptionScroll)), (*gPCToggleStringsPtr)[4]); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); } //This has been separated for interesting reasons. Don't question it. -void puppycam_render_option_text(void) -{ +void puppycam_render_option_text(void) { gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); puppycam_print_text(278,212,(*gPCToggleStringsPtr)[gPCOptionOpen],1); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); @@ -434,359 +400,284 @@ void puppycam_render_option_text(void) extern struct SaveBuffer gSaveBuffer; -void puppycam_check_pause_buttons() -{ - if (gPlayer1Controller->buttonPressed & R_TRIG) - { +void puppycam_check_pause_buttons(void) { + if (gPlayer1Controller->buttonPressed & R_TRIG) { play_sound(SOUND_MENU_CHANGE_SELECT, gGlobalSoundSource); - if (gPCOptionOpen == 0) - { + if (gPCOptionOpen == 0) { gPCOptionOpen = 1; - #if MULTILANG +#if MULTILANG newcam_set_language(); eu_set_language(gInGameLanguage-1); - #endif - } - else - { +#endif + } else { gPCOptionOpen = 0; - #if MULTILANG +#if MULTILANG load_language_text(); - #endif +#endif puppycam_set_save(); } } - if (gPCOptionOpen) - { - if (ABS(gPlayer1Controller->rawStickY) > 60 || gPlayer1Controller->buttonDown & U_JPAD || gPlayer1Controller->buttonDown & D_JPAD) - { - gPCOptionTimer -= 1; - if (gPCOptionTimer <= 0) - { - switch (gPCOptionIndex) - { - case 0: gPCOptionIndex++; gPCOptionTimer += 10; break; - default: gPCOptionTimer += 5; break; + if (gPCOptionOpen) { + if (ABS(gPlayer1Controller->rawStickY) > 60 || gPlayer1Controller->buttonDown & U_JPAD || gPlayer1Controller->buttonDown & D_JPAD) { + gPCOptionTimer--; + if (gPCOptionTimer <= 0) { + if (gPCOptionIndex == 0) { + gPCOptionIndex++; + gPCOptionTimer += 10; + } else { + gPCOptionTimer += 5; } play_sound(SOUND_MENU_CHANGE_SELECT, gGlobalSoundSource); - if (gPlayer1Controller->rawStickY >= 60 || gPlayer1Controller->buttonDown & U_JPAD) - { + if (gPlayer1Controller->rawStickY >= 60 || gPlayer1Controller->buttonDown & U_JPAD) { gPCOptionSelected--; - if (gPCOptionSelected < 0) - gPCOptionSelected = gPCOptionCap-1; - } - else - if (gPlayer1Controller->rawStickY <= -60 || gPlayer1Controller->buttonDown & D_JPAD) - { + if (gPCOptionSelected < 0) { + gPCOptionSelected = gPCOptionCap - 1; + } + } else if (gPlayer1Controller->rawStickY <= -60 || gPlayer1Controller->buttonDown & D_JPAD) { gPCOptionSelected++; - if (gPCOptionSelected >= gPCOptionCap) + if (gPCOptionSelected >= gPCOptionCap) { gPCOptionSelected = 0; + } } } - } - else - if (ABS(gPlayer1Controller->rawStickX) > 60 || gPlayer1Controller->buttonDown & L_JPAD || gPlayer1Controller->buttonDown & R_JPAD) - { - gPCOptionTimer -= 1; - if (gPCOptionTimer <= 0) - { - switch (gPCOptionIndex) - { + } else if (ABS(gPlayer1Controller->rawStickX) > 60 || gPlayer1Controller->buttonDown & L_JPAD || gPlayer1Controller->buttonDown & R_JPAD) { + gPCOptionTimer--; + if (gPCOptionTimer <= 0) { + switch (gPCOptionIndex) { case 0: gPCOptionIndex++; gPCOptionTimer += 10; break; default: gPCOptionTimer += 5; break; } play_sound(SOUND_MENU_CHANGE_SELECT, gGlobalSoundSource); - if (gPlayer1Controller->rawStickX >= 60 || gPlayer1Controller->buttonDown & R_JPAD) + if (gPlayer1Controller->rawStickX >= 60 || gPlayer1Controller->buttonDown & R_JPAD) { puppycam_change_setting(1); - else - if (gPlayer1Controller->rawStickX <= -60 || gPlayer1Controller->buttonDown & L_JPAD) + } else if (gPlayer1Controller->rawStickX <= -60 || gPlayer1Controller->buttonDown & L_JPAD) puppycam_change_setting(-1); + } } - } - else - { + } else { gPCOptionTimer = 0; gPCOptionIndex = 0; } - - while (gPCOptionScroll - gPCOptionSelected < -3 && gPCOptionSelected > gPCOptionScroll) - gPCOptionScroll +=1; - while (gPCOptionScroll + gPCOptionSelected > 0 && gPCOptionSelected < gPCOptionScroll) - gPCOptionScroll -=1; + while (gPCOptionScroll - gPCOptionSelected < -3 && gPCOptionSelected > gPCOptionScroll) gPCOptionScroll++; + while (gPCOptionScroll + gPCOptionSelected > 0 && gPCOptionSelected < gPCOptionScroll) gPCOptionScroll--; } } ///CORE -//Just a function that sets a bunch of camera values to 0. It's a function because it's got shared functionality. -void puppycam_reset_values(void) -{ - gPuppyCam.swimPitch = 0; - gPuppyCam.edgePitch = 0; - gPuppyCam.moveZoom = 0; - gPuppyCam.floorY[0] = 0; - gPuppyCam.floorY[1] = 0; - gPuppyCam.terrainPitch = 0; - gPuppyCam.splineIndex = 0; +// Just a function that sets a bunch of camera values to 0. It's a function because it's got shared functionality. +void puppycam_reset_values(void) { + gPuppyCam.swimPitch = 0; + gPuppyCam.edgePitch = 0; + gPuppyCam.moveZoom = 0; + gPuppyCam.floorY[0] = 0; + gPuppyCam.floorY[1] = 0; + gPuppyCam.terrainPitch = 0; + gPuppyCam.splineIndex = 0; gPuppyCam.splineProgress = 0; } -//Set up values. Runs on level load. -void puppycam_init(void) -{ - if (gMarioState->marioObj) +// Set up values. Runs on level load. +void puppycam_init(void) { + if (gMarioState->marioObj) { gPuppyCam.targetObj = gMarioState->marioObj; + } gPuppyCam.targetObj2 = NULL; gPuppyCam.intendedFlags = PUPPYCAM_BEHAVIOUR_DEFAULT; - if (gCurrLevelNum == LEVEL_PSS || (gCurrLevelNum == LEVEL_TTM && gCurrAreaIndex == 2) || (gCurrLevelNum == LEVEL_CCM && gCurrAreaIndex == 2)) + if (gCurrLevelNum == LEVEL_PSS || (gCurrLevelNum == LEVEL_TTM && gCurrAreaIndex == 2) || (gCurrLevelNum == LEVEL_CCM && gCurrAreaIndex == 2)) { gPuppyCam.intendedFlags |= PUPPYCAM_BEHAVIOUR_SLIDE_CORRECTION; - gPuppyCam.flags = gPuppyCam.intendedFlags; - gPuppyCam.zoom = gPuppyCam.zoomPoints[1]; - gPuppyCam.zoomSet = 1; - gPuppyCam.zoomTarget = gPuppyCam.zoom; - gPuppyCam.yaw = gMarioState->faceAngle[1]+0x8000; - gPuppyCam.yawTarget = gPuppyCam.yaw; - gPuppyCam.pitch = 0x3800; - gPuppyCam.pitchTarget = gPuppyCam.pitch; - gPuppyCam.yawAcceleration = 0; - gPuppyCam.pitchAcceleration = 0; - gPuppyCam.shakeFrames = 0; - gPuppyCam.shake[0] = 0; - gPuppyCam.shake[1] = 0; - gPuppyCam.shake[2] = 0; - gPuppyCam.pos[0] = 0; - gPuppyCam.pos[1] = 0; - gPuppyCam.pos[2] = 0; - gPuppyCam.focus[0] = 0; - gPuppyCam.focus[1] = 0; - gPuppyCam.focus[2] = 0; - gPuppyCam.pan[0] = 0; - gPuppyCam.pan[1] = 0; //gMarioState->pos[1]; - gPuppyCam.pan[2] = 0; - gPuppyCam.targetFloorHeight = gPuppyCam.pan[1]; + } + gPuppyCam.flags = gPuppyCam.intendedFlags; + gPuppyCam.zoom = gPuppyCam.zoomPoints[1]; + gPuppyCam.zoomSet = 1; + gPuppyCam.zoomTarget = gPuppyCam.zoom; + gPuppyCam.yaw = gMarioState->faceAngle[1] + 0x8000; + gPuppyCam.yawTarget = gPuppyCam.yaw; + gPuppyCam.pitch = 0x3800; + gPuppyCam.pitchTarget = gPuppyCam.pitch; + gPuppyCam.yawAcceleration = 0; + gPuppyCam.pitchAcceleration = 0; + gPuppyCam.shakeFrames = 0; + vec3_zero(gPuppyCam.shake); + vec3_zero(gPuppyCam.pos); + vec3_zero(gPuppyCam.focus); + vec3_zero(gPuppyCam.pan); // gMarioState->pos[1]; + gPuppyCam.targetFloorHeight = gPuppyCam.pan[1]; gPuppyCam.lastTargetFloorHeight = gMarioState->pos[1]; - gPuppyCam.opacity = 255; - gPuppyCam.framesSinceC[0] = 10; //This just exists to stop input type B being stupid. - gPuppyCam.framesSinceC[1] = 10; //This just exists to stop input type B being stupid. - gPuppyCam.mode3Flags = PUPPYCAM_MODE3_ZOOMED_MED; - gPuppyCam.debugFlags = PUPPYDEBUG_LOCK_CONTROLS; + gPuppyCam.opacity = 255; + gPuppyCam.framesSinceC[0] = 10; // This just exists to stop input type B being stupid. + gPuppyCam.framesSinceC[1] = 10; // This just exists to stop input type B being stupid. + gPuppyCam.mode3Flags = PUPPYCAM_MODE3_ZOOMED_MED; + gPuppyCam.debugFlags = PUPPYDEBUG_LOCK_CONTROLS; puppycam_reset_values(); } -void puppycam_input_pitch(void) -{ - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) - { - //Handles vertical inputs. - if (gPlayer1Controller->buttonDown & U_CBUTTONS || gPuppyCam.stick2[1] != 0) - gPuppyCam.pitchAcceleration -= 50*(gPuppyCam.options.sensitivityY/100.f); - else - if (gPlayer1Controller->buttonDown & D_CBUTTONS || gPuppyCam.stick2[1] != 0) - gPuppyCam.pitchAcceleration += 50*(gPuppyCam.options.sensitivityY/100.f); - else +void puppycam_input_pitch(void) { + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) { + // Handles vertical inputs. + if (gPlayer1Controller->buttonDown & U_CBUTTONS || gPuppyCam.stick2[1] != 0) { + gPuppyCam.pitchAcceleration -= 50 * (gPuppyCam.options.sensitivityY / 100.f); + } else if (gPlayer1Controller->buttonDown & D_CBUTTONS || gPuppyCam.stick2[1] != 0) { + gPuppyCam.pitchAcceleration += 50 * (gPuppyCam.options.sensitivityY / 100.f); + } else { gPuppyCam.pitchAcceleration = 0; - + } gPuppyCam.pitchAcceleration = CLAMP(gPuppyCam.pitchAcceleration, -100, 100); - //When Mario's moving, his pitch is clamped pretty aggressively, so this exists so you can shift your view up and down momentarily at an actually usable range, rather than the otherwise baby range. - if (gMarioState->action & ACT_FLAG_MOVING && (gPuppyCam.pitch >= 0x3800 || gPuppyCam.pitch <= 0x2000)) + // When Mario's moving, his pitch is clamped pretty aggressively, so this exists so you can shift your view up and down momentarily at an actually usable range, rather than the otherwise baby range. + if (gMarioState->action & ACT_FLAG_MOVING && (gPuppyCam.pitch >= 0x3800 || gPuppyCam.pitch <= 0x2000)) { gPuppyCam.moveFlagAdd = 8; + } } } -void puppycam_input_zoom(void) -{ - //Handles R button zooming. - if (gPlayer1Controller->buttonPressed & R_TRIG && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE) - { +void puppycam_input_zoom(void) { + // Handles R button zooming. + if (gPlayer1Controller->buttonPressed & R_TRIG && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE) { gPuppyCam.zoomSet++; - if (gPuppyCam.zoomSet >= 3) + if (gPuppyCam.zoomSet >= 3) { gPuppyCam.zoomSet = 0; - + } gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[gPuppyCam.zoomSet]; play_sound(SOUND_MENU_CLICK_CHANGE_VIEW,gGlobalSoundSource); } } -void puppycam_input_centre(void) -{ - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) +void puppycam_input_centre(void) { + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) { return; + } s32 inputDefault = L_TRIG; - if (gPuppyCam.options.inputType == 2) + if (gPuppyCam.options.inputType == 2) { inputDefault = R_TRIG; - //Handles L button centering. + } + // Handles L button centering. if (gPlayer1Controller->buttonPressed & inputDefault && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION && - !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && !(gPlayer1Controller->buttonDown & U_JPAD)) - { - gPuppyCam.yawTarget = gMarioState->faceAngle[1]+0x8000; + !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && !(gPlayer1Controller->buttonDown & U_JPAD)) { + gPuppyCam.yawTarget = gMarioState->faceAngle[1] + 0x8000; play_sound(SOUND_MENU_CLICK_CHANGE_VIEW,gGlobalSoundSource); } } -//The default control scheme. Hold the button down to turn the camera, and double tap to turn quickly. -static void puppycam_input_hold_preset1(f32 ivX) -{ - if (!gPuppyCam.options.analogue && gPlayer1Controller->buttonPressed & L_CBUTTONS && gPuppyCam.framesSinceC[0] <= 5) - { - gPuppyCam.yawTarget -= 0x4000*ivX; +// The default control scheme. Hold the button down to turn the camera, and double tap to turn quickly. +static void puppycam_input_hold_preset1(f32 ivX) { + if (!gPuppyCam.options.analogue && gPlayer1Controller->buttonPressed & L_CBUTTONS && gPuppyCam.framesSinceC[0] <= 5) { + gPuppyCam.yawTarget -= 0x4000 * ivX; play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); - } - else - if (!gPuppyCam.options.analogue && gPlayer1Controller->buttonPressed & R_CBUTTONS && gPuppyCam.framesSinceC[1] <= 5) - { - gPuppyCam.yawTarget += 0x4000*ivX; + } else if (!gPuppyCam.options.analogue && gPlayer1Controller->buttonPressed & R_CBUTTONS && gPuppyCam.framesSinceC[1] <= 5) { + gPuppyCam.yawTarget += 0x4000 * ivX; play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); } - if ((gPlayer1Controller->buttonDown & L_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0) - { - gPuppyCam.yawAcceleration -= 75*(gPuppyCam.options.sensitivityX/100.f); + if ((gPlayer1Controller->buttonDown & L_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0) { + gPuppyCam.yawAcceleration -= 75 * (gPuppyCam.options.sensitivityX / 100.f); gPuppyCam.framesSinceC[0] = 0; - } - else - if ((gPlayer1Controller->buttonDown & R_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0) - { - gPuppyCam.yawAcceleration += 75*(gPuppyCam.options.sensitivityX/100.f); + } else if ((gPlayer1Controller->buttonDown & R_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0) { + gPuppyCam.yawAcceleration += 75*(gPuppyCam.options.sensitivityX / 100.f); gPuppyCam.framesSinceC[1] = 0; - } - else + } else { gPuppyCam.yawAcceleration = 0; + } } -//An alternative control scheme, hold the button down to turn the camera, or press it once to turn it quickly. -static void puppycam_input_hold_preset2(f32 ivX) -{ - //These set the initial button press. - if (gPlayer1Controller->buttonPressed & L_CBUTTONS) - { - gPuppyCam.framesSinceC[0] = 0; - } - - if (gPlayer1Controller->buttonPressed & R_CBUTTONS) - { - gPuppyCam.framesSinceC[1] = 0; - } - - //These handle when you release the button - if ((!(gPlayer1Controller->buttonDown & L_CBUTTONS)) && gPuppyCam.framesSinceC[0] <= 5) - { - gPuppyCam.yawTarget -= 0x3000*ivX; +// An alternative control scheme, hold the button down to turn the camera, or press it once to turn it quickly. +static void puppycam_input_hold_preset2(f32 ivX) { + // These set the initial button press. + if (gPlayer1Controller->buttonPressed & L_CBUTTONS) gPuppyCam.framesSinceC[0] = 0; + if (gPlayer1Controller->buttonPressed & R_CBUTTONS) gPuppyCam.framesSinceC[1] = 0; + // These handle when you release the button + if ((!(gPlayer1Controller->buttonDown & L_CBUTTONS)) && gPuppyCam.framesSinceC[0] <= 5) { + gPuppyCam.yawTarget -= 0x3000 * ivX; play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); gPuppyCam.framesSinceC[0] = 6; } - if ((!(gPlayer1Controller->buttonDown & R_CBUTTONS)) && gPuppyCam.framesSinceC[1] <= 5) - { - gPuppyCam.yawTarget += 0x3000*ivX; + if ((!(gPlayer1Controller->buttonDown & R_CBUTTONS)) && gPuppyCam.framesSinceC[1] <= 5) { + gPuppyCam.yawTarget += 0x3000 * ivX; play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); gPuppyCam.framesSinceC[1] = 6; } - //Handles continuous movement as normal, as long as the button's held. - if (gPlayer1Controller->buttonDown & L_CBUTTONS) - { - gPuppyCam.yawAcceleration -= 75*(gPuppyCam.options.sensitivityX/100.f); - } - else - if (gPlayer1Controller->buttonDown & R_CBUTTONS) - { - gPuppyCam.yawAcceleration += 75*(gPuppyCam.options.sensitivityX/100.f); - } - else + // Handles continuous movement as normal, as long as the button's held. + if (gPlayer1Controller->buttonDown & L_CBUTTONS) { + gPuppyCam.yawAcceleration -= 75 * (gPuppyCam.options.sensitivityX / 100.f); + } else if (gPlayer1Controller->buttonDown & R_CBUTTONS) { + gPuppyCam.yawAcceleration += 75 * (gPuppyCam.options.sensitivityX / 100.f); + } else { gPuppyCam.yawAcceleration = 0; + } } -//Another alternative control scheme. This one aims to mimic the parallel camera scheme down to the last bit from the original game. -static void puppycam_input_hold_preset3(void) -{ +// Another alternative control scheme. This one aims to mimic the parallel camera scheme down to the last bit from the original game. +static void puppycam_input_hold_preset3(void) { f32 stickMag[2] = {gPlayer1Controller->rawStickX*0.65f, gPlayer1Controller->rawStickY*0.2f}; - //Just in case it happens to be nonzero. + // Just in case it happens to be nonzero. gPuppyCam.yawAcceleration = 0; //In theory this shouldn't be necessary, but it's nice to cover all bases. - if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) + if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) { return; - - if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) - { + } + if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) { gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_COLLISION; - //Handles continuous movement as normal, as long as the button's held. - if (ABS(gPlayer1Controller->rawStickX) > DEADZONE) - { - gPuppyCam.yawAcceleration -= (gPuppyCam.options.sensitivityX/100.f)*stickMag[0]; - } - else + // Handles continuous movement as normal, as long as the button's held. + if (ABS(gPlayer1Controller->rawStickX) > DEADZONE) { + gPuppyCam.yawAcceleration -= (gPuppyCam.options.sensitivityX / 100.f) * stickMag[0]; + } else { gPuppyCam.yawAcceleration = 0; - - if (ABS(gPlayer1Controller->rawStickY) > DEADZONE) - { - gPuppyCam.pitchAcceleration -= (gPuppyCam.options.sensitivityY/100.f)*stickMag[1]; } - else + if (ABS(gPlayer1Controller->rawStickY) > DEADZONE) { + gPuppyCam.pitchAcceleration -= (gPuppyCam.options.sensitivityY / 100.f) * stickMag[1]; + } else { gPuppyCam.pitchAcceleration = approach_f32_asymptotic(gPuppyCam.pitchAcceleration, 0, DECELERATION); - } - else - { - if (gPlayer1Controller->buttonPressed & L_TRIG) - { - if (gPuppyCam.yawTarget % 0x2000) + } + } else { + if (gPlayer1Controller->buttonPressed & L_TRIG) { + if (gPuppyCam.yawTarget % 0x2000) { gPuppyCam.yawTarget += 0x2000 - gPuppyCam.yawTarget % 0x2000; + } } - if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) - gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3800, 0x200, 0x200); - if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_OUT) - gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3000, 0x200, 0x200); + if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3800, 0x200, 0x200); + if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_OUT) gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3000, 0x200, 0x200); - if ((gPlayer1Controller->buttonPressed & L_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[0] > DEADZONE && !gPuppyCam.stickN[0])) - { - gPuppyCam.stickN[0] = 1; + if ((gPlayer1Controller->buttonPressed & L_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[0] > DEADZONE && !gPuppyCam.stickN[0])) { + gPuppyCam.stickN[0] = 1; gPuppyCam.yawTarget -= 0x2000; play_sound(SOUND_MENU_CAMERA_TURN,gGlobalSoundSource); } - if ((gPlayer1Controller->buttonPressed & R_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[0] < -DEADZONE && !gPuppyCam.stickN[0])) - { - gPuppyCam.stickN[0] = 1; + if ((gPlayer1Controller->buttonPressed & R_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[0] < -DEADZONE && !gPuppyCam.stickN[0])) { + gPuppyCam.stickN[0] = 1; gPuppyCam.yawTarget += 0x2000; play_sound(SOUND_MENU_CAMERA_TURN,gGlobalSoundSource); } } - //Handles zooming in. Works just like vanilla. - if ((gPlayer1Controller->buttonPressed & U_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] > DEADZONE && !gPuppyCam.stickN[1])) - { - if ((gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) && !(gMarioState->action & ACT_FLAG_AIR) && !(gMarioState->action & ACT_FLAG_SWIMMING)) - { - gPuppyCam.stickN[1] = 1; + // Handles zooming in. Works just like vanilla. + if ((gPlayer1Controller->buttonPressed & U_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] > DEADZONE && !gPuppyCam.stickN[1])) { + if ((gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) && !(gMarioState->action & ACT_FLAG_AIR) && !(gMarioState->action & ACT_FLAG_SWIMMING)) { + gPuppyCam.stickN[1] = 1; gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_IN; gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_MED; - gPuppyCam.zoomTarget = 200; + gPuppyCam.zoomTarget = 200; gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ENTER_FIRST_PERSON; play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); - } - else - if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_OUT) - { - gPuppyCam.stickN[1] = 1; + } else if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_OUT) { + gPuppyCam.stickN[1] = 1; gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_MED; gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_OUT; - gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[1]; + gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[1]; play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); } - } - else //Otherwise handle zooming out. - if ((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1])) - { - if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) - { + } else if ((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1])) { // Otherwise handle zooming out. + if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) { gPuppyCam.stickN[1] = 1; gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_OUT; gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_MED; @@ -796,14 +687,12 @@ static void puppycam_input_hold_preset3(void) } } if ((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1]) || - gPlayer1Controller->buttonPressed & B_BUTTON || gPlayer1Controller->buttonPressed & A_BUTTON) - { - if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) - { - gPuppyCam.stickN[1] = 1; + gPlayer1Controller->buttonPressed & B_BUTTON || gPlayer1Controller->buttonPressed & A_BUTTON) { + if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) { + gPuppyCam.stickN[1] = 1; gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_MED; gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_IN; - gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[1]; + gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[1]; gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ENTER_FIRST_PERSON; play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource); @@ -811,38 +700,32 @@ static void puppycam_input_hold_preset3(void) } } -//Handles C Button inputs for modes that have held inputs, rather than presses. -static void puppycam_input_hold(void) -{ +// Handles C Button inputs for modes that have held inputs, rather than presses. +static void puppycam_input_hold(void) { f32 ivX = ((gPuppyCam.options.invertX*2)-1)*(gPuppyCam.options.sensitivityX/100.f); f32 ivY = ((gPuppyCam.options.invertY*2)-1)*(gPuppyCam.options.sensitivityY/100.f); s8 stickMag[2] = {100, 100}; - if (gPuppyCam.intendedFlags & PUPPYCAM_BEHAVIOUR_FREE) + if (gPuppyCam.intendedFlags & PUPPYCAM_BEHAVIOUR_FREE) { gPuppyCam.flags = PUPPYCAM_BEHAVIOUR_FREE | PUPPYCAM_BEHAVIOUR_YAW_ROTATION | PUPPYCAM_BEHAVIOUR_PITCH_ROTATION; - - //Analogue Camera stuff. If it fails to find an input, then it just sets stickmag to 100, which after calculations means the value goes unchanged. - if (gPuppyCam.options.analogue && gPuppyCam.options.inputType != 2) - { - stickMag[0] = gPuppyCam.stick2[0]*1.25f; - stickMag[1] = gPuppyCam.stick2[1]*1.25f; + } + // Analogue Camera stuff. If it fails to find an input, then it just sets stickmag to 100, which after calculations means the value goes unchanged. + if (gPuppyCam.options.analogue && gPuppyCam.options.inputType != 2) { + stickMag[0] = gPuppyCam.stick2[0] * 1.25f; + stickMag[1] = gPuppyCam.stick2[1] * 1.25f; } //In theory this shouldn't be necessary, but it's nice to cover all bases. - if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) + if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) { return; - - if ((!gPuppyCam.options.analogue || gPuppyCam.options.inputType == 2) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE)) - { - switch (gPuppyCam.options.inputType) - { - default: puppycam_input_hold_preset1(ivX); puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); break; - case 1: puppycam_input_hold_preset2(ivX); puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); break; - case 2: puppycam_input_hold_preset3(); puppycam_input_centre(); break; - } } - else - { + if ((!gPuppyCam.options.analogue || gPuppyCam.options.inputType == 2) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE)) { + switch (gPuppyCam.options.inputType) { + default: puppycam_input_hold_preset1(ivX); puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); break; + case 1: puppycam_input_hold_preset2(ivX); puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); break; + case 2: puppycam_input_hold_preset3(); puppycam_input_centre(); break; + } + } else { puppycam_input_hold_preset1(ivX); puppycam_input_pitch(); puppycam_input_zoom(); @@ -854,168 +737,146 @@ static void puppycam_input_hold(void) gPuppyCam.yawAcceleration = CLAMP(gPuppyCam.yawAcceleration, -100, 100); - gPuppyCam.yawTarget += (12*gPuppyCam.yawAcceleration*ivX)*(stickMag[0]*0.01f); - gPuppyCam.pitchTarget += ((4+gPuppyCam.moveFlagAdd)*gPuppyCam.pitchAcceleration*ivY)*(stickMag[1]*0.01f); + gPuppyCam.yawTarget += (12 * gPuppyCam.yawAcceleration * ivX) * (stickMag[0] * 0.01f); + gPuppyCam.pitchTarget += ((4 + gPuppyCam.moveFlagAdd) * gPuppyCam.pitchAcceleration * ivY) * (stickMag[1] * 0.01f); } -//Handles C Button inputs for modes that have pressed inputs, rather than held. -static void puppycam_input_press(void) -{ - f32 ivX = ((gPuppyCam.options.invertX*2)-1)*(gPuppyCam.options.sensitivityX/100.f); - f32 ivY = ((gPuppyCam.options.invertY*2)-1)*(gPuppyCam.options.sensitivityY/100.f); +// Handles C Button inputs for modes that have pressed inputs, rather than held. +static void puppycam_input_press(void) { + f32 ivX = ((gPuppyCam.options.invertX * 2) - 1) * (gPuppyCam.options.sensitivityX / 100.f); + f32 ivY = ((gPuppyCam.options.invertY * 2) - 1) * (gPuppyCam.options.sensitivityY / 100.f); s8 stickMag = 0; - //Analogue Camera stuff. If it fails to find an input, then it just sets stickmag to 100, which after calculations means the value goes unchanged. - if (gPuppyCam.options.analogue) - stickMag = gPuppyCam.stick2[0]*1.25f; - else + // Analogue Camera stuff. If it fails to find an input, then it just sets stickmag to 100, which after calculations means the value goes unchanged. + if (gPuppyCam.options.analogue) { + stickMag = gPuppyCam.stick2[0] * 1.25f; + } else { stickMag = 100; - - //Just in case it happens to be nonzero. + } + // Just in case it happens to be nonzero. gPuppyCam.yawAcceleration = 0; - //In theory this shouldn't be necessary, but it's nice to cover all bases. - if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) + // In theory this shouldn't be necessary, but it's nice to cover all bases. + if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) { return; - - if ((gPlayer1Controller->buttonPressed & L_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stickN[0] == 0 && gPuppyCam.stick2[0] < -DEADZONE)) - { + } + if ((gPlayer1Controller->buttonPressed & L_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stickN[0] == 0 && gPuppyCam.stick2[0] < -DEADZONE)) { gPuppyCam.stickN[0] = 1; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) - gPuppyCam.yawTarget -= 0x2000*ivX; - else - gPuppyCam.yawTarget -= 0x4000*ivX; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) { + gPuppyCam.yawTarget -= 0x2000 * ivX; + } else { + gPuppyCam.yawTarget -= 0x4000 * ivX; + } play_sound(SOUND_MENU_CAMERA_ZOOM_IN,gGlobalSoundSource); } - if ((gPlayer1Controller->buttonPressed & R_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stickN[0] == 0 && gPuppyCam.stick2[0] > DEADZONE)) - { + if ((gPlayer1Controller->buttonPressed & R_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stickN[0] == 0 && gPuppyCam.stick2[0] > DEADZONE)) { gPuppyCam.stickN[0] = 1; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) - gPuppyCam.yawTarget += 0x2000*ivX; - else - gPuppyCam.yawTarget += 0x4000*ivX; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) { + gPuppyCam.yawTarget += 0x2000 * ivX; + } else { + gPuppyCam.yawTarget += 0x4000 * ivX; + } play_sound(SOUND_MENU_CAMERA_ZOOM_IN,gGlobalSoundSource); } puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); - gPuppyCam.pitchTarget += ((4+gPuppyCam.moveFlagAdd)*gPuppyCam.pitchAcceleration*ivY)*(stickMag*0.01f); + gPuppyCam.pitchTarget += ((4 + gPuppyCam.moveFlagAdd) * gPuppyCam.pitchAcceleration * ivY) * (stickMag * 0.01f); } -void puppycam_debug_view(void) -{ - if (gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS) - { - if (ABS(gPlayer1Controller->rawStickX) > DEADZONE) - { - gPuppyCam.pos[0] += (gPlayer1Controller->rawStickX/4) * -sins(gPuppyCam.yawTarget); - gPuppyCam.pos[2] += (gPlayer1Controller->rawStickX/4) * coss(gPuppyCam.yawTarget); +void puppycam_debug_view(void) { + if (gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS) { + if (ABS(gPlayer1Controller->rawStickX) > DEADZONE) { + gPuppyCam.pos[0] += (gPlayer1Controller->rawStickX / 4) * -sins(gPuppyCam.yawTarget); + gPuppyCam.pos[2] += (gPlayer1Controller->rawStickX / 4) * coss(gPuppyCam.yawTarget); } - if (ABS(gPlayer1Controller->rawStickY) > DEADZONE) - { - gPuppyCam.pos[0] += (gPlayer1Controller->rawStickY/4) * coss(gPuppyCam.yawTarget); - gPuppyCam.pos[1] += (gPlayer1Controller->rawStickY/4) * sins(gPuppyCam.pitchTarget); - gPuppyCam.pos[2] += (gPlayer1Controller->rawStickY/4) * sins(gPuppyCam.yawTarget); + if (ABS(gPlayer1Controller->rawStickY) > DEADZONE) { + gPuppyCam.pos[0] += (gPlayer1Controller->rawStickY / 4) * coss(gPuppyCam.yawTarget); + gPuppyCam.pos[1] += (gPlayer1Controller->rawStickY / 4) * sins(gPuppyCam.pitchTarget); + gPuppyCam.pos[2] += (gPlayer1Controller->rawStickY / 4) * sins(gPuppyCam.yawTarget); } - if (gPlayer1Controller->buttonDown & Z_TRIG || gPlayer1Controller->buttonDown & L_TRIG) + if (gPlayer1Controller->buttonDown & Z_TRIG || gPlayer1Controller->buttonDown & L_TRIG) { gPuppyCam.pos[1] -= 20; - if (gPlayer1Controller->buttonDown & R_TRIG) + } + if (gPlayer1Controller->buttonDown & R_TRIG) { gPuppyCam.pos[1] += 20; - - gPuppyCam.focus[0] = gPuppyCam.pos[0] + (100 *coss(gPuppyCam.yawTarget)); - gPuppyCam.focus[1] = gPuppyCam.pos[1] + (100 *sins(gPuppyCam.pitchTarget)); - gPuppyCam.focus[2] = gPuppyCam.pos[2] + (100 *sins(gPuppyCam.yawTarget)); - } - else - { - if (gPuppyCam.debugFlags & PUPPYDEBUG_TRACK_MARIO) - { - gPuppyCam.focus[0] = gPuppyCam.targetObj->oPosX; - gPuppyCam.focus[1] = gPuppyCam.targetObj->oPosY; - gPuppyCam.focus[2] = gPuppyCam.targetObj->oPosZ; + } + gPuppyCam.focus[0] = gPuppyCam.pos[0] + (100 * coss(gPuppyCam.yawTarget)); + gPuppyCam.focus[1] = gPuppyCam.pos[1] + (100 * sins(gPuppyCam.pitchTarget)); + gPuppyCam.focus[2] = gPuppyCam.pos[2] + (100 * sins(gPuppyCam.yawTarget)); + } else { + if (gPuppyCam.debugFlags & PUPPYDEBUG_TRACK_MARIO) { + vec3_copy(gPuppyCam.focus, &gPuppyCam.targetObj->oPosVec); } - gPuppyCam.yawTarget = atan2s(gPuppyCam.pos[2] - gPuppyCam.focus[2], gPuppyCam.pos[0] - gPuppyCam.focus[0]); + gPuppyCam.yawTarget = atan2s(gPuppyCam.pos[2] - gPuppyCam.focus[2], gPuppyCam.pos[0] - gPuppyCam.focus[0]); gPuppyCam.pitchTarget = atan2s(gPuppyCam.pos[1] - gPuppyCam.focus[1], 100); } - gPuppyCam.yaw = gPuppyCam.yawTarget; + gPuppyCam.yaw = gPuppyCam.yawTarget; gPuppyCam.pitch = gPuppyCam.pitchTarget; - if (gPlayer1Controller->buttonPressed & A_BUTTON && gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS) - { + if (gPlayer1Controller->buttonPressed & A_BUTTON && gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS) { vec3f_set(gMarioState->pos, gPuppyCam.pos[0], gPuppyCam.pos[1], gPuppyCam.pos[2]); } - if (gPlayer1Controller->buttonPressed & B_BUTTON) - { - if (gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS) + if (gPlayer1Controller->buttonPressed & B_BUTTON) { + if (gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS) { gPuppyCam.debugFlags &= ~PUPPYDEBUG_LOCK_CONTROLS; - else + } else { gPuppyCam.debugFlags |= PUPPYDEBUG_LOCK_CONTROLS; + } } - if (gPlayer1Controller->buttonPressed & R_TRIG && !(gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS)) - { - if (gPuppyCam.debugFlags & PUPPYDEBUG_TRACK_MARIO) + if (gPlayer1Controller->buttonPressed & R_TRIG && !(gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS)) { + if (gPuppyCam.debugFlags & PUPPYDEBUG_TRACK_MARIO) { gPuppyCam.debugFlags &= ~PUPPYDEBUG_TRACK_MARIO; - else + } else { gPuppyCam.debugFlags |= PUPPYDEBUG_TRACK_MARIO; + } } } -static void puppycam_view_panning(void) -{ +static void puppycam_view_panning(void) { f32 panFloor, panMulti; s32 expectedPanX, expectedPanZ; s32 height = gPuppyCam.targetObj->oPosY; s32 panEx = (gPuppyCam.zoomTarget >= 1000) * 160; //Removes the basic panning when idling if the zoom level is at the closest. f32 slideSpeed = 1; - panMulti = CLAMP(gPuppyCam.zoom/(f32)gPuppyCam.zoomPoints[2], 0.f, 1.f); - if (gPuppyCam.options.inputType == 2) + panMulti = CLAMP(gPuppyCam.zoom / (f32)gPuppyCam.zoomPoints[2], 0.f, 1.f); + if (gPuppyCam.options.inputType == 2) { panMulti /= 2; - - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT && gMarioState->action != ACT_HOLDING_BOWSER && gMarioState->action != ACT_SLEEPING && gMarioState->action != ACT_START_SLEEPING) - { - if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) + } + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT && gMarioState->action != ACT_HOLDING_BOWSER && gMarioState->action != ACT_SLEEPING && gMarioState->action != ACT_START_SLEEPING) { + if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) { slideSpeed = 10; - - expectedPanX = LENSIN(panEx+(200*(gMarioState->forwardVel/320.f)), gMarioState->faceAngle[1])*panMulti; - expectedPanZ = LENCOS(panEx+(200*(gMarioState->forwardVel/320.f)), gMarioState->faceAngle[1])*panMulti; + } + expectedPanX = LENSIN(panEx + (200 * (gMarioState->forwardVel / 320.f)), gMarioState->faceAngle[1]) * panMulti; + expectedPanZ = LENCOS(panEx + (200 * (gMarioState->forwardVel / 320.f)), gMarioState->faceAngle[1]) * panMulti; gPuppyCam.pan[0] = approach_f32_asymptotic(gPuppyCam.pan[0], expectedPanX, 0.02f*slideSpeed); gPuppyCam.pan[2] = approach_f32_asymptotic(gPuppyCam.pan[2], expectedPanZ, 0.02f*slideSpeed); - if (gMarioState->vel[1] == 0.0f) - { - panFloor = CLAMP(find_floor_height((s16)(gPuppyCam.targetObj->oPosX+expectedPanX),(s16)(gPuppyCam.targetObj->oPosY + 200), - (s16)(gPuppyCam.targetObj->oPosZ+expectedPanZ)),gPuppyCam.targetObj->oPosY-50,gPuppyCam.targetObj->oPosY+50); - //If the floor is lower than 150 units below Mario, then ignore the Y value and tilt the camera instead. - if (panFloor <= gPuppyCam.targetObj->oPosY-150) - { + if (gMarioState->vel[1] == 0.0f) { + panFloor = CLAMP(find_floor_height((s16)(gPuppyCam.targetObj->oPosX+expectedPanX), (s16)(gPuppyCam.targetObj->oPosY + 200), + (s16)(gPuppyCam.targetObj->oPosZ+expectedPanZ)), gPuppyCam.targetObj->oPosY - 50,gPuppyCam.targetObj->oPosY + 50); + // If the floor is lower than 150 units below Mario, then ignore the Y value and tilt the camera instead. + if (panFloor <= gPuppyCam.targetObj->oPosY - 150) { panFloor = gPuppyCam.targetObj->oPosY; gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, -0x2000, 0x80, 0x80); - } - else - { + } else { gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, 0, 0x100, 0x100); } - - gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], panFloor-height, 0.025f); - } - else + gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], panFloor - height, 0.025f); + } else { gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], 0, 0.05f); - } - else - { - gPuppyCam.pan[0] = 0; - gPuppyCam.pan[1] = 0; - gPuppyCam.pan[2] = 0; + } + } else { + vec3_zero(gPuppyCam.pan); } } -void puppycam_terrain_angle(void) -{ +void puppycam_terrain_angle(void) { f32 adjustSpeed; s32 floor2 = find_floor_height(gPuppyCam.pos[0], gPuppyCam.pos[1]+100, gPuppyCam.pos[2]); s32 ceil = 20000;//find_ceil(gPuppyCam.pos[0], gPuppyCam.pos[1]+100, gPuppyCam.pos[2]); @@ -1023,47 +884,41 @@ void puppycam_terrain_angle(void) s16 floorPitch; s32 gotTheOkay = FALSE; - if (gMarioState->action & ACT_FLAG_SWIMMING || !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER)) - { + if (gMarioState->action & ACT_FLAG_SWIMMING || !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER)) { gPuppyCam.intendedTerrainPitch = 0; adjustSpeed = 0.25f; farFromSurface = TRUE; - } - else - { - f32 x, z, floorHeight; + } else { adjustSpeed = CLAMP(MAX(gMarioState->forwardVel/480.0f, gPuppyCam.yawAcceleration/100.0f), 0.05f, 1.0f); - x = gPuppyCam.targetObj->oPosX - (10 * sins(gPuppyCam.yaw)); - z = gPuppyCam.targetObj->oPosZ - (10 * coss(gPuppyCam.yaw)); + f32 x = gPuppyCam.targetObj->oPosX - (10 * sins(gPuppyCam.yaw)); + f32 z = gPuppyCam.targetObj->oPosZ - (10 * coss(gPuppyCam.yaw)); - floorHeight = find_floor_height(x, gPuppyCam.targetObj->oPosY+100, z); + f32 floorHeight = find_floor_height(x, gPuppyCam.targetObj->oPosY+100, z); - if (ABS(gMarioState->floorHeight - floorHeight) > 350) - { + if (ABS(gMarioState->floorHeight - floorHeight) > 350) { gPuppyCam.intendedTerrainPitch = 0; - } - else - { + } else { floorPitch = -atan2s(30.0f, gMarioState->floorHeight - floorHeight); gPuppyCam.intendedTerrainPitch = approach_f32_asymptotic(gPuppyCam.intendedTerrainPitch, floorPitch, adjustSpeed); gotTheOkay = TRUE; } - //Ensures that the camera is below and above floors and ceilings. It ignores this rule for each if the camera's headed upwards anyway. + // Ensures that the camera is below and above floors and ceilings. It ignores this rule for each if the camera's headed upwards anyway. farFromSurface = ((gPuppyCam.pos[1] > floor2 + 50 || gPuppyCam.intendedTerrainPitch < gPuppyCam.terrainPitch) && (gPuppyCam.pos[1] < ceil - 50 || gPuppyCam.intendedTerrainPitch > gPuppyCam.terrainPitch)); - //If the camera is too close to a vertical obstruction, it'll make the intended pitch much further away, making it swivel faster. - if (!farFromSurface && gotTheOkay) + // If the camera is too close to a vertical obstruction, it'll make the intended pitch much further away, making it swivel faster. + if (!farFromSurface && gotTheOkay) { gPuppyCam.intendedTerrainPitch = approach_f32_asymptotic(gPuppyCam.intendedTerrainPitch, floorPitch, adjustSpeed*3); + } } - if (farFromSurface) + if (farFromSurface) { gPuppyCam.terrainPitch = approach_f32_asymptotic(gPuppyCam.terrainPitch, gPuppyCam.intendedTerrainPitch, adjustSpeed); + } } -const struct sPuppyAngles puppyAnglesNull = -{ +const struct sPuppyAngles puppyAnglesNull = { {PUPPY_NULL, PUPPY_NULL, PUPPY_NULL}, {PUPPY_NULL, PUPPY_NULL, PUPPY_NULL}, PUPPY_NULL, @@ -1071,61 +926,54 @@ const struct sPuppyAngles puppyAnglesNull = PUPPY_NULL, }; -//Checks the bounding box of a puppycam volume. If it's inside, then set the pointer to the current index. -static s32 puppycam_check_volume_bounds(struct sPuppyVolume *volume, s32 index) -{ +// Checks the bounding box of a puppycam volume. If it's inside, then set the pointer to the current index. +static s32 puppycam_check_volume_bounds(struct sPuppyVolume *volume, s32 index) { s32 rel[3]; s32 pos[2]; f32 distCheck; - if (sPuppyVolumeStack[index]->room != gMarioCurrentRoom && sPuppyVolumeStack[index]->room != -1) + if (sPuppyVolumeStack[index]->room != gMarioCurrentRoom && sPuppyVolumeStack[index]->room != -1) { return FALSE; - - if (sPuppyVolumeStack[index]->shape == PUPPYVOLUME_SHAPE_BOX) - { - //Fetch the relative position. to the triggeree. + } + if (sPuppyVolumeStack[index]->shape == PUPPYVOLUME_SHAPE_BOX) { + // Fetch the relative position. to the triggeree. rel[0] = sPuppyVolumeStack[index]->pos[0] - gPuppyCam.targetObj->oPosX; rel[1] = sPuppyVolumeStack[index]->pos[1] - gPuppyCam.targetObj->oPosY; rel[2] = sPuppyVolumeStack[index]->pos[2] - gPuppyCam.targetObj->oPosZ; - //Use the dark, forbidden arts of trig to rotate the volume. + // Use the dark, forbidden arts of trig to rotate the volume. pos[0] = rel[2] * sins(sPuppyVolumeStack[index]->rot) + rel[0] * coss(sPuppyVolumeStack[index]->rot); pos[1] = rel[2] * coss(sPuppyVolumeStack[index]->rot) - rel[0] * sins(sPuppyVolumeStack[index]->rot); #ifdef VISUAL_DEBUG Vec3f debugPos[2]; - vec3f_set(debugPos[0], sPuppyVolumeStack[index]->pos[0], sPuppyVolumeStack[index]->pos[1], sPuppyVolumeStack[index]->pos[2]); + vec3f_set(debugPos[0], sPuppyVolumeStack[index]->pos[0], sPuppyVolumeStack[index]->pos[1], sPuppyVolumeStack[index]->pos[2]); vec3f_set(debugPos[1], sPuppyVolumeStack[index]->radius[0], sPuppyVolumeStack[index]->radius[1], sPuppyVolumeStack[index]->radius[2]); debug_box_color(0x0000FF00); debug_box_rot(debugPos[0], debugPos[1], sPuppyVolumeStack[index]->rot, DEBUG_SHAPE_BOX | DEBUG_UCODE_DEFAULT); #endif - //Now compare values. + // Now compare values. if (-sPuppyVolumeStack[index]->radius[0] < pos[0] && pos[0] < sPuppyVolumeStack[index]->radius[0] && -sPuppyVolumeStack[index]->radius[1] < rel[1] && rel[1] < sPuppyVolumeStack[index]->radius[1] && - -sPuppyVolumeStack[index]->radius[2] < pos[1] && pos[1] < sPuppyVolumeStack[index]->radius[2]) - { + -sPuppyVolumeStack[index]->radius[2] < pos[1] && pos[1] < sPuppyVolumeStack[index]->radius[2]) { *volume = *sPuppyVolumeStack[index]; return TRUE; } - } - else - if (sPuppyVolumeStack[index]->shape == PUPPYVOLUME_SHAPE_CYLINDER) - { + } else if (sPuppyVolumeStack[index]->shape == PUPPYVOLUME_SHAPE_CYLINDER) { // s16 dir; f32 dist; rel[0] = sPuppyVolumeStack[index]->pos[0] - gPuppyCam.targetObj->oPosX; rel[1] = sPuppyVolumeStack[index]->pos[1] - gPuppyCam.targetObj->oPosY; rel[2] = sPuppyVolumeStack[index]->pos[2] - gPuppyCam.targetObj->oPosZ; - dist = sqrtf((rel[0] * rel[0]) + (rel[2] * rel[2])); - #ifdef VISUAL_DEBUG + dist = sqrtf(sqr(rel[0]) + sqr(rel[2])); +#ifdef VISUAL_DEBUG Vec3f debugPos[2]; - vec3f_set(debugPos[0], sPuppyVolumeStack[index]->pos[0], sPuppyVolumeStack[index]->pos[1], sPuppyVolumeStack[index]->pos[2]); + vec3f_set(debugPos[0], sPuppyVolumeStack[index]->pos[0], sPuppyVolumeStack[index]->pos[1], sPuppyVolumeStack[index]->pos[2]); vec3f_set(debugPos[1], sPuppyVolumeStack[index]->radius[0], sPuppyVolumeStack[index]->radius[1], sPuppyVolumeStack[index]->radius[2]); debug_box_color(0x0000FF00); debug_box_rot(debugPos[0], debugPos[1], sPuppyVolumeStack[index]->rot, DEBUG_SHAPE_CYLINDER | DEBUG_UCODE_DEFAULT); - #endif +#endif distCheck = (dist < sPuppyVolumeStack[index]->radius[0]); - if (-sPuppyVolumeStack[index]->radius[1] < rel[1] && rel[1] < sPuppyVolumeStack[index]->radius[1] && distCheck) - { + if (-sPuppyVolumeStack[index]->radius[1] < rel[1] && rel[1] < sPuppyVolumeStack[index]->radius[1] && distCheck) { *volume = *sPuppyVolumeStack[index]; return TRUE; } @@ -1135,70 +983,65 @@ static s32 puppycam_check_volume_bounds(struct sPuppyVolume *volume, s32 index) return FALSE; } -//Handles wall adjustment when wall kicking. -void puppycam_wall_angle(void) -{ +// Handles wall adjustment when wall kicking. +void puppycam_wall_angle(void) { struct Surface *wall; struct WallCollisionData cData; s16 wallYaw; - if (!(gMarioState->action & ACT_WALL_KICK_AIR) || ((gMarioState->action & ACT_FLAG_AIR) && ABS(gMarioState->forwardVel) < 16.0f) || !(gMarioState->action & ACT_FLAG_AIR)) + if (!(gMarioState->action & ACT_WALL_KICK_AIR) || ((gMarioState->action & ACT_FLAG_AIR) && ABS(gMarioState->forwardVel) < 16.0f) || !(gMarioState->action & ACT_FLAG_AIR)) { return; - + } cData.x = gPuppyCam.targetObj->oPosX; cData.y = gPuppyCam.targetObj->oPosY; cData.z = gPuppyCam.targetObj->oPosZ; cData.radius = 150.0f; cData.offsetY = 0; - if (find_wall_collisions(&cData)) + if (find_wall_collisions(&cData)) { wall = cData.walls[cData.numWalls - 1]; - else + } else { return; + } wallYaw = atan2s(wall->normal.z, wall->normal.x) + 0x4000; wallYaw -= gPuppyCam.yawTarget; - if (wallYaw % 0x4000) + if (wallYaw % 0x4000) { wallYaw += 0x4000 - wallYaw % 0x4000; - + } gPuppyCam.yawTarget = approach_s32(gPuppyCam.yawTarget, wallYaw, 0x200, 0x200); } -void puppycam_projection_behaviours(void) -{ +void puppycam_projection_behaviours(void) { f32 turnRate = 1; - //This will only be executed if Mario's the target. If it's not, it'll reset the - if (gPuppyCam.targetObj == gMarioState->marioObj) - { + // This will only be executed if Mario's the target. If it's not, it'll reset the + if (gPuppyCam.targetObj == gMarioState->marioObj) { if (gPuppyCam.options.turnAggression > 0 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && - gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) - {//Holy hell this is getting spicy. - //With turn aggression enabled, or if Mario's sliding, adjust the camera view behind mario. - if (gPuppyCam.options.turnAggression > 0 || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) - { - if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) - turnRate = 4; //If he's sliding, do it 4x as fast. - //The deal here, is if Mario's moving, or he's sliding and the camera's within 90 degrees behind him, it'll auto focus behind him, with an intensity based on the camera's centre speed. - //It also scales with forward velocity, so it's a gradual effect as he speeds up. + gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) { // Holy hell this is getting spicy. + // With turn aggression enabled, or if Mario's sliding, adjust the camera view behind mario. + if (gPuppyCam.options.turnAggression > 0 || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) { + if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) { + turnRate = 4; // If he's sliding, do it 4x as fast. + } + // The deal here, is if Mario's moving, or he's sliding and the camera's within 90 degrees behind him, it'll auto focus behind him, with an intensity based on the camera's centre speed. + // It also scales with forward velocity, so it's a gradual effect as he speeds up. if ((ABS(gPlayer1Controller->rawStickX) > 20 && !(gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE)) || (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE && (s16)ABS(((gPuppyCam.yaw + 0x8000) % 0xFFFF - 0x8000) - ((gMarioState->faceAngle[1]) % 0xFFFF - 0x8000)) < 0x3000 )) gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), ((gPuppyCam.options.turnAggression * 10) * ABS(gMarioState->forwardVel / 32) * ABS(gPlayer1Controller->rawStickX / 80.0f) * turnRate)); } - } - else - { //If none of the above is true, it'll attempt to do this instead. - //If the camera's in these modes, snap the yaw to prevent desync. - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) - { - if (gPuppyCam.yawTarget % 0x2000) + } else { //If none of the above is true, it'll attempt to do this instead. + // If the camera's in these modes, snap the yaw to prevent desync. + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) { + if (gPuppyCam.yawTarget % 0x2000) { gPuppyCam.yawTarget += 0x2000 - gPuppyCam.yawTarget % 0x2000; + } } - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) - { - if (gPuppyCam.yawTarget % 0x4000) + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) { + if (gPuppyCam.yawTarget % 0x4000) { gPuppyCam.yawTarget += 0x4000 - gPuppyCam.yawTarget % 0x4000; + } } } @@ -1209,232 +1052,185 @@ void puppycam_projection_behaviours(void) , CLAMP((absf(gMarioState->vel[1]) - 17.f) / 200.f, 0, 0.1f) + CLAMP((absf(gPuppyCam.targetFloorHeight - gPuppyCam.lastTargetFloorHeight) - 30.f) / 300.f, 0, 0.1f)); - if (gMarioState->action == ACT_SLEEPING || gMarioState->action == ACT_START_SLEEPING) + if (gMarioState->action == ACT_SLEEPING || gMarioState->action == ACT_START_SLEEPING) { gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomPoints[0],0.01f); - else - if (gMarioState->action & ACT_FLAG_SWIMMING && gMarioState->waterLevel-100 - gMarioState->pos[1] > 5) - { - //When moving underwater, the camera will zoom in on Mayro. + } else if (gMarioState->action & ACT_FLAG_SWIMMING && gMarioState->waterLevel-100 - gMarioState->pos[1] > 5) { + // When moving underwater, the camera will zoom in on Mayro. gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom, MAX(gPuppyCam.zoomTarget/1.5f, gPuppyCam.zoomPoints[0]), 0.2f); - } - else + } else { gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomTarget,0.2f); - - //Attempts at automatic adjustment that only apply when moving or jumping. - if (gMarioState->action & ACT_FLAG_MOVING || gMarioState->action & ACT_FLAG_AIR || (gMarioState->action & ACT_FLAG_SWIMMING && !gMarioState->waterLevel-100 - gMarioState->pos[1] > 5 && gMarioState->forwardVel != 0.0f)) - { - //Clamp the height when moving. You can still look up and down to a reasonable degree but it readjusts itself the second you let go. - if (gPuppyCam.pitchTarget > 0x3800) - gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x3800, 0.2f); - - if (gPuppyCam.pitchTarget < 0x2000) - gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x2000, 0.2f); + } + // Attempts at automatic adjustment that only apply when moving or jumping. + if (gMarioState->action & ACT_FLAG_MOVING || gMarioState->action & ACT_FLAG_AIR || (gMarioState->action & ACT_FLAG_SWIMMING && !gMarioState->waterLevel-100 - gMarioState->pos[1] > 5 && gMarioState->forwardVel != 0.0f)) { + // Clamp the height when moving. You can still look up and down to a reasonable degree but it readjusts itself the second you let go. + if (gPuppyCam.pitchTarget > 0x3800) gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x3800, 0.2f); + if (gPuppyCam.pitchTarget < 0x2000) gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x2000, 0.2f); } - //Applies a light outward zoom to the camera when moving. Sets it back to 0 when not moving. - if (gMarioState->forwardVel > 0) - { + // Applies a light outward zoom to the camera when moving. Sets it back to 0 when not moving. + if (gMarioState->forwardVel > 0) { gPuppyCam.moveZoom = approach_f32(gPuppyCam.moveZoom, 100.0f*(gMarioState->forwardVel/32.0f), gMarioState->forwardVel/10, gMarioState->forwardVel/10); - } - else - { + } else { gPuppyCam.moveZoom = approach_f32(gPuppyCam.moveZoom, 0, 5, 5); } - //Zooms the camera in further when underwater. - if (gPuppyCam.pitch > 0x38C0 && ABS(gPuppyCam.swimPitch) < 100) - { - gPuppyCam.zoom = approach_f32_asymptotic((f32)gPuppyCam.zoom, 250.0f, CLAMP((f32)((gPuppyCam.pitch-0x38C0)/3072.0f), 0.0f, 1.0f)); + // Zooms the camera in further when underwater. + if (gPuppyCam.pitch > 0x38C0 && ABS(gPuppyCam.swimPitch) < 100) { + gPuppyCam.zoom = approach_f32_asymptotic((f32)gPuppyCam.zoom, 250.0f, CLAMP((f32)((gPuppyCam.pitch - 0x38C0) / 3072.0f), 0.0f, 1.0f)); } - if (!(gMarioState->action & ACT_FLAG_SWIMMING)) - { + if (!(gMarioState->action & ACT_FLAG_SWIMMING)) { gPuppyCam.floorY[0] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 300); gPuppyCam.floorY[1] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 350); gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,0,0.2f); - } - else - { + } else { gPuppyCam.floorY[0] = 0; gPuppyCam.floorY[1] = 0; gPuppyCam.targetFloorHeight = gPuppyCam.targetObj->oPosY; gPuppyCam.lastTargetFloorHeight = gPuppyCam.targetObj->oPosY; gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), (1000 * (gMarioState->forwardVel / 32))); - if (gMarioState->waterLevel-100 - gMarioState->pos[1] > 5 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) - gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,gMarioState->faceAngle[0]/10,0.05f); - else - gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,0,0.2f); + if (gMarioState->waterLevel - 100 - gMarioState->pos[1] > 5 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) { + gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,gMarioState->faceAngle[0] / 10, 0.05f); + } else { + gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch, 0, 0.2f); + } } - //This sets the view offset from Mario. It accentuates a bit further when moving. + // This sets the view offset from Mario. It accentuates a bit further when moving. puppycam_view_panning(); - //This sets a pseudo tilt offset based on the floor heights in front and behind mario. + // This sets a pseudo tilt offset based on the floor heights in front and behind mario. puppycam_terrain_angle(); - //This will shift the intended yaw when wall kicking, to align with the wall being kicked. - //puppycam_wall_angle(); - } - else - { + // This will shift the intended yaw when wall kicking, to align with the wall being kicked. + // puppycam_wall_angle(); + } else { puppycam_reset_values(); } } -void puppycam_shake(UNUSED s16 x, UNUSED s16 y, UNUSED s16 z) -{ +void puppycam_shake(UNUSED s16 x, UNUSED s16 y, UNUSED s16 z) { } -///This is the highest level of the basic steps that go into the code. Anything above is called from these following functions. +/// This is the highest level of the basic steps that go into the code. Anything above is called from these following functions. -//The centrepiece behind the input side of PuppyCam. The C buttons branch off. -static void puppycam_input_core(void) -{ +// The centrepiece behind the input side of PuppyCam. The C buttons branch off. +static void puppycam_input_core(void) { puppycam_analogue_stick(); gPuppyCam.moveFlagAdd = 0; - //Decide which input for left and right C buttons to use based on behaviour type. - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_NORMAL || gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) + // Decide which input for left and right C buttons to use based on behaviour type. + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_NORMAL || gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) { puppycam_input_hold(); - else - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR || gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) + } else if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR || gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) { puppycam_input_press(); + } } -//Calculates the base position the camera should be, before any modification. -static void puppycam_projection(void) -{ +// Calculates the base position the camera should be, before any modification. +static void puppycam_projection(void) { Vec3s targetPos, targetPos2, targetPos3; s16 pitchTotal; - s32 panD = (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT)/8192; + s32 panD = (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT) / 8192; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) - { + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) { puppycam_reset_values(); puppycam_debug_view(); return; } - //Extra behaviours that get tacked onto the projection. Will be completely ignored if there is no target object. + // Extra behaviours that get tacked onto the projection. Will be completely ignored if there is no target object. puppycam_projection_behaviours(); - //These are what the base rotations aspire to be. - gPuppyCam.pitch = CLAMP(gPuppyCam.pitch,0x1000,0x7000); - gPuppyCam.pitchTarget = CLAMP(gPuppyCam.pitchTarget,0x1000,0x7000); - //These are the base rotations going to be used. - gPuppyCam.yaw = gPuppyCam.yawTarget - approach_f32_asymptotic((s16)(gPuppyCam.yawTarget - gPuppyCam.yaw), 0, 0.3335f); + // These are what the base rotations aspire to be. + gPuppyCam.pitch = CLAMP(gPuppyCam.pitch, 0x1000, 0x7000); + gPuppyCam.pitchTarget = CLAMP(gPuppyCam.pitchTarget, 0x1000, 0x7000); + // These are the base rotations going to be used. + gPuppyCam.yaw = gPuppyCam.yawTarget - approach_f32_asymptotic((s16)(gPuppyCam.yawTarget - gPuppyCam.yaw ), 0, 0.3335f); gPuppyCam.pitch = gPuppyCam.pitchTarget - approach_f32_asymptotic((s16)(gPuppyCam.pitchTarget - gPuppyCam.pitch), 0, 0.3335f); - //This adds the pitch effect when underwater, which is capped so it doesn't get out of control. If you're not swimming, swimpitch is 0, so it's normal. + // This adds the pitch effect when underwater, which is capped so it doesn't get out of control. If you're not swimming, swimpitch is 0, so it's normal. pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10)+gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800); - if (gPuppyCam.targetObj) - { + if (gPuppyCam.targetObj) { vec3s_set(targetPos, gPuppyCam.targetObj->oPosX, gPuppyCam.targetObj->oPosY, gPuppyCam.targetObj->oPosZ); vec3s_copy(targetPos3, targetPos); - if (gPuppyCam.targetObj2) - { + if (gPuppyCam.targetObj2) { vec3s_set(targetPos2, gPuppyCam.targetObj2->oPosX, gPuppyCam.targetObj2->oPosY, gPuppyCam.targetObj2->oPosZ); targetPos3[0] = (s16)approach_f32_asymptotic(targetPos[0], targetPos2[0], 0.5f); targetPos3[1] = (s16)approach_f32_asymptotic(targetPos[1], targetPos2[1], 0.5f); targetPos3[2] = (s16)approach_f32_asymptotic(targetPos[2], targetPos2[2], 0.5f); gPuppyCam.targetDist[0] = approach_f32_asymptotic(gPuppyCam.targetDist[0],(ABS(LENCOS(sqrtf(((targetPos[0]-targetPos2[0])*(targetPos[0]-targetPos2[0]))+((targetPos[2]-targetPos2[2])*(targetPos[2]-targetPos2[2]))), (s16)ABS(((gPuppyCam.yaw + 0x8000) % 0xFFFF - 0x8000) - (atan2s(targetPos[2]-targetPos2[2], targetPos[0]-targetPos2[0])) % 0xFFFF - 0x8000)+0x4000))), 0.2f); - } - else - { + } else { gPuppyCam.targetDist[0] = approach_f32_asymptotic(gPuppyCam.targetDist[0], 0, 0.2f); } gPuppyCam.targetDist[1] = gPuppyCam.targetDist[0] + gPuppyCam.zoom+gPuppyCam.moveZoom; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) - gPuppyCam.focus[0] = targetPos3[0] + gPuppyCam.shake[0] + (gPuppyCam.pan[0]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2])*panD; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT) - gPuppyCam.focus[1] = targetPos3[1] + gPuppyCam.shake[1] + (gPuppyCam.pan[1]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2]) + gPuppyCam.povHeight - gPuppyCam.floorY[0] + (gPuppyCam.swimPitch/10); - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) - gPuppyCam.focus[2] = targetPos3[2] + gPuppyCam.shake[2] + (gPuppyCam.pan[2]*gPuppyCam.targetDist[1]/gPuppyCam.zoomPoints[2])*panD; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) gPuppyCam.focus[0] = targetPos3[0] + gPuppyCam.shake[0] + (gPuppyCam.pan[0] * gPuppyCam.targetDist[1] / gPuppyCam.zoomPoints[2]) * panD; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT) gPuppyCam.focus[1] = targetPos3[1] + gPuppyCam.shake[1] + (gPuppyCam.pan[1] * gPuppyCam.targetDist[1] / gPuppyCam.zoomPoints[2]) + gPuppyCam.povHeight - gPuppyCam.floorY[0] + (gPuppyCam.swimPitch / 10); + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) gPuppyCam.focus[2] = targetPos3[2] + gPuppyCam.shake[2] + (gPuppyCam.pan[2] * gPuppyCam.targetDist[1] / gPuppyCam.zoomPoints[2]) * panD; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) - gPuppyCam.pos[0] = gPuppyCam.targetObj->oPosX + LENSIN(LENSIN(gPuppyCam.targetDist[1],pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[0]; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT) - gPuppyCam.pos[1] = gPuppyCam.targetObj->oPosY + gPuppyCam.povHeight + LENCOS(gPuppyCam.targetDist[1],pitchTotal) + gPuppyCam.shake[1] - gPuppyCam.floorY[1]; - if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) - gPuppyCam.pos[2] = gPuppyCam.targetObj->oPosZ + LENCOS(LENSIN(gPuppyCam.targetDist[1],pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[2]; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) gPuppyCam.pos[0] = gPuppyCam.targetObj->oPosX + LENSIN(LENSIN(gPuppyCam.targetDist[1], pitchTotal), gPuppyCam.yaw) + gPuppyCam.shake[0]; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT) gPuppyCam.pos[1] = gPuppyCam.targetObj->oPosY + gPuppyCam.povHeight + LENCOS(gPuppyCam.targetDist[1], pitchTotal) + gPuppyCam.shake[1] - gPuppyCam.floorY[1]; + if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) gPuppyCam.pos[2] = gPuppyCam.targetObj->oPosZ + LENCOS(LENSIN(gPuppyCam.targetDist[1], pitchTotal), gPuppyCam.yaw) + gPuppyCam.shake[2]; } } -//Calls any scripts to affect the camera, if applicable. -static void puppycam_script(void) -{ +// Calls any scripts to affect the camera, if applicable. +static void puppycam_script(void) { u16 i = 0; struct sPuppyVolume volume; - if (gPuppyVolumeCount == 0 || !gPuppyCam.targetObj) + if (gPuppyVolumeCount == 0 || !gPuppyCam.targetObj) { return; + } + for (i = 0; i < gPuppyVolumeCount; i++) { + if (puppycam_check_volume_bounds(&volume, i)) { + // First applies pos and focus, for the most basic of volumes. + if (volume.angles != NULL) { + if (volume.angles->pos[0] != PUPPY_NULL) gPuppyCam.pos[0] = volume.angles->pos[0]; + if (volume.angles->pos[1] != PUPPY_NULL) gPuppyCam.pos[1] = volume.angles->pos[1]; + if (volume.angles->pos[2] != PUPPY_NULL) gPuppyCam.pos[2] = volume.angles->pos[2]; - for (i = 0; i < gPuppyVolumeCount; i++) - { - if (puppycam_check_volume_bounds(&volume, i)) - { - //First applies pos and focus, for the most basic of volumes. - if (volume.angles != NULL) - { - if (volume.angles->pos[0] != PUPPY_NULL) - gPuppyCam.pos[0] = volume.angles->pos[0]; - if (volume.angles->pos[1] != PUPPY_NULL) - gPuppyCam.pos[1] = volume.angles->pos[1]; - if (volume.angles->pos[2] != PUPPY_NULL) - gPuppyCam.pos[2] = volume.angles->pos[2]; + if (volume.angles->focus[0] != PUPPY_NULL) gPuppyCam.focus[0] = volume.angles->focus[0]; + if (volume.angles->focus[1] != PUPPY_NULL) gPuppyCam.focus[1] = volume.angles->focus[1]; + if (volume.angles->focus[2] != PUPPY_NULL) gPuppyCam.focus[2] = volume.angles->focus[2]; - if (volume.angles->focus[0] != PUPPY_NULL) - gPuppyCam.focus[0] = volume.angles->focus[0]; - if (volume.angles->focus[1] != PUPPY_NULL) - gPuppyCam.focus[1] = volume.angles->focus[1]; - if (volume.angles->focus[2] != PUPPY_NULL) - gPuppyCam.focus[2] = volume.angles->focus[2]; - - if (volume.angles->yaw != PUPPY_NULL) - { + if (volume.angles->yaw != PUPPY_NULL) { gPuppyCam.yawTarget = volume.angles->yaw; - gPuppyCam.yaw = volume.angles->yaw; + gPuppyCam.yaw = volume.angles->yaw; gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_YAW_ROTATION; } - if (volume.angles->pitch != PUPPY_NULL) - { + if (volume.angles->pitch != PUPPY_NULL) { gPuppyCam.pitchTarget = volume.angles->pitch; - gPuppyCam.pitch = volume.angles->pitch; + gPuppyCam.pitch = volume.angles->pitch; gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_PITCH_ROTATION; } - if (volume.angles->zoom != PUPPY_NULL) - { + if (volume.angles->zoom != PUPPY_NULL) { gPuppyCam.zoomTarget = volume.angles->zoom; - gPuppyCam.zoom = gPuppyCam.zoomTarget; + gPuppyCam.zoom = gPuppyCam.zoomTarget; gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE; } } - //Adds and removes behaviour flags, as set. - if (volume.flagsRemove) - gPuppyCam.flags &= ~volume.flagsRemove; - if (volume.flagsAdd) - gPuppyCam.flags |= volume.flagsAdd; - if (volume.flagPersistance == PUPPYCAM_BEHAVIOUR_PERMANENT) - { - //Adds and removes behaviour flags, as set. - if (volume.flagsRemove) - gPuppyCam.intendedFlags &= ~volume.flagsRemove; - if (volume.flagsAdd) - gPuppyCam.intendedFlags |= volume.flagsAdd; + // Adds and removes behaviour flags, as set. + if (volume.flagsRemove) gPuppyCam.flags &= ~volume.flagsRemove; + if (volume.flagsAdd ) gPuppyCam.flags |= volume.flagsAdd; + if (volume.flagPersistance == PUPPYCAM_BEHAVIOUR_PERMANENT) { + // Adds and removes behaviour flags, as set. + if (volume.flagsRemove) gPuppyCam.intendedFlags &= ~volume.flagsRemove; + if (volume.flagsAdd ) gPuppyCam.intendedFlags |= volume.flagsAdd; } - //Last and probably least, check if there's a function attached, and call it, if so. + // Last and probably least, check if there's a function attached, and call it, if so. if (volume.func) { (volume.func)(); } @@ -1443,35 +1239,32 @@ static void puppycam_script(void) } //Handles collision detection using ray casting. -static void puppycam_collision(void) -{ +static void puppycam_collision(void) { struct WallCollisionData wall0, wall1; struct Surface *surf[2]; Vec3f camdir[2]; Vec3f hitpos[2]; Vec3f target[2]; - s16 pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10) + gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800); + s16 pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch * 10) + gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800); s32 dist[2]; - if (gPuppyCam.targetObj == NULL) + if (gPuppyCam.targetObj == NULL) { return; - - //The ray, starting from the top + } + // The ray, starting from the top target[0][0] = gPuppyCam.targetObj->oPosX; target[0][1] = gPuppyCam.targetObj->oPosY + (gPuppyCam.povHeight) - CLAMP(gPuppyCam.targetObj->oPosY - gPuppyCam.targetFloorHeight, 0, 300); target[0][2] = gPuppyCam.targetObj->oPosZ; - //The ray, starting from the bottom + // The ray, starting from the bottom target[1][0] = gPuppyCam.targetObj->oPosX; - target[1][1] = gPuppyCam.targetObj->oPosY + (gPuppyCam.povHeight *0.4f); + target[1][1] = gPuppyCam.targetObj->oPosY + (gPuppyCam.povHeight * 0.4f); target[1][2] = gPuppyCam.targetObj->oPosZ; camdir[0][0] = LENSIN(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[0]; camdir[0][1] = LENCOS(gPuppyCam.zoomTarget,pitchTotal) + gPuppyCam.shake[1]; camdir[0][2] = LENCOS(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[2]; - camdir[1][0] = camdir[0][0]; - camdir[1][1] = camdir[0][1]; - camdir[1][2] = camdir[0][2]; + vec3_copy(camdir[1], camdir[0]); find_surface_on_ray(target[0], camdir[0], &surf[0], hitpos[0], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL); find_surface_on_ray(target[1], camdir[1], &surf[1], hitpos[1], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL); @@ -1482,97 +1275,80 @@ static void puppycam_collision(void) gPuppyCam.collisionDistance = gPuppyCam.zoomTarget; - if (surf[0] && surf[1]) - { + if (surf[0] && surf[1]) { gPuppyCam.collisionDistance = sqrtf(MAX(dist[0], dist[1])); - if (gPuppyCam.zoom > gPuppyCam.collisionDistance) - { + if (gPuppyCam.zoom > gPuppyCam.collisionDistance) { gPuppyCam.zoom = MIN(gPuppyCam.collisionDistance, gPuppyCam.zoomTarget); - if (gPuppyCam.zoom - gPuppyCam.zoomTarget < 5) - { - if (dist[0] >= dist[1]) - { - gPuppyCam.pos[0] = hitpos[0][0]; - gPuppyCam.pos[1] = hitpos[0][1]; - gPuppyCam.pos[2] = hitpos[0][2]; - } - else - { + if (gPuppyCam.zoom - gPuppyCam.zoomTarget < 5) { + if (dist[0] >= dist[1]) { + vec3_copy(gPuppyCam.pos, hitpos[0]); + } else { gPuppyCam.pos[0] = hitpos[1][0]; - gPuppyCam.pos[1] = hitpos[1][1] + (gPuppyCam.povHeight*0.6f); + gPuppyCam.pos[1] = hitpos[1][1] + (gPuppyCam.povHeight * 0.6f); gPuppyCam.pos[2] = hitpos[1][2]; } } } } - #define START_DIST 500 - #define END_DIST 250 - gPuppyCam.opacity = CLAMP((f32)(((gPuppyCam.zoom-END_DIST)/255.0f)*(START_DIST-END_DIST)), 0, 255); + #define END_DIST 250 + gPuppyCam.opacity = CLAMP((f32)(((gPuppyCam.zoom - END_DIST) / 255.0f) * (START_DIST - END_DIST)), 0, 255); } extern Vec3f sOldPosition; extern Vec3f sOldFocus; extern struct PlayerGeometry sMarioGeometry; -//Applies the PuppyCam values to the actual game's camera, giving the final product. -static void puppycam_apply(void) -{ - vec3f_set(gLakituState.pos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); - vec3f_set(gLakituState.goalPos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); - vec3f_set(gLakituState.curPos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); - vec3f_set(gCamera->pos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); - vec3f_set(sOldPosition, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); +// Applies the PuppyCam values to the actual game's camera, giving the final product. +static void puppycam_apply(void) { + vec3f_set(gLakituState.pos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); + vec3f_set(gLakituState.goalPos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); + vec3f_set(gLakituState.curPos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); + vec3f_set(gCamera->pos, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); + vec3f_set(sOldPosition, (f32)gPuppyCam.pos[0], (f32)gPuppyCam.pos[1], (f32)gPuppyCam.pos[2]); - vec3f_set(gLakituState.focus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); + vec3f_set(gLakituState.focus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); vec3f_set(gLakituState.goalFocus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); - vec3f_set(gLakituState.curFocus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); - vec3f_set(gCamera->focus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); - vec3f_set(sOldFocus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); + vec3f_set(gLakituState.curFocus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); + vec3f_set(gCamera->focus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); + vec3f_set(sOldFocus, (f32)gPuppyCam.focus[0], (f32)gPuppyCam.focus[1], (f32)gPuppyCam.focus[2]); - gCamera->yaw = gPuppyCam.yaw; - gCamera->nextYaw = gPuppyCam.yaw; + gCamera->yaw = gPuppyCam.yaw; + gCamera->nextYaw = gPuppyCam.yaw; - gLakituState.yaw = gPuppyCam.yaw; + gLakituState.yaw = gPuppyCam.yaw; gLakituState.nextYaw = gPuppyCam.yaw; - gLakituState.oldYaw = gPuppyCam.yaw; + gLakituState.oldYaw = gPuppyCam.yaw; - gLakituState.mode = gCamera->mode; + gLakituState.mode = gCamera->mode; gLakituState.defMode = gCamera->defMode; - gLakituState.roll = approach_s32(gLakituState.roll, 0, 0x80, 0x80); + gLakituState.roll = approach_s32(gLakituState.roll, 0, 0x80, 0x80); - //Commented out simply because vanilla SM64 has this always set sometimes, and relies on certain camera modes to apply secondary foci. - //Uncomment to have fun with certain angles. - /*if (gSecondCameraFocus != NULL) - { + // Commented out simply because vanilla SM64 has this always set sometimes, and relies on certain camera modes to apply secondary foci. + // Uncomment to have fun with certain angles. + /*if (gSecondCameraFocus != NULL) { gPuppyCam.targetObj2 = gSecondCameraFocus; - } - else - { + } else { gPuppyCam.targetObj2 = NULL; }*/ - if (gMarioState->floor != NULL) - { - sMarioGeometry.currFloor = gMarioState->floor; + if (gMarioState->floor != NULL) { + sMarioGeometry.currFloor = gMarioState->floor; sMarioGeometry.currFloorHeight = gMarioState->floorHeight; - sMarioGeometry.currFloorType = gMarioState->floor->type; + sMarioGeometry.currFloorType = gMarioState->floor->type; } - if (gMarioState->ceil != NULL) - { - sMarioGeometry.currCeil = gMarioState->ceil; - sMarioGeometry.currCeilHeight = gMarioState->ceilHeight; - sMarioGeometry.currCeilType = gMarioState->ceil->type; + if (gMarioState->ceil != NULL) { + sMarioGeometry.currCeil = gMarioState->ceil; + sMarioGeometry.currCeilHeight = gMarioState->ceilHeight; + sMarioGeometry.currCeilType = gMarioState->ceil->type; } } -//The basic loop sequence, which is called outside. -void puppycam_loop(void) -{ - if (!gPuppyCam.cutscene && sDelayedWarpOp == 0) - { - //Sets this before going through any possible modifications. +// The basic loop sequence, which is called outside. +void puppycam_loop(void) { + if (!gPuppyCam.cutscene && sDelayedWarpOp == 0) { + // Sets this before going through any possible modifications. gPuppyCam.flags = gPuppyCam.intendedFlags; puppycam_input_core(); puppycam_projection(); @@ -1581,10 +1357,7 @@ void puppycam_loop(void) puppycam_collision(); else gPuppyCam.opacity = 255; - } - else - if (gPuppyCam.cutscene) - { + } else if (gPuppyCam.cutscene) { gPuppyCam.opacity = 255; puppycam_process_cutscene(); } diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index 6a60b716..351cddcc 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -220,8 +220,7 @@ struct Object *allocate_object(struct ObjectNode *objList) { // If no unimportant object exists, then the object pool is exhausted. if (unimportantObj == NULL) { // We've met with a terrible fate. - while (TRUE) { - } + while (TRUE) {} } else { // If an unimportant object does exist, unload it and take its slot. unload_object(unimportantObj); diff --git a/src/goddard/renderer.c b/src/goddard/renderer.c index 5de01758..84044e6c 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -3018,7 +3018,7 @@ void Unknown801A5D90(struct ObjGroup *arg0) { sp23C = FALSE; for (;;) { - trackerNum += 1; + trackerNum++; mt = get_memtracker_by_index(trackerNum); if (mt->name != NULL) { diff --git a/src/goddard/shape_helper.c b/src/goddard/shape_helper.c index 744da1d4..8fa835c0 100644 --- a/src/goddard/shape_helper.c +++ b/src/goddard/shape_helper.c @@ -1181,7 +1181,7 @@ void animate_mario_head_normal(struct ObjAnimator *self) { if (self->frame == 810.0f) { self->frame = 750.0f; - self->nods -= 1; + self->nods--; if (self->nods == 0) { state = 3; } diff --git a/src/menu/file_select.c b/src/menu/file_select.c index f8da9958..dad6024d 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -2319,7 +2319,7 @@ void print_file_select_strings(void) { sTextBaseAlpha += 10; } if (sMainMenuTimer < 1000) { - sMainMenuTimer += 1; + sMainMenuTimer++; } }