From af98f5f9a30e7276ffe9c21c903cc6f1a866e39c Mon Sep 17 00:00:00 2001 From: theo3 Date: Mon, 15 Mar 2021 21:17:25 -0700 Subject: [PATCH 1/3] several more player functions done --- CONTRIBUTING.md | 4 +- asm/bigBarrel.s | 4 +- asm/bigGoron.s | 4 +- asm/code_0800857C.s | 2 +- asm/code_0806FA6C.s | 4 +- asm/code_08070698.s | 1349 +----------------------- asm/code_080732D0.s | 10 +- asm/code_08078778.s | 14 +- asm/jarPortal.s | 2 +- asm/non_matching/player/sub_08071634.s | 172 +++ asm/objectB.s | 2 +- data/data_08114208.s | 138 --- data/data_0811B9E0.s | 140 +++ include/area.h | 13 +- include/entity.h | 4 +- include/functions.h | 2 +- include/global.h | 14 +- include/player.h | 41 +- include/structures.h | 16 + linker.ld | 2 + src/arm_proxy.c | 33 +- src/code_0804AA84.c | 8 +- src/code_0805436C.c | 2 +- src/code_08077DF4.c | 2 +- src/enemy/acroBandits.c | 6 +- src/enemy/beetle.c | 12 +- src/enemy/bobomb.c | 14 +- src/enemy/bombPeahat.c | 18 +- src/enemy/businessScrub.c | 28 +- src/enemy/darkNut.c | 2 +- src/enemy/doorMimic.c | 4 +- src/enemy/fireballGuy.c | 2 +- src/enemy/gibdo.c | 10 +- src/enemy/gyorgMale.c | 200 ++-- src/enemy/helmasaur.c | 14 +- src/enemy/keese.c | 4 +- src/enemy/lakitu.c | 4 +- src/enemy/lakituCloud.c | 6 +- src/enemy/likeLike.c | 6 +- src/enemy/madderpillar.c | 4 +- src/enemy/moldorm.c | 6 +- src/enemy/moldworm.c | 16 +- src/enemy/octorok.c | 6 +- src/enemy/peahat.c | 12 +- src/enemy/pesto.c | 14 +- src/enemy/puffstool.c | 8 +- src/enemy/rockChuchu.c | 4 +- src/enemy/rollobite.c | 10 +- src/enemy/rope.c | 10 +- src/enemy/rupeeLike.c | 6 +- src/enemy/slime.c | 9 +- src/enemy/smallPesto.c | 6 +- src/enemy/spark.c | 2 +- src/enemy/spearMoblin.c | 4 +- src/enemy/spikedBeetle.c | 2 +- src/enemy/spinyChuchu.c | 6 +- src/enemy/tektite.c | 10 +- src/enemy/tektiteGolden.c | 10 +- src/enemy/wisp.c | 6 +- src/game.c | 3 +- src/item.c | 1 - src/item11.c | 4 +- src/manager/manager15.c | 6 +- src/manager/manager1A.c | 4 +- src/manager/manager3.c | 18 +- src/npc/beedle.c | 2 +- src/npc/bigGoron.c | 4 +- src/npc/cow.c | 24 +- src/object/backgroundCloud.c | 10 +- src/object/bakerOven.c | 4 +- src/object/bird.c | 4 +- src/object/button.c | 2 +- src/object/houseDoorExterior.c | 6 +- src/object/itemOnGround.c | 6 +- src/object/object2A.c | 2 +- src/object/object49.c | 4 +- src/object/object86.c | 8 +- src/object/pot.c | 12 +- src/player.c | 695 ++++++++++-- src/script.c | 4 +- 80 files changed, 1366 insertions(+), 1920 deletions(-) create mode 100644 asm/non_matching/player/sub_08071634.s create mode 100644 data/data_0811B9E0.s diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a438e7d..8b9e3fe5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -182,7 +182,7 @@ typedef struct Entity u32 * field_0x4; EntityType entityType; u8 action; - u8 previousActionFlag; + u8 subAction; u8 actionDelay; u8 field_0xf; u8 flags; @@ -199,7 +199,7 @@ What's the 12th byte in this struct? u32 * field_0x4; //4-7 EntityType entityType; //8-11 u8 action; //12 - u8 previousActionFlag; //13 + u8 subAction; //13 ``` --- diff --git a/asm/bigBarrel.s b/asm/bigBarrel.s index e7390c31..f721b772 100644 --- a/asm/bigBarrel.s +++ b/asm/bigBarrel.s @@ -176,7 +176,7 @@ _08088B82: subs r1, #0x50 movs r2, #0xa0 movs r3, #0x30 - bl sub_0806FBFC + bl CheckPlayerProximity cmp r0, #0 beq _08088BBA ldrb r0, [r5] @@ -194,7 +194,7 @@ _08088BBA: adds r1, #0x30 movs r2, #0xa0 movs r3, #0x30 - bl sub_0806FBFC + bl CheckPlayerProximity cmp r0, #0 beq _08088BDE ldrb r0, [r5] diff --git a/asm/bigGoron.s b/asm/bigGoron.s index 439e2cd7..4713c398 100644 --- a/asm/bigGoron.s +++ b/asm/bigGoron.s @@ -583,7 +583,7 @@ _0806D46C: ldrsh r1, [r4, r2] movs r2, #0x40 movs r3, #0x40 - bl sub_0806FBFC + bl CheckPlayerProximity cmp r0, #0 beq _0806D4AC adds r2, r4, #0 @@ -724,7 +724,7 @@ _0806D540: ldrsh r1, [r4, r2] movs r2, #0x18 movs r3, #0x40 - bl sub_0806FBFC + bl CheckPlayerProximity cmp r0, #0 beq _0806D5B4 _0806D590: diff --git a/asm/code_0800857C.s b/asm/code_0800857C.s index 3522fc17..c4a611b9 100644 --- a/asm/code_0800857C.s +++ b/asm/code_0800857C.s @@ -719,7 +719,7 @@ sub_08008AC6: @ 0x08008AC6 movs r3, #0xe2 movs r2, #0x3d strb r3, [r0, r2] - bl sub_08079458 + bl RespawnPlayer _08008AEC: pop {r0, pc} diff --git a/asm/code_0806FA6C.s b/asm/code_0806FA6C.s index 81ff4789..438a5157 100644 --- a/asm/code_0806FA6C.s +++ b/asm/code_0806FA6C.s @@ -144,8 +144,8 @@ UnloadHitbox: @ 0x0806FBEC str r0, [r4, #0x48] pop {r4, pc} - thumb_func_start sub_0806FBFC -sub_0806FBFC: @ 0x0806FBFC + thumb_func_start CheckPlayerProximity +CheckPlayerProximity: @ 0x0806FBFC push {r4, r5, r6, lr} adds r5, r3, #0 ldr r4, _0806FC20 @ =gPlayerEntity diff --git a/asm/code_08070698.s b/asm/code_08070698.s index 10b20c3e..69452e1c 100644 --- a/asm/code_08070698.s +++ b/asm/code_08070698.s @@ -6,1322 +6,9 @@ .text - thumb_func_start sub_080714A8 -sub_080714A8: @ 0x080714A8 - push {r4, lr} - adds r4, r0, #0 - ldr r0, _08071524 @ =gArea - ldrb r0, [r0, #0x17] - cmp r0, #5 - bgt _080714BE - cmp r0, #4 - blt _080714BE - ldr r0, _08071528 @ =gPlayerEntity - bl sub_0806F948 -_080714BE: - ldr r3, _0807152C @ =gPlayerState - ldrb r1, [r3, #0xd] - movs r0, #0x84 - ands r0, r1 - cmp r0, #0 - bne _0807153E - ldrb r0, [r4, #0x15] - cmp r0, r1 - beq _080714D4 - movs r0, #8 - strb r0, [r4, #0xe] -_080714D4: - ldrb r0, [r4, #0xe] - subs r0, #1 - strb r0, [r4, #0xe] - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0xff - bne _08071538 - ldrb r0, [r3, #0xd] - strb r0, [r4, #0x15] - lsls r0, r0, #0x18 - lsrs r0, r0, #0x1a - strb r0, [r4, #0x14] - movs r0, #0x80 - lsls r0, r0, #0xa - str r0, [r4, #0x20] - movs r1, #0 - movs r0, #0x80 - lsls r0, r0, #1 - strh r0, [r4, #0x24] - movs r0, #9 - strb r0, [r4, #0xc] - movs r0, #7 - strb r0, [r4, #0xd] - strb r1, [r4, #0xf] - ldr r1, [r3, #0x30] - movs r0, #8 - ands r0, r1 - ldr r4, _08071530 @ =0x0000080C - adds r2, r4, #0 - cmp r0, #0 - beq _08071516 - ldr r0, _08071534 @ =0x0000041C - adds r2, r0, #0 -_08071516: - strh r2, [r3, #8] - movs r0, #0x21 - rsbs r0, r0, #0 - ands r1, r0 - str r1, [r3, #0x30] - b _0807156A - .align 2, 0 -_08071524: .4byte gArea -_08071528: .4byte gPlayerEntity -_0807152C: .4byte gPlayerState -_08071530: .4byte 0x0000080C -_08071534: .4byte 0x0000041C -_08071538: - ldrb r0, [r3, #0xd] - strb r0, [r4, #0x15] - b _08071542 -_0807153E: - movs r0, #8 - strb r0, [r4, #0xe] -_08071542: - ldr r0, _0807155C @ =gArea - ldrb r0, [r0, #0x17] - cmp r0, #4 - bne _08071560 - adds r0, r4, #0 - adds r0, #0x5a - ldrb r0, [r0] - cmp r0, #0 - bne _08071566 - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - b _0807156A - .align 2, 0 -_0807155C: .4byte gArea -_08071560: - adds r0, r4, #0 - bl sub_08077698 -_08071566: - bl sub_08079938 -_0807156A: - pop {r4, pc} - thumb_func_start sub_0807156C -sub_0807156C: @ 0x0807156C - push {lr} - ldr r2, _080715A0 @ =gRoomControls - movs r1, #0 - str r1, [r2, #0x30] - ldr r2, _080715A4 @ =gUnk_02034490 - movs r1, #1 - strb r1, [r2] - movs r1, #3 - strb r1, [r0, #0xd] - movs r1, #0x1e - strb r1, [r0, #0xf] - ldr r2, _080715A8 @ =gPlayerState - movs r1, #0xe7 - lsls r1, r1, #3 - strh r1, [r2, #8] - movs r1, #6 - movs r2, #1 - movs r3, #0 - bl CreateObjectWithParent - bl sub_08077B20 - bl sub_0805E544 - pop {pc} - .align 2, 0 -_080715A0: .4byte gRoomControls -_080715A4: .4byte gUnk_02034490 -_080715A8: .4byte gPlayerState - - thumb_func_start sub_080715AC -sub_080715AC: @ 0x080715AC - push {r4, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xf] - cmp r0, #0 - bne _080715CC - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - ldr r0, _080715D0 @ =gPlayerState - ldr r0, [r0, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - beq _080715CC - movs r0, #4 - strb r0, [r4, #0xd] -_080715CC: - pop {r4, pc} - .align 2, 0 -_080715D0: .4byte gPlayerState - - thumb_func_start sub_080715D4 -sub_080715D4: @ 0x080715D4 - push {lr} - adds r3, r0, #0 - movs r2, #0 - movs r0, #5 - strb r0, [r3, #0xd] - movs r0, #0x29 - adds r0, r0, r3 - mov ip, r0 - ldrb r1, [r0] - movs r0, #0x39 - rsbs r0, r0, #0 - ands r0, r1 - mov r1, ip - strb r0, [r1] - strb r2, [r3, #0xf] - ldrb r0, [r3, #0x19] - movs r1, #3 - orrs r0, r1 - strb r0, [r3, #0x19] - adds r0, r3, #0 - adds r0, #0x80 - movs r2, #0x80 - lsls r2, r2, #1 - str r2, [r0] - adds r0, #4 - str r2, [r0] - adds r0, r3, #0 - adds r1, r2, #0 - movs r3, #0 - bl sub_0805EC9C - ldr r2, _08071628 @ =gPlayerState - ldr r0, _0807162C @ =0x000002C3 - strh r0, [r2, #8] - ldr r0, [r2, #0x30] - movs r1, #0x80 - orrs r0, r1 - str r0, [r2, #0x30] - ldr r0, _08071630 @ =0x0000016F - bl SoundReq - pop {pc} - .align 2, 0 -_08071628: .4byte gPlayerState -_0807162C: .4byte 0x000002C3 -_08071630: .4byte 0x0000016F - - thumb_func_start sub_08071634 -sub_08071634: @ 0x08071634 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - adds r5, r0, #0 - adds r0, #0x81 - ldrb r0, [r0] - cmp r0, #0 - beq _08071654 - adds r1, r5, #0 - adds r1, #0x80 - ldr r0, [r1] - adds r0, #0x80 - lsls r0, r0, #0x14 - lsrs r7, r0, #0x17 - adds r4, r1, #0 - b _0807166A -_08071654: - adds r4, r5, #0 - adds r4, #0x80 - ldrb r1, [r4] - lsrs r1, r1, #6 - movs r0, #3 - eors r1, r0 - adds r1, #1 - movs r0, #0x10 - bl __divsi3 - asrs r7, r0, #1 -_0807166A: - adds r0, r5, #0 - adds r0, #0x84 - ldr r3, [r0] - movs r1, #0x80 - lsls r1, r1, #1 - adds r2, r0, #0 - cmp r3, r1 - bls _08071684 - adds r0, r3, #0 - adds r0, #0x80 - lsls r0, r0, #0x14 - lsrs r3, r0, #0x17 - b _08071694 -_08071684: - cmp r3, r1 - bne _0807168C - movs r3, #0x10 - b _08071694 -_0807168C: - ldr r1, _080716B0 @ =gUnk_0811BABC - lsrs r0, r3, #5 - adds r0, r0, r1 - ldrb r3, [r0] -_08071694: - movs r0, #0x80 - lsls r0, r0, #9 - mov r8, r0 - adds r0, r5, #0 - adds r0, #0x5a - ldrb r0, [r0] - cmp r0, #2 - beq _080716EA - cmp r0, #2 - bgt _080716B4 - cmp r0, #1 - beq _080716BA - b _08071754 - .align 2, 0 -_080716B0: .4byte gUnk_0811BABC -_080716B4: - cmp r0, #3 - beq _0807171E - b _08071754 -_080716BA: - movs r1, #0x29 - adds r1, r1, r5 - mov ip, r1 - ldrb r1, [r1] - movs r0, #0x39 - rsbs r0, r0, #0 - ands r0, r1 - mov r1, ip - strb r0, [r1] - ldr r0, [r4] - cmp r0, #0x80 - bls _080716D6 - subs r0, r0, r7 - str r0, [r4] -_080716D6: - lsls r1, r3, #1 - ldr r0, [r2] - adds r0, r0, r1 - str r0, [r2] - mov r0, r8 - lsls r1, r0, #1 - ldr r0, [r5, #0x30] - adds r0, r0, r1 - str r0, [r5, #0x30] - b _08071754 -_080716EA: - ldr r0, [r4] - adds r0, r0, r7 - str r0, [r4] - ldr r1, [r2] - movs r6, #0x80 - lsls r6, r6, #1 - cmp r1, r6 - bls _08071710 - ldr r0, _0807170C @ =0x0000017F - cmp r1, r0 - bhi _08071702 - lsrs r3, r3, #1 -_08071702: - subs r0, r1, r3 - cmp r0, #0xff - bhi _08071716 - str r6, [r2] - b _08071718 - .align 2, 0 -_0807170C: .4byte 0x0000017F -_08071710: - cmp r1, #0x80 - bls _08071718 - subs r0, r1, r3 -_08071716: - str r0, [r2] -_08071718: - ldr r0, [r5, #0x34] - mov r1, r8 - b _08071750 -_0807171E: - ldr r0, [r4] - ldr r6, _08071740 @ =0x0000033F - cmp r0, r6 - bhi _0807172A - adds r0, r0, r7 - str r0, [r4] -_0807172A: - ldr r1, [r2] - cmp r1, r6 - bls _08071744 - movs r0, #8 - strb r0, [r5, #0xe] - movs r0, #0x1e - strb r0, [r5, #0xf] - movs r0, #6 - strb r0, [r5, #0xd] - b _0807174A - .align 2, 0 -_08071740: .4byte 0x0000033F -_08071744: - lsls r0, r3, #1 - adds r0, r1, r0 - str r0, [r2] -_0807174A: - mov r0, r8 - lsls r1, r0, #1 - ldr r0, [r5, #0x34] -_08071750: - subs r0, r0, r1 - str r0, [r5, #0x34] -_08071754: - ldr r1, [r4] - ldr r2, [r2] - adds r0, r5, #0 - movs r3, #0 - bl sub_0805EC9C - adds r0, r5, #0 - bl UpdateAnimationSingleFrame - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7, pc} - - thumb_func_start sub_0807176C -sub_0807176C: @ 0x0807176C - push {r4, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xe] - cmp r0, #0 - bne _080717C6 - movs r1, #0x80 - lsls r1, r1, #6 - adds r0, r4, #0 - bl sub_08003FC4 - cmp r0, #0 - bne _080717CA - ldrb r1, [r4, #0x18] - movs r0, #4 - rsbs r0, r0, #0 - ands r0, r1 - strb r0, [r4, #0x18] - ldr r1, _080717AC @ =gArea - ldrb r0, [r1, #0x17] - cmp r0, #3 - bne _080717B0 - ldrb r0, [r4, #0xf] - subs r0, #1 - strb r0, [r4, #0xf] - lsls r0, r0, #0x18 - cmp r0, #0 - bne _080717CA - adds r0, r4, #0 - bl sub_080717F8 - b _080717CA - .align 2, 0 -_080717AC: .4byte gArea -_080717B0: - cmp r0, #6 - bne _080717C0 - ldr r0, _080717BC @ =gUnk_0813AB58 - bl DoExitTransition - b _080717CA - .align 2, 0 -_080717BC: .4byte gUnk_0813AB58 -_080717C0: - movs r0, #1 - strb r0, [r1, #0x19] - b _080717CA -_080717C6: - subs r0, #1 - strb r0, [r4, #0xe] -_080717CA: - pop {r4, pc} - - thumb_func_start sub_080717CC -sub_080717CC: @ 0x080717CC - push {lr} - adds r1, r0, #0 - ldr r0, _080717E4 @ =gFadeControl - ldrb r0, [r0] - cmp r0, #0 - bne _080717F4 - ldrb r0, [r1, #0xe] - cmp r0, #0 - beq _080717E8 - subs r0, #1 - strb r0, [r1, #0xe] - b _080717F4 - .align 2, 0 -_080717E4: .4byte gFadeControl -_080717E8: - adds r0, r1, #0 - bl sub_080717F8 - movs r0, #0x10 - bl sub_080500F4 -_080717F4: - pop {pc} - .align 2, 0 - - thumb_func_start sub_080717F8 -sub_080717F8: @ 0x080717F8 - push {r4, lr} - ldr r2, _08071850 @ =gArea - ldrb r1, [r2, #0x16] - lsls r1, r1, #1 - strb r1, [r0, #0x14] - ldr r3, _08071854 @ =gUnk_0811BAC4 - ldrb r1, [r2, #0x16] - lsls r1, r1, #2 - adds r1, r1, r3 - ldrh r1, [r1] - ldrh r4, [r2, #0x12] - adds r1, r1, r4 - movs r4, #0 - strh r1, [r0, #0x2e] - ldrb r1, [r2, #0x16] - lsls r1, r1, #1 - adds r1, #1 - lsls r1, r1, #1 - adds r1, r1, r3 - ldrh r1, [r1] - ldrh r3, [r2, #0x14] - adds r1, r1, r3 - strh r1, [r0, #0x32] - movs r1, #0xb4 - strb r1, [r2, #0x1a] - ldr r1, _08071858 @ =gUnk_02034490 - strb r4, [r1] - movs r1, #9 - strb r1, [r0, #0xc] - strb r4, [r0, #0xd] - ldr r3, _0807185C @ =gPlayerState - ldr r1, [r3, #0x30] - movs r2, #0x21 - rsbs r2, r2, #0 - ands r1, r2 - movs r2, #0x80 - orrs r1, r2 - str r1, [r3, #0x30] - bl sub_0805EC60 - bl UnfreezeTime - pop {r4, pc} - .align 2, 0 -_08071850: .4byte gArea -_08071854: .4byte gUnk_0811BAC4 -_08071858: .4byte gUnk_02034490 -_0807185C: .4byte gPlayerState - - thumb_func_start sub_08071860 -sub_08071860: @ 0x08071860 - push {r4, lr} - adds r4, r0, #0 - bl sub_08078EFC - cmp r0, #0 - beq _08071876 - bl sub_08056360 - bl sub_08071A6C - b _08071896 -_08071876: - ldr r0, _08071898 @ =gPlayerState - adds r0, #0xa8 - movs r1, #0x13 - strb r1, [r0] - ldrb r1, [r4, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r4, #0x10] - ldr r1, _0807189C @ =gUnk_0811BAD4 - ldrb r0, [r4, #0xd] - lsls r0, r0, #2 - adds r0, r0, r1 - ldr r1, [r0] - adds r0, r4, #0 - bl _call_via_r1 -_08071896: - pop {r4, pc} - .align 2, 0 -_08071898: .4byte gPlayerState -_0807189C: .4byte gUnk_0811BAD4 - - thumb_func_start sub_080718A0 -sub_080718A0: @ 0x080718A0 - push {r4, r5, lr} - adds r4, r0, #0 - bl ResetPlayer - ldr r0, _080718EC @ =gUnk_03000B80 - adds r0, #0x63 - movs r1, #0 - strb r1, [r0] - adds r0, r4, #0 - adds r0, #0x3d - strb r1, [r0] - ldr r1, _080718F0 @ =gUnk_03003DC0 - movs r2, #6 - movs r0, #6 - strb r0, [r1] - ldrb r1, [r4, #0x11] - subs r0, #0x16 - ands r0, r1 - orrs r0, r2 - strb r0, [r4, #0x11] - ldr r5, _080718F4 @ =gPlayerState - ldr r0, [r5, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - beq _080718F8 - movs r0, #2 - strb r0, [r4, #0xd] - adds r2, r4, #0 - adds r2, #0x29 - ldrb r1, [r2] - subs r0, #0x3b - ands r0, r1 - strb r0, [r2] - bl sub_08052BB8 - b _08071938 - .align 2, 0 -_080718EC: .4byte gUnk_03000B80 -_080718F0: .4byte gUnk_03003DC0 -_080718F4: .4byte gPlayerState -_080718F8: - ldrb r0, [r5, #2] - cmp r0, #0 - bne _08071928 - ldrb r0, [r4, #0xd] - adds r0, #1 - strb r0, [r4, #0xd] - ldrb r0, [r4, #0x14] - cmp r0, #2 - bne _08071914 - ldr r0, _08071910 @ =0x000003CA - b _08071916 - .align 2, 0 -_08071910: .4byte 0x000003CA -_08071914: - ldr r0, _08071924 @ =0x000003C6 -_08071916: - strh r0, [r5, #8] - ldrb r1, [r4, #0x18] - movs r0, #0x41 - rsbs r0, r0, #0 - ands r0, r1 - strb r0, [r4, #0x18] - b _08071938 - .align 2, 0 -_08071924: .4byte 0x000003C6 -_08071928: - movs r1, #0x80 - lsls r1, r1, #6 - adds r0, r4, #0 - bl sub_08003FC4 - cmp r0, #0 - bne _08071938 - strb r0, [r5, #2] -_08071938: - pop {r4, r5, pc} - .align 2, 0 - - thumb_func_start sub_0807193C -sub_0807193C: @ 0x0807193C - push {r4, lr} - adds r4, r0, #0 - bl UpdateAnimationSingleFrame - adds r0, r4, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08071986 - ldrb r0, [r4, #0xd] - adds r0, #1 - strb r0, [r4, #0xd] - adds r0, r4, #0 - movs r1, #6 - movs r2, #0 - movs r3, #0 - bl CreateObjectWithParent - str r0, [r4, #0x54] - cmp r0, #0 - beq _08071986 - ldrb r0, [r4, #0x14] - cmp r0, #2 - bne _0807197C - ldr r1, _08071978 @ =gPlayerState - movs r0, #0xf3 - lsls r0, r0, #2 - b _08071980 - .align 2, 0 -_08071978: .4byte gPlayerState -_0807197C: - ldr r1, _08071988 @ =gPlayerState - ldr r0, _0807198C @ =0x000003C7 -_08071980: - strh r0, [r1, #8] - bl sub_08052BB8 -_08071986: - pop {r4, pc} - .align 2, 0 -_08071988: .4byte gPlayerState -_0807198C: .4byte 0x000003C7 - - thumb_func_start sub_08071990 -sub_08071990: @ 0x08071990 - push {r4, lr} - adds r2, r0, #0 - ldr r0, _080719C0 @ =gTextBox - ldrb r1, [r0] - movs r0, #0x7f - ands r0, r1 - cmp r0, #0 - bne _080719E2 - ldrb r0, [r2, #0xd] - adds r0, #1 - strb r0, [r2, #0xd] - ldr r3, _080719C4 @ =gPlayerState - ldr r0, [r3, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080719D8 - ldrb r0, [r2, #0x14] - cmp r0, #2 - bne _080719CC - ldr r0, _080719C8 @ =0x000003CD - strh r0, [r3, #8] - b _08071A4A - .align 2, 0 -_080719C0: .4byte gTextBox -_080719C4: .4byte gPlayerState -_080719C8: .4byte 0x000003CD -_080719CC: - ldr r0, _080719D4 @ =0x000003C9 - strh r0, [r3, #8] - b _08071A4A - .align 2, 0 -_080719D4: .4byte 0x000003C9 -_080719D8: - bl sub_08071A6C - bl sub_08079258 - b _08071A4A -_080719E2: - ldr r4, _08071A20 @ =gPlayerState - ldr r0, [r4, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - bne _08071A4A - ldrb r0, [r2, #0x14] - movs r3, #0 - cmp r0, #2 - bne _080719F8 - movs r3, #4 -_080719F8: - ldr r0, [r2, #0x54] - ldrb r0, [r0, #0xe] - cmp r0, #0 - beq _08071A24 - adds r0, r3, #0 - adds r0, #0xc8 - adds r1, r2, #0 - adds r1, #0x58 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - ldrb r1, [r1] - cmp r0, r1 - beq _08071A44 - movs r1, #0xf2 - lsls r1, r1, #2 - adds r0, r1, #0 - adds r0, r3, r0 - strh r0, [r4, #8] - b _08071A4A - .align 2, 0 -_08071A20: .4byte gPlayerState -_08071A24: - adds r0, r3, #0 - adds r0, #0xc7 - adds r1, r2, #0 - adds r1, #0x58 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - ldrb r1, [r1] - cmp r0, r1 - beq _08071A44 - ldr r1, _08071A40 @ =0x000003C7 - adds r0, r3, r1 - strh r0, [r4, #8] - b _08071A4A - .align 2, 0 -_08071A40: .4byte 0x000003C7 -_08071A44: - adds r0, r2, #0 - bl UpdateAnimationSingleFrame -_08071A4A: - pop {r4, pc} - - thumb_func_start sub_08071A4C -sub_08071A4C: @ 0x08071A4C - push {r4, lr} - adds r4, r0, #0 - bl UpdateAnimationSingleFrame - adds r4, #0x5a - ldrb r1, [r4] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08071A68 - bl sub_08071A6C - bl sub_0807921C -_08071A68: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_08071A6C -sub_08071A6C: @ 0x08071A6C - ldr r1, _08071A84 @ =gUnk_03003DC0 - movs r0, #0 - strb r0, [r1] - ldr r3, _08071A88 @ =gPlayerEntity - ldrb r1, [r3, #0x11] - lsrs r2, r1, #4 - subs r0, #0x10 - ands r0, r1 - orrs r0, r2 - strb r0, [r3, #0x11] - bx lr - .align 2, 0 -_08071A84: .4byte gUnk_03003DC0 -_08071A88: .4byte gPlayerEntity - - thumb_func_start sub_08071A8C -sub_08071A8C: @ 0x08071A8C - push {lr} - ldr r1, _08071AA8 @ =gPlayerState - adds r1, #0xa8 - movs r2, #0x19 - strb r2, [r1] - ldr r2, _08071AAC @ =gUnk_0811BAE4 - ldrb r1, [r0, #0xd] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_08071AA8: .4byte gPlayerState -_08071AAC: .4byte gUnk_0811BAE4 - - thumb_func_start sub_08071AB0 -sub_08071AB0: @ 0x08071AB0 - push {r4, lr} - adds r3, r0, #0 - ldrb r0, [r3, #0xd] - adds r0, #1 - strb r0, [r3, #0xd] - ldr r1, _08071AD8 @ =gPlayerState - ldr r2, [r1, #0x30] - movs r0, #1 - orrs r2, r0 - str r2, [r1, #0x30] - ldrb r4, [r3, #0xa] - cmp r4, #1 - bne _08071ADC - movs r1, #0 - movs r0, #0 - strh r0, [r3, #0x24] - strb r1, [r3, #0xe] - strb r4, [r3, #0xf] - b _08071AE8 - .align 2, 0 -_08071AD8: .4byte gPlayerState -_08071ADC: - movs r0, #0x80 - ands r2, r0 - cmp r2, #0 - beq _08071AE6 - movs r0, #0x40 -_08071AE6: - strh r0, [r3, #0x24] -_08071AE8: - adds r0, r3, #0 - bl sub_08071AF0 - pop {r4, pc} - - thumb_func_start sub_08071AF0 -sub_08071AF0: @ 0x08071AF0 - push {r4, r5, lr} - adds r4, r0, #0 - ldr r5, _08071B34 @ =gPlayerState - adds r0, r5, #0 - adds r0, #0x80 - movs r1, #0 - strh r1, [r0] - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - ldrb r0, [r4, #0xa] - cmp r0, #1 - bne _08071B44 - ldrb r0, [r4, #0xf] - subs r0, #1 - strb r0, [r4, #0xf] - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08071B58 - ldr r0, _08071B38 @ =gUnk_0811BAF0 - ldrb r1, [r4, #0xe] - lsls r1, r1, #2 - adds r1, r1, r0 - ldrb r2, [r1] - adds r0, r2, #0 - cmp r0, #0xff - beq _08071B3C - strb r2, [r4, #0xf] - ldrh r0, [r1, #2] - strh r0, [r4, #0x24] - ldrb r0, [r4, #0xe] - adds r0, #1 - strb r0, [r4, #0xe] - b _08071B58 - .align 2, 0 -_08071B34: .4byte gPlayerState -_08071B38: .4byte gUnk_0811BAF0 -_08071B3C: - ldrb r0, [r4, #0xd] - adds r0, #1 - strb r0, [r4, #0xd] - b _08071B5C -_08071B44: - ldrb r0, [r5, #6] - subs r0, #1 - strb r0, [r5, #6] - movs r1, #0x7f - ands r0, r1 - cmp r0, #0 - bne _08071B58 - ldrb r0, [r4, #0xd] - adds r0, #1 - strb r0, [r4, #0xd] -_08071B58: - bl sub_08079E08 -_08071B5C: - pop {r4, r5, pc} - .align 2, 0 - - thumb_func_start sub_08071B60 -sub_08071B60: @ 0x08071B60 - push {r4, r5, lr} - adds r4, r0, #0 - ldr r5, _08071BAC @ =gPlayerState - movs r2, #0 - movs r0, #2 - strb r0, [r5, #6] - ldr r0, [r5, #0x30] - movs r1, #2 - rsbs r1, r1, #0 - ands r0, r1 - str r0, [r5, #0x30] - strb r2, [r4, #0xa] - adds r0, r4, #0 - adds r0, #0x42 - strb r2, [r0] - adds r0, r4, #0 - bl sub_080728AC - movs r0, #6 - strb r0, [r4, #0xf] - ldr r0, [r5, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - bne _08071BA8 - movs r0, #0x82 - lsls r0, r0, #1 - strh r0, [r5, #8] - movs r0, #3 - strh r0, [r4, #0x12] - ldrb r1, [r4, #0x14] - lsrs r1, r1, #1 - adds r1, #0x3c - adds r0, r4, #0 - bl InitAnimationForceUpdate -_08071BA8: - pop {r4, r5, pc} - .align 2, 0 -_08071BAC: .4byte gPlayerState - - thumb_func_start sub_08071BB0 -sub_08071BB0: @ 0x08071BB0 - push {lr} - ldrb r2, [r0, #0x10] - movs r1, #0x7f - ands r1, r2 - strb r1, [r0, #0x10] - ldr r2, _08071BD4 @ =gUnk_0811BB2C - ldrb r1, [r0, #0xd] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - ldr r0, _08071BD8 @ =gPlayerState - adds r0, #0xa8 - movs r1, #0x12 - strb r1, [r0] - pop {pc} - .align 2, 0 -_08071BD4: .4byte gUnk_0811BB2C -_08071BD8: .4byte gPlayerState - - thumb_func_start sub_08071BDC -sub_08071BDC: @ 0x08071BDC - push {r4, r5, lr} - adds r4, r0, #0 - ldr r5, _08071C10 @ =gPlayerState - ldr r0, [r5, #0x30] - movs r1, #0x88 - lsls r1, r1, #1 - ands r0, r1 - cmp r0, #0 - bne _08071C9C - movs r1, #0x80 - lsls r1, r1, #6 - adds r0, r4, #0 - bl sub_08003FC4 - cmp r0, #0 - beq _08071C1C - ldr r0, [r5, #0x30] - movs r1, #8 - ands r0, r1 - cmp r0, #0 - beq _08071C14 - movs r0, #0x84 - lsls r0, r0, #3 - strh r0, [r5, #8] - b _08071C9C - .align 2, 0 -_08071C10: .4byte gPlayerState -_08071C14: - movs r0, #0x81 - lsls r0, r0, #4 - strh r0, [r5, #8] - b _08071C9C -_08071C1C: - strb r0, [r5, #0xc] - ldr r1, [r5, #0x30] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08071C4C - ldrb r0, [r5, #0x12] - subs r0, #8 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #2 - bhi _08071C42 - adds r0, r4, #0 - bl sub_0807A298 - bl sub_08079458 - movs r0, #0xa - strb r0, [r4, #0xc] -_08071C42: - ldr r0, _08071C48 @ =0x00000C1A - b _08071C5A - .align 2, 0 -_08071C48: .4byte 0x00000C1A -_08071C4C: - movs r0, #8 - ands r1, r0 - movs r0, #0xde - lsls r0, r0, #1 - cmp r1, #0 - beq _08071C5A - ldr r0, _08071CA0 @ =0x00000459 -_08071C5A: - ldr r2, _08071CA4 @ =gPlayerState - movs r3, #0 - strh r0, [r2, #8] - ldr r0, [r2, #0x30] - ldr r1, _08071CA8 @ =0xFEDBF2FE - ands r0, r1 - str r0, [r2, #0x30] - movs r0, #1 - strb r0, [r4, #0xd] - movs r0, #4 - strb r0, [r4, #0x14] - adds r5, r4, #0 - adds r5, #0x29 - ldrb r1, [r5] - subs r0, #0x3d - ands r0, r1 - movs r1, #8 - orrs r0, r1 - strb r0, [r5] - ldrb r0, [r4, #0x18] - movs r1, #3 - orrs r0, r1 - strb r0, [r4, #0x18] - strb r3, [r2, #2] - strb r3, [r2, #6] - adds r0, r4, #0 - bl sub_0800451C - bl ResetPlayer - movs r0, #0x87 - bl SoundReq -_08071C9C: - pop {r4, r5, pc} - .align 2, 0 -_08071CA0: .4byte 0x00000459 -_08071CA4: .4byte gPlayerState -_08071CA8: .4byte 0xFEDBF2FE - - thumb_func_start sub_08071CAC -sub_08071CAC: @ 0x08071CAC - push {r4, lr} - adds r4, r0, #0 - bl UpdateAnimationSingleFrame - adds r0, r4, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r3, #0x80 - adds r0, r3, #0 - ands r0, r1 - cmp r0, #0 - beq _08071CFE - ldr r1, _08071CE0 @ =gPlayerState - ldr r2, [r1, #0x30] - adds r0, r2, #0 - ands r0, r3 - cmp r0, #0 - bne _08071CEC - movs r0, #8 - ands r2, r0 - ldr r0, _08071CE4 @ =0x000002BD - cmp r2, #0 - beq _08071CEE - ldr r0, _08071CE8 @ =0x0000045A - b _08071CEE - .align 2, 0 -_08071CE0: .4byte gPlayerState -_08071CE4: .4byte 0x000002BD -_08071CE8: .4byte 0x0000045A -_08071CEC: - ldr r0, _08071D00 @ =0x00000C1B -_08071CEE: - strh r0, [r1, #8] - movs r0, #2 - strb r0, [r4, #0xd] - movs r0, #0xf0 - strb r0, [r4, #0xe] - movs r0, #0x7b - bl SoundReq -_08071CFE: - pop {r4, pc} - .align 2, 0 -_08071D00: .4byte 0x00000C1B - - thumb_func_start sub_08071D04 -sub_08071D04: @ 0x08071D04 - push {r4, r5, lr} - adds r5, r0, #0 - bl UpdateAnimationSingleFrame - adds r0, r5, #0 - adds r0, #0x5a - ldrb r0, [r0] - cmp r0, #0 - beq _08071D7A - movs r4, #0 - movs r0, #0x28 - bl sub_080544DC - adds r1, r0, #0 - cmp r1, #0 - beq _08071D3A - ldr r0, _08071D6C @ =gSave - adds r0, r0, r1 - adds r0, #0xb5 - movs r1, #0x20 - strb r1, [r0] - movs r0, #0x40 - movs r1, #0x60 - movs r2, #2 - bl CreateObject - movs r4, #0x20 -_08071D3A: - cmp r4, #0 - beq _08071D74 - adds r0, r4, #0 - bl ModHealth - movs r2, #0 - movs r0, #3 - strb r0, [r5, #0xd] - ldr r1, _08071D70 @ =gPlayerState - adds r0, r1, #0 - adds r0, #0x3c - strb r2, [r0] - movs r0, #0xff - strb r0, [r5, #0x15] - movs r3, #0 - strh r2, [r5, #0x24] - movs r0, #0xc0 - lsls r0, r0, #9 - str r0, [r5, #0x20] - movs r0, #1 - strb r0, [r1, #2] - adds r1, #0x26 - strb r3, [r1] - b _08071D7A - .align 2, 0 -_08071D6C: .4byte gSave -_08071D70: .4byte gPlayerState -_08071D74: - ldr r1, _08071D7C @ =gScreenTransition - movs r0, #1 - strb r0, [r1, #5] -_08071D7A: - pop {r4, r5, pc} - .align 2, 0 -_08071D7C: .4byte gScreenTransition - - thumb_func_start sub_08071D80 -sub_08071D80: @ 0x08071D80 - push {r4, r5, lr} - adds r4, r0, #0 - bl UpdateAnimationSingleFrame - ldr r5, _08071DB4 @ =gPlayerState - movs r0, #1 - strb r0, [r5, #0x14] - adds r0, r4, #0 - bl sub_08073904 - ldrb r1, [r5, #2] - movs r0, #7 - ands r0, r1 - cmp r0, #3 - bne _08071DB2 - movs r0, #0 - strb r0, [r5, #2] - adds r1, r4, #0 - adds r1, #0x3d - movs r0, #0xe2 - strb r0, [r1] - bl UnfreezeTime - bl sub_080791D0 -_08071DB2: - pop {r4, r5, pc} - .align 2, 0 -_08071DB4: .4byte gPlayerState - - thumb_func_start sub_08071DB8 -sub_08071DB8: @ 0x08071DB8 - push {lr} - ldr r2, _08071DCC @ =gUnk_0811BB3C - ldrb r1, [r0, #0xd] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_08071DCC: .4byte gUnk_0811BB3C - - thumb_func_start sub_08071DD0 -sub_08071DD0: @ 0x08071DD0 - push {lr} - adds r2, r0, #0 - ldr r1, _08071DF4 @ =gPlayerState - adds r0, r1, #0 - adds r0, #0x38 - ldrb r0, [r0] - strb r0, [r2, #0xe] - adds r3, r1, #0 - adds r3, #0x39 - ldrb r0, [r3] - cmp r0, #0 - beq _08071DF8 - movs r0, #0 - strb r0, [r3] - movs r0, #2 - strb r0, [r2, #0xd] - adds r0, #0xfe - b _08071E00 - .align 2, 0 -_08071DF4: .4byte gPlayerState -_08071DF8: - movs r0, #1 - strb r0, [r2, #0xd] - movs r0, #0x8a - lsls r0, r0, #1 -_08071E00: - strh r0, [r1, #8] - pop {pc} - - thumb_func_start sub_08071E04 -sub_08071E04: @ 0x08071E04 - push {r4, r5, lr} - adds r4, r0, #0 - ldr r0, [r4, #0x34] - cmp r0, #0 - beq _08071E38 - ldr r5, _08071E34 @ =gPlayerState - ldrb r0, [r5, #0x14] - cmp r0, #0 - bne _08071E38 - bl sub_0807A1B8 - ldrb r0, [r5, #0x12] - cmp r0, #1 - bne _08071E38 - movs r0, #7 - strb r0, [r5, #0x11] - ldr r0, [r5, #0x30] - movs r1, #0x80 - lsls r1, r1, #2 - orrs r0, r1 - str r0, [r5, #0x30] - bl sub_080791BC - b _08071E72 - .align 2, 0 -_08071E34: .4byte gPlayerState -_08071E38: - adds r0, r4, #0 - bl UpdateAnimationSingleFrame - bl sub_08079B24 - cmp r0, #0 - bne _08071E4E - adds r0, r4, #0 - bl sub_08079708 - b _08071E72 -_08071E4E: - bl sub_080792D8 - bl sub_0807953C - cmp r0, #0 - beq _08071E60 - ldrb r0, [r4, #0xe] - subs r0, #2 - b _08071E64 -_08071E60: - ldrb r0, [r4, #0xe] - subs r0, #1 -_08071E64: - strb r0, [r4, #0xe] - movs r0, #0xe - ldrsb r0, [r4, r0] - cmp r0, #0 - bgt _08071E72 - bl sub_080791BC -_08071E72: - pop {r4, r5, pc} - - thumb_func_start sub_08071E74 -sub_08071E74: @ 0x08071E74 - push {r4, lr} - adds r4, r0, #0 - movs r1, #0x80 - lsls r1, r1, #6 - bl sub_08003FC4 - bl sub_08079E08 - ldrb r0, [r4, #0xe] - adds r1, r0, #0 - adds r1, #0xff - strb r1, [r4, #0xe] - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08071E96 - bl sub_080791BC -_08071E96: - pop {r4, pc} - - thumb_func_start sub_08071E98 -sub_08071E98: @ 0x08071E98 + thumb_func_start PlayerEmptyBottle +PlayerEmptyBottle: @ 0x08071E98 push {lr} ldr r2, _08071EAC @ =gUnk_0811BB48 ldrb r1, [r0, #0xd] @@ -1403,8 +90,8 @@ _08071F32: .align 2, 0 _08071F34: .4byte gPlayerState - thumb_func_start sub_08071F38 -sub_08071F38: @ 0x08071F38 + thumb_func_start PlayerFrozen +PlayerFrozen: @ 0x08071F38 push {lr} ldr r2, _08071F4C @ =gUnk_0811BB50 ldrb r1, [r0, #0xd] @@ -1754,8 +441,8 @@ _080721DE: .align 2, 0 _080721E0: .4byte gPlayerState - thumb_func_start sub_080721E4 -sub_080721E4: @ 0x080721E4 + thumb_func_start PlayerPull +PlayerPull: @ 0x080721E4 push {lr} ldr r1, _08072208 @ =gPlayerState adds r1, #0xa8 @@ -1865,8 +552,8 @@ _080722B0: .align 2, 0 _080722B4: .4byte 0x00000944 - thumb_func_start sub_080722B8 -sub_080722B8: @ 0x080722B8 + thumb_func_start PlayerLava +PlayerLava: @ 0x080722B8 push {lr} ldr r1, _080722D4 @ =gPlayerState adds r1, #0xa8 @@ -2026,7 +713,7 @@ sub_080723D0: @ 0x080723D0 strb r0, [r1] subs r0, #0x16 bl ModHealth - bl sub_08079458 + bl RespawnPlayer _0807240A: pop {r4, pc} @@ -2059,7 +746,7 @@ sub_0807240C: @ 0x0807240C movs r0, #2 rsbs r0, r0, #0 bl ModHealth - bl sub_08079458 + bl RespawnPlayer _08072448: pop {pc} .align 2, 0 @@ -2125,8 +812,8 @@ _080724AE: _080724C2: pop {pc} - thumb_func_start sub_080724C4 -sub_080724C4: @ 0x080724C4 + thumb_func_start PlayerRoomTransition +PlayerRoomTransition: @ 0x080724C4 push {lr} ldr r2, _080724D8 @ =gUnk_0811BB88 ldrb r1, [r0, #0xd] @@ -2303,8 +990,8 @@ _08072620: _08072624: .4byte gPlayerState _08072628: .4byte gPlayerEntity - thumb_func_start sub_0807262C -sub_0807262C: @ 0x0807262C + thumb_func_start PlayerRoll +PlayerRoll: @ 0x0807262C push {lr} ldr r1, _08072648 @ =gPlayerState adds r1, #0xa8 @@ -2714,8 +1401,8 @@ _08072940: .4byte gPlayerState _08072944: .4byte gPlayerEntity _08072948: .4byte gRoomControls - thumb_func_start sub_0807294C -sub_0807294C: @ 0x0807294C + thumb_func_start PlayerInHole +PlayerInHole: @ 0x0807294C push {lr} ldr r1, _08072968 @ =gPlayerState adds r1, #0xa8 @@ -3776,8 +2463,8 @@ _080731A4: pop {r4, pc} .align 2, 0 - thumb_func_start sub_080731A8 -sub_080731A8: @ 0x080731A8 + thumb_func_start PlayerUseEntrance +PlayerUseEntrance: @ 0x080731A8 push {r4, lr} adds r4, r0, #0 ldr r0, _080731D0 @ =gPlayerState diff --git a/asm/code_080732D0.s b/asm/code_080732D0.s index 45299238..a3a199e9 100644 --- a/asm/code_080732D0.s +++ b/asm/code_080732D0.s @@ -175,8 +175,8 @@ _08073418: .align 2, 0 _0807341C: .4byte gRoomControls - thumb_func_start sub_08073420 -sub_08073420: @ 0x08073420 + thumb_func_start PlayerParachute +PlayerParachute: @ 0x08073420 push {r4, lr} adds r4, r0, #0 bl sub_08078EFC @@ -1280,8 +1280,8 @@ _08073C58: _08073C66: pop {pc} - thumb_func_start sub_08073C68 -sub_08073C68: @ 0x08073C68 + thumb_func_start PlayerMinish +PlayerMinish: @ 0x08073C68 push {lr} ldr r2, _08073C7C @ =gUnk_0811BC60 ldrb r1, [r0, #0xd] @@ -2760,7 +2760,7 @@ _0807476C: strb r0, [r1] subs r0, #0x24 bl ModHealth - bl sub_08079458 + bl RespawnPlayer _08074792: pop {r4, pc} .align 2, 0 diff --git a/asm/code_08078778.s b/asm/code_08078778.s index e1ddb07e..28d49c0d 100644 --- a/asm/code_08078778.s +++ b/asm/code_08078778.s @@ -866,7 +866,7 @@ sub_08078EFC: @ 0x08078EFC strb r2, [r0, #0xc] strb r1, [r0, #0xd] strb r1, [r3, #0xc] - bl sub_08070680 + bl DoPlayerAction movs r0, #1 b _08078F22 .align 2, 0 @@ -1583,8 +1583,8 @@ _08079454: _08079456: pop {r4, r5, pc} - thumb_func_start sub_08079458 -sub_08079458: @ 0x08079458 + thumb_func_start RespawnPlayer +RespawnPlayer: @ 0x08079458 push {r4, r5, lr} ldr r4, _08079498 @ =gPlayerEntity movs r1, #0 @@ -1915,7 +1915,7 @@ _080796C8: strb r1, [r0, #0x10] movs r1, #0x81 strb r1, [r4, #2] - bl sub_08070680 + bl DoPlayerAction movs r0, #1 b _080796FE .align 2, 0 @@ -2537,7 +2537,7 @@ sub_08079B24: @ 0x08079B24 ldrb r0, [r0] cmp r0, #0 beq _08079B6C - bl sub_08079458 + bl RespawnPlayer b _08079BC0 .align 2, 0 _08079B60: .4byte gPlayerEntity @@ -5401,8 +5401,8 @@ sub_0807B0C8: @ 0x0807B0C8 .align 2, 0 _0807B0F8: .4byte gPlayerEntity - thumb_func_start sub_0807B0FC -sub_0807B0FC: @ 0x0807B0FC + thumb_func_start PlayerWarp +PlayerWarp: @ 0x0807B0FC push {lr} ldr r2, _0807B110 @ =gUnk_0811C27C ldrb r1, [r0, #0xd] diff --git a/asm/jarPortal.s b/asm/jarPortal.s index 09c48e54..8b057fc8 100644 --- a/asm/jarPortal.s +++ b/asm/jarPortal.s @@ -230,7 +230,7 @@ sub_0808C01C: @ 0x0808C01C subs r1, #0x18 movs r2, #0x30 movs r3, #0x30 - bl sub_0806FBFC + bl CheckPlayerProximity cmp r0, #0 beq _0808C0A6 ldr r2, _0808C06C @ =gArea diff --git a/asm/non_matching/player/sub_08071634.s b/asm/non_matching/player/sub_08071634.s new file mode 100644 index 00000000..96fd319c --- /dev/null +++ b/asm/non_matching/player/sub_08071634.s @@ -0,0 +1,172 @@ + .syntax unified + push {r4, r5, r6, r7, lr} + mov r7, r8 + push {r7} + adds r5, r0, #0 + adds r0, #0x81 + ldrb r0, [r0] + cmp r0, #0 + beq _08071654 + adds r1, r5, #0 + adds r1, #0x80 + ldr r0, [r1] + adds r0, #0x80 + lsls r0, r0, #0x14 + lsrs r7, r0, #0x17 + adds r4, r1, #0 + b _0807166A +_08071654: + adds r4, r5, #0 + adds r4, #0x80 + ldrb r1, [r4] + lsrs r1, r1, #6 + movs r0, #3 + eors r1, r0 + adds r1, #1 + movs r0, #0x10 + bl __divsi3 + asrs r7, r0, #1 +_0807166A: + adds r0, r5, #0 + adds r0, #0x84 + ldr r3, [r0] + movs r1, #0x80 + lsls r1, r1, #1 + adds r2, r0, #0 + cmp r3, r1 + bls _08071684 + adds r0, r3, #0 + adds r0, #0x80 + lsls r0, r0, #0x14 + lsrs r3, r0, #0x17 + b _08071694 +_08071684: + cmp r3, r1 + bne _0807168C + movs r3, #0x10 + b _08071694 +_0807168C: + ldr r1, _080716B0 @ =gUnk_0811BABC + lsrs r0, r3, #5 + adds r0, r0, r1 + ldrb r3, [r0] +_08071694: + movs r0, #0x80 + lsls r0, r0, #9 + mov r8, r0 + adds r0, r5, #0 + adds r0, #0x5a + ldrb r0, [r0] + cmp r0, #2 + beq _080716EA + cmp r0, #2 + bgt _080716B4 + cmp r0, #1 + beq _080716BA + b _08071754 + .align 2, 0 +_080716B0: .4byte gUnk_0811BABC +_080716B4: + cmp r0, #3 + beq _0807171E + b _08071754 +_080716BA: + movs r1, #0x29 + adds r1, r1, r5 + mov ip, r1 + ldrb r1, [r1] + movs r0, #0x39 + rsbs r0, r0, #0 + ands r0, r1 + mov r1, ip + strb r0, [r1] + ldr r0, [r4] + cmp r0, #0x80 + bls _080716D6 + subs r0, r0, r7 + str r0, [r4] +_080716D6: + lsls r1, r3, #1 + ldr r0, [r2] + adds r0, r0, r1 + str r0, [r2] + mov r0, r8 + lsls r1, r0, #1 + ldr r0, [r5, #0x30] + adds r0, r0, r1 + str r0, [r5, #0x30] + b _08071754 +_080716EA: + ldr r0, [r4] + adds r0, r0, r7 + str r0, [r4] + ldr r1, [r2] + movs r6, #0x80 + lsls r6, r6, #1 + cmp r1, r6 + bls _08071710 + ldr r0, _0807170C @ =0x0000017F + cmp r1, r0 + bhi _08071702 + lsrs r3, r3, #1 +_08071702: + subs r0, r1, r3 + cmp r0, #0xff + bhi _08071716 + str r6, [r2] + b _08071718 + .align 2, 0 +_0807170C: .4byte 0x0000017F +_08071710: + cmp r1, #0x80 + bls _08071718 + subs r0, r1, r3 +_08071716: + str r0, [r2] +_08071718: + ldr r0, [r5, #0x34] + mov r1, r8 + b _08071750 +_0807171E: + ldr r0, [r4] + ldr r6, _08071740 @ =0x0000033F + cmp r0, r6 + bhi _0807172A + adds r0, r0, r7 + str r0, [r4] +_0807172A: + ldr r1, [r2] + cmp r1, r6 + bls _08071744 + movs r0, #8 + strb r0, [r5, #0xe] + movs r0, #0x1e + strb r0, [r5, #0xf] + movs r0, #6 + strb r0, [r5, #0xd] + b _0807174A + .align 2, 0 +_08071740: .4byte 0x0000033F +_08071744: + lsls r0, r3, #1 + adds r0, r1, r0 + str r0, [r2] +_0807174A: + mov r0, r8 + lsls r1, r0, #1 + ldr r0, [r5, #0x34] +_08071750: + subs r0, r0, r1 + str r0, [r5, #0x34] +_08071754: + ldr r1, [r4] + ldr r2, [r2] + adds r0, r5, #0 + movs r3, #0 + bl sub_0805EC9C + adds r0, r5, #0 + bl UpdateAnimationSingleFrame + pop {r3} + mov r8, r3 + pop {r4, r5, r6, r7, pc} + .syntax divided \ No newline at end of file diff --git a/asm/objectB.s b/asm/objectB.s index e7f17d89..cfb07492 100644 --- a/asm/objectB.s +++ b/asm/objectB.s @@ -281,7 +281,7 @@ _08083DA0: _08083DA8: .4byte gSave _08083DAC: ldrb r0, [r4, #0xa] - bl sub_080544DC + bl GetBottleContaining adds r1, r0, #0 cmp r1, #0 beq _08083DC8 diff --git a/data/data_08114208.s b/data/data_08114208.s index 18307d1d..fc5876e7 100644 --- a/data/data_08114208.s +++ b/data/data_08114208.s @@ -708,141 +708,3 @@ gUnk_0811B9D0:: @ 0811B9D0 gUnk_0811B9D8:: @ 0811B9D8 .incbin "baserom.gba", 0x11B9D8, 0x0000008 - -gUnk_0811B9E0:: @ 0811B9E0 - .incbin "baserom.gba", 0x11B9E0, 0x0000080 - -gUnk_0811BA60:: @ 0811BA60 - .incbin "baserom.gba", 0x11BA60, 0x0000008 - -gUnk_0811BA68:: @ 0811BA68 - .incbin "baserom.gba", 0x11BA68, 0x000000C - -gUnk_0811BA74:: @ 0811BA74 - .incbin "baserom.gba", 0x11BA74, 0x0000008 - -gUnk_0811BA7C:: @ 0811BA7C - .incbin "baserom.gba", 0x11BA7C, 0x000000C - -gUnk_0811BA88:: @ 0811BA88 - .incbin "baserom.gba", 0x11BA88, 0x000000C - -gUnk_0811BA94:: @ 0811BA94 - .incbin "baserom.gba", 0x11BA94, 0x0000008 - -gUnk_0811BA9C:: @ 0811BA9C - .incbin "baserom.gba", 0x11BA9C, 0x0000020 - -gUnk_0811BABC:: @ 0811BABC - .incbin "baserom.gba", 0x11BABC, 0x0000008 - -gUnk_0811BAC4:: @ 0811BAC4 - .incbin "baserom.gba", 0x11BAC4, 0x0000010 - -gUnk_0811BAD4:: @ 0811BAD4 - .incbin "baserom.gba", 0x11BAD4, 0x0000010 - -gUnk_0811BAE4:: @ 0811BAE4 - .incbin "baserom.gba", 0x11BAE4, 0x000000C - -gUnk_0811BAF0:: @ 0811BAF0 - .incbin "baserom.gba", 0x11BAF0, 0x000003C - -gUnk_0811BB2C:: @ 0811BB2C - .incbin "baserom.gba", 0x11BB2C, 0x000000C - -gUnk_0811BB38:: @ 0811BB38 - .incbin "baserom.gba", 0x11BB38, 0x0000004 - -gUnk_0811BB3C:: @ 0811BB3C - .incbin "baserom.gba", 0x11BB3C, 0x000000C - -gUnk_0811BB48:: @ 0811BB48 - .incbin "baserom.gba", 0x11BB48, 0x0000008 - -gUnk_0811BB50:: @ 0811BB50 - .incbin "baserom.gba", 0x11BB50, 0x0000008 - -gUnk_0811BB58:: @ 0811BB58 - .incbin "baserom.gba", 0x11BB58, 0x0000008 - -gUnk_0811BB60:: @ 0811BB60 - .incbin "baserom.gba", 0x11BB60, 0x0000008 - -gUnk_0811BB68:: @ 0811BB68 - .incbin "baserom.gba", 0x11BB68, 0x0000008 - -gUnk_0811BB70:: @ 0811BB70 - .incbin "baserom.gba", 0x11BB70, 0x0000010 - -gUnk_0811BB80:: @ 0811BB80 - .incbin "baserom.gba", 0x11BB80, 0x0000008 - -gUnk_0811BB88:: @ 0811BB88 - .incbin "baserom.gba", 0x11BB88, 0x0000008 - -gUnk_0811BB90:: @ 0811BB90 - .incbin "baserom.gba", 0x11BB90, 0x0000008 - -gUnk_0811BB98:: @ 0811BB98 - .incbin "baserom.gba", 0x11BB98, 0x0000014 - -gUnk_0811BBAC:: @ 0811BBAC - .incbin "baserom.gba", 0x11BBAC, 0x0000010 - -gUnk_0811BBBC:: @ 0811BBBC - .incbin "baserom.gba", 0x11BBBC, 0x0000006 - -gUnk_0811BBC2:: @ 0811BBC2 - .incbin "baserom.gba", 0x11BBC2, 0x0000006 - -gUnk_0811BBC8:: @ 0811BBC8 - .incbin "baserom.gba", 0x11BBC8, 0x0000006 - -gUnk_0811BBCE:: @ 0811BBCE - .incbin "baserom.gba", 0x11BBCE, 0x0000006 - -gUnk_0811BBD4:: @ 0811BBD4 - .incbin "baserom.gba", 0x11BBD4, 0x0000010 - -gUnk_0811BBE4:: @ 0811BBE4 - .incbin "baserom.gba", 0x11BBE4, 0x0000008 - -gUnk_0811BBEC:: @ 0811BBEC - .incbin "baserom.gba", 0x11BBEC, 0x000000C - -gUnk_0811BBF8:: @ 0811BBF8 - .incbin "baserom.gba", 0x11BBF8, 0x0000010 - -gUnk_0811BC08:: @ 0811BC08 - .incbin "baserom.gba", 0x11BC08, 0x0000020 - -gUnk_0811BC28:: @ 0811BC28 - .incbin "baserom.gba", 0x11BC28, 0x0000008 - -gUnk_0811BC30:: @ 0811BC30 - .incbin "baserom.gba", 0x11BC30, 0x0000008 - -gUnk_0811BC38:: @ 0811BC38 - .incbin "baserom.gba", 0x11BC38, 0x0000008 - -gUnk_0811BC40:: @ 0811BC40 - .incbin "baserom.gba", 0x11BC40, 0x0000008 - -gUnk_0811BC48:: @ 0811BC48 - .incbin "baserom.gba", 0x11BC48, 0x0000018 - -gUnk_0811BC60:: @ 0811BC60 - .incbin "baserom.gba", 0x11BC60, 0x0000020 - -gUnk_0811BC80:: @ 0811BC80 - .incbin "baserom.gba", 0x11BC80, 0x0000008 - -gUnk_0811BC88:: @ 0811BC88 - .incbin "baserom.gba", 0x11BC88, 0x0000010 - -gUnk_0811BC98:: @ 0811BC98 - .incbin "baserom.gba", 0x11BC98, 0x000001C - -gUnk_0811BCB4:: @ 0811BCB4 - .incbin "baserom.gba", 0x11BCB4, 0x0000010 diff --git a/data/data_0811B9E0.s b/data/data_0811B9E0.s new file mode 100644 index 00000000..62216140 --- /dev/null +++ b/data/data_0811B9E0.s @@ -0,0 +1,140 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +gUnk_0811BA60:: @ 0811BA60 + .incbin "baserom.gba", 0x11BA60, 0x0000008 + +gUnk_0811BA68:: @ 0811BA68 + .incbin "baserom.gba", 0x11BA68, 0x000000C + +gUnk_0811BA74:: @ 0811BA74 + .incbin "baserom.gba", 0x11BA74, 0x0000008 + +gUnk_0811BA7C:: @ 0811BA7C + .incbin "baserom.gba", 0x11BA7C, 0x000000C + +gUnk_0811BA88:: @ 0811BA88 + .incbin "baserom.gba", 0x11BA88, 0x000000C + +gUnk_0811BA94:: @ 0811BA94 + .incbin "baserom.gba", 0x11BA94, 0x0000008 + +gUnk_0811BA9C:: @ 0811BA9C + .incbin "baserom.gba", 0x11BA9C, 0x0000020 + +gUnk_0811BABC:: @ 0811BABC + .incbin "baserom.gba", 0x11BABC, 0x0000008 + +gUnk_0811BAC4:: @ 0811BAC4 + .incbin "baserom.gba", 0x11BAC4, 0x0000010 + +gUnk_0811BAD4:: @ 0811BAD4 + .incbin "baserom.gba", 0x11BAD4, 0x0000010 + +gUnk_0811BAE4:: @ 0811BAE4 + .incbin "baserom.gba", 0x11BAE4, 0x000000C + +gUnk_0811BAF0:: @ 0811BAF0 + .incbin "baserom.gba", 0x11BAF0, 0x000003C + +gUnk_0811BB2C:: @ 0811BB2C + .incbin "baserom.gba", 0x11BB2C, 0x000000C + +gUnk_0811BB38:: @ 0811BB38 + .incbin "baserom.gba", 0x11BB38, 0x0000004 + +gUnk_0811BB3C:: @ 0811BB3C + .incbin "baserom.gba", 0x11BB3C, 0x000000C + +gUnk_0811BB48:: @ 0811BB48 + .incbin "baserom.gba", 0x11BB48, 0x0000008 + +gUnk_0811BB50:: @ 0811BB50 + .incbin "baserom.gba", 0x11BB50, 0x0000008 + +gUnk_0811BB58:: @ 0811BB58 + .incbin "baserom.gba", 0x11BB58, 0x0000008 + +gUnk_0811BB60:: @ 0811BB60 + .incbin "baserom.gba", 0x11BB60, 0x0000008 + +gUnk_0811BB68:: @ 0811BB68 + .incbin "baserom.gba", 0x11BB68, 0x0000008 + +gUnk_0811BB70:: @ 0811BB70 + .incbin "baserom.gba", 0x11BB70, 0x0000010 + +gUnk_0811BB80:: @ 0811BB80 + .incbin "baserom.gba", 0x11BB80, 0x0000008 + +gUnk_0811BB88:: @ 0811BB88 + .incbin "baserom.gba", 0x11BB88, 0x0000008 + +gUnk_0811BB90:: @ 0811BB90 + .incbin "baserom.gba", 0x11BB90, 0x0000008 + +gUnk_0811BB98:: @ 0811BB98 + .incbin "baserom.gba", 0x11BB98, 0x0000014 + +gUnk_0811BBAC:: @ 0811BBAC + .incbin "baserom.gba", 0x11BBAC, 0x0000010 + +gUnk_0811BBBC:: @ 0811BBBC + .incbin "baserom.gba", 0x11BBBC, 0x0000006 + +gUnk_0811BBC2:: @ 0811BBC2 + .incbin "baserom.gba", 0x11BBC2, 0x0000006 + +gUnk_0811BBC8:: @ 0811BBC8 + .incbin "baserom.gba", 0x11BBC8, 0x0000006 + +gUnk_0811BBCE:: @ 0811BBCE + .incbin "baserom.gba", 0x11BBCE, 0x0000006 + +gUnk_0811BBD4:: @ 0811BBD4 + .incbin "baserom.gba", 0x11BBD4, 0x0000010 + +gUnk_0811BBE4:: @ 0811BBE4 + .incbin "baserom.gba", 0x11BBE4, 0x0000008 + +gUnk_0811BBEC:: @ 0811BBEC + .incbin "baserom.gba", 0x11BBEC, 0x000000C + +gUnk_0811BBF8:: @ 0811BBF8 + .incbin "baserom.gba", 0x11BBF8, 0x0000010 + +gUnk_0811BC08:: @ 0811BC08 + .incbin "baserom.gba", 0x11BC08, 0x0000020 + +gUnk_0811BC28:: @ 0811BC28 + .incbin "baserom.gba", 0x11BC28, 0x0000008 + +gUnk_0811BC30:: @ 0811BC30 + .incbin "baserom.gba", 0x11BC30, 0x0000008 + +gUnk_0811BC38:: @ 0811BC38 + .incbin "baserom.gba", 0x11BC38, 0x0000008 + +gUnk_0811BC40:: @ 0811BC40 + .incbin "baserom.gba", 0x11BC40, 0x0000008 + +gUnk_0811BC48:: @ 0811BC48 + .incbin "baserom.gba", 0x11BC48, 0x0000018 + +gUnk_0811BC60:: @ 0811BC60 + .incbin "baserom.gba", 0x11BC60, 0x0000020 + +gUnk_0811BC80:: @ 0811BC80 + .incbin "baserom.gba", 0x11BC80, 0x0000008 + +gUnk_0811BC88:: @ 0811BC88 + .incbin "baserom.gba", 0x11BC88, 0x0000010 + +gUnk_0811BC98:: @ 0811BC98 + .incbin "baserom.gba", 0x11BC98, 0x000001C + +gUnk_0811BCB4:: @ 0811BCB4 + .incbin "baserom.gba", 0x11BCB4, 0x0000010 diff --git a/include/area.h b/include/area.h index 4d363a31..1c2ef424 100644 --- a/include/area.h +++ b/include/area.h @@ -11,14 +11,15 @@ typedef struct { u16 localFlagOffset; u8 filler[10]; u16 field_0x10; - u16 field_0x12; - u16 field_0x14; - u8 field_0x16; - u8 field_0x17; + u16 curPortalX; + u16 curPortalY; + u8 curPortalExitDirection; + u8 curPortalType; u8 field_0x18; // u8 filler3[7]; - u8 fadeOut; - u8 filler2[14]; + bool8 playShrinkSeq; + u8 unk1A; + u8 filler2[13]; u8 filler4[0x835]; u32 musicIndex; u32 pMusicIndex; diff --git a/include/entity.h b/include/entity.h index f3a76a68..929868b5 100644 --- a/include/entity.h +++ b/include/entity.h @@ -47,7 +47,7 @@ typedef struct Entity { /*0x0a*/ u8 type; // was: form /*0x0b*/ u8 type2; // was: parameter /*0x0c*/ u8 action; - /*0x0d*/ u8 previousActionFlag; + /*0x0d*/ u8 subAction; /*0x0e*/ u8 actionDelay; /*0x0f*/ u8 field_0xf; /*0x10*/ u8 flags; @@ -108,7 +108,7 @@ typedef struct Entity { /*0x3a*/ u8 field_0x3a; /*0x3b*/ u8 flags2; /*0x3c*/ u8 field_0x3c; - /*0x3d*/ s8 hurtBlinkTime; + /*0x3d*/ s8 iframes; /*0x3e*/ u8 field_0x3e; /*0x3f*/ u8 damageType; /*0x40*/ u8 field_0x40; diff --git a/include/functions.h b/include/functions.h index d6ce6fb3..ecd9b01c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -110,7 +110,7 @@ extern u32 sub_08049FDC(Entity*, u32); extern u32 sub_080041A0(Entity*, Entity*, u32, u32); extern u32 sub_08049EE4(Entity*); extern Entity* sub_0804A98C(Entity*, u8, u8); -extern u32 sub_080544DC(u32); +extern u32 GetBottleContaining(u32); extern void sub_08077E54(Entity*); extern void sub_080042BA(Entity*, u32); extern void sub_08077F24(ItemBehavior*, u32); diff --git a/include/global.h b/include/global.h index de47c6ac..6d7f2311 100644 --- a/include/global.h +++ b/include/global.h @@ -51,21 +51,21 @@ #define static_assert(cond) extern char assertion[(cond) ? 1 : -1] #if NON_MATCHING -#define asmfunc(prologue, path) +#define ASM_FUNC(path, decl) #else -#define asmfunc(prologue, path) \ - NAKED prologue { \ +#define ASM_FUNC(path, decl) \ + NAKED decl { \ asm(".include " #path); \ } #endif #if NON_MATCHING -#define NONMATCH(prologue, path) prologue +#define NONMATCH(path, decl) decl #define END_NONMATCH #else -#define NONMATCH(path, prologue) \ - NAKED prologue { \ - asm(".include " #path); \ +#define NONMATCH(path, decl) \ + NAKED decl { \ + asm(".include " #path); \ if (0) #define END_NONMATCH } #endif diff --git a/include/player.h b/include/player.h index e9d96665..da6f324b 100644 --- a/include/player.h +++ b/include/player.h @@ -6,6 +6,41 @@ #include "global.h" #include "entity.h" +enum { + PLAYER_INIT, + PLAYER_NORMAL, + PLAYER_DUMMY, + PLAYER_FALL, + PLAYER_JUMP, + PLAYER_PUSH, + PLAYER_BOUNCE, + PLAYER_08070E9C, + PLAYER_ITEMGET, + PLAYER_MINISH, + PLAYER_MINISHDIE, + PLAYER_08071DB8, + PLAYER_EMPTYBOTTLE, + PLAYER_FROZEN, + PLAYER_0807204C, + PLAYER_080720DC, + PLAYER_PULL, + PLAYER_LAVA, + PLAYER_WARP, + PLAYER_08072454, + PLAYER_DROWN, + PLAYER_USEPORTAL, + PLAYER_TALKEZLO, + PLAYER_ROOMTRANSITION, + PLAYER_ROLL, + PLAYER_080728AC, + PLAYER_INHOLE, + PLAYER_08072C9C, + PLAYER_08074C44, + PLAYER_08072F34, + PLAYER_USEENTRANCE, + PLAYER_PARACHUTE, +}; + typedef struct { /*0x00*/ u8 field_0x0[2]; /*0x02*/ u8 jumpStatus; @@ -17,12 +52,14 @@ typedef struct { /*0x0a*/ u8 field_0xa; /*0x0b*/ u8 keepFacing; /*0x0c*/ u8 playerAction; - /*0x0d*/ u8 field_0xd[2]; + /*0x0d*/ u8 field_0xd; + /*0x0e*/ u8 field_0xe; /*0x0f*/ u8 hurtBlinkSpeed; /*0x10*/ u8 field_0x10[4]; /*0x11*/ u8 field_0x14; /*0x11*/ u8 field_0x15; - /*0x14*/ u16 field_0x16[2]; + /*0x14*/ u16 startPosX; + /*0x16*/ u16 startPosY; /*0x1a*/ u8 field_0x1a[2]; /*0x1c*/ u8 field_0x1c; /*0x1d*/ u8 field_0x1d[5]; diff --git a/include/structures.h b/include/structures.h index 42e9d3ab..d6dfdd61 100644 --- a/include/structures.h +++ b/include/structures.h @@ -167,6 +167,22 @@ extern BG3Buffer gBG3Buffer; static_assert(sizeof(BG3Buffer) == 0x1000); */ +struct { + u8 filler[0x70]; +} extern gUnk_03000B80; +static_assert(sizeof(gUnk_03000B80) == 0x70); + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u8 freezeTime; + u8 unk9; +} EntityHandler; + +extern EntityHandler gUnk_03003DC0; + extern u8 gUnk_02022740[]; extern u8 gUnk_02034490[]; diff --git a/linker.ld b/linker.ld index 4a55674c..01c96243 100644 --- a/linker.ld +++ b/linker.ld @@ -1019,6 +1019,8 @@ SECTIONS { data/data_08108D30.o(.rodata); src/npc/ezloCap.o(.rodata); data/data_08114208.o(.rodata); + src/player.o(.rodata); + data/data_0811B9E0.o(.rodata); src/item.o(.rodata); data/data_0811BD44.o(.rodata); data/room_headers.o(.rodata); diff --git a/src/arm_proxy.c b/src/arm_proxy.c index e18e4a1c..05d5235f 100644 --- a/src/arm_proxy.c +++ b/src/arm_proxy.c @@ -30,7 +30,7 @@ extern void LoadResources(); extern void FadeMain(); extern u32 sub_0805E3B0(); extern void HandlePlayerLife(); -extern void sub_08070680(); +extern void DoPlayerAction(); extern void sub_080171F0(); extern void sub_08078FB0(); extern void DrawEntity(); @@ -68,17 +68,6 @@ typedef struct { } NPCStruct; extern NPCStruct gUnk_02031EC0[100]; -typedef struct { - u8 unk0; - u8 unk1; - u8 unk2; - u8 unk3; - u8 freezeTime; - u8 unk9; -} EntityHandler; - -extern EntityHandler gUnk_03003DC0; - typedef struct { void* last; void* first; @@ -156,7 +145,7 @@ void PlayerUpdate(Entity* this) { } } HandlePlayerLife(this); - sub_08070680(this); + DoPlayerAction(this); if ((this->height.WORD == 0) && (this->action == 1 || this->action == 9)) sub_08008790(this, 8); sub_080171F0(); @@ -174,7 +163,7 @@ void HandlePlayerLife(Entity* this) { gUnk_0200AF00.filler25[8] = 0; gUnk_0200AF00.filler25[9] = 0; - if ((gPlayerEntity.bitfield & 0x80) && (gPlayerEntity.hurtBlinkTime > 0)) + if ((gPlayerEntity.bitfield & 0x80) && (gPlayerEntity.iframes > 0)) SoundReq(SFX_86); gPlayerState.flags.all &= ~(0x2000000 | 0x200); @@ -278,7 +267,7 @@ void sub_080171F0(void) { sub_0807A8D8(&gPlayerEntity); if (gPlayerState.jumpStatus & 0xc0) - gPlayerEntity.hurtBlinkTime = 0xfe; + gPlayerEntity.iframes = 0xfe; if (gPlayerEntity.action != 0x17) { sub_08077FEC(gPlayerEntity.action); @@ -286,17 +275,17 @@ void sub_080171F0(void) { } void ItemUpdate(Entity* this) { - if ((this->flags & 1) == 0 && this->action == 0 && this->previousActionFlag == 0) + if ((this->flags & 1) == 0 && this->action == 0 && this->subAction == 0) ItemInit(this); if (!sub_0805E3B0(this)) { gPlayerItemFunctions[this->id](this); this->bitfield &= ~0x80; - if (this->hurtBlinkTime != 0) { - if (this->hurtBlinkTime > 0) - this->hurtBlinkTime--; + if (this->iframes != 0) { + if (this->iframes > 0) + this->iframes--; else - this->hurtBlinkTime++; + this->iframes++; } } DrawEntity(this); @@ -340,8 +329,8 @@ void ObjectUpdate(Entity* this) { if (((this->flags & 1) == 0) && (this->action == 0)) sub_080A2838(this); - if (this->hurtBlinkTime != 0) - this->hurtBlinkTime++; + if (this->iframes != 0) + this->iframes++; if (!sub_0805E3B0(this)) { gObjectFunctions[this->id](this); this->bitfield &= ~0x80; diff --git a/src/code_0804AA84.c b/src/code_0804AA84.c index 59485d74..406a513b 100644 --- a/src/code_0804AA84.c +++ b/src/code_0804AA84.c @@ -18,7 +18,7 @@ extern void (*const gUnk_080D412C[])(); extern struct_02018EB0 gUnk_02018EB0; u32 sub_0804AA84(void) { - if (gArea.fadeOut != 0) { + if (gArea.playShrinkSeq) { gMain.transition = 4; gArea.filler[8] = 0; gArea.filler[9] = 0; @@ -26,8 +26,8 @@ u32 sub_0804AA84(void) { sub_0805E5A8(); return 1; } else { - gArea.filler[18] = gArea.fadeOut; - *(vu8*)&gArea.fadeOut = gArea.fadeOut; + gArea.filler[18] = gArea.playShrinkSeq; + *(vu8*)&gArea.playShrinkSeq = gArea.playShrinkSeq; return 0; } } @@ -40,7 +40,7 @@ void sub_0804AAD4(void) { MemClear32((void*)&gUnk_02018EB0, 0x28); gUnk_02018EB0.unk = 0; EraseAllEntities(); - CreateObject(0x3d, gArea.field_0x17, 0); + CreateObject(0x3d, gArea.curPortalType, 0); gArea.filler[8]++; } diff --git a/src/code_0805436C.c b/src/code_0805436C.c index be879f99..20aee72e 100644 --- a/src/code_0805436C.c +++ b/src/code_0805436C.c @@ -133,7 +133,7 @@ u32 sub_080544C8(u32 arg0) { } } -u32 sub_080544DC(u32 arg0) { +u32 GetBottleContaining(u32 arg0) { if (arg0 == gSave.stats.bottles[0]) { return 1; } else if (arg0 == gSave.stats.bottles[1]) { diff --git a/src/code_08077DF4.c b/src/code_08077DF4.c index 1697ecb0..0dc90c4a 100644 --- a/src/code_08077DF4.c +++ b/src/code_08077DF4.c @@ -35,7 +35,7 @@ void sub_08077E3C(Entity* ent, u32 idx) { void sub_08077E54(Entity* ent) { ent->action = gPlayerEntity.animIndex; *(u8*)&ent->spriteIndex = gPlayerEntity.frameIndex; - ent->previousActionFlag = gPlayerEntity.frameDuration; + ent->subAction = gPlayerEntity.frameDuration; ent->actionDelay = gPlayerEntity.frames.all; } diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 2825aed5..09463b1e 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -62,8 +62,8 @@ void sub_080318DC(Entity* this) { do { brother->action = 5; brother->spritePriority.b1 = 1; - if (brother->hurtBlinkTime == 0) - brother->hurtBlinkTime = -12; + if (brother->iframes == 0) + brother->iframes = -12; } while (brother = brother->attachedEntity, brother != NULL); } if (this->parent) { @@ -113,7 +113,7 @@ void sub_080318DC(Entity* this) { } void sub_08031A60(Entity* this) { - if (this->hurtBlinkTime > 0) + if (this->iframes > 0) sub_08003FC4(this, 0x1800); sub_08001324(this); diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 5ba78755..0e9c9586 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -66,7 +66,7 @@ void sub_08021818(Entity* this) { void sub_08021848(Entity* this) { if (sub_0806F520(this)) { - gUnk_080CB5C8[this->previousActionFlag](this); + gUnk_080CB5C8[this->subAction](this); } else { this->action = 3; this->height.HALF.HI = 0; @@ -75,7 +75,7 @@ void sub_08021848(Entity* this) { } void sub_0802187C(Entity* this) { - this->previousActionFlag = 2; + this->subAction = 2; } void nullsub_130(Entity* this) { @@ -98,8 +98,8 @@ void sub_080218B4(Entity* this) { } void sub_080218CC(Entity* this) { - if (this->previousActionFlag == 0) { - this->previousActionFlag = 1; + if (this->subAction == 0) { + this->subAction = 1; this->spriteSettings.b.draw = 1; this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f; this->speed = 0x100; @@ -124,8 +124,8 @@ void sub_080218CC(Entity* this) { } void sub_08021984(Entity* this) { - if (this->previousActionFlag == 0) { - this->previousActionFlag = 1; + if (this->subAction == 0) { + this->subAction = 1; this->flags |= 0x80; this->spriteSettings.b.draw = 3; this->height.HALF.HI = -0x80; diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index d9c1a2a8..3d724227 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -63,8 +63,8 @@ void sub_0802C688(Entity* this) { } void sub_0802C7AC(Entity* this) { - if (this->previousActionFlag < 3 && !sub_0806F520(this)) { - this->previousActionFlag = 0; + if (this->subAction < 3 && !sub_0806F520(this)) { + this->subAction = 0; this->field_0xf = 1; this->height.HALF.HI = 0; if (this->field_0x82.HALF.LO != 2) { @@ -75,7 +75,7 @@ void sub_0802C7AC(Entity* this) { this->field_0x80.HALF.HI = 0; } else { this->height.HALF.HI = -1; - gUnk_080CD600[this->previousActionFlag](this); + gUnk_080CD600[this->subAction](this); if (this->actionDelay != 0) { GetNextFrame(this); } @@ -83,7 +83,7 @@ void sub_0802C7AC(Entity* this) { } void sub_0802C820(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; } @@ -180,11 +180,11 @@ void sub_0802C91C(Entity* this) { } void sub_0802C9B8(Entity* this) { - gUnk_080CD618[this->previousActionFlag](this); + gUnk_080CD618[this->subAction](this); } void sub_0802C9D0(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->flags &= ~0x80; this->spritePriority.b1 = 0; this->field_0x82.HALF.HI = 1; @@ -255,7 +255,7 @@ void nullsub_150(Entity* this) { void sub_0802CB68(Entity* this) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->direction = Random() & 0x18; this->direction |= 4; this->flags |= 0x80; diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 228855be..46c7d8b2 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -70,11 +70,11 @@ void sub_0802A8AC(Entity* this) { } void sub_0802A8C8(Entity* this) { - gUnk_080CD140[this->previousActionFlag](this); + gUnk_080CD140[this->subAction](this); } void sub_0802A8E0(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; } @@ -102,7 +102,7 @@ void sub_0802A91C(Entity* this) { void sub_0802A924(Entity* this) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0; this->field_0xf = 0; this->hitbox = (Hitbox*)&gUnk_080CD16C; @@ -128,7 +128,7 @@ void sub_0802A9A8(Entity* this) { if (this->actionDelay) { if (--this->actionDelay == 0) { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x40; sub_0802ACDC(this, 8); } @@ -254,7 +254,7 @@ void sub_0802AB40(Entity* this) { void sub_0802AC08(Entity* this) { if (this->frames.all & 0x80) { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x40; this->speed = 0xc0; sub_0802ACDC(this, 8); @@ -386,7 +386,7 @@ void sub_0802AE68(Entity* this) { } void sub_0802AEBC(Entity* this) { - gUnk_080CD158[this->previousActionFlag](this); + gUnk_080CD158[this->subAction](this); } void sub_0802AED4(Entity* this) { @@ -407,7 +407,7 @@ void sub_0802AED4(Entity* this) { } void sub_0802AF28(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; sub_08079BD8(this); this->spritePriority.b1 = 2; GetNextFrame(this); @@ -424,7 +424,7 @@ void sub_0802AF58(Entity* this) { void sub_0802AF74(Entity* this) { this->action = 3; - this->previousActionFlag = 0; + this->subAction = 0; if (this->actionDelay > 60) { this->actionDelay = 60; } @@ -510,7 +510,7 @@ void sub_0802B048(Entity* this) { } else { if (this->field_0xf) { if (--this->field_0xf == 0) { - if (action == 2 && this->previousActionFlag == 1) { + if (action == 2 && this->subAction == 1) { gPlayerState.heldObject = 0; } sub_0805EC60(this); diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 49ba9ea1..2c80b226 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -54,7 +54,7 @@ void sub_08028934(Entity* this) { if (this->damageType == 1 && (this->bitfield & 0x7f) == 0x42) { this->action = 3; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x28; this->flags &= ~0x80; sub_080290E0(this, 4); @@ -97,7 +97,7 @@ void sub_08028A48(Entity* this) { this->actionDelay--; } else if (sub_08028F98(this, 0)) { sub_08029078(this); - this->previousActionFlag = 0; + this->subAction = 0; this->field_0xf = 1; } } @@ -106,11 +106,11 @@ void sub_08028A74(Entity* this) { u32 unk; GetNextFrame(this); - switch (this->previousActionFlag) { + switch (this->subAction) { case 0: unk = 1; if (this->frames.all & 0x80) { - this->previousActionFlag = 1; + this->subAction = 1; this->actionDelay = 0x3c; this->field_0xf = 0x10; sub_08028FDC(this); @@ -120,7 +120,7 @@ void sub_08028A74(Entity* this) { case 1: unk = 1; if (--this->actionDelay == 0) { - this->previousActionFlag = 2; + this->subAction = 2; this->actionDelay = 0x20; this->field_0xf = 0; sub_08028FDC(this); @@ -141,14 +141,14 @@ void sub_08028A74(Entity* this) { ent->parent = this; ent->direction = this->direction; this->frames.all &= ~1; - this->previousActionFlag = 3; + this->subAction = 3; } } break; case 3: unk = 2; if (this->frames.all & 0x80) { - this->previousActionFlag = 4; + this->subAction = 4; this->actionDelay = 0x50; sub_080290E0(this, 1); } @@ -157,13 +157,13 @@ void sub_08028A74(Entity* this) { unk = 2; if (--this->actionDelay == 0) { if (sub_08028F98(this, 0)) { - this->previousActionFlag = 1; + this->subAction = 1; this->actionDelay = 0x3c; this->field_0xf = 0x10; sub_08028FDC(this); } else { sub_08028FFC(this); - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x50; this->field_0xf = 0; } @@ -174,7 +174,7 @@ void sub_08028A74(Entity* this) { if (!sub_08028F98(this, unk)) { sub_08028FFC(this); - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x50; this->field_0xf = 0; } @@ -183,11 +183,11 @@ void sub_08028A74(Entity* this) { void sub_08028BC4(Entity* this) { Entity* iVar1; - switch (this->previousActionFlag) { + switch (this->subAction) { case 0: if (this->actionDelay == 0) { if (this->frames.all & 0x80) { - this->previousActionFlag = 1; + this->subAction = 1; sub_08028FDC(this); sub_080290E0(this, 5); this->spritePriority.b1 = 1; @@ -199,7 +199,7 @@ void sub_08028BC4(Entity* this) { case 1: if (this->frames.all & 0x80) { this->action = 4; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x1e; this->field_0xf = 5; sub_080290E0(this, 0); @@ -314,7 +314,7 @@ void sub_08028E40(Entity* this) { struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD; this->action = 4; - this->previousActionFlag = gTextBox.doTextBox & 0x7f; + this->subAction = gTextBox.doTextBox & 0x7f; this->actionDelay = 1; if (CheckLocalFlag(offer->field_0xa) == 0) { SetLocalFlag(offer->field_0xa); diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 83fa7296..18561e86 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -241,7 +241,7 @@ void sub_08020FAC(Entity* this) { if (this->field_0x7a.HALF.LO) { this->field_0x7a.HALF.LO--; } else { - this->hurtBlinkTime = -8; + this->iframes = -8; sub_08021390(this); } } else { diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index 27357c08..2bfc1fc4 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -4,7 +4,7 @@ extern s16 sub_080001DA(u32, u32); // ? extern void sub_08049CF4(); -extern u32 sub_0806FBFC(u32, u32, u32, u32); +extern u32 CheckPlayerProximity(u32, u32, u32, u32); void sub_080221C0(); typedef struct { @@ -54,7 +54,7 @@ void sub_08022034(Entity* this) { void sub_0802209C(Entity* this) { if (this->actionDelay == 0) { - if (sub_0806FBFC(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) { + if (CheckPlayerProximity(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) { this->action = 2; this->actionDelay = 0x12; InitializeAnimation(this, this->type2 + 4); diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index e2d8914d..c7bdbbe2 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -79,7 +79,7 @@ void sub_08045454(Entity* this) { tmp = 0; ent->type2 = 1; ent->height.HALF.HI = tmp; - ent->hurtBlinkTime = -0x10; + ent->iframes = -0x10; /* Set MiniFireballGuy offset relative to killed slime. */ sub_08045178(this, ent, off->h, off->v); diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index f3228707..bc338a94 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -337,12 +337,12 @@ NONMATCH("asm/non_matching/gibdo/sub_08037A58.inc", void sub_08037A58(Entity* th sub_08037ACC(this); this->action = 7; this->spritePriority.b0 = (this->spritePriority.b0 & 0xf8) | 4; - if (this->hurtBlinkTime == 0) { - this->hurtBlinkTime = 0xec; + if (this->iframes == 0) { + this->iframes = 0xec; } this->damageType = 0x26; this->flags2 |= 1; - this->hurtBlinkTime = 0xf4; + this->iframes = 0xf4; this->field_0x3e = (this->animationState << 3) ^ 0x10; this->field_0x42 = 8; this->field_0x46 = 0x180; @@ -354,7 +354,7 @@ END_NONMATCH void sub_08037ACC(Entity* this) { gPlayerState.flags.all &= 0xFFFFFEFF; gPlayerEntity.flags |= 0x80; - gPlayerEntity.hurtBlinkTime = 0x1e; + gPlayerEntity.iframes = 0x1e; gPlayerEntity.field_0x3e = DirectionFromAnimationState(this->animationState); gPlayerEntity.field_0x42 = 4; gPlayerEntity.field_0x46 = 0x180; @@ -362,7 +362,7 @@ void sub_08037ACC(Entity* this) { // Damage player maybe? void sub_08037B10(Entity* this) { u32 h; - gPlayerEntity.hurtBlinkTime = 0xc; + gPlayerEntity.iframes = 0xc; h = ModHealth(-8); sub_0800449C(&gPlayerEntity, 0x7a); if (h == 0) { diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index 1edbf4f9..f8a0b890 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -29,54 +29,54 @@ const u16 gUnk_080D1C60[8]; void GyorgMale(Entity*); void sub_08046898(Entity*); // action 0 void sub_08046910(Entity*); // action 1 -void sub_08046930(Entity*); // action 1 previousActionFlag 0 -void sub_0804696C(Entity*); // action 1 previousActionFlag 1 -void sub_080469CC(Entity*); // action 1 previousActionFlag 2 -void sub_080469F4(Entity*); // action 1 previousActionFlag 3 -void sub_08046A30(Entity*); // action 1 previousActionFlag 4 -void sub_08046A54(Entity*); // action 1 previousActionFlag 5 -void sub_08046A78(Entity*); // action 1 previousActionFlag 6 +void sub_08046930(Entity*); // action 1 subAction 0 +void sub_0804696C(Entity*); // action 1 subAction 1 +void sub_080469CC(Entity*); // action 1 subAction 2 +void sub_080469F4(Entity*); // action 1 subAction 3 +void sub_08046A30(Entity*); // action 1 subAction 4 +void sub_08046A54(Entity*); // action 1 subAction 5 +void sub_08046A78(Entity*); // action 1 subAction 6 void sub_08046A9C(Entity*); // action 2 -void sub_08046AE8(Entity*); // action 2 previousActionFlag 0 -void sub_08046B18(Entity*); // action 2 previousActionFlag 1 -void sub_08046B8C(Entity*); // action 2 previousActionFlag 2 -void sub_08046C04(Entity*); // action 2 previousActionFlag 3 -void sub_08046C88(Entity*); // action 2 previousActionFlag 4 +void sub_08046AE8(Entity*); // action 2 subAction 0 +void sub_08046B18(Entity*); // action 2 subAction 1 +void sub_08046B8C(Entity*); // action 2 subAction 2 +void sub_08046C04(Entity*); // action 2 subAction 3 +void sub_08046C88(Entity*); // action 2 subAction 4 void sub_08046CEC(Entity*); // action 3 -void sub_08046D44(Entity*); // action 3 previousActionFlag 0 -void sub_08046D98(Entity*); // action 3 previousActionFlag 1 -void sub_08046E0C(Entity*); // action 3 previousActionFlag 2 -void sub_08046E68(Entity*); // action 3 previousActionFlag 3 -void sub_08046EF4(Entity*); // action 3 previousActionFlag 4 +void sub_08046D44(Entity*); // action 3 subAction 0 +void sub_08046D98(Entity*); // action 3 subAction 1 +void sub_08046E0C(Entity*); // action 3 subAction 2 +void sub_08046E68(Entity*); // action 3 subAction 3 +void sub_08046EF4(Entity*); // action 3 subAction 4 void sub_08046F64(Entity*); // action 4 -void sub_08046FE8(Entity*); // action 4 previousActionFlag 0 -void sub_0804702C(Entity*); // action 4 previousActionFlag 1 -void sub_080470B4(Entity*); // action 4 previousActionFlag 2 -void sub_08047140(Entity*); // action 4 previousActionFlag 3 -void sub_0804717C(Entity*); // action 4 previousActionFlag 4 -void sub_080471C8(Entity*); // action 4 previousActionFlag 5 -void sub_0804723C(Entity*); // action 4 previousActionFlag 6 -void sub_08047284(Entity*); // action 4 previousActionFlag 7 -void sub_080472BC(Entity*); // action 4 previousActionFlag 8 -void sub_08047310(Entity*); // action 4 previousActionFlag 9 +void sub_08046FE8(Entity*); // action 4 subAction 0 +void sub_0804702C(Entity*); // action 4 subAction 1 +void sub_080470B4(Entity*); // action 4 subAction 2 +void sub_08047140(Entity*); // action 4 subAction 3 +void sub_0804717C(Entity*); // action 4 subAction 4 +void sub_080471C8(Entity*); // action 4 subAction 5 +void sub_0804723C(Entity*); // action 4 subAction 6 +void sub_08047284(Entity*); // action 4 subAction 7 +void sub_080472BC(Entity*); // action 4 subAction 8 +void sub_08047310(Entity*); // action 4 subAction 9 void sub_0804736C(Entity*); // action 5 -void sub_080473B8(Entity*); // action 5 previousActionFlag 0 -void sub_080473F0(Entity*); // action 5 previousActionFlag 1 -void sub_08047484(Entity*); // action 5 previousActionFlag 2 -void sub_08047508(Entity*); // action 5 previousActionFlag 3 -void sub_080475F4(Entity*); // action 5 previousActionFlag 4 -void sub_0804763C(Entity*); // action 5 previousActionFlag 5 -void sub_0804772C(Entity*); // action 5 previousActionFlag 6 +void sub_080473B8(Entity*); // action 5 subAction 0 +void sub_080473F0(Entity*); // action 5 subAction 1 +void sub_08047484(Entity*); // action 5 subAction 2 +void sub_08047508(Entity*); // action 5 subAction 3 +void sub_080475F4(Entity*); // action 5 subAction 4 +void sub_0804763C(Entity*); // action 5 subAction 5 +void sub_0804772C(Entity*); // action 5 subAction 6 void sub_08047778(Entity*); // action 6 -void sub_08047798(Entity*); // action 6 previousActionFlag 0 -void sub_080477F0(Entity*); // action 6 previousActionFlag 1 -void sub_08047914(Entity*); // action 6 previousActionFlag 2 -void sub_08047978(Entity*); // action 6 previousActionFlag 3 -void sub_08047B08(Entity*); // action 6 previousActionFlag 4 +void sub_08047798(Entity*); // action 6 subAction 0 +void sub_080477F0(Entity*); // action 6 subAction 1 +void sub_08047914(Entity*); // action 6 subAction 2 +void sub_08047978(Entity*); // action 6 subAction 3 +void sub_08047B08(Entity*); // action 6 subAction 4 void sub_08047B84(Entity*); // action 7 -void sub_08047BA4(Entity*); // action 7 previousActionFlag 0 -void sub_08047BF0(Entity*); // action 7 previousActionFlag 1, also called elsewhere -void sub_08047D24(Entity*); // action 7 previousActionFlag 2 +void sub_08047BA4(Entity*); // action 7 subAction 0 +void sub_08047BF0(Entity*); // action 7 subAction 1, also called elsewhere +void sub_08047D24(Entity*); // action 7 subAction 2 void sub_08047D88(Entity*); // void sub_08047DF0(Entity*, u32); void sub_08047E48(Entity*); // @@ -118,7 +118,7 @@ void sub_08046898(Entity* this) { tmp->parent = this; this->attachedEntity = tmp; this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->spriteRendering.b0 = 3; this->spriteSettings.b.draw = 1; this->spriteOrientation.flipY = 2; @@ -136,20 +136,20 @@ void (*const gUnk_080D1B1C[7])(Entity*) = { sub_08046930, sub_0804696C, sub_0804 sub_08046A30, sub_08046A54, sub_08046A78 }; void sub_08046910(Entity* this) { - gUnk_080D1B1C[this->previousActionFlag](this); + gUnk_080D1B1C[this->subAction](this); UpdateAnimationSingleFrame(this); } void sub_08046930(Entity* this) { if (this->type) { - this->previousActionFlag = 5; + this->subAction = 5; this->direction = 0x20; this->speed = 0x280; } sub_08047D88(this); if (this->field_0x7c.BYTES.byte0 == 0) return; - this->previousActionFlag = 1; + this->subAction = 1; this->actionDelay = 1; this->animationState = 0; this->direction = 0; @@ -159,7 +159,7 @@ void sub_08046930(Entity* this) { void sub_0804696C(Entity* this) { sub_08047E48(this); if (gRoomControls.roomOriginY + 0x130 > this->y.HALF.HI) { - this->previousActionFlag = 2; + this->subAction = 2; this->direction = 0x80; this->speed = 0x100; this->spriteOrientation.flipY = 3; @@ -177,7 +177,7 @@ void sub_0804696C(Entity* this) { void sub_080469CC(Entity* this) { sub_08047E48(this); if (gRoomControls.roomOriginY + 0x210 < this->y.HALF.HI) { - this->previousActionFlag = 3; + this->subAction = 3; this->direction = 0x90; } } @@ -185,7 +185,7 @@ void sub_080469CC(Entity* this) { void sub_080469F4(Entity* this) { sub_08047E48(this); if (gRoomControls.roomOriginY + 0x290 < this->y.HALF.HI) { - this->previousActionFlag = 4; + this->subAction = 4; this->spriteOrientation.flipY = 2; this->spriteRendering.b3 = 2; } @@ -195,14 +195,14 @@ void sub_08046A30(Entity* this) { sub_08047D88(this); if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 1) { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; } } void sub_08046A54(Entity* this) { sub_08047E48(this); if (gRoomControls.roomOriginX + 0x380 < this->x.HALF.HI) { - this->previousActionFlag = 6; + this->subAction = 6; } } @@ -210,7 +210,7 @@ void sub_08046A78(Entity* this) { sub_08047D88(this); if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 0x10) { this->action = 3; - this->previousActionFlag = 0; + this->subAction = 0; } } @@ -222,16 +222,16 @@ void sub_08046A9C(Entity* this) { InitAnimationForceUpdate(this, 0); } } - gUnk_080D1B38[this->previousActionFlag](this); + gUnk_080D1B38[this->subAction](this); UpdateAnimationSingleFrame(this); if (this->field_0x7c.BYTES.byte0) { this->action = 6; - this->previousActionFlag = 0; + this->subAction = 0; } } void sub_08046AE8(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->speed = 0x180; sub_08048178(this, ((Entity*)this->myHeap)->next->animationState >> 5); this->field_0x76.HWORD = this->direction << 8; @@ -248,7 +248,7 @@ void sub_08046B18(Entity* this) { } this->direction = this->field_0x76.HWORD >> 8; } else { - this->previousActionFlag = 2; + this->subAction = 2; } sub_08047D88(this); sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8); @@ -256,7 +256,7 @@ void sub_08046B18(Entity* this) { void sub_08046B8C(Entity* this) { if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) { - this->previousActionFlag = 3; + this->subAction = 3; this->field_0x76.HWORD = this->direction << 8; this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x200; this->field_0x82.HWORD = gRoomControls.roomOriginY + 0x210; @@ -278,7 +278,7 @@ void sub_08046C04(Entity* this) { } this->direction = this->field_0x76.HWORD >> 8; } else { - this->previousActionFlag = 4; + this->subAction = 4; this->field_0x70.HALF.LO = ((tmp + 0x20) & 0xC0) >> 6; } sub_08047D88(this); @@ -287,7 +287,7 @@ void sub_08046C04(Entity* this) { void sub_08046C88(Entity* this) { if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) { - this->previousActionFlag = 1; + this->subAction = 1; sub_08048178(this, sub_08048158(this->field_0x70.HALF_U.LO)); sub_08047D88(this); } else { @@ -305,11 +305,11 @@ void sub_08046CEC(Entity* this) { InitAnimationForceUpdate(this, 1); } } - gUnk_080D1B4C[this->previousActionFlag](this); + gUnk_080D1B4C[this->subAction](this); UpdateAnimationSingleFrame(this); if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 2) { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; this->animationState = this->speed; } } @@ -318,7 +318,7 @@ const u16 gUnk_080D1B60[8] = { 0x200, 0x184, 0x28C, 0x210, 0x200, 0x29C, 0x174, void sub_08046D44(Entity* this) { const u16* tmp; - this->previousActionFlag = 1; + this->subAction = 1; this->speed = 0x200; tmp = gUnk_080D1B60 + (((Entity*)this->myHeap)->next->animationState >> 5); this->field_0x80.HWORD = tmp[0] + gRoomControls.roomOriginX; @@ -337,7 +337,7 @@ void sub_08046D98(Entity* this) { } this->direction = this->field_0x76.HWORD >> 8; } else { - this->previousActionFlag = 2; + this->subAction = 2; } sub_08047D88(this); sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8); @@ -345,7 +345,7 @@ void sub_08046D98(Entity* this) { void sub_08046E0C(Entity* this) { if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) { - this->previousActionFlag = 3; + this->subAction = 3; this->field_0x76.HWORD = this->direction << 8; sub_08047D88(this); } else { @@ -369,7 +369,7 @@ void sub_08046E68(Entity* this) { sub_08047D88(this); sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8); } else { - this->previousActionFlag = 4; + this->subAction = 4; this->actionDelay = 0x3F; this->field_0xf = 1; this->direction = (gUnk_080D1B70[Random() & 1] + tmp) & 0xC0; @@ -408,7 +408,7 @@ void sub_08046F64(Entity* this) { InitAnimationForceUpdate(this, 1); } } - gUnk_080D1B94[this->previousActionFlag](this); + gUnk_080D1B94[this->subAction](this); UpdateAnimationSingleFrame(this); if (--this->field_0x7c.HALF.HI == 0) { Entity* tmp; @@ -422,12 +422,12 @@ void sub_08046F64(Entity* this) { } if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 4) { this->action = 5; - this->previousActionFlag = 0; + this->subAction = 0; } } void sub_08046FE8(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->speed = 0x1c0; this->field_0x7c.HALF.HI = 0x1e; this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x290; @@ -446,7 +446,7 @@ void sub_0804702C(Entity* this) { } sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, (this->speed >> 0x10) + 0x10)) { - this->previousActionFlag = 2; + this->subAction = 2; this->field_0x76.HWORD = this->direction << 8; this->speed = 0x280; } @@ -466,7 +466,7 @@ void sub_080470B4(Entity* this) { sub_08047D88(this); sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8); } else { - this->previousActionFlag = 3; + this->subAction = 3; this->speed = 0x200; this->field_0x76.HWORD = this->direction << 8; this->field_0x74.HWORD = gUnk_080D1BBC[Random() & 1]; @@ -479,7 +479,7 @@ void sub_08047140(Entity* this) { this->direction = this->field_0x76.HWORD >> 8; if (this->direction > 0xbf) { this->direction = 0xC0; - this->previousActionFlag = 4; + this->subAction = 4; } sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); } @@ -490,7 +490,7 @@ void sub_0804717C(Entity* this) { } sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); if (gRoomControls.roomOriginX + 0x200 > this->x.HALF.HI) { - this->previousActionFlag = 5; + this->subAction = 5; } } @@ -506,19 +506,19 @@ void sub_080471C8(Entity* this) { return; if (this->field_0x74.HWORD > 0x100) { if (Random() & 1) { - this->previousActionFlag = 6; + this->subAction = 6; } else { - this->previousActionFlag = 0; + this->subAction = 0; } } else { - this->previousActionFlag = 0; + this->subAction = 0; } } void sub_0804723C(Entity* this) { this->direction -= 2; if (this->direction < 0xc0) { - this->previousActionFlag = 7; + this->subAction = 7; this->speed = 0x200; this->direction = 0xc0; this->field_0x76.HWORD = 0xc000; @@ -532,7 +532,7 @@ void sub_08047284(Entity* this) { this->direction = this->field_0x76.HWORD >> 8; if (this->direction < 0x40) { this->direction = 0x40; - this->previousActionFlag = 8; + this->subAction = 8; } sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); } @@ -544,7 +544,7 @@ void sub_080472BC(Entity* this) { sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); if (gRoomControls.roomOriginX + 0x2B0 >= this->x.HALF.HI) return; - this->previousActionFlag = 9; + this->subAction = 9; this->field_0x76.HWORD = this->direction << 8; } @@ -556,7 +556,7 @@ void sub_08047310(Entity* this) { this->direction = this->field_0x76.HWORD >> 8; if ((u8)(this->direction + 0x7F) < 0x40) { this->direction = 0xC0; - this->previousActionFlag = 4; + this->subAction = 4; } sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); } @@ -570,16 +570,16 @@ void sub_0804736C(Entity* this) { InitAnimationForceUpdate(this, 0); } } - gUnk_080D1BC0[this->previousActionFlag](this); + gUnk_080D1BC0[this->subAction](this); UpdateAnimationSingleFrame(this); if (this->currentHealth == 0) { this->action = 7; - this->previousActionFlag = 0; + this->subAction = 0; } } void sub_080473B8(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->speed = 0x120; this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x200; this->field_0x82.HWORD = gRoomControls.roomOriginY + 0x1D0; @@ -606,7 +606,7 @@ void sub_080473F0(Entity* this) { } sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8); if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 8)) { - this->previousActionFlag = 2; + this->subAction = 2; this->field_0x76.HWORD = this->direction << 8; this->speed = 0x180; } @@ -624,7 +624,7 @@ void sub_08047484(Entity* this) { sub_08047D88(this); sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8); } else { - this->previousActionFlag = 3; + this->subAction = 3; this->speed = 0x200; this->direction = 0x40; this->field_0x76.HWORD = 0x4000; @@ -664,7 +664,7 @@ void sub_08047508(Entity* this) { } sub_08047E48(this); if (gRoomControls.roomOriginX + 0x280 < this->x.HALF.HI) { - this->previousActionFlag = 4; + this->subAction = 4; this->speed = 0x200; this->animationState = this->direction; this->field_0x76.HWORD = this->direction << 8; @@ -682,7 +682,7 @@ void sub_080475F4(Entity* this) { this->direction = this->field_0x76.HWORD >> 8; if (this->direction >= 0xc0) { this->direction = 0xc0; - this->previousActionFlag = 5; + this->subAction = 5; this->speed = 0x200; this->field_0x7c.HALF.HI = 0x3c; } @@ -719,7 +719,7 @@ void sub_0804763C(Entity* this) { } sub_08047E48(this); if (gRoomControls.roomOriginX + 0x180 > this->x.HALF.HI) { - this->previousActionFlag = 6; + this->subAction = 6; this->speed = 0x200; this->animationState = this->direction; this->field_0x76.HWORD = this->direction << 8; @@ -737,7 +737,7 @@ void sub_0804772C(Entity* this) { this->direction = this->field_0x76.HWORD >> 8; if (this->direction <= 0x40) { this->direction = 0x40; - this->previousActionFlag = 3; + this->subAction = 3; this->speed = 0x200; this->field_0x7c.HALF.HI = 0x1e; } @@ -747,12 +747,12 @@ void sub_0804772C(Entity* this) { void (*const gUnk_080D1BDC[5])(Entity*) = { sub_08047798, sub_080477F0, sub_08047914, sub_08047978, sub_08047B08 }; void sub_08047778(Entity* this) { - gUnk_080D1BDC[this->previousActionFlag](this); + gUnk_080D1BDC[this->subAction](this); UpdateAnimationSingleFrame(this); } void sub_08047798(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->speed = 0x80; if (this->x.HALF.HI - gRoomControls.roomOriginX < 0x1F8) { this->field_0x80.HWORD = 0xa8; @@ -774,7 +774,7 @@ void sub_080477F0(Entity* this) { sub_08047E48(this); if (!sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; this->spriteOrientation.flipY = 2; this->spriteRendering.b3 = 2; this->direction = this->animationState; @@ -785,7 +785,7 @@ void sub_080477F0(Entity* this) { this->spriteRendering.b3 = 3; } if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) { - this->previousActionFlag = 2; + this->subAction = 2; this->field_0x76.HWORD = this->animationState << 8; this->field_0x74.HWORD = gUnk_080D1BF0[Random() & 1]; if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 1) { @@ -804,7 +804,7 @@ void sub_08047914(Entity* this) { this->animationState = this->field_0x76.HWORD >> 8; sub_08047EA4(this, ((0x100 - this->animationState) & 0xFF) << 8); } else { - this->previousActionFlag = 3; + this->subAction = 3; this->field_0x70.HALF.LO = 0x3C; this->field_0x7c.HALF.HI = ((this->type * 0xF) << 2) + 0x78; sub_080A1D70(((Entity*)this->myHeap)->prev, this->animationState); @@ -839,7 +839,7 @@ void sub_08047978(Entity* this) { } if (!sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; this->spriteOrientation.flipY = 2; this->spriteRendering.b3 = 2; this->direction = this->animationState; @@ -848,7 +848,7 @@ void sub_08047978(Entity* this) { return; if (this->attachedEntity->action != 1) return; - this->previousActionFlag = 4; + this->subAction = 4; if (this->type == 0) { if ((((Entity*)this->myHeap)->next->animationState >> 6) == 1) { this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x1C0; @@ -882,11 +882,11 @@ void sub_08047B08(Entity* this) { return; if (this->type == 0) { this->action = 7; - this->previousActionFlag = 0; + this->subAction = 0; this->direction ^= 0x80; } else { this->action = 4; - this->previousActionFlag = 0; + this->subAction = 0; this->spriteOrientation.flipY = 2; this->spriteRendering.b3 = 2; this->direction = this->animationState; @@ -896,12 +896,12 @@ void sub_08047B08(Entity* this) { void (*const gUnk_080D1BF4[3])(Entity*) = { sub_08047BA4, sub_08047BF0, sub_08047D24 }; void sub_08047B84(Entity* this) { - gUnk_080D1BF4[this->previousActionFlag](this); + gUnk_080D1BF4[this->subAction](this); UpdateAnimationSingleFrame(this); } void sub_08047BA4(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->actionDelay = 0x78; this->field_0xf = 0; if (gRoomControls.roomOriginX + 0x200 < this->x.HALF.HI) { @@ -937,7 +937,7 @@ void sub_08047BF0(Entity* this) { this->speed = 0x140; sub_08047E48(this); if (this->y.HALF.HI > gRoomControls.roomOriginY + 0x270) { - this->previousActionFlag = 2; + this->subAction = 2; this->field_0x7c.HALF.HI = 0xAA; SoundReq(0x12D); InitAnimationForceUpdate(this, 1); diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 723050a4..ed7a71b8 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -62,16 +62,16 @@ void sub_0802BBC4(Entity* this) { void sub_0802BC20(Entity* this) { if (this->damageType != 0x19) { if (sub_0806F520(this)) { - gUnk_080CD42C[this->previousActionFlag](this); + gUnk_080CD42C[this->subAction](this); } - } else if (2 < this->previousActionFlag || sub_0806F520(this)) { - gUnk_080CD438[this->previousActionFlag](this); + } else if (2 < this->subAction || sub_0806F520(this)) { + gUnk_080CD438[this->subAction](this); } } void sub_0802BC74(Entity* this) { sub_0802C1C0(this); - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; this->animationState = (gPlayerEntity.animationState >> 1) ^ 2; InitializeAnimation(this, this->animationState); @@ -101,7 +101,7 @@ void sub_0802BCA8(Entity* this) { } void sub_0802BCFC(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; } @@ -259,7 +259,7 @@ void sub_0802BF78(Entity* this) { void sub_0802BF98(Entity* this) { if (sub_0806F520(this)) { - gUnk_080CD450[this->previousActionFlag](this); + gUnk_080CD450[this->subAction](this); } else { this->action = 2; this->actionDelay = 30; @@ -268,7 +268,7 @@ void sub_0802BF98(Entity* this) { } void sub_0802BFD0(Entity* this) { - this->previousActionFlag = 2; + this->subAction = 2; } void sub_0802BFD8(Entity* this) { diff --git a/src/enemy/keese.c b/src/enemy/keese.c index 0462b254..35904a3e 100644 --- a/src/enemy/keese.c +++ b/src/enemy/keese.c @@ -43,12 +43,12 @@ void sub_08021d98(Entity* this) { void sub_08021DA8(Entity* this) { if (sub_0806F520(this)) { - gUnk_080CB6C4[this->previousActionFlag](this); + gUnk_080CB6C4[this->subAction](this); } } void sub_08021DCC(Entity* this) { - this->previousActionFlag = 2; + this->subAction = 2; } void sub_08021DD4(Entity* this) { diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 163ec9e1..5d6fcb6e 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -140,12 +140,12 @@ void sub_0803C784(Entity* this) { void sub_0803C820(Entity* this) { if (sub_0806F520(this)) { - gUnk_080D0148[this->previousActionFlag](this); + gUnk_080D0148[this->subAction](this); } } void sub_0803C844(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 0x3c; } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index 80679029..467e273c 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -38,16 +38,16 @@ void sub_0803CCEC(Entity* this) { void sub_0803CCFC(Entity* this) { if (sub_0806F520(this) == 0) { - if (this->previousActionFlag == 2) { + if (this->subAction == 2) { sub_0803CE3C(this); } } else { - gUnk_080D043C[this->previousActionFlag](this); + gUnk_080D043C[this->subAction](this); } } void sub_0803CD2C(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 0x3c; } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 60a7b7b7..53af5aad 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -210,7 +210,7 @@ void sub_0802810C(Entity* this) { gPlayerState.flags.all &= 0xffffffef; gPlayerEntity.flags |= 0x80; gPlayerEntity.field_0x20 = 0x18000; - gPlayerEntity.hurtBlinkTime = -60; + gPlayerEntity.iframes = -60; gPlayerEntity.direction = gPlayerEntity.animationState << 2; gPlayerEntity.spritePriority.b1 = this->field_0x82.HALF.HI; gPlayerEntity.height.HALF.HI = gPlayerEntity.spriteOffsetY; @@ -219,8 +219,8 @@ void sub_0802810C(Entity* this) { this->actionDelay = 0x50; this->field_0xf = 0; this->flags2 |= 2; - if (this->hurtBlinkTime == 0) { - this->hurtBlinkTime = -18; + if (this->iframes == 0) { + this->iframes = -18; } } #else diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 9c2d526f..012f5abf 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -460,12 +460,12 @@ void sub_0802A098(Entity* this) { void sub_0802A0F8(Entity* this) { if (this->currentHealth != 0) { - if ((this->bitfield & 0x80) && this->hurtBlinkTime != 0) { + if ((this->bitfield & 0x80) && this->iframes != 0) { Entity* ent = this; u32 i; for (i = 0; i < 6; i++) { ent = ent->attachedEntity; - ent->hurtBlinkTime = this->hurtBlinkTime; + ent->iframes = this->iframes; } } } else { diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index 186bee30..429905be 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -40,9 +40,9 @@ void sub_08022BEC(Entity* this) { this->animationState = ((this->direction + 2) & 0x1c) >> 2; this->frameIndex = this->animationState; - this->attachedEntity->hurtBlinkTime = this->hurtBlinkTime; - (*(Entity**)&this->field_0x7c)->hurtBlinkTime = this->hurtBlinkTime; - (*(Entity**)&this->field_0x80)->hurtBlinkTime = this->hurtBlinkTime; + this->attachedEntity->iframes = this->iframes; + (*(Entity**)&this->field_0x7c)->iframes = this->iframes; + (*(Entity**)&this->field_0x80)->iframes = this->iframes; sub_0804AA30(this, gUnk_080CBBA0); } diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index 3bf68715..2ac1af64 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -67,12 +67,12 @@ void sub_080230CC(Entity* this) { } void sub_080230E4(Entity* this) { - if (this->previousActionFlag == 0xff) { + if (this->subAction == 0xff) { this->action = 7; this->actionDelay = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->damageType = 0x85; - this->hurtBlinkTime = -8; + this->iframes = -8; this->field_0x7c.BYTES.byte3 = 0; this->field_0x7a.HALF.HI = 0; if (this->bitfield == 0x80 || this->bitfield == 0x9e) { @@ -90,7 +90,7 @@ void sub_080230E4(Entity* this) { gPlayerEntity.spriteSettings.b.draw = 1; gPlayerEntity.field_0x20 = 0x18000; gPlayerEntity.direction = 0xff; - gPlayerEntity.hurtBlinkTime = -0x14; + gPlayerEntity.iframes = -0x14; gPlayerState.jumpStatus = 0x41; gPlayerState.flags.all &= 0xfff7ffff; } @@ -410,7 +410,7 @@ void sub_08023894(Entity* this) { gPlayerEntity.y.HALF.HI = this->y.HALF.HI; gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(*(Entity**)&this->field_0x74, this)); gPlayerEntity.animationState = gPlayerEntity.direction >> 2; - gPlayerEntity.hurtBlinkTime = 12; + gPlayerEntity.iframes = 12; ModHealth(-0x10); sub_0800449C(&gPlayerEntity, 0x7a); } @@ -421,7 +421,7 @@ void sub_0802390C(Entity* this) { if (this->bitfield & 0x80) { Entity* ent = this->attachedEntity; do { - ent->hurtBlinkTime = this->hurtBlinkTime; + ent->iframes = this->iframes; } while (ent = ent->attachedEntity, ent != NULL); } else { Entity* ent = this->attachedEntity; @@ -431,7 +431,7 @@ void sub_0802390C(Entity* this) { if (bVar2 != 0) { u32 tmp; ent->currentHealth = 0xff; - tmp = (u8)ent->hurtBlinkTime; + tmp = (u8)ent->iframes; if (this->currentHealth >= bVar2) { this->currentHealth -= bVar2; } else { @@ -440,7 +440,7 @@ void sub_0802390C(Entity* this) { ent = this; do { - ent->hurtBlinkTime = tmp; + ent->iframes = tmp; } while (ent = ent->attachedEntity, ent != NULL); break; } diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index d89e4e65..4a021874 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -55,16 +55,16 @@ void sub_0801EB0C(Entity* this) { } void sub_0801EB2C(Entity* this) { - if (this->previousActionFlag < 3 && !sub_0806F520(this)) { + if (this->subAction < 3 && !sub_0806F520(this)) { Octorok_Pause(this); InitializeAnimation(this, this->animationState); } else { - gUnk_080CA158[this->previousActionFlag](this); + gUnk_080CA158[this->subAction](this); } } void sub_0801EB68(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; } diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 07fd3f5a..85a38d74 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -58,14 +58,14 @@ void sub_0801FFDC(Entity* this) { this->animationState = PeahatAnimation_SlicedPropeller; this->action = 5; this->speed = 0x80; - this->hurtBlinkTime = -30; + this->iframes = -30; this->field_0x80.HALF.HI = 0; InitializeAnimation(this, this->animationState); } else if (this->bitfield == 0x9b) { this->animationState = PeahatAnimation_BrokenPropeller; this->action = 5; this->speed = 0x80; - this->hurtBlinkTime = -30; + this->iframes = -30; this->field_0x80.HALF.HI = 0; InitializeAnimation(this, this->animationState); } else if (this->bitfield == 0x80) { @@ -87,14 +87,14 @@ void sub_0801FFDC(Entity* this) { } void sub_08020088(Entity* this) { - if (2 >= this->previousActionFlag && !sub_0806F520(this)) + if (2 >= this->subAction && !sub_0806F520(this)) return; - gUnk_080CA5BC[this->previousActionFlag](this); + gUnk_080CA5BC[this->subAction](this); } void sub_080200B4(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; if (this->animationState == PeahatAnimation_Flying) { this->animationState = PeahatAnimation_BrokenPropeller; @@ -150,7 +150,7 @@ void Peahat_Fly(Entity* this) { if (sub_08049FDC(this, 1)) { if (this->field_0x82.HALF.HI == 0 && (this->field_0xf & 0xf) == 0 && sub_08049F1C(this, gUnk_020000B0, 0x30)) { this->action = 2; - this->previousActionFlag = Random() & 3; + this->subAction = Random() & 3; this->actionDelay = 60; this->speed = 160; } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index a8d24fa2..f34d439a 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -78,20 +78,20 @@ void sub_08023FE0(Entity* this) { } void sub_08023FF0(Entity* this) { - if (this->previousActionFlag < 3 && !sub_0806F520(this)) { + if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->flags |= 0x80; this->damageType = 0x77; this->actionDelay = 1; this->speed = 0x40; } else { - gUnk_080CBEF8[this->previousActionFlag](this); + gUnk_080CBEF8[this->subAction](this); } } void sub_08024038(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; GetNextFrame(this); } @@ -129,7 +129,7 @@ void sub_080240B8(Entity* this) { u32 direction = (Random() & 0xc0) >> 3; sub_0804A720(this); this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->field_0x80.HALF.LO = 0; if (direction & 8) { this->y.HALF.HI += (direction & 0x10) ? -0x20 : 0x20; @@ -829,7 +829,7 @@ void sub_08024E4C(Entity* this) { player->spritePriority.b1 = 0; if (this->field_0xf == 0) { (this->field_0x86.HALF.HI++; - player->hurtBlinkTime = 8; + player->iframes = 8; ModHealth(-2); sub_0800449C(player, 0x7a); } @@ -849,7 +849,7 @@ void sub_08024F50(Entity* this) { CopyPosition(this, &gPlayerEntity); gPlayerEntity.action = 1; gPlayerEntity.flags |= 0x80; - gPlayerEntity.hurtBlinkTime = -0x3c; + gPlayerEntity.iframes = -0x3c; gPlayerEntity.direction = gPlayerEntity.animationState << 2; gPlayerEntity.speed = 0; gPlayerEntity.spritePriority.b1 = this->cutsceneBeh.HALF.HI; diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 08908191..aba4ff55 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -74,7 +74,7 @@ void sub_08025020(Entity* this) { if (0 < this->field_0x20) { this->field_0x20 = 0; } - this->hurtBlinkTime = -0xc; + this->iframes = -0xc; this->field_0x42 = 0; if (this->field_0x80.HALF.LO == 0) { this->animationState = (*(Entity**)&this->field_0x4c)->direction >> 3; @@ -84,7 +84,7 @@ void sub_08025020(Entity* this) { } break; default: - if (this->damageType == 0x82 && this->hurtBlinkTime < 0) { + if (this->damageType == 0x82 && this->iframes < 0) { Entity* ent = CreateObject(0x21, 2, 0); if (ent != NULL) { ent->spritePriority.b0 = 3; @@ -108,14 +108,14 @@ void sub_0802511C(Entity* this) { void sub_0802514C(Entity* this) { sub_08003FC4(this, 0x2000); if (sub_0806F520(this)) { - gUnk_080CBFEC[this->previousActionFlag](this); + gUnk_080CBFEC[this->subAction](this); } else { sub_08025C2C(this); } } void sub_08025180(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->actionDelay = Random(); this->animationState = (((*(Entity**)&this->field_0x4c)->direction ^ 0x10) >> 3); InitializeAnimation(this, this->animationState + 4); diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index 01a0c9c7..dd4d31c6 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -43,7 +43,7 @@ void sub_08022254(Entity* this) { ent = CreateEnemy(1, 1); if (ent) { ent->type2 = 1; - ent->hurtBlinkTime = -8; + ent->iframes = -8; sub_0804A4E4(this, ent); this->action = 2; this->flags &= ~0x80; @@ -96,7 +96,7 @@ void sub_080223E4(Entity* this) { ent = this->attachedEntity; if (ent) { ent->bitfield = 0x94; - ent->hurtBlinkTime = 0x10; + ent->iframes = 0x10; ent->field_0x42 = 0xc; ent->field_0x3e = this->direction; } diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 263b5625..5928e62b 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -63,18 +63,18 @@ void sub_080206E0(Entity* this) { } void sub_08020734(Entity* this) { - if (this->previousActionFlag < 3 && !sub_0806F520(this)) { + if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 4; this->flags |= 0x80; this->direction = 0xff; InitializeAnimation(this, this->animationState + 0x10); } else { - gUnk_080CA6A4[this->previousActionFlag](this); + gUnk_080CA6A4[this->subAction](this); } } void sub_0802077C(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 60; } @@ -132,11 +132,11 @@ void Rollobite_Walk(Entity* this) { } void sub_08020874(Entity* this) { - gUnk_080CA6BC[this->previousActionFlag](this); + gUnk_080CA6BC[this->subAction](this); } void sub_0802088C(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->flags &= ~0x80; this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState; this->spritePriority.b1 = 0; diff --git a/src/enemy/rope.c b/src/enemy/rope.c index d1d73723..f6076324 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -36,12 +36,12 @@ void sub_080313AC(Entity* this) { void sub_080313E8(Entity* this) { if (sub_0806F520()) { - gUnk_080CE470[this->previousActionFlag](this); + gUnk_080CE470[this->subAction](this); } } void sub_0803140C(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 0x3c; } @@ -65,7 +65,7 @@ void sub_08031434(Entity* this) { sub_08031600(this); } else { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->spriteSettings.b.draw = (this->spriteSettings.b.draw & 0xfc); this->height.HALF.HI = -0x80; this->frameIndex = 0xff; @@ -73,13 +73,13 @@ void sub_08031434(Entity* this) { } void sub_08031480(Entity* this) { - if (this->previousActionFlag == 0) { + if (this->subAction == 0) { if (this->actionDelay != 0) { this->actionDelay--; } else { sub_08031600(this); this->action = 1; - this->previousActionFlag = 1; + this->subAction = 1; this->spriteSettings.b.draw = 3; this->spriteRendering.b3 = 1; this->spriteOrientation.flipY = 1; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 64584892..b1aebc92 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -234,7 +234,7 @@ void sub_080296D8(Entity* this) { gPlayerState.flags.all &= 0xffffffef; gPlayerEntity.flags |= 0x80; gPlayerEntity.field_0x20 = 0x18000; - gPlayerEntity.hurtBlinkTime = 0xa6; + gPlayerEntity.iframes = 0xa6; gPlayerEntity.height.HALF.HI = -2; gPlayerEntity.direction = gPlayerEntity.animationState << 2; gPlayerEntity.spritePriority.b1 = this->field_0x80.HALF.LO; @@ -243,8 +243,8 @@ void sub_080296D8(Entity* this) { this->action = 5; this->field_0xf = 0x3c; this->flags2 |= 3; - if ((s8)this->hurtBlinkTime == 0) { - this->hurtBlinkTime = 0xf4; + if ((s8)this->iframes == 0) { + this->iframes = 0xf4; } } diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 9609232d..f6ea1d7f 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -3,12 +3,6 @@ #include "room.h" #include "functions.h" -typedef struct { - void* field_0x0; - void* entityCount; - u8 freezeTime; -} EntityHandler; - typedef struct { s8 h, v; } PACKED PosOffset; @@ -29,7 +23,6 @@ extern u8 gUnk_080D16D0[4]; // Entity count per form extern PosOffset gUnk_080D16D4[4]; extern u8 gEntCount; -extern EntityHandler gHitboxCount; void Slime(Entity* this) { EnemyFunctionHandler(this, gUnk_080D16A4); @@ -117,7 +110,7 @@ void sub_080450A8(Entity* this) { ent->parent = entities[(i + count - 1) % count]; ent->type2 = 1; ent->height.HALF.HI = 0; - ent->hurtBlinkTime = -0x10; + ent->iframes = -0x10; /* Set MiniSlime offset relative to killed slime. */ sub_08045178(this, ent, off->h, off->v); diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c index 7b6dbbfd..7d5aea83 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -42,17 +42,17 @@ void sub_0803169C(Entity* this) { iVar1 = sub_0806F520(this); if (iVar1 == 0) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->flags = this->flags | 0x80; this->speed = 0x40; this->field_0xf = 1; } else { - gUnk_080CE554[this->previousActionFlag](this); + gUnk_080CE554[this->subAction](this); } } void sub_080316DC(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 0x3c; } diff --git a/src/enemy/spark.c b/src/enemy/spark.c index 210b8431..4a6541fa 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -19,7 +19,7 @@ void sub_0802B2E0(Entity* this) { if (this->bitfield & 0x80) { if ((this->bitfield & 0x7f) == 0x14) { this->flags &= ~0x80; - this->hurtBlinkTime = 0; + this->iframes = 0; this->spriteSettings.b.draw = 0; this->action = 2; ent = CreateFx(this, 2, 0); diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index 68e0fef5..8523ae91 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -56,7 +56,7 @@ void sub_08028284(Entity* this) { } } - this->attachedEntity->hurtBlinkTime = this->hurtBlinkTime; + this->attachedEntity->iframes = this->iframes; if (this->currentHealth == 0) { this->speed = 0; this->field_0x82.HALF.LO = 0; @@ -386,7 +386,7 @@ void sub_080288C0(Entity* this) { Entity* ent = this->attachedEntity; if (ent && (ent->bitfield & 0x80)) { this->field_0x3e = ent->field_0x3e; - this->hurtBlinkTime = -ent->hurtBlinkTime; + this->iframes = -ent->iframes; this->field_0x46 = ent->field_0x46; this->field_0x42 = ent->field_0x42; ent->field_0x42 = 0; diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 503084e7..727243a2 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -52,7 +52,7 @@ void sub_0802B628(Entity* this) { this->speed = 0xc0; this->direction = this->field_0x3e; this->field_0x42 = 0; - this->hurtBlinkTime = -8; + this->iframes = -8; this->damageType = 100; InitializeAnimation(this, 9); } diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 7bf39713..7b2424b8 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -117,11 +117,11 @@ void sub_080225EC(Entity* this) { } void sub_08022654(Entity* this) { - switch (this->previousActionFlag) { + switch (this->subAction) { case 0: if (--this->field_0xf) return; - this->previousActionFlag = 1; + this->subAction = 1; SoundReq(0x12d); InitializeAnimation(this, 0); /* fallthrough */ @@ -129,7 +129,7 @@ void sub_08022654(Entity* this) { if (sub_08003FC4(this, 0x1800)) return; - this->previousActionFlag = 2; + this->subAction = 2; this->spriteSettings.b.draw = 1; InitializeAnimation(this, 5); EnqueueSFX(0x7d); diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 66d2ca82..506cd20f 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -29,7 +29,7 @@ void sub_0802F150(Entity* this) { switch (this->bitfield & 0x3f) { case 0x14: this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; if (this->type != 0) { this->actionDelay = 0xc0; } else { @@ -70,7 +70,7 @@ void sub_0802F210(Entity* this) { sub_0804A720(this); this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = gUnk_080CDEF8[Random() & 3]; this->actionDelay = (Random() & 0x1f) + this->actionDelay; this->field_0xf = 0; @@ -119,7 +119,7 @@ void sub_0802F300(Entity* this) { if (sub_080044EC(this, this->field_0x80.HWORD) == 1) { this->action = 3; - this->previousActionFlag = 0; + this->subAction = 0; if (this->type != 0) { rand = 0; } @@ -146,9 +146,9 @@ void sub_0802F300(Entity* this) { } } - if ((this->previousActionFlag == 0) && (temp < this->height.HALF.HI)) { + if ((this->subAction == 0) && (temp < this->height.HALF.HI)) { InitializeAnimation(this, 4); - this->previousActionFlag = 1; + this->subAction = 1; } if (temp < -0xc) { diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 3bf14e34..35399b09 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -27,7 +27,7 @@ void sub_08037F00(Entity* this) { sub_0804AA30(this, &gUnk_080CF4A0); if (this->bitfield == 0x94) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x14; this->field_0xf = 0; this->field_0x80.HALF.LO = 0; @@ -69,7 +69,7 @@ void sub_08037FA0(Entity* this) { } sub_0804A720(this); this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = (Random() & 0x1f) + 0x20; this->field_0xf = 0; this->field_0x80.HALF.LO = 0; @@ -106,7 +106,7 @@ void sub_08038048(Entity* this) { if (sub_080044EC(this, 0x3000) == 1) { this->action = 3; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0x14; InitializeAnimation(this, 3); return; @@ -121,9 +121,9 @@ void sub_08038048(Entity* this) { sub_08038168(this); } - if ((this->previousActionFlag == 0) && (temp < this->height.HALF.HI)) { + if ((this->subAction == 0) && (temp < this->height.HALF.HI)) { InitializeAnimation(this, 4); - this->previousActionFlag = 1; + this->subAction = 1; } if (temp < -0xc) { diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 10463258..d611c173 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -49,7 +49,7 @@ void sub_08033564(Entity* this) { break; case 0x14: this->flags &= 0x7f; - this->hurtBlinkTime = 0; + this->iframes = 0; this->spriteSettings.b.draw = FALSE; ent = CreateFx(this, 2, 0); if (ent != NULL) { @@ -64,12 +64,12 @@ void sub_08033564(Entity* this) { void sub_0803362C(Entity* this) { if (sub_0806F520() != 0) { - gUnk_080CEB98[this->previousActionFlag](this); + gUnk_080CEB98[this->subAction](this); } } void sub_08033650(Entity* this) { - this->previousActionFlag = 2; + this->subAction = 2; } void sub_08033658(Entity* this) { diff --git a/src/game.c b/src/game.c index 08d0198a..8d4654b0 100644 --- a/src/game.c +++ b/src/game.c @@ -13,7 +13,6 @@ extern u8 gArea; extern Entity gPlayerEntity; -extern u32 gUnk_03000B80; extern u32 gUnk_03003FC0; extern u16 gWalletSizes[4]; @@ -238,7 +237,7 @@ void InitializePlayer(void) { Entity* pl; sub_080784C8(); - MemClear32((void*)&gUnk_03000B80, 0x70); + MemClear32((void*)&gUnk_03000B80, sizeof(gUnk_03000B80)); MemClear32((void*)&gPlayerState, 0xb0); MemFill32(0xffffffff, &gPlayerState.field_0x40, 0x40); diff --git a/src/item.c b/src/item.c index ad7a419b..efe29411 100644 --- a/src/item.c +++ b/src/item.c @@ -28,7 +28,6 @@ extern void (*const gUnk_0811BDE0[])(ItemBehavior* beh, u32); extern void (*const gUnk_0811BDE8[])(ItemBehavior* beh, u32); extern void (*const gUnk_0811BDF4[])(ItemBehavior* beh, u32); -extern u8 gUnk_02034490; #if 0 void Ocarina(ItemBehavior* beh, u32 inputFlags) { gOcarinaStates[beh->stateID](beh, inputFlags); diff --git a/src/item11.c b/src/item11.c index 984d02e0..78d4168b 100644 --- a/src/item11.c +++ b/src/item11.c @@ -16,7 +16,7 @@ extern Hitbox* gUnk_080B3DE8[]; void Item11(Entity* this) { if (this->currentHealth) { - this->hurtBlinkTime = 0; + this->iframes = 0; gUnk_080B3DD0[this->action](this); } else { DeleteThisEntity(); @@ -82,7 +82,7 @@ void sub_08018DE8(Entity* this) { sub_08018F6C(this); break; case 5: - this->attachedEntity->previousActionFlag = 4; + this->attachedEntity->subAction = 4; this->flags = this->flags | 0x80; this->action = 2; this->spritePriority.b0 = 2; diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 87135c56..66e92559 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -251,10 +251,10 @@ void sub_0805A664(Manager15* this) { sub_0805A68C(this); } -extern u32 sub_0806FBFC(u32, u32, u32, u32); +extern u32 CheckPlayerProximity(u32, u32, u32, u32); void sub_0805A68C(Manager15* this) { - if (sub_0806FBFC(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) { + if (CheckPlayerProximity(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) { if (this->unk_2c <= 0x1007) { gScreen.controls.alphaBlend = ++this->unk_2c; this->unk_22 = 0; @@ -285,7 +285,7 @@ void sub_0805A6E8(Manager15* this) { } u32 sub_0805A73C(Manager15* this) { - return sub_0806FBFC(this->unk_38 - 0x6, this->unk_3a - 0x6, 0xC, 0xC); + return CheckPlayerProximity(this->unk_38 - 0x6, this->unk_3a - 0x6, 0xC, 0xC); } void sub_0805A758(Manager15* this) { diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c index 19a1dbca..46acfb2e 100644 --- a/src/manager/manager1A.c +++ b/src/manager/manager1A.c @@ -30,7 +30,7 @@ void sub_0805B030(Manager1A* this) { } extern void sub_08052D74(void*, void*, void*); -extern u32 sub_0806FBFC(u32, u32, u32, u32); +extern u32 CheckPlayerProximity(u32, u32, u32, u32); typedef struct struct_08108764 { u8 unk_00; @@ -138,7 +138,7 @@ void sub_0805B168(Manager1A* this) { u32 sub_0805B1CC(Manager1A* this) { u32 re = 0; - if (sub_0806FBFC(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) { + if (CheckPlayerProximity(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) { if ((gPlayerState.flags.all & 0x4) && (gPlayerState.flags.all & 0x1)) { gPlayerState.flags.all |= 0x8000; } else if (gPlayerState.flags.all & 0x8000) { diff --git a/src/manager/manager3.c b/src/manager/manager3.c index 5234f149..15676771 100644 --- a/src/manager/manager3.c +++ b/src/manager/manager3.c @@ -6,6 +6,8 @@ #include "player.h" #include "functions.h" +// Facilitates the usage of minish portals. + typedef struct { Manager manager; u32 unk_20; @@ -21,7 +23,7 @@ typedef struct { } Manager3; extern s8 gUnk_08107C6C[]; -extern u32 sub_0806FBFC(u32, u32, u32, u32); +extern u32 CheckPlayerProximity(u32, u32, u32, u32); extern u32 sub_08057810(void); extern u32 sub_080002C0(u16, u16, u8); extern void sub_080577AC(u32, u32, u32); @@ -34,14 +36,14 @@ void sub_080576C0(Manager3* this) { this->unk_24 = this->unk_3a + gRoomControls.roomOriginY - 0x20; return; } - if (sub_0806FBFC(this->unk_20, this->unk_24, 0x40, 0x40)) { - gArea.field_0x12 = this->unk_20 + 0x20; - gArea.field_0x14 = this->unk_24 + 0x20 + gUnk_08107C6C[this->manager.unk_0a]; - gArea.field_0x16 = this->unk_34; - gArea.field_0x17 = this->manager.unk_0a; + if (CheckPlayerProximity(this->unk_20, this->unk_24, 0x40, 0x40)) { + gArea.curPortalX = this->unk_20 + 0x20; + gArea.curPortalY = this->unk_24 + 0x20 + gUnk_08107C6C[this->manager.unk_0a]; + gArea.curPortalExitDirection = this->unk_34; + gArea.curPortalType = this->manager.unk_0a; if (!CheckGlobalFlag(EZERO_1ST)) { gArea.field_0x18 = 1; - gArea.field_0x17 = 5; + gArea.curPortalType = 5; } else { if ((gPlayerState.flags.all & 0x20) && gPlayerState.jumpStatus == 0) { gArea.field_0x18 = 2; @@ -90,7 +92,7 @@ void sub_080577AC(u32 baseX, u32 baseY, u32 layer) { } u32 sub_08057810(void) { - if ((gPlayerState.flags.all & 0x80) && !gPlayerState.field_0xaa && (gArea.field_0x17 != 0x6) && + if ((gPlayerState.flags.all & 0x80) && !gPlayerState.field_0xaa && (gArea.curPortalType != 0x6) && (gPlayerState.heldObject == 0)) { switch (gPlayerState.field_0xa8) { case 0: diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 3e09302f..b4d25858 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -159,6 +159,6 @@ void sub_080634EC(Entity* this) { void sub_08063504(Entity* this, ScriptExecutionContext* context) { u32 uVar1; - uVar1 = sub_080544DC(gUnk_0810C88C[this->type2]); + uVar1 = GetBottleContaining(gUnk_0810C88C[this->type2]); context->condition = BOOLCAST(uVar1); } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index d4896ce9..c51e4199 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -20,7 +20,7 @@ void BigGoron(Entity* this) { void sub_0806CF30(Entity* this) { if (this->action == 0) { this->action = 1; - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x68.HWORD = this->x.HALF.HI; sub_0805E3A0(this, 2); sub_0806D0B0(this); @@ -30,7 +30,7 @@ void sub_0806CF30(Entity* this) { HandleEntity0x82Actions(this); } - switch (this->previousActionFlag) { + switch (this->subAction) { case 0: case 1: if (gScreenTransition.frameCount % 4 == 0) { diff --git a/src/npc/cow.c b/src/npc/cow.c index d5e7988d..62d31597 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -56,8 +56,8 @@ void sub_08068FC0(Entity* ent) { void sub_08069018(Entity* ent) { s32 var0; - if (ent->previousActionFlag == 0) { - ent->previousActionFlag++; + if (ent->subAction == 0) { + ent->subAction++; ent->field_0xf = (Random() & 0x3F) + 0x3C; InitAnimationForceUpdate(ent, ent->animationState); } @@ -70,7 +70,7 @@ void sub_08069018(Entity* ent) { } else { ent->action = 3; } - ent->previousActionFlag = var0; + ent->subAction = var0; } sub_0806924C(ent); @@ -79,10 +79,10 @@ void sub_08069018(Entity* ent) { void sub_08069068(Entity* ent) { s32 var0; - if (ent->previousActionFlag == 0) { + if (ent->subAction == 0) { u32 anim; - ent->previousActionFlag++; + ent->subAction++; anim = (Random() & 2) - 1; anim = (anim + ent->animationState) & 3; @@ -126,7 +126,7 @@ void sub_08069068(Entity* ent) { var0 = --ent->field_0xf; if (var0 == 0) { ent->action = 3; - ent->previousActionFlag = var0; + ent->subAction = var0; } sub_0806924C(ent); @@ -134,7 +134,7 @@ void sub_08069068(Entity* ent) { void sub_08069124(Entity* ent) { UpdateAnimationSingleFrame(ent); - gUnk_08111928[ent->previousActionFlag](ent); + gUnk_08111928[ent->subAction](ent); sub_0806924C(ent); } @@ -142,13 +142,13 @@ void sub_08069148(Entity* ent) { u32 var0 = Random() & 3; var0 += 3; ent->field_0xf = var0; - ent->previousActionFlag = 1; + ent->subAction = 1; InitAnimationForceUpdate(ent, ent->animationState + 8); } void sub_08069168(Entity* ent) { if ((s8)ent->frames.all < 0) { - ent->previousActionFlag = 2; + ent->subAction = 2; InitAnimationForceUpdate(ent, ent->animationState + 12); } } @@ -160,14 +160,14 @@ void sub_08069188(Entity* ent) { if (((s8)--ent->field_0xf) != 0) return; - ent->previousActionFlag = 3; + ent->subAction = 3; InitAnimationForceUpdate(ent, ent->animationState + 16); } void sub_080691BC(Entity* ent) { if ((s8)ent->frames.all < 0) { ent->action = 1; - ent->previousActionFlag = 0; + ent->subAction = 0; InitAnimationForceUpdate(ent, ent->animationState + 4); } } @@ -175,7 +175,7 @@ void sub_080691BC(Entity* ent) { void sub_080691E0(Entity* ent) { if (UpdateFuseInteraction(ent) != 0) { ent->action = 1; - ent->previousActionFlag = 0; + ent->subAction = 0; } } diff --git a/src/object/backgroundCloud.c b/src/object/backgroundCloud.c index df2625a3..f47d276c 100644 --- a/src/object/backgroundCloud.c +++ b/src/object/backgroundCloud.c @@ -24,7 +24,7 @@ void sub_0808F658(Entity* this) { this->animationState = 0; this->x.HALF.HI += (Random() & 0xf) << 4; this->actionDelay = 0; - this->previousActionFlag = 0; + this->subAction = 0; } void sub_0808F6E0(Entity* this) { @@ -35,8 +35,8 @@ void sub_0808F6E0(Entity* this) { } void sub_0808F70C(Entity* this) { - if (this->previousActionFlag == 0) { - this->previousActionFlag = 1; + if (this->subAction == 0) { + this->subAction = 1; this->actionDelay = ((Random() & 7) << 3) + 31; if ((this->direction & 0x10)) { @@ -49,10 +49,10 @@ void sub_0808F70C(Entity* this) { this->y.HALF.HI = gUnk_08121EB3[this->type2 * 2 + (Random() & 1)]; } - if (this->previousActionFlag == 1) { + if (this->subAction == 1) { if (--this->actionDelay == 0) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; } } } diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index a64217f1..12cbf897 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -59,12 +59,12 @@ void sub_0809CD0C(Entity* this) { } /* Damage minish link if he touches a steam cloud */ - if (this->field_0xf == 0 && gPlayerEntity.hurtBlinkTime == 0 && this->frameIndex && + if (this->field_0xf == 0 && gPlayerEntity.iframes == 0 && this->frameIndex && sub_0806FC80(this, &gPlayerEntity, 4)) { this->field_0xf++; ModHealth(-2); sub_0800449C(&gPlayerEntity, 0x7a); - gPlayerEntity.hurtBlinkTime = 16; + gPlayerEntity.iframes = 16; gPlayerEntity.field_0x3e = 16; gPlayerEntity.field_0x42 = 12; gPlayerEntity.field_0x46 = 16; diff --git a/src/object/bird.c b/src/object/bird.c index 6d126380..ca248b21 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -69,7 +69,7 @@ void sub_0809D048(Entity* this) { } void sub_0809D06C(Entity* this) { - gUnk_08123EFC[this->previousActionFlag](this); + gUnk_08123EFC[this->subAction](this); } void sub_0809D084(Entity* this) { @@ -80,7 +80,7 @@ void sub_0809D084(Entity* this) { if (temp != 0) { PositionRelative(this->parent, this, 0, 0x80000); } else { - this->previousActionFlag++; + this->subAction++; this->field_0x20 = temp; } } diff --git a/src/object/button.c b/src/object/button.c index 23a2ee8d..b98d6169 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -47,7 +47,7 @@ void sub_08081FF8(Entity*); void sub_08081BAC(Entity* this) { if (sub_08081CB0(this)) { - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 0xA; sub_0805E4E0(this, 0xA); sub_08081FF8(this); diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 0d9b6e81..2b6edaae 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -61,7 +61,7 @@ void sub_080866D8(Entity* this) { entity->field_0x68.HWORD = prop->unk0; entity->field_0x6a.HWORD = prop->unk2; entity->collisionLayer = prop->unk4; - entity->previousActionFlag = prop->unk5; + entity->subAction = prop->unk5; UpdateSpriteForCollisionLayer(entity); *((u32*)(&this->field_0x68)) |= mask; if (prop->unk8) { @@ -98,7 +98,7 @@ static void sub_0808681C(Entity* this) { this->spriteSettings.b.draw = 1; this->frameIndex = 0; this->hitbox = &gUnk_081206AC; - if (this->previousActionFlag == 1) { + if (this->subAction == 1) { this->action = 2; this->frameIndex = 1; } @@ -158,7 +158,7 @@ void sub_0808692C(Entity* this) { this->flags &= 0xFD; this->type2 = 2; this->action = this->frameIndex == 0 ? 1 : 2; - this->previousActionFlag = 0; + this->subAction = 0; this->actionDelay = 8; } diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index b794b546..b30b1d33 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -162,7 +162,7 @@ static void sub_080810FC(Entity* this) { sub_08081598(this); } else { this->action = 2; - this->previousActionFlag = 0; + this->subAction = 0; this->flags |= 0x80; this->flags2 = 0x11; CopyPosition(&gPlayerEntity, this); @@ -304,11 +304,11 @@ void sub_0808136C(Entity* this) { } static void sub_080813BC(Entity* this) { - gUnk_0811E840[this->previousActionFlag](this); + gUnk_0811E840[this->subAction](this); } void sub_080813D4(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 1; this->spriteSettings.b.draw = 1; } diff --git a/src/object/object2A.c b/src/object/object2A.c index ffd00460..dca66978 100644 --- a/src/object/object2A.c +++ b/src/object/object2A.c @@ -31,7 +31,7 @@ void sub_08089B18(Entity* this) { case 4: if (!CheckFlags(this->field_0x86.HWORD)) { this->spriteSettings.b.draw = FALSE; - this->previousActionFlag = 1; + this->subAction = 1; return; } } diff --git a/src/object/object49.c b/src/object/object49.c index 16bf7bb9..7271d2d6 100644 --- a/src/object/object49.c +++ b/src/object/object49.c @@ -150,13 +150,13 @@ void sub_0808F2C0(Entity* this) { void sub_0808F370(Entity* this) { if (this->action == 0) { - if (this->parent->previousActionFlag == 1) { + if (this->parent->subAction == 1) { this->action = 1; this->field_0x70.WORD = 0; sub_0808F5EC(this); } } else { - u8 flag = this->parent->previousActionFlag - 1; + u8 flag = this->parent->subAction - 1; if (flag < 5) { if (this->field_0x70.WORD == 0) { if (--(*(u32*)&this->field_0x74) == -1) { diff --git a/src/object/object86.c b/src/object/object86.c index 9706e040..8aadd5ff 100644 --- a/src/object/object86.c +++ b/src/object/object86.c @@ -18,7 +18,7 @@ void sub_08099DD0(Entity* this) { this->collisionLayer = 1; this->spriteRendering.b3 = 3; this->spritePriority.b0 = 7; - this->previousActionFlag = 0; + this->subAction = 0; if (GetInventoryValue(0x46)) { this->action = 4; this->frameIndex = 0; @@ -31,7 +31,7 @@ void sub_08099DD0(Entity* this) { void sub_08099E10(Entity* this) { if (CheckLocalFlag(0x74)) { GetNextFrame(this); - if ((this->frames.all == 1) && (this->previousActionFlag == 0)) { + if ((this->frames.all == 1) && (this->subAction == 0)) { this->frames.all = 0; sub_08099ECC(this); } @@ -56,7 +56,7 @@ void sub_08099E58(Entity* this) { void sub_08099E8C(Entity* this) { if (sub_080041A0(this, &gPlayerEntity, 0xc, 0xc)) { - if (this->previousActionFlag == 0) { + if (this->subAction == 0) { sub_08099ECC(this); sub_0805E4E0(this, 0x1e); } @@ -70,7 +70,7 @@ void nullsub_534(Entity* this) { } void sub_08099ECC(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; CopyPosition(this, &gPlayerEntity); gPlayerState.playerAction = 3; gPlayerState.field_0x34[4] = 0; diff --git a/src/object/pot.c b/src/object/pot.c index f28fb9ee..1c44efef 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -62,7 +62,7 @@ void sub_08082310(Entity* this) { switch (var0) { case 0x13: this->action = 3; - this->previousActionFlag = 0; + this->subAction = 0; break; case 0x1D: SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); @@ -114,7 +114,7 @@ void sub_08082310(Entity* this) { } void sub_080824F8(Entity* this) { - gUnk_0811F0A8[this->previousActionFlag](this); + gUnk_0811F0A8[this->subAction](this); } void sub_08082510(Entity* this) { @@ -125,7 +125,7 @@ void sub_08082510(Entity* this) { this->flags2 = gPlayerEntity.flags2; this->spriteOffsetY = 0; SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); - this->previousActionFlag++; + this->subAction++; } void nullsub_511(Entity* this) { @@ -166,7 +166,7 @@ void sub_080825F0(Entity* this) { static void sub_08082608(Entity* this) { this->action = 1; - this->previousActionFlag = 0; + this->subAction = 0; } void sub_08082614(Entity* this) { @@ -203,11 +203,11 @@ void sub_08082614(Entity* this) { } void sub_080826E4(Entity* this) { - gUnk_0811F0C4[this->previousActionFlag](this); + gUnk_0811F0C4[this->subAction](this); } void sub_080826FC(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->field_0x1d = 48; this->actionDelay = 0; } diff --git a/src/player.c b/src/player.c index 7dfcbb93..49949c20 100644 --- a/src/player.c +++ b/src/player.c @@ -7,34 +7,60 @@ #include "area.h" #include "save.h" -extern const void (*const gUnk_0811B9E0[])(Entity*); -extern const void (*const gUnk_0811BA60[])(Entity*); -extern const void (*const gUnk_0811BA68[])(Entity*); -extern const void (*const gUnk_0811BA74[])(Entity*); -extern const void (*const gUnk_0811BA7C[])(Entity*); -extern const void (*const gUnk_0811BA88[])(Entity*); -extern const void (*const gUnk_0811BA94[])(Entity*); -extern const void (*const gUnk_0811BA9C[])(Entity*); +static void (*const sPlayerActions[])(Entity*); +extern void (*const gUnk_0811BA60[])(Entity*); +extern void (*const gUnk_0811BA68[])(Entity*); +extern void (*const gUnk_0811BA74[])(Entity*); +extern void (*const gUnk_0811BA7C[])(Entity*); +extern void (*const gUnk_0811BA88[])(Entity*); +extern void (*const gUnk_0811BA94[])(Entity*); +extern void (*const gUnk_0811BA9C[])(Entity*); +extern void (*const gUnk_0811BAD4[])(Entity*); +extern void (*const gUnk_0811BAE4[])(Entity*); +extern void (*const gUnk_0811BB3C[])(Entity*); -extern void sub_08079458(); +extern void RespawnPlayer(); extern void sub_080797EC(); extern void sub_08079E08(); extern void sub_08078F60(); +extern void sub_0806F948(); +extern void sub_08077698(); +extern void sub_0805E544(); +extern void sub_080717F8(); +extern void DoExitTransition(); +extern void UnfreezeTime(); +extern void sub_08071A6C(); +extern void sub_08052BB8(); +extern void sub_08079258(); +extern void sub_08071AF0(); +extern void sub_080728AC(); +extern void sub_0807A298(); +extern u32 sub_08079B24(); +extern void sub_08079708(); +extern void sub_080792D8(); + +typedef struct { + u8 frame; + u8 dummy; + u16 speed; +} PushFrames; + +extern PushFrames gUnk_0811BAF0[]; extern Hitbox gUnk_08114F88; +extern ScreenTransitionData gUnk_0813AB58; -// inject -void sub_08070680(Entity* this) { - gUnk_0811B9E0[this->action](this); +void DoPlayerAction(Entity* this) { + sPlayerActions[this->action](this); } -void sub_08070698(Entity* this) { +void PlayerInit(Entity* this) { Entity* ent; gPlayerState.field_0x0[0] = 0xff; - gPlayerState.field_0x16[0] = gPlayerEntity.x.HALF.HI; - gPlayerState.field_0x16[1] = gPlayerEntity.y.HALF.HI; - this->flags = this->flags | 0x80; + gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; + gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; + this->flags |= 0x80; this->spritePriority.b0 = 0xc; this->spritePriority.b1 = 1; this->spriteSettings.b.shadow = 1; @@ -74,9 +100,7 @@ void sub_08070698(Entity* this) { } // PlayerState.flags need to be 100% before this one can reasonably be done -NONMATCH("asm/non_matching/player/sub_08070794.s", void sub_08070794(Entity* this)) { -} -END_NONMATCH +ASM_FUNC("asm/non_matching/player/sub_08070794.s", void PlayerNormal(Entity* this)) void sub_08070BEC(Entity* this, u32 r0) { if (r0 & 1) @@ -88,12 +112,12 @@ void sub_08070BEC(Entity* this, u32 r0) { sub_08079E08(); } -void sub_08070C10(Entity* this) { - gPlayerState.field_0xd[0] = 0xFF; +void PlayerFall(Entity* this) { + gPlayerState.field_0xd = 0xFF; gPlayerState.pushedObject = 0x80; gPlayerState.field_0xa8 = 10; - gUnk_0811BA60[this->previousActionFlag](this); + gUnk_0811BA60[this->subAction](this); } void sub_08070C3C(Entity* this) { @@ -111,7 +135,7 @@ void sub_08070C3C(Entity* this) { else gPlayerState.field_0x8 = 0x1b8; - this->previousActionFlag++; + this->subAction++; this->flags &= ~0x80; this->spritePriority.b1 = 0; ResetPlayer(); @@ -128,16 +152,16 @@ void sub_08070CB4(Entity* this) { this->spriteSettings.b.draw = 0; } else { gPlayerState.flags.all &= ~(0x4 | 0x8000); - sub_08079458(); + RespawnPlayer(); gPlayerState.field_0xa = 0; - this->hurtBlinkTime = 0x20; + this->iframes = 32; ModHealth(-2); } } } -void sub_08070D20(Entity* this) { - gUnk_0811BA68[this->previousActionFlag](this); +void PlayerBounce(Entity* this) { + gUnk_0811BA68[this->subAction](this); } void sub_08070D38(Entity* this) { @@ -145,7 +169,7 @@ void sub_08070D38(Entity* this) { this->direction = ((this->animationState & 0xe) << 2) ^ 0x10; this->speed = 0x100; this->field_0x42 = 0; - this->previousActionFlag++; + this->subAction++; this->actionDelay = gPlayerState.field_0x38; this->spriteIndex = 1; @@ -201,7 +225,7 @@ NONMATCH("asm/non_matching/player/sub_08070DC4.s", void sub_08070DC4(Entity* thi this->spriteIndex = 1; this->actionDelay = 8; - this->previousActionFlag++; + this->subAction++; if ((gPlayerState.flags.all & 0x80) == 0) gPlayerState.field_0x8 = 0x100; @@ -224,7 +248,7 @@ void sub_08070E9C(Entity* this) { gPlayerState.field_0x27[0] = 4; gPlayerState.field_0xa8 = 0x13; sub_0807A1B8(); - gUnk_0811BA74[this->previousActionFlag](this); + gUnk_0811BA74[this->subAction](this); } } @@ -232,7 +256,7 @@ void sub_08070EDC(Entity* this) { this->scriptedScene = 2; if ((gTextBox.doTextBox & 0x7f) != 0) - this->previousActionFlag = 1; + this->subAction = 1; if ((gPlayerState.flags.all & 0x80) == 0) sub_08079938(); @@ -248,13 +272,13 @@ void sub_08070f24(Entity* this) { } } -void sub_08070F50(Entity* this) { +void PlayerItemGet(Entity* this) { Entity* child; u8* temp; // todo: retype gPlayerState.field_0xa8 = 0x15; this->flags &= ~(0x80); - gUnk_0811BA7C[this->previousActionFlag](this); + gUnk_0811BA7C[this->subAction](this); child = this->attachedEntity; if (child != NULL) { @@ -275,7 +299,7 @@ void sub_08070FA4(Entity* this) { gPlayerState.jumpStatus = 0; if ((gPlayerState.flags.all & 0x80) == 0) { - if ((gPlayerState.flags.all & 0x8) != 0) { + if (gPlayerState.flags.all & 0x8) { if (sub_080542AC(gPlayerState.field_0x38)) { temp = 0x45e; } else { @@ -291,16 +315,15 @@ void sub_08070FA4(Entity* this) { gPlayerState.field_0x8 = temp; } - this->previousActionFlag = 1; + this->subAction = 1; ResetPlayer(); sub_08078F60(); } void sub_08071020(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frames.all != 0) { - this->previousActionFlag = 2; - } + if (this->frames.all != 0) + this->subAction = 2; } void sub_08071038(Entity* this) { @@ -310,24 +333,24 @@ void sub_08071038(Entity* this) { if (sub_08078EFC() || (gTextBox.doTextBox & 0x7f)) return; - if ((this->frames.all & 0x80) != 0) { + if (this->frames.all & 0x80) { this->attachedEntity = 0; this->field_0x42 = 0; - this->hurtBlinkTime = 0xf8; + this->iframes = 248; gPlayerState.jumpStatus = 0; sub_080791D0(); } } -void sub_08071084(Entity* this) { +void PlayerJump(Entity* this) { gPlayerState.field_0xa8 = 0xb; - gUnk_0811BA88[this->previousActionFlag](this); + gUnk_0811BA88[this->subAction](this); } void sub_080710A8(Entity* this) { u32 temp; - this->previousActionFlag++; + this->subAction++; gPlayerState.flags.all |= 1; gPlayerState.flags.all &= ~(0x400 | 0x800); @@ -353,7 +376,7 @@ void sub_080710A8(Entity* this) { asm("lsl r0, r0, #0x4"); this->field_0x20 = (temp - 4) * 64 * 64; - this->speed = 0x100; + this->speed = 256; sub_0807A108(); SoundReq(0x7c); SoundReq(0x78); @@ -367,7 +390,7 @@ void sub_08071130(Entity* this) { if (gPlayerState.field_0x1a[1] == 0) { UpdateAnimationSingleFrame(this); - if ((this->frames.all & 1)) + if (this->frames.all & 1) return; } @@ -401,7 +424,7 @@ void sub_08071130(Entity* this) { this->actionDelay = 6; if (((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) && ((gPlayerState.flags.all & 0x80) == 0)) { - if ((gPlayerState.flags.all & 0x8) != 0) { + if (gPlayerState.flags.all & 0x8) { gPlayerState.field_0x8 = 0x424; } else { gPlayerState.field_0x8 = 0x820; @@ -409,7 +432,7 @@ void sub_08071130(Entity* this) { this->animIndex = 0xff; } - this->previousActionFlag++; + this->subAction++; sub_08078F60(); this->field_0x42 = 0; SoundReq(0x7d); @@ -428,33 +451,31 @@ void sub_08071208(Entity* this) { } } -void sub_08071248(Entity* this) { +void PlayerDrown(Entity* this) { gPlayerState.field_0xa8 = 0x16; gPlayerState.flags.all |= 4; this->flags &= ~0x80; - gUnk_0811BA94[this->previousActionFlag](this); + gUnk_0811BA94[this->subAction](this); } void sub_0807127C(Entity* this) { - this->previousActionFlag = 1; + this->subAction = 1; this->spritePriority.b1 = 0; - if ((gPlayerState.flags.all & 0x80) != 0) { + if (gPlayerState.flags.all & 0x80) { this->actionDelay = 0x3c; gPlayerState.field_0x8 = 0xc19; SoundReq(0x84); } else { - if ((gPlayerState.flags.all & 0x10000) == 0) { + if ((gPlayerState.flags.all & 0x10000) == 0) sub_08004168(this); - } CreateFx(this, 11, 0); - if ((gPlayerState.flags.all & 8) == 0) { + if ((gPlayerState.flags.all & 8) == 0) gPlayerState.field_0x8 = 0x72c; - } else { + else gPlayerState.field_0x8 = 0x44c; - } } ResetPlayer(); } @@ -480,28 +501,29 @@ void sub_080712F0(Entity* this) { return; this->field_0x42 = 0; - this->hurtBlinkTime = 0x20; + this->iframes = 32; this->spritePriority.b1 = 1; this->spriteSettings.b.draw = FALSE; - gPlayerState.flags.all &= ~(0x4); - sub_08079458(); + gPlayerState.flags.all &= ~0x4; + RespawnPlayer(); } -void sub_08071380(Entity* this) { +static void PlayerUsePortal(Entity* this) { gPlayerState.field_0xa8 = 0xe; - gUnk_0811BA9C[this->previousActionFlag](this); + gUnk_0811BA9C[this->subAction](this); - if ((this->previousActionFlag == 7) || (this->previousActionFlag < 3)) + // probably a switch + if ((this->subAction == 7) || (this->subAction < 3)) return; if ((gPlayerState.flags.all & 0x20) == 0) return; - if ((gInput.newKeys & 0x102) == 0) + if ((gInput.newKeys & (0x100 | 0x2)) == 0) return; - if (CheckIsDungeon() || gArea.field_0x17 == 3) { - this->previousActionFlag = 7; + if (CheckIsDungeon() || gArea.curPortalType == 3) { + this->subAction = 7; this->actionDelay = 30; DoFade(7, 16); SoundReq(0xf8); @@ -510,19 +532,19 @@ void sub_08071380(Entity* this) { } } -void sub_08071400(Entity* this) { +static void PortalJumpOnUpdate(Entity* this) { u16 x; u16 y; - this->flags &= ~(0x80); + this->flags &= ~0x80; this->field_0x42 = 0; - x = gArea.field_0x12; - y = gArea.field_0x14; + x = gArea.curPortalX; + y = gArea.curPortalY; if ((this->x.HALF.HI != x) || (this->y.HALF.HI != y)) { - this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.field_0x12, gArea.field_0x14); - this->speed = 0x100; + this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY); + this->speed = 256; sub_08079E08(); } @@ -531,17 +553,542 @@ void sub_08071400(Entity* this) { if (gPlayerState.jumpStatus == 0) { gPlayerState.flags.all |= 0x20; - this->previousActionFlag = 1; + this->subAction = 1; this->animationState = 4; this->spriteSettings.b.flipX = FALSE; - if (gArea.field_0x17 == 4) { + if (gArea.curPortalType == 4) { gPlayerState.field_0x8 = 0x52c; } } this->actionDelay = 8; - if (gArea.field_0x17 != 3) { + if (gArea.curPortalType != 3) { this->spritePriority.b0 = 3; } } + +static void PortalStandUpdate(Entity* this) { + switch (gArea.curPortalType) { + case 4: + case 5: + sub_0806F948(&gPlayerEntity); + break; + } + + if ((gPlayerState.field_0xd & 0x84) == 0) { + if (this->direction != gPlayerState.field_0xd) { + this->actionDelay = 8; + } + if (--this->actionDelay == 0xff) { + this->direction = gPlayerState.field_0xd; + this->animationState = this->direction >> 2; + this->field_0x20 = 0x20000; + this->speed = 256; + this->action = 9; + this->subAction = 7; + this->field_0xf = 0; + gPlayerState.field_0x8 = (gPlayerState.flags.all & 8) ? 0x41C : 0x80C; + gPlayerState.flags.all &= ~0x20; + return; + } + this->direction = gPlayerState.field_0xd; + } else { + this->actionDelay = 8; + } + + if (gArea.curPortalType == 4) { + if (this->frames.all == 0) { + UpdateAnimationSingleFrame(this); + return; + } + } else { + sub_08077698(this); + } + sub_08079938(); +} + +static void PortalActivateInit(Entity* this) { + gRoomControls.cameraTarget = NULL; + gUnk_02034490[0] = 1; + this->subAction = 3; + this->field_0xf = 0x1e; + gPlayerState.field_0x8 = 0x738; + CreateObjectWithParent(this, 6, 1, 0); + sub_08077B20(); + sub_0805E544(); +} + +static void PortalActivateUpdate(Entity* this) { + if (this->field_0xf) + return; + + UpdateAnimationSingleFrame(this); + + if (gPlayerState.flags.all & 0x80) + this->subAction = 4; +} + +static void PortalShrinkInit(Entity* this) { + this->subAction = 5; + this->spritePriority.b1 = 0; + this->field_0xf = 0; + this->spriteRendering.b0 = 3; + *(u32*)&this->field_0x80.HWORD = 0x100; + *(u32*)&this->cutsceneBeh = 0x100; + sub_0805EC9C(this, 0x100, 0x100, 0); + gPlayerState.field_0x8 = 0x2c3; + gPlayerState.flags.all |= 0x80; + SoundReq(0x16f); +} + +// horrible +ASM_FUNC("asm/non_matching/player/sub_08071634.s", static void PortalShrinkUpdate(Entity* this)) + +static void PortalEnterUpdate(Entity* this) { + if (this->actionDelay == 0) { + if (sub_08003FC4(this, 0x2000)) + return; + + this->spriteSettings.b.draw = FALSE; + + if (gArea.curPortalType == 3) { + if (--this->field_0xf == 0) + sub_080717F8(this); + return; + } + if (gArea.curPortalType == 6) + DoExitTransition(&gUnk_0813AB58); + else + gArea.playShrinkSeq = 1; + + return; + } + this->actionDelay--; +} + +static void PortalUnknownUpdate(Entity* this) { + if (gFadeControl.active) + return; + + if (this->actionDelay != 0) { + this->actionDelay--; + return; + } + + sub_080717F8(this); + sub_080500F4(0x10); +} + +extern s16 gUnk_0811BAC4[]; + +void sub_080717F8(Entity* this) { + u32 x; + u32 y; + this->animationState = gArea.curPortalExitDirection << 1; + this->x.HALF.HI = gArea.curPortalX + gUnk_0811BAC4[gArea.curPortalExitDirection * 2]; + this->y.HALF.HI = gArea.curPortalY + gUnk_0811BAC4[gArea.curPortalExitDirection * 2 + 1]; + gArea.unk1A = 0xb4; + gUnk_02034490[0] = 0; + this->action = 9; + this->subAction = 0; + gPlayerState.flags.all = (gPlayerState.flags.all & ~0x20) | 0x80; + sub_0805EC60(this); + UnfreezeTime(); +} + +void PlayerTalkEzlo(Entity* this) { + if (sub_08078EFC()) { + sub_08056360(); + sub_08071A6C(); + } else { + gPlayerState.field_0xa8 = 0x13; + this->flags &= ~0x80; + gUnk_0811BAD4[this->subAction](this); + } +} + +void sub_080718A0(Entity* this) { + ResetPlayer(); + gUnk_03000B80.filler[0x63] = 0; + this->iframes = 0; + gUnk_03003DC0.unk0 = 6; + this->scriptedScene = 6; + + if (gPlayerState.flags.all & 0x80) { + this->subAction = 2; + this->spritePriority.b1 = 0; + sub_08052BB8(); + return; + } + + if (gPlayerState.jumpStatus == 0) { + this->subAction++; + + if (this->animationState == 2) + gPlayerState.field_0x8 = 0x3ca; + else + gPlayerState.field_0x8 = 0x3c6; + + this->spriteSettings.b.flipX = 0; + return; + } + + if (!sub_08003FC4(this, 0x2000)) + gPlayerState.jumpStatus = 0; +} + +void sub_0807193C(Entity* this) { + Entity* child; + + UpdateAnimationSingleFrame(this); + if (this->frames.all & 0x80) { + this->subAction++; + child = CreateObjectWithParent(this, 6, 0, 0); + this->attachedEntity = child; + if (child != NULL) { + if (this->animationState == 2) + gPlayerState.field_0x8 = 0x3cc; + else + gPlayerState.field_0x8 = 0x3c7; + sub_08052BB8(); + } + } +} + +void sub_08071990(Entity* this) { + u32 temp; + + if ((gTextBox.doTextBox & 0x7f) == 0) { + this->subAction++; + + if ((gPlayerState.flags.all & 0x80) == 0) { + if (this->animationState == 2) + gPlayerState.field_0x8 = 0x3cd; + else + gPlayerState.field_0x8 = 0x3c9; + } else { + sub_08071A6C(); + sub_08079258(); + } + return; + } + + if (gPlayerState.flags.all & 0x80) + return; + + if (this->animationState == 2) + temp = 4; + else + temp = 0; + + if (this->attachedEntity->actionDelay != 0) { + if ((u8)(temp + 200) != this->animIndex) { + gPlayerState.field_0x8 = temp + 0x3c8; + return; + } + } else { + if ((u8)(temp + 199) != this->animIndex) { + gPlayerState.field_0x8 = temp + 0x3c7; + return; + } + } + UpdateAnimationSingleFrame(this); +} + +void sub_08071A4C(Entity* this) { + UpdateAnimationSingleFrame(this); + if (this->frames.all & 0x80) { + sub_08071A6C(); + sub_0807921C(); + } +} + +void sub_08071A6C(void) { + gUnk_03003DC0.unk0 = 0; + gPlayerEntity.scriptedScene = gPlayerEntity.scriptedScene2; +} + +void PlayerPush(Entity* this) { + gPlayerState.field_0xa8 = 0x19; + gUnk_0811BAE4[this->subAction](this); +} + +void sub_08071AB0(Entity* this) { + u32 speed; + + this->subAction++; + gPlayerState.flags.all |= 1; + if (this->type == 1) { + this->speed = 0; + this->actionDelay = 0; + this->field_0xf = 1; + } else { + this->speed = (gPlayerState.flags.all & 0x80) ? 64 : 128; + } + sub_08071AF0(this); +} + +void sub_08071AF0(Entity* this) { + gPlayerState.field_0x80 = 0; + UpdateAnimationSingleFrame(this); + if (this->type == 1) { + if (--this->field_0xf == 0) { + if (gUnk_0811BAF0[this->actionDelay].frame != 0xff) { + this->field_0xf = gUnk_0811BAF0[this->actionDelay].frame; + this->speed = gUnk_0811BAF0[this->actionDelay].speed; + this->actionDelay++; + } else { + this->subAction++; + return; + } + } + } else { + gPlayerState.pushedObject--; + if ((gPlayerState.pushedObject & 0x7f) == 0) { + this->subAction++; + } + } + sub_08079E08(); +} + +void sub_08071B60(Entity* this) { + gPlayerState.pushedObject = 2; + gPlayerState.flags.all &= ~0x1; + this->type = 0; + this->field_0x42 = 0; + sub_080728AC(this); + this->field_0xf = 6; + if ((gPlayerState.flags.all & 0x80) == 0) { + gPlayerState.field_0x8 = 0x104; + this->spriteIndex = 3; + InitAnimationForceUpdate(this, (this->animationState >> 1) + 0x3c); + } +} + +extern void (*const gUnk_0811BB2C[])(Entity*); + +void PlayerMinishDie(Entity* this) { + this->flags &= ~0x80; + gUnk_0811BB2C[this->subAction](this); + gPlayerState.field_0xa8 = 0x12; +} + +void sub_08071BDC(Entity* this) { + u32 temp; + + if (gPlayerState.flags.all & (0x10 | 0x100)) + return; + + if (sub_08003FC4(this, 0x2000)) { + if ((gPlayerState.flags.all & 8) != 0) + gPlayerState.field_0x8 = 0x420; + else + gPlayerState.field_0x8 = 0x810; + return; + } + + gPlayerState.playerAction = 0; + if (gPlayerState.flags.all & 0x80) { + if ((u8)(gPlayerState.field_0x10[2] - 8) < 3) { + sub_0807A298(this); + RespawnPlayer(); + this->action = 10; + } + temp = 0xc1a; + } else { + temp = (gPlayerState.flags.all & 8) ? 0x459 : 0x1bc; + } + gPlayerState.field_0x8 = temp; + + gPlayerState.flags.all &= ~(0x1000000 | 0x200000 | 0x40000 | 0x800 | 0x400 | 0x100 | 0x1); + this->subAction = 1; + this->animationState = 4; + this->spritePriority.b1 = 1; + this->spriteSettings.b.draw = 3; + gPlayerState.jumpStatus = 0; + gPlayerState.pushedObject = 0; + sub_0800451C(this); + ResetPlayer(); + SoundReq(0x87); +} + +void sub_08071CAC(Entity* this) { + UpdateAnimationSingleFrame(this); + if (this->frames.all & 0x80) { + u32 temp; + if ((gPlayerState.flags.all & 0x80) == 0) + temp = (gPlayerState.flags.all & 8) ? 0x45a : 0x2bd; + else + temp = 0xc1b; + gPlayerState.field_0x8 = temp; + + this->subAction = 2; + this->actionDelay = 0xf0; + SoundReq(0x7b); + } +} + +void sub_08071D04(Entity* this) { + int idx; + int deltaHealth; + + UpdateAnimationSingleFrame(this); + if (this->frames.all == 0) + return; + + deltaHealth = 0; + idx = GetBottleContaining(0x28); + if (idx != 0) { + gSave.stats.bottles[idx - 1] = 0x20; + CreateObject(0x40, 0x60, 2); + deltaHealth = 32; + } + + if (deltaHealth != 0) { + ModHealth(deltaHealth); + this->subAction = 3; + gPlayerState.field_0x3c[0] = 0; + this->direction = 0xff; + this->speed = 0; + this->field_0x20 = 0x18000; + gPlayerState.jumpStatus = 1; + gPlayerState.swimState = 0; + return; + } + + gScreenTransition.field_0x4[1] = 1; +} + +void sub_08071D80(Entity* this) { + UpdateAnimationSingleFrame(this); + gPlayerState.field_0x14 = 1; + sub_08073904(this); + if ((gPlayerState.jumpStatus & 7) == 3) { + gPlayerState.jumpStatus = 0; + this->iframes = 226; + UnfreezeTime(); + sub_080791D0(); + } +} + +void sub_08071DB8(Entity* this) { + gUnk_0811BB3C[this->subAction](this); +} + +void sub_08071DD0(Entity* this) { + this->actionDelay = gPlayerState.field_0x38; + if (gPlayerState.field_0x39 != 0) { + gPlayerState.field_0x39 = 0; + this->subAction = 2; + gPlayerState.field_0x8 = 0x100; + } else { + this->subAction = 1; + gPlayerState.field_0x8 = 0x114; + } +} + +void sub_08071E04(Entity* this) { + if ((this->height.WORD != 0) && (gPlayerState.field_0x14 == '\0')) { + sub_0807A1B8(); + if (gPlayerState.field_0x10[2] == 1) { + gPlayerState.field_0x10[1] = 7; + gPlayerState.flags.all |= 0x200; + sub_080791BC(); + return; + } + } + + UpdateAnimationSingleFrame(this); + if (sub_08079B24() == 0) { + sub_08079708(this); + return; + } + + sub_080792D8(); + if (sub_0807953C()) + this->actionDelay -= 2; + else + this->actionDelay -= 1; + + if ((s8)this->actionDelay < 1) + sub_080791BC(); +} + +void sub_08071E74(Entity* this) { + u32 temp; + + sub_08003FC4(this, 0x2000); + sub_08079E08(); + temp = this->actionDelay--; + if (temp == 0) + sub_080791BC(); +} + +void PlayerInit(Entity*); +void PlayerNormal(Entity*); +void PlayerInit(Entity*); +void PlayerFall(Entity*); +void PlayerJump(Entity*); +void PlayerPush(Entity*); +void PlayerBounce(Entity*); +void sub_08070E9C(Entity*); +void PlayerItemGet(Entity*); +void PlayerMinish(Entity*); +void PlayerMinishDie(Entity*); +void sub_08071DB8(Entity*); +void PlayerEmptyBottle(Entity*); +void PlayerFrozen(Entity*); +void sub_0807204C(Entity*); +void sub_080720DC(Entity*); +void PlayerPull(Entity*); +void PlayerLava(Entity*); +void PlayerWarp(Entity*); +void sub_08072454(Entity*); +void PlayerDrown(Entity*); +void PlayerUsePortal(Entity*); +void PlayerTalkEzlo(Entity*); +void PlayerRoomTransition(Entity*); +void PlayerRoll(Entity*); +void sub_080728AC(Entity*); +void PlayerInHole(Entity*); +void sub_08072C9C(Entity*); +void sub_08074C44(Entity*); +void sub_08072F34(Entity*); +void PlayerUseEntrance(Entity*); +void PlayerParachute(Entity*); + +static void (*const sPlayerActions[])(Entity*) = { + [PLAYER_INIT] = PlayerInit, + [PLAYER_NORMAL] = PlayerNormal, + [PLAYER_DUMMY] = PlayerInit, + [PLAYER_FALL] = PlayerFall, + [PLAYER_JUMP] = PlayerJump, + [PLAYER_PUSH] = PlayerPush, + [PLAYER_BOUNCE] = PlayerBounce, + [PLAYER_08070E9C] = sub_08070E9C, + [PLAYER_ITEMGET] = PlayerItemGet, + [PLAYER_MINISH] = PlayerMinish, + [PLAYER_MINISHDIE] = PlayerMinishDie, + [PLAYER_08071DB8] = sub_08071DB8, + [PLAYER_EMPTYBOTTLE] = PlayerEmptyBottle, + [PLAYER_FROZEN] = PlayerFrozen, + [PLAYER_0807204C] = sub_0807204C, + [PLAYER_080720DC] = sub_080720DC, + [PLAYER_PULL] = PlayerPull, + [PLAYER_LAVA] = PlayerLava, + [PLAYER_WARP] = PlayerWarp, + [PLAYER_08072454] = sub_08072454, + [PLAYER_DROWN] = PlayerDrown, + [PLAYER_USEPORTAL] = PlayerUsePortal, + [PLAYER_TALKEZLO] = PlayerTalkEzlo, + [PLAYER_ROOMTRANSITION] = PlayerRoomTransition, + [PLAYER_ROLL] = PlayerRoll, + [PLAYER_080728AC] = sub_080728AC, + [PLAYER_INHOLE] = PlayerInHole, + [PLAYER_08072C9C] = sub_08072C9C, + [PLAYER_08074C44] = sub_08074C44, + [PLAYER_08072F34] = sub_08072F34, + [PLAYER_USEENTRANCE] = PlayerUseEntrance, + [PLAYER_PARACHUTE] = PlayerParachute, +}; diff --git a/src/script.c b/src/script.c index 6e4d577a..450ff8f9 100644 --- a/src/script.c +++ b/src/script.c @@ -853,7 +853,7 @@ void ScriptCommand_BuyItem(Entity* entity, ScriptExecutionContext* context) { } void ScriptCommand_0807E48C(Entity* entity, ScriptExecutionContext* context) { - context->condition = sub_080544DC(context->scriptInstructionPointer[1]); + context->condition = GetBottleContaining(context->scriptInstructionPointer[1]); gActiveScriptInfo.flags |= 1; } @@ -1085,7 +1085,7 @@ void ScriptCommand_0807E8E4(Entity* entity, ScriptExecutionContext* context) { void ScriptCommand_0807E908(Entity* entity, ScriptExecutionContext* context) { entity->action = context->scriptInstructionPointer[1]; - entity->previousActionFlag = 0; + entity->subAction = 0; } void ScriptCommand_SetIntVariable(Entity* entity, ScriptExecutionContext* context) { From a39686c24c4b1acc2459088659c6f648b7dff80e Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 17 Mar 2021 20:20:32 -0700 Subject: [PATCH 2/3] fix --- asm/non_matching/player/sub_08071634.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asm/non_matching/player/sub_08071634.s b/asm/non_matching/player/sub_08071634.s index 96fd319c..3c377521 100644 --- a/asm/non_matching/player/sub_08071634.s +++ b/asm/non_matching/player/sub_08071634.s @@ -169,4 +169,4 @@ _08071754: pop {r3} mov r8, r3 pop {r4, r5, r6, r7, pc} - .syntax divided \ No newline at end of file + .syntax divided From 3b1f9e6aa76a769f07d7176215dc198c467b99e0 Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 17 Mar 2021 20:26:41 -0700 Subject: [PATCH 3/3] fix2 --- src/game.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game.c b/src/game.c index 4d02bdcb..4c06014b 100644 --- a/src/game.c +++ b/src/game.c @@ -15,7 +15,6 @@ extern u8 gArea; extern Entity gPlayerEntity; -extern u32 gUnk_03000B80; extern u32 gUnk_03003FC0; extern u16 gWalletSizes[4]; @@ -240,8 +239,8 @@ void InitializePlayer(void) { Entity* pl; sub_080784C8(); - MemClear32((void*)&gUnk_03000B80, sizeof(gUnk_03000B80)); - MemClear32((void*)&gPlayerState, 0xb0); + MemClear((void*)&gUnk_03000B80, sizeof(gUnk_03000B80)); + MemClear((void*)&gPlayerState, 0xb0); MemFill32(0xffffffff, &gPlayerState.field_0x40, 0x40); pl = &gPlayerEntity;