From e54bb887d7e6c76e4aa987f90f148fcd496790f6 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 20 Aug 2020 19:26:34 +0100 Subject: [PATCH 01/10] match move_player --- .../code_7bb60_len_41b0/move_player.s | 34 ------------------- include/common_structs.h | 2 +- include/enums.h | 27 +++++++-------- src/code_7bb60_len_41b0.c | 13 +++++++ 4 files changed, 27 insertions(+), 49 deletions(-) delete mode 100644 asm/nonmatchings/code_7bb60_len_41b0/move_player.s diff --git a/asm/nonmatchings/code_7bb60_len_41b0/move_player.s b/asm/nonmatchings/code_7bb60_len_41b0/move_player.s deleted file mode 100644 index 245018e8b0..0000000000 --- a/asm/nonmatchings/code_7bb60_len_41b0/move_player.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel move_player -/* 07BC28 800E2778 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 07BC2C 800E277C 44861000 */ mtc1 $a2, $f2 -/* 07BC30 800E2780 3C068011 */ lui $a2, 0x8011 -/* 07BC34 800E2784 24C6EFC8 */ addiu $a2, $a2, -0x1038 -/* 07BC38 800E2788 AFBF0010 */ sw $ra, 0x10($sp) -/* 07BC3C 800E278C 8CC20000 */ lw $v0, ($a2) -/* 07BC40 800E2790 34424000 */ ori $v0, $v0, 0x4000 -/* 07BC44 800E2794 ACC20000 */ sw $v0, ($a2) -/* 07BC48 800E2798 8CC20004 */ lw $v0, 4($a2) -/* 07BC4C 800E279C 3C030040 */ lui $v1, 0x40 -/* 07BC50 800E27A0 ACC500A0 */ sw $a1, 0xa0($a2) -/* 07BC54 800E27A4 A4C40012 */ sh $a0, 0x12($a2) -/* 07BC58 800E27A8 00431024 */ and $v0, $v0, $v1 -/* 07BC5C 800E27AC 14400009 */ bnez $v0, .L800E27D4 -/* 07BC60 800E27B0 E4C20054 */ swc1 $f2, 0x54($a2) -/* 07BC64 800E27B4 C4C00058 */ lwc1 $f0, 0x58($a2) -/* 07BC68 800E27B8 4602003C */ c.lt.s $f0, $f2 -/* 07BC6C 800E27BC 00000000 */ nop -/* 07BC70 800E27C0 45000002 */ bc1f .L800E27CC -/* 07BC74 800E27C4 24040001 */ addiu $a0, $zero, 1 -/* 07BC78 800E27C8 24040002 */ addiu $a0, $zero, 2 -.L800E27CC: -/* 07BC7C 800E27CC 0C039769 */ jal set_action_state -/* 07BC80 800E27D0 00000000 */ nop -.L800E27D4: -/* 07BC84 800E27D4 8FBF0010 */ lw $ra, 0x10($sp) -/* 07BC88 800E27D8 03E00008 */ jr $ra -/* 07BC8C 800E27DC 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/include/common_structs.h b/include/common_structs.h index df735d4d15..8dfd7d62d2 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1328,7 +1328,7 @@ typedef struct PlayerStatus { /* 0x044 */ f32 decorationPos[2]; /* 0x04C */ char unk_4C[4]; /* 0x050 */ f32 jumpApexHeight; - /* 0x054 */ s32 currentSpeed; + /* 0x054 */ f32 currentSpeed; /* 0x058 */ f32 walkSpeed; /* 0x05C */ f32 runSpeed; /* 0x060 */ char unk_60[8]; diff --git a/include/enums.h b/include/enums.h index a2247d75d4..9d1d2d3cb0 100644 --- a/include/enums.h +++ b/include/enums.h @@ -11,19 +11,18 @@ typedef UNK_TYPE EncounterTriggerFlags; #define EncounterTriggerFlags_HAMMER 0x00000004 #define EncounterTriggerFlags_PARTNER 0x00000006 -typedef UNK_TYPE PartnerId; -#define PartnerId_NONE 0x00000000 -#define PartnerId_GOOMBARIO 0x00000001 -#define PartnerId_KOOPER 0x00000002 -#define PartnerId_BOMBETTE 0x00000003 -#define PartnerId_PARAKARRY 0x00000004 -#define PartnerId_GOOMPA 0x00000005 -#define PartnerId_WATT 0x00000006 -#define PartnerId_SUSHIE 0x00000007 -#define PartnerId_LAKILESTER 0x00000008 -#define PartnerId_BOW 0x00000009 -#define PartnerId_GOOMBARIA 0x0000000A -#define PartnerId_TWINK 0x0000000B +#define PartnerId_NONE 0x00 +#define PartnerId_GOOMBARIO 0x01 +#define PartnerId_KOOPER 0x02 +#define PartnerId_BOMBETTE 0x03 +#define PartnerId_PARAKARRY 0x04 +#define PartnerId_GOOMPA 0x05 +#define PartnerId_WATT 0x06 +#define PartnerId_SUSHIE 0x07 +#define PartnerId_LAKILESTER 0x08 +#define PartnerId_BOW 0x09 +#define PartnerId_GOOMBARIA 0x0A +#define PartnerId_TWINK 0x0B typedef UNK_TYPE SpriteId; #define SpriteId_WORLD_GOOMBARIO 0x00000001 @@ -1224,7 +1223,6 @@ typedef UNK_TYPE DoorSounds; #define DoorSounds_CREAKY 0x00000003 #define DoorSounds_GATE 0x00000004 -typedef UNK_TYPE ActionState; #define ActionState_IDLE 0x00000000 #define ActionState_WALK 0x00000001 #define ActionState_RUN 0x00000002 @@ -1236,6 +1234,7 @@ typedef UNK_TYPE ActionState; #define ActionState_STEP_DOWN 0x00000009 #define ActionState_LAND 0x0000000A #define ActionState_STEP_DOWN_LAND 0x0000000B +// Following states prohibit normal movement: #define ActionState_CONVERSATION 0x0000000C #define ActionState_SPIN_JUMP 0x0000000D #define ActionState_GROUND_POUND 0x0000000E diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c index 3b1f4bd7d9..325f934f80 100644 --- a/src/code_7bb60_len_41b0.c +++ b/src/code_7bb60_len_41b0.c @@ -6,6 +6,19 @@ INCLUDE_ASM("code_7bb60_len_41b0", func_800E26C4); INCLUDE_ASM("code_7bb60_len_41b0", move_player); +void move_player(s16 duration, f32 heading, f32 speed) { + PlayerStatus* player_status = &gPlayerStatus; + + player_status->flags = player_status->flags | 0x4000; + player_status->heading = heading; + player_status->moveFrames = duration; + player_status->currentSpeed = speed; + + if (!(player_status->animFlags & 0x00400000)) { + set_action_state(speed > player_status->walkSpeed ? ActionState_RUN : ActionState_WALK); + } +} + INCLUDE_ASM("code_7bb60_len_41b0", func_800E27E0); INCLUDE_ASM("code_7bb60_len_41b0", func_800E29C8); From 79944164d96b140666310facb1453b7766d60571 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 20 Aug 2020 19:43:45 +0100 Subject: [PATCH 02/10] 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; From 7f2e872956401e5eb9ae7c8318b385e1d4790f2c Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 20 Aug 2020 20:02:06 +0100 Subject: [PATCH 03/10] fix coverage.py --delete-matched --- coverage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage.py b/coverage.py index 8722fa07e1..9144190192 100755 --- a/coverage.py +++ b/coverage.py @@ -67,7 +67,7 @@ if __name__ == "__main__": exit(1) elif "--delete-matched" in argv or input("Delete them [y/N]? ").upper() == "Y": for func in matched_but_undeleted_asm: - file = glob(path.join(DIR, f"../asm/nonmatchings/*/{func}.s"))[0] + file = glob(path.join(DIR, f"asm/nonmatchings/*/{func}.s"))[0] remove(file) elif len(asm) != len(non_matched): print(f"warning: number of INCLUDE_ASM macros ({len(asm)}) != number of asm files ({len(non_matched)})") From 42688faecd2169b7c0c6969abef046d963fa31a0 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 20 Aug 2020 20:15:06 +0100 Subject: [PATCH 04/10] match check_input_hammer --- .../code_7bb60_len_41b0/check_input_hammer.s | 40 ------------------- include/common_structs.h | 2 +- src/code_7bb60_len_41b0.c | 18 ++++++++- 3 files changed, 18 insertions(+), 42 deletions(-) delete mode 100644 asm/nonmatchings/code_7bb60_len_41b0/check_input_hammer.s diff --git a/asm/nonmatchings/code_7bb60_len_41b0/check_input_hammer.s b/asm/nonmatchings/code_7bb60_len_41b0/check_input_hammer.s deleted file mode 100644 index 77c7af5e5c..0000000000 --- a/asm/nonmatchings/code_7bb60_len_41b0/check_input_hammer.s +++ /dev/null @@ -1,40 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel check_input_hammer -/* 07F590 800E60E0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 07F594 800E60E4 3C038011 */ lui $v1, 0x8011 -/* 07F598 800E60E8 2463EFC8 */ addiu $v1, $v1, -0x1038 -/* 07F59C 800E60EC AFBF0010 */ sw $ra, 0x10($sp) -/* 07F5A0 800E60F0 8C6200E0 */ lw $v0, 0xe0($v1) -/* 07F5A4 800E60F4 3C048011 */ lui $a0, 0x8011 -/* 07F5A8 800E60F8 2484F290 */ addiu $a0, $a0, -0xd70 -/* 07F5AC 800E60FC 30424000 */ andi $v0, $v0, 0x4000 -/* 07F5B0 800E6100 10400014 */ beqz $v0, .L800E6154 -/* 07F5B4 800E6104 0000102D */ daddu $v0, $zero, $zero -/* 07F5B8 800E6108 8C620000 */ lw $v0, ($v1) -/* 07F5BC 800E610C 30420004 */ andi $v0, $v0, 4 -/* 07F5C0 800E6110 14400010 */ bnez $v0, .L800E6154 -/* 07F5C4 800E6114 0000102D */ daddu $v0, $zero, $zero -/* 07F5C8 800E6118 3C038011 */ lui $v1, 0x8011 -/* 07F5CC 800E611C 8063EBB0 */ lb $v1, -0x1450($v1) -/* 07F5D0 800E6120 24020001 */ addiu $v0, $zero, 1 -/* 07F5D4 800E6124 14620004 */ bne $v1, $v0, .L800E6138 -/* 07F5D8 800E6128 24020006 */ addiu $v0, $zero, 6 -/* 07F5DC 800E612C 80830012 */ lb $v1, 0x12($a0) -/* 07F5E0 800E6130 10620008 */ beq $v1, $v0, .L800E6154 -/* 07F5E4 800E6134 0000102D */ daddu $v0, $zero, $zero -.L800E6138: -/* 07F5E8 800E6138 80830001 */ lb $v1, 1($a0) -/* 07F5EC 800E613C 2402FFFF */ addiu $v0, $zero, -1 -/* 07F5F0 800E6140 10620004 */ beq $v1, $v0, .L800E6154 -/* 07F5F4 800E6144 0000102D */ daddu $v0, $zero, $zero -/* 07F5F8 800E6148 0C039769 */ jal set_action_state -/* 07F5FC 800E614C 24040012 */ addiu $a0, $zero, 0x12 -/* 07F600 800E6150 24020001 */ addiu $v0, $zero, 1 -.L800E6154: -/* 07F604 800E6154 8FBF0010 */ lw $ra, 0x10($sp) -/* 07F608 800E6158 03E00008 */ jr $ra -/* 07F60C 800E615C 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/include/common_structs.h b/include/common_structs.h index 05f07238a9..b23fadd7f6 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -105,7 +105,7 @@ typedef struct PlayerData { /* 0x00F */ u8 starPieces; /* 0x010 */ s8 starPoints; /* 0x011 */ char unk_11; - /* 0x012 */ u8 currentPartner; + /* 0x012 */ s8 currentPartner; /* 0x013 */ char unk_13; /* 0x014 */ struct PartnerData partners[12]; /* 0x074 */ s16 keyItems[32]; diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c index 1da639d8e9..f20b78dd57 100644 --- a/src/code_7bb60_len_41b0.c +++ b/src/code_7bb60_len_41b0.c @@ -181,7 +181,23 @@ INCLUDE_ASM("code_7bb60_len_41b0", start_bounce_a); INCLUDE_ASM("code_7bb60_len_41b0", start_bounce_b); -INCLUDE_ASM("code_7bb60_len_41b0", check_input_hammer); +s32 check_input_hammer(void) { + PlayerStatus* player_status = &gPlayerStatus; + PlayerData* player_data = &gPlayerData; + + if (player_status->pressedButtons & Buttons_B) { + if (!(player_status->flags & 4)) { + if (D_8010EBB0 != 1 || player_data->currentPartner != PartnerId_WATT) { + if (player_data->hammerLevel != -1) { + set_action_state(ActionState_HAMMER); + return TRUE; + } + } + } + } + + return FALSE; +} INCLUDE_ASM("code_7bb60_len_41b0", check_input_jump); From b37ca1583c5460ccd95511b88db1d06cbf36a383 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Mon, 24 Aug 2020 13:53:19 +0100 Subject: [PATCH 05/10] ci: don't fail lint on first push to new branch --- .github/workflows/lint.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 57055f3d70..61956f6155 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -23,7 +23,11 @@ jobs: uses: trilom/file-changes-action@v1.2.4 with: output: ' ' + continue-on-error: true - run: ./format.sh ${{ steps.files.outputs.files}} + if: ${{ steps.files.outcome == 'success' }} + - run: ./format.sh + if: ${{ steps.files.outcome == 'failure' }} # fail if any files were changed by ./format.sh - id: files_formatted From 1546efeec086fba95fc6706ea25ff25a345e3bf2 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Mon, 24 Aug 2020 14:18:49 +0100 Subject: [PATCH 06/10] bump n64splat --- tools/n64splat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/n64splat b/tools/n64splat index 932a8fe873..1a525eafd7 160000 --- a/tools/n64splat +++ b/tools/n64splat @@ -1 +1 @@ -Subproject commit 932a8fe873977407fe7127430121cf480bb597d2 +Subproject commit 1a525eafd798840e3b1d8bb7d543aa26d3014a3d From cfe3a408802de48e0d43065c8a0218eec46520bd Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Mon, 24 Aug 2020 14:22:44 +0100 Subject: [PATCH 07/10] move ActionState comment --- include/enums.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/enums.h b/include/enums.h index 2856d90b6f..8c06a6d716 100644 --- a/include/enums.h +++ b/include/enums.h @@ -1235,8 +1235,7 @@ typedef s8 ActionState; #define ActionState_STEP_DOWN 0x00000009 #define ActionState_LAND 0x0000000A #define ActionState_STEP_DOWN_LAND 0x0000000B -// Following states prohibit normal movement: -#define ActionState_CONVERSATION 0x0000000C +#define ActionState_CONVERSATION 0x0000000C // This and following states prohibit normal movement. #define ActionState_SPIN_JUMP 0x0000000D #define ActionState_GROUND_POUND 0x0000000E #define ActionState_ULTRA_JUMP 0x0000000F From da5d8171b8c1216c16bb6560747bb41f6b1938c6 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Mon, 7 Sep 2020 09:32:18 -0400 Subject: [PATCH 08/10] Update code_7bb60_len_41b0.c ~0x200 --- src/code_7bb60_len_41b0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c index f20b78dd57..c258e79b61 100644 --- a/src/code_7bb60_len_41b0.c +++ b/src/code_7bb60_len_41b0.c @@ -103,7 +103,7 @@ void set_action_state(s32 actionState) { s32 phi_return; if (player_status->flags & 0x200) { - player_status->flags &= -0x201; + player_status->flags &= ~0x200; func_800E01A4(); } From 8d7e4b327eaa7d7fab355d0d7dcb73de35ab12ed Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Tue, 8 Sep 2020 12:21:15 +0100 Subject: [PATCH 09/10] match set_action_state Thanks @pixel-stuck! --- .../code_7bb60_len_41b0/set_action_state.s | 133 ------------------ src/code_7bb60_len_41b0.c | 121 +++++++--------- 2 files changed, 52 insertions(+), 202 deletions(-) delete mode 100644 asm/nonmatchings/code_7bb60_len_41b0/set_action_state.s diff --git a/asm/nonmatchings/code_7bb60_len_41b0/set_action_state.s b/asm/nonmatchings/code_7bb60_len_41b0/set_action_state.s deleted file mode 100644 index 80f7d315a8..0000000000 --- a/asm/nonmatchings/code_7bb60_len_41b0/set_action_state.s +++ /dev/null @@ -1,133 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel set_action_state -/* 07F254 800E5DA4 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 07F258 800E5DA8 AFB00010 */ sw $s0, 0x10($sp) -/* 07F25C 800E5DAC 3C108011 */ lui $s0, 0x8011 -/* 07F260 800E5DB0 2610EFC8 */ addiu $s0, $s0, -0x1038 -/* 07F264 800E5DB4 AFBF0018 */ sw $ra, 0x18($sp) -/* 07F268 800E5DB8 AFB10014 */ sw $s1, 0x14($sp) -/* 07F26C 800E5DBC 8E030000 */ lw $v1, ($s0) -/* 07F270 800E5DC0 30620200 */ andi $v0, $v1, 0x200 -/* 07F274 800E5DC4 10400005 */ beqz $v0, .L800E5DDC -/* 07F278 800E5DC8 0080882D */ daddu $s1, $a0, $zero -/* 07F27C 800E5DCC 2402FDFF */ addiu $v0, $zero, -0x201 -/* 07F280 800E5DD0 00621024 */ and $v0, $v1, $v0 -/* 07F284 800E5DD4 0C038069 */ jal func_800E01A4 -/* 07F288 800E5DD8 AE020000 */ sw $v0, ($s0) -.L800E5DDC: -/* 07F28C 800E5DDC 8E040004 */ lw $a0, 4($s0) -/* 07F290 800E5DE0 30824000 */ andi $v0, $a0, 0x4000 -/* 07F294 800E5DE4 1040000C */ beqz $v0, .L800E5E18 -/* 07F298 800E5DE8 2A22000C */ slti $v0, $s1, 0xc -/* 07F29C 800E5DEC 10400059 */ beqz $v0, .L800E5F54 -/* 07F2A0 800E5DF0 00000000 */ nop -/* 07F2A4 800E5DF4 06200057 */ bltz $s1, .L800E5F54 -/* 07F2A8 800E5DF8 3C038000 */ lui $v1, 0x8000 -/* 07F2AC 800E5DFC 920200B4 */ lbu $v0, 0xb4($s0) -/* 07F2B0 800E5E00 A20200B5 */ sb $v0, 0xb5($s0) -/* 07F2B4 800E5E04 8E020000 */ lw $v0, ($s0) -/* 07F2B8 800E5E08 A21100B4 */ sb $s1, 0xb4($s0) -/* 07F2BC 800E5E0C 00431025 */ or $v0, $v0, $v1 -/* 07F2C0 800E5E10 080397D5 */ j .L800E5F54 -/* 07F2C4 800E5E14 AE020000 */ sw $v0, ($s0) - -.L800E5E18: -/* 07F2C8 800E5E18 24020015 */ addiu $v0, $zero, 0x15 -/* 07F2CC 800E5E1C 12220003 */ beq $s1, $v0, .L800E5E2C -/* 07F2D0 800E5E20 24020017 */ addiu $v0, $zero, 0x17 -/* 07F2D4 800E5E24 1622001A */ bne $s1, $v0, .L800E5E90 -/* 07F2D8 800E5E28 24020011 */ addiu $v0, $zero, 0x11 -.L800E5E2C: -/* 07F2DC 800E5E2C 820300BF */ lb $v1, 0xbf($s0) -/* 07F2E0 800E5E30 24020003 */ addiu $v0, $zero, 3 -/* 07F2E4 800E5E34 50620001 */ beql $v1, $v0, .L800E5E3C -/* 07F2E8 800E5E38 24110015 */ addiu $s1, $zero, 0x15 -.L800E5E3C: -/* 07F2EC 800E5E3C 3C028011 */ lui $v0, 0x8011 -/* 07F2F0 800E5E40 2442F290 */ addiu $v0, $v0, -0xd70 -/* 07F2F4 800E5E44 90430012 */ lbu $v1, 0x12($v0) -/* 07F2F8 800E5E48 2462FFF9 */ addiu $v0, $v1, -7 -/* 07F2FC 800E5E4C 2C420002 */ sltiu $v0, $v0, 2 -/* 07F300 800E5E50 14400005 */ bnez $v0, .L800E5E68 -/* 07F304 800E5E54 00031600 */ sll $v0, $v1, 0x18 -/* 07F308 800E5E58 00021603 */ sra $v0, $v0, 0x18 -/* 07F30C 800E5E5C 24030004 */ addiu $v1, $zero, 4 -/* 07F310 800E5E60 1443000B */ bne $v0, $v1, .L800E5E90 -/* 07F314 800E5E64 24020011 */ addiu $v0, $zero, 0x11 -.L800E5E68: -/* 07F318 800E5E68 3C028011 */ lui $v0, 0x8011 -/* 07F31C 800E5E6C 8042EBB0 */ lb $v0, -0x1450($v0) -/* 07F320 800E5E70 10400006 */ beqz $v0, .L800E5E8C -/* 07F324 800E5E74 34830004 */ ori $v1, $a0, 4 -/* 07F328 800E5E78 8E020000 */ lw $v0, ($s0) -/* 07F32C 800E5E7C AE030004 */ sw $v1, 4($s0) -/* 07F330 800E5E80 34420800 */ ori $v0, $v0, 0x800 -/* 07F334 800E5E84 080397D5 */ j .L800E5F54 -/* 07F338 800E5E88 AE020000 */ sw $v0, ($s0) - -.L800E5E8C: -/* 07F33C 800E5E8C 24020011 */ addiu $v0, $zero, 0x11 -.L800E5E90: -/* 07F340 800E5E90 16220007 */ bne $s1, $v0, .L800E5EB0 -/* 07F344 800E5E94 2403BFFF */ addiu $v1, $zero, -0x4001 -/* 07F348 800E5E98 8E020000 */ lw $v0, ($s0) -/* 07F34C 800E5E9C A6000012 */ sh $zero, 0x12($s0) -/* 07F350 800E5EA0 34420010 */ ori $v0, $v0, 0x10 -/* 07F354 800E5EA4 AE020000 */ sw $v0, ($s0) -/* 07F358 800E5EA8 00431024 */ and $v0, $v0, $v1 -/* 07F35C 800E5EAC AE020000 */ sw $v0, ($s0) -.L800E5EB0: -/* 07F360 800E5EB0 920200B4 */ lbu $v0, 0xb4($s0) -/* 07F364 800E5EB4 A20200B5 */ sb $v0, 0xb5($s0) -/* 07F368 800E5EB8 2402001F */ addiu $v0, $zero, 0x1f -/* 07F36C 800E5EBC 52220001 */ beql $s1, $v0, .L800E5EC4 -/* 07F370 800E5EC0 A20000B5 */ sb $zero, 0xb5($s0) -.L800E5EC4: -/* 07F374 800E5EC4 2402001B */ addiu $v0, $zero, 0x1b -/* 07F378 800E5EC8 16220004 */ bne $s1, $v0, .L800E5EDC -/* 07F37C 800E5ECC 00000000 */ nop -/* 07F380 800E5ED0 8E020004 */ lw $v0, 4($s0) -/* 07F384 800E5ED4 34420004 */ ori $v0, $v0, 4 -/* 07F388 800E5ED8 AE020004 */ sw $v0, 4($s0) -.L800E5EDC: -/* 07F38C 800E5EDC 8E030000 */ lw $v1, ($s0) -/* 07F390 800E5EE0 3C028000 */ lui $v0, 0x8000 -/* 07F394 800E5EE4 A21100B4 */ sb $s1, 0xb4($s0) -/* 07F398 800E5EE8 00622825 */ or $a1, $v1, $v0 -/* 07F39C 800E5EEC 820300B4 */ lb $v1, 0xb4($s0) -/* 07F3A0 800E5EF0 2402001A */ addiu $v0, $zero, 0x1a -/* 07F3A4 800E5EF4 10620017 */ beq $v1, $v0, .L800E5F54 -/* 07F3A8 800E5EF8 AE050000 */ sw $a1, ($s0) -/* 07F3AC 800E5EFC 3C02FFFD */ lui $v0, 0xfffd -/* 07F3B0 800E5F00 3442FFFF */ ori $v0, $v0, 0xffff -/* 07F3B4 800E5F04 3C04FFFE */ lui $a0, 0xfffe -/* 07F3B8 800E5F08 3484FFFF */ ori $a0, $a0, 0xffff -/* 07F3BC 800E5F0C 00A21024 */ and $v0, $a1, $v0 -/* 07F3C0 800E5F10 3C038011 */ lui $v1, 0x8011 -/* 07F3C4 800E5F14 2463F250 */ addiu $v1, $v1, -0xdb0 -/* 07F3C8 800E5F18 AE020000 */ sw $v0, ($s0) -/* 07F3CC 800E5F1C 8E020004 */ lw $v0, 4($s0) -/* 07F3D0 800E5F20 8C630030 */ lw $v1, 0x30($v1) -/* 07F3D4 800E5F24 00441024 */ and $v0, $v0, $a0 -/* 07F3D8 800E5F28 10600003 */ beqz $v1, .L800E5F38 -/* 07F3DC 800E5F2C AE020004 */ sw $v0, 4($s0) -/* 07F3E0 800E5F30 0C05271B */ jal stop_sound -/* 07F3E4 800E5F34 0060202D */ daddu $a0, $v1, $zero -.L800E5F38: -/* 07F3E8 800E5F38 8E0200D8 */ lw $v0, 0xd8($s0) -/* 07F3EC 800E5F3C 10400005 */ beqz $v0, .L800E5F54 -/* 07F3F0 800E5F40 00000000 */ nop -/* 07F3F4 800E5F44 8C43000C */ lw $v1, 0xc($v0) -/* 07F3F8 800E5F48 2402000A */ addiu $v0, $zero, 0xa -/* 07F3FC 800E5F4C AC620024 */ sw $v0, 0x24($v1) -/* 07F400 800E5F50 AE0000D8 */ sw $zero, 0xd8($s0) -.L800E5F54: -/* 07F404 800E5F54 8FBF0018 */ lw $ra, 0x18($sp) -/* 07F408 800E5F58 8FB10014 */ lw $s1, 0x14($sp) -/* 07F40C 800E5F5C 8FB00010 */ lw $s0, 0x10($sp) -/* 07F410 800E5F60 03E00008 */ jr $ra -/* 07F414 800E5F64 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c index c258e79b61..7deec05cc7 100644 --- a/src/code_7bb60_len_41b0.c +++ b/src/code_7bb60_len_41b0.c @@ -83,95 +83,78 @@ INCLUDE_ASM("code_7bb60_len_41b0", func_800E5A2C); INCLUDE_ASM("code_7bb60_len_41b0", func_800E5C78); -#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 &= ~0x200; 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; + if (actionState < ActionState_CONVERSATION) { + if (actionState >= 0) { + player_status->prevActionState = player_status->actionState; + player_status->actionState = actionState; + player_status->flags |= 0x80000000; + } } - } else { - //if () { - // goto hit_hazard; - //} + return; + } + + if (actionState == ActionState_HIT_HAZARD || actionState == ActionState_HIT_LAVA) { + u8 partner; + 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; + // Whilst Lakilester, Bow, or Parakarry's ability is active, hazards have no effect. + partner = player_data->currentPartner; + if ((partner - 7) < 2u || (s8)partner == PartnerId_PARAKARRY) { + if (D_8010EBB0) { + player_status->animFlags |= 0x4; + player_status->flags |= 0x800; + return; } } } + + if (actionState == ActionState_SLIDING) { + player_status->flags |= 0x10; + player_status->moveFrames = 0; + player_status->flags &= ~0x4000; + } + + 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; + + if (player_status->actionState == ActionState_SPIN) { + return; + } + + player_status->flags &= 0xFFFDFFFF; + player_status->animFlags &= 0xFFFEFFFF; + + if (unknown_struct[0xC]) { + stop_sound(unknown_struct[0xC]); + } + + if (player_status->unk_D8) { + ((UNK_PTR**) (player_status->unk_D8))[3][9] = 0xA; + player_status->unk_D8 = NULL; + } } -#else -void INCLUDE_ASM("code_7bb60_len_41b0", set_action_state, s32 actionState); -#endif INCLUDE_ASM("code_7bb60_len_41b0", update_locomotion_state); From db1accd9919e2b852affde656fca2aa79d50801e Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Tue, 8 Sep 2020 12:24:16 +0100 Subject: [PATCH 10/10] type PlayerStatus::unk_D8 --- include/common_structs.h | 2 +- src/code_7bb60_len_41b0.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index bac930aa54..51bb600a53 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1367,7 +1367,7 @@ typedef struct PlayerStatus { /* 0x0C4 */ char unk_C4[8]; /* 0x0CC */ s32 shadowID; /* 0x0D0 */ char unk_D0[8]; - /* 0x0D8 */ UNK_PTR unk_D8; + /* 0x0D8 */ UNK_PTR** unk_D8; /* 0x0DC */ s32 currentButtons; /* 0x0E0 */ s32 pressedButtons; /* 0x0E4 */ s32 heldButtons; diff --git a/src/code_7bb60_len_41b0.c b/src/code_7bb60_len_41b0.c index 7deec05cc7..413b8f31bd 100644 --- a/src/code_7bb60_len_41b0.c +++ b/src/code_7bb60_len_41b0.c @@ -151,7 +151,7 @@ void set_action_state(s32 actionState) { } if (player_status->unk_D8) { - ((UNK_PTR**) (player_status->unk_D8))[3][9] = 0xA; + player_status->unk_D8[3][9] = 0xA; player_status->unk_D8 = NULL; } }