papermario/src/code_7bb60_len_41b0.c

277 lines
8.2 KiB
C
Raw Normal View History

2020-08-04 08:49:11 +02:00
#include "common.h"
2020-10-03 22:04:49 +02:00
void func_800E26B0(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
playerStatus->jumpApexHeight = playerStatus->position.y;
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E26C4);
2020-08-04 08:49:11 +02:00
2020-08-20 20:43:45 +02:00
void set_action_state(s32 actionState);
2020-08-04 08:49:11 +02:00
2020-10-29 17:08:00 +01:00
void move_player(s32 duration, f32 heading, f32 speed) {
2020-10-03 22:04:49 +02:00
PlayerStatus* playerStatus = &gPlayerStatus;
2020-08-20 20:26:34 +02:00
2020-10-03 22:04:49 +02:00
playerStatus->flags |= 0x4000;
playerStatus->heading = heading;
playerStatus->moveFrames = duration;
playerStatus->currentSpeed = speed;
2020-08-20 20:26:34 +02:00
2020-10-05 22:04:33 +02:00
if (!(playerStatus->animFlags & 0x400000)) {
2020-10-03 22:04:49 +02:00
set_action_state(speed > playerStatus->walkSpeed ? ActionState_RUN : ActionState_WALK);
2020-08-20 20:26:34 +02:00
}
}
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_main_above);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E29C8);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E2BB0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", update_fall_state);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E2F60);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", gravity_use_fall_parms);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3100);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E315C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", phys_player_land);
2020-08-04 08:49:11 +02:00
2020-10-05 22:04:33 +02:00
f32 integrate_gravity(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
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];
}
2020-08-04 08:49:11 +02:00
2020-10-03 22:04:49 +02:00
f32 func_800E34D8(void) {
f32 ret = integrate_gravity();
if (func_800E0208() != 0) {
ret = 0.0f;
}
return ret;
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E3514);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_main_lateral);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", collision_check_player_intersecting_world);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4404);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4508);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E45E0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E46C8);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4744);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4AD8);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4B40);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4BB8);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E4F10);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_midair_jump);
2020-08-04 08:49:11 +02:00
2020-10-03 22:04:49 +02:00
PartnerId get_current_partner_id(void) {
return gPlayerData.currentPartner;
}
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5098);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5150);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5174);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E52F8);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5348);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E546C);
2020-08-04 08:49:11 +02:00
2020-10-03 22:04:49 +02:00
void save_ground_pos(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
playerStatus->lastGoodPosition.x = playerStatus->position.x;
playerStatus->lastGoodPosition.y = playerStatus->position.y;
playerStatus->lastGoodPosition.z = playerStatus->position.z;
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5520);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5530);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E58F0);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5938);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E59A0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5A2C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E5C78);
2020-08-04 08:49:11 +02:00
2020-08-20 20:43:45 +02:00
void set_action_state(s32 actionState) {
2020-10-03 22:04:49 +02:00
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerData* playerData = &gPlayerData;
UNK_TYPE* unknownStruct = &D_8010F250;
2020-08-20 20:43:45 +02:00
2020-10-03 22:04:49 +02:00
if (playerStatus->flags & 0x200) {
playerStatus->flags &= ~0x200;
2020-09-24 05:16:13 +02:00
enable_player_input();
2020-08-20 20:43:45 +02:00
}
2020-10-03 22:04:49 +02:00
if (playerStatus->animFlags & 0x4000) {
if (actionState < ActionState_CONVERSATION) {
if (actionState >= 0) {
2020-10-03 22:04:49 +02:00
playerStatus->prevActionState = playerStatus->actionState;
playerStatus->actionState = actionState;
playerStatus->flags |= 0x80000000;
}
2020-08-20 20:43:45 +02:00
}
return;
}
if (actionState == ActionState_HIT_HAZARD || actionState == ActionState_HIT_LAVA) {
u8 partner;
2020-10-03 22:04:49 +02:00
if (playerStatus->unk_BF == 3) {
2020-08-20 20:43:45 +02:00
actionState = ActionState_HIT_HAZARD;
}
// Whilst Lakilester, Bow, or Parakarry's ability is active, hazards have no effect.
2020-10-03 22:04:49 +02:00
partner = playerData->currentPartner;
if (((u8)(partner - 7) < 2) || (playerData->currentPartner == PartnerId_PARAKARRY)) {
if (D_8010EBB0[0]) {
playerStatus->animFlags |= 0x4;
playerStatus->flags |= 0x800;
return;
2020-08-20 20:43:45 +02:00
}
}
}
2020-08-20 20:43:45 +02:00
if (actionState == ActionState_SLIDING) {
2020-10-03 22:04:49 +02:00
playerStatus->flags |= 0x10;
playerStatus->moveFrames = 0;
playerStatus->flags &= ~0x4000;
}
2020-10-03 22:04:49 +02:00
playerStatus->prevActionState = playerStatus->actionState;
if (actionState == ActionState_USE_TWEESTER) {
2020-10-03 22:04:49 +02:00
playerStatus->prevActionState = ActionState_IDLE;
}
if (actionState == ActionState_ENEMY_FIRST_STRIKE) {
2020-10-03 22:04:49 +02:00
playerStatus->animFlags |= 4;
}
2020-10-03 22:04:49 +02:00
playerStatus->actionState = actionState;
playerStatus->flags |= 0x80000000;
2020-10-03 22:04:49 +02:00
if (playerStatus->actionState == ActionState_SPIN) {
return;
}
2020-10-03 22:04:49 +02:00
playerStatus->flags &= ~0x20000;
playerStatus->animFlags &= ~0x10000;
2020-10-03 22:04:49 +02:00
if (unknownStruct[0xC]) {
stop_sound(unknownStruct[0xC]);
}
2020-10-03 22:04:49 +02:00
if (playerStatus->unk_D8) {
playerStatus->unk_D8[3][9] = 0xA;
playerStatus->unk_D8 = NULL;
2020-08-20 20:43:45 +02:00
}
}
2020-08-04 08:49:11 +02:00
2020-10-05 22:04:33 +02:00
void update_locomotion_state(void) {
PlayerStatus* playerStatus = (&gPlayerStatus);
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);
}
2020-10-03 22:04:49 +02:00
void start_falling(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
set_action_state(ActionState_FALLING);
2020-10-05 22:04:33 +02:00
playerStatus->gravityIntegrator[0] = 0.1143f;
playerStatus->gravityIntegrator[1] = -0.2871f;
playerStatus->gravityIntegrator[2] = -0.1823f;
playerStatus->gravityIntegrator[3] = 0.01152f;
2020-10-03 22:04:49 +02:00
}
void start_bounce_a(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
set_action_state(ActionState_BOUNCE);
playerStatus->gravityIntegrator[0] = 10.0f;
playerStatus->gravityIntegrator[1] = -2.0f;
2020-10-05 22:04:33 +02:00
playerStatus->gravityIntegrator[2] = 0.8f;
2020-10-03 22:04:49 +02:00
playerStatus->gravityIntegrator[3] = -0.75f;
}
void start_bounce_b(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
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;
}
2020-08-04 08:49:11 +02:00
2020-08-20 21:15:06 +02:00
s32 check_input_hammer(void) {
2020-10-03 22:04:49 +02:00
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerData* playerData = &gPlayerData;
2020-08-20 21:15:06 +02:00
2020-10-08 21:03:58 +02:00
if (playerStatus->pressedButtons & Button_B) {
2020-10-03 22:04:49 +02:00
if (!(playerStatus->flags & 4)) {
if (D_8010EBB0[0] != 1 || playerData->currentPartner != PartnerId_WATT) {
if (playerData->hammerLevel != -1) {
2020-08-20 21:15:06 +02:00
set_action_state(ActionState_HAMMER);
return TRUE;
}
}
}
}
return FALSE;
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_jump);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", check_input_spin);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E636C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E63A4);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E6428);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E6500);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", make_disguise_npc);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_7bb60_len_41b0", func_800E66C4);