diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c new file mode 100644 index 0000000000..c782d58865 --- /dev/null +++ b/src/code_7bb60_len_41b0.c @@ -0,0 +1,292 @@ +#include "common.h" +#include "world/partners.h" + +extern s32 D_8010C96C; // npc list index +extern s16 D_8010C9B0; + +void func_800E26B0(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + playerStatus->jumpApexHeight = playerStatus->position.y; +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E26C4); + +void set_action_state(s32 actionState); + +void move_player(s32 duration, f32 heading, f32 speed) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + playerStatus->flags |= 0x4000; + playerStatus->heading = heading; + playerStatus->moveFrames = duration; + playerStatus->currentSpeed = speed; + + if (!(playerStatus->animFlags & 0x400000)) { + set_action_state(speed > playerStatus->walkSpeed ? ActionState_RUN : ActionState_WALK); + } +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_main_above); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E29C8); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E2BB0); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", update_fall_state); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E2F60); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", gravity_use_fall_parms); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3100); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E315C); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", phys_player_land); + +f32 integrate_gravity(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + if (playerStatus->flags & 0x40000) { + playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3] / 1.7f; + playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2] / 1.7f; + playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1] / 1.7f; + } else { + playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3]; + playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2]; + playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1]; + } + return playerStatus->gravityIntegrator[0]; +} + +f32 func_800E34D8(void) { + f32 ret = integrate_gravity(); + + if (func_800E0208() != 0) { + ret = 0.0f; + } + return ret; +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3514); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_main_lateral); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_check_player_intersecting_world); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4404); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4508); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E45E0); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E46C8); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4744); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4AD8); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4B40); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4BB8); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4F10); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_midair_jump); + +PartnerID get_current_partner_id(void) { + return gPlayerData.currentPartner; +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5098); + +void func_800E5150(void) { + gCollisionStatus.unk_0A = func_800E5174(); +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5174); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", can_player_interact); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5348); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E546C); + +void save_ground_pos(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + playerStatus->lastGoodPosition.x = playerStatus->position.x; + playerStatus->lastGoodPosition.y = playerStatus->position.y; + playerStatus->lastGoodPosition.z = playerStatus->position.z; +} + +void func_800E5520(void) { + D_8010C9B0 = 0; +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5530); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E58F0); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5938); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E59A0); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5A2C); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5C78); + +void set_action_state(s32 actionState) { + PlayerStatus* playerStatus = PLAYER_STATUS; + PlayerData* playerData = PLAYER_DATA; + UNK_TYPE* unknownStruct = &D_8010F250; + + if (playerStatus->flags & 0x200) { + playerStatus->flags &= ~0x200; + enable_player_input(); + } + + if (playerStatus->animFlags & 0x4000) { + if (actionState < ActionState_CONVERSATION) { + if (actionState >= 0) { + playerStatus->prevActionState = playerStatus->actionState; + playerStatus->actionState = actionState; + playerStatus->flags |= 0x80000000; + } + } + return; + } + + if (actionState == ActionState_HIT_HAZARD || actionState == ActionState_HIT_LAVA) { + PartnerID partner; + + if (playerStatus->unk_BF == 3) { + actionState = ActionState_HIT_HAZARD; + } + + // Whilst Sushie, Lakilester, Parakarry's ability is active, hazards have no effect. + partner = playerData->currentPartner; + + if (partner == PartnerID_SUSHIE || partner == PartnerID_LAKILESTER || partner == PartnerID_PARAKARRY) { + if (D_8010EBB0[0]) { + playerStatus->animFlags |= 0x4; + playerStatus->flags |= 0x800; + return; + } + } + } + + if (actionState == ActionState_SLIDING) { + playerStatus->flags |= 0x10; + playerStatus->moveFrames = 0; + playerStatus->flags &= ~0x4000; + } + + playerStatus->prevActionState = playerStatus->actionState; + if (actionState == ActionState_USE_TWEESTER) { + playerStatus->prevActionState = ActionState_IDLE; + } + + if (actionState == ActionState_ENEMY_FIRST_STRIKE) { + playerStatus->animFlags |= 4; + } + playerStatus->actionState = actionState; + playerStatus->flags |= 0x80000000; + + if (playerStatus->actionState == ActionState_SPIN) { + return; + } + + playerStatus->flags &= ~0x20000; + playerStatus->animFlags &= ~0x10000; + + if (unknownStruct[0xC]) { + stop_sound(unknownStruct[0xC]); + } + + if (playerStatus->unk_D8) { + playerStatus->unk_D8[3][9] = 0xA; + playerStatus->unk_D8 = NULL; + } +} + +void update_locomotion_state(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + do { } while (0); // required to match + + set_action_state((!is_ability_active(Ability_SLOW_GO) + && (SQ(playerStatus->stickAxis[0]) + SQ(playerStatus->stickAxis[1]) >= 0xBD2)) ? ActionState_RUN : ActionState_WALK); +} + +void start_falling(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + set_action_state(ActionState_FALLING); + playerStatus->gravityIntegrator[0] = 0.1143f; + playerStatus->gravityIntegrator[1] = -0.2871f; + playerStatus->gravityIntegrator[2] = -0.1823f; + playerStatus->gravityIntegrator[3] = 0.01152f; +} + +void start_bounce_a(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + set_action_state(ActionState_BOUNCE); + playerStatus->gravityIntegrator[0] = 10.0f; + playerStatus->gravityIntegrator[1] = -2.0f; + playerStatus->gravityIntegrator[2] = 0.8f; + playerStatus->gravityIntegrator[3] = -0.75f; +} + +void start_bounce_b(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + + set_action_state(ActionState_BOUNCE); + playerStatus->gravityIntegrator[0] = 8.0f; + playerStatus->gravityIntegrator[1] = -1.0f; + playerStatus->gravityIntegrator[2] = 0; + playerStatus->gravityIntegrator[3] = 0; + playerStatus->flags |= 0x800000; +} + +s32 check_input_hammer(void) { + PlayerStatus* playerStatus = PLAYER_STATUS; + PlayerData* playerData = PLAYER_DATA; + + if (playerStatus->pressedButtons & Button_B) { + if (!(playerStatus->flags & 4)) { + if (D_8010EBB0[0] != 1 || playerData->currentPartner != PartnerID_WATT) { + if (playerData->hammerLevel != -1) { + set_action_state(ActionState_HAMMER); + return TRUE; + } + } + } + } + + return FALSE; +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_jump); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_spin); + +void func_800E636C(s32 arg0) { + s32 listIndex = D_8010C96C; + + if (listIndex >= 0) { + get_npc_by_index(listIndex)->currentAnim = arg0; + } +} + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E63A4); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E6428); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E6500); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", make_disguise_npc); + +INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E66C4); + diff --git a/src/world/actions.c b/src/world/actions.c index 7a67cff037..baee58aae7 100644 --- a/src/world/actions.c +++ b/src/world/actions.c @@ -74,298 +74,4 @@ s32 D_800F7C8C[] = { (s32)&func_802B6350_E28D80, 0x00E28A30, 0x00E291A0, 0x00000000, (s32)&func_802B6350_E28D80, 0x00E236E0, 0x00E24040, 0x00000000, (s32)&func_802B6350_E28D80, 0x00E28A30, 0x00E291A0, 0x01000000, - NULL, // TODO: file split (world/actions.c) }; - -#include "common.h" -#include "world/partners.h" - -extern s32 D_8010C96C; // npc list index -extern s16 D_8010C9B0; - -void func_800E26B0(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - playerStatus->jumpApexHeight = playerStatus->position.y; -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E26C4); - -void set_action_state(s32 actionState); - -void move_player(s32 duration, f32 heading, f32 speed) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - playerStatus->flags |= 0x4000; - playerStatus->heading = heading; - playerStatus->moveFrames = duration; - playerStatus->currentSpeed = speed; - - if (!(playerStatus->animFlags & 0x400000)) { - set_action_state(speed > playerStatus->walkSpeed ? ActionState_RUN : ActionState_WALK); - } -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_main_above); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E29C8); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E2BB0); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", update_fall_state); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E2F60); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", gravity_use_fall_parms); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3100); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E315C); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", phys_player_land); - -f32 integrate_gravity(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - if (playerStatus->flags & 0x40000) { - playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3] / 1.7f; - playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2] / 1.7f; - playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1] / 1.7f; - } else { - playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3]; - playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2]; - playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1]; - } - return playerStatus->gravityIntegrator[0]; -} - -f32 func_800E34D8(void) { - f32 ret = integrate_gravity(); - - if (func_800E0208() != 0) { - ret = 0.0f; - } - return ret; -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3514); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_main_lateral); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_check_player_intersecting_world); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4404); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4508); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E45E0); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E46C8); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4744); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4AD8); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4B40); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4BB8); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4F10); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_midair_jump); - -PartnerID get_current_partner_id(void) { - return gPlayerData.currentPartner; -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5098); - -void func_800E5150(void) { - gCollisionStatus.unk_0A = func_800E5174(); -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5174); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", can_player_interact); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5348); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E546C); - -void save_ground_pos(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - playerStatus->lastGoodPosition.x = playerStatus->position.x; - playerStatus->lastGoodPosition.y = playerStatus->position.y; - playerStatus->lastGoodPosition.z = playerStatus->position.z; -} - -void func_800E5520(void) { - D_8010C9B0 = 0; -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5530); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E58F0); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5938); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E59A0); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5A2C); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5C78); - -void set_action_state(s32 actionState) { - PlayerStatus* playerStatus = PLAYER_STATUS; - PlayerData* playerData = PLAYER_DATA; - UNK_TYPE* unknownStruct = &D_8010F250; - - if (playerStatus->flags & 0x200) { - playerStatus->flags &= ~0x200; - enable_player_input(); - } - - if (playerStatus->animFlags & 0x4000) { - if (actionState < ActionState_CONVERSATION) { - if (actionState >= 0) { - playerStatus->prevActionState = playerStatus->actionState; - playerStatus->actionState = actionState; - playerStatus->flags |= 0x80000000; - } - } - return; - } - - if (actionState == ActionState_HIT_HAZARD || actionState == ActionState_HIT_LAVA) { - PartnerID partner; - - if (playerStatus->unk_BF == 3) { - actionState = ActionState_HIT_HAZARD; - } - - // Whilst Sushie, Lakilester, Parakarry's ability is active, hazards have no effect. - partner = playerData->currentPartner; - - if (partner == PartnerID_SUSHIE || partner == PartnerID_LAKILESTER || partner == PartnerID_PARAKARRY) { - if (D_8010EBB0[0]) { - playerStatus->animFlags |= 0x4; - playerStatus->flags |= 0x800; - return; - } - } - } - - if (actionState == ActionState_SLIDING) { - playerStatus->flags |= 0x10; - playerStatus->moveFrames = 0; - playerStatus->flags &= ~0x4000; - } - - playerStatus->prevActionState = playerStatus->actionState; - if (actionState == ActionState_USE_TWEESTER) { - playerStatus->prevActionState = ActionState_IDLE; - } - - if (actionState == ActionState_ENEMY_FIRST_STRIKE) { - playerStatus->animFlags |= 4; - } - playerStatus->actionState = actionState; - playerStatus->flags |= 0x80000000; - - if (playerStatus->actionState == ActionState_SPIN) { - return; - } - - playerStatus->flags &= ~0x20000; - playerStatus->animFlags &= ~0x10000; - - if (unknownStruct[0xC]) { - stop_sound(unknownStruct[0xC]); - } - - if (playerStatus->unk_D8) { - playerStatus->unk_D8[3][9] = 0xA; - playerStatus->unk_D8 = NULL; - } -} - -void update_locomotion_state(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - do { } while (0); // required to match - - set_action_state((!is_ability_active(Ability_SLOW_GO) - && (SQ(playerStatus->stickAxis[0]) + SQ(playerStatus->stickAxis[1]) >= 0xBD2)) ? ActionState_RUN : ActionState_WALK); -} - -void start_falling(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - set_action_state(ActionState_FALLING); - playerStatus->gravityIntegrator[0] = 0.1143f; - playerStatus->gravityIntegrator[1] = -0.2871f; - playerStatus->gravityIntegrator[2] = -0.1823f; - playerStatus->gravityIntegrator[3] = 0.01152f; -} - -void start_bounce_a(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - set_action_state(ActionState_BOUNCE); - playerStatus->gravityIntegrator[0] = 10.0f; - playerStatus->gravityIntegrator[1] = -2.0f; - playerStatus->gravityIntegrator[2] = 0.8f; - playerStatus->gravityIntegrator[3] = -0.75f; -} - -void start_bounce_b(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - - set_action_state(ActionState_BOUNCE); - playerStatus->gravityIntegrator[0] = 8.0f; - playerStatus->gravityIntegrator[1] = -1.0f; - playerStatus->gravityIntegrator[2] = 0; - playerStatus->gravityIntegrator[3] = 0; - playerStatus->flags |= 0x800000; -} - -s32 check_input_hammer(void) { - PlayerStatus* playerStatus = PLAYER_STATUS; - PlayerData* playerData = PLAYER_DATA; - - if (playerStatus->pressedButtons & Button_B) { - if (!(playerStatus->flags & 4)) { - if (D_8010EBB0[0] != 1 || playerData->currentPartner != PartnerID_WATT) { - if (playerData->hammerLevel != -1) { - set_action_state(ActionState_HAMMER); - return TRUE; - } - } - } - } - - return FALSE; -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_jump); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_spin); - -void func_800E636C(s32 arg0) { - s32 listIndex = D_8010C96C; - - if (listIndex >= 0) { - get_npc_by_index(listIndex)->currentAnim = arg0; - } -} - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E63A4); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E6428); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E6500); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", make_disguise_npc); - -INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E66C4); - diff --git a/src/world/partner/goombario.c b/src/world/partner/goombario.c index 3f3e7ed82a..e1d45b20b3 100644 --- a/src/world/partner/goombario.c +++ b/src/world/partner/goombario.c @@ -66,10 +66,10 @@ void world_goombario_pre_battle(Npc* partner) { func_80027088(0); enable_player_input(); CancelMessageAndBlock(); - clear_partner_move_history(arg0); + clear_partner_move_history(partner); D_8010EBB0[0] = 0; D_8010EBB0[3] = 0; - disable_npc_blur(arg0); + disable_npc_blur(partner); } D_8010EBB0[3] = 1; } diff --git a/tools/splat.yaml b/tools/splat.yaml index ca4e533430..6ec2885bf4 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -262,7 +262,7 @@ segments: - [0x759b0, c, code_759b0_len_61b0] - [0x77480, c] - [0x7B440, c] - - [0x7bb60, c, world/actions] + - [0x7bb60, c, code_7bb60_len_41b0] - [0x7fd10, c, code_7fd10_len_b40] - [0x80850, c, code_80850_len_3060] - [0x838b0, c, world/partners]