From 79944164d96b140666310facb1453b7766d60571 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 20 Aug 2020 19:43:45 +0100 Subject: [PATCH] wip: set_action_state --- include/common_structs.h | 3 +- include/variables.h | 2 + src/code_7bb60_len_41b0.c | 92 ++++++++++++++++++++++++++++++++++++++- undefined_syms.txt | 2 + 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 8dfd7d62d2..05f07238a9 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1355,7 +1355,8 @@ typedef struct PlayerStatus { /* 0x0C0 */ u32* decorationList; /* 0x0C4 */ char unk_C4[8]; /* 0x0CC */ s32 shadowID; - /* 0x0D0 */ char unk_D0[12]; + /* 0x0D0 */ char unk_D0[8]; + /* 0x0D8 */ UNK_PTR unk_D8; /* 0x0DC */ s32 currentButtons; /* 0x0E0 */ s32 pressedButtons; /* 0x0E4 */ s32 heldButtons; diff --git a/include/variables.h b/include/variables.h index 2c39320eb9..87cd594e16 100644 --- a/include/variables.h +++ b/include/variables.h @@ -78,5 +78,7 @@ extern UNK_TYPE D_80147474; extern UNK_TYPE D_80147574; extern UNK_TYPE D_80109270; extern UNK_TYPE D_80108558; +extern UNK_TYPE D_8010F250; // play_sound state struct? +extern s8 D_8010EBB0; #endif diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c index 325f934f80..1da639d8e9 100644 --- a/src/code_7bb60_len_41b0.c +++ b/src/code_7bb60_len_41b0.c @@ -4,7 +4,7 @@ INCLUDE_ASM("code_7bb60_len_41b0", func_800E26B0); INCLUDE_ASM("code_7bb60_len_41b0", func_800E26C4); -INCLUDE_ASM("code_7bb60_len_41b0", move_player); +void set_action_state(s32 actionState); void move_player(s16 duration, f32 heading, f32 speed) { PlayerStatus* player_status = &gPlayerStatus; @@ -83,7 +83,95 @@ INCLUDE_ASM("code_7bb60_len_41b0", func_800E5A2C); INCLUDE_ASM("code_7bb60_len_41b0", func_800E5C78); -INCLUDE_ASM("code_7bb60_len_41b0", set_action_state); +#ifdef NON_MATCHING +void set_action_state(s32 actionState) { + PlayerStatus* player_status = &gPlayerStatus; + PlayerData* player_data = &gPlayerData; + UNK_TYPE* unknown_struct = &D_8010F250; + + //s32 player_status->animFlags; + s32 temp_a1; + s32 temp_v0; + s32 temp_v0_2; + s32 isMovementAllowed; + s32 temp_v0_4; + //s32 player_status->flags; + SoundId sound; + u8 partner; + u8 partnerIgnoresHazards; + UNK_PTR** temp_v0_5; + s32 phi_return; + + if (player_status->flags & 0x200) { + player_status->flags &= -0x201; + func_800E01A4(); + } + + //player_status->animFlags = player_status->animFlags; + isMovementAllowed = actionState < ActionState_CONVERSATION; + if (player_status->animFlags & 0x4000) { + if (isMovementAllowed && actionState >= 0) { + player_status->prevActionState = player_status->actionState; + player_status->actionState = actionState; + player_status->flags |= 0x80000000; + } + } else { + //if () { + // goto hit_hazard; + //} + if (player_status->unk_BF == 3) { + actionState = ActionState_HIT_HAZARD; + } + if (actionState == ActionState_HIT_HAZARD || actionState == ActionState_HIT_LAVA) { + hit_hazard: + + partner = player_data->currentPartner; + partnerIgnoresHazards = (partner - 7) < 2u; // Lakilester or Bow + if (partnerIgnoresHazards || (s8)partner == PartnerId_PARAKARRY) { + if (D_8010EBB0) { + player_status->animFlags |= 0x4; + player_status->flags |= 0x800; + return; + } + //actionState = ActionState_HIT_HAZARD; // u8 + } + } + if (actionState == ActionState_SLIDING) { + player_status->moveFrames = 0; + player_status->flags |= 0x10; + player_status->flags &= -0x4001; + } + + player_status->prevActionState = player_status->actionState; + if (actionState != ActionState_USE_TWEESTER) { + // ??? + } + player_status->prevActionState = ActionState_IDLE; + if (actionState == ActionState_ENEMY_FIRST_STRIKE) { + player_status->animFlags |= 4; + } + player_status->actionState = actionState; + player_status->flags |= 0x80000000; + //phi_return = 0x1A; + if (player_status->actionState != ActionState_SPIN) { + player_status->flags &= 0xFFFDFFFF; + sound = unknown_struct[0x30]; + player_status->animFlags &= 0xFFFEFFFF; + if (sound) stop_sound(sound); + + temp_v0_5 = player_status->unk_D8; + //phi_return = (s32) temp_v0_5; + if (temp_v0_5) { + temp_v0_5[0x0C][0x24] = 0xA; + player_status->unk_D8 = NULL; + //phi_return = 0xA; + } + } + } +} +#else +void INCLUDE_ASM("code_7bb60_len_41b0", set_action_state, s32 actionState); +#endif INCLUDE_ASM("code_7bb60_len_41b0", update_locomotion_state); diff --git a/undefined_syms.txt b/undefined_syms.txt index 0d342669f7..d56f31526c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -8,6 +8,8 @@ gBattleScriptList = 0x802DA690; gCurrentScriptListPtr = 0x802DA890; gGlobalTimeSpace = 0x802D9CA8; D_80147574 = 0x80147574; +D_8010EBB0 = 0x8010EBB0; +D_8010F250 = 0x8010F250; gMapTransitionAlpha = 0x800A0940; D_800E92D8 = 0x800E92D8;