diff --git a/src/main/1EC20.c b/src/main/1EC20.c index d6f44990f..9e04b38ed 100644 --- a/src/main/1EC20.c +++ b/src/main/1EC20.c @@ -237,8 +237,8 @@ void func_8002ED80(struct EngineObj* arg0) void func_8002ED98(struct EngineObj* arg0) { func_800129F0(8); - arg0->unk2 = 0; arg0->unk1++; + arg0->unk2 = 0; } // engine_state_3_update_funcs state 7 diff --git a/src/main/1FD10.c b/src/main/1FD10.c index 4dcc697fd..e4037154c 100644 --- a/src/main/1FD10.c +++ b/src/main/1FD10.c @@ -2,8 +2,8 @@ void func_8002F510(struct EngineObj* arg0) { - arg0->unk3 = 0; arg0->unk2++; + arg0->unk3 = 0; } void func_8002F524(struct EngineObj* arg0) diff --git a/src/main/background.c b/src/main/background.c index 8e7622d49..40325facb 100644 --- a/src/main/background.c +++ b/src/main/background.c @@ -58,18 +58,18 @@ void func_80027850(void) void func_80027908(struct BackgroundObj* arg0) { - arg0->unk47 = 2; - arg0->unk48 = 8; - arg0->unk2C = 0x60; - arg0->unk2E = 0xC0; - arg0->unk30 = 0xA0; - arg0->unk32 = 0xA0; arg0->unk14.val = arg0->x_pos.val; arg0->unk18.val = arg0->y_pos.val; arg0->unk24 = arg0->unk1C; arg0->unk26 = arg0->unk1E; arg0->unk28 = arg0->unk20; arg0->unk2A = arg0->unk22; + arg0->unk47 = 2; + arg0->unk48 = 8; + arg0->unk2C = 0x60; + arg0->unk2E = 0xC0; + arg0->unk30 = 0xA0; + arg0->unk32 = 0xA0; arg0->unk4++; } diff --git a/src/main/character_select.c b/src/main/character_select.c index f61775aa7..cb5db84eb 100644 --- a/src/main/character_select.c +++ b/src/main/character_select.c @@ -173,9 +173,9 @@ void character_select_state_4(struct EngineObj* arg0) arg0->character_state.bytes[1] |= 0x80; } } else if (!(arg0->character_state.bytes[1] & 0x7F)) { + arg0->unk1++; arg0->unk2 = 0; arg0->unk4 = 20; // how long to wait on green background before fading out - arg0->unk1++; } } diff --git a/src/main/effects/effect_24_boss_warning.c b/src/main/effects/effect_24_boss_warning.c index 8b1a5df2f..0ea1fa734 100644 --- a/src/main/effects/effect_24_boss_warning.c +++ b/src/main/effects/effect_24_boss_warning.c @@ -50,10 +50,11 @@ void boss_warning_advance_tiles(struct EffectObj* self) effect = boss_warning_tiles[self->ext.effect_24.unk1B]; effect->unk5++; - if (++self->ext.effect_24.unk1B == 0x16) { + self->ext.effect_24.unk1B++; + if (self->ext.effect_24.unk1B == 0x16) { old_unk5 = self->unk5; - self->ext.effect_24.timer = 0x3C; self->unk5 = old_unk5 + 1; + self->ext.effect_24.timer = 0x3C; if (engine_obj.stage == 0) { func_8001653C(); } diff --git a/src/main/game_info.c b/src/main/game_info.c index a67cfb1e3..2b1c4cbc8 100644 --- a/src/main/game_info.c +++ b/src/main/game_info.c @@ -429,7 +429,8 @@ void func_8001D698(struct GameInfo* arg0) arg0->mode = 0; arg0->unk2 = 0; arg0->unk3 = 0; - if (++arg0->unkC == 4) { + arg0->unkC++; + if (arg0->unkC == 4) { arg0->unkC = 0; } } diff --git a/src/main/items/item_19_data_capsule.c b/src/main/items/item_19_data_capsule.c index 631f7a381..75f8f5edd 100644 --- a/src/main/items/item_19_data_capsule.c +++ b/src/main/items/item_19_data_capsule.c @@ -52,10 +52,12 @@ void data_capsule_idle(struct ItemObj* arg0) void data_capsule_attached_init(struct ItemObj* arg0) { arg0->state = 1; - arg0->on_screen = 1; arg0->unk5 = 0; arg0->unk6 = 0; arg0->unk7 = 0; + arg0->on_screen = 1; + arg0->unk18.val = arg0->x_pos.val; + arg0->unk1C.val = arg0->y_pos.val; arg0->unk54 = 0; arg0->unk50 = 0; arg0->unk68 = NULL; @@ -67,8 +69,6 @@ void data_capsule_attached_init(struct ItemObj* arg0) arg0->unk28 = 0; arg0->unk2C = 0; arg0->unk16 = 4; - arg0->unk18.val = arg0->x_pos.val; - arg0->unk1C.val = arg0->y_pos.val; set_animation(arg0, 1); } diff --git a/src/main/layers/layer_04_volcano_camera.c b/src/main/layers/layer_04_volcano_camera.c index 40b6db9c1..f64e50925 100644 --- a/src/main/layers/layer_04_volcano_camera.c +++ b/src/main/layers/layer_04_volcano_camera.c @@ -16,9 +16,9 @@ void volcano_camera_update(struct LayerObj* arg0) void volcano_camera_init(struct LayerObj* arg0) { + arg0->state++; arg0->unk5 = 1; arg0->bg_offset = 2; - arg0->state++; background_objects[0].unk2E = 0xA0; background_objects[0].unk2C = 0x50; volcano_camera_main(arg0); diff --git a/src/main/mains/main_02_item_carrier.c b/src/main/mains/main_02_item_carrier.c index 8bb8baca1..4e898316b 100644 --- a/src/main/mains/main_02_item_carrier.c +++ b/src/main/mains/main_02_item_carrier.c @@ -208,11 +208,10 @@ void item_carrier_leave_start(struct MainObj* self) { if ((self->y_pos.val > g_Player.y_pos.val)) { self->unk6 = 1; - self->unk7 = 0; } else { self->unk6 = 2; - self->unk7 = 0; } + self->unk7 = 0; } void item_carrier_leave_up(struct MainObj* self) diff --git a/src/main/mains/main_04_drill_copter.c b/src/main/mains/main_04_drill_copter.c index fbbf8c7ed..44f3e0c9b 100644 --- a/src/main/mains/main_04_drill_copter.c +++ b/src/main/mains/main_04_drill_copter.c @@ -120,9 +120,9 @@ void drill_copter_drop(struct MainObj* self) void drill_copter_drop_start(struct MainObj* self) { + self->unk6++; self->unk7C = 0x1E; self->air_state = -1; - self->unk6++; set_animation(self, 4); func_8001540C(2, 8, self); } diff --git a/src/main/mains/main_08_eregion.c b/src/main/mains/main_08_eregion.c index 25d8e62ae..50c6d6cd0 100644 --- a/src/main/mains/main_08_eregion.c +++ b/src/main/mains/main_08_eregion.c @@ -497,8 +497,8 @@ void eregion_recoil_start(struct MainObj* self) set_animation(self, 0xA); self->x_speed = self->x_pos.i.hi; if (self->animation_step.fields.frame_index == 0x1C || self->animation_step.fields.frame_index == 0x1D) { - s32 x_speed = (s16)self->x_speed; - self->x_pos.i.hi = self->unk15 != 0 ? x_speed - 0x16 : x_speed + 0x16; + s16 x_speed = self->x_speed; + self->x_pos.i.hi = x_speed + (self->unk15 != 0 ? -0x16 : 0x16); } } diff --git a/src/main/mains/main_34_highway_trooper.c b/src/main/mains/main_34_highway_trooper.c index 6a65b2cbe..25c36d342 100644 --- a/src/main/mains/main_34_highway_trooper.c +++ b/src/main/mains/main_34_highway_trooper.c @@ -81,7 +81,7 @@ void highway_trooper_attack_fire(struct MainObj* self) void highway_trooper_attack_ready_jump(struct MainObj* self) { if (self->animation_step.fields.event == 2) { - if (self->unk2 == self->animation_step.fields.event) { + if (self->unk2 == 2) { self->terrain_box = &highway_trooper_terrain_box; } self->unk6++; diff --git a/src/main/mains/main_49_train_soldier.c b/src/main/mains/main_49_train_soldier.c index e0dc8ff7e..271263c33 100644 --- a/src/main/mains/main_49_train_soldier.c +++ b/src/main/mains/main_49_train_soldier.c @@ -58,10 +58,7 @@ void train_soldier_despawn(struct MainObj* self) { if (SP_CUR_MAIN_OBJ->ext.main_49.unk86 == 0) { despawn_object(OBJECT_HEADER(self)); - return; - } - - if (self->unk2 == 9) { + } else if (self->unk2 == 9) { despawn_object(OBJECT_HEADER(self)); } else { despawn_object_permanently(OBJECT_HEADER(self)); diff --git a/src/main/mains/main_56_jet_stingray.c b/src/main/mains/main_56_jet_stingray.c index 566f8c570..bd7e6f6aa 100644 --- a/src/main/mains/main_56_jet_stingray.c +++ b/src/main/mains/main_56_jet_stingray.c @@ -673,10 +673,10 @@ void jet_stingray_leap_start(struct MainObj* self) void jet_stingray_leap_fall(struct MainObj* self) { if (self->y_speed > 0) { - self->y_speed = 0; - self->gravity = -FIXED(0.8125); self->unk6++; self->ext.main_56.flags &= ~2; + self->y_speed = 0; + self->gravity = -FIXED(0.8125); } } diff --git a/src/main/mains/main_57_frost_walrus.c b/src/main/mains/main_57_frost_walrus.c index d119ea88d..e8dd4db5c 100644 --- a/src/main/mains/main_57_frost_walrus.c +++ b/src/main/mains/main_57_frost_walrus.c @@ -664,7 +664,7 @@ void frost_walrus_breath_launch(struct MainObj* self) { animate_object(ANIMATED_OBJECT(self)); if (self->animation_step.fields.event == 1) { - self->ext.main_57.shot->unk8C.word = self->animation_step.fields.event; + self->ext.main_57.shot->unk8C.word = 1; spawn_debris(0xA, frost_walrus_breath_debris, self->ext.main_57.shot); } if (self->animation_step.fields.event == 2) { diff --git a/src/main/mains/main_60_storm_owl.c b/src/main/mains/main_60_storm_owl.c index 36e0e97f5..2f40058fe 100644 --- a/src/main/mains/main_60_storm_owl.c +++ b/src/main/mains/main_60_storm_owl.c @@ -563,10 +563,10 @@ void storm_owl_feather_volley_start(struct MainObj* self) { animate_object(ANIMATED_OBJECT(self)); set_animation(self, 3); + self->unk15 = self->ext.main_60.corner >= 2 ? 0 : 0x40; self->unk7C = 0x1C; self->collision_data = (const u16*)D_80107B78; self->ext.main_60.shot_count = 0; - self->unk15 = self->ext.main_60.corner < 2 ? 0x40 : 0; self->unk6++; } diff --git a/src/main/mains/main_61_split_mushroom.c b/src/main/mains/main_61_split_mushroom.c index aae24bddb..480c41dd4 100644 --- a/src/main/mains/main_61_split_mushroom.c +++ b/src/main/mains/main_61_split_mushroom.c @@ -483,10 +483,8 @@ void split_mushroom_spore_rain_recover(struct MainObj* self) void split_mushroom_spore_rain_finish(struct MainObj* self) { - u16 timer; animate_object(ANIMATED_OBJECT(self)); - timer = --self->unk7C; - if ((timer << 16) == 0) { + if (--self->unk7C == 0) { self->y_speed = 0; if (self->unk2 == 0) { self->unk7C = 6; diff --git a/src/main/mains/main_64_cyber_peacock.c b/src/main/mains/main_64_cyber_peacock.c index 09c37a415..dd764b9dc 100644 --- a/src/main/mains/main_64_cyber_peacock.c +++ b/src/main/mains/main_64_cyber_peacock.c @@ -181,8 +181,8 @@ void cyber_peacock_start_teleport(struct MainObj* self) void cyber_peacock_teleport_start(struct MainObj* self) { cyber_peacock_start_teleport(self); - self->unk7 = 0; self->unk6++; + self->unk7 = 0; set_animation(self, 2); self->ext.main_64.skip_attack = 0; } diff --git a/src/main/mains/main_68_sigma.c b/src/main/mains/main_68_sigma.c index 2f02deffd..718b0e803 100644 --- a/src/main/mains/main_68_sigma.c +++ b/src/main/mains/main_68_sigma.c @@ -898,8 +898,8 @@ void sigma_death(struct MainObj* self) void sigma_cloak_stagger_start(struct MainObj* self) { - self->unk42 &= 0x7FFF; self->unk4B = -1; + self->unk42 &= 0x7FFF; self->unk5++; self->unk7C = 0x40; self->unk7E = 4; @@ -947,11 +947,8 @@ void sigma_cloak_stagger_fade(struct MainObj* self) void sigma_cloak_stagger_finish(struct MainObj* self) { - s16 timer = self->unk7C; self->on_screen = 0; - timer--; - self->unk7C = timer; - if (timer == 0) { + if (--self->unk7C == 0) { self->state = 1; self->unk5 = 2; self->unk6 = 0; @@ -1055,18 +1052,18 @@ void sigma_reveal_dialogue(struct MainObj* self) void sigma_reveal_fill_health(struct MainObj* self) { - u16 temp_v0; + s16 temp_v0; if (self->hp < 0x30) { temp_v0 = --self->unk7C; - if ((temp_v0 << 0x10) == 0) { + if (temp_v0 == 0) { func_8001540C(0, 0xE, 0); self->unk7C = 2; } self->hp = (s8)((u8)self->hp + 1); } else { - self->unk7C = 0x5A; self->unk5 = (s8)((u8)self->unk5 + 1); + self->unk7C = 0x5A; } is_on_screen(BASE_OBJECT(self)); } diff --git a/src/main/mains/main_69_colonel.c b/src/main/mains/main_69_colonel.c index 56316cc77..712b721f7 100644 --- a/src/main/mains/main_69_colonel.c +++ b/src/main/mains/main_69_colonel.c @@ -20,11 +20,9 @@ void colonel_spawn(struct MainObj* self) void colonel_spawn_warning(struct MainObj* self) { struct EffectObj* effect; - u8 value; - value = self->unk2; - self->ext.main_69.state.bytes.variant = value; - if (value == 1) { + self->ext.main_69.state.bytes.variant = self->unk2; + if (self->ext.main_69.state.bytes.variant == 1) { self->unk5++; } else { effect = find_free_effect_obj(); diff --git a/src/main/mains/main_72_unused_ride_armor.c b/src/main/mains/main_72_unused_ride_armor.c index 8cb2e7500..53d463913 100644 --- a/src/main/mains/main_72_unused_ride_armor.c +++ b/src/main/mains/main_72_unused_ride_armor.c @@ -5,33 +5,28 @@ void unused_ride_armor_init(struct MainObj* self) { - s32 x_pos; - s32 y_pos; - - x_pos = self->x_pos.val; - y_pos = self->y_pos.val; self->state = 1; self->unk5 = 2; + self->unk6 = 0; + self->unk7 = 0; + self->unk7C = 0; + self->on_screen = 0; self->hp = 0x18; self->contact_damage = 6; + self->invincibility_timer = 0; + self->unk18.val = self->x_pos.val; + self->unk1C.val = self->y_pos.val; self->animation_table = (const u8* const*)unused_ride_armor_animations; self->hurt_box = (const u8*)&unused_ride_armor_hit_box; self->attack_box = (const u8*)&unused_ride_armor_hit_box; self->terrain_box = &unused_ride_armor_terrain_box; self->collision_data = (const u16*)D_80108184; - self->unk6 = 0; - self->unk7 = 0; - self->unk7C = 0; - self->on_screen = 0; - self->invincibility_timer = 0; self->air_state = 0; self->x_speed = 0; self->y_speed = 0; self->x_accel = 0; self->gravity = 0; self->unk16 = 5; - self->unk18.val = x_pos; - self->unk1C.val = y_pos; } void unused_ride_armor_face_player(struct MainObj* self) diff --git a/src/main/mains/main_75_general.c b/src/main/mains/main_75_general.c index ddb131a79..61dabff96 100644 --- a/src/main/mains/main_75_general.c +++ b/src/main/mains/main_75_general.c @@ -352,7 +352,7 @@ void general_punch_rings(struct MainObj* self) void general_punch_wait_return(struct MainObj* self) { - if ((general_fists[0]->timer == 0x80) && (general_fists[1]->timer == general_fists[0]->timer)) { + if ((general_fists[0]->timer == 0x80) && (general_fists[1]->timer == 0x80)) { self->unk6++; general_fists[0]->state++; general_fists[1]->state++; diff --git a/src/main/misc/misc_05_pod_effect.c b/src/main/misc/misc_05_pod_effect.c index fe4faad49..1fcf82ef8 100644 --- a/src/main/misc/misc_05_pod_effect.c +++ b/src/main/misc/misc_05_pod_effect.c @@ -45,9 +45,7 @@ void pod_effect_animate(struct MiscObj* self) animate_object(ANIMATED_OBJECT(self)); if (self->unk2 == 0) { - if (self->animation_step.fields.event != 0) { - self->state = 5; - } else if (self->animation_step.fields.relative_step < 0) { + if ((self->animation_step.fields.event != 0) || (self->animation_step.fields.relative_step < 0)) { self->state = 5; } } else { diff --git a/src/main/misc/misc_11_blink_marker.c b/src/main/misc/misc_11_blink_marker.c index b1a05163e..beb98a87a 100644 --- a/src/main/misc/misc_11_blink_marker.c +++ b/src/main/misc/misc_11_blink_marker.c @@ -36,13 +36,13 @@ void blink_marker_main(struct MiscObj* self) if (FLICKER_ENABLED) { self->on_screen ^= 1; } - if (self->on_screen == 0) { - return; + if (self->on_screen != 0) { + is_on_screen(BASE_OBJECT(self)); } } else { animate_object(ANIMATED_OBJECT(self)); + is_on_screen(BASE_OBJECT(self)); } - is_on_screen(BASE_OBJECT(self)); } void blink_marker_despawn(struct MiscObj* self) diff --git a/src/main/misc/misc_14_frame_ghost.c b/src/main/misc/misc_14_frame_ghost.c index a7ea91f6a..0c30d9d0f 100644 --- a/src/main/misc/misc_14_frame_ghost.c +++ b/src/main/misc/misc_14_frame_ghost.c @@ -8,7 +8,6 @@ void frame_ghost_init(register struct MiscObj* self) u8 state; source = self->ext.pointer.unk50; - state = self->state + 1; self->unk40 = source->unk40; self->unk42 = source->unk42 & 0x7FFF; self->animation_table = source->animation_table; @@ -16,6 +15,7 @@ void frame_ghost_init(register struct MiscObj* self) self->bg_offset = source->bg_offset; self->unk15 = 0; self->unk16 = 7; + state = self->state + 1; self->state = state; set_animation_frame(ANIMATED_OBJECT(self), 2, self->unk2); self->unk7 = 0xA; diff --git a/src/main/misc/misc_33_cyberspace_warp.c b/src/main/misc/misc_33_cyberspace_warp.c index 8c3e2fa27..0ba1eb0a7 100644 --- a/src/main/misc/misc_33_cyberspace_warp.c +++ b/src/main/misc/misc_33_cyberspace_warp.c @@ -24,12 +24,11 @@ void cyberspace_warp_despawn(struct MiscObj* self) void cyberspace_warp_fade(struct MiscObj* self) { - animate_object(ANIMATED_OBJECT(self)); if (--self->ext.misc_33.timer == 0) { + self->state++; self->unk5 = 0; self->unk6 = 0; - self->state++; } if (func_8002B160(BASE_OBJECT(self)) == 0) { is_on_screen(BASE_OBJECT(self)); diff --git a/src/main/misc/misc_34_cyberspace_guide.c b/src/main/misc/misc_34_cyberspace_guide.c index 5912e7fc4..86f8c3a76 100644 --- a/src/main/misc/misc_34_cyberspace_guide.c +++ b/src/main/misc/misc_34_cyberspace_guide.c @@ -31,12 +31,9 @@ void cyberspace_guide_despawn(struct MiscObj* self) void cyberspace_guide_appear(struct MiscObj* self) { - u8 timer; animate_object(ANIMATED_OBJECT(self)); - timer = self->ext.unk.unk54 - 1; - self->ext.unk.unk54 = timer; - if (timer == 0) { - self->ext.unk.unk54 = 0x24; + if (--self->ext.misc_34.timer == 0) { + self->ext.misc_34.timer = 0x24; self->unk5 = 1; set_animation(self, 2); } @@ -77,13 +74,9 @@ void cyberspace_guide_leave_start(struct MiscObj* self) void cyberspace_guide_leave_drift(struct MiscObj* self) { - u8 timer; - animate_object(ANIMATED_OBJECT(self)); move_object(MOVING_OBJECT(self)); - timer = self->ext.misc_34.timer - 1; - self->ext.misc_34.timer = timer; - if (timer == 0) { + if (--self->ext.misc_34.timer == 0) { self->ext.misc_34.timer = 0x1E; self->x_vel.val = FIXED(3); self->y_vel.val = 0; @@ -94,13 +87,10 @@ void cyberspace_guide_leave_drift(struct MiscObj* self) void cyberspace_guide_leave_finish(struct MiscObj* self) { - u8 timer; struct EffectObj* related; move_with_gravity(ANIMATED_OBJECT(self)); - timer = self->ext.misc_34.timer - 1; - self->ext.misc_34.timer = timer; - if (timer == 0) { + if (--self->ext.misc_34.timer == 0) { related = self->ext.misc_34.related; related->ext.effect_38.active = 1; if (!(engine_obj.checkpoint % 2)) { diff --git a/src/main/misc/misc_43_intro_messenger.c b/src/main/misc/misc_43_intro_messenger.c index 9798e21a2..da6c89cc1 100644 --- a/src/main/misc/misc_43_intro_messenger.c +++ b/src/main/misc/misc_43_intro_messenger.c @@ -69,11 +69,10 @@ void intro_messenger_land(struct MiscObj* self) if (self->animation_step.fields.event != 0) { if (engine_obj.cur_character == 0) { func_8002217C(0x2E, 0xFF, 0); - self->unk5 = 3; } else { func_8002217C(0x27, 0xFF, 0); - self->unk5 = 3; } + self->unk5 = 3; } } @@ -110,10 +109,9 @@ void intro_messenger_delay(struct MiscObj* self) } if (engine_obj.cur_character == 0) { func_8002217C(0x2F, 0, 0); - self->unk5 = 7; - return; + } else { + func_8002217C(0x28, 0, 0); } - func_8002217C(0x28, 0, 0); self->unk5 = 7; } diff --git a/src/main/misc/misc_44_stage_cutscene.c b/src/main/misc/misc_44_stage_cutscene.c index 8bf8bf220..9fb4a0a6b 100644 --- a/src/main/misc/misc_44_stage_cutscene.c +++ b/src/main/misc/misc_44_stage_cutscene.c @@ -43,11 +43,7 @@ void stage_cutscene_wait_scroll(struct UnkObj* self) void stage_cutscene_first_line(struct UnkObj* self) { - s8 timer; - - timer = self->ext.timer - 1; - self->ext.timer = timer; - if (timer == 0) { + if (--self->ext.timer == 0) { func_8002217C(0x29, 1, 0); self->unk5 = 3; } @@ -63,11 +59,7 @@ void stage_cutscene_wait_first(struct UnkObj* self) void stage_cutscene_second_line(struct UnkObj* self) { - s8 timer; - - timer = self->ext.timer - 1; - self->ext.timer = timer; - if (timer == 0) { + if (--self->ext.timer == 0) { func_8002217C(0x2A, 2, 0); self->unk5 = 5; } diff --git a/src/main/misc/misc_46_post_boss_cutscene.c b/src/main/misc/misc_46_post_boss_cutscene.c index e33d500f8..2ca6989a2 100644 --- a/src/main/misc/misc_46_post_boss_cutscene.c +++ b/src/main/misc/misc_46_post_boss_cutscene.c @@ -35,11 +35,7 @@ void post_boss_cutscene_wait_scroll(struct UnkObj* self) void post_boss_cutscene_arrive(struct UnkObj* self) { - s8 timer; - - timer = self->ext.timer - 1; - self->ext.timer = timer; - if (timer == 0) { + if (--self->ext.timer == 0) { func_8001540C(2, 0x2A, self); self->unk4B = 1; self->unk5 = 2; @@ -72,11 +68,10 @@ void post_boss_cutscene_first_line(struct UnkObj* self) } if (engine_obj.cur_character == 0) { func_8002217C(0x1F, 1, 0); - self->unk5 = 5; } else { func_8002217C(0x1A, 3, 0); - self->unk5 = 5; } + self->unk5 = 5; } void post_boss_cutscene_wait_first(struct UnkObj* self) @@ -89,11 +84,7 @@ void post_boss_cutscene_wait_first(struct UnkObj* self) void post_boss_cutscene_shake_start(struct UnkObj* self) { - s8 timer; - - timer = self->ext.timer - 1; - self->ext.timer = timer; - if (timer == 0) { + if (--self->ext.timer == 0) { func_8001540C(2, 0x2A, self); self->x_vel.val = 0; self->unk28 = FIXED(1); @@ -123,15 +114,13 @@ void post_boss_cutscene_shake(struct UnkObj* self) void post_boss_cutscene_second_line(struct UnkObj* self) { - self->ext.timer -= 1; - if (self->ext.timer == 0) { + if (--self->ext.timer == 0) { if (engine_obj.cur_character == 0) { func_8002217C(0x30, 2, 0); - self->unk5 = 9; } else { func_8002217C(0x2B, 4, 0); - self->unk5 = 9; } + self->unk5 = 9; } } diff --git a/src/main/misc/misc_52_npc_cutscene.c b/src/main/misc/misc_52_npc_cutscene.c index e0fc412e1..24223c42f 100644 --- a/src/main/misc/misc_52_npc_cutscene.c +++ b/src/main/misc/misc_52_npc_cutscene.c @@ -144,24 +144,16 @@ void npc_cutscene_finish_fade(struct MiscObj* self) void npc_cutscene_finish_wait(struct MiscObj* self) { - u8 timer; - is_on_screen(BASE_OBJECT(self)); - timer = self->ext.misc_52.timer - 1; - self->ext.misc_52.timer = timer; - if (timer == 0) { + if (--self->ext.misc_52.timer == 0) { engine_obj.unkF = 0x40; } } void npc_cutscene_leave(struct MiscObj* self) { - u8 timer; - self->on_screen = 0; - timer = self->ext.misc_52.timer - 1; - self->ext.misc_52.timer = timer; - if (timer == 0) { + if (--self->ext.misc_52.timer == 0) { player_end_script_action(); despawn_object_permanently(OBJECT_HEADER(self)); } diff --git a/src/main/player_check.c b/src/main/player_check.c index d87983cf2..05cf76ebe 100644 --- a/src/main/player_check.c +++ b/src/main/player_check.c @@ -524,17 +524,20 @@ s32 player_check_ladder(struct PlayerObj* self) s32 player_check_ladder_air(struct PlayerObj* self) { - if (self->input_locked != 0 || !(self->input.buttons.held & PLAYER_INPUT_UP)) { + if (self->input_locked != 0) { + return 0; + } + if (!(self->input.buttons.held & PLAYER_INPUT_UP)) { return 0; } if (func_8002D994(self) == 0x20) { if (self->attacking) { player_enter_ladder_shoot(self); - return 1; + } else { + player_set_animation(self, 0x1F); + player_enter_ladder_up(self); } - player_set_animation(self, 0x1F); - player_enter_ladder_up(self); return 1; } return 0; @@ -636,11 +639,13 @@ s32 player_leap_check_peak(struct PlayerObj* self) void player_leap_check_wall(struct PlayerObj* self) { - s32 blocked; + u32 blocked; blocked = 0; if (self->unk15 != 0) { - blocked = self->unk88.bytes.collision_flags & PLAYER_COLLIDE_RIGHT; + if (self->unk88.bytes.collision_flags & PLAYER_COLLIDE_RIGHT) { + blocked = 1; + } if (self->x_vel.val <= 0) { blocked = 1; } diff --git a/src/main/player_enter.c b/src/main/player_enter.c index 2140cf15a..7700de36c 100644 --- a/src/main/player_enter.c +++ b/src/main/player_enter.c @@ -364,13 +364,13 @@ void player_enter_wall_cling(struct PlayerObj* self) { player_set_animation_shooting(self, 0xD); func_8001540C(1, 4, self); - self->afterimage = -1; self->x_vel.val = 0; self->unk28 = 0; self->y_vel.val = 0; self->unk2C = 0; self->dash_momentum = 0; self->air_action = 0; + self->afterimage = -1; self->unk8A.bytes.low = 8; if (self->unk88.bytes.collision_flags & PLAYER_COLLIDE_RIGHT) { self->unk15 = 0x40; diff --git a/src/main/player_special.c b/src/main/player_special.c index 120a3c25d..d3afdcb7d 100644 --- a/src/main/player_special.c +++ b/src/main/player_special.c @@ -1858,7 +1858,6 @@ void player_zero_ryuenjin(struct PlayerObj* self) void player_zero_ryuenjin_start(struct PlayerObj* self) { u8 event; - s32 scratch; player_zero_saber_on_event(self, 0x23); event = self->animation_step.fields.event; @@ -1869,14 +1868,11 @@ void player_zero_ryuenjin_start(struct PlayerObj* self) } else { self->x_vel.val = -FIXED(4); } - scratch = FIXED(6.75); - self->y_vel.val = scratch; - scratch = (u8)self->unk6; self->unk28 = -FIXED(0.25); + self->y_vel.val = FIXED(6.75); self->unk2C = FIXED(0.2578125); self->spike_immune = 0; - scratch += 1; - self->unk6 = scratch; + self->unk6++; } } diff --git a/src/main/player_weapon.c b/src/main/player_weapon.c index bb37b91de..0d7cb622b 100644 --- a/src/main/player_weapon.c +++ b/src/main/player_weapon.c @@ -1075,13 +1075,12 @@ INCLUDE_ASM("main/nonmatchings/player_weapon", func_80038568); void player_cancel_released_charge(void) { struct PlayerObj* player = &g_Player; - u16 held = player->input.buttons.held; - if (!(held & PLAYER_INPUT_SHOOT)) { + if (!(player->input.buttons.held & PLAYER_INPUT_SHOOT)) { player->charge_state[0] = 0; player->charge_timer = 0; } - if (!(held & PLAYER_INPUT_SPECIAL)) { + if (!(player->input.buttons.held & PLAYER_INPUT_SPECIAL)) { player->charge_state[1] = 0; player->special_charge_timer = 0; } diff --git a/src/main/shots/shot_19_trooper_bomb.c b/src/main/shots/shot_19_trooper_bomb.c index 6bebfd77f..55d614a3c 100644 --- a/src/main/shots/shot_19_trooper_bomb.c +++ b/src/main/shots/shot_19_trooper_bomb.c @@ -19,9 +19,9 @@ void trooper_bomb_fall(struct ShotObj* self) { move_with_gravity(ANIMATED_OBJECT(self)); if (self->unk70 != 0) { + self->state++; self->unk84.value = 0x40; self->on_screen = 0; - self->state++; return; } update_on_screen(BASE_OBJECT(self), 0x20, 0x20); diff --git a/src/main/shots/shot_24_train_boss_shot.c b/src/main/shots/shot_24_train_boss_shot.c index d85114a7e..45d9947d8 100644 --- a/src/main/shots/shot_24_train_boss_shot.c +++ b/src/main/shots/shot_24_train_boss_shot.c @@ -10,26 +10,24 @@ void train_boss_shot_update(struct ShotObj* self) void train_boss_bullet_init(struct ShotObj* self) { u16 flags; - struct WeaponObj* owner; - flags = self->unk42; - owner = self->unk7C; self->state = 1; self->on_screen = 1; self->unk58.collision_data = D_80106070; + flags = self->unk42; + self->unk42 = flags & 0x7FFF; self->x_vel.val = 0; - self->unk54 = train_boss_bullet_hit_box; - self->unk50.data = train_boss_bullet_hit_box; - self->unk84.shot_24.timer = 0x20; self->y_vel.val = 0; self->unk28 = 0; self->unk2C = 0; self->unk16 = 0; self->unk68 = NULL; + self->unk54 = train_boss_bullet_hit_box; + self->unk50.data = train_boss_bullet_hit_box; self->unk6 = 0; + self->unk84.shot_24.timer = 0x20; self->unk84.shot_24.owner_notified = 0; - self->unk42 = flags & 0x7FFF; - self->unk84.shot_24.owner_state = owner->unk6; + self->unk84.shot_24.owner_state = self->unk7C->unk6; self->unk5C = 1; self->unk60 = 4; set_animation(self, 4); diff --git a/src/main/shots/shot_35_walrus_ice.c b/src/main/shots/shot_35_walrus_ice.c index ecd2db8e7..904fe1542 100644 --- a/src/main/shots/shot_35_walrus_ice.c +++ b/src/main/shots/shot_35_walrus_ice.c @@ -99,7 +99,7 @@ void walrus_ice_icicle_wait_drop(struct ShotObj* self) { s16 timer; struct MainObj* owner; - u16* table; + s16* table; owner = MAIN_OBJECT(self->unk7C); if (owner->unk6 != 5) { @@ -109,9 +109,8 @@ void walrus_ice_icicle_wait_drop(struct ShotObj* self) } } - table = (u16*)owner->ext.main_57.rect; - - self->x_pos.i.hi = background_objects[0].unk1E + (table[self->unk2] + 0x10); + table = (s16*)owner->ext.main_57.rect; + self->x_pos.i.hi = (background_objects[0].unk1E + 0x10) + table[self->unk2]; self->timer = 15; self->unk6++; } diff --git a/src/main/shots/shot_40_hatch_blast.c b/src/main/shots/shot_40_hatch_blast.c index d8d5781b1..b6a70c4ad 100644 --- a/src/main/shots/shot_40_hatch_blast.c +++ b/src/main/shots/shot_40_hatch_blast.c @@ -9,7 +9,6 @@ void hatch_blast_update(struct ShotObj* self) void hatch_blast_init(struct ShotObj* self) { - self->y_pos.i.hi = (u16)self->y_pos.i.hi + 0x7E; self->state = 1; self->unk5 = 0; self->unk6 = 0; @@ -17,6 +16,7 @@ void hatch_blast_init(struct ShotObj* self) self->on_screen = 1; self->unk8A = 0; self->unk84.value = 0; + self->y_pos.i.hi += 0x7E; self->unk16 = 2; self->unk68 = &hatch_blast_terrain_box; self->unk54 = NULL; diff --git a/src/main/shots/shot_43_gunship_shot.c b/src/main/shots/shot_43_gunship_shot.c index 00465dd96..74d1bf958 100644 --- a/src/main/shots/shot_43_gunship_shot.c +++ b/src/main/shots/shot_43_gunship_shot.c @@ -16,12 +16,13 @@ void gunship_shot_bullet_fall(struct ShotObj* self) move_with_gravity(ANIMATED_OBJECT(self)); if (func_8002DD04(MAIN_OBJECT(self)) < 0) { spawn_explosion(BASE_OBJECT(self)); - } else { - func_8002D9BC(self); - if (func_8002B160(BASE_OBJECT(self)) == 0) { - is_on_screen(BASE_OBJECT(self)); - return; - } + self->state = 3; + return; + } + func_8002D9BC(self); + if (func_8002B160(BASE_OBJECT(self)) == 0) { + is_on_screen(BASE_OBJECT(self)); + return; } self->state = 3; } diff --git a/src/main/shots/shot_46_sigma_shot.c b/src/main/shots/shot_46_sigma_shot.c index 8b2f669ed..e8d7a2800 100644 --- a/src/main/shots/shot_46_sigma_shot.c +++ b/src/main/shots/shot_46_sigma_shot.c @@ -187,14 +187,11 @@ void sigma_bolt_bounce_wall(struct ShotObj* self) void sigma_bolt_bounce_floor(struct ShotObj* self) { - s32 var_a1; - if (self->unk70 & 8) { self->unk5++; - var_a1 = self->unk99 != 0 ? FIXED(5) : FIXED(-5); - self->x_vel.val = var_a1; + self->x_vel.val = self->unk99 != 0 ? FIXED(5) : FIXED(-5); if (self->unk2 == 2) { - self->x_vel.val = -var_a1; + self->x_vel.val *= -1; } self->y_vel.val = 0; } diff --git a/src/main/shots/shot_53_sigma_head.c b/src/main/shots/shot_53_sigma_head.c index 2029af232..256c4c3dd 100644 --- a/src/main/shots/shot_53_sigma_head.c +++ b/src/main/shots/shot_53_sigma_head.c @@ -266,8 +266,8 @@ void sigma_head_lightning(struct ShotObj* self) void sigma_head_freeze_start(struct ShotObj* self) { set_animation(self, 9); - self->unk6++; self->timer = 1; + self->unk6++; self->x_vel.val = FIXED(-1); self->y_vel.val = 0; } diff --git a/src/main/shots/shot_55_general_shot.c b/src/main/shots/shot_55_general_shot.c index f900c5193..bf7bd09e9 100644 --- a/src/main/shots/shot_55_general_shot.c +++ b/src/main/shots/shot_55_general_shot.c @@ -478,11 +478,8 @@ void general_orb_wait(struct ShotObj* self) void general_orb_aim(struct ShotObj* self) { - s16 timer; - animate_object(ANIMATED_OBJECT(self)); - timer = --self->unk8A; - if ((timer << 0x10) == 0) { + if (--self->unk8A == 0) { self->unk5 = (u8)self->unk5 + 1; self->x_vel.val = self->unk15 ? FIXED(5) : FIXED(-5); self->y_vel.val = 0; diff --git a/src/main/weapons/weapon_01_lightning_web.c b/src/main/weapons/weapon_01_lightning_web.c index cc77a18d7..879dd2f40 100644 --- a/src/main/weapons/weapon_01_lightning_web.c +++ b/src/main/weapons/weapon_01_lightning_web.c @@ -77,13 +77,10 @@ void lightning_web_init(struct WeaponObj* arg0) void lightning_web_fly(struct WeaponObj* arg0) { - u8 temp_v0; struct Weapon1Ext* weapon_1; weapon_1 = &arg0->ext.weapon_1; - temp_v0 = weapon_1->timer - 1; - weapon_1->timer = temp_v0; - if (temp_v0 == 0) { + if (--weapon_1->timer == 0) { set_animation(arg0, 1); arg0->unk16 = 3; arg0->state++; diff --git a/src/main/weapons/weapon_03_soul_body.c b/src/main/weapons/weapon_03_soul_body.c index 20c6cf1b2..25ed39b0b 100644 --- a/src/main/weapons/weapon_03_soul_body.c +++ b/src/main/weapons/weapon_03_soul_body.c @@ -93,12 +93,12 @@ void soul_body_main(struct WeaponObj* self) void soul_body_extend(struct WeaponObj* arg0) { - u16* offset_ptr; + s16* offset_ptr; s16 x_pos; s16 offset; arg0->on_screen = 1; - offset_ptr = &arg0->ext.weapon_3.offset; + offset_ptr = (s16*)&arg0->ext.weapon_3.offset; if (arg0->unk15 != 0) { arg0->x_pos.i.hi = g_Player.x_pos.u.hi + *offset_ptr; } else { @@ -110,7 +110,7 @@ void soul_body_extend(struct WeaponObj* arg0) arg0->unk5++; return; } - *(s16*)offset_ptr = offset + 8; + *offset_ptr = offset + 8; } void soul_body_hold(struct WeaponObj* arg0)