diff --git a/.gitignore b/.gitignore index e3bb8d94..69ee3035 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,4 @@ _Deparsed_XSubs.pm *.sna __pycache__ Info.plist +ctx.c diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b8e5c60..d43217a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,7 @@ sub_08086284: @ 0x08086284 ldrh r2, [r0] adds r0, r4, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo pop {r4, pc} .align 2, 0 _080862B4: .4byte gUnk_08120668 @@ -119,10 +119,10 @@ Then, start translating the code to `src/evilSpirit.c`, bit by bit: ldrh r2, [r0] add r0, r4, #0 mov r3, #0 - bl sub_0805EC9C + bl SetAffineInfo ``` ```c - sub_0805EC9C(r0, *(u16 *)(r0 + 0x76), *(u16 *)(r0 + 0x7a), 0); + SetAffineInfo(r0, *(u16 *)(r0 + 0x76), *(u16 *)(r0 + 0x7a), 0); ``` --- ```asm @@ -151,7 +151,7 @@ Putting it all together, we get: void sub_08086284(u8 *r0) { gUnk_08120668[*(u8 *)(r0 + 0xc)](r0); *(u8 *)(r0 + 0x41) = 0; - sub_0805EC9C(r0, *(u16 *)(r0 + 0x76), *(u16 *)(r0 + 0x7a), 0); + SetAffineInfo(r0, *(u16 *)(r0 + 0x76), *(u16 *)(r0 + 0x7a), 0); return; } ``` @@ -217,7 +217,7 @@ Much better. void sub_08086284(Entity *r0) { gUnk_08120668[r0->action](r0); r0->bitfield = 0; - sub_0805EC9C(r0, r0->field_0x76.HWORD, r0->field_0x7a.HWORD, 0); + SetAffineInfo(r0, r0->field_0x76.HWORD, r0->field_0x7a.HWORD, 0); return; } ``` @@ -235,18 +235,18 @@ src/evilSpirit.c: In function `sub_08086284': src/evilSpirit.c:4: syntax error before `*' src/evilSpirit.c:5: `gUnk_08120668' undeclared (first use in this function) src/evilSpirit.c:5: (Each undeclared identifier is reported only once for each function it appears in.) -src/evilSpirit.c:7: warning: implicit declaration of function `sub_0805EC9C' +src/evilSpirit.c:7: warning: implicit declaration of function `SetAffineInfo' ``` -We got some errors. We need to tell the compiler what `gUnk_08120668`, `Entity`, and `sub_0805EC9C` are. +We got some errors. We need to tell the compiler what `gUnk_08120668`, `Entity`, and `SetAffineInfo` are. We know `r0` is an `Entity`, which is from `entity.h`. We can declare this above the function: ```c #include "entity.h" ``` -What about `gUnk_08120668` and `sub_0805EC9C`? +What about `gUnk_08120668` and `SetAffineInfo`? ```c -extern void sub_0805EC9C(); +extern void SetAffineInfo(); extern void (*gUnk_08120668[])(Entity *); ``` Now the compiler will look outside of this file for both of these. We don't have to set the size of `gUnk_08120668`, a function array, since it's size is irrelevant for now. @@ -258,13 +258,13 @@ Now our file looks like this: #include "global.h" #include "entity.h" -extern void sub_0805EC9C(); +extern void SetAffineInfo(); extern void (*gUnk_08120668[])(Entity *); void sub_08086284(Entity *r0) { gUnk_08120668[r0->action](r0); r0->bitfield = 0; - sub_0805EC9C(r0, r0->field_0x76.HWORD, r0->field_0x7a.HWORD, 0); + SetAffineInfo(r0, r0->field_0x76.HWORD, r0->field_0x7a.HWORD, 0); return; } ``` diff --git a/asm/enemy/chuchuBoss.s b/asm/enemy/chuchuBoss.s index c14282fe..0cf40833 100644 --- a/asm/enemy/chuchuBoss.s +++ b/asm/enemy/chuchuBoss.s @@ -488,7 +488,7 @@ sub_08026060: @ 0x08026060 adds r0, #4 ldrh r3, [r0] adds r0, r4, #0 - bl sub_0805EC9C + bl SetAffineInfo pop {r4, pc} .align 2, 0 _0802608C: .4byte gUnk_080CC1C8 diff --git a/asm/non_matching/GetEmptyEntity.inc b/asm/non_matching/GetEmptyEntity.inc index faa6d4d6..4330be0a 100644 --- a/asm/non_matching/GetEmptyEntity.inc +++ b/asm/non_matching/GetEmptyEntity.inc @@ -48,7 +48,7 @@ _0805E6CC: .4byte gPlayerEntity _0805E6D0: .4byte gUpdateContext _0805E6D4: adds r4, #0x88 - ldr r0, _0805E738 @ =gUnk_03003BE0 + ldr r0, _0805E738 @ =gCarryEntities cmp r4, r0 blo _0805E6A8 movs r0, #0 @@ -101,7 +101,7 @@ _0805E730: mov r8, r3 pop {r4, r5, r6, r7, pc} .align 2, 0 -_0805E738: .4byte gUnk_03003BE0 +_0805E738: .4byte gCarryEntities _0805E73C: .4byte gEntityLists _0805E740: .4byte gUpdateContext .syntax divided diff --git a/asm/non_matching/sub_0805EC9C.inc b/asm/non_matching/SetAffineInfo.inc similarity index 100% rename from asm/non_matching/sub_0805EC9C.inc rename to asm/non_matching/SetAffineInfo.inc diff --git a/asm/non_matching/bombPeahat/sub_0802AFC8.inc b/asm/non_matching/bombPeahat/sub_0802AFC8.inc index 89393e10..6781fe36 100644 --- a/asm/non_matching/bombPeahat/sub_0802AFC8.inc +++ b/asm/non_matching/bombPeahat/sub_0802AFC8.inc @@ -49,7 +49,7 @@ _0802B00C: adds r0, r4, #0 adds r1, r2, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo _0802B022: ldrb r0, [r4, #0xf] ands r0, r7 diff --git a/asm/non_matching/code_0805EC04/sub_0805ED30.inc b/asm/non_matching/code_0805EC04/UpdatePlayerInput.inc similarity index 97% rename from asm/non_matching/code_0805EC04/sub_0805ED30.inc rename to asm/non_matching/code_0805EC04/UpdatePlayerInput.inc index bdf6bc56..0ace695b 100644 --- a/asm/non_matching/code_0805EC04/sub_0805ED30.inc +++ b/asm/non_matching/code_0805EC04/UpdatePlayerInput.inc @@ -79,7 +79,7 @@ _0805EDB4: strb r0, [r2] ldr r0, _0805EDF8 @ =gInput ldrh r0, [r0] - bl sub_0805EE04 + bl ConvInputToState adds r1, r4, #0 adds r1, #0x90 strh r0, [r1] @@ -88,7 +88,7 @@ _0805EDC6: ldrh r1, [r0] _0805EDCA: adds r0, r1, #0 - bl sub_0805EE04 + bl ConvInputToState ldr r3, _0805EDFC @ =gPlayerState adds r1, r3, #0 adds r1, #0x90 diff --git a/asm/non_matching/frozenOctorok/FrozenOctorok_Action1.inc b/asm/non_matching/frozenOctorok/FrozenOctorok_Action1.inc index a764d5b5..4eb27cb8 100644 --- a/asm/non_matching/frozenOctorok/FrozenOctorok_Action1.inc +++ b/asm/non_matching/frozenOctorok/FrozenOctorok_Action1.inc @@ -252,7 +252,7 @@ _0809C7C4: adds r0, #6 ldrh r3, [r0] adds r0, r5, #0 - bl sub_0805EC9C + bl SetAffineInfo b _0809C7DE _0809C7D2: ldr r0, _0809C7E0 @ =gRoomControls diff --git a/asm/non_matching/itemBomb/sub_08076088.inc b/asm/non_matching/itemBomb/sub_08076088.inc index 6f95363b..b5f733df 100644 --- a/asm/non_matching/itemBomb/sub_08076088.inc +++ b/asm/non_matching/itemBomb/sub_08076088.inc @@ -98,7 +98,7 @@ _08076138: _0807614A: adds r0, r4, #0 movs r1, #0x13 - bl CreatePlayerBomb + bl CreatePlayerItemWithParent adds r3, r0, #0 cmp r3, #0 bne _08076162 diff --git a/asm/non_matching/itemMoleMitts/sub_080772A8.inc b/asm/non_matching/itemMoleMitts/sub_080772A8.inc index e3424dcf..11be37fb 100644 --- a/asm/non_matching/itemMoleMitts/sub_080772A8.inc +++ b/asm/non_matching/itemMoleMitts/sub_080772A8.inc @@ -99,7 +99,7 @@ _08077370: .4byte gUnk_0811BE16 _08077374: adds r0, r4, #0 adds r1, r6, #0 - bl sub_08077E78 + bl DeletePlayerItem ldr r0, _08077388 @ =gPlayerState adds r0, #0x3d movs r1, #0 diff --git a/asm/non_matching/itemTryPickupObject/sub_080761C0.inc b/asm/non_matching/itemTryPickupObject/ItemPickupCheck.inc similarity index 96% rename from asm/non_matching/itemTryPickupObject/sub_080761C0.inc rename to asm/non_matching/itemTryPickupObject/ItemPickupCheck.inc index 08ce1ec9..e355fe27 100644 --- a/asm/non_matching/itemTryPickupObject/sub_080761C0.inc +++ b/asm/non_matching/itemTryPickupObject/ItemPickupCheck.inc @@ -33,7 +33,7 @@ _080761DE: blo _0807626E cmp r3, #2 bne _080762C0 - ldr r0, _0807622C @ =gUnk_03003BE0 + ldr r0, _0807622C @ =gCarryEntities ldr r2, [r0, #8] ldrb r1, [r2, #0x16] movs r0, #0xf @@ -49,7 +49,7 @@ _080761DE: _08076220: .4byte gPlayerState _08076224: .4byte 0x00001201 _08076228: .4byte gPlayerEntity -_0807622C: .4byte gUnk_03003BE0 +_0807622C: .4byte gCarryEntities _08076230: str r2, [r4, #0x18] strb r3, [r2, #0xc] diff --git a/asm/non_matching/minishEzlo/sub_080630A4.inc b/asm/non_matching/minishEzlo/sub_080630A4.inc index 4a041f21..269de92b 100644 --- a/asm/non_matching/minishEzlo/sub_080630A4.inc +++ b/asm/non_matching/minishEzlo/sub_080630A4.inc @@ -132,7 +132,7 @@ _08063186: adds r0, r4, #0 adds r1, r2, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo adds r0, r4, #0 movs r1, #0x11 bl InitAnimationForceUpdate @@ -163,7 +163,7 @@ _080631CA: ldr r2, [r4, #0x70] adds r0, r4, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo ldr r1, _080631E4 @ =gActiveScriptInfo movs r0, #0 strb r0, [r1, #6] diff --git a/asm/non_matching/ocarina/OcarinaUpdate.inc b/asm/non_matching/ocarina/OcarinaUpdate.inc index ffd951df..b6d19673 100644 --- a/asm/non_matching/ocarina/OcarinaUpdate.inc +++ b/asm/non_matching/ocarina/OcarinaUpdate.inc @@ -27,7 +27,7 @@ bl ResetPlayerEventPriority adds r0, r5, #0 adds r1, r6, #0 - bl sub_08077E78 + bl DeletePlayerItem _08076C6E: pop {r4, r5, r6, pc} .align 2, 0 diff --git a/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc b/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc index fdcbb90b..5a9cc660 100644 --- a/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc +++ b/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc @@ -308,7 +308,7 @@ _0809A420: adds r0, #0x7a ldrh r3, [r0] adds r0, r7, #0 - bl sub_0805EC9C + bl SetAffineInfo b _0809A436 _0809A432: subs r0, #1 diff --git a/asm/non_matching/playerItem13/sub_080AD040.inc b/asm/non_matching/playerItem13/sub_080AD040.inc index bb2ed5c3..9f1785e5 100644 --- a/asm/non_matching/playerItem13/sub_080AD040.inc +++ b/asm/non_matching/playerItem13/sub_080AD040.inc @@ -85,7 +85,7 @@ _080AD0D8: ldr r0, [r4, #0x34] str r0, [r5, #0x34] adds r0, r4, #0 - bl sub_080B1AA8 + bl GetTileUnderEntity cmp r0, #0x11 bhi _080AD0FC cmp r0, #0x10 diff --git a/asm/non_matching/playerItemBomb/sub_0801B2CC.inc b/asm/non_matching/playerItemBomb/sub_0801B2CC.inc index a538e0b3..f10caa01 100644 --- a/asm/non_matching/playerItemBomb/sub_0801B2CC.inc +++ b/asm/non_matching/playerItemBomb/sub_0801B2CC.inc @@ -5,7 +5,7 @@ cmp r0, #0 bne _0801B2DE adds r0, r4, #0 - bl sub_08078930 + bl RegisterCarryEntity _0801B2DE: movs r0, #8 bl IsItemEquipped diff --git a/asm/non_matching/playerItemBomb/sub_0801B3A4.inc b/asm/non_matching/playerItemBomb/sub_0801B3A4.inc index 21a6c44c..7c4a5b73 100644 --- a/asm/non_matching/playerItemBomb/sub_0801B3A4.inc +++ b/asm/non_matching/playerItemBomb/sub_0801B3A4.inc @@ -40,7 +40,7 @@ _0801B3E0: adds r0, r4, #0 adds r1, r2, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo _0801B3F4: ldrb r0, [r4, #0xf] ands r0, r5 diff --git a/asm/non_matching/playerUtils/sub_08078954.inc b/asm/non_matching/playerUtils/FreeCarryEntity.inc similarity index 90% rename from asm/non_matching/playerUtils/sub_08078954.inc rename to asm/non_matching/playerUtils/FreeCarryEntity.inc index 57002a64..2c604c70 100644 --- a/asm/non_matching/playerUtils/sub_08078954.inc +++ b/asm/non_matching/playerUtils/FreeCarryEntity.inc @@ -2,7 +2,7 @@ push {r4, r5, lr} adds r5, r0, #0 movs r4, #0 - ldr r0, _08078970 @ =gUnk_03003BE0 + ldr r0, _08078970 @ =gCarryEntities ldrb r1, [r0, #2] adds r2, r0, #0 cmp r4, r1 @@ -13,7 +13,7 @@ subs r0, r1, #1 b _0807898C .align 2, 0 -_08078970: .4byte gUnk_03003BE0 +_08078970: .4byte gCarryEntities _08078974: adds r4, #1 ldrb r3, [r2, #2] diff --git a/asm/non_matching/playerUtils/sub_08078930.inc b/asm/non_matching/playerUtils/RegisterCarryEntity.inc similarity index 79% rename from asm/non_matching/playerUtils/sub_08078930.inc rename to asm/non_matching/playerUtils/RegisterCarryEntity.inc index 8e5c252f..613f17dc 100644 --- a/asm/non_matching/playerUtils/sub_08078930.inc +++ b/asm/non_matching/playerUtils/RegisterCarryEntity.inc @@ -1,7 +1,7 @@ .syntax unified push {lr} adds r3, r0, #0 - ldr r2, _08078950 @ =gUnk_03003BE0 + ldr r2, _08078950 @ =gCarryEntities ldrb r0, [r2, #2] cmp r0, #0x1f bhi _0807894C @@ -16,5 +16,5 @@ _0807894C: pop {pc} .align 2, 0 -_08078950: .4byte gUnk_03003BE0 +_08078950: .4byte gCarryEntities .syntax divided diff --git a/asm/non_matching/playerUtils/sub_08078180.inc b/asm/non_matching/playerUtils/sub_08078180.inc index ba6be0b6..8086c11b 100644 --- a/asm/non_matching/playerUtils/sub_08078180.inc +++ b/asm/non_matching/playerUtils/sub_08078180.inc @@ -124,7 +124,7 @@ _08078278: ldrb r0, [r0] cmp r0, #0xe beq _080782BC - ldr r1, _080782A0 @ =gUnk_03003BE0 + ldr r1, _080782A0 @ =gCarryEntities ldrb r0, [r1, #1] movs r4, #9 cmp r0, #2 @@ -136,7 +136,7 @@ _08078278: movs r4, #8 b _080782B6 .align 2, 0 -_080782A0: .4byte gUnk_03003BE0 +_080782A0: .4byte gCarryEntities _080782A4: adds r0, r5, #0 adds r0, #0xa8 diff --git a/asm/non_matching/playerUtils/sub_080789A8.inc b/asm/non_matching/playerUtils/sub_080789A8.inc index ecb20e64..4c9b058d 100644 --- a/asm/non_matching/playerUtils/sub_080789A8.inc +++ b/asm/non_matching/playerUtils/sub_080789A8.inc @@ -2,14 +2,14 @@ push {r4, r5, r6, r7, lr} mov r7, r8 push {r7} - ldr r1, _080789BC @ =gUnk_03003BE0 + ldr r1, _080789BC @ =gCarryEntities ldrb r0, [r1] cmp r0, #0 beq _080789C0 ldrb r0, [r1, #1] b _08078A88 .align 2, 0 -_080789BC: .4byte gUnk_03003BE0 +_080789BC: .4byte gCarryEntities _080789C0: ldr r0, _08078A5C @ =gPlayerState ldr r0, [r0, #0x30] @@ -34,7 +34,7 @@ _080789E6: ldrb r0, [r0, #0x12] cmp r0, #0x12 beq _08078A56 - ldr r3, _08078A68 @ =gUnk_03003BE0 + ldr r3, _08078A68 @ =gCarryEntities movs r0, #1 strb r0, [r3] ldrb r4, [r3, #2] @@ -80,7 +80,7 @@ _08078A2E: lsls r2, r2, #0x18 asrs r2, r2, #0x18 bl sub_080B1A0C - ldr r4, _08078A68 @ =gUnk_03003BE0 + ldr r4, _08078A68 @ =gCarryEntities strh r0, [r4, #4] movs r1, #6 bl sub_0806FC24 @@ -93,7 +93,7 @@ _08078A56: _08078A5C: .4byte gPlayerState _08078A60: .4byte gPlayerEntity _08078A64: .4byte gUnk_080084BC -_08078A68: .4byte gUnk_03003BE0 +_08078A68: .4byte gCarryEntities _08078A6C: .4byte gUnk_0811BFE0 _08078A70: .4byte gUnk_08007DF4 _08078A74: diff --git a/asm/non_matching/pullableMushroom/sub_0808ABC4.inc b/asm/non_matching/pullableMushroom/sub_0808ABC4.inc index 254d7866..d89258b1 100644 --- a/asm/non_matching/pullableMushroom/sub_0808ABC4.inc +++ b/asm/non_matching/pullableMushroom/sub_0808ABC4.inc @@ -150,6 +150,6 @@ _0808ACDE: ldr r2, [r4, #0x78] ldr r3, [r4, #0x70] adds r0, r4, #0 - bl sub_0805EC9C + bl SetAffineInfo pop {r4, r5, pc} .syntax divided diff --git a/asm/object/code_0808C964.s b/asm/object/code_0808C964.s index 1cef7b78..dabd1f86 100644 --- a/asm/object/code_0808C964.s +++ b/asm/object/code_0808C964.s @@ -89,7 +89,7 @@ _0808C9FA: adds r0, r4, #0 adds r1, r2, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo _0808CA04: pop {r4, pc} .align 2, 0 @@ -205,7 +205,7 @@ _0808CAD6: adds r0, r4, #0 adds r1, r3, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo _0808CAE0: pop {r4, r5, r6, pc} .align 2, 0 diff --git a/asm/object/evilSpirit.s b/asm/object/evilSpirit.s index bcdd728a..6998684b 100644 --- a/asm/object/evilSpirit.s +++ b/asm/object/evilSpirit.s @@ -33,7 +33,7 @@ EvilSpirit: @ 0x08086284 ldrh r2, [r0] adds r0, r4, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo pop {r4, pc} .align 2, 0 _080862B4: .4byte gUnk_08120668 diff --git a/asm/object/minecart.s b/asm/object/minecart.s index e1579bbb..3f838464 100644 --- a/asm/object/minecart.s +++ b/asm/object/minecart.s @@ -15,7 +15,7 @@ sub_08091C0C: @ 0x08091C0C adds r0, r4, #0 bl CopyPosition adds r0, r4, #0 - bl sub_080B1AA8 + bl GetTileUnderEntity cmp r0, #0x68 beq _08091C46 cmp r0, #0x68 diff --git a/asm/object/objectAD.s b/asm/object/objectAD.s index 16f62476..fac47835 100644 --- a/asm/object/objectAD.s +++ b/asm/object/objectAD.s @@ -76,7 +76,7 @@ _080A04F8: adds r1, r4, #0 adds r2, r4, #0 movs r3, #0 - bl sub_0805EC9C + bl SetAffineInfo movs r1, #0xe0 lsls r1, r1, #1 subs r1, r1, r4 diff --git a/asm/object/objectBlockingStairs.s b/asm/object/objectBlockingStairs.s index f7cc26f1..bfe2cb30 100644 --- a/asm/object/objectBlockingStairs.s +++ b/asm/object/objectBlockingStairs.s @@ -200,7 +200,7 @@ _08093040: cmp r0, #0 beq _080930E6 adds r0, r6, #0 - bl sub_08078930 + bl RegisterCarryEntity adds r3, r7, #0 ldrb r2, [r3] movs r0, #0x80 diff --git a/asm/src/code_08003FC4.s b/asm/src/code_08003FC4.s index 718c0306..ee3bd1d7 100644 --- a/asm/src/code_08003FC4.s +++ b/asm/src/code_08003FC4.s @@ -5,22 +5,22 @@ .text +@ r0 = Entity* +@ r1 = Gravity strength +@ returns z pos thumb_func_start GravityUpdate GravityUpdate: @ 0x08003FC4 - @ r0 = Entity* - @ r1 = Gravity strength - @ returns z pos adds r3, r0, #0 ldr r0, [r3, #0x34] ldr r2, [r3, #0x20] subs r0, r0, r2 - bpl _08003FD6 + bpl hitground subs r2, r2, r1 str r0, [r3, #0x34] str r2, [r3, #0x20] bx lr -_08003FD6: +hitground: movs r0, #0 str r0, [r3, #0x34] str r0, [r3, #0x20] @@ -29,7 +29,7 @@ _08003FD6: non_word_aligned_thumb_func_start sub_08003FDE sub_08003FDE: @ 0x08003FDE push {r0, lr} - bl sub_08003FF2 + bl CheckEntityPickup cmp r0, #0 pop {r2} beq _08003FF0 @@ -38,8 +38,8 @@ sub_08003FDE: @ 0x08003FDE _08003FF0: pop {pc} - non_word_aligned_thumb_func_start sub_08003FF2 -sub_08003FF2: @ 0x08003FF2 + non_word_aligned_thumb_func_start CheckEntityPickup +CheckEntityPickup: @ 0x08003FF2 push {r4, r5, r6, r7, lr} ldr r4, [r1, #0x48] ldrb r5, [r4, #6] diff --git a/asm/src/code_080043E8.s b/asm/src/code_080043E8.s index 8ce6abb5..9bd9eeee 100644 --- a/asm/src/code_080043E8.s +++ b/asm/src/code_080043E8.s @@ -170,7 +170,7 @@ _08004516: thumb_func_start sub_0800451C sub_0800451C: @ 0x0800451C push {r0, lr} - bl sub_080B1AA8 + bl GetTileUnderEntity adds r1, r0, #0 pop {r0, r3} mov lr, r3 diff --git a/asm/src/crt0.s b/asm/src/crt0.s index 2e3609b4..6dde879b 100644 --- a/asm/src/crt0.s +++ b/asm/src/crt0.s @@ -13,37 +13,25 @@ header: start_vector: mov r0, #0x12 msr cpsr_fc, r0 - ldr sp, sp_irq + ldr sp, =irq_stack_begin mov r0, #0x1f msr cpsr_fc, r0 - ldr sp, sp_usr - ldr r1, INTR_VECTOR_BUF - ldr r0, intr_main + ldr sp, =usr_stack_begin + ldr r1, =0x03007FFC + ldr r0, =ram_IntrMain str r0, [r1] -.ifdef EU - ldr r1, unk_function - mov lr, pc - bx r1 -.else -.ifdef DEMO_JP - ldr r1, unk_function + +.ifndef USA +.ifndef DEMO_USA +.ifndef JP + ldr r1, =fill_rq_stack mov lr, pc bx r1 .endif .endif +.endif + ldr r1, =AgbMain mov lr, pc bx r1 -_080000F0: b start_vector -sp_irq: .4byte irq_stack_begin -sp_usr: .4byte usr_stack_begin -INTR_VECTOR_BUF: .4byte 0x03007FFC -intr_main: .4byte ram_IntrMain -.ifdef EU -unk_function: .4byte fill_rq_stack -.else -.ifdef DEMO_JP -unk_function: .4byte fill_rq_stack -.endif -.endif diff --git a/asm/src/intr.s b/asm/src/intr.s index 4aea95fc..93b68c22 100644 --- a/asm/src/intr.s +++ b/asm/src/intr.s @@ -129,7 +129,7 @@ arm_sub_080B1A8C: @ 0x080B1A8C ldrb r2, [r0, #0x38] mov r0, r3 b arm_sub_080B1AB4 -arm_sub_080B1AA8: +arm_GetTileUnderEntity: ldrb r2, [r0, #0x38] ldrh r1, [r0, #0x32] ldrh r0, [r0, #0x2e] diff --git a/asm/src/script.s b/asm/src/script.s index 71de3364..4a607068 100644 --- a/asm/src/script.s +++ b/asm/src/script.s @@ -106,7 +106,7 @@ _08016A64: sub_08016A6C: @ 0x08016A6C push {r4, r5, lr} adds r4, r0, #0 - bl sub_080B1AA8 + bl GetTileUnderEntity add r1, pc, #0x38 _08016A76: adds r1, #4 diff --git a/asm/src/stack_check.s b/asm/src/stack_check.s new file mode 100644 index 00000000..32ed1fa5 --- /dev/null +++ b/asm/src/stack_check.s @@ -0,0 +1,43 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + .syntax unified + .text + + thumb_func_start fill_rq_stack +fill_rq_stack: // fill iqr and user stack with 'MCZ3' + adr r0, pool + ldm r0!, {r1, r2, r3} +loop1: + subs r2, #4 + str r1, [r2] + cmp r2, r3 + bgt loop1 + bx lr + +// unused +// returns the maximum values reached by irq stack (r0) and usr stack (r1) +check_stack_threshold: + adr r0, pool + ldm r0!, {r1, r2, r3} +loop2: + ldr r0, [r3] + adds r3, #4 + cmp r0, r1 // cmp against magic + beq loop2 + + subs r2, #0xa0 +loop3: + ldr r0, [r2] + adds r2, #4 + cmp r0, r1 // cmp against magic + beq loop3 + + subs r1, r2, #4 + subs r0, r3, #4 + bx lr + + .align 2, 0 +pool: + .byte '3, 'Z, 'C, 'M // r1 + .4byte irq_stack_begin // r2 + .4byte usr_stack_top // r3 diff --git a/asm/src/veneer.s b/asm/src/veneer.s index 3cb55e81..a160d6cd 100644 --- a/asm/src/veneer.s +++ b/asm/src/veneer.s @@ -5,51 +5,6 @@ .text -.ifndef USA -.ifndef DEMO_USA -.ifndef JP - thumb_func_start fill_rq_stack -fill_rq_stack: // fill iqr and user stack with 'MCZ3' - adr r0, 1f - ldm r0!, {r1, r2, r3} -0: - subs r2, #4 - str r1, [r2] - cmp r2, r3 - bgt 0b - bx lr - -// unused -// returns the maximum values reached by irq stack (r0) and usr stack (r1) -check_stack_threshold: - adr r0, 1f - ldm r0!, {r1, r2, r3} -0: - ldr r0, [r3] - adds r3, #4 - cmp r0, r1 // cmp against magic - beq 0b - - subs r2, #0xa0 -0: - ldr r0, [r2] - adds r2, #4 - cmp r0, r1 // cmp against magic - beq 0b - - subs r1, r2, #4 - subs r0, r3, #4 - bx lr - - .align 2, 0 -1: - .byte '3, 'Z, 'C, 'M // r1 - .4byte irq_stack_begin // r2 - .4byte usr_stack_top // r3 -.endif -.endif -.endif - thumb_func_start UpdateScrollVram UpdateScrollVram: @ 0x08000108 push {r4, lr} @@ -322,9 +277,9 @@ sub_080B1A8C: @ 0x080002B4 @ return: @ ======== @ Called every frame a pot is thrown, every frame the screen is sliding in a transition, and once when entering stairs. - thumb_func_start sub_080B1AA8 -sub_080B1AA8: @ 0x080002B8 - ldr r3, _08000324 @ =ram_sub_080B1AA8 + thumb_func_start GetTileUnderEntity +GetTileUnderEntity: @ 0x080002B8 + ldr r3, _08000324 @ =ram_GetTileUnderEntity bx r3 @ call 0x080B1AB4 @@ -458,7 +413,7 @@ _08000314: .4byte ram_sub_080B1A48 _08000318: .4byte ram_sub_080B1A58 _0800031C: .4byte ram_GetTileType _08000320: .4byte ram_sub_080B1A8C -_08000324: .4byte ram_sub_080B1AA8 +_08000324: .4byte ram_GetTileUnderEntity _08000328: .4byte ram_sub_080B1AB4 _0800032C: .4byte ram_sub_080B1AC8 _08000330: .4byte ram_sub_080B1AD8 diff --git a/data/const/item/itemTryPickupObject.s b/data/const/item/itemTryPickupObject.s index 2c523ea7..ba058a82 100644 --- a/data/const/item/itemTryPickupObject.s +++ b/data/const/item/itemTryPickupObject.s @@ -6,7 +6,7 @@ gUnk_0811BDB4:: @ 0811BDB4 - .4byte sub_080761C0 + .4byte ItemPickupCheck .4byte sub_080762D8 .4byte sub_08076488 .4byte sub_08076518 diff --git a/data/scripts/cutscene/introBusinessScrub/script_ZeldaIntroBusinessScrub.inc b/data/scripts/cutscene/introBusinessScrub/script_ZeldaIntroBusinessScrub.inc index ae7c5633..24942bab 100644 --- a/data/scripts/cutscene/introBusinessScrub/script_ZeldaIntroBusinessScrub.inc +++ b/data/scripts/cutscene/introBusinessScrub/script_ZeldaIntroBusinessScrub.inc @@ -33,7 +33,7 @@ SCRIPT_START script_ZeldaIntroBusinessScrub SetEntitySpeed 0x0200 WalkSouth 0x0008 SetAnimation 0x0040 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimationState 0x0006 DoPostScriptAction 0x0000 SetSyncFlag 0x00000002 diff --git a/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc b/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc index 46e39e17..8427c4de 100644 --- a/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc +++ b/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc @@ -30,7 +30,7 @@ SCRIPT_START script_Npc4EMonsters Call NPC4E_SaveEquippedItems Call SetPlayerActionNormal CallWithArg EquipItem, 0x0000000d - CallWithArg sub_0807F29C, gUnk_080049F6 + CallWithArg SetInputMacro, gUnk_080049F6 _0807F0B4 0x0001 SetEntityPositionRelative 0x01f8, 0x0068 SetSyncFlag 0x00000004 @@ -41,7 +41,7 @@ SCRIPT_START script_Npc4EMonsters PlaySound SFX_1C3 SetSyncFlag 0x20000000 Wait 0x0078 - CallWithArg sub_0807F29C, 0x00000000 + CallWithArg SetInputMacro, 0x00000000 Call NPC4E_RestoreEquippedItems SetSyncFlag 0x40000000 SetSyncFlag 0x00000010 diff --git a/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc b/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc index 02d18eba..f807fc41 100644 --- a/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc +++ b/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc @@ -10,11 +10,11 @@ SCRIPT_START script_Npc4EVaatiAttacking Call NPC4E_SaveEquippedItems Call SetPlayerActionNormal CallWithArg EquipItem, 0x0000000d - CallWithArg sub_0807F29C, gUnk_080049F6 + CallWithArg SetInputMacro, gUnk_080049F6 Wait 0x001e SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000200 - CallWithArg sub_0807F29C, 0x00000000 + CallWithArg SetInputMacro, 0x00000000 Call NPC4E_RestoreEquippedItems Wait 0x003c SetSyncFlag 0x08000000 diff --git a/data/scripts/cutscene/introCeremony/script_PlayerFainting.inc b/data/scripts/cutscene/introCeremony/script_PlayerFainting.inc index 8e0ae500..f35afc73 100644 --- a/data/scripts/cutscene/introCeremony/script_PlayerFainting.inc +++ b/data/scripts/cutscene/introCeremony/script_PlayerFainting.inc @@ -11,7 +11,7 @@ SCRIPT_START script_PlayerFainting Call sub_0807F1E8 DoPostScriptAction 0x0011 EndBlock - Call WaitForFrameHiBit + Call WaitForAnimDone WaitForSyncFlag 0x80000000 Call SetPlayerActionNormal SCRIPT_END diff --git a/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc b/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc index 13d6fa8c..5236e03b 100644 --- a/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc +++ b/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc @@ -13,21 +13,21 @@ SCRIPT_START script_VaatiIntroCeremony WaitForSyncFlagAndClear 0x00000100 SetAnimationState 0x0004 DoPostScriptAction 0x001c - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimationState 0x0004 DoPostScriptAction 0x0000 SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00000100 SetAnimationState 0x0000 DoPostScriptAction 0x001c - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimationState 0x0000 DoPostScriptAction 0x0000 SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00000100 SetAnimationState 0x0000 DoPostScriptAction 0x001a - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0000 SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00000100 @@ -71,7 +71,7 @@ SCRIPT_START script_VaatiIntroCeremony Wait 0x005a SetAnimationState 0x0004 DoPostScriptAction 0x001c - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimationState 0x0004 DoPostScriptAction 0x0000 Wait 0x001e diff --git a/data/scripts/cutscene/introCeremony/script_ZeldaIntroCastle.inc b/data/scripts/cutscene/introCeremony/script_ZeldaIntroCastle.inc index cfe741b1..9ccd1167 100644 --- a/data/scripts/cutscene/introCeremony/script_ZeldaIntroCastle.inc +++ b/data/scripts/cutscene/introCeremony/script_ZeldaIntroCastle.inc @@ -48,7 +48,7 @@ script_08011206: Call sub_08066E20 Wait 0x0014 DoPostScriptAction 0x0010 - Call WaitForFrameHiBit + Call WaitForAnimDone PlaySound SFX_1CA SetSyncFlag 0x00000020 WaitForSyncFlagAndClear 0x00000010 diff --git a/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc b/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc index 10f3eef7..ffd9dc02 100644 --- a/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc +++ b/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc @@ -164,14 +164,14 @@ SCRIPT_START script_Npc4EIntroTown CallWithArg EquipItem, 0x0000000d SetIntVariable 0x000000ff Call sub_0807F5B0 - CallWithArg sub_0807F29C, gUnk_080049D6 + CallWithArg SetInputMacro, gUnk_080049D6 Wait 0x00b7 SetIntVariable 0x00000000 Call sub_0807F5B0 MessageFromTargetPos 0x102c, 0x0000 WaitUntilTextboxCloses @ Give control back to the player - CallWithArg sub_0807F29C, 0x00000000 + CallWithArg SetInputMacro, 0x00000000 Call NPC4E_RestoreEquippedItems _0807F0B4 0x0004 CameraTargetPlayer diff --git a/data/scripts/cutscene/originStory/script_MinishEzlo.inc b/data/scripts/cutscene/originStory/script_MinishEzlo.inc index 5acc0d71..7b5e52c9 100644 --- a/data/scripts/cutscene/originStory/script_MinishEzlo.inc +++ b/data/scripts/cutscene/originStory/script_MinishEzlo.inc @@ -34,7 +34,7 @@ SCRIPT_START script_MinishEzlo SetSyncFlag 0x00010000 WaitForSyncFlagAndClear 0x00008000 SetAnimation 0x000d - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00010000 Wait 0x003c DoPostScriptAction 0x0005 diff --git a/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc b/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc index 75e76a5b..2d149f47 100644 --- a/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc +++ b/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc @@ -17,7 +17,7 @@ SCRIPT_START script_Object6AMinishCap SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000080 SetAnimation 0x0001 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END .2byte 0x0000 diff --git a/data/scripts/cutscene/originStory/script_Vaati.inc b/data/scripts/cutscene/originStory/script_Vaati.inc index 3a48e430..ac8c49a7 100644 --- a/data/scripts/cutscene/originStory/script_Vaati.inc +++ b/data/scripts/cutscene/originStory/script_Vaati.inc @@ -23,7 +23,7 @@ SCRIPT_START script_Vaati SetSyncFlag 0x00001000 WaitForSyncFlagAndClear 0x00000800 DoPostScriptAction 0x0018 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimationState 0x0004 DoPostScriptAction 0x0000 SetSyncFlag 0x00001000 diff --git a/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc b/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc index 8e9cce5d..f356d65f 100644 --- a/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc +++ b/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc @@ -16,7 +16,7 @@ SCRIPT_START script_VaatiAppearsAgain Wait 0x0014 SetAnimationState 0x0000 DoPostScriptAction 0x001c - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0000 SetSyncFlag 0x00000004 WaitForSyncFlagAndClear 0x00000002 diff --git a/data/scripts/cutscene/outro/script_MinishEzloGoodbye.inc b/data/scripts/cutscene/outro/script_MinishEzloGoodbye.inc index ba35737d..db38ceb7 100644 --- a/data/scripts/cutscene/outro/script_MinishEzloGoodbye.inc +++ b/data/scripts/cutscene/outro/script_MinishEzloGoodbye.inc @@ -25,17 +25,17 @@ SCRIPT_START script_MinishEzloGoodbye SetSyncFlag 0x00000004 WaitForSyncFlagAndClear 0x00000002 SetAnimation 0x000c - Call WaitForFrameHiBit + Call WaitForAnimDone Call sub_08094B94 SetSyncFlag 0x00000004 WaitForSyncFlagAndClear 0x00000002 SetAnimation 0x000f - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000004 WaitForSyncFlagAndClear 0x00000002 CallWithArg sub_080960C4, script_Object6AEzloFinalMagic SetAnimation 0x0012 - Call WaitForFrameHiBit + Call WaitForAnimDone Wait 0x001e SetSyncFlag 0x00000020 StopBgm diff --git a/data/scripts/cutscene/outro/script_MinishEzloOutro.inc b/data/scripts/cutscene/outro/script_MinishEzloOutro.inc index b82f4618..1741a522 100644 --- a/data/scripts/cutscene/outro/script_MinishEzloOutro.inc +++ b/data/scripts/cutscene/outro/script_MinishEzloOutro.inc @@ -10,20 +10,20 @@ SCRIPT_START script_MinishEzloOutro WaitForSyncFlagAndClear 0x00000002 SetAnimation 0x000e DoPostScriptAction 0x0007 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0004 SetSyncFlag 0x00000040 WaitForSyncFlagAndClear 0x00000002 SetAnimation 0x000c - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000040 WaitForSyncFlagAndClear 0x00000002 SetAnimation 0x000f - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000040 WaitForSyncFlagAndClear 0x00000002 SetAnimation 0x000c - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000040 WaitForSyncFlagAndClear 0x00000002 CallWithArg sub_080960C4, script_EzloZeldaMagic diff --git a/data/scripts/cutscene/reveal/script_PlayerFaintAgain.inc b/data/scripts/cutscene/reveal/script_PlayerFaintAgain.inc index 6593d60f..460b706c 100644 --- a/data/scripts/cutscene/reveal/script_PlayerFaintAgain.inc +++ b/data/scripts/cutscene/reveal/script_PlayerFaintAgain.inc @@ -1,9 +1,9 @@ @ Sanctuary Player faint from Vaati attack SCRIPT_START script_PlayerFaintAgain Call sub_0807F1C4 - Call WaitForFrameHiBit + Call WaitForAnimDone Call sub_0807F1E8 - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000002 WaitForSyncFlagAndClear 0x00000004 PlaySound SFX_PLY_JUMP diff --git a/data/scripts/cutscene/takeover/script_VaatiTakeover.inc b/data/scripts/cutscene/takeover/script_VaatiTakeover.inc index efd31a2b..1a2520c3 100644 --- a/data/scripts/cutscene/takeover/script_VaatiTakeover.inc +++ b/data/scripts/cutscene/takeover/script_VaatiTakeover.inc @@ -14,7 +14,7 @@ SCRIPT_START script_VaatiTakeover Wait 0x0014 SetAnimationState 0x0000 DoPostScriptAction 0x001c - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0000 SetSyncFlag 0x00000020 WaitForSyncFlagAndClear 0x00000010 diff --git a/data/scripts/dhc/script_Vaati1Intro.inc b/data/scripts/dhc/script_Vaati1Intro.inc index 3255d880..0308aab2 100644 --- a/data/scripts/dhc/script_Vaati1Intro.inc +++ b/data/scripts/dhc/script_Vaati1Intro.inc @@ -25,7 +25,7 @@ SCRIPT_START script_Vaati1Intro PlayBgm BGM_VAATI_REBORN DoPostScriptAction 0x0019 PlaySound SFX_198 - Call WaitForFrameHiBit + Call WaitForAnimDone SetRoomFlag 0x0000 DoPostScriptAction 0x0008 Wait 0x0080 diff --git a/data/scripts/dhc/script_VaatiWithZelda.inc b/data/scripts/dhc/script_VaatiWithZelda.inc index 1464b9a8..55897c74 100644 --- a/data/scripts/dhc/script_VaatiWithZelda.inc +++ b/data/scripts/dhc/script_VaatiWithZelda.inc @@ -11,7 +11,7 @@ SCRIPT_START script_VaatiWithZelda Wait 0x003c SetAnimationState 0x0004 DoPostScriptAction 0x001c - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0000 Wait 0x003c SetSyncFlag 0x00000002 diff --git a/data/scripts/dhc/script_ZeldaAfterDefeatingV2.inc b/data/scripts/dhc/script_ZeldaAfterDefeatingV2.inc index 8c2d1161..bad68ee4 100644 --- a/data/scripts/dhc/script_ZeldaAfterDefeatingV2.inc +++ b/data/scripts/dhc/script_ZeldaAfterDefeatingV2.inc @@ -18,7 +18,7 @@ script_0800DCD0: StopBgm Call sub_08066E50 PlaySound SFX_1C9 - Call WaitForFrameHiBit + Call WaitForAnimDone PlaySound SFX_1CA Wait 0x003c DoPostScriptAction 0x0004 diff --git a/data/scripts/hyruleTown/script_Librari.inc b/data/scripts/hyruleTown/script_Librari.inc index 759b102e..7f456a0e 100644 --- a/data/scripts/hyruleTown/script_Librari.inc +++ b/data/scripts/hyruleTown/script_Librari.inc @@ -10,7 +10,7 @@ script_0800E974: JumpIfNot script_0800E974 SetPlayerIdle SetAnimation 0x0008 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x0009 Call sub_0806B260 JumpIfNot script_0800E9E4 diff --git a/data/scripts/hyruleTown/script_LibrariLater.inc b/data/scripts/hyruleTown/script_LibrariLater.inc index cc4fda75..5b97f721 100644 --- a/data/scripts/hyruleTown/script_LibrariLater.inc +++ b/data/scripts/hyruleTown/script_LibrariLater.inc @@ -10,7 +10,7 @@ script_08012440: JumpIfNot script_08012440 SetPlayerIdle SetAnimation 0x0008 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x0009 Call sub_0806B2B4 WaitUntilTextboxCloses diff --git a/data/scripts/hyruleTown/script_LibrarianLeft.inc b/data/scripts/hyruleTown/script_LibrarianLeft.inc index 2cda1ba0..bed65448 100644 --- a/data/scripts/hyruleTown/script_LibrarianLeft.inc +++ b/data/scripts/hyruleTown/script_LibrarianLeft.inc @@ -10,7 +10,7 @@ script_08008BA2: TriggerInteract SetPlayerIdle SetAnimation 0x0004 - Call WaitForFrameHiBit + Call WaitForAnimDone MessageFromTarget 0x4912 WaitUntilTextboxCloses SetAnimation 0x0008 diff --git a/data/scripts/hyruleTown/script_LibrarianLeftWithQuest.inc b/data/scripts/hyruleTown/script_LibrarianLeftWithQuest.inc index 6fbcd584..a6f0efee 100644 --- a/data/scripts/hyruleTown/script_LibrarianLeftWithQuest.inc +++ b/data/scripts/hyruleTown/script_LibrarianLeftWithQuest.inc @@ -16,13 +16,13 @@ script_08008BD2: SetGlobalFlag 0x0061 .endif SetAnimation 0x0004 - Call WaitForFrameHiBit + Call WaitForAnimDone WaitUntilTextboxCloses Call sub_0806BA34 JumpIfNot script_08008C54 WaitUntilTextboxCloses CallWithArg sub_0806BB1C, 0x00000000 - Call WaitForFrameHiBit + Call WaitForAnimDone CallWithArg sub_0806BB1C, 0x00000001 Call sub_0806BB7C JumpIfNot script_08008C5C @@ -34,11 +34,11 @@ script_08008BD2: Wait 0x000f PlaySound SFX_SECRET SetAnimation 0x0004 - Call WaitForFrameHiBit + Call WaitForAnimDone MessageNoOverlap 0x4913 WaitUntilTextboxCloses SetAnimation 0x0008 - Call WaitForFrameHiBit + Call WaitForAnimDone Jump script_08008C5C script_08008C54: SetAnimation 0x0008 diff --git a/data/scripts/hyruleTown/script_LibrarianRight.inc b/data/scripts/hyruleTown/script_LibrarianRight.inc index df64ef65..2945aaf2 100644 --- a/data/scripts/hyruleTown/script_LibrarianRight.inc +++ b/data/scripts/hyruleTown/script_LibrarianRight.inc @@ -10,7 +10,7 @@ script_08008B6E: TriggerInteract SetPlayerIdle SetAnimation 0x0004 - Call WaitForFrameHiBit + Call WaitForAnimDone Call sub_0806BBB0 WaitUntilTextboxCloses SetAnimation 0x0008 diff --git a/data/scripts/hyruleTown/script_Mayor.inc b/data/scripts/hyruleTown/script_Mayor.inc index 83a6c6a5..1761b2cf 100644 --- a/data/scripts/hyruleTown/script_Mayor.inc +++ b/data/scripts/hyruleTown/script_Mayor.inc @@ -12,12 +12,12 @@ script_0800EA6A: SetPlayerIdle FacePlayer CallWithArg sub_0807F3D8, 0x00000004 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x0009 Call sub_0806CE80 WaitUntilTextboxCloses EnablePlayerControl SetAnimation 0x000a - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x0008 Jump script_0800EA6A diff --git a/data/scripts/hyruleTown/script_Pita.inc b/data/scripts/hyruleTown/script_Pita.inc index 5732755d..4c554ae1 100644 --- a/data/scripts/hyruleTown/script_Pita.inc +++ b/data/scripts/hyruleTown/script_Pita.inc @@ -11,7 +11,7 @@ script_080106BE: JumpIfNot script_080106BE SetPlayerIdle FacePlayer - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0000 HasRoomItemForSale JumpIf script_080106E0 diff --git a/data/scripts/hyruleTown/script_Stamp.inc b/data/scripts/hyruleTown/script_Stamp.inc index c478adeb..1b70e3de 100644 --- a/data/scripts/hyruleTown/script_Stamp.inc +++ b/data/scripts/hyruleTown/script_Stamp.inc @@ -11,7 +11,7 @@ script_080107AA: CheckEntityInteractType JumpIfNot script_080107AA SetPlayerIdle - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0001 Call sub_08062CBC WaitUntilTextboxCloses diff --git a/data/scripts/npc/script_BladeBrothers.inc b/data/scripts/npc/script_BladeBrothers.inc index e42d8c46..8dbcf6d5 100644 --- a/data/scripts/npc/script_BladeBrothers.inc +++ b/data/scripts/npc/script_BladeBrothers.inc @@ -36,7 +36,7 @@ script_08016262: Call sub_08068E00 WaitUntilTextboxCloses DoPostScriptAction 0x0001 - Call WaitForFrameHiBit + Call WaitForAnimDone Call sub_08068E90 Call sub_08068C8C JumpIf script_0801631C diff --git a/data/scripts/npc/script_Farmer.inc b/data/scripts/npc/script_Farmer.inc index a03617d1..2aa74c78 100644 --- a/data/scripts/npc/script_Farmer.inc +++ b/data/scripts/npc/script_Farmer.inc @@ -11,7 +11,7 @@ script_0800B0E8: script_0800B0F6: SetPlayerIdle Call sub_0807DF28 - Call WaitForFrameHiBit + Call WaitForAnimDone FacePlayer CallWithArg sub_0806BC94, 0x00000004 Call sub_0806BCE8 @@ -24,7 +24,7 @@ script_0800B0F6: script_0800B134: SetPlayerIdle Call sub_0807DF28 - Call WaitForFrameHiBit + Call WaitForAnimDone FacePlayer CallWithArg sub_0806BC94, 0x00000004 Call sub_0807F650 diff --git a/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc b/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc index 3e97485d..509c2f48 100644 --- a/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc +++ b/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc @@ -85,9 +85,9 @@ script_080138D0: .endif Call NPC4E_SaveEquippedItems CallWithArg EquipItem, 0x00010001 - CallWithArg sub_0807F29C, gUnk_080049FE + CallWithArg SetInputMacro, gUnk_080049FE Wait 0x00c8 - CallWithArg sub_0807F29C, 0x00000000 + CallWithArg SetInputMacro, 0x00000000 Call NPC4E_RestoreEquippedItems script_08013A8E: .ifndef EU diff --git a/data/scripts/sanctuary/script_Object6ASword2.inc b/data/scripts/sanctuary/script_Object6ASword2.inc index 2acab4f5..8723ac1a 100644 --- a/data/scripts/sanctuary/script_Object6ASword2.inc +++ b/data/scripts/sanctuary/script_Object6ASword2.inc @@ -6,7 +6,7 @@ SCRIPT_START script_Object6ASword2 EndBlock WaitForSyncFlagAndClear 0x00000080 SetAnimation 0x000c - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000080 DoPostScriptAction 0x0006 diff --git a/data/scripts/sanctuary/script_Object6ASword3.inc b/data/scripts/sanctuary/script_Object6ASword3.inc index 38b36455..1cd22b94 100644 --- a/data/scripts/sanctuary/script_Object6ASword3.inc +++ b/data/scripts/sanctuary/script_Object6ASword3.inc @@ -6,7 +6,7 @@ SCRIPT_START script_Object6ASword3 EndBlock WaitForSyncFlagAndClear 0x00000080 SetAnimation 0x000d - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000080 DoPostScriptAction 0x0006 diff --git a/data/scripts/sanctuary/script_Object6ASwordCharge10.inc b/data/scripts/sanctuary/script_Object6ASwordCharge10.inc index 000d1c95..31fd102a 100644 --- a/data/scripts/sanctuary/script_Object6ASwordCharge10.inc +++ b/data/scripts/sanctuary/script_Object6ASwordCharge10.inc @@ -9,6 +9,6 @@ SCRIPT_START script_Object6ASwordCharge10 EndBlock WaitForSyncFlag 0x00000020 Wait 0x0078 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END diff --git a/data/scripts/sanctuary/script_Object6ASwordCharge5.inc b/data/scripts/sanctuary/script_Object6ASwordCharge5.inc index 3b06636f..8dc55e5f 100644 --- a/data/scripts/sanctuary/script_Object6ASwordCharge5.inc +++ b/data/scripts/sanctuary/script_Object6ASwordCharge5.inc @@ -6,11 +6,11 @@ SCRIPT_START script_Object6ASwordCharge5 EndBlock WaitForSyncFlagAndClear 0x00000200 SetAnimation 0x0008 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x000c SetSyncFlag 0x00002000 WaitForSyncFlag 0x00000020 SetAnimation 0x0010 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END diff --git a/data/scripts/sanctuary/script_Object6ASwordCharge6.inc b/data/scripts/sanctuary/script_Object6ASwordCharge6.inc index 0fccc71d..1a080034 100644 --- a/data/scripts/sanctuary/script_Object6ASwordCharge6.inc +++ b/data/scripts/sanctuary/script_Object6ASwordCharge6.inc @@ -6,11 +6,11 @@ SCRIPT_START script_Object6ASwordCharge6 EndBlock WaitForSyncFlagAndClear 0x00000400 SetAnimation 0x0009 - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x000d SetSyncFlag 0x00004000 WaitForSyncFlag 0x00000020 SetAnimation 0x0011 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END diff --git a/data/scripts/sanctuary/script_Object6ASwordCharge8.inc b/data/scripts/sanctuary/script_Object6ASwordCharge8.inc index 9120d4b9..d86e5dce 100644 --- a/data/scripts/sanctuary/script_Object6ASwordCharge8.inc +++ b/data/scripts/sanctuary/script_Object6ASwordCharge8.inc @@ -7,12 +7,12 @@ SCRIPT_START script_Object6ASwordCharge8 EndBlock WaitForSyncFlagAndClear 0x00001000 SetAnimation 0x000b - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x000f SetSyncFlag 0x00010000 WaitForSyncFlag 0x00000020 SetAnimation 0x0013 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END .2byte 0x0000 diff --git a/data/scripts/sanctuary/script_Object6ASwordCharge9.inc b/data/scripts/sanctuary/script_Object6ASwordCharge9.inc index 637466b7..7b1b20c0 100644 --- a/data/scripts/sanctuary/script_Object6ASwordCharge9.inc +++ b/data/scripts/sanctuary/script_Object6ASwordCharge9.inc @@ -8,7 +8,7 @@ SCRIPT_START script_Object6ASwordCharge9 EndBlock WaitForSyncFlag 0x00000020 Wait 0x0078 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END .2byte 0x0000 diff --git a/data/scripts/sanctuary/script_Object6ASwordInPedestal.inc b/data/scripts/sanctuary/script_Object6ASwordInPedestal.inc index 2584cb86..b2096d46 100644 --- a/data/scripts/sanctuary/script_Object6ASwordInPedestal.inc +++ b/data/scripts/sanctuary/script_Object6ASwordInPedestal.inc @@ -6,7 +6,7 @@ SCRIPT_START script_Object6ASwordInPedestal EndBlock WaitForSyncFlagAndClear 0x00000080 SetAnimation 0x000b - Call WaitForFrameHiBit + Call WaitForAnimDone SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000080 DoPostScriptAction 0x0006 diff --git a/data/scripts/sanctuary/script_Objet6ASwordCharge7.inc b/data/scripts/sanctuary/script_Objet6ASwordCharge7.inc index 30ab72f0..ab1e6db4 100644 --- a/data/scripts/sanctuary/script_Objet6ASwordCharge7.inc +++ b/data/scripts/sanctuary/script_Objet6ASwordCharge7.inc @@ -7,12 +7,12 @@ SCRIPT_START script_Objet6ASwordCharge7 EndBlock WaitForSyncFlagAndClear 0x00000800 SetAnimation 0x000a - Call WaitForFrameHiBit + Call WaitForAnimDone SetAnimation 0x000e SetSyncFlag 0x00008000 WaitForSyncFlag 0x00000020 SetAnimation 0x0012 - Call WaitForFrameHiBit + Call WaitForAnimDone DoPostScriptAction 0x0006 SCRIPT_END .2byte 0x0000 diff --git a/genctx.sh b/genctx.sh new file mode 100644 index 00000000..f9fd2a23 --- /dev/null +++ b/genctx.sh @@ -0,0 +1,38 @@ +headers="" +num=0 + +recurse_dir() { + for file in `ls $1` + do + if [ -d $1/$file ] + then + recurse_dir $1/$file + else + if [ -f $1/$file ] + then + if [ ${file##*.} = "h" ] + then + # make a copy of the path but without ./ + p=${1#./} + #if path begins with / then remove it + p=${p#/} + # if path isnt empty add / + if [ -n "$p" ] + then + p="$p/" + fi + headers+="#include \"$p$file\"\n" + num=$(( $num + 1 )) + fi + fi + fi + done +} + +cd include +recurse_dir ./ +cd .. + +echo "#include \"gba/types.h\"\n$headers" | cc -E -nostdinc -Iinclude -Itools/agbcc/include - > ctx.c +echo "$headers" +echo "$num headers, written to ctx.c" diff --git a/include/coord.h b/include/coord.h index 31453184..b8af7117 100644 --- a/include/coord.h +++ b/include/coord.h @@ -7,13 +7,16 @@ s16 FixedMul(s16 r0, s16 r1); s16 FixedDiv(s16 r0, s16 r1); +void* AllocMutableHitbox(Entity*); +void UnloadHitbox(Entity*); + void CopyPosition(Entity*, Entity*); void PositionEntityOnTop(Entity*, Entity*); void PositionRelative(Entity*, Entity*, s32, s32); void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2); void sub_0806FA90(Entity*, Entity*, s32, s32); -void SortEntityAbove(Entity*, Entity*); -void SortEntityBelow(Entity*, Entity*); +void SortEntityAbove(Entity* below_ent, Entity* above_ent); +void SortEntityBelow(Entity* above_ent, Entity* below_ent); u32 sub_0806F5A4(u32 idx); bool32 sub_0806F3E4(Entity*); diff --git a/include/entity.h b/include/entity.h index 4b25be09..4f2cc3ca 100644 --- a/include/entity.h +++ b/include/entity.h @@ -106,7 +106,7 @@ typedef struct { } Hitbox3D; typedef struct { - u8 b0 : 3; // 1-4 + u8 b0 : 3; // 1-4 /**< set to is 4 in entity init (default/lowest?) u8 b1 : 3; // 8 u8 b2 : 1; // 0x40 u8 b3 : 1; // 0x80 @@ -504,6 +504,8 @@ extern u8 gManagerCount; #define COLLISION_OFF(entity) ((entity)->flags &= ~ENT_COLLIDE) #define COLLISION_ON(entity) ((entity)->flags |= ENT_COLLIDE) +#define ANIM_DONE (1 << 7) /* invalid frame index */ + /** @name Tile Macros */ /// @{ #define TILE(x, y) (((((x)-gRoomControls.origin_x) >> 4) & 0x3F) | ((((y)-gRoomControls.origin_y) >> 4) & 0x3F) << 6) #define TILE_POS(x, y) (x + (y << 6)) @@ -512,7 +514,8 @@ extern u8 gManagerCount; /// @} /** @name Animation State Macros */ ///@{ -#define AnimationStateTurnAround(expr) ((expr) ^ 0x4) +#define AnimationStateFlip90(expr) ((expr) ^ 0x2) +#define AnimationStateFlip180(expr) ((expr) ^ 0x4) #define AnimationStateIdle(expr) ((expr)&0x6) #define AnimationStateWalk(expr) ((expr)&0xe) ///@} diff --git a/include/functions.h b/include/functions.h index b4e79f4d..daa1e0f7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -24,7 +24,7 @@ extern void CreateItemOnGround(Entity*); extern Entity* CreateLargeWaterTrace(Entity*); extern void CreateMagicSparkles(u32, u32, u32); extern void CreateMinishEntrance(u32 tile); -extern Entity* CreatePlayerBomb(ItemBehavior*, u32); +extern Entity* CreatePlayerItemWithParent(ItemBehavior*, u32); extern u32 CreateRandomItemDrop(Entity*, u32); extern void CreateSparkle(Entity*); extern void DoPlayerAction(Entity*); @@ -85,7 +85,7 @@ extern void sub_08000148(u32, u32, u32); extern u32 sub_080B1A0C(Entity*, s32, s32); extern u32 sub_080B1A48(u32, u32, u32); extern u32 sub_080B1A8C(Entity*, u32, u32); -extern u32 sub_080B1AA8(Entity*); +extern u32 GetTileUnderEntity(Entity*); extern u32 sub_080B1AE0(u16, u8); extern u32 sub_080B1AF0(Entity*, s32, s32); extern u32 sub_080B1B18(s32, s32, u32); @@ -152,8 +152,8 @@ extern void sub_08059278(void); extern void sub_0805B4D0(u32); extern void sub_0805BC4C(void); extern void sub_0805EC60(Entity*); -extern void sub_0805EC9C(Entity*, u32, u32, u32); -extern void sub_0805ED14(u32*); +extern void SetAffineInfo(Entity*, u32, u32, u32); +extern void InitPlayerMacro(u32*); extern u32* sub_0805F25C(u32); extern u32 sub_0805F7A0(u32); extern void sub_0805F8E4(u32 r0, WStruct* r1); @@ -182,7 +182,7 @@ extern void sub_08077D38(ItemBehavior*, u32); extern void sub_08077DF4(ItemBehavior*, u32); extern void sub_08077E3C(ItemBehavior*, u32); extern void sub_08077E54(ItemBehavior*); -extern void sub_08077E78(ItemBehavior*, u32); +extern void DeletePlayerItem(ItemBehavior*, u32); extern bool32 sub_08077EC8(ItemBehavior*); extern bool32 sub_08077EFC(ItemBehavior*); extern bool32 sub_08077F10(ItemBehavior*); @@ -198,8 +198,8 @@ extern void sub_08078850(Entity*, u32, u32, void*); extern s32 sub_0807887C(Entity*, u32, u32); extern void sub_080788E0(Entity*); extern s32 sub_08078904(); -extern void sub_08078930(Entity*); -extern void sub_08078954(Entity*); +extern void RegisterCarryEntity(Entity*); +extern void FreeCarryEntity(Entity*); extern void sub_08078AC0(u32, u32, u32); extern void sub_08078B48(void); extern void sub_08078E84(Entity*, Entity*); diff --git a/include/player.h b/include/player.h index ba4d4de6..0776c0a5 100644 --- a/include/player.h +++ b/include/player.h @@ -109,7 +109,7 @@ enum PlayerFlags { PL_FROZEN = 0x800, PL_IN_MINECART = 0x1000, PL_DRUGGED = 0x4000, - PL_FLAGS8000 = 0x8000, + PL_PIT_IS_EXIT = 0x8000, PL_FLAGS10000 = 0x10000, PL_FLAGS20000 = 0x20000, PL_ROLLING = 0x40000, @@ -204,7 +204,7 @@ typedef struct { /*0x02*/ u8 jump_status; /*0x03*/ u8 field_0x3[2]; /*0x05*/ u8 heldObject; - /*0x06*/ u8 pushedObject; + /*0x06*/ u8 pushedObject; // hi bit is special, rest is used as a timer /*0x07*/ u8 field_0x7; /*0x08*/ u16 animation; /*0x0a*/ u8 field_0xa; @@ -224,7 +224,7 @@ typedef struct { /*0x1a*/ u8 mobility; /*0x1b*/ u8 sword_state; /*0x1c*/ u8 field_0x1c; - /*0x1d*/ u8 field_0x1d; + /*0x1d*/ u8 gustJarSpeed; /*0x1e*/ u8 dash_state; /*0x1f*/ u8 field_0x1f[3]; /*0x22*/ u16 field_0x22[2]; diff --git a/include/room.h b/include/room.h index 43ac8f40..5f71a07d 100644 --- a/include/room.h +++ b/include/room.h @@ -128,7 +128,7 @@ typedef struct { /* 0x12 */ u16 dungeon_map_y; /* 0x14 */ u16 overworld_map_x; /* 0x16 */ u16 overworld_map_y; - /* 0x18 */ u8 field_0x24[0x8]; + /* 0x18 */ u8 field_0x24[8]; } PlayerRoomStatus; static_assert(sizeof(PlayerRoomStatus) == 0x20); @@ -140,7 +140,8 @@ typedef struct { /* 0x09 */ u8 type; // transition when changing areas /* 0x0a */ u16 stairs_idx; // seems to be a tile type /* 0x0c */ PlayerRoomStatus player_status; - /* 0x2c */ u8 field_0x2c[0x9]; + /* 0x2c */ u8 entity_update_type; // differentiates entity priority on kinstone menu? + /* 0x2d */ u8 field_0x2c[0x8]; /* 0x35 */ u8 hint_height; /* 0x36 */ u16 hint_idx; /* 0x38 */ u8 field_0x38; diff --git a/linker.ld b/linker.ld index b75881c9..3dabfcb2 100644 --- a/linker.ld +++ b/linker.ld @@ -136,7 +136,7 @@ SECTIONS { . = 0x00035542; gUnk_02035542 = .; . = 0x00036540; gUnk_02036540 = .; . = 0x00036570; gScriptExecutionContextArray = .; - . = 0x000369F0; gUnk_020369F0 = .; + . = 0x000369F0; gEntityListsBackup = .; . = 0x00036A38; gCurrentWindow = .; . = 0x00036A40; gNewWindow = .; #if defined(DEMO_USA) || defined(DEMO_JP) @@ -177,7 +177,7 @@ SECTIONS { . = 0x00001160; gPlayerEntity = .; . = 0x000011E8; gUnk_030011E8 = .; . = 0x000015A0; gUnk_030015A0 = .; - . = 0x00003BE0; gUnk_03003BE0 = .; + . = 0x00003BE0; gCarryEntities = .; . = 0x00003C70; gUnk_03003C70 = .; . = 0x00003D70; gEntityLists = .; . = 0x00003DB8; gCollidableCount = .; @@ -213,7 +213,7 @@ SECTIONS { . = 0x000057CC; ram_sub_080B1A58 = .; . = 0x000057D4; ram_GetTileType = .; . = 0x00005800; ram_sub_080B1A8C = .; - . = 0x0000581C; ram_sub_080B1AA8 = .; + . = 0x0000581C; ram_GetTileUnderEntity = .; . = 0x00005828; ram_sub_080B1AB4 = .; . = 0x0000583C; ram_sub_080B1AC8 = .; . = 0x0000584C; ram_sub_080B1AD8 = .; @@ -274,6 +274,9 @@ SECTIONS { /* handwritten assembly */ asm/src/crt0.o(.text); +#if defined(EU) || defined(DEMO_JP) + asm/src/stack_check.o(.text); +#endif asm/src/veneer.o(.text); data/data_08000360.o(.rodata); asm/src/code_08000E44.o(.text); diff --git a/src/affine.c b/src/affine.c index f0e2549b..00ee3c32 100644 --- a/src/affine.c +++ b/src/affine.c @@ -55,7 +55,7 @@ void CopyOAM(void) { void DrawEntities(void) { void (*fn)(void); - gOAMControls._0[6] = gRoomTransition.field_0x2c[3] ? 15 : 0; + gOAMControls._0[6] = gRoomTransition.field_0x2c[2] ? 15 : 0; gOAMControls._4 = gRoomControls.aff_x + gRoomControls.scroll_x; gOAMControls._6 = gRoomControls.aff_y + gRoomControls.scroll_y; gOAMControls.field_0x1++; diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c index 37996780..42f1403a 100644 --- a/src/code_0805EC04.c +++ b/src/code_0805EC04.c @@ -32,7 +32,7 @@ void sub_0805EC60(Entity* this) { } } -ASM_FUNC("asm/non_matching/sub_0805EC9C.inc", bool32 sub_0805EC9C(Entity* ent, u32 param_2, u32 param_3, u32 param_4)) +ASM_FUNC("asm/non_matching/SetAffineInfo.inc", bool32 SetAffineInfo(Entity* ent, u32 param_2, u32 param_3, u32 param_4)) void sub_0805ECEC(int param_1, u32 param_2, u32 param_3, u32 param_4) { u16* temp; @@ -45,46 +45,46 @@ void sub_0805ECEC(int param_1, u32 param_2, u32 param_3, u32 param_4) { temp[2] = param_4; } -void sub_0805ED14(u32 param_1) { +void InitPlayerMacro(u32 param_1) { gPlayerState.field_0x9c = param_1; gPlayerState.field_0x98 = 0; gPlayerState.field_0x9a = 0; } -ASM_FUNC("asm/non_matching/code_0805EC04/sub_0805ED30.inc", void sub_0805ED30()) +ASM_FUNC("asm/non_matching/code_0805EC04/UpdatePlayerInput.inc", void UpdatePlayerInput()) -u32 sub_0805EE04(u32 param_1) { - u32 result = (s32) - (param_1 & 0x200) >> 0x1f & 0x1000; - if ((param_1 & 0x100) != 0) { +u32 ConvInputToState(u32 keys) { + u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000; + if (keys & R_BUTTON) { result |= 0x20; result |= 0x8000; result |= 0x80; } - if ((param_1 & 1) != 0) { + if (keys & A_BUTTON) { result |= 0x8; result |= 0x41; } - if ((param_1 & 2) != 0) { + if (keys & B_BUTTON) { result |= 0x10; result |= 0x2; } - if ((param_1 & 0x10) != 0) { + if (keys & DPAD_RIGHT) { result |= 0x100; } - if ((param_1 & 0x20) != 0) { + if (keys & DPAD_LEFT) { result |= 0x200; } - if ((param_1 & 0x40) != 0) { + if (keys & DPAD_UP) { result |= 0x400; } - if ((param_1 & 0x80) != 0) { + if (keys & DPAD_DOWN) { result |= 0x800; } return result; } void sub_0805EE88(void) { - if ((gRoomTransition.field_0x2c[3] != 0) && ((gRoomTransition.frameCount & 3) == 0)) { + if ((gRoomTransition.field_0x2c[2] != 0) && ((gRoomTransition.frameCount & 3) == 0)) { LoadPaletteGroup((((u32)gRoomTransition.frameCount & 0xc) >> 2) + 0x2f); } } diff --git a/src/collision.c b/src/collision.c index 9832b61c..52bd8d27 100644 --- a/src/collision.c +++ b/src/collision.c @@ -370,7 +370,7 @@ s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { if ((tgt->field_0x3a & 4) != 0) { if (tgt->field_0x1d) { - s32 x = tgt->field_0x1d = tgt->field_0x1d - gPlayerState.field_0x1d; + s32 x = tgt->field_0x1d = tgt->field_0x1d - gPlayerState.gustJarSpeed; if (x << 24 <= 0) { tgt->field_0x1d = 0; tgt->subAction = 2; diff --git a/src/color.c b/src/color.c index 6e243a88..301e5613 100644 --- a/src/color.c +++ b/src/color.c @@ -47,7 +47,7 @@ void sub_0801D000(u32 a1) { tmp = 0; } - roomTransition->field_0x2c[3] = tmp; + roomTransition->field_0x2c[2] = tmp; if (a1) { CleanUpObjPalettes(); sub_0801CFD0(0xf); diff --git a/src/coord.c b/src/coord.c index 61cfb199..629f700a 100644 --- a/src/coord.c +++ b/src/coord.c @@ -20,7 +20,6 @@ extern const u16 gUnk_080047F6[]; u32 sub_0806F58C(Entity*, Entity*); u32 sub_0806FCA0(Entity*, Entity*); -void UnloadHitbox(Entity*); extern u32 sub_08007DD6(u32, const u16*); u32 PointInsideRadius(s32 x, s32 y, s32 radius); extern void sub_0806FEE8(struct_gUnk_020000C0_1*, u32, u32, u32); @@ -61,7 +60,7 @@ bool32 sub_0806F3E4(Entity* ent) { if ((gPlayerState.field_0x1c & 0x7F) != 1) return 0; - switch (gPlayerState.field_0x1d) { + switch (gPlayerState.gustJarSpeed) { case 1: ent->knockbackSpeed += 64; break; @@ -329,12 +328,12 @@ void sub_0806FA90(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { PositionRelative(source, target, Q_16_16(offsetX), Q_16_16(offsetY)); } -void SortEntityAbove(Entity* param_1, Entity* param_2) { - param_2->spritePriority.b0 = gSpriteSortAboveTable[param_1->spritePriority.b0]; +void SortEntityAbove(Entity* below_ent, Entity* above_ent) { + above_ent->spritePriority.b0 = gSpriteSortAboveTable[below_ent->spritePriority.b0]; } -void SortEntityBelow(Entity* param_1, Entity* param_2) { - param_2->spritePriority.b0 = gSpriteSortBelowTable[param_1->spritePriority.b0]; +void SortEntityBelow(Entity* above_ent, Entity* below_ent) { + below_ent->spritePriority.b0 = gSpriteSortBelowTable[above_ent->spritePriority.b0]; } void sub_0806FB00(Entity* ent, u32 param_1, u32 param_2, u32 param_3) { @@ -380,9 +379,10 @@ void sub_0806FBB4(Entity* ent) { } } -void AllocMutableHitbox(Entity* ent) { +void* AllocMutableHitbox(Entity* ent) { UnloadHitbox(ent); ent->hitbox = zMalloc(sizeof(Hitbox3D)); + return ent->hitbox; } void UnloadHitbox(Entity* ent) { @@ -538,7 +538,7 @@ u32 LoadExtraSpriteData(Entity* ent, const SpriteLoadData* data) { return 1; } -void sub_0806FE84(Entity* ent) { +void UnloadOBJPalette2(Entity* ent) { u32 index; u32 spriteAnimation = ent->spriteAnimation[2]; ent->spriteAnimation[2] = 0; diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 0edf6d34..34d0ea7c 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -155,7 +155,7 @@ void sub_08031B48(Entity* this) { this->frame = 0; COLLISION_ON(this); } else { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 0x3; this->actionDelay = gUnk_080CE5B0[Random() & 7]; InitializeAnimation(this, 1); @@ -188,7 +188,7 @@ void sub_08031B98(Entity* this) { void sub_08031C1C(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = '\x01'; this->actionDelay = gUnk_080CE5B8[Random() & 7]; this->spriteSettings.draw = 0; @@ -199,7 +199,7 @@ void sub_08031C58(Entity* this) { Entity *a, *b; GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (gEntCount < 0x43) { u32 tmp = Random(); tmp &= 3; @@ -274,7 +274,7 @@ void sub_08031DA0(Entity* this) { } void sub_08031DC4(Entity* this) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->actionDelay = 0xb4; this->spriteSettings.draw = 0; @@ -360,7 +360,7 @@ void sub_08031F54(Entity* this) { void sub_08031FB0(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) && (this->parent || --this->actionDelay == 0)) { + if ((this->frame & ANIM_DONE) && (this->parent || --this->actionDelay == 0)) { this->action = 4; this->direction = sub_08049F84(this, 1); *(u8*)&this->field_0x76 = 0; @@ -469,7 +469,7 @@ void sub_08032204(Entity* this) { this->frame = 0; this->frameDuration = (Random() & 0x30) + 30; } else { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 9; InitializeAnimation(this, 13); } @@ -478,7 +478,7 @@ void sub_08032204(Entity* this) { void sub_08032248(Entity* this) { if (GravityUpdate(this, Q_8_8(24.0)) == 0) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { ((Entity*)this->field_0x7c.WORD)->actionDelay--; DeleteEntity(this); diff --git a/src/enemy/armos.c b/src/enemy/armos.c index 829e195d..0fd596a2 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -113,7 +113,7 @@ void sub_080301D4(ArmosEntity* this) { void sub_08030240(ArmosEntity* this) { if (super->animIndex == 6) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { GetNextFrame(super); } } @@ -188,8 +188,8 @@ void sub_08030338(ArmosEntity* this) { EnqueueSFX(SFX_12A); return; } - bVar2 = super->frame & 0x80; - if ((super->frame & 0x80) != 0) { + bVar2 = super->frame & ANIM_DONE; + if ((super->frame & ANIM_DONE) != 0) { if (this->unk_80 != 2) { super->action = 3; super->animationState = 0xff; @@ -244,7 +244,7 @@ NONMATCH("asm/non_matching/armos/sub_080304BC.inc", void sub_080304BC(ArmosEntit u32 tmp; sub_080309A8(this); - tmp = super->frame & 0x80; + tmp = super->frame & ANIM_DONE; if (tmp != 0) { sub_08030580(this); } else { @@ -267,7 +267,7 @@ void sub_080304F4(ArmosEntity* this) { } void sub_08030524(ArmosEntity* this) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { sub_080309A8(this); } else if (super->frame == 1) { super->frame = 0; @@ -277,7 +277,7 @@ void sub_08030524(ArmosEntity* this) { void sub_08030554(ArmosEntity* this) { sub_080309A8(this); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 3; sub_080309C8(this, (u32)super->animationState); sub_080306C4(this); diff --git a/src/enemy/ballChainSoldier.c b/src/enemy/ballChainSoldier.c index f29df68c..9e1ef699 100644 --- a/src/enemy/ballChainSoldier.c +++ b/src/enemy/ballChainSoldier.c @@ -150,7 +150,7 @@ void sub_0803E71C(BallChainSoldierEntity* this) { } void sub_0803E75C(BallChainSoldierEntity* this) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { UpdateAnimationSingleFrame(super); } else { if (--super->actionDelay == 0) { diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 207cf1c7..25e104c8 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -117,7 +117,7 @@ void sub_080218CC(Entity* this) { this->frameDuration = 1; } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->actionDelay = (Random() & 0x38) + 8; this->field_0xf = 1; @@ -209,7 +209,7 @@ void sub_08021AD8(Entity* this) { this->frameDuration = 1; } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->actionDelay = 20; ((u8*)&this->field_0x86)[0] = 60; @@ -268,7 +268,7 @@ void sub_08021C58(Entity* this) { this->frameDuration = 1; } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->actionDelay = 60; this->field_0xf = 1; @@ -280,7 +280,7 @@ void sub_08021C58(Entity* this) { } void sub_08021CD0(Entity* this) { - if ((this->frame & 0x80) == 0) + if ((this->frame & ANIM_DONE) == 0) GetNextFrame(this); if (sub_08049F84(this, 1) == 0xff) diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index 42c3d2b1..7e214b63 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -245,7 +245,7 @@ void sub_0802CAF8(Entity* this) { EnqueueSFX(SFX_104); } sub_0802CC18(this); - sub_08078930(this); + RegisterCarryEntity(this); if (this->field_0xf && this->z.HALF.HI == 0) { this->field_0xf = 0; COLLISION_ON(this); @@ -286,7 +286,7 @@ void sub_0802CBC4(Entity* this) { if (this->field_0x82.HALF.HI) { sub_08079184(); } - sub_08078954(this); + FreeCarryEntity(this); ent = CreateObjectWithParent(this, OBJECT_20, 0, 0); if (ent) { diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 5a1a80f3..5c327b91 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -289,7 +289,7 @@ void sub_0802AB40(Entity* this) { #endif void sub_0802AC08(Entity* this) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->subAction = 0; this->actionDelay = 0x40; @@ -470,7 +470,7 @@ void sub_0802AED4(Entity* this) { } } else { if (!sub_0800442E(this)) { - sub_08078930(this); + RegisterCarryEntity(this); } } if (this->type2 != 0 && this->field_0x80.HALF.HI) { @@ -535,7 +535,7 @@ NONMATCH("asm/non_matching/bombPeahat/sub_0802AFC8.inc", void sub_0802AFC8(Entit this->field_0x82.HWORD ^= 0x8000; } tmp = 0x130 - (this->field_0x82.HWORD & 0xf0); - sub_0805EC9C(this, tmp, tmp, 0); + SetAffineInfo(this, tmp, tmp, 0); } if (this->field_0xf & flag) { this->palette.b.b0 = this->palette.b.b4; @@ -572,7 +572,7 @@ void sub_0802B048(Entity* this) { this->field_0xf = 0x50; this->field_0x82.HWORD = 0; this->spriteRendering.b0 = 3; - sub_0805EC9C(this, 0x100, 0x100, 0); + SetAffineInfo(this, 0x100, 0x100, 0); } } else { if (this->field_0xf) { @@ -587,7 +587,7 @@ void sub_0802B048(Entity* this) { this->spriteSettings.draw = 0; COLLISION_ON(this); this->field_0x7a.HALF.HI = 0; - sub_08078954(this); + FreeCarryEntity(this); if (this->parent->next) { this->parent->field_0x80.HALF.HI = 0; } diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 6c71441d..8283894b 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -112,7 +112,7 @@ void sub_08028A74(Entity* this) { switch (this->subAction) { case 0: unk = 1; - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->subAction = 1; this->actionDelay = 0x3c; this->field_0xf = 0x10; @@ -150,7 +150,7 @@ void sub_08028A74(Entity* this) { break; case 3: unk = 2; - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->subAction = 4; this->actionDelay = 0x50; sub_080290E0(this, 1); @@ -189,7 +189,7 @@ void sub_08028BC4(Entity* this) { switch (this->subAction) { case 0: if (this->actionDelay == 0) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->subAction = 1; sub_08028FDC(this); sub_080290E0(this, 5); @@ -200,7 +200,7 @@ void sub_08028BC4(Entity* this) { } break; case 1: - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 4; this->subAction = 0; this->actionDelay = 0x1e; diff --git a/src/enemy/businessScrubPrologue.c b/src/enemy/businessScrubPrologue.c index 036c4e19..f87040f3 100644 --- a/src/enemy/businessScrubPrologue.c +++ b/src/enemy/businessScrubPrologue.c @@ -100,7 +100,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) { switch (super->subAction) { case 0: r6 = 1; - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->subAction = 1; super->actionDelay = 0x3c; super->field_0xf = 0x10; @@ -133,7 +133,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) { break; case 3: r6 = 2; - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->subAction = 4; super->actionDelay = 0x50; sub_08046030(this, 1); @@ -170,7 +170,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) { switch (super->subAction) { case 0: if (super->actionDelay == 0) { - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->subAction = 1; sub_08045F98(this); sub_08046030(this, 5); @@ -181,7 +181,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) { } break; case 1: - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->action = 5; super->subAction = 0; sub_08046030(this, 0); @@ -222,7 +222,7 @@ void sub_08045EDC(BusinessScrubPrologueEntity* this) { super->frame &= 0xfe; sub_080954AC(super, this->unk_84); EnqueueSFX(SFX_18D); - } else if (super->frame & 0x80) { + } else if (super->frame & ANIM_DONE) { super->action = 5; super->subAction = 0; sub_08046030(this, 1); diff --git a/src/enemy/chaser.c b/src/enemy/chaser.c index 16a61b2a..24dca7cf 100644 --- a/src/enemy/chaser.c +++ b/src/enemy/chaser.c @@ -64,7 +64,7 @@ void sub_0802B56C(Entity* this) { void sub_0802B5C8(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->actionDelay = 30; InitializeAnimation(this, 0); diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 8521f64b..9f23dd3b 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -155,7 +155,7 @@ void Chuchu_OnDeath(Entity* this) { } void Chuchu_OnConfused(Entity* this) { - if ((this->frame & 0x80) == 0) + if ((this->frame & ANIM_DONE) == 0) GetNextFrame(this); GenericConfused(this); } @@ -173,7 +173,7 @@ void nullsub_4(Entity* this) { void sub_0801F0C8(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; this->actionDelay = (Random() & 3) + 0xc; this->field_0xf = Random(); @@ -221,7 +221,7 @@ void sub_0801F1B0(Entity* this) { GetNextFrame(this); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (sub_0801FBD0(this)) { sub_0801F328(this); } else { @@ -240,7 +240,7 @@ void sub_0801F228(Entity* this) { void sub_0801F250(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_0801F360(this); } @@ -267,7 +267,7 @@ void sub_0801F270(Entity* this) { void sub_0801F2CC(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->spriteSettings.draw = 0; InitializeAnimation(this, 4); @@ -277,7 +277,7 @@ void sub_0801F2CC(Entity* this) { void sub_0801F2F8(Entity* this) { GravityUpdate(this, 0x1800); GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_0801F340(this); sub_0804AA1C(this); } @@ -362,7 +362,7 @@ void sub_0801F48C(Entity* this) { void sub_0801F494(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; this->field_0xf = 30; this->direction = sub_08049F84(this, 1); @@ -418,7 +418,7 @@ void sub_0801F584(Entity* this) { GetNextFrame(this); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (sub_0801FBD0(this)) { this->field_0x82.HALF.HI = 0; sub_0801F730(this); @@ -440,7 +440,7 @@ void sub_0801F61C(Entity* this) { void sub_0801F638(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 8; this->field_0xf = 30; this->direction = sub_08049F84(this, 1); @@ -465,7 +465,7 @@ void sub_0801F688(Entity* this) { void sub_0801F6CC(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->spriteSettings.draw = 0; InitializeAnimation(this, 4); @@ -475,7 +475,7 @@ void sub_0801F6CC(Entity* this) { void sub_0801F6F8(Entity* this) { GravityUpdate(this, 0x1800); GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 4; this->speed = 0x20; sub_0804AA1C(this); @@ -538,7 +538,7 @@ void sub_0801F7FC(Entity* this) { void sub_0801F840(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_0801FB14(this); COLLISION_ON(this); this->spritePriority.b0 = 4; @@ -594,7 +594,7 @@ void sub_0801F940(Entity* this) { GetNextFrame(this); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (sub_0801FBD0(this)) { sub_0801FAE0(this); } else { @@ -614,7 +614,7 @@ void sub_0801F9C4(Entity* this) { void sub_0801F9E0(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 8; this->field_0xf = 30; this->direction = sub_08049F84(this, 1); @@ -639,7 +639,7 @@ void sub_0801FA30(Entity* this) { void sub_0801FA78(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->spriteSettings.draw = 0; InitializeAnimation(this, 4); @@ -650,7 +650,7 @@ void sub_0801FA78(Entity* this) { void sub_0801FAAC(Entity* this) { GravityUpdate(this, 0x1800); GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_0801FB14(this); this->speed = 0x20; sub_0804AA1C(this); @@ -705,7 +705,7 @@ void sub_0801FB68(Entity* this) { } u32 sub_0801FBD0(Entity* this) { - if (sub_080B1AA8(this) == 0x10) { + if (GetTileUnderEntity(this) == 0x10) { return 1; } else { return 0; diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c index 24c8555a..28b32be5 100644 --- a/src/enemy/cuccoAggr.c +++ b/src/enemy/cuccoAggr.c @@ -164,7 +164,7 @@ void sub_08038F20(CuccoAggrEntity* this) { sub_08039298(this); GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { sub_0803901C(this); } } @@ -328,7 +328,7 @@ void CuccoAggr_CreateFx(CuccoAggrEntity* this) { void sub_08039298(CuccoAggrEntity* this) { if (super->type2 == 0) { - sub_08078930(super); + RegisterCarryEntity(super); } } diff --git a/src/enemy/curtain.c b/src/enemy/curtain.c index af8c22d0..0a0d342c 100644 --- a/src/enemy/curtain.c +++ b/src/enemy/curtain.c @@ -49,7 +49,7 @@ void sub_08048268(Entity* this) { } GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->actionDelay = 0; InitializeAnimation(this, 0); } @@ -58,7 +58,7 @@ void sub_08048268(Entity* this) { void sub_08048294(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; SetLocalFlag(0x72); InitializeAnimation(this, 1); diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 6c1b0238..7fae4b0b 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -141,7 +141,7 @@ void sub_08020D9C(Entity* this) { void sub_08020DB4(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_08021390(this); } @@ -161,7 +161,7 @@ void sub_08020DD4(Entity* this) { void sub_08020E28(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_080213B0(this); } @@ -170,14 +170,14 @@ void sub_08020E48(Entity* this) { sub_080213F0(this); } else { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_080213B0(this); } } void sub_08020E78(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_08021390(this); } @@ -211,7 +211,7 @@ void sub_08020E98(Entity* this) { void sub_08020F28(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_08021400(this); } @@ -241,7 +241,7 @@ void sub_08020F48(Entity* this) { } void sub_08020FAC(Entity* this) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (this->field_0x7a.HALF.LO) { this->field_0x7a.HALF.LO--; } else { @@ -264,7 +264,7 @@ void sub_08020FE4(Entity* this) { void sub_08021010(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->hitType = 0x56; sub_080213F0(this); } @@ -280,7 +280,7 @@ void sub_08021038(Entity* this) { EnqueueSFX(SFX_10E); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_08021588(this); if (this->field_0x7c.BYTES.byte0) { this->field_0x7c.BYTES.byte0--; @@ -300,7 +300,7 @@ void sub_080210A8(Entity* this) { this->frame = 0; sub_08021588(this); EnqueueSFX(SFX_15D); - } else if (this->frame & 0x80) { + } else if (this->frame & ANIM_DONE) { sub_08021390(this); } } @@ -330,7 +330,7 @@ void sub_080210E4(Entity* this) { } void sub_08021170(Entity* this) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (this->field_0x7a.HALF.HI) { this->field_0x7a.HALF.HI--; } else { @@ -346,7 +346,7 @@ void sub_080211A0(Entity* this) { sub_08021390(this); } else { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_080213B0(this); } } @@ -357,7 +357,7 @@ void sub_080211D0(Entity* this) UpdateAnimationSingleFrame(this); sub_0802159C(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_08021390(this); } @@ -365,7 +365,7 @@ void sub_080211F4(Entity* this) { UpdateAnimationSingleFrame(this); sub_08021600(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) sub_08021390(this); } diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index f340affa..540ae972 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -75,7 +75,7 @@ void sub_080220D8(Entity* this) { void sub_080220F0(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { const PosOffset* off; u32 i; @@ -107,7 +107,7 @@ void sub_08022174(Entity* this) { void sub_08022198(Entity* this) { sub_0800445C(this); GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->actionDelay = 0x5a; } diff --git a/src/enemy/enemy4D.c b/src/enemy/enemy4D.c index e8165957..9c13ceaf 100644 --- a/src/enemy/enemy4D.c +++ b/src/enemy/enemy4D.c @@ -207,7 +207,7 @@ void Enemy4D_Action6(Enemy4DEntity* this) { } void Enemy4D_Action7(Enemy4DEntity* this) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { UpdateAnimationSingleFrame(super); } else { if (--super->actionDelay == 0) { diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 98f80480..2811e901 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -223,7 +223,7 @@ void Enemy50_Action2(Enemy50Entity* this) { void Enemy50_Action3(Enemy50Entity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->flags |= 0x80; this->unk_7c = this->unk_80 * ((Random() & 0x30) + 0x3c) + 0x78; sub_08041128(this); @@ -292,7 +292,7 @@ void Enemy50_Action7(Enemy50Entity* this) { void Enemy50_Action8(Enemy50Entity* this) { sub_0803F738(this); GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 9; this->unk_78 = 0; InitializeAnimation(super, 4); diff --git a/src/enemy/enemy64.c b/src/enemy/enemy64.c index 8fde9fbc..919a569b 100644 --- a/src/enemy/enemy64.c +++ b/src/enemy/enemy64.c @@ -54,7 +54,7 @@ void Enemy64(Enemy64Entity* this) { super->subAction = 0; } Enemy64_Actions[super->action](this); - sub_0805EC9C(super, 0xaa, 0xaa, this->unk_78); + SetAffineInfo(super, 0xaa, 0xaa, this->unk_78); super->animationState = -(this->unk_78 >> 8); sub_080499F0(this); this->unk_7d = super->spriteSettings.draw; diff --git a/src/enemy/enemyE.c b/src/enemy/enemyE.c index f0428d37..957c953b 100644 --- a/src/enemy/enemyE.c +++ b/src/enemy/enemyE.c @@ -54,7 +54,7 @@ void sub_08023000(Entity* this, int frames) { tmp *= -1; this->spriteRendering.b0 = 3; - sub_0805EC9C(this, tmp, 0x80, 0); + SetAffineInfo(this, tmp, 0x80, 0); } // clang-format off diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index 26b22f65..aae204a2 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -196,7 +196,7 @@ void Eyegore_Action3(EyegoreEntity* this) { super->spriteOffsetX = gUnk_080CE2BC[--super->actionDelay & 3]; } else { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->flags |= ENT_COLLIDE; super->animationState = 2; sub_08030E58(this); @@ -214,7 +214,7 @@ void Eyegore_Action4(EyegoreEntity* this) { sub_08030E3C(this); break; case 2: - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->animationState = this->unk_7f; InitializeAnimation(super, super->animationState + 4); } @@ -227,7 +227,7 @@ void Eyegore_Action4(EyegoreEntity* this) { break; default: - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { InitializeAnimation(super, super->animationState); if ((this->unk_79 & 0x80) != 0) { super->action = 5; @@ -252,7 +252,7 @@ void Eyegore_Action5(EyegoreEntity* this) { sub_08030E3C(this); break; case 2: - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->animationState = this->unk_7f; InitializeAnimation(super, super->animationState + 4); } @@ -261,7 +261,7 @@ void Eyegore_Action5(EyegoreEntity* this) { } break; default: - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { InitializeAnimation(super, super->animationState); if (sub_08049FDC(super, 1)) { sub_08030E58(this); @@ -280,7 +280,7 @@ void Eyegore_Action5(EyegoreEntity* this) { void Eyegore_Action6(EyegoreEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 2; } } diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 261efa49..262781bb 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -20,7 +20,7 @@ void (*const gUnk_080CFBD4[])(FlyingSkullEntity*); const s8 gUnk_080CFBE4[4]; extern s32 sub_080012DC(Entity*); -extern void sub_08078930(Entity*); +extern void RegisterCarryEntity(Entity*); void sub_0803A100(FlyingSkullEntity* this); void sub_0803A0E0(FlyingSkullEntity* this); @@ -130,7 +130,7 @@ void sub_08039DD8(FlyingSkullEntity* this) { sub_0803A0E0(this); } - sub_08078930(super); + RegisterCarryEntity(super); } else { if ((gPlayerState.flags & PL_MINISH) == 0) { Entity* ent = &gPlayerEntity; diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index a7870e07..7bd4179b 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -250,7 +250,7 @@ void Ghini_Action7(GhiniEntity* this) { void Ghini_Action8(GhiniEntity* this) { sub_0803F738(this); GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 9; super->flags |= 0x80; this->unk_78 = 0; diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 9c29dd4e..4e18f26e 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -164,7 +164,7 @@ void sub_08037624(GibdoEntity* this) { void sub_08037690(GibdoEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { this->field_0x77 = 0x14; sub_08037794(this); } else { @@ -196,7 +196,7 @@ void sub_080376D0(GibdoEntity* this) { void sub_0803773C(GibdoEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { sub_08037794(this); } } diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index fb2777e4..50ae9126 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -549,7 +549,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D86C.inc", void sub_0802D86C(GleerokE UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) == 0) + if ((super->frame & ANIM_DONE) == 0) return; enemy = CreateEnemy(GLEEROK, 6); @@ -569,7 +569,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D86C.inc", void sub_0802D86C(GleerokE GetNextFrame(super); - if ((super->frame & 0x80) == 0) + if ((super->frame & ANIM_DONE) == 0) return; enemy = CreateEnemy(GLEEROK, 3); @@ -998,7 +998,7 @@ void sub_0802E0B8(GleerokEntity* this) { void sub_0802E1D0(GleerokEntity* this) { Gleerok_HeapStruct* heap = this->unk_84; - if (!(super->frame & 0x80)) { + if (!(super->frame & ANIM_DONE)) { GetNextFrame(super); } if (super->frame & 0x3f) { @@ -1144,7 +1144,7 @@ void sub_0802E448(GleerokEntity* this) { void sub_0802E4C0(GleerokEntity* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { if (super->action != 2) { this->unk_74 = 0; this->unk_75 = 8; @@ -1220,7 +1220,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802E518.inc", void sub_0802E518(GleerokE r7 += heap->ent2->actionDelay; } else { if (super->iframes == 0) { - if ((super->animIndex != (heap->filler[0x15] >> 3) + 0x2f) || (super->frame & 0x80) != 0) { + if ((super->animIndex != (heap->filler[0x15] >> 3) + 0x2f) || (super->frame & ANIM_DONE) != 0) { r7 = (heap->filler[0x15] >> 3) + 0x28; } } else { diff --git a/src/enemy/gyorgFemaleEye.c b/src/enemy/gyorgFemaleEye.c index 84d1aa3b..6ddb4f65 100644 --- a/src/enemy/gyorgFemaleEye.c +++ b/src/enemy/gyorgFemaleEye.c @@ -125,7 +125,7 @@ void sub_08048B2C(GyorgFemaleEyeEntity* this) { void sub_08048B84(GyorgFemaleEyeEntity* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->action = 3; super->flags |= ENT_COLLIDE; super->hitType = 0x1E; @@ -155,7 +155,7 @@ void sub_08048BB0(GyorgFemaleEyeEntity* this) { SoundReq(SFX_ITEM_GLOVES_KNOCKBACK); } GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->hitType = 0x1E; InitializeAnimation(super, gUnk_080D2010[(super->animationState << 3) + super->type]); UpdateAnimationVariableFrames(super, 7); @@ -176,7 +176,7 @@ void sub_08048BB0(GyorgFemaleEyeEntity* this) { void sub_08048CEC(GyorgFemaleEyeEntity* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->action = 1; InitializeAnimation(super, gUnk_080D2010[(super->animationState << 3) + super->type]); } diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index f9ca7d8c..e0af39c7 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -106,7 +106,7 @@ void GyorgMale(GyorgMaleEntity* this) { } gUnk_080D1AFC[super->action](this); if (super->action != 7) { - sub_0805EC9C(super, 0xaa, 0xaa, this->unk_78); + SetAffineInfo(super, 0xaa, 0xaa, this->unk_78); } super->animationState = -(this->unk_78 >> 8); sub_08048004(this); @@ -986,7 +986,7 @@ void sub_08047BF0(GyorgMaleEntity* this) { } } } - sub_0805EC9C(super, 0xAA, 0xAA, this->unk_78); + SetAffineInfo(super, 0xAA, 0xAA, this->unk_78); } void sub_08047D24(GyorgMaleEntity* this) { @@ -1005,7 +1005,7 @@ void sub_08047D24(GyorgMaleEntity* this) { } else { sub_08047E58(this); } - sub_0805EC9C(super, this->unk_7e, this->unk_7e, this->unk_78); + SetAffineInfo(super, this->unk_7e, this->unk_7e, this->unk_78); } } diff --git a/src/enemy/gyorgMaleEye.c b/src/enemy/gyorgMaleEye.c index a7586c44..4e9128f3 100644 --- a/src/enemy/gyorgMaleEye.c +++ b/src/enemy/gyorgMaleEye.c @@ -79,7 +79,7 @@ void GyorgMaleEye_Init(GyorgMaleEyeEntity* this) { void GyorgMaleEye_Action1(GyorgMaleEyeEntity* this) { sub_08048F50(this); GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 2; super->flags |= 0x80; super->actionDelay = 0x2d; @@ -98,7 +98,7 @@ void GyorgMaleEye_Action2(GyorgMaleEyeEntity* this) { void GyorgMaleEye_Action3(GyorgMaleEyeEntity* this) { sub_08048F50(this); GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 2c593691..5d34065a 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -79,7 +79,7 @@ void sub_0802BC74(Entity* this) { sub_0802C1C0(this); this->subAction = 1; this->field_0x1d = 60; - this->animationState = (gPlayerEntity.animationState >> 1) ^ 2; + this->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1); InitializeAnimation(this, this->animationState); } @@ -92,7 +92,7 @@ void sub_0802BCA8(Entity* this) { Entity* ent; this->action = 7; - this->actionDelay = 0x5a; + this->actionDelay = 90; this->zVelocity = Q_16_16(1.5); this->hitType = 0x19; this->field_0x3a = this->field_0x3a & 0xfb; diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 340a9be5..09564cd3 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -85,7 +85,7 @@ void sub_0803248C(Entity* this) { void sub_080324CC(Entity* this) { if (sub_080325E8(this) == 0) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_080326FC(this); sub_08032740(this); } diff --git a/src/enemy/keese.c b/src/enemy/keese.c index 63b5b78d..bbc2bac6 100644 --- a/src/enemy/keese.c +++ b/src/enemy/keese.c @@ -79,7 +79,7 @@ void Keese_Fly(Entity* this) { this->field_0x7a.HWORD--; } GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_08021F24(this); } else { ProcessMovement1(this); diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 70145906..971ffd09 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -152,7 +152,7 @@ void Lakitu_Hide(Entity* this) { void Lakitu_EndHide(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = IDLE; this->actionDelay = 0x3c; @@ -180,7 +180,7 @@ void Lakitu_Idle(Entity* this) { void Lakitu_BeginHide(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->spriteSettings.draw = 0; @@ -191,7 +191,7 @@ void Lakitu_BeginHide(Entity* this) { void Lakitu_Lightning(Entity* this) { UpdateAnimationSingleFrame(this); - if (!(this->frame & 0x80)) { + if (!(this->frame & ANIM_DONE)) { return; } diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 4226da39..3e53a53a 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -85,7 +85,7 @@ void Leever_Idle(Entity* this) { void Leever_DigUp(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; if (this->type == LeeverForm_Red) { this->field_0x74.HWORD = 180; @@ -113,7 +113,7 @@ void Leever_Attack(Entity* this) { void Leever_DigDown(Entity* this) { Leever_Move(this); GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->actionDelay = 0xf0; this->spriteSettings.draw = FALSE; diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index cdad77e6..26ed3023 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -277,7 +277,7 @@ void sub_08029D14(Entity* this) { } } else { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 4; this->actionDelay = 0x78; this->hitType = 0x6c; @@ -299,7 +299,7 @@ void sub_08029D78(Entity* this) { void sub_08029DAC(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 6; this->parent->field_0x76.HALF.HI = 1; InitializeAnimation(this, this->animationState + 8); diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index 5d3a04b8..786039df 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -238,7 +238,7 @@ void sub_0803A364(Entity* this) { break; case 4: GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->subAction = 5; } break; @@ -261,7 +261,7 @@ void sub_0803A364(Entity* this) { break; case 7: GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->subAction = 8; this->spriteSettings.draw = 0; InitAnimationForceUpdate(this->child, 8); @@ -270,7 +270,7 @@ void sub_0803A364(Entity* this) { break; case 8: sub_0803B55C(this); - if ((this->child->frame & 0x80) == 0) { + if ((this->child->frame & ANIM_DONE) == 0) { return; } uVar1 = 9; @@ -286,7 +286,7 @@ void sub_0803A364(Entity* this) { break; case 10: sub_0803B55C(this); - if ((this->child->frame & 0x80) != 0) { + if ((this->child->frame & ANIM_DONE) != 0) { this->subAction = 0xb; this->spriteSettings.draw = 1; InitializeAnimation(this, 4); @@ -294,7 +294,7 @@ void sub_0803A364(Entity* this) { break; case 0xb: GetNextFrame(this); - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return; } if (this->type2 != 0) { @@ -365,7 +365,7 @@ void sub_0803A60C(Entity* this) { index = ((this->parent->field_0xf >> 4) + 3); this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 6; this->spriteSettings.draw = 0; InitAnimationForceUpdate(this->child, 8); @@ -482,7 +482,7 @@ void sub_0803A814(Entity* this) { index = ((this->parent->field_0xf >> 4) + 3); this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; sub_0803B55C(this); - if ((this->child->frame & 0x80) != 0) { + if ((this->child->frame & ANIM_DONE) != 0) { this->action = 0xe; this->spriteSettings.draw = 1; InitializeAnimation(this, 4); @@ -497,7 +497,7 @@ void sub_0803A86C(Entity* this) { index = ((this->parent->field_0xf >> 4) + 3); this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { COLLISION_ON(this); sub_0803B59C(this); } @@ -619,7 +619,7 @@ void sub_0803AB10(Entity* this) { this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; LinearMoveUpdate(this); sub_0803B55C(this); - if ((this->child->frame & 0x80) != 0) { + if ((this->child->frame & ANIM_DONE) != 0) { this->action = 0x15; this->actionDelay = 0xf; } @@ -649,7 +649,7 @@ void sub_0803ABB4(Entity* this) { this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; GetNextFrame(this); sub_0803B55C(this); - if ((this->child->frame & 0x80) != 0) { + if ((this->child->frame & ANIM_DONE) != 0) { this->action = 0x17; COLLISION_ON(this); this->speed = 0x180; @@ -768,7 +768,7 @@ void sub_0803ADF4(Entity* this) { this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; UpdateAnimationSingleFrame(this); GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 0x1c; this->actionDelay = 0x1e; this->spriteSettings.draw = 0; @@ -803,7 +803,7 @@ void sub_0803AEC4(Entity* this) { this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; UpdateAnimationSingleFrame(this); GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { COLLISION_ON(this); sub_0803B59C(this); } @@ -818,7 +818,7 @@ void sub_0803AF18(Entity* this) { void sub_0803AF50(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 0x20; this->spriteSettings.draw = 0; InitAnimationForceUpdate(this->child, 8); @@ -827,7 +827,7 @@ void sub_0803AF50(Entity* this) { void sub_0803AF7C(Entity* this) { sub_0803B55C(this); - if ((this->child->frame & 0x80) != 0) { + if ((this->child->frame & ANIM_DONE) != 0) { this->action = 0x21; this->actionDelay = 0xf; } @@ -892,7 +892,7 @@ void sub_0803B074(Entity* this) { index = ((this->parent->field_0xf >> 4) + 3); this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; sub_0803B55C(this); - if ((this->child->frame & 0x80) != 0) { + if ((this->child->frame & ANIM_DONE) != 0) { this->action = 0x27; this->spriteSettings.draw = 1; InitializeAnimation(this, 4); @@ -903,7 +903,7 @@ void sub_0803B074(Entity* this) { void sub_0803B0D4(Entity* this) { UpdateAnimationSingleFrame(this); GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { COLLISION_ON(this); sub_0803B59C(this); } @@ -938,7 +938,7 @@ void sub_0803B144(Entity* this) { void sub_0803B17C(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 0x2b; COLLISION_ON(this); this->hitType = 0x18; @@ -951,7 +951,7 @@ void sub_0803B1B8(Entity* this) { Entity* temp; u16 val; - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { GetNextFrame(this); UpdateAnimationSingleFrame(this->child); } @@ -994,7 +994,7 @@ void sub_0803B2D0(Entity* this) { Entity* entity; GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 0x2d; this->spriteSettings.draw = 0; entity = *(Entity**)&this->field_0x74; @@ -1009,7 +1009,7 @@ void sub_0803B30C(Entity* this) { Entity* entity; entity = *(Entity**)&this->field_0x74; - if ((entity->frame & 0x80) != 0) { + if ((entity->frame & ANIM_DONE) != 0) { this->action = 0x2e; sub_0803B8E8(this, 0x13); InitializeAnimation(entity, 0); @@ -1064,7 +1064,7 @@ void sub_0803B3F4(Entity* this) { index = ((this->parent->field_0xf >> 4) + 3); this->z.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->hitType = 0x17; if (this->type == 0) { this->hitbox = (Hitbox*)&gUnk_080FD35C; diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index add39f8b..feee0839 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -757,7 +757,7 @@ void sub_08034B0C(Entity* this) { this->actionDelay--; } else { GetNextFrame(this); - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return; } this->action = 2; @@ -789,7 +789,7 @@ void sub_08034B38(Entity* this) { void sub_08034BA0(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->parent->field_0x7c.HALF.HI = 0xff; DeleteEntity(this); } diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index b6099372..03f29e2a 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -170,7 +170,7 @@ void sub_08023288(Entity* this) { void sub_08023330(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 4; this->actionDelay = 0x19; COLLISION_ON(this); diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index 5ee3c12a..a205d1d6 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -94,7 +94,7 @@ void sub_0801EB9C(Entity* this) { void Octorok_Initialize(Entity* this) { sub_0804A720(this); if (this->type == 2) { - this->animationState = this->type; + this->animationState = 2; } else { this->animationState = Random() & 3; } @@ -141,13 +141,13 @@ void Octorok_ShootNut(Entity* this) { } } - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) Octorok_Pause(this); } void Octorok_Pause(Entity* this) { this->action = 1; - this->actionDelay = (Random() & 0x38) + 0x18; + this->actionDelay = (Random() & 0x38) + 24; } void Octorok_Turn(Entity* this) { diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index b4fbc73a..49ca9525 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -125,7 +125,7 @@ void OctorokBoss_Hit(OctorokBossEntity* this) { sub_08078B48(); } sub_0800445C(super); - sub_0805EC9C(super, this->unk_76, this->unk_74, this->angle.HWORD); + SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); } void OctorokBoss_Hit_SubAction0(OctorokBossEntity* this) { @@ -327,7 +327,7 @@ void OctorokBoss_Intro(OctorokBossEntity* this) { gUnk_02034490.unk0 = 1; sub_08036F60(this); OctorokBoss_Intro_SubActions[super->subAction](this); - sub_0805EC9C(super, this->unk_76, this->unk_74, this->angle.HWORD); + SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); } void OctorokBoss_Intro_SubAction0(OctorokBossEntity* this) { @@ -475,7 +475,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) { sub_08036914(super, angle, radius); this->angle.HALF.HI = ((OctorokBossEntity*)super->parent)->angle.HALF.HI + OctorokBoss_LegAngleOffset2[super->type - 1] + this->timer; - sub_0805EC9C(super, this->unk_76, this->unk_74, this->angle.HWORD); + SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); break; case TAIL: @@ -522,7 +522,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) { sub_080369D0(this, GET_TAIL_RADIUS(this), 4); } super->bitfield = 0; - sub_0805EC9C(super, this->unk_76, this->unk_74, -this->angle.HWORD ^ 0x8000); + SetAffineInfo(super, this->unk_76, this->unk_74, -this->angle.HWORD ^ 0x8000); break; case MOUTH: @@ -546,7 +546,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) { sub_08036914(super, angle, radius); this->angle.HALF.HI = ((OctorokBossEntity*)super->parent)->angle.HALF.HI; - sub_0805EC9C(super, this->unk_76, this->unk_74, this->angle.HWORD); + SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); sub_0800445C(super); } break; @@ -562,7 +562,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) { } } OctorokBoss_Action1_SubActions[super->subAction](this); - sub_0805EC9C(super, this->unk_76, this->unk_74, this->angle.HWORD); + SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); break; } } @@ -905,7 +905,7 @@ void OctorokBoss_Burning(OctorokBossEntity* this) { CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 3); } } - sub_0805EC9C(super, this->unk_76, this->unk_74, this->angle.HWORD); + SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); } void OctorokBoss_Burning_SubAction0(OctorokBossEntity* this) { diff --git a/src/enemy/octorokGolden.c b/src/enemy/octorokGolden.c index 9f38b9c7..4bdac449 100644 --- a/src/enemy/octorokGolden.c +++ b/src/enemy/octorokGolden.c @@ -90,7 +90,7 @@ void sub_08037D54(Entity* this) { EnqueueSFX(SFX_124); } } - } else if (this->frame & 0x80) { + } else if (this->frame & ANIM_DONE) { if (--this->actionDelay == 0) { this->action = 1; this->field_0xf = 0x3c; diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 3f85d704..c6051ba0 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -289,7 +289,7 @@ void Peahat_Recover(Entity* this) { void Peahat_Hop(Entity* this) { GetNextFrame(this); if (--this->actionDelay == 0) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 9; this->zVelocity = Q_16_16(1.5); this->animationState = PeahatAnimation_NewPropeller; @@ -313,7 +313,7 @@ void Peahat_Hop(Entity* this) { void Peahat_Takeoff(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->hitType = 0x70; this->field_0x82.HALF.LO = 1; diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 94111c8f..18838cf6 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -237,7 +237,7 @@ void sub_080253D4(Entity* this) { void sub_0802541C(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; this->field_0xf = 1; this->zVelocity = Q_16_16(2); @@ -270,7 +270,7 @@ void sub_0802547C(Entity* this) { void sub_080254B4(Entity* this) { GravityUpdate(this, Q_16_16(0.125)); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (this->z.HALF.HI == 0) { if (this->cutsceneBeh.HWORD == 0) { this->hitType = 0x82; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index d0d22bc9..c9beaa52 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -21,7 +21,7 @@ void sub_08020A7C(Entity*); bool32 Rollobite_TryToHoleUp(Entity*); bool32 Rollobite_IsRolledUp(Entity*); -extern void sub_08078930(Entity*); +extern void RegisterCarryEntity(Entity*); void Rollobite(Entity* this) { EnemyFunctionHandler(this, Rollobite_Functions); @@ -175,7 +175,7 @@ void Rollobite_Turn(Entity* this) { void Rollobite_RolledUp(Entity* this) { u32 unk; - if ((this->frame & 0x80) == 0) + if ((this->frame & ANIM_DONE) == 0) GetNextFrame(this); unk = sub_080044EC(this, 0x2800); @@ -185,7 +185,7 @@ void Rollobite_RolledUp(Entity* this) { this->action = 5; InitializeAnimation(this, this->animationState + 12); } - sub_08078930(this); + RegisterCarryEntity(this); } else { if (unk == 1) EnqueueSFX(SFX_104); @@ -197,7 +197,7 @@ void Rollobite_RolledUp(Entity* this) { void Rollobite_Unroll(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { COLLISION_ON(this); this->speed = 0x100; this->hitType = 34; @@ -206,7 +206,7 @@ void Rollobite_Unroll(Entity* this) { InitializeAnimation(this, this->animationState); } else { if ((this->frame & 1) == 0) - sub_08078930(this); + RegisterCarryEntity(this); } } diff --git a/src/enemy/rope.c b/src/enemy/rope.c index 48a59799..8d728a03 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -174,7 +174,7 @@ void sub_08031600(Entity* this) { u32 sub_0803163C(Entity* this) { u32 h; - if (sub_080B1AA8(this) == 0x13) { + if (GetTileUnderEntity(this) == 0x13) { h = this->field_0x7a.HWORD / 2; } else { h = this->field_0x7a.HWORD; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 903ddc0b..720243ed 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -122,7 +122,7 @@ void sub_08029474(Entity* this) { u32 bVar1; sub_080296C8(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; this->actionDelay = 8; bVar1 = GetFacingDirection(this, &gPlayerEntity); @@ -196,7 +196,7 @@ void sub_08029610(Entity* this) { void sub_08029630(Entity* this) { sub_080296C8(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->field_0x80.HALF.HI = 1; this->child->spriteSettings.draw = FALSE; sub_080297F0(this); diff --git a/src/enemy/scissorsBeetle.c b/src/enemy/scissorsBeetle.c index 41f84df0..28ce9d57 100644 --- a/src/enemy/scissorsBeetle.c +++ b/src/enemy/scissorsBeetle.c @@ -142,7 +142,7 @@ void sub_08038B08(ScissorsBeetleEntity* this) { } UpdateAnimationSingleFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->action = 4; this->unk_82 = 3; super->actionDelay = 0x32; diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index e6b5eb87..5405cf71 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -134,7 +134,7 @@ void sub_08023CE0(Entity* this) { default: GetNextFrame(this); if (this->frame) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { Entity* ent = CreateEnemy(SLUGGULA, 1); if (ent) { sub_0804A4E4(this, ent); @@ -157,7 +157,7 @@ void sub_08023E10(Entity* this) { } GetNextFrame(this); - if (this->frame & 0x80) + if (this->frame & ANIM_DONE) DeleteEntity(this); } diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index 6ab1efcd..cbdfe52e 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -171,7 +171,7 @@ void sub_08033A7C(SpinyBeetleEntity* this) { } GetNextFrame(super); - if ((super->frame & 0x80) == 0) + if ((super->frame & ANIM_DONE) == 0) return; super->action = 3; diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 784d1a2e..7d49e0d2 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -181,7 +181,7 @@ void sub_080226EC(Entity* this) { void sub_08022780(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 4; InitializeAnimation(this, 3); EnqueueSFX(SFX_194); @@ -201,7 +201,7 @@ void sub_080227AC(Entity* this) { this->hitType = 0x5c; } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->field_0xf = gUnk_080CBA60[Random() & 3]; InitializeAnimation(this, 0); @@ -211,7 +211,7 @@ void sub_080227AC(Entity* this) { void sub_0802281C(Entity* this) { GravityUpdate(this, Q_8_8(24.0)); GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->speed = 0x20; InitializeAnimation(this, 0); @@ -234,7 +234,7 @@ void sub_08022854(Entity* this) { void sub_0802289C(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->speed = 0x20; this->field_0x80.HALF.HI = 0x78; diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 2751cd5b..67f6b6e1 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -269,7 +269,7 @@ void Stalfos_Action11(StalfosEntity* this) { void Stalfos_Action12(StalfosEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { if (super->type2 == 1) { sub_0803998C(this); DeleteEntity(super->child); diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index ddeb53d2..db461a94 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -97,7 +97,7 @@ void sub_0802F284(Entity* this) { if (this->actionDelay != 0) { this->actionDelay--; } else if (this->field_0xf != 0) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->actionDelay = 0x10; this->field_0xf = this->type; @@ -105,7 +105,7 @@ void sub_0802F284(Entity* this) { sub_0802F45C(this); InitializeAnimation(this, 2); } - } else if (this->frame & 0x80) { + } else if (this->frame & ANIM_DONE) { this->field_0xf = 0x40; InitializeAnimation(this, 1); } @@ -137,7 +137,7 @@ void sub_0802F300(Entity* this) { return; } else if (this->collisions != 0) { sub_0800417E(this, this->collisions); - } else if ((sub_080B1AA8(this) & 0xf0) == 0x50) { + } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { this->direction = (this->direction + 0x10) & 0x1f; } @@ -167,7 +167,7 @@ void sub_0802F3F4(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if ((*(u8*)&this->field_0x7c.HALF.LO < 2) && ((this->type % 2) != 0)) { this->action = 2; this->actionDelay = 0x10; diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index b35f8f2c..af71db25 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -85,7 +85,7 @@ void sub_08037Fe0(Entity* this) { if (this->actionDelay != 0) { this->actionDelay--; } else if (this->field_0xf != 0) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; this->actionDelay = 6; this->field_0xf = 0; @@ -93,7 +93,7 @@ void sub_08037Fe0(Entity* this) { sub_08038168(this); InitializeAnimation(this, 2); } - } else if (this->frame & 0x80) { + } else if (this->frame & ANIM_DONE) { this->field_0xf = 0x40; InitializeAnimation(this, 1); } @@ -116,7 +116,7 @@ void sub_08038048(Entity* this) { return; } else if (this->collisions != 0) { sub_0800417E(this, this->collisions); - } else if ((sub_080B1AA8(this) & 0xf0) == 0x50) { + } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { this->direction = (this->direction + 0x10) & 0x1f; } @@ -141,7 +141,7 @@ void sub_08038048(Entity* this) { void sub_08038110(Entity* this) { UpdateAnimationVariableFrames(this, 2); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (this->field_0x80.HALF.LO < 5) { this->action = 2; this->actionDelay = 8; diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index e4b6e5e4..d9f17946 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -713,7 +713,7 @@ void sub_08042FD8(Entity* this) { this->frame = 0; } } else { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (--this->field_0xf == 0) { this->subAction = 8; this->actionDelay = 0x3c; diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 222e1dd4..fa72f6f8 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -162,7 +162,7 @@ void sub_08044868(Entity* this) { if (this->field_0x82.HALF.HI) { switch (this->field_0x74.HALF.LO) { case 0: - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->field_0x74.HALF.LO = 1; this->direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10); this->speed = 0x180; diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index 9c875dd0..320e4bf3 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -153,7 +153,7 @@ void VaatiProjectileFunction0Action2(Entity* this) { } void VaatiProjectileFunction0Action3(Entity* this) { - if (this->child->frame & 0x80) { + if (this->child->frame & ANIM_DONE) { if (--this->z.HALF.HI <= -0x18) { this->action = 4; this->actionDelay = (Random() & 0xf) + 0xf; diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index a84dfcbc..07639d76 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -235,7 +235,7 @@ void VaatiRebornEnemyType0Action2(Entity* this) { } break; case 1: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0x74.HALF.LO = 2; this->spriteSettings.draw = 0; this->actionDelay = 0x10; @@ -260,7 +260,7 @@ void VaatiRebornEnemyType0Action2(Entity* this) { } break; case 3: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->spriteSettings.draw = 1; if (4 < this->field_0x80.HALF.HI) { this->x.HALF.HI = gPlayerEntity.x.HALF.HI; @@ -318,7 +318,7 @@ void VaatiRebornEnemyType0Action3(Entity* this) { } break; case 2: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0x74.HALF.LO = 3; InitAnimationForceUpdate(this, 0); } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 7ca2f6d7..7149ea69 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -675,7 +675,7 @@ void VaatiTransfiguredType2Action1(Entity* this) { } break; case 1: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0x74.HALF.LO = 0; this->field_0xf = (Random() & 0x7f) + 0x17; InitAnimationForceUpdate(this, 0); @@ -790,7 +790,7 @@ void VaatiTransfiguredType5Action1(Entity* this) { this->field_0x80.HALF.LO = 0; this->spriteSettings.draw = 0; } else { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->frame &= ~0x80; if (gEntCount < 0x47) { sub_08040648(this, this->type, 1); @@ -814,13 +814,13 @@ void VaatiTransfiguredType5Action2(Entity* this) { } if (this->field_0x80.HALF.LO == 0) { if (this->parent->parent->action != 6) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0x80.HALF.LO += 1; InitializeAnimation(this, 3); } } } else { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index cd42c7a3..457b294d 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -129,7 +129,7 @@ void VaatiTransfiguredEyeFunction0Action0(Entity* this) { void VaatiTransfiguredEyeFunction0Action1(Entity* this) { sub_08045A28(this); if (this->field_0x82.HALF.LO == 0) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { if (this->type != 0) { COLLISION_ON(this); } @@ -169,7 +169,7 @@ void VaatiTransfiguredEyeFunction0Action2(Entity* this) { void VaatiTransfiguredEyeFunction0Action3(Entity* this) { sub_08045A28(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 2; if (this->type != 0) { if (this->actionDelay == 0) { @@ -187,7 +187,7 @@ void VaatiTransfiguredEyeFunction0Action4(Entity* this) { sub_08045A28(this); if (this->field_0xf == 0) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0xf = 0x20; } } else { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index af31d2f8..2d8c3619 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -365,7 +365,7 @@ void VaatiWrathType0Action6(Entity* this) { type1->frame &= 0xfd; } } else { - if ((type1->frame & 0x80) != 0) { + if ((type1->frame & ANIM_DONE) != 0) { sub_0804235C(this); } } @@ -546,7 +546,7 @@ void VaatiWrathType0ActionC(Entity* this) { entity->frame &= 0xfe; InitAnimationForceUpdate(this, 9); } else { - if (entity->frame & 0x80) { + if (entity->frame & ANIM_DONE) { sub_0804235C(this); } } @@ -617,7 +617,7 @@ void sub_08041BE8(Entity* this) { void sub_08041CD0(Entity* this) { GetNextFrame(((VaatiWrathHeapStruct*)this->myHeap)->type2); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (this->actionDelay != 0) { this->actionDelay--; } else { @@ -964,7 +964,7 @@ u32 sub_080422C0(Entity* this, u32 unk1) { type1->frame &= 0xfb; InitAnimationForceUpdate(this, 3); } else { - if (type1->frame & 0x80) { + if (type1->frame & ANIM_DONE) { InitAnimationForceUpdate(this, 0); type1->subAction = 0; InitializeAnimation(type1, 0xc); diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c index 690d8ee6..784be12b 100644 --- a/src/enemy/vaatiWrathEye.c +++ b/src/enemy/vaatiWrathEye.c @@ -56,7 +56,7 @@ void VaatiWrathEyeAction0(Entity* this) { void VaatiWrathEyeAction1(Entity* this) { sub_080485D8(this); GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 2; InitializeAnimation(this, 1); } @@ -105,7 +105,7 @@ void VaatiWrathEyeAction4(Entity* this) { } } else { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 5; this->actionDelay = 0; } @@ -137,7 +137,7 @@ void VaatiWrathEyeAction6(Entity* this) { InitializeAnimation(this, 6); } } else { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 7; this->actionDelay = 120; this->field_0xf = 0; @@ -193,7 +193,7 @@ void VaatiWrathEyeAction8(Entity* this) { void VaatiWrathEyeAction9(Entity* this) { sub_080485FC(this); GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 4; this->actionDelay = 1; this->parent->field_0x7a.HALF.HI = (this->parent->field_0x7a.HALF.HI & 0xf) | (1 << this->type); diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index 7f08b67e..b9377a19 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -112,7 +112,7 @@ void sub_0802A610(Entity* this) { GetNextFrame(this); sub_0802A7D0(this); - flags = this->frame & 0x80; + flags = this->frame & ANIM_DONE; if (flags) { this->action = 4; this->actionDelay = 0x1e; @@ -154,7 +154,7 @@ void sub_0802A69C(Entity* this) { /* sigh... */ GetNextFrame(this); - flags = this->frame & 0x80; + flags = this->frame & ANIM_DONE; if (flags) { this->action = 6; this->actionDelay = 0x1e; @@ -193,7 +193,7 @@ void sub_0802A78C(Entity* this) { void sub_0802A7D0(Entity* this) { u32 unk = gUnk_080CD0B0[(this->field_0x7c.BYTES.byte1++ >> 3) & 7] + 0x100; - sub_0805EC9C(this, unk, unk, 0); + SetAffineInfo(this, unk, unk, 0); } // clang-format off void (*const WallMaster_Functions[])(Entity*) = { diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index 3ee61f51..989097fe 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -131,7 +131,7 @@ void sub_0802CE68(Entity* this) { } sub_0802CFD8(this); GetNextFrame(this); - frames = this->frame & 0x80; + frames = this->frame & ANIM_DONE; if (frames) { this->action = 4; this->actionDelay = 30; @@ -169,7 +169,7 @@ ASM_FUNC("asm/non_matching/wallMaster2/sub_0802CF8C.inc", void sub_0802CF8C(Enti void sub_0802CFD8(Entity* this) { u32 unk = gUnk_080CD740[(this->field_0x7a.HALF.LO++ >> 3) & 7]; - sub_0805EC9C(this, (s16)this->field_0x74.HWORD + unk, 0x100 + unk, this->field_0x76.HWORD); + SetAffineInfo(this, (s16)this->field_0x74.HWORD + unk, 0x100 + unk, this->field_0x76.HWORD); } // clang-format off diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 39c329a2..629c54cd 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -56,7 +56,7 @@ void sub_0802A2B4(Entity* this) { void sub_0802A2FC(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { DeleteEntity(this); } else if (this->frame & 1) { COLLISION_OFF(this); diff --git a/src/entity.c b/src/entity.c index 4bd014e5..d696050c 100644 --- a/src/entity.c +++ b/src/entity.c @@ -9,15 +9,14 @@ extern u8 gUnk_081091F8[]; extern u8 gUnk_081091EE[]; extern u8 gUpdateVisibleTiles; extern Manager gUnk_02033290; -void sub_0805ED30(void); +void UpdatePlayerInput(void); void ClearHitboxList(void); void sub_0805EE88(void); void ClearAllDeletedEntities(void); void DeleteAllEntities(void); void sub_0805E98C(void); -extern void sub_0806FE84(Entity*); +extern void UnloadOBJPalette2(Entity*); extern void sub_08017744(Entity*); -extern void UnloadHitbox(Entity*); extern void sub_0804AA1C(Entity*); void ClearDeletedEntity(Entity*); @@ -64,8 +63,8 @@ void sub_0805E248(void) { gUpdateVisibleTiles = 0; } -void sub_0805E374(Entity* e) { - u8 r3 = gRoomTransition.player_status.field_0x24[8]; +void SetDefaultPriorityForKind(Entity* e) { + u8 r3 = gRoomTransition.entity_update_type; u8* array = gUnk_081091F8; if (r3 != 2) { @@ -201,7 +200,7 @@ void UpdateEntities(void) { gRoomVars.filler1[0] = gRoomVars.field_0x4; gRoomVars.field_0x4 = 0; - sub_0805ED30(); + UpdatePlayerInput(); UpdatePriority(); ClearHitboxList(); sub_0806F0A4(); @@ -232,7 +231,7 @@ void EraseAllEntities(void) { } extern Entity gUnk_030015A0[0x48]; -extern Entity gUnk_03003BE0; +extern Entity gCarryEntities; NONMATCH("asm/non_matching/GetEmptyEntity.inc", Entity* GetEmptyEntity()) { u8 flags_ip; @@ -263,7 +262,7 @@ NONMATCH("asm/non_matching/GetEmptyEntity.inc", Entity* GetEmptyEntity()) { ClearDeletedEntity(ptr); return ptr; } - } while (++ptr < &gUnk_03003BE0); + } while (++ptr < &gCarryEntities); flags_ip = 0; rv = NULL; @@ -343,9 +342,9 @@ void DeleteEntity(Entity* ent) { if (ent->next) { UnloadGFXSlots(ent); UnloadOBJPalette(ent); - sub_0806FE84(ent); + UnloadOBJPalette2(ent); sub_080788E0(ent); - sub_08078954(ent); + FreeCarryEntity(ent); sub_0805EC60(ent); sub_08017744(ent); ReleaseTransitionManager(ent); @@ -437,15 +436,15 @@ void ReleaseTransitionManager(void* mgr) { } } -extern Entity gUnk_020369F0; +extern LinkedList gEntityListsBackup; void sub_0805E958(void) { - MemCopy(&gEntityLists, &gUnk_020369F0, 0x48); + MemCopy(&gEntityLists, &gEntityListsBackup, 0x48); sub_0805E98C(); } void sub_0805E974(void) { - MemCopy(&gUnk_020369F0, &gEntityLists, 0x48); + MemCopy(&gEntityListsBackup, &gEntityLists, 0x48); } void sub_0805E98C(void) { @@ -479,7 +478,7 @@ void DeleteSleepingEntities(void) { list = &gEntityLists[0]; do { - for (ent = list->first; (u32)ent != (u32)list; ent = next) { + for (ent = list->first; (intptr_t)ent != (intptr_t)list; ent = next) { next = ent->next; if (ent->flags & ENT_DELETED) DeleteEntityAny(ent); @@ -501,7 +500,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) { } else { gManagerCount++; } - sub_0805E374(entity); + SetDefaultPriorityForKind(entity); } void PrependEntityToList(Entity* entity, u32 listIndex) { diff --git a/src/game.c b/src/game.c index be7e224b..b4465752 100644 --- a/src/game.c +++ b/src/game.c @@ -407,7 +407,7 @@ static void GameMain_ChangeRoom(void) { sub_0801855C(); } #elif defined(DEMO_JP) - if (gRoomTransition.field_0x2c[5]) + if (gRoomTransition.field_0x2c[4]) CheckAreaDiscovery(); if (gArea.inventoryGfxIdx != 0xff) { sub_0801855C(); diff --git a/src/interrupts.c b/src/interrupts.c index 5115c45a..c52df16b 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -14,7 +14,7 @@ extern u8 gUnk_03003DE0; extern u8 gUnk_03000C30; extern u8 gUpdateVisibleTiles; -extern Entity gUnk_03003BE0; +extern Entity gCarryEntities; extern Entity* gPlayerClones[3]; extern u16 gUnk_080B2CD8[]; @@ -334,7 +334,7 @@ void sub_080171F0(void) { gPlayerState.mobility = 0; gPlayerState.speed_modifier = 0; gPlayerState.field_0xaa = 0; - MemClear(&gUnk_03003BE0, 0x8c); + MemClear(&gCarryEntities, 0x8c); gPlayerEntity.spriteOffsetY = gPlayerState.field_0x3f; gPlayerState.field_0x3f = 0; sub_0807B0C8(); diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c index 96d8585e..5f20f8d7 100644 --- a/src/item/itemBomb.c +++ b/src/item/itemBomb.c @@ -29,7 +29,7 @@ void sub_08075FF8(ItemBehavior* this, u32 arg1) { } maxBombs = this->behaviorID == 7 ? 3 : 1; if (maxBombs > bombCount) { - entity = CreatePlayerBomb(this, 2); + entity = CreatePlayerItemWithParent(this, 2); if (entity != NULL) { tmp = &gUnk_0811BDAC[gPlayerEntity.animationState & 6]; // TODO fix array access @@ -41,8 +41,8 @@ void sub_08075FF8(ItemBehavior* this, u32 arg1) { } } } - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } -// TODO arg1 type not yet known, called by sub_080761C0 and sub_080762D8 +// TODO arg1 type not yet known, called by ItemPickupCheck and sub_080762D8 ASM_FUNC("asm/non_matching/itemBomb/sub_08076088.inc", void sub_08076088(ItemBehavior* this, void* arg1)) diff --git a/src/item/itemBoomerang.c b/src/item/itemBoomerang.c index eb6c67cc..9e402d00 100644 --- a/src/item/itemBoomerang.c +++ b/src/item/itemBoomerang.c @@ -15,7 +15,7 @@ void sub_08075D2C(ItemBehavior* this, u32 arg1) { sub_08077D38(this, arg1); gPlayerState.field_0x3[1] |= 8; } else { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } @@ -30,5 +30,5 @@ void sub_08075D88(ItemBehavior* this, u32 arg1) { return; } } - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } diff --git a/src/item/itemBow.c b/src/item/itemBow.c index 87e4544d..bc8244f9 100644 --- a/src/item/itemBow.c +++ b/src/item/itemBow.c @@ -16,7 +16,7 @@ void sub_08075DF4(ItemBehavior* this, u32 arg1) { sub_08077D38(this, arg1); gPlayerState.field_0x1f[2] = 1; } else { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } @@ -39,7 +39,7 @@ void sub_08075E40(ItemBehavior* this, u32 arg1) { } } gPlayerState.field_0x1f[2] = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } void sub_08075EC0(ItemBehavior* this, u32 arg1) { @@ -51,7 +51,7 @@ void sub_08075EC0(ItemBehavior* this, u32 arg1) { if (iVar2 != 0 && arrowCount != 0) { if (((gPlayerState.field_0x3[1] & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) { gPlayerState.field_0x1f[2] = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } else { gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa; @@ -70,7 +70,7 @@ void sub_08075F38(ItemBehavior* this, u32 arg1) { } } else { gPlayerState.field_0x1f[2] = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } @@ -86,5 +86,5 @@ void sub_08075F84(ItemBehavior* this, u32 arg1) { } } gPlayerState.field_0x1f[2] = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } diff --git a/src/item/itemDebug.c b/src/item/itemDebug.c index f8790cde..deec580d 100644 --- a/src/item/itemDebug.c +++ b/src/item/itemDebug.c @@ -1,9 +1,9 @@ #include "item.h" extern Entity* sub_08077BD4(ItemBehavior*); -extern void sub_08077E78(ItemBehavior*, u32); +extern void DeletePlayerItem(ItemBehavior*, u32); void ItemDebug(ItemBehavior* beh, u32 arg1) { sub_08077BD4(beh); - sub_08077E78(beh, arg1); + DeletePlayerItem(beh, arg1); } diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index 7393229f..ea3cd42d 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -18,12 +18,12 @@ void sub_08076DF4(ItemBehavior* this, u32 arg1) { this->field_0x5[5] = gPlayerEntity.animationState; this->field_0x5[4] |= 0x80; this->field_0x5[4]++; - gPlayerState.field_0x1d = 1; + gPlayerState.gustJarSpeed = 1; *(u32*)&gPlayerEntity.field_0x74 = 0; gPlayerState.field_0x1c = 1; sub_08077BB8(this); } else { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } @@ -31,7 +31,7 @@ void sub_08076E60(ItemBehavior* this, u32 arg1) { Entity* playerItem; if ((gPlayerState.field_0x1c & 0xf) == 0) { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } if ((this->field_0x5[9] & 0x80) != 0) { this->stateID = 2; @@ -48,18 +48,18 @@ void sub_08076E60(ItemBehavior* this, u32 arg1) { void sub_08076EC8(ItemBehavior* this, u32 arg1) { if ((gPlayerState.field_0x1c & 0xf) == 0) { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); return; } if (sub_08077EFC(this)) { u32 val; if (this->field_0x5[2] > 0xef) { - gPlayerState.field_0x1d = 3; + gPlayerState.gustJarSpeed = 3; } else if (++this->field_0x5[2] > 0x77) { - gPlayerState.field_0x1d = 2; + gPlayerState.gustJarSpeed = 2; } else { - gPlayerState.field_0x1d = 1; + gPlayerState.gustJarSpeed = 1; } if (gPlayerEntity.subAction == 0x1b) { @@ -93,7 +93,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { if (this->field_0x5[3]) { this->field_0x5[3] = 0; this->field_0x5[2] = 0; - gPlayerState.field_0x1d = 1; + gPlayerState.gustJarSpeed = 1; player = &gPlayerEntity; *(u32*)&player->field_0x74 = 0; gPlayerState.field_0x1c = 1; @@ -137,7 +137,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { if (this->field_0x5[9] & 1) { gPlayerState.field_0x1c = 5; gPlayerEntity.field_0x70.WORD = 0; - if (gPlayerState.field_0x1d) { + if (gPlayerState.gustJarSpeed) { CreatePlayerItem(0x11, 0, 0, 0); } } @@ -157,7 +157,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { case 7: sub_08077DF4(this, 0x514); gPlayerState.field_0x1c = 3; - gPlayerState.field_0x1d = 0; + gPlayerState.gustJarSpeed = 0; break; case 1: case 2: @@ -169,7 +169,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { case0: gPlayerState.field_0x1c = 0; gPlayerEntity.field_0x70.WORD = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); break; } } diff --git a/src/item/itemJarEmpty.c b/src/item/itemJarEmpty.c index 11a27fcc..c50dee06 100644 --- a/src/item/itemJarEmpty.c +++ b/src/item/itemJarEmpty.c @@ -62,7 +62,7 @@ void sub_08077640(ItemBehavior* this, u32 arg1) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } @@ -70,6 +70,6 @@ void sub_0807766C(ItemBehavior* this, u32 arg1) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } diff --git a/src/item/itemLantern.c b/src/item/itemLantern.c index e4aabd31..c05b8d01 100644 --- a/src/item/itemLantern.c +++ b/src/item/itemLantern.c @@ -27,7 +27,7 @@ void sub_08075A0C(ItemBehavior* this, u32 arg1) { ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); gPlayerState.flags &= ~PL_USE_LANTERN; ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } else { this->field_0x5[4] |= 0x80; sub_08077D38(this, arg1); @@ -79,7 +79,7 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { if (!(((sub_08077F10(this) == 0) && (itemSlot < 2)) || (gPlayerState.jump_status != 0))) { ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); gPlayerState.flags &= ~PL_USE_LANTERN; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); SoundReq(SFX_ITEM_LANTERN_OFF); } else { if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.frameIndex < 0x37)) && @@ -100,8 +100,8 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { } sub_08077DF4(this, 0x60c); bVar1 = (8 >> (arg1)); - gPlayerState.field_0xa = bVar1 | gPlayerState.field_0xa; - gPlayerState.keepFacing = bVar1 | gPlayerState.keepFacing; + gPlayerState.field_0xa |= bVar1; + gPlayerState.keepFacing |= bVar1; } } } diff --git a/src/item/itemMoleMitts.c b/src/item/itemMoleMitts.c index 355f69df..610c718f 100644 --- a/src/item/itemMoleMitts.c +++ b/src/item/itemMoleMitts.c @@ -41,7 +41,7 @@ void sub_08077130(ItemBehavior* this, u32 arg1) { this->stateID = 1; } } else { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); gPlayerState.field_0x3c[1] = 0; } } @@ -51,7 +51,7 @@ void sub_080771C8(ItemBehavior* this, u32 arg1) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); gPlayerState.field_0x3c[1] = 0; } else { if (((this->field_0x5[9] & 0x20) != 0) && (this->field_0x5[3] == 0xff)) { @@ -94,7 +94,7 @@ void sub_08077448(ItemBehavior* this, u32 arg1) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerState.field_0x3c[1] = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c index fff83945..a536d2d7 100644 --- a/src/item/itemOcarina.c +++ b/src/item/itemOcarina.c @@ -15,7 +15,7 @@ void ItemOcarina(ItemBehavior* this, u32 arg1) { void OcarinaUse(ItemBehavior* this, u32 arg1) { if (gPlayerState.queued_action == PLAYER_ROLL) { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } else { this->field_0x5[4] |= 0xf; gPlayerEntity.animationState = 0x04; @@ -44,7 +44,7 @@ NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBe gUnk_02034490.unk0 = 0; CreateBird(); ResetPlayerEventPriority(); - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } END_NONMATCH diff --git a/src/item/itemPacciCane.c b/src/item/itemPacciCane.c index 4ea479f5..ada5d308 100644 --- a/src/item/itemPacciCane.c +++ b/src/item/itemPacciCane.c @@ -18,10 +18,10 @@ void sub_08076C98(ItemBehavior* beh, u32 arg1) { void sub_08076CBC(ItemBehavior* beh, u32 arg1) { if ((beh->field_0x5[9] & 0x80) != 0) { - sub_08077E78(beh, arg1); + DeletePlayerItem(beh, arg1); } else { if ((beh->field_0x5[9] & 0x40) != 0) { - CreatePlayerBomb(beh, 0x12); + CreatePlayerItemWithParent(beh, 0x12); } UpdateItemAnim(beh); } diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index b361f0fe..2a32cfd9 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -26,7 +26,7 @@ void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { if (gPlayerEntity.field_0x7a.HWORD != 0) { gPlayerState.dash_state = 0; gPlayerState.field_0xe = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } else { bVar1 = this->field_0x5[2] - 1; this->field_0x5[2] = bVar1; @@ -78,7 +78,7 @@ void sub_080768F8(ItemBehavior* this, u32 arg1) { } else { gPlayerState.dash_state = 0; gPlayerState.field_0xe = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } @@ -95,7 +95,7 @@ void sub_08076964(ItemBehavior* this, u32 arg1) { if ((++gPlayerState.dash_state) == 0x1e) { if ((gPlayerState.flags & PL_FLAGS2) != 0) { gPlayerState.dash_state = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); return; } gPlayerState.dash_state = 0x40; @@ -105,7 +105,7 @@ void sub_08076964(ItemBehavior* this, u32 arg1) { (gPlayerState.skills & SKILL_DASH_ATTACK) != 0) { gPlayerState.field_0xab = 3; sub_08077DF4(this, 0x298); - bombEntity = CreatePlayerBomb(this, 0xc); + bombEntity = CreatePlayerItemWithParent(this, 0xc); if (bombEntity != NULL) { if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) { uVar3 = gSave.stats.itemButtons[SLOT_A]; @@ -127,7 +127,7 @@ void sub_08076964(ItemBehavior* this, u32 arg1) { } } gPlayerState.dash_state = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } void sub_08076A88(ItemBehavior* this, u32 arg1) { @@ -170,5 +170,5 @@ void sub_08076A88(ItemBehavior* this, u32 arg1) { } } gPlayerState.dash_state = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c index 3c94d851..486fc90e 100644 --- a/src/item/itemRocsCape.c +++ b/src/item/itemRocsCape.c @@ -55,7 +55,7 @@ void ItemRocsCape(ItemBehavior* this, u32 arg1) { } } } - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } void sub_08076758(ItemBehavior* this, u32 arg1) { @@ -84,6 +84,6 @@ void sub_08076758(ItemBehavior* this, u32 arg1) { } } } else { - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } diff --git a/src/item/itemShield.c b/src/item/itemShield.c index 6c5a0866..d8cd9ace 100644 --- a/src/item/itemShield.c +++ b/src/item/itemShield.c @@ -30,7 +30,7 @@ void sub_08076D34(ItemBehavior* beh, u32 arg1) { } } else { gPlayerState.field_0x3[0] = 0; - sub_08077E78(beh, arg1); + DeletePlayerItem(beh, arg1); } } @@ -40,6 +40,6 @@ void sub_08076D94(ItemBehavior* beh, u32 arg1) { UpdateItemAnim(beh); } else { gPlayerState.field_0x3[0] = 0; - sub_08077E78(beh, arg1); + DeletePlayerItem(beh, arg1); } } diff --git a/src/item/itemSword.c b/src/item/itemSword.c index cce1e02f..f55a1275 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -107,7 +107,7 @@ void sub_080754B8(ItemBehavior* this, u32 arg1) { if (gPlayerEntity.frameSpriteSettings & 1) { iVar1 = sub_0807B014(); if (iVar1 && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) { - CreatePlayerBomb(this, 0xf); + CreatePlayerItemWithParent(this, 0xf); if (iVar1 == 0xf) { gPlayerState.field_0xab = 5; } else { @@ -228,7 +228,7 @@ void sub_08075738(ItemBehavior* this, u32 arg1) { } else { if (((((gPlayerEntity.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && ((gPlayerState.skills & SKILL_FOURSWORD) != 0))) { - Entity* bombEnt = CreatePlayerBomb(this, 0x14); + Entity* bombEnt = CreatePlayerItemWithParent(this, 0x14); if (bombEnt) { bombEnt->animationState = (gPlayerEntity.animationState & 6) | 0x80; } @@ -313,5 +313,5 @@ void sub_080759B8(ItemBehavior* this, u32 arg1) { gPlayerState.flags &= ~PL_SWORD_THRUST; gPlayerState.sword_state = 0; gPlayerState.item = NULL; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index 1eb0c3e2..c4addc70 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -9,7 +9,7 @@ void ItemTryPickupObject(ItemBehavior* this, u32 arg1) { gUnk_0811BDB4[this->stateID](this, arg1); } -ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080761C0.inc", void sub_080761C0(ItemBehavior* this, u32 arg1)) +ASM_FUNC("asm/non_matching/itemTryPickupObject/ItemPickupCheck.inc", void ItemPickupCheck(ItemBehavior* this, u32 arg1)) void sub_080762C4(ItemBehavior* this, u32 arg1, u8 arg2, u32 arg3) { this->field_0x18 = arg1; @@ -61,6 +61,6 @@ void sub_0807660C(ItemBehavior* this, u32 arg1) { UpdateItemAnim(this); if ((--this->field_0x5[2] == 0xff) || (gPlayerState.field_0x0[1] == 0)) { gPlayerState.field_0x0[1] = 0; - sub_08077E78(this, arg1); + DeletePlayerItem(this, arg1); } } diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c index 92a56415..ae167838 100644 --- a/src/manager/manager1A.c +++ b/src/manager/manager1A.c @@ -137,8 +137,8 @@ u32 sub_0805B1CC(Manager1A* this) { u32 re = 0; if (CheckPlayerProximity(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) { if ((gPlayerState.flags & PL_DROWNING) && (gPlayerState.flags & PL_BUSY)) { - gPlayerState.flags |= PL_FLAGS8000; - } else if (gPlayerState.flags & PL_FLAGS8000) { + gPlayerState.flags |= PL_PIT_IS_EXIT; + } else if (gPlayerState.flags & PL_PIT_IS_EXIT) { re = 1; } } diff --git a/src/menu/kinstone_menu.c b/src/menu/kinstone_menu.c index 45850f4d..2643eb57 100644 --- a/src/menu/kinstone_menu.c +++ b/src/menu/kinstone_menu.c @@ -80,7 +80,7 @@ void Subtask_KinstoneMenu(void) { KinstoneMenu_Type3, KinstoneMenu_Type4, KinstoneMenu_Type5, }; #if !(defined(DEMO_USA) || defined(DEMO_JP)) - gRoomTransition.player_status.field_0x24[8] = 2; + gRoomTransition.entity_update_type = 2; FlushSprites(); kinstoneMenuTypes[gMenu.menuType](); sub_080A3B74(); @@ -90,7 +90,7 @@ void Subtask_KinstoneMenu(void) { UpdateEntities(); DrawEntities(); CopyOAM(); - gRoomTransition.player_status.field_0x24[8] = 0; + gRoomTransition.entity_update_type = 0; #endif } diff --git a/src/npc/beedle.c b/src/npc/beedle.c index ee5a33ac..ab3d2bae 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -67,7 +67,7 @@ void sub_0806336C(Entity* this) { void sub_08063390(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; InitializeAnimation(this, GetAnimationState(this)); sub_08078778(this); diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index e916f2c1..a8ab63b5 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -53,7 +53,7 @@ void sub_08068A1C(Entity* this) { int offset; this->type2 = this->type; - if (gRoomTransition.player_status.field_0x24[8] != 0) { + if (gRoomTransition.entity_update_type != 0) { offset = 6; bVar1 = 3; @@ -105,7 +105,7 @@ void sub_08068AA4(Entity* this) { } void sub_08068ADC(Entity* this) { - if (gRoomTransition.player_status.field_0x24[8] == 2) { + if (gRoomTransition.entity_update_type == 2) { GetNextFrame(this); } sub_0806FD3C(this); @@ -146,7 +146,7 @@ void sub_08068B84(Entity* this) { if (p = this->actionDelay, gUnk_08111618[p]) { ForceEquipItem(gUnk_08111618[this->actionDelay], 0); } - sub_0805ED14(gUnk_081115EC[this->actionDelay]); + InitPlayerMacro(gUnk_081115EC[this->actionDelay]); } void sub_08068BB4(Entity* this) { diff --git a/src/npc/brocco.c b/src/npc/brocco.c index 176f1e42..3ee53bcd 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -47,7 +47,7 @@ void sub_08063584(Entity* this) { if (this->field_0xf != 0) { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0xf = 0; } } diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index 189c10c0..9d5e8567 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -32,7 +32,7 @@ void CastorWildsStatue(Entity* this) { } void sub_080673C0(Entity* this) { - if (gRoomTransition.player_status.field_0x24[8] != 0) { + if (gRoomTransition.entity_update_type != 0) { this->action = 3; } else { this->action = 1; diff --git a/src/npc/cat.c b/src/npc/cat.c index 9de7337d..8ff4860d 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -102,7 +102,7 @@ void sub_080678AC(Entity* this) { sub_08067AAC(this); } else { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { sub_08067B34(this); } } @@ -137,7 +137,7 @@ void sub_08067904(Entity* this) { void sub_0806797C(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_08067B08(this); } } @@ -166,7 +166,7 @@ void sub_08067A0C(Entity* this) { u8 tmp; UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (sub_08067D20(this) != 0) { sub_08067B80(this, 5); this->actionDelay = this->actionDelay + 0x14; @@ -186,7 +186,7 @@ void sub_08067A0C(Entity* this) { void sub_08067A78(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_08067AAC(this); } } diff --git a/src/npc/cucco.c b/src/npc/cucco.c index 73b17303..254fbcbb 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -78,7 +78,7 @@ void Cucco_Idle(Entity* this) { InitAnimationForceUpdate(this, (Random() & 1) + 2); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 1; this->subAction = 0; } diff --git a/src/npc/dog.c b/src/npc/dog.c index b5924d68..e54e6477 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -119,7 +119,7 @@ void sub_08069D00(Entity* this) { this->field_0x6a.HALF.HI = 8; sub_0806A028(this); if (0x1f < this->animIndex) { - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return; } this->field_0x6a.HALF.HI = 8; @@ -197,7 +197,7 @@ void sub_08069E50(Entity* this) { sub_0806A028(this); UpdateAnimationSingleFrame(this); if (this->animIndex > 0x1f) { - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return; } this->field_0x6a.HALF.HI = 8; diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index d4798164..ba3005a6 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -40,7 +40,7 @@ void sub_0806BFD8(Entity* this) { } void sub_0806C00C(Entity* this, ScriptExecutionContext* context) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { context->condition = 1; } else { context->condition = 0; diff --git a/src/npc/festari.c b/src/npc/festari.c index 2af31802..8dbc8274 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -45,7 +45,7 @@ void sub_0805FE48(Entity* this) { } UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { switch (this->animIndex) { case 8: case 10: diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index a0d29023..9a0cf266 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -25,7 +25,7 @@ void GoronMerchant(Entity* this) { } void sub_08069584(Entity* this) { - if (gRoomTransition.player_status.field_0x24[8] != 0) { + if (gRoomTransition.entity_update_type != 0) { this->action = 3; } else { this->action = 1; @@ -59,7 +59,7 @@ void sub_080695E8(Entity* this) { } void sub_0806961C(Entity* this) { - if (gRoomTransition.player_status.field_0x24[8] == 2) { + if (gRoomTransition.entity_update_type == 2) { UpdateAnimationSingleFrame(this); } sub_0806FD3C(this); diff --git a/src/npc/gregal.c b/src/npc/gregal.c index d503f209..7dfd3ada 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -97,7 +97,7 @@ void sub_0806CC08(Entity* this) { } void sub_0806CCB4(Entity* this, ScriptExecutionContext* context) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { context->condition = 1; } else { context->condition = 0; diff --git a/src/npc/mailbox.c b/src/npc/mailbox.c index 755e0b2c..1f7c7835 100644 --- a/src/npc/mailbox.c +++ b/src/npc/mailbox.c @@ -40,7 +40,7 @@ void sub_08063220(Entity* this) { void sub_08063254(Entity* this, u32 unused) { sub_08063280(this, unused); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 3; MessageFromTarget(0); } diff --git a/src/npc/mama.c b/src/npc/mama.c index 57290d94..210bce90 100644 --- a/src/npc/mama.c +++ b/src/npc/mama.c @@ -61,7 +61,7 @@ void Mama_Head(Entity* this) { void sub_0806C4A8(Entity* this, ScriptExecutionContext* context) { s32 tmp; - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { tmp = GetAnimationState(this); if (tmp < 0) { tmp = 3; diff --git a/src/npc/minishEzlo.c b/src/npc/minishEzlo.c index 5216a19f..d501f60f 100644 --- a/src/npc/minishEzlo.c +++ b/src/npc/minishEzlo.c @@ -34,7 +34,7 @@ void sub_0806305C(Entity* this) { this->spriteRendering.b0 = 3; *(u32*)&this->field_0x6c = 0x100; this->field_0x70.WORD = 0x100; - sub_0805EC9C(this, 0x100, 0x100, 0x0); + SetAffineInfo(this, 0x100, 0x100, 0x0); InitAnimationForceUpdate(this, 0x10); this->field_0x80.HWORD = 0x10; SoundReq(SFX_PLY_SHRINKING); diff --git a/src/npc/npc5.c b/src/npc/npc5.c index 2f8ae154..574527d4 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -270,7 +270,7 @@ void sub_08060D78(Entity* this) { void sub_08060DD0(Entity* this) { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 1; sub_08060E70(this, 0); } @@ -296,7 +296,7 @@ void sub_08060DFC(Entity* this) { void sub_08060E34(Entity* this) { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 2; this->animationState = DirectionToAnimationState(GetFacingDirection(this, &gPlayerEntity)) * 2; sub_08060E70(this, 8); @@ -323,7 +323,7 @@ void sub_08060E94(Entity* this) { void sub_08060EDC(Entity* this) { s32 tmp; - if (((u32)this->animIndex - 0x20 < 0x10) && ((this->frame & 0x80) == 0)) { + if (((u32)this->animIndex - 0x20 < 0x10) && ((this->frame & ANIM_DONE) == 0)) { UpdateAnimationSingleFrame(this); } else { tmp = GetFacingDirection(this, &gPlayerEntity) + this->animationState * -4; @@ -337,7 +337,7 @@ void sub_08060EDC(Entity* this) { } } else { if ((this->animationState & 1) == 0) { - if (((this->frame & 0x80) != 0) && (0xf >= (u32)this->animIndex - 0x20)) { + if (((this->frame & ANIM_DONE) != 0) && (0xf >= (u32)this->animIndex - 0x20)) { sub_08060E70(this, 0); } else { sub_08060E94(this); @@ -528,7 +528,7 @@ u32 sub_08061230(Entity* this) { } } else { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return 1; } ((UnkHeap*)this->myHeap)->unk_0 &= 0xfe; @@ -551,7 +551,7 @@ void sub_08061358(Entity* this) { switch (this->subAction) { case 0: UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return; } this->subAction = 1; @@ -576,7 +576,7 @@ void sub_08061358(Entity* this) { break; case 2: UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { return; } this->animationState = ((this->frame & 0x18) >> 2); @@ -914,7 +914,7 @@ void sub_08061B58(Entity* this) { this->action = 1; InitAnimationForceUpdate(this, 2); } - if (gRoomTransition.player_status.field_0x24[8] == 2) { + if (gRoomTransition.entity_update_type == 2) { UpdateAnimationSingleFrame(this); } sub_0806FD3C(this); diff --git a/src/npc/npc9.c b/src/npc/npc9.c index df8cc07e..6e1ff9f6 100644 --- a/src/npc/npc9.c +++ b/src/npc/npc9.c @@ -29,7 +29,7 @@ void sub_08062B14(Entity* this) { void sub_08062B48(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { MessageFromTarget(0xa01); // invalid this->action++; } diff --git a/src/npc/pina.c b/src/npc/pina.c index d4eea09e..e1ea0e4b 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -49,7 +49,7 @@ void sub_08063AC0(Entity* this) { if (this->field_0xf != 0) { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->field_0xf = 0; } } diff --git a/src/npc/rem.c b/src/npc/rem.c index 3353060d..2315efbd 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -73,7 +73,7 @@ void sub_0806A410(Entity* this) { } break; case 1: - if (((this->frame & 0x80) != 0)) { + if (((this->frame & ANIM_DONE) != 0)) { sub_0806A9B0(this, *(ScriptExecutionContext**)&this->cutsceneBeh); } break; @@ -88,14 +88,14 @@ void sub_0806A458(Entity* this) { } break; case 1: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->subAction = 2; InitializeAnimation(this, 10); ClearLocalFlag(0x62); } break; case 2: - if (((this->frame & 0x80) != 0)) { + if (((this->frame & ANIM_DONE) != 0)) { this->action = 1; this->subAction = 0; this->actionDelay = 0x3c; @@ -108,7 +108,7 @@ void sub_0806A458(Entity* this) { void sub_0806A4CC(Entity* this) { switch (this->subAction) { case 0: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { if ((u8)(this->animIndex - 8) < 2) { this->subAction = 1; this->field_0x6a.HWORD = 1; @@ -120,7 +120,7 @@ void sub_0806A4CC(Entity* this) { } break; case 1: - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->subAction = 2; InitializeAnimation(this, GetAnimationState(this)); } @@ -143,7 +143,7 @@ void sub_0806A550(Entity* this) { gActiveScriptInfo.syncFlags |= 0x100; SoundReq(SFX_CHEST_OPEN); } - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 5; this->subAction = 0; InitializeAnimation(this, 0xd); @@ -157,7 +157,7 @@ void nullsub_503(Entity* this) { void sub_0806A5C0(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { InitializeAnimation(this, (Random() & 3) + 4); } } @@ -301,7 +301,7 @@ void sub_0806A890(Entity* this) { SetDefaultPriority(this, PRIO_MESSAGE); } GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/npc/smith.c b/src/npc/smith.c index 02f9c472..ae4394dd 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -104,7 +104,7 @@ void sub_080661B0(Entity* this) { void sub_080661BC(Entity* this) { if (this->animIndex == 0xc) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->field_0x80.HWORD = GetAnimationState(this) + 8; InitAnimationForceUpdate(this, this->field_0x80.HWORD); } diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 7f7ffa88..93914b00 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -70,7 +70,7 @@ void sub_0806AC3C(Entity* this) { if (!(this->field_0x68.HALF.HI & 7)) { this->animationState = sub_0806F5B0(this->field_0x68.HALF.HI); - InitializeAnimation(this, (this->animationState / 2) ^ 2); + InitializeAnimation(this, AnimationStateFlip90(this->animationState / 2)); } } diff --git a/src/npc/vaatiReborn.c b/src/npc/vaatiReborn.c index fb59284e..5209022d 100644 --- a/src/npc/vaatiReborn.c +++ b/src/npc/vaatiReborn.c @@ -130,7 +130,7 @@ void VaatiRebornAction1(Entity* this) { } break; case 1: - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->subAction = 2; ChangeObjPalette(this, 0x13f); InitAnimationForceUpdate(this, this->subAction - 1); @@ -153,7 +153,7 @@ void VaatiRebornAction1(Entity* this) { } break; case 3: - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { SetRoomFlag(0); DeleteThisEntity(); } diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 46187a72..0b67a4a8 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -152,7 +152,7 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) { break; case 4: UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { gActiveScriptInfo.flags |= 1; return; } diff --git a/src/npcUtils.c b/src/npcUtils.c index 3c042b23..2bd9564a 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -178,7 +178,7 @@ u32 sub_0806EED0(Entity* ent) { } u32 sub_0806EEF4(Entity* ent) { - if (ent->frame & 0x80) + if (ent->frame & ANIM_DONE) return sub_0806EF74(ent, 1); return 0; } diff --git a/src/object/angryStatue.c b/src/object/angryStatue.c index 097f4626..d3fbe01d 100644 --- a/src/object/angryStatue.c +++ b/src/object/angryStatue.c @@ -55,7 +55,7 @@ void AngryStatue_Action2(Entity* this) { EnqueueSFX(SFX_EC); } - } else if ((this->frame & 0x80) != 0) { + } else if ((this->frame & ANIM_DONE) != 0) { this->action = 1; InitializeAnimation(this, this->type); } diff --git a/src/object/beanstalk.c b/src/object/beanstalk.c index 729d0fe0..5dace1cc 100644 --- a/src/object/beanstalk.c +++ b/src/object/beanstalk.c @@ -169,7 +169,7 @@ void Beanstalk_Action1Type0(BeanstalkEntity* this) { void Beanstalk_Action1Type0SubAction0(BeanstalkEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { if (super->actionDelay < 2) { super->actionDelay++; } else { @@ -186,7 +186,7 @@ void Beanstalk_Action1Type0SubAction1(BeanstalkEntity* this) { SoundReq(SFX_198); } UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { Entity* entity = CreateObject(BEANSTALK, 1, 0); super->child = entity; if (entity != NULL) { @@ -228,7 +228,7 @@ void Beanstalk_Action1Type2(BeanstalkEntity* this) { super->actionDelay = 0; } } - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->child = CreateObject(BEANSTALK, 3, 0); if (super->child != NULL) { super->child->x.HALF.HI = super->x.HALF.HI; @@ -242,7 +242,7 @@ void Beanstalk_Action1Type2(BeanstalkEntity* this) { } void Beanstalk_Action1Type4(BeanstalkEntity* this) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { GetNextFrame(super); } } @@ -290,7 +290,7 @@ void Beanstalk_Action1Type7(BeanstalkEntity* this) { super->actionDelay = 0; } GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { InitializeAnimation(super, (super->type2 - 1) * 3 + 1); } break; diff --git a/src/object/bigIceBlock.c b/src/object/bigIceBlock.c index 09407bc4..79df9f91 100644 --- a/src/object/bigIceBlock.c +++ b/src/object/bigIceBlock.c @@ -87,7 +87,7 @@ void BigIceBlock_Action2(BigIceBlockEntity* this) { super->actionDelay += 1; } tmp = gUnk_081237B0[super->actionDelay >> 5]; - sub_0805EC9C(super, 0x100, tmp, 0); + SetAffineInfo(super, 0x100, tmp, 0); if (super->type != 1) { if (super->type != 2) { SetFlag(this->unk_86); @@ -114,7 +114,7 @@ void sub_08099880(BigIceBlockEntity* this) { sub_08099C18(this); } uVar4 = (0x3c - super->actionDelay) * 0x20 + 0x100; - sub_0805EC9C(super, 0x100, uVar4, 0); + SetAffineInfo(super, 0x100, uVar4, 0); sub_0806FCF4(super, uVar4, 2, 0); obj = CreateObject(SPECIAL_FX, 0x11, 0x40); if (obj != NULL) { diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c index 5c36d40b..23aa475f 100644 --- a/src/object/bigPushableLever.c +++ b/src/object/bigPushableLever.c @@ -70,7 +70,7 @@ void BigPushableLever_Idle(BigPushableLeverEntity* this) { void BigPushableLever_Pushing(BigPushableLeverEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { if (super->type2 == 0) { SetFlag(this->pushedFlag); } else { diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index 69260c5b..323cbf0b 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -91,7 +91,7 @@ void sub_08098E3C(Entity* this) { InitAnimationForceUpdate(this, this->type); } temp = &gUnk_08123690[this->type & 2]; - sub_0805EC9C(this, temp[0], temp[1], 0); + SetAffineInfo(this, temp[0], temp[1], 0); UpdateAnimationSingleFrame(this); } diff --git a/src/object/bird.c b/src/object/bird.c index cafe1262..f16d46b5 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -131,7 +131,7 @@ void sub_0809D178(Entity* this) { UpdateSpriteForCollisionLayer(this); this->frame = 0x80; } - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { InitializeAnimation(this, Random() & 3); this->frameDuration = (Random() & 0xf) + 0x10; this->spriteSettings.flipX = FALSE; diff --git a/src/object/bollard.c b/src/object/bollard.c index 3a7d13b7..1c6a8bda 100644 --- a/src/object/bollard.c +++ b/src/object/bollard.c @@ -59,7 +59,7 @@ void sub_0808B2CC(BollardEntity* this) { void sub_0808B324(BollardEntity* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { sub_0808B42C(this); } } @@ -80,7 +80,7 @@ void sub_0808B344(BollardEntity* this) { void sub_0808B38C(BollardEntity* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { sub_0808B41C(this); } } diff --git a/src/object/bossDoor.c b/src/object/bossDoor.c index 5b1bd36d..0d1844e1 100644 --- a/src/object/bossDoor.c +++ b/src/object/bossDoor.c @@ -93,7 +93,7 @@ void BossDoor_Action1(BossDoorEntity* this) { } void BossDoor_Action2(BossDoorEntity* this) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { if ((gRoomTransition.frameCount & 3) == 0) { SoundReq(SFX_185); } diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index a7890edb..a7072aa7 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -162,7 +162,7 @@ void ChestSpawner_Type2Action3(ChestSpawnerEntity* this) { void ChestSpawner_Type2Action4(ChestSpawnerEntity* this) { sub_0800445C(super); GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { if (--super->field_0xf == 0) { if (super->actionDelay == 0x18) { super->action = 6; diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 13652224..52fe70db 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -133,7 +133,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { u32 tmp; if ((super->type & 1) != 0) { if (super->type == 3) { - sub_08078930(super); + RegisterCarryEntity(super); sub_0800445C(super); } else { PositionRelative(super->parent, super, -0x1c0000, -0x280000); @@ -159,7 +159,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { super->spriteRendering.b3 = parent->spriteRendering.b3; super->spriteOrientation.flipY = parent->spriteOrientation.flipY; } - sub_0805EC9C(super, 0xcc, 0xcc, 0); + SetAffineInfo(super, 0xcc, 0xcc, 0); } else { gPlayerState.mobility |= 0x80; gPlayerState.heldObject = 5; @@ -177,7 +177,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { gUnk_0200AF00.unk_2f = 0; } PositionRelative(&gPlayerEntity, super, 0, 0x10000); - if (sub_080B1AA8(super) == 0x19) { + if (GetTileUnderEntity(super) == 0x19) { sub_0807BA8C(0xdc, super->collisionLayer); sub_08096A78(this); } @@ -228,7 +228,7 @@ void CrenelBeanSprout_Action2SubAction3(CrenelBeanSproutEntity* this) { void CrenelBeanSprout_Action3(CrenelBeanSproutEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action++; InitializeAnimation(super, 10); } diff --git a/src/object/deathFx.c b/src/object/deathFx.c index 4fe5ccb9..dee32ccc 100644 --- a/src/object/deathFx.c +++ b/src/object/deathFx.c @@ -49,7 +49,7 @@ void DeathFx_Action0(DeathFxObject* this) { tmp = super->actionDelay; super->actionDelay = 0; } - sub_0805EC9C(super, tmp, tmp, 0); + SetAffineInfo(super, tmp, tmp, 0); LoadSwapGFX(super, 4, 0); InitAnimationForceUpdate(super, 0); SoundReq(SFX_BOSS_EXPLODE); @@ -80,7 +80,7 @@ void DeathFx_Action0(DeathFxObject* this) { void DeathFx_Action1(DeathFxObject* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { sub_08081790(this); DeathFx_Delete(this); } else { @@ -92,7 +92,7 @@ void DeathFx_Action1(DeathFxObject* this) { void DeathFx_Action2(DeathFxObject* this) { UpdateAnimationSingleFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { DeathFx_Delete(this); } else { if ((super->frame & 1) != 0) { diff --git a/src/object/eyeSwitch.c b/src/object/eyeSwitch.c index 125e68fe..769a2cdf 100644 --- a/src/object/eyeSwitch.c +++ b/src/object/eyeSwitch.c @@ -56,7 +56,7 @@ void sub_08088718(EyeSwitchEntity* this) { void sub_08088760(EyeSwitchEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 3; this->unk70 = super->actionDelay << 1; InitializeAnimation(super, super->animationState + 4); @@ -78,7 +78,7 @@ void sub_08088790(EyeSwitchEntity* this) { void sub_080887D8(EyeSwitchEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 1; COLLISION_ON(super); InitializeAnimation(super, super->animationState); diff --git a/src/object/ezloCap.c b/src/object/ezloCap.c index e36a09cf..1a0d8894 100644 --- a/src/object/ezloCap.c +++ b/src/object/ezloCap.c @@ -152,7 +152,7 @@ void EzloCap_Type1Action1(EzloCapEntity* this) { } } } - } else if ((super->frame & 0x80) != 0) { + } else if ((super->frame & ANIM_DONE) != 0) { super->actionDelay = Random() & 3; if (super->actionDelay != 0) { super->spriteSettings.flipX = Random() & 1; @@ -203,7 +203,7 @@ void sub_08082C5C(EzloCapEntity* this) { } break; case 2: - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { InitAnimationForceUpdate(super, gUnk_0811F18C[Random() & 3] + (Random() & 3)); return; } @@ -292,7 +292,7 @@ void EzloCap_ScriptedAction2(EzloCapEntity* this) { void EzloCap_ScriptedAction3(EzloCapEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 1; super->subAction = 0; super->spriteOffsetX = 0; diff --git a/src/object/fan.c b/src/object/fan.c index 890689e9..d372ff5c 100644 --- a/src/object/fan.c +++ b/src/object/fan.c @@ -81,7 +81,7 @@ void Fan_Action2(FanEntity* this) { void Fan_Action3(FanEntity* this) { sub_0809F08C(this); sub_0809EE44(this); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { sub_0809EE34(this); } } diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index 3ae836d1..df7dbdc5 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -197,7 +197,7 @@ void FigurineDevice_Action3(FigurineDeviceEntity* this) { GetNextFrame(super); switch (this->unk_7a) { case 0: - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { this->unk_7a = 1; super->actionDelay = 0x28; ChangeObjPalette(super, gUnk_08120AA8[super->type2]); @@ -207,7 +207,7 @@ void FigurineDevice_Action3(FigurineDeviceEntity* this) { break; case 1: - if (((super->frame & 0x80) != 0) && (--super->actionDelay == 0)) { + if (((super->frame & ANIM_DONE) != 0) && (--super->actionDelay == 0)) { this->unk_7a = 2; SetRoomFlag(2); MenuFadeIn(7, super->field_0xf); diff --git a/src/object/frozenWaterElement.c b/src/object/frozenWaterElement.c index c0019201..7d3bd4c7 100644 --- a/src/object/frozenWaterElement.c +++ b/src/object/frozenWaterElement.c @@ -47,12 +47,12 @@ void sub_0809BECC(FrozenWaterElementEntity* this) { super->frameIndex = 0; super->spriteRendering.b0 = 3; sub_0809C0A8(this); - sub_0805EC9C(super, 0xcc, 0xcc, 0); + SetAffineInfo(super, 0xcc, 0xcc, 0); } } void sub_0809BF1C(FrozenWaterElementEntity* this) { - sub_0805EC9C(super, 0xcc, 0xcc, 0); + SetAffineInfo(super, 0xcc, 0xcc, 0); if (CheckFlags(OUGONTEKI_G)) { Entity* obj = CreateObject(OBJECT_90, 0, 0); if (obj != NULL) { @@ -88,7 +88,7 @@ void sub_0809BF74(FrozenWaterElementEntity* this) { if (this->unk_74 < 0x78) { tmp2 = ((0x78 - this->unk_74) << 5); tmp2 += 0xcc; - sub_0805EC9C(super, ((0x78 - this->unk_74) << 4) + 0xcc, tmp2, 0); + SetAffineInfo(super, ((0x78 - this->unk_74) << 4) + 0xcc, tmp2, 0); sub_0806FCF4(super, tmp2, 8, 0); super->spriteOffsetY += 8; } diff --git a/src/object/gentariCurtains.c b/src/object/gentariCurtains.c index e3ff7b3a..eed470dc 100644 --- a/src/object/gentariCurtains.c +++ b/src/object/gentariCurtains.c @@ -27,7 +27,7 @@ void sub_080921F0(GentariCurtainEntity* this); void sub_08092214(GentariCurtainEntity* this); extern Entity gUnk_030011E8[7]; -extern Entity gUnk_03003BE0; +extern Entity gCarryEntities; void GentariCurtain(Entity* this) { static void (*const actionFuncs[])(GentariCurtainEntity*) = { @@ -76,7 +76,7 @@ void sub_0809214C(GentariCurtainEntity* this) { void sub_08092164(GentariCurtainEntity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 3; SetTile(this->tileIndex, this->tile, 1); SetTile(this->tileIndex2, this->tile2, 1); diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index a03d9344..ffbfe2a6 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -173,7 +173,7 @@ void GreatFairy_WingsInit(Entity* this) { gScreen.controls.layerFXControl = 0xF40; gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 8); this->speed = 1024; - sub_0805EC9C(this, 1024, 256, 0); + SetAffineInfo(this, 1024, 256, 0); } void GreatFairy_WingsUpdate(Entity* this) { @@ -184,7 +184,7 @@ void GreatFairy_WingsUpdate(Entity* this) { gRoomVars.animFlags |= 32; gActiveScriptInfo.syncFlags |= 4; } else { - sub_0805EC9C(this, this->speed, 256, 0); + SetAffineInfo(this, this->speed, 256, 0); } } @@ -273,7 +273,7 @@ void GreatFairy_MiniAffineInit2(Entity* this) { this->actionDelay = 90; this->speed = 4096; this->spriteRendering.b0 = 3; - sub_0805EC9C(this, 256, 256, 0); + SetAffineInfo(this, 256, 256, 0); } } @@ -285,7 +285,7 @@ void GreatFairy_MiniAffineUpdate(Entity* this) { sub_0805EC60(this); } else { this->speed -= 24; - sub_0805EC9C(this, 256, this->speed >> 4, 0); + SetAffineInfo(this, 256, this->speed >> 4, 0); } } @@ -304,7 +304,7 @@ void GreatFairy_DropletInit(Entity* this) { void GreatFairy_DropletUpdate(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { DeleteEntity(this); } } @@ -370,7 +370,7 @@ void GreatFairy_EnergyInit(Entity* this) { void GreatFairy_EnergyUpdate(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { DeleteEntity(this); } } diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c index a81709c4..421990cb 100644 --- a/src/object/heartContainer.c +++ b/src/object/heartContainer.c @@ -47,7 +47,7 @@ static void sub_0808E714(Entity* this) { int var0 = 0x400 - this->field_0xf * 8; if (var0 > 0x100) { this->field_0xf++; - sub_0805EC9C(this, var0, var0, 0); + SetAffineInfo(this, var0, var0, 0); } else { this->action = 3; this->field_0x3c |= 0x10; diff --git a/src/object/jailBars.c b/src/object/jailBars.c index 9983eb1c..3a4abc9b 100644 --- a/src/object/jailBars.c +++ b/src/object/jailBars.c @@ -5,7 +5,7 @@ #include "sound.h" #include "functions.h" -extern void sub_080A0960(Entity*, u32); +static void SetJailBarTiles(Entity*, u32); extern void (*const gUnk_08124950[])(Entity*); extern u16 gUnk_08124960[]; @@ -18,11 +18,11 @@ void JailBars(Entity* this) { void sub_080A08C4(Entity* this) { if (CheckFlags(this->field_0x86.HWORD) == 0) { this->action = 1; - sub_080A0960(this, 0); + SetJailBarTiles(this, 0); } else { this->action = 3; InitializeAnimation(this, 1); - sub_080A0960(this, 1); + SetJailBarTiles(this, 1); } this->spriteSettings.draw = 3; // ??? this->collisionLayer = 1; @@ -32,14 +32,14 @@ void sub_080A08C4(Entity* this) { void sub_080A0910(Entity* this) { if (CheckFlags(this->field_0x86.HWORD) != 0) { this->action = 2; - sub_080A0960(this, 1); + SetJailBarTiles(this, 1); SoundReq(SFX_10B); } } void sub_080A0938(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; InitializeAnimation(this, 1); } @@ -48,7 +48,7 @@ void sub_080A0938(Entity* this) { void nullsub_127(Entity* this) { } -void sub_080A0960(Entity* this, u32 arg1) { +static void SetJailBarTiles(Entity* this, u32 arg1) { u16* puVar1; puVar1 = gUnk_08124960; diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index 8576cfa8..56338844 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -95,7 +95,7 @@ void LavaPlatform_Type0Action2(LavaPlatformEntity* this) { (super->child)->spriteOffsetY = 0; InitializeAnimation(super->child, super->child->animationState); CreateFx(super, FX_LAVA_SPLASH_HUGE, 0); - } else if ((super->zVelocity < 0x18000) && ((super->frame & 0x80) == 0)) { + } else if ((super->zVelocity < 0x18000) && ((super->frame & ANIM_DONE) == 0)) { UpdateAnimationSingleFrame(super); } } @@ -169,7 +169,7 @@ void LavaPlatform_Type1Action4(LavaPlatformEntity* this) { } if (this->timer < 0x8d) { GetNextFrame(super); - tmp = super->frame & 0x80; + tmp = super->frame & ANIM_DONE; if (tmp) { // Platform sank super->action = 5; @@ -216,7 +216,7 @@ void LavaPlatform_Type1Action6(LavaPlatformEntity* this) { super->flags |= ENT_COLLIDE; super->hitType = 0xac; } else { - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { sub_0809264C(this); if (tmp) { gPlayerState.field_0x3f = 0xfd; diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index d7f653df..a7fd4209 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -124,7 +124,7 @@ void sub_08085A98(LilypadLargeEntity* this) { sub_08085F1C(this); if (0x7fffff < (u32)this->unk_78.WORD) { this->unk_78.WORD -= 0x20000; - sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); } if (sub_080B1A8C(super, 0, 0x18) != 0x11) { super->subAction = 2; @@ -148,7 +148,7 @@ void sub_08085B40(LilypadLargeEntity* this) { if (GravityUpdate(super, 0x2000) != 0) { if ((u32)this->unk_78.WORD < 0x1200000) { this->unk_78.WORD += 0x100000; - sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); } gPlayerEntity.y.HALF.HI = (super->y.HALF.HI + super->z.HALF.HI) - this->unk_74; if (gArea.locationIndex == 0x1b) { @@ -159,7 +159,7 @@ void sub_08085B40(LilypadLargeEntity* this) { } } else { ResetCollisionLayer(super); - if (sub_080B1AA8(super) == 0xd) { + if (GetTileUnderEntity(super) == 0xd) { ResetCollisionLayer(&gPlayerEntity); sub_08085CDC(this); super->direction = GetFacingDirection(&gPlayerEntity, super); @@ -181,7 +181,7 @@ void sub_08085B40(LilypadLargeEntity* this) { super->actionDelay |= 0x80; this->unk_70 = 0; this->unk_6c = 0; - if (sub_080B1AA8(super) == 0xd) { + if (GetTileUnderEntity(super) == 0xd) { super->action = 4; } } @@ -214,7 +214,7 @@ void sub_08085C5C(LilypadLargeEntity* this) { void sub_08085CDC(LilypadLargeEntity* this) { this->unk_78.WORD += 0x100000; if (this->unk_78.WORD_U < 0x4000000) { - sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); } else { DeleteThisEntity(); } @@ -381,5 +381,5 @@ void sub_08085F48(LilypadLargeEntity* this) { } } } - sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); } diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index c8cf76f1..ce03ff99 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -59,5 +59,5 @@ static void sub_08097B24(Entity* this) { temp2 = ++this->field_0xf; temp = temp3[(temp2 >> 5) & 7]; - sub_0805EC9C(this, temp, temp, 0); + SetAffineInfo(this, temp, temp, 0); } diff --git a/src/object/litArea.c b/src/object/litArea.c index 06d50198..f042209e 100644 --- a/src/object/litArea.c +++ b/src/object/litArea.c @@ -19,7 +19,7 @@ void LitArea(Entity* this) { this->actionDelay = 2; this->field_0x68.HWORD = 0xfffe; this->field_0x6a.HWORD = 0x80; - sub_0805EC9C(this, 0x80, 0x80, 0); + SetAffineInfo(this, 0x80, 0x80, 0); } else { if (--this->actionDelay == 0) { this->actionDelay = 2; @@ -30,7 +30,7 @@ void LitArea(Entity* this) { if (0x88 < this->field_0x6a.HWORD) { this->field_0x68.HWORD = 0xffff; } - sub_0805EC9C(this, this->field_0x6a.HWORD, this->field_0x6a.HWORD, 0); + SetAffineInfo(this, this->field_0x6a.HWORD, this->field_0x6a.HWORD, 0); } } gScreen.lcd.displayControl |= DISPCNT_OBJWIN_ON; diff --git a/src/object/macroBook.c b/src/object/macroBook.c index 462dfea1..b63bfc37 100644 --- a/src/object/macroBook.c +++ b/src/object/macroBook.c @@ -44,7 +44,7 @@ void MacroBook_Init(MacroBookEntity* this) { super->spriteOffsetY = -4; super->spritePriority.b0 = 7; super->spriteRendering.b3 = 3; - sub_0805EC9C(super, this->unk80, this->unk80, 0); + SetAffineInfo(super, this->unk80, this->unk80, 0); UpdateSpriteForCollisionLayer(super); InitAnimationForceUpdate(super, super->field_0xf); sub_0809A958(this); @@ -56,7 +56,7 @@ void MacroBook_Action1(MacroBookEntity* this) { if (super->actionDelay) { super->actionDelay--; } else { - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { if (super->field_0xf == 3) { super->action = 2; super->actionDelay = 90; @@ -83,7 +83,7 @@ void MacroBook_Action2(MacroBookEntity* this) { super->action = 1; super->actionDelay = 0; } else { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { return; } super->action = 3; @@ -117,7 +117,7 @@ void MacroBook_Action3(MacroBookEntity* this) { if (super->actionDelay) { this->unk80 += 8; super->x.WORD += 0x400; - sub_0805EC9C(super, this->unk80, this->unk80, 0); + SetAffineInfo(super, this->unk80, this->unk80, 0); } else { sub_0809AA9C(this, super->child, 0); sub_0809AA9C(this, &gPlayerEntity, 1); diff --git a/src/object/macroPlayer.c b/src/object/macroPlayer.c index 37cf06ce..4adcb573 100644 --- a/src/object/macroPlayer.c +++ b/src/object/macroPlayer.c @@ -111,7 +111,7 @@ void MacroPlayer_Type0_Init(MacroPlayerEntity* this) { super->z.HALF.HI = 0xff50; this->unk6a = 4; super->spriteRendering.b0 = 3; - sub_0805EC9C(super, 4, 4, 0); + SetAffineInfo(super, 4, 4, 0); ptr = gUnk_02018EB0; *(Entity**)&ptr[0x14] = super; ChangeObjPalette(super, sub_0807A094(0)); @@ -125,7 +125,7 @@ void MacroPlayer_Type0_Init(MacroPlayerEntity* this) { void sub_0808CC88(MacroPlayerEntity* this) { if (this->unk6a < 0x400) { this->unk6a += 4; - sub_0805EC9C(super, this->unk6a, this->unk6a, 0); + SetAffineInfo(super, this->unk6a, this->unk6a, 0); sub_0806FCF4(super, this->unk6a, 8, 2); } } diff --git a/src/object/minecart.c b/src/object/minecart.c index 5b2538f2..7370c28b 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -146,7 +146,7 @@ void sub_080919AC(Entity* this) { iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[this->animationState]); if (iVar2 == 0) { this->direction = DirectionTurnAround(this->direction); - this->animationState = this->animationState ^ 2; + this->animationState = AnimationStateFlip90(this->animationState); } else { switch (uVar3) { case 0x64: @@ -177,7 +177,7 @@ void sub_080919AC(Entity* this) { case 0x6d: case 0x6e: case 0x6f: - if (uVar3 == sub_080B1AA8(this)) { + if (uVar3 == GetTileUnderEntity(this)) { sub_08091C0C(this); gPlayerEntity.animationState = this->animationState << 1; return; diff --git a/src/object/mineralWaterSource.c b/src/object/mineralWaterSource.c index 1ffcd585..e4b438d4 100644 --- a/src/object/mineralWaterSource.c +++ b/src/object/mineralWaterSource.c @@ -1,5 +1,4 @@ -#include "global.h" -#include "entity.h" +#include "object.h" extern void (*MineralWaterSourceActionFuncs[])(Entity*); @@ -12,8 +11,6 @@ typedef struct { extern UnkStruct_MineralWater MineralWaterSourceParameters[]; -extern bool32 AllocMutableHitbox(Entity*); - void MineralWaterSource(Entity* this) { MineralWaterSourceActionFuncs[this->action](this); } @@ -21,7 +18,7 @@ void MineralWaterSource(Entity* this) { void MineralWaterSource_Init(Entity* this) { UnkStruct_MineralWater* unknownParameters; - if (!AllocMutableHitbox(this)) { + if (AllocMutableHitbox(this) == NULL) { return; } diff --git a/src/object/object15.c b/src/object/object15.c index 25bfe1f5..43b03d0b 100644 --- a/src/object/object15.c +++ b/src/object/object15.c @@ -34,7 +34,7 @@ void Object15_Action1(Entity* this) { DeleteThisEntity(); } } else { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/object/object1E.c b/src/object/object1E.c index 48991a92..1356bdd0 100644 --- a/src/object/object1E.c +++ b/src/object/object1E.c @@ -72,7 +72,7 @@ END_NONMATCH void sub_080875F4(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } if (this->type2 != 0) { diff --git a/src/object/object20.c b/src/object/object20.c index 1cfb4c2c..9474f662 100644 --- a/src/object/object20.c +++ b/src/object/object20.c @@ -48,7 +48,7 @@ void sub_08087824(Entity* this) { void sub_08087888(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } else { if (this->frame < 5) { diff --git a/src/object/object21.c b/src/object/object21.c index 6641b14c..f25e1a50 100644 --- a/src/object/object21.c +++ b/src/object/object21.c @@ -38,7 +38,7 @@ void Object21(Object21Entity* this) { } else { if (super->animIndex == 0xa) { InitializeAnimation(super, 0xd); - } else if ((super->frame & 0x80) != 0) { + } else if ((super->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/object/object2B.c b/src/object/object2B.c index 747bf241..efd23de9 100644 --- a/src/object/object2B.c +++ b/src/object/object2B.c @@ -17,6 +17,6 @@ void Object2B(Entity* object) { DeleteThisEntity(); } else { int position = 0x120 - parent->z.HALF.HI; - sub_0805EC9C(object, position, position, parent->field_0x7c.HALF_U.HI); + SetAffineInfo(object, position, position, parent->field_0x7c.HALF_U.HI); } } diff --git a/src/object/object36.c b/src/object/object36.c index 83150e0f..94dae2b3 100644 --- a/src/object/object36.c +++ b/src/object/object36.c @@ -69,7 +69,7 @@ void sub_0808BBE0(Object36Entity* this) { diff /= 0x10; super->spriteOffsetY = gUnk_08121474[diff]; ptr = &gUnk_0812144C[diff * 2]; - sub_0805EC9C(super, ptr[0], ptr[1], 0); + SetAffineInfo(super, ptr[0], ptr[1], 0); } else { super->bitfield &= 0x7f; } @@ -119,7 +119,7 @@ void sub_0808BD14(Object36Entity* this) { if (super->field_0xf != 0) { super->field_0xf -= 8; - sub_0805EC9C(super, 0x200 - super->field_0xf, 0x200 - super->field_0xf, 0); + SetAffineInfo(super, 0x200 - super->field_0xf, 0x200 - super->field_0xf, 0); } if (super->bitfield == 0x93) { super->direction = GetFacingDirection(super, &gPlayerEntity); diff --git a/src/object/object3D.c b/src/object/object3D.c index 0416ac2c..05514818 100644 --- a/src/object/object3D.c +++ b/src/object/object3D.c @@ -74,7 +74,7 @@ void Object3D_Action1(Object3DEntity* this) { super->actionDelay = 0x1e; super->field_0xf = 0xff; super->spriteRendering.b0 = 3; - sub_0805EC9C(super, 0x100, 0x100, 0); + SetAffineInfo(super, 0x100, 0x100, 0); gArea.field_0x10 = 1; SetFade(5, 8); } @@ -108,7 +108,7 @@ void Object3D_Action2(Object3DEntity* this) { if (0x80 < super->field_0xf) { super->field_0xf -= 8; } - sub_0805EC9C(super, super->field_0xf, super->field_0xf, 0); + SetAffineInfo(super, super->field_0xf, super->field_0xf, 0); } else { gArea.filler3[0]++; gArea.field_0x10 = 0; diff --git a/src/object/object3E.c b/src/object/object3E.c index 672c428e..c950452e 100644 --- a/src/object/object3E.c +++ b/src/object/object3E.c @@ -191,7 +191,7 @@ void Object3E_Type7(Object3EEntity* this) { super->spritePriority.b0 = 7; super->spriteRendering.alphaBlend = 1; super->frameIndex = super->type2; - sub_0805EC9C(super, (1 - super->type2) * 0x200 + 0x100, 0xffffff40, 0); + SetAffineInfo(super, (1 - super->type2) * 0x200 + 0x100, 0xffffff40, 0); } } diff --git a/src/object/object43.c b/src/object/object43.c index fdf67abc..b8d9edea 100644 --- a/src/object/object43.c +++ b/src/object/object43.c @@ -197,7 +197,7 @@ void Object43_Action3(Object43Entity* this) { void Object43_Action4(Object43Entity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/object/object44.c b/src/object/object44.c index 0753c7f4..b73c0bca 100644 --- a/src/object/object44.c +++ b/src/object/object44.c @@ -51,7 +51,7 @@ void sub_0808E298(Entity* this) { void sub_0808E318(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { sub_0808E354(this, 0x343); DeleteThisEntity(); } else { diff --git a/src/object/object49.c b/src/object/object49.c index aaecd05b..1b74b298 100644 --- a/src/object/object49.c +++ b/src/object/object49.c @@ -111,7 +111,7 @@ void sub_0808F244(Entity* this) { } static void sub_0808F2B0(Entity* this) { - sub_0805EC9C(this, *(u32*)&this->field_0x74, *(u32*)&this->field_0x78, this->field_0x70.WORD); + SetAffineInfo(this, *(u32*)&this->field_0x74, *(u32*)&this->field_0x78, this->field_0x70.WORD); } void sub_0808F2C0(Entity* this) { diff --git a/src/object/object4B.c b/src/object/object4B.c index 7e76e856..b7dbc6ab 100644 --- a/src/object/object4B.c +++ b/src/object/object4B.c @@ -48,7 +48,7 @@ void Object4B_Action1(Object4BEntity* this) { void Object4B_Action2(Object4BEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action++; super->spritePriority.b1 = 3; InitializeAnimation(super, 2); @@ -80,12 +80,12 @@ void Object4B_Action4(Object4BEntity* this) { } if ((super->y.HALF.HI - gRoomControls.origin_y) < 0x231) { super->y.HALF.HI = gRoomControls.origin_y + 0x230; - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action++; super->actionDelay = 0x78; InitializeAnimation(super, 2); } - } else if ((super->frame & 0x80) != 0) { + } else if ((super->frame & ANIM_DONE) != 0) { super->zVelocity = 0x20000; InitializeAnimation(super, 3); SoundReq(SFX_12B); @@ -102,7 +102,7 @@ void Object4B_Action5(Object4BEntity* this) { void Object4B_Action6(Object4BEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action++; super->actionDelay = 0x3c; InitializeAnimation(super, 1); diff --git a/src/object/object61.c b/src/object/object61.c index 4c72c0d9..5756afdd 100644 --- a/src/object/object61.c +++ b/src/object/object61.c @@ -124,7 +124,7 @@ void Object61_Action1Type0(Object61Entity* this) { super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; sub_0806FCF4(super, this->unk_72, 10, 2); - sub_0805EC9C(super, this->unk_6e, this->unk_72, 0); + SetAffineInfo(super, this->unk_6e, this->unk_72, 0); sub_0806FEBC(&gPlayerEntity, 1, super); } diff --git a/src/object/object64.c b/src/object/object64.c index a536c556..d1d6f62e 100644 --- a/src/object/object64.c +++ b/src/object/object64.c @@ -67,7 +67,7 @@ void sub_08093EAC(Object64Entity* this) { void sub_08093ED0(Object64Entity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { DeleteEntity(super); } } @@ -80,7 +80,7 @@ void sub_08093EF0(Object64Entity* this) { return; } GetNextFrame(super); - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { return; } object = CreateObject(OBJECT_64, 1, 0); @@ -100,7 +100,7 @@ void sub_08093EF0(Object64Entity* this) { CopyPosition(super, object); } } - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { return; } if (super->parent == &gPlayerEntity) { @@ -111,7 +111,7 @@ void sub_08093EF0(Object64Entity* this) { break; case 2: GetNextFrame(super); - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { return; } DeleteThisEntity(); diff --git a/src/object/object66.c b/src/object/object66.c index 02f31e6c..bd82c084 100644 --- a/src/object/object66.c +++ b/src/object/object66.c @@ -27,7 +27,7 @@ void Object66(Entity* this) { iVar2 = 0x100 - 2 * (parent->z.HALF.HI + 0x40); iVar4 = 0x200 - 4 * (parent->z.HALF.HI + 0x40); } - sub_0805EC9C(this, iVar2, iVar4, 0); + SetAffineInfo(this, iVar2, iVar4, 0); } else { DeleteThisEntity(); } diff --git a/src/object/object67.c b/src/object/object67.c index 05218223..f36636f8 100644 --- a/src/object/object67.c +++ b/src/object/object67.c @@ -27,8 +27,6 @@ void sub_08094570(Object67Entity*); void sub_08094660(Object67Entity*); void sub_08094708(Object67Entity*, u32, u32); -extern bool32 AllocMutableHitbox(Entity*); - void Object67(Entity* this) { static void (*const actionFuncs[])(Object67Entity*) = { sub_08094148, sub_08094398, sub_08094424, sub_08094540, sub_08094570, @@ -135,7 +133,7 @@ void sub_08094148(Object67Entity* this) { this->unk84.HALF.HI = 0x100; } - if (AllocMutableHitbox(super)) { + if (AllocMutableHitbox(super) != NULL) { super->hitbox->offset_x = gUnk_080FD2E8.offset_x; super->hitbox->offset_y = gUnk_080FD2E8.offset_y; super->hitbox->unk2[0] = gUnk_080FD2E8.unk2[0]; @@ -181,7 +179,7 @@ void sub_08094398(Object67Entity* this) { this->unk7c = 600; super->action = 2; } - sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + SetAffineInfo(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); } else { if ((((GenericEntity*)super->child)->field_0x78.HALF.HI & 0x80) == 0) { DeleteThisEntity(); @@ -224,7 +222,7 @@ void sub_08094424(Object67Entity* this) { } else { sub_0806FCF4(super, this->unk80.HALF.HI, 0x20, super->actionDelay); sub_0806FCF4(super, this->unk84.HALF.HI, 0x20, super->field_0xf); - sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + SetAffineInfo(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); } if (super->hitbox != NULL) { @@ -241,7 +239,7 @@ void sub_08094540(Object67Entity* this) { super->action = 4; this->unk7c = 2; } - sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + SetAffineInfo(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); } void sub_08094570(Object67Entity* this) { @@ -275,7 +273,7 @@ void sub_08094570(Object67Entity* this) { } sub_0806FCF4(super, this->unk80.HALF.HI, 0x20, super->actionDelay); sub_0806FCF4(super, this->unk84.HALF.HI, 0x20, super->field_0xf); - sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + SetAffineInfo(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); } if (super->hitbox != NULL) { diff --git a/src/object/object6A.c b/src/object/object6A.c index 9ae71669..79670b5a 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -327,7 +327,7 @@ void sub_08094E30(Object6AEntity* this) { super->zVelocity = 0; SetDefaultPriority(super, PRIO_PLAYER_EVENT); InitializeAnimation(super, 0); - if (sub_080B1AA8(super) == 13) { + if (GetTileUnderEntity(super) == 13) { super->action = 3; } break; @@ -344,7 +344,7 @@ void sub_08094E30(Object6AEntity* this) { break; case 2: GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { DeleteThisEntity(); } break; @@ -548,9 +548,9 @@ void sub_08095288(Object6AEntity* this) { if (super->subAction != 0) { if ((u32)sub_080044EC(super, 0x1800) <= 1) { super->subAction = 0; - sub_0805EC9C(super, 0x100, 0x100, 0xC000); + SetAffineInfo(super, 0x100, 0x100, 0xC000); } else { - sub_0805EC9C(super, 0x100, 0x100, super->actionDelay << 8); + SetAffineInfo(super, 0x100, 0x100, super->actionDelay << 8); super->actionDelay += 10; LinearMoveUpdate(super); } @@ -770,7 +770,7 @@ void sub_0809577C(Object6AEntity* this) { InitializeAnimation(super, 1); } GetNextFrame(super); - if (super->frame & 0x80) + if (super->frame & ANIM_DONE) DeleteThisEntity(); } @@ -951,7 +951,7 @@ void sub_08095B48(Object6AEntity* this) { p = super->parent; if (p != NULL) { if ((p->frame & 0x40) == 0) { - if (p->frame & 0x80) { + if (p->frame & ANIM_DONE) { DeleteThisEntity(); return; } diff --git a/src/object/object86.c b/src/object/object86.c index 57151a05..bdaa2811 100644 --- a/src/object/object86.c +++ b/src/object/object86.c @@ -31,7 +31,7 @@ void sub_08099E10(Entity* this) { this->frame = 0; sub_08099ECC(this); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 2; InitializeAnimation(this, 1); } @@ -40,7 +40,7 @@ void sub_08099E10(Entity* this) { void sub_08099E58(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->frame &= ~0x80; this->actionDelay++; if (this->actionDelay == 3) { @@ -70,5 +70,5 @@ void sub_08099ECC(Entity* this) { CopyPosition(this, &gPlayerEntity); gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x38 = 0; - gPlayerState.flags |= PL_FLAGS8000; + gPlayerState.flags |= PL_PIT_IS_EXIT; } diff --git a/src/object/object9B.c b/src/object/object9B.c index 1f88aefa..82b7eebf 100644 --- a/src/object/object9B.c +++ b/src/object/object9B.c @@ -25,7 +25,7 @@ void sub_0809E7C0(Entity* this) { void sub_0809E7E0(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { DeleteThisEntity(); } } diff --git a/src/object/objectA2.c b/src/object/objectA2.c index e529794c..8091c484 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -74,7 +74,7 @@ void sub_0809F374(Entity* this) { } void sub_0809F3E8(Entity* this) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->action = 3; InitializeAnimation(this, 2); } diff --git a/src/object/objectAF.c b/src/object/objectAF.c index 8aa2c9ed..cd7ebe6a 100644 --- a/src/object/objectAF.c +++ b/src/object/objectAF.c @@ -40,7 +40,7 @@ void sub_080A05F4(Entity* this) { void sub_080A0624(Entity* this) { GetNextFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { DeleteThisEntity(); } } diff --git a/src/object/objectB3.c b/src/object/objectB3.c index 770d4e27..de0313ee 100644 --- a/src/object/objectB3.c +++ b/src/object/objectB3.c @@ -75,7 +75,7 @@ void sub_080A0AF0(Entity* this) { ExecuteScriptForEntity(this, NULL); GetNextFrame(this); if (this->animIndex == 5) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/object/objectC1.c b/src/object/objectC1.c index 780c1c78..ed045a6d 100644 --- a/src/object/objectC1.c +++ b/src/object/objectC1.c @@ -101,7 +101,7 @@ void ObjectC1_Action8(ObjectC1Entity* this) { if ((gMessage.doTextBox & 0x7f) != 0) { return; } - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->action = 1; gPlayerEntity.flags = this->unk_69; gPlayerEntity.spriteSettings.draw = this->unk_68; diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index 5582f707..0433a93d 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -99,7 +99,7 @@ void ObjectOnPillar_Action1(ObjectOnPillarEntity* this) { if (sub_08097008(this)) { super->action = 3; } else { - sub_08078930(super); + RegisterCarryEntity(super); } } } @@ -211,7 +211,7 @@ void sub_080970F4(ObjectOnPillarEntity* this) { bool32 sub_08097144(ObjectOnPillarEntity* this) { LinearMoveUpdate(super); sub_0800445C(super); - if (sub_080B1AA8(super) == 0x19) { + if (GetTileUnderEntity(super) == 0x19) { super->spriteOffsetY = 2; } if ((--this->unk_76 == 0) && sub_08097194(this) == FALSE) { diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index e986348f..faba73b0 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -120,7 +120,7 @@ void ObjectOnSpinyBeetle_Action1(ObjectOnSpinyBeetleEntity* this) { } } else { sub_08098918(this); - sub_08078930(super); + RegisterCarryEntity(super); } } else { sub_080989C0(this); diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index ef2f279a..f1fbb022 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -111,7 +111,7 @@ void OctorokBossObject_Init(Entity* this) { ((-(u32)this->parent->field_0x7a.HALF.HI << 0x18) >> 0x18) + (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], (u32)gUnk_0812388C[(u32)this->type2 * 2]); - sub_0805EC9C(this, this->field_0x76.HWORD, this->field_0x74.HWORD, this->field_0x7a.HWORD); + SetAffineInfo(this, this->field_0x76.HWORD, this->field_0x74.HWORD, this->field_0x7a.HWORD); InitializeAnimation(this, 7); break; case 7: @@ -239,8 +239,8 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc", this->field_0x76.HWORD -= 0x20; this->field_0x74.HWORD -= 0x20; } - sub_0805EC9C(this, (u32)this->field_0x76.HWORD, (u32)(u16)this->field_0x74.HWORD, - (u32)(u16)this->field_0x7a.HWORD); + SetAffineInfo(this, (u32)this->field_0x76.HWORD, (u32)(u16)this->field_0x74.HWORD, + (u32)(u16)this->field_0x7a.HWORD); } else { *(int*)&this->field_0x78 -= 1; } diff --git a/src/object/playerClone.c b/src/object/playerClone.c index eee252ae..b8a94abc 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -98,7 +98,7 @@ void PlayerClone_Action2(PlayerCloneEntity* this) { if (gPlayerEntity.iframes >= 1) { gPlayerState.chargeState.action = 1; } else { - sub_080B1AA8(super); + GetTileUnderEntity(super); sub_08084B1C(this); super->x.HALF.HI = gPlayerEntity.x.HALF.HI + this->unk78; super->y.HALF.HI = gPlayerEntity.y.HALF.HI + this->unk7a; diff --git a/src/object/pot.c b/src/object/pot.c index 239d0732..22ee8ce0 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -16,7 +16,7 @@ extern void (*const gUnk_0811F090[])(Entity*); extern void (*const gUnk_0811F0A8[])(Entity*); extern void (*const gUnk_0811F0C4[])(Entity*); -extern void sub_08078930(Entity*); +extern void RegisterCarryEntity(Entity*); extern void sub_08016A6C(Entity*); void Pot(Entity* this) { @@ -94,7 +94,7 @@ void sub_08082310(Entity* this) { DeleteThisEntity(); break; default: - if (sub_080B1AA8(this) == 13) { + if (GetTileUnderEntity(this) == 13) { CreateFx(this, FX_FALL_DOWN, 0); } else if (tileType == 0x4005) { gPlayerState.field_0xab = 4; @@ -104,7 +104,7 @@ void sub_08082310(Entity* this) { break; } } else { - sub_08078930(this); + RegisterCarryEntity(this); } break; } @@ -194,7 +194,7 @@ void sub_08082614(Entity* this) { break; default: SetTile(0x4000, COORD_TO_TILE(this), this->collisionLayer); - sub_08078930(this); + RegisterCarryEntity(this); break; } } diff --git a/src/object/pullableLever.c b/src/object/pullableLever.c index 35088834..98b62c82 100644 --- a/src/object/pullableLever.c +++ b/src/object/pullableLever.c @@ -92,7 +92,7 @@ void PullableLever_HandleInit(PullableLeverEntity* this) { } void PullableLever_HandleAction1(PullableLeverEntity* this) { - sub_08078930(super); + RegisterCarryEntity(super); if (this->pullLength != 0) { super->direction = super->type2 << 3; LinearMoveUpdate(super); diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index ff7bff42..0c0e5796 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -162,7 +162,7 @@ void sub_0808ACEC(PullableMushroomEntity* this) { default: super->field_0xf = 0; super->actionDelay = 0; - sub_08078930(super); + RegisterCarryEntity(super); break; } } @@ -171,7 +171,7 @@ void sub_0808ADA0(PullableMushroomEntity* this) { if ((sub_0808B1F0(this, super->child) < 8) || (super->child == NULL)) { super->subAction += 1; super->actionDelay = 2; - super->flags |= 0x80; + super->flags |= ENT_COLLIDE; super->animationState ^= 2; super->spritePriority.b0 = 4; } else { @@ -182,9 +182,9 @@ void sub_0808ADA0(PullableMushroomEntity* this) { void sub_0808ADF0(PullableMushroomEntity* this) { if (super->animationState + 0xd == super->animIndex) { - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { super->subAction = 0; - super->flags |= 0x80; + super->flags |= ENT_COLLIDE; } else { GetNextFrame(super); } @@ -199,7 +199,7 @@ void sub_0808ADF0(PullableMushroomEntity* this) { SoundReq(SFX_12E); } else { GetNextFrame(super); - if (((super->frame & 0x80) != 0) && (--super->actionDelay == 0xff)) { + if (((super->frame & ANIM_DONE) != 0) && (--super->actionDelay == 0xff)) { InitializeAnimation(super, super->animationState + 0xd); } } @@ -245,7 +245,7 @@ void sub_0808AEB0(PullableMushroomEntity* this) { } else { super->actionDelay = 1; this->unk_7c = 1; - super->animationState = gPlayerEntity.animationState >> 1 ^ 2; + super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1); super->direction = (super->animationState << 3); super->flags &= 0x7f; super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; @@ -264,7 +264,7 @@ void sub_0808AEB0(PullableMushroomEntity* this) { void sub_0808AFD4(PullableMushroomEntity* this) { super->action = 1; super->subAction = 1; - (super->child)->direction = super->direction ^ 0x10; + (super->child)->direction = DirectionTurnAround(super->direction); SoundReq(SFX_130); } @@ -278,9 +278,9 @@ void PullableMushroom_Action3(PullableMushroomEntity* this) { if ((((gPlayerState.field_0x1c & 0xf) != 1) || ((super->bitfield & 0x7f) != 0x13)) && (super->type == 1)) { (super->parent)->action = 1; (super->parent)->subAction = 1; - super->direction = super->parent->direction ^ 0x10; - super->parent->flags &= 0x7f; - super->flags &= 0x7f; + super->direction = DirectionTurnAround(super->parent->direction); + super->parent->flags &= ~ENT_COLLIDE; + super->flags &= ~ENT_COLLIDE; super->action = 1; SoundReq(SFX_130); } @@ -288,7 +288,7 @@ void PullableMushroom_Action3(PullableMushroomEntity* this) { void sub_0808B05C(PullableMushroomEntity* this) { if (super->type == 0) { - super->animationState = gPlayerEntity.animationState >> 1 ^ 2; + super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1); super->direction = super->animationState << 3; super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; super->flags &= 0x7f; @@ -346,7 +346,7 @@ void sub_0808B168(PullableMushroomEntity* this, u32 param_2) { Entity* pEVar6; if (param_2 != 0) { - iVar2 = (super->animationState ^ 2) * 2; + iVar2 = AnimationStateFlip90(super->animationState) * 2; pcVar5 = (gUnk_081211F4 + iVar2); pcVar3 = pcVar5 + 1; pEVar5 = super->parent; @@ -356,11 +356,11 @@ void sub_0808B168(PullableMushroomEntity* this, u32 param_2) { pEVar6 = &gPlayerEntity; pEVar5 = super->parent; pcVar5 = (gUnk_081211FC + super->animationState * 2); - pcVar3 = (gUnk_081211F4 + 1 + (super->animationState ^ 2) * 2); + pcVar3 = (gUnk_081211F4 + 1 + AnimationStateFlip90(super->animationState) * 2); } else { pEVar6 = super->parent; pEVar5 = &gPlayerEntity; - pcVar5 = (gUnk_081211F4 + (super->animationState ^ 2) * 2); + pcVar5 = (gUnk_081211F4 + AnimationStateFlip90(super->animationState) * 2); pcVar3 = (gUnk_081211FC + 1 + super->animationState * 2); } } diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c index 503f75d2..c546d23e 100644 --- a/src/object/pushableLever.c +++ b/src/object/pushableLever.c @@ -69,7 +69,7 @@ void PushableLever_Idle(PushableLeverEntity* this) { void PushableLever_Pushing(PushableLeverEntity* this) { GetNextFrame(super); - if ((super->frame & 0x80) != 0) { + if ((super->frame & ANIM_DONE) != 0) { if (super->type2 == 0) { SetFlag(this->pushedFlag); } else { diff --git a/src/object/pushableRock.c b/src/object/pushableRock.c index 75a9733e..20c84f43 100644 --- a/src/object/pushableRock.c +++ b/src/object/pushableRock.c @@ -75,13 +75,13 @@ void PushableRock_Action2(PushableRockEntity* this) { super->speed = PushableRock_Speeds[super->frame & 0xf]; LinearMoveUpdate(super); GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { super->action = 0; } } void PushableRock_Action3(PushableRockEntity* this) { - if ((super->frame & 0x80) == 0) { + if ((super->frame & ANIM_DONE) == 0) { GetNextFrame(super); } else { super->spritePriority.b0 = 7; diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index c47ebfba..fd8de005 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -83,7 +83,7 @@ void PushableStatue_Action1(PushableStatueEntity* this) { break; } } else { - sub_08078930(super); + RegisterCarryEntity(super); } } } diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index 3ffedb89..11994ed5 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -137,7 +137,7 @@ void SmallIceBlock_Action3(SmallIceBlockEntity* this) { } else { super->actionDelay++; } - sub_0805EC9C(super, 0x100, gUnk_08123748[super->actionDelay >> 5], 0); + SetAffineInfo(super, 0x100, gUnk_08123748[super->actionDelay >> 5], 0); if (super->type == 1) { CreateGroundItemWithFlags(super, ITEM_SMALL_KEY, 0, this->unk_86); SoundReq(SFX_SECRET); @@ -162,7 +162,7 @@ void SmallIceBlock_Action4(SmallIceBlockEntity* this) { if (super->actionDelay == 0x30) { SetTile(this->unk_6c, this->unk_70, super->collisionLayer); } - sub_0805EC9C(super, 0x100, (0x3c - super->actionDelay) * 0x20 + 0x100, 0); + SetAffineInfo(super, 0x100, (0x3c - super->actionDelay) * 0x20 + 0x100, 0); if ((super->actionDelay & 1) != 0) { obj = CreateObject(SPECIAL_FX, 0x11, 0x40); if (obj != NULL) { diff --git a/src/object/smoke.c b/src/object/smoke.c index 7fed0867..4ce9b8c4 100644 --- a/src/object/smoke.c +++ b/src/object/smoke.c @@ -44,7 +44,7 @@ void sub_0808A484(Entity* this) { void sub_0808A4D0(Entity* this) { GetNextFrame(this); LinearMoveUpdate(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { DeleteEntity(this); } } diff --git a/src/object/specialFx.c b/src/object/specialFx.c index dcd3a25a..c5262d9c 100644 --- a/src/object/specialFx.c +++ b/src/object/specialFx.c @@ -187,7 +187,7 @@ void sub_080845B8(SpecialFxObject* this) { void sub_080845DC(SpecialFxObject* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { DeleteThisEntity(); } } @@ -202,7 +202,7 @@ void sub_080845F8(SpecialFxObject* this) { void sub_08084630(SpecialFxObject* this) { GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { if ((super->type2 & 1) && (super->child != 0)) { ((GenericEntity*)super->child)->field_0x6a.HWORD--; if (this->unk_68 != 0) { @@ -254,7 +254,7 @@ void sub_080846B0(SpecialFxObject* this) { void sub_0808471C(SpecialFxObject* this) { static const s8 gUnk_0811FB08[] = { -8, -8, 8, -8, -8, 8, 8, 8 }; GetNextFrame(super); - if (super->frame & 0x80) { + if (super->frame & ANIM_DONE) { u32 i; for (i = 0; i < 4; i++) { Entity* fx = CreateFx(super, 0x24, 0); @@ -280,7 +280,7 @@ void sub_08084784(SpecialFxObject* this) { void sub_08084798(SpecialFxObject* this) { GetNextFrame(super); - if ((super->frame & 0x80) || !super->child->next) { + if ((super->frame & ANIM_DONE) || !super->child->next) { DeleteThisEntity(); } } diff --git a/src/player.c b/src/player.c index f209e891..60257988 100644 --- a/src/player.c +++ b/src/player.c @@ -653,12 +653,14 @@ static void PlayerFallInit(Entity* this) { static void PlayerFallUpdate(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { - if ((gSave.stats.health != 0) && (gPlayerState.flags & PL_FLAGS8000)) { + if (this->frame & ANIM_DONE) { + if ((gSave.stats.health != 0) && (gPlayerState.flags & PL_PIT_IS_EXIT)) { + // pit leads to another room gPlayerState.flags &= ~(PL_BUSY | PL_DROWNING); this->spriteSettings.draw = 0; } else { - gPlayerState.flags &= ~(PL_DROWNING | PL_FLAGS8000); + // stay in this room + gPlayerState.flags &= ~(PL_DROWNING | PL_PIT_IS_EXIT); RespawnPlayer(); gPlayerState.field_0xa = 0; this->iframes = 32; @@ -850,7 +852,7 @@ static void sub_08071038(Entity* this) { if (RunQueuedAction() || (gMessage.doTextBox & 0x7f)) return; - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->child = NULL; this->knockbackDuration = 0; this->iframes = 248; @@ -1016,7 +1018,7 @@ static void sub_080712F0(Entity* this) { if ((gPlayerState.flags & PL_MINISH) != 0) { if (--this->actionDelay == 0) temp = TRUE; - } else if ((this->frame & 0x80) != 0) { + } else if ((this->frame & ANIM_DONE) != 0) { if (this->animIndex != 0xce) gPlayerState.animation = 0x2ce; else @@ -1167,7 +1169,7 @@ static void PortalShrinkInit(Entity* this) { this->spriteRendering.b0 = 3; *(u32*)&this->field_0x80.HWORD = 0x100; *(u32*)&this->cutsceneBeh = 0x100; - sub_0805EC9C(this, 0x100, 0x100, 0); + SetAffineInfo(this, 0x100, 0x100, 0); gPlayerState.animation = 0x2c3; gPlayerState.flags |= PL_MINISH; SoundReq(SFX_PLY_SHRINKING); @@ -1244,7 +1246,7 @@ void PortalShrinkUpdate(Entity* this) { break; } - sub_0805EC9C(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); + SetAffineInfo(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); UpdateAnimationSingleFrame(this); } @@ -1352,7 +1354,7 @@ static void sub_0807193C(Entity* this) { Entity* child; UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->subAction++; child = CreateObjectWithParent(this, EZLO_CAP, 0, 0); this->child = child; @@ -1407,7 +1409,7 @@ static void sub_08071990(Entity* this) { static void sub_08071A4C(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { reset_priority(); sub_0807921C(); } @@ -1495,6 +1497,7 @@ static void sub_08071B60(Entity* this) { this->type = 0; this->knockbackDuration = 0; PlayerWaitForScroll(this); + // Final push? this->field_0xf = 6; if ((gPlayerState.flags & PL_MINISH) == 0) { gPlayerState.animation = 0x104; @@ -1559,7 +1562,7 @@ static void PlayerMinishDieInit(Entity* this) { static void sub_08071CAC(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { u32 temp; if ((gPlayerState.flags & PL_MINISH) == 0) temp = (gPlayerState.flags & PL_NO_CAP) ? 0x45a : 0x2bd; @@ -1688,7 +1691,7 @@ static void PlayerEmptyBottleInit(Entity* this) { Entity* ent; ResetPlayer(); - ent = CreatePlayerBomb((ItemBehavior*)this, 0xe); + ent = CreatePlayerItemWithParent((ItemBehavior*)this, 0xe); if (ent != NULL) { ent->field_0x68.HALF.LO = gPlayerState.field_0x38; this->subAction++; @@ -1709,7 +1712,7 @@ static void PlayerEmptyBottleInit(Entity* this) { static void PlayerEmptyBottleUpdate(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { gPlayerState.item = NULL; sub_0807921C(); } @@ -1796,7 +1799,7 @@ static void sub_08072098(Entity* this) { return; else ; - else if ((this->frame & 0x80) == 0) + else if ((this->frame & ANIM_DONE) == 0) return; if (this->health != 0) @@ -1869,7 +1872,7 @@ static void sub_08072214(Entity* this) { this->subAction = 1; this->speed = PULL_SPEED; this->actionDelay = gPlayerState.field_0x38; - this->direction = Direction8FromAnimationState(AnimationStateTurnAround(this->animationState)); + this->direction = Direction8FromAnimationState(AnimationStateFlip180(this->animationState)); if ((gPlayerState.flags & PL_NO_CAP) == 0) { gPlayerState.animation = 0x34c; } else { @@ -2006,7 +2009,7 @@ static void PlayerRoomTransition(Entity* this) { static void sub_080724DC(Entity* this) { this->knockbackDuration = 0; DeleteClones(); - if (sub_080B1AA8(this) != 0x29) { + if (GetTileUnderEntity(this) != 0x29) { if ((gPlayerState.field_0x82[7] == 0) && (gPlayerState.swim_state != 0)) { sub_0807AE20(this); } @@ -2164,10 +2167,10 @@ static void PlayerRollUpdate(Entity* this) { if (this->frame & 0x40) { sub_08077698(this); } - if ((this->frame & 0x80) || (gPlayerState.field_0x3[1] != 0)) { + if ((this->frame & ANIM_DONE) || (gPlayerState.field_0x3[1] != 0)) { ResetPlayerAnimationAndAction(); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { gPlayerState.flags &= ~(PL_MOLDWORM_RELEASED | PL_ROLLING); } UpdateAnimationSingleFrame(this); @@ -2232,7 +2235,7 @@ static void PlayerInHoleInit(Entity* this) { } static void PlayerInHoleUpdate(Entity* this) { - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { if (this->actionDelay == 1) { this->subAction = 3; this->actionDelay = 0x28; @@ -2648,7 +2651,7 @@ static void sub_080731D8(Entity* this) { static void sub_080732D0(Entity* this) { UpdateAnimationSingleFrame(this); - if (sub_080B1AA8(this) != 40) { + if (GetTileUnderEntity(this) != 40) { this->direction = DirectionNorth; LinearMoveUpdate(this); } else { @@ -3043,7 +3046,7 @@ static void sub_080739EC(Entity* this) { } void sub_08073A94(Entity* this) { - if ((this->frame & 0x80) || this->knockbackDuration != 0) { + if ((this->frame & ANIM_DONE) || this->knockbackDuration != 0) { sub_08073B60(this); } if (gPlayerEntity.z.WORD != 0) { @@ -3288,7 +3291,7 @@ static void sub_08074018(Entity* this) { *(u32*)&this->cutsceneBeh -= 32; else this->subAction++; - sub_0805EC9C(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); + SetAffineInfo(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); UpdateAnimationSingleFrame(this); } @@ -3976,7 +3979,7 @@ void sub_08074F8C(Entity* this) { this->frame = 0; gActiveScriptInfo.syncFlags |= 4; } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->field_0x68.HALF.LO++; this->actionDelay = 8; this->animationState = IdleSouth; @@ -4064,7 +4067,7 @@ void sub_0807513C(Entity* this) { SoundReq(SFX_14B); SoundReq(SFX_PLY_VO6); } - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->field_0x68.HALF.LO++; this->actionDelay = 60; } @@ -4079,7 +4082,7 @@ void sub_0807518C(Entity* this) { void sub_080751B4(Entity* this) { UpdateAnimationSingleFrame(this); - if (this->frame & 0x80) { + if (this->frame & ANIM_DONE) { this->animationState = IdleSouth; this->subAction = 1; this->field_0x68.HALF.LO = 0; @@ -4130,7 +4133,7 @@ void sub_0807529C(Entity* this) { void sub_080752AC(Entity* this, ScriptExecutionContext* ctx) { LinearMoveUpdate(this); if (!ctx->unk_18) { - if (sub_080B1AA8(this) != 41) { + if (GetTileUnderEntity(this) != 41) { ctx->unk_18 = 1; ctx->unk_19 = 6; } diff --git a/src/playerItem/playerItem11.c b/src/playerItem/playerItem11.c index d8f3a3a7..72b5a702 100644 --- a/src/playerItem/playerItem11.c +++ b/src/playerItem/playerItem11.c @@ -55,7 +55,7 @@ void sub_08018CBC(Entity* this) { this->spriteIndex = 0xa6; this->palette.raw = 0x33; this->spriteVramOffset = 0; - this->type = gPlayerState.field_0x1d - 1; + this->type = gPlayerState.gustJarSpeed - 1; this->actionDelay = gUnk_080B3DE0[this->type * 2]; this->damage = gUnk_080B3DE0[this->type * 2 + 1]; this->hurtType = 0x1b; diff --git a/src/playerItem/playerItem12.c b/src/playerItem/playerItem12.c index 170c107e..cadb27f0 100644 --- a/src/playerItem/playerItem12.c +++ b/src/playerItem/playerItem12.c @@ -109,7 +109,7 @@ void sub_080701F8(Entity* this) { } if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { if (sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) == 0) { - if (sub_080B1AA8(this) == 0x19) { + if (GetTileUnderEntity(this) == 0x19) { this->action = 4; COLLISION_OFF(this); this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8; @@ -132,7 +132,7 @@ void sub_080701F8(Entity* this) { void sub_0807037C(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/playerItem/playerItem3.c b/src/playerItem/playerItem3.c index 81f89bfc..a461e043 100644 --- a/src/playerItem/playerItem3.c +++ b/src/playerItem/playerItem3.c @@ -34,7 +34,7 @@ void PlayerItem3(Entity* this) { } else { this->field_0x86.HWORD -= 0x2000; } - sub_0805EC9C(this, 0x100, 0x100, this->field_0x86.HWORD); + SetAffineInfo(this, 0x100, 0x100, this->field_0x86.HWORD); } this->field_0xf--; diff --git a/src/playerItem/playerItemBomb.c b/src/playerItem/playerItemBomb.c index c7bdd7cb..93ae9547 100644 --- a/src/playerItem/playerItemBomb.c +++ b/src/playerItem/playerItemBomb.c @@ -24,7 +24,7 @@ void PlayerItemBomb(Entity* this) { this->field_0xf = 0x50; *(u32*)&this->field_0x68 = 0; this->spriteRendering.b0 = 3; - sub_0805EC9C(this, 0x100, 0x100, 0); + SetAffineInfo(this, 0x100, 0x100, 0); } } else { if (this->field_0xf != 0) { @@ -37,7 +37,7 @@ void PlayerItemBomb(Entity* this) { this->actionDelay = 0x0f; this->spriteSettings.draw = 0; sub_0805EC60(this); - sub_08078954(this); + FreeCarryEntity(this); CreateObjectWithParent(this, 0x20, 0, 0); sub_0801B418(this); } else { diff --git a/src/playerItem/playerItemBottle.c b/src/playerItem/playerItemBottle.c index 14ee8449..015b6119 100644 --- a/src/playerItem/playerItemBottle.c +++ b/src/playerItem/playerItemBottle.c @@ -14,7 +14,6 @@ void PlayerItemBottle_UseOther(Entity*); void PlayerItemBottle_Init(Entity*); extern u32 SetBottleContents(u32 itemID, u32 bottleIndex); -extern bool32 AllocMutableHitbox(Entity*); extern void sub_0801B9F0(Entity* this); void PlayerItemBottle(Entity* this) { @@ -37,7 +36,7 @@ void PlayerItemBottle_Init(Entity* this) { this->field_0x6e.HALF.HI = bottleType; switch (bottleType) { case ITEM_BOTTLE_EMPTY: - if (AllocMutableHitbox(this) == 0) { + if (AllocMutableHitbox(this) == NULL) { return; } COLLISION_ON(this); diff --git a/src/playerItem/playerItemGustJar.c b/src/playerItem/playerItemGustJar.c index f5d9e0f0..df29a22e 100644 --- a/src/playerItem/playerItemGustJar.c +++ b/src/playerItem/playerItemGustJar.c @@ -41,7 +41,7 @@ void PlayerItemGustJar_Init(Entity* this) { void PlayerItemGustJar_Action1(Entity* this) { sub_080ADC84(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 2; sub_080ADCA0(this, 0); } else { @@ -78,7 +78,7 @@ void PlayerItemGustJar_Action2(Entity* this) { this->frameDuration = 0x7f; } - switch (gPlayerState.field_0x1d) { + switch (gPlayerState.gustJarSpeed) { case 3: sub_080ADCDC(this, 3); this->palette.b.b0 = 0; @@ -132,7 +132,7 @@ void PlayerItemGustJar_Action3(Entity* this) { } void PlayerItemGustJar_Action4(Entity* this) { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->spriteSettings.draw = 0; } else { UpdateAnimationSingleFrame(this); diff --git a/src/playerItem/playerItemLantern.c b/src/playerItem/playerItemLantern.c index 00b2f9c6..077fa405 100644 --- a/src/playerItem/playerItemLantern.c +++ b/src/playerItem/playerItemLantern.c @@ -4,7 +4,6 @@ extern void (*const gUnk_080FEEA8[])(Entity*); -extern bool32 AllocMutableHitbox(Entity*); void sub_08054AC8(Entity*); void PlayerItemLantern(Entity* this) { @@ -22,7 +21,7 @@ void sub_08054A60(Entity* this) { this->field_0x3c = 7; this->flags2 = -0x80; this->animationState = gPlayerEntity.animationState & 0xe; - if (AllocMutableHitbox(this) == FALSE) { + if (AllocMutableHitbox(this) == NULL) { DeleteThisEntity(); } sub_0801766C(this); diff --git a/src/playerItem/playerItemPacciCane.c b/src/playerItem/playerItemPacciCane.c index dc36a6fd..3a1d7540 100644 --- a/src/playerItem/playerItemPacciCane.c +++ b/src/playerItem/playerItemPacciCane.c @@ -29,7 +29,7 @@ void PlayerItemPacciCane_Action1(Entity* this) { u32 playerFrame; u32 frameIndex; u32 flipX; - if (((gPlayerEntity.frame & 0x80) != 0) || (this != gPlayerState.item)) { + if (((gPlayerEntity.frame & ANIM_DONE) != 0) || (this != gPlayerState.item)) { if (this == gPlayerState.item) { gPlayerState.item = NULL; } diff --git a/src/playerUtils.c b/src/playerUtils.c index b68fef08..3d2cb0e8 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -17,7 +17,7 @@ extern void sub_080752E8(ItemBehavior* behavior, u32 arg1); // item.c extern void sub_0800857C(Entity*); -extern void sub_0805E374(Entity*); +extern void SetDefaultPriorityForKind(Entity*); extern void DoPlayerAction(Entity*); extern Entity* sub_0805E744(); extern void sub_0809D738(Entity*); @@ -44,7 +44,7 @@ bool32 sub_080778CC(); ItemBehavior* sub_0807794C(u32); u32 sub_080789A8(void); ItemBehavior* sub_080779EC(u32); -void sub_08077E78(ItemBehavior*, u32); +void DeletePlayerItem(ItemBehavior*, u32); void sub_08077AEC(void); bool32 sub_08079E90(u32); void sub_08079258(void); @@ -251,7 +251,7 @@ ItemBehavior* sub_08077A48(s32 param_1) { u32 tmp = gPlayerState.jump_status & 0x20; if ((((gPlayerState.jump_status & 0x20) == 0)) && (gUnk_0811BE48[param_1].unk0[1] >= gUnk_03000B80[0].field_0x5[4])) { - sub_08077E78(gUnk_03000B80, 0); + DeletePlayerItem(gUnk_03000B80, 0); gPlayerState.field_0x0[1] = tmp; gPlayerState.field_0x1c = tmp; gPlayerState.sword_state = tmp; @@ -288,7 +288,7 @@ ItemBehavior* sub_08077AC8(void) { void sub_08077AEC(void) { u32 slot; - sub_08077E78(gUnk_03000B80 + 3, 3); + DeletePlayerItem(gUnk_03000B80 + 3, 3); gPlayerState.flags &= ~PL_USE_LANTERN; slot = IsItemEquipped(ITEM_LANTERN_ON); if (slot != 2) { @@ -305,7 +305,7 @@ void ResetPlayer() { u32 index = 0; ItemBehavior* ptr = gUnk_03000B80; do { - sub_08077E78(ptr, index); + DeletePlayerItem(ptr, index); ptr++; index++; } while (index <= 2); @@ -355,7 +355,7 @@ Entity* sub_08077BD4(ItemBehavior* beh) { if (sub_08077C94(beh, gUnk_0811BE48[beh->behaviorID].unk0[3]) != 0) { return NULL; } else { - return CreatePlayerBomb(beh, gUnk_0811BE48[beh->behaviorID].unk0[3]); + return CreatePlayerItemWithParent(beh, gUnk_0811BE48[beh->behaviorID].unk0[3]); } } @@ -368,11 +368,11 @@ Entity* sub_08077C0C(ItemBehavior* beh, u32 arg1) { if (sub_08077C94(beh, bVar1) != 0) { return NULL; } else { - return CreatePlayerBomb(beh, bVar1); + return CreatePlayerItemWithParent(beh, bVar1); } } -Entity* CreatePlayerBomb(ItemBehavior* beh, u32 subtype) { +Entity* CreatePlayerItemWithParent(ItemBehavior* beh, u32 subtype) { Entity* pEVar1; pEVar1 = CreatePlayerItem(subtype, 0, 0, beh->behaviorID); @@ -512,7 +512,7 @@ void sub_08077E54(ItemBehavior* beh) { beh->field_0x5[9] = gPlayerEntity.frame; } -void sub_08077E78(ItemBehavior* arg0, u32 bits) { +void DeletePlayerItem(ItemBehavior* arg0, u32 bits) { u32 not ; if (bits == 0) { @@ -569,7 +569,7 @@ bool32 sub_08077F24(ItemBehavior* beh, u32 arg1) { void sub_08077F50(ItemBehavior* beh, u32 arg1) { sub_08079184(); - sub_08077E78(beh, arg1); + DeletePlayerItem(beh, arg1); } u32 sub_08077F64(ItemBehavior* arg0, u32 unk) { @@ -586,15 +586,17 @@ u32 sub_08077F64(ItemBehavior* arg0, u32 unk) { void sub_08077F84(void) { Entity* obj; - if (((gPlayerEntity.collisionLayer & 2) == 0) && - GetTileTypeByPos(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 0xc, 2) - 0x343U < 4) { - sub_0807AA80(&gPlayerEntity); - gPlayerState.jump_status |= 8; - obj = CreateObject(OBJECT_44, 0, 0); - if (obj != NULL) { - obj->x = gPlayerEntity.x; - obj->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0xc; - gPlayerEntity.y.HALF.HI -= 0xc; + if ((gPlayerEntity.collisionLayer & 2) == 0) { + u32 tile = GetTileTypeByPos(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 12, 2); + if (tile == 0x343 || tile == 0x344 || tile == 0x345 || tile == 0x346) { + sub_0807AA80(&gPlayerEntity); + gPlayerState.jump_status |= 8; + obj = CreateObject(OBJECT_44, 0, 0); + if (obj != NULL) { + obj->x = gPlayerEntity.x; + obj->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0xc; + gPlayerEntity.y.HALF.HI -= 0xc; + } } } } @@ -615,11 +617,11 @@ NONMATCH("asm/non_matching/playerUtils/sub_08078008.inc", bool32 sub_08078008(Ch } else { swordType = gSave.stats.itemButtons[0]; } - if (swordType - 1 < 2) { + if (swordType == 1 || swordType == 2) { swordType = 0; } if ((swordType != 0) && ((gPlayerState.sword_state & 0x20) != 0)) { - if (++state->preChargeTimer > 0x14) { + if (++state->preChargeTimer > 20) { state->preChargeTimer = 10; state->action = 3; state->swordType = swordType; @@ -634,7 +636,7 @@ END_NONMATCH bool32 sub_08078070(ChargeState* state) { if ((gPlayerState.sword_state & 0x20) != 0) { if ((gPlayerState.skills & SKILL_FAST_SPLIT) != SKILL_NONE) { - state->chargeTimer += 0xc; + state->chargeTimer += 12; } else { state->chargeTimer += 6; } @@ -643,7 +645,7 @@ bool32 sub_08078070(ChargeState* state) { state->action = 4; SoundReq(SFX_ITEM_SWORD_CHARGE_FINISH); } else { - if (Mod(state->chargeTimer, 0x14) == 0) { + if (Mod(state->chargeTimer, 20) == 0) { SoundReq(SFX_ITEM_SWORD_CHARGE); } } @@ -665,7 +667,8 @@ bool32 sub_080780E0(ChargeState* state) { } bool32 sub_08078108(ChargeState* state) { - if (--state->chargeTimer * 0x10000 < 0) { + state->chargeTimer -= 1; + if (state->chargeTimer < 0) { state->chargeTimer = 0; state->action = 2; } @@ -673,7 +676,8 @@ bool32 sub_08078108(ChargeState* state) { } bool32 sub_08078124(ChargeState* state) { - if ((state->chargeTimer -= 0x10) * 0x10000 < 0) { + state->chargeTimer -= 0x10; + if (state->chargeTimer < 0) { state->chargeTimer = 0; state->action = 2; } @@ -681,7 +685,8 @@ bool32 sub_08078124(ChargeState* state) { } bool32 sub_08078140(ChargeState* info) { - if (--info->preChargeTimer * 0x1000000 < 0) { + info->preChargeTimer -= 1; + if (info->preChargeTimer < 0) { info->preChargeTimer = 0; info->action = 0; return TRUE; @@ -819,9 +824,9 @@ s32 sub_08078904(Entity* entity) { return -1; } -ASM_FUNC("asm/non_matching/playerUtils/sub_08078930.inc", void sub_08078930(Entity* a)) +ASM_FUNC("asm/non_matching/playerUtils/RegisterCarryEntity.inc", void RegisterCarryEntity(Entity* a)) -ASM_FUNC("asm/non_matching/playerUtils/sub_08078954.inc", void sub_08078954(Entity* a)) +ASM_FUNC("asm/non_matching/playerUtils/FreeCarryEntity.inc", void FreeCarryEntity(Entity* a)) ASM_FUNC("asm/non_matching/playerUtils/sub_080789A8.inc", u32 sub_080789A8()) @@ -836,7 +841,7 @@ void CreateEzloHint(u32 hintId, u32 hintHeight) { gRoomTransition.hint_idx = hintId; #if defined(EU) || defined(JP) // TODO what fields of the room transition are switched in these variants? - gRoomTransition.field_0x2c[8] = hintHeight; + gRoomTransition.field_0x2c[7] = hintHeight; #else gRoomTransition.hint_height = hintHeight; #endif @@ -889,7 +894,7 @@ void sub_08078B48(void) { gPlayerState.field_0x82[8] = 2; } -void sub_08078C24(void) { +void ClearPlayerState(void) { gPlayerState.field_0x0[0] = 0; gPlayerState.field_0x0[1] = 0; gPlayerState.jump_status = 0; @@ -1080,7 +1085,7 @@ void sub_0807921C(void) { PL_MOLDWORM_RELEASED | PL_PARACHUTE); ResolvePlayerAnimation(); SetPlayerActionNormal(); - sub_0805E374(&gPlayerEntity); + SetDefaultPriorityForKind(&gPlayerEntity); } void sub_08079258(void) { @@ -1096,7 +1101,7 @@ void sub_08079258(void) { ~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE); gPlayerState.swim_state = 0; gPlayerState.queued_action = 0; - sub_0805E374(&gPlayerEntity); + SetDefaultPriorityForKind(&gPlayerEntity); } void sub_080792BC(s32 speed, u32 direction, u32 field_0x38) { @@ -1187,7 +1192,7 @@ bool32 sub_08079D48(void) { return TRUE; } else { if (!sub_08008B22()) { - if (!sub_08007DD6((u16)sub_080B1AA8(&gPlayerEntity), gUnk_0811C268)) { + if (!sub_08007DD6((u16)GetTileUnderEntity(&gPlayerEntity), gUnk_0811C268)) { return TRUE; } } @@ -1256,7 +1261,7 @@ bool32 sub_08079F48(u32 param_1, u32 param_2) { bool32 sub_08079F8C(void) { if ((gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_FROZEN | PL_FALLING | PL_DISABLE_ITEMS | - PL_FLAGS8000 | PL_IN_MINECART | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_FLAGS2000000 | PL_CLIMBING)) != 0 || + PL_PIT_IS_EXIT | PL_IN_MINECART | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_FLAGS2000000 | PL_CLIMBING)) != 0 || gPlayerState.field_0x3c[0] != 0 || gPlayerEntity.action == 3 || gPlayerEntity.action == 0xb) { return FALSE; } else { @@ -2008,15 +2013,15 @@ void sub_0807C810(void) { } void CloneMapData(void) { - gRoomTransition.field_0x2c[1] = 1; + gRoomTransition.field_0x2c[0] = 1; MemCopy(&gMapBottom.mapData, &gMapBottom.mapDataClone, 0x2000); MemCopy(&gMapTop.mapData, &gMapTop.mapDataClone, 0x2000); } void sub_0807C898(void) { - gRoomTransition.field_0x2c[1] = 2; + gRoomTransition.field_0x2c[0] = 2; LoadRoomGfx(); - gRoomTransition.field_0x2c[1] = 0; + gRoomTransition.field_0x2c[0] = 0; } ASM_FUNC("asm/non_matching/playerUtils/sub_0807C8B0.inc", void sub_0807C8B0()) diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index 785504ed..94eb1e59 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -100,7 +100,7 @@ void DekuSeedProjectile_Action2(Entity* this) { void DekuSeedProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 81970ad1..843bdafa 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -81,7 +81,7 @@ void DirtBallProjectile_Action1(Entity* this) { break; case 1: this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0); - sub_08078954(this->child); + FreeCarryEntity(this->child); CopyPosition(this, this->child); if ((0xf < (u8)(this->actionDelay++ + 1)) && (entity = this->child, entity->actionDelay == 0)) { if ((this->actionDelay & 2) != 0) { @@ -117,7 +117,7 @@ void DirtBallProjectile_Action2(Entity* this) { if (entity->next == NULL) { DeleteThisEntity(); } - sub_08078954(entity); + FreeCarryEntity(entity); CopyPosition(this, entity); } if (sub_080044EC(this, 0x2800) != 1) { @@ -159,7 +159,7 @@ void DirtBallProjectile_Action2(Entity* this) { void DirtBallProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteEntity(this); } } diff --git a/src/projectile/fireProjectile.c b/src/projectile/fireProjectile.c index 80fed65b..85c06766 100644 --- a/src/projectile/fireProjectile.c +++ b/src/projectile/fireProjectile.c @@ -63,7 +63,7 @@ void FireProjectile_Action2(Entity* this) { void FireProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteEntity(this); } } diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index 43cf8ae4..8346d260 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -120,7 +120,7 @@ void GleerokProjectile_Action2(Entity* this) { sub_080A90D8(this); } } else { - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 3; COLLISION_OFF(this); InitializeAnimation(this, 0x53); @@ -130,7 +130,7 @@ void GleerokProjectile_Action2(Entity* this) { void GleerokProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c index 6a98e185..69c0aa73 100644 --- a/src/projectile/gyorgMaleEnergyProjectile.c +++ b/src/projectile/gyorgMaleEnergyProjectile.c @@ -86,7 +86,7 @@ void GyorgMaleEnergyProjectile_Action2(Entity* this) { void GyorgMaleEnergyProjectile_Action3(Entity* this) { ProcessMovement3(this); GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/projectile/iceProjectile.c b/src/projectile/iceProjectile.c index 0f845d8e..2b5b6b34 100644 --- a/src/projectile/iceProjectile.c +++ b/src/projectile/iceProjectile.c @@ -65,7 +65,7 @@ void IceProjectile_Action2(Entity* this) { void IceProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteEntity(this); } } diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index f828070b..1bc2c36e 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -131,7 +131,7 @@ void MandiblesProjectile_Action3(Entity* this) { this->field_0xf -= 1; } else { UpdateAnimationSingleFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 4; this->field_0x82.HALF.LO = 3; this->field_0xf = 0x40; diff --git a/src/projectile/mazaalEnergyBeam.c b/src/projectile/mazaalEnergyBeam.c index 6e284ccf..095f8e45 100644 --- a/src/projectile/mazaalEnergyBeam.c +++ b/src/projectile/mazaalEnergyBeam.c @@ -40,7 +40,7 @@ void MazaalEnergyBeam_Action1(Entity* this) { void MazaalEnergyBeam_Action2(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteEntity(this); } } diff --git a/src/projectile/moblinSpear.c b/src/projectile/moblinSpear.c index d2816076..9d84ccbf 100644 --- a/src/projectile/moblinSpear.c +++ b/src/projectile/moblinSpear.c @@ -1,7 +1,7 @@ #include "entity.h" #include "enemy.h" +#include "coord.h" -extern bool32 AllocMutableHitbox(Entity*); typedef struct { s8 offsetX; s8 offsetY; @@ -44,7 +44,7 @@ void sub_080A832C(Entity* this) { } void MoblinSpear_Init(Entity* this) { - if (AllocMutableHitbox(this) != 0) { + if (AllocMutableHitbox(this) != NULL) { this->action = 1; } } diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index 9d173880..93951fad 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -69,7 +69,7 @@ void sub_080AA78C(Entity* this) { animationState = (gPlayerEntity.animationState >> 1); if (animationState != this->type) { this->field_0x3a &= 0xfb; - if ((animationState ^ 2) != this->type) { + if (AnimationStateFlip90(animationState) != this->type) { return; } this->iframes = 0xe2; @@ -85,7 +85,7 @@ void sub_080AA78C(Entity* this) { this->frame &= 0xef; EnqueueSFX(SFX_100); } - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { sub_080AAAA8(this); } } else { @@ -111,7 +111,7 @@ void SpiderWeb_Init(Entity* this) { } void SpiderWeb_Action1(Entity* this) { - if ((this->frame & 0x80) == 0) { + if ((this->frame & ANIM_DONE) == 0) { UpdateAnimationSingleFrame(this); } sub_080AA9E0(this); @@ -145,7 +145,7 @@ void SpiderWeb_SubAction0(Entity* this) { InitAnimationForceUpdate(this, this->type + 4); } if ((entity->animationState >> 1 == this->type) && (gPlayerState.framestate == PL_STATE_PULL) && - ((gPlayerState.heldObject & 2) != 0) && ((gPlayerEntity.frame & 2) != 0) && ((this->frame & 0x80) == 0)) { + ((gPlayerState.heldObject & 2) != 0) && ((gPlayerEntity.frame & 2) != 0) && ((this->frame & ANIM_DONE) == 0)) { UpdateAnimationSingleFrame(this); if ((this->frame & 1) != 0) { entity->x.HALF.HI = gUnk_0812A06C[entity->animationState] + entity->x.HALF.HI; @@ -195,7 +195,7 @@ void sub_080AA9E0(Entity* this) { this->spritePriority.b0 = ptr->b0; this->direction = ptr->direction; if (ptr->b0 == 5) { - sub_08078930(this); + RegisterCarryEntity(this); } } diff --git a/src/projectile/v1EyeLaser.c b/src/projectile/v1EyeLaser.c index 2f746396..19966321 100644 --- a/src/projectile/v1EyeLaser.c +++ b/src/projectile/v1EyeLaser.c @@ -34,7 +34,7 @@ void V1EyeLaser_Init(Entity* this) { void V1EyeLaser_Action1(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 2; InitializeAnimation(this, 1); sub_080AB758(this); diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index a441e225..8c2e0729 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -85,7 +85,7 @@ void V1FireProjectile_Action1(Entity* this) { void V1FireProjectile_Action2(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { this->action = 3; COLLISION_OFF(this); InitializeAnimation(this, 0x53); @@ -94,7 +94,7 @@ void V1FireProjectile_Action2(Entity* this) { void V1FireProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index e329945c..3733945d 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -124,7 +124,7 @@ void sub_080ABD70(Entity* this) { SetTileType(0x6d, this->field_0x74.HWORD, 2); } } - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteThisEntity(); } } diff --git a/src/projectile/windProjectile.c b/src/projectile/windProjectile.c index 96211f1b..8232bf91 100644 --- a/src/projectile/windProjectile.c +++ b/src/projectile/windProjectile.c @@ -69,7 +69,7 @@ void WindProjectile_Action2(Entity* this) { void WindProjectile_Action3(Entity* this) { GetNextFrame(this); - if ((this->frame & 0x80) != 0) { + if ((this->frame & ANIM_DONE) != 0) { DeleteEntity(this); } } diff --git a/src/script.c b/src/script.c index f08b600e..a6a4e36c 100644 --- a/src/script.c +++ b/src/script.c @@ -1634,8 +1634,8 @@ void EquipItem(Entity* entity, ScriptExecutionContext* context) { ForceEquipItem(item, slot); } -void sub_0807F29C(Entity* entity, ScriptExecutionContext* context) { - sub_0805ED14((void*)context->intVariable); +void SetInputMacro(Entity* entity, ScriptExecutionContext* context) { + InitPlayerMacro((void*)context->intVariable); } void sub_0807F2A8(Entity* entity, ScriptExecutionContext* context) { @@ -1646,8 +1646,8 @@ void sub_0807F2A8(Entity* entity, ScriptExecutionContext* context) { } } -void WaitForFrameHiBit(Entity* entity, ScriptExecutionContext* context) { - if ((entity->frame & 0x80) != 0) { +void WaitForAnimDone(Entity* entity, ScriptExecutionContext* context) { + if ((entity->frame & ANIM_DONE) != 0) { gActiveScriptInfo.flags |= 1; } else { gActiveScriptInfo.commandSize = 0; @@ -1655,7 +1655,7 @@ void WaitForFrameHiBit(Entity* entity, ScriptExecutionContext* context) { } void WaitForPlayerFrameHiBit(Entity* entity, ScriptExecutionContext* context) { - if ((gPlayerEntity.frame & 0x80) != 0) { + if ((gPlayerEntity.frame & ANIM_DONE) != 0) { gActiveScriptInfo.flags |= 1; } else { gActiveScriptInfo.commandSize = 0; diff --git a/src/subtask2.c b/src/subtask2.c index 2ac69033..47542862 100644 --- a/src/subtask2.c +++ b/src/subtask2.c @@ -378,7 +378,7 @@ void Subtask_Init(void) { ResetPaletteTable(0); gGFXSlots.unk0 = 1; gUI.nextToLoad = 2; - gRoomTransition.field_0x2c[4] = 1; + gRoomTransition.field_0x2c[3] = 1; } }