From 34e69959df548688ef8535eb4cab18e5a53992a8 Mon Sep 17 00:00:00 2001 From: theo3 Date: Tue, 14 Dec 2021 23:31:27 -0800 Subject: [PATCH] cleanup --- asm/beanstalk.s | 2 +- asm/bird.s | 2 +- asm/businessScrubPrologue.s | 4 +- asm/chestSpawner.s | 2 +- asm/code_08003FC4.s | 4 +- asm/code_0806ED78.s | 6 +- asm/code_080732D0.s | 4 +- asm/crow.s | 2 +- asm/enemy4D.s | 2 +- asm/enemy50.s | 2 +- asm/{object6.s => ezloCap.s} | 4 +- asm/floatingPlatform.s | 2 +- asm/ghini.s | 2 +- asm/gleerok.s | 2 +- asm/lavaPlatform.s | 2 +- asm/macroBook.s | 2 +- asm/macros/scripts.inc | 4 +- asm/mulldozer.s | 2 +- asm/non_matching/eu/sub_0802AAC0.inc | 2 +- asm/non_matching/player/sub_08072D54.inc | 16 +- asm/non_matching/sub_080560B8.inc | 4 +- asm/object29.s | 6 +- asm/object87.s | 2 +- asm/objectAB.s | 2 +- asm/takkuri.s | 2 +- asm/wizzrobeFire.s | 2 +- asm/wizzrobeIce.s | 2 +- asm/wizzrobeWind.s | 2 +- assets/assets.json | 92 +- data/animations/object/ezloCap.s | 152 +++ data/animations/object/object6.s | 152 --- data/const/object/{object6.s => ezloCap.s} | 6 +- data/data_081146D0.s | 4 +- data/data_0811B9E0.s | 150 --- data/data_0811E454.s | 11 - data/data_0811E750.s | 9 - data/gfx/sprite_frames.s | 4 +- data/gfx/sprite_ptrs.s | 4 +- data/scripts/script_08008D8C.inc | 4 +- data/scripts/script_08009464.inc | 2 +- data/scripts/script_080095F2.inc | 2 +- data/scripts/script_08009B78.inc | 2 +- data/scripts/script_08009F14.inc | 6 +- data/scripts/script_0800AB6E.inc | 6 +- data/scripts/script_0800B41C.inc | 2 +- data/scripts/script_0800B5EC.inc | 2 +- data/scripts/script_0800C550.inc | 2 +- data/scripts/script_0800CD7C.inc | 8 +- data/scripts/script_0800D874.inc | 2 +- data/scripts/script_0800D954.inc | 2 +- data/scripts/script_0800E0BC.inc | 2 +- data/scripts/script_0800E6B0.inc | 2 +- data/scripts/script_0800EA54.inc | 2 +- data/scripts/script_0800EFC0.inc | 2 +- data/scripts/script_0800F724.inc | 2 +- data/scripts/script_080100C8.inc | 2 +- data/scripts/script_08010264.inc | 8 +- data/scripts/script_08011B40.inc | 2 +- data/scripts/script_08011C7C.inc | 6 +- data/scripts/script_0801232C.inc | 2 +- data/scripts/script_08012430.inc | 2 +- data/scripts/script_08012F86.inc | 4 +- data/scripts/script_0801319A.inc | 2 +- data/scripts/script_08014094.inc | 2 +- data/scripts/script_080140B8.inc | 2 +- data/scripts/script_08014154.inc | 2 +- data/scripts/script_08014198.inc | 2 +- data/scripts/script_080143C0.inc | 2 +- data/scripts/script_080145E8.inc | 2 +- data/scripts/script_08014B34.inc | 4 +- data/scripts/script_08014E14.inc | 4 +- data/scripts/script_08016062.inc | 2 +- data/scripts/script_0801609E.inc | 2 +- data/scripts/script_080160A8.inc | 8 +- data/scripts/script_08016384.inc | 2 +- data/scripts/script_080165D8.inc | 2 +- include/definitions.h | 2 +- include/effects.h | 2 +- include/entity.h | 24 +- include/fileScreen.h | 1 + include/functions.h | 4 +- include/hitbox.h | 3 +- include/npc.h | 4 +- include/object.h | 4 +- include/player.h | 12 +- include/room.h | 4 +- include/structures.h | 2 + linker.ld | 17 +- src/collision.c | 2 +- src/coord.c | 4 +- src/createEnemy.c | 2 +- src/debugScreen.c | 26 +- src/demoScreen.c | 8 +- src/enemy/acroBandits.c | 2 +- src/enemy/beetle.c | 2 +- src/enemy/businessScrub.c | 6 +- src/enemy/cuccoChickAggr.c | 2 +- src/enemy/darkNut.c | 4 +- src/enemy/fireballGuy.c | 2 +- src/enemy/keaton.c | 2 +- src/enemy/lakitu.c | 2 +- src/enemy/likeLike.c | 2 +- src/enemy/mazaalHead.c | 2 +- src/enemy/moldworm.c | 6 +- src/enemy/pesto.c | 4 +- src/enemy/slime.c | 2 +- src/enemy/vaatiWrath.c | 6 +- src/entity.c | 10 +- src/fade.c | 8 +- src/flagDebug.c | 10 +- src/interrupts.c | 26 +- src/intro.c | 10 +- src/item/itemPegasusBoots.c | 2 +- src/item/itemRocsCape.c | 2 +- src/main.c | 46 +- src/manager/manager1.c | 10 +- src/manager/manager12.c | 16 +- src/manager/manager14.c | 8 +- src/manager/manager15.c | 80 +- src/manager/manager18.c | 12 +- src/manager/manager19.c | 6 +- src/manager/manager1A.c | 6 +- src/manager/manager1B.c | 4 +- src/manager/manager1D.c | 2 +- src/manager/manager2.c | 17 +- src/manager/manager2E.c | 4 +- src/manager/manager2F.c | 4 +- src/manager/manager31.c | 38 +- src/manager/manager32.c | 12 +- src/manager/manager36.c | 2 +- src/manager/manager39.c | 4 +- src/manager/manager7.c | 8 +- src/manager/managerA.c | 2 +- src/manager/managerB.c | 4 +- src/manager/managerC.c | 2 +- src/manager/managerF.c | 4 +- src/npc.c | 2 +- src/npc/beedle.c | 2 +- src/npc/bigGoron.c | 14 +- src/npc/carpenter.c | 8 +- src/npc/cat.c | 4 +- src/npc/cucco.c | 2 +- src/npc/cuccoChick.c | 2 +- src/npc/dampe.c | 2 +- src/npc/dog.c | 6 +- src/npc/drLeft.c | 2 +- src/npc/emma.c | 2 +- src/npc/epona.c | 2 +- src/npc/{ezloCap.c => ezlo.c} | 4 +- src/npc/farmers.c | 2 +- src/npc/festari.c | 4 +- src/npc/forestMinish.c | 4 +- src/npc/gentari.c | 4 +- src/npc/ghostBrothers.c | 2 +- src/npc/goronMerchant.c | 26 +- src/npc/gregal.c | 10 +- src/npc/hurdyGurdyMan.c | 6 +- src/npc/kingGustaf.c | 2 +- src/npc/librari.c | 2 +- src/npc/mama.c | 2 +- src/npc/marcy.c | 2 +- src/npc/mayorHagen.c | 2 +- src/npc/melari.c | 2 +- src/npc/minishEzlo.c | 2 +- src/npc/mutoh.c | 2 +- src/npc/percy.c | 2 +- src/npc/pita.c | 2 +- src/npc/rem.c | 6 +- src/npc/stockwell.c | 2 +- src/npc/syrup.c | 2 +- src/npc/teachers.c | 2 +- src/npc/townMinish.c | 2 +- src/npc/vaati.c | 2 +- src/npc/wheaton.c | 2 +- src/npc/zelda.c | 2 +- src/npc/zeldaFollower.c | 2 +- src/object.c | 2 +- src/object/bigVortex.c | 2 +- src/object/book.c | 2 +- src/object/button.c | 16 +- src/object/cloud.c | 2 +- src/object/greatFairy.c | 4 +- src/object/heartContainer.c | 2 +- src/object/houseDoorExterior.c | 8 +- src/object/itemOnGround.c | 4 +- src/object/lilypadSmall.c | 2 +- src/object/minecart.c | 2 +- src/object/minishSizedEntrance.c | 2 +- src/object/object1A.c | 2 +- src/object/object86.c | 2 +- src/object/objectA2.c | 2 +- src/object/warpPoint.c | 4 +- src/overworld.c | 2 +- src/player.c | 1038 ++++++++++++-------- src/projectile/dirtBallProjectile.c | 2 +- src/room.c | 145 ++- src/save.c | 4 +- src/script.c | 415 ++++---- 198 files changed, 1578 insertions(+), 1550 deletions(-) rename asm/{object6.s => ezloCap.s} (99%) create mode 100644 data/animations/object/ezloCap.s delete mode 100644 data/animations/object/object6.s rename data/const/object/{object6.s => ezloCap.s} (79%) delete mode 100755 data/data_0811E454.s rename src/npc/{ezloCap.c => ezlo.c} (96%) diff --git a/asm/beanstalk.s b/asm/beanstalk.s index c6934032..6f25ea98 100644 --- a/asm/beanstalk.s +++ b/asm/beanstalk.s @@ -810,7 +810,7 @@ _0808A0FC: adds r0, r5, #0 movs r2, #0 movs r3, #8 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0808A1DC b _0808A1B0 diff --git a/asm/bird.s b/asm/bird.s index 2c43ef24..765e06da 100644 --- a/asm/bird.s +++ b/asm/bird.s @@ -158,7 +158,7 @@ _0809D2D6: adds r1, r6, #0 movs r2, #0xe movs r3, #0xe - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0809D3A8 movs r1, #0x36 diff --git a/asm/businessScrubPrologue.s b/asm/businessScrubPrologue.s index ee5b6397..f8bf3fe4 100644 --- a/asm/businessScrubPrologue.s +++ b/asm/businessScrubPrologue.s @@ -517,7 +517,7 @@ sub_08045F54: @ 0x08045F54 adds r1, r4, #0 movs r2, #0x20 movs r3, #0x20 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 bne _08045F90 cmp r5, #2 @@ -530,7 +530,7 @@ _08045F82: adds r0, r6, #0 adds r1, r4, #0 adds r2, r3, #0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 bne _08045F94 _08045F90: diff --git a/asm/chestSpawner.s b/asm/chestSpawner.s index 756dfa62..4fac73dc 100644 --- a/asm/chestSpawner.s +++ b/asm/chestSpawner.s @@ -163,7 +163,7 @@ _08083F78: adds r1, r5, #0 movs r2, #0x10 movs r3, #8 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _08083F98 movs r0, #0x10 diff --git a/asm/code_08003FC4.s b/asm/code_08003FC4.s index 2779befc..4e033a93 100644 --- a/asm/code_08003FC4.s +++ b/asm/code_08003FC4.s @@ -293,8 +293,8 @@ sub_0800419C: @ 0x0800419C push {r5, r6, lr} b _080041B0 - thumb_func_start sub_080041A0 -sub_080041A0: @ 0x080041A0 + thumb_func_start EntityInRectRadius +EntityInRectRadius: @ 0x080041A0 push {r5, r6, lr} movs r6, #0x38 ldrb r5, [r0, r6] diff --git a/asm/code_0806ED78.s b/asm/code_0806ED78.s index d93e7cc2..74ca8730 100644 --- a/asm/code_0806ED78.s +++ b/asm/code_0806ED78.s @@ -36,7 +36,7 @@ sub_0806ED9C: @ 0x0806ED9C rsbs r6, r6, #0 ldr r1, _0806EDC0 @ =gPlayerEntity adds r2, r4, #0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0806EDBC adds r0, r5, #0 @@ -69,7 +69,7 @@ sub_0806EDD8: @ 0x0806EDD8 ldr r6, _0806EE00 @ =gPlayerEntity adds r1, r6, #0 adds r2, r4, #0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0806EDFC adds r0, r5, #0 @@ -1106,7 +1106,7 @@ sub_0806F548: @ 0x0806F548 push {r4, r5, lr} adds r4, r0, #0 adds r5, r1, #0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 bne _0806F55A movs r0, #0 diff --git a/asm/code_080732D0.s b/asm/code_080732D0.s index b4cb9e7f..8a27c50a 100644 --- a/asm/code_080732D0.s +++ b/asm/code_080732D0.s @@ -1799,7 +1799,7 @@ sub_08074060: @ 0x08074060 bl sub_08003FC4 cmp r0, #0 bne _080740D0 - ldr r0, _080740C4 @ =gUnk_08114F88 + ldr r0, _080740C4 @ =gPlayerHitbox str r0, [r4, #0x48] movs r3, #0x10 movs r0, #0x10 @@ -1840,7 +1840,7 @@ sub_08074060: @ 0x08074060 bl sub_0805EC60 b _080740D6 .align 2, 0 -_080740C4: .4byte gUnk_08114F88 +_080740C4: .4byte gPlayerHitbox _080740C8: .4byte gPlayerState _080740CC: .4byte 0x0000080C _080740D0: diff --git a/asm/crow.s b/asm/crow.s index 4dca91a7..d736150b 100644 --- a/asm/crow.s +++ b/asm/crow.s @@ -241,7 +241,7 @@ sub_0803298C: @ 0x0803298C adds r0, r4, #0 movs r2, #0x88 movs r3, #0x50 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080329E2 ldr r0, [r5] diff --git a/asm/enemy4D.s b/asm/enemy4D.s index 03a8a479..669274fd 100644 --- a/asm/enemy4D.s +++ b/asm/enemy4D.s @@ -558,7 +558,7 @@ sub_0803EFAC: @ 0x0803EFAC adds r4, r1, #0 movs r2, #0x50 movs r3, #0x50 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0803EFD6 adds r0, r4, #0 diff --git a/asm/enemy50.s b/asm/enemy50.s index 7b044061..cdab7151 100644 --- a/asm/enemy50.s +++ b/asm/enemy50.s @@ -907,7 +907,7 @@ _08041184: adds r0, r4, #0 movs r2, #0x70 movs r3, #0x48 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080411C8 _080411B6: diff --git a/asm/object6.s b/asm/ezloCap.s similarity index 99% rename from asm/object6.s rename to asm/ezloCap.s index 7d3f9749..cb68080e 100644 --- a/asm/object6.s +++ b/asm/ezloCap.s @@ -7,8 +7,8 @@ .text - thumb_func_start Object6 -Object6: @ 0x080828E0 + thumb_func_start EzloCap +EzloCap: @ 0x080828E0 push {lr} adds r2, r0, #0 ldrb r1, [r2, #0x10] diff --git a/asm/floatingPlatform.s b/asm/floatingPlatform.s index 917a653e..a6f7a1ec 100644 --- a/asm/floatingPlatform.s +++ b/asm/floatingPlatform.s @@ -107,7 +107,7 @@ sub_08086168: @ 0x08086168 ldrb r2, [r1] ldrb r3, [r1, #1] adds r1, r4, #0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080861A8 bl sub_08079F8C diff --git a/asm/ghini.s b/asm/ghini.s index 1a7136c0..2a43603a 100644 --- a/asm/ghini.s +++ b/asm/ghini.s @@ -824,7 +824,7 @@ _0803F5E8: adds r0, r4, #0 movs r2, #0x70 movs r3, #0x48 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0803F62C _0803F61A: diff --git a/asm/gleerok.s b/asm/gleerok.s index db1ba73b..eebd581e 100644 --- a/asm/gleerok.s +++ b/asm/gleerok.s @@ -1266,7 +1266,7 @@ _0802D924: adds r0, r4, #0 movs r2, #8 movs r3, #8 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 bne _0802D936 b _0802DB7E diff --git a/asm/lavaPlatform.s b/asm/lavaPlatform.s index 3024b6b9..a973a799 100644 --- a/asm/lavaPlatform.s +++ b/asm/lavaPlatform.s @@ -603,7 +603,7 @@ sub_0809269C: @ 0x0809269C adds r1, r5, #0 movs r2, #0x10 movs r3, #0x10 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080926E0 bl sub_08079F8C diff --git a/asm/macroBook.s b/asm/macroBook.s index bb20fefb..3b3396a4 100644 --- a/asm/macroBook.s +++ b/asm/macroBook.s @@ -399,7 +399,7 @@ _0809AA5C: adds r1, r4, #0 movs r2, #0x20 movs r3, #0x22 - bl sub_080041A0 + bl EntityInRectRadius strh r0, [r7] lsls r0, r0, #0x10 cmp r0, #0 diff --git a/asm/macros/scripts.inc b/asm/macros/scripts.inc index 6b78fc2c..df85a3a2 100644 --- a/asm/macros/scripts.inc +++ b/asm/macros/scripts.inc @@ -308,7 +308,7 @@ .4byte \w .endm -.macro WaitPlayerAction8 +.macro WaitPlayerGetItem .2byte 0x0434 .endm @@ -563,7 +563,7 @@ .2byte \yOffset .endm -.macro SetEntityPosition x:req, y:req +.macro OffsetEntityPosition x:req, y:req .2byte 0x0c6a .2byte \x .2byte \y diff --git a/asm/mulldozer.s b/asm/mulldozer.s index 8244ecb8..7617bcf3 100644 --- a/asm/mulldozer.s +++ b/asm/mulldozer.s @@ -978,7 +978,7 @@ sub_08033364: @ 0x08033364 _0803337E: adds r0, r4, #0 adds r2, r3, #0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080333B4 ldrb r0, [r4, #0xa] diff --git a/asm/non_matching/eu/sub_0802AAC0.inc b/asm/non_matching/eu/sub_0802AAC0.inc index 9004a523..8024a38e 100644 --- a/asm/non_matching/eu/sub_0802AAC0.inc +++ b/asm/non_matching/eu/sub_0802AAC0.inc @@ -60,7 +60,7 @@ _0802AAD4: adds r0, r4, #0 movs r2, #0x10 movs r3, #0x10 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0802AB56 ldrb r0, [r5, #0xf] diff --git a/asm/non_matching/player/sub_08072D54.inc b/asm/non_matching/player/sub_08072D54.inc index ce770b44..6ade7257 100644 --- a/asm/non_matching/player/sub_08072D54.inc +++ b/asm/non_matching/player/sub_08072D54.inc @@ -38,7 +38,7 @@ _08072D9C: beq _08072E30 b _08072E6C _08072DA6: - ldr r1, _08072DC8 @ =gUnk_0811BBD4 + ldr r1, _08072DC8 @ =sTileTable ldr r0, _08072DCC @ =gPlayerEntity ldrb r0, [r0, #0x14] lsrs r0, r0, #1 @@ -54,10 +54,10 @@ _08072DA6: strb r0, [r4, #0xf] b _08072E6C .align 2, 0 -_08072DC8: .4byte gUnk_0811BBD4 +_08072DC8: .4byte sTileTable _08072DCC: .4byte gPlayerEntity _08072DD0: - ldr r1, _08072DEC @ =gUnk_0811BBD4 + ldr r1, _08072DEC @ =sTileTable ldr r0, _08072DF0 @ =gPlayerEntity ldrb r0, [r0, #0x14] lsrs r0, r0, #1 @@ -71,7 +71,7 @@ _08072DD0: strb r5, [r4, #0xe] b _08072E6C .align 2, 0 -_08072DEC: .4byte gUnk_0811BBD4 +_08072DEC: .4byte sTileTable _08072DF0: .4byte gPlayerEntity _08072DF4: movs r0, #2 @@ -82,7 +82,7 @@ _08072DFA: movs r5, #4 eors r0, r5 strb r0, [r4, #0x14] - ldr r1, _08072E28 @ =gUnk_0811BBD4 + ldr r1, _08072E28 @ =sTileTable ldr r0, _08072E2C @ =gPlayerEntity ldrb r0, [r0, #0x14] lsrs r0, r0, #1 @@ -102,14 +102,14 @@ _08072E22: eors r0, r5 b _08072E6A .align 2, 0 -_08072E28: .4byte gUnk_0811BBD4 +_08072E28: .4byte sTileTable _08072E2C: .4byte gPlayerEntity _08072E30: ldrb r0, [r4, #0x14] movs r1, #4 eors r0, r1 strb r0, [r4, #0x14] - ldr r1, _08072E58 @ =gUnk_0811BBD4 + ldr r1, _08072E58 @ =sTileTable ldr r0, _08072E5C @ =gPlayerEntity ldrb r0, [r0, #0x14] lsrs r0, r0, #1 @@ -124,7 +124,7 @@ _08072E30: strb r0, [r4, #0xe] b _08072E64 .align 2, 0 -_08072E58: .4byte gUnk_0811BBD4 +_08072E58: .4byte sTileTable _08072E5C: .4byte gPlayerEntity _08072E60: movs r0, #4 diff --git a/asm/non_matching/sub_080560B8.inc b/asm/non_matching/sub_080560B8.inc index 73872d2a..56e0eb89 100644 --- a/asm/non_matching/sub_080560B8.inc +++ b/asm/non_matching/sub_080560B8.inc @@ -7,7 +7,7 @@ .text push {r4, lr} - bl sub_08056134 + bl CheckHeaderValid cmp r0, #0 bne _080560F8 movs r0, #0x80 @@ -22,7 +22,7 @@ ble _080560E4 cmp r1, #1 bne _080560E4 - bl sub_08056134 + bl CheckHeaderValid cmp r0, #0 bne _080560F8 _080560E4: diff --git a/asm/object29.s b/asm/object29.s index 72e20190..c39f1423 100644 --- a/asm/object29.s +++ b/asm/object29.s @@ -304,7 +304,7 @@ _0808999E: adds r1, r5, #0 movs r2, #0xf movs r3, #0xf - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _08089A62 ldrb r0, [r4, #0xe] @@ -418,7 +418,7 @@ sub_08089A7C: @ 0x08089A7C adds r1, r5, #0 movs r2, #0xf movs r3, #0xf - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _08089AB8 ldr r2, _08089AB4 @ =gPlayerState @@ -461,7 +461,7 @@ sub_08089AE0: @ 0x08089AE0 ldr r1, _08089AF8 @ =gPlayerEntity movs r2, #0xf movs r3, #0xf - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _08089AF6 ldr r1, _08089AFC @ =gPlayerState diff --git a/asm/object87.s b/asm/object87.s index 2af555eb..4412cc19 100644 --- a/asm/object87.s +++ b/asm/object87.s @@ -454,7 +454,7 @@ _0809A25C: adds r0, r7, #0 movs r2, #2 movs r3, #2 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 bne _0809A2A6 b _0809A632 diff --git a/asm/objectAB.s b/asm/objectAB.s index bc40b3a5..cbecc43b 100644 --- a/asm/objectAB.s +++ b/asm/objectAB.s @@ -89,7 +89,7 @@ sub_080A0158: @ 0x080A0158 adds r0, r4, #0 movs r2, #0x10 movs r3, #0x10 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080A018A movs r0, #0x37 diff --git a/asm/takkuri.s b/asm/takkuri.s index b2419d0b..57dbaf0e 100644 --- a/asm/takkuri.s +++ b/asm/takkuri.s @@ -251,7 +251,7 @@ _0803BD2C: adds r0, r4, #0 movs r2, #0x88 movs r3, #0x50 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0803BD80 ldr r0, [r5] diff --git a/asm/wizzrobeFire.s b/asm/wizzrobeFire.s index 17a05df2..ffe3a72f 100644 --- a/asm/wizzrobeFire.s +++ b/asm/wizzrobeFire.s @@ -238,7 +238,7 @@ _0802FCDE: adds r0, r4, #0 movs r2, #0xa0 movs r3, #0xa0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0802FDCA adds r0, r4, #0 diff --git a/asm/wizzrobeIce.s b/asm/wizzrobeIce.s index 8e5c95ee..ae171a3f 100644 --- a/asm/wizzrobeIce.s +++ b/asm/wizzrobeIce.s @@ -265,7 +265,7 @@ _0802FFB6: adds r0, r4, #0 movs r2, #0xa0 movs r3, #0xa0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _080300A2 adds r0, r4, #0 diff --git a/asm/wizzrobeWind.s b/asm/wizzrobeWind.s index 0e24ccf7..ed1ca987 100644 --- a/asm/wizzrobeWind.s +++ b/asm/wizzrobeWind.s @@ -290,7 +290,7 @@ _0802F6B6: adds r0, r4, #0 movs r2, #0xa0 movs r3, #0xa0 - bl sub_080041A0 + bl EntityInRectRadius cmp r0, #0 beq _0802F7A2 adds r0, r4, #0 diff --git a/assets/assets.json b/assets/assets.json index 3363aa4e..38ff89a0 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -41601,7 +41601,7 @@ "size": 8 }, { - "path": "data_081146D0/gUnk_08114F88.bin", + "path": "data_081146D0/gPlayerHitbox.bin", "start": 1134472, "size": 16 }, @@ -41666,7 +41666,7 @@ "type": "sprite_frame" }, { - "path": "sprites/gSpriteFrames_Object6.bin", + "path": "sprites/gSpriteFrames_EzloCap.bin", "start": 1142228, "size": 400, "type": "sprite_frame" @@ -42750,16 +42750,6 @@ "DEMO_JP": -2192 } }, - { - "path": "data_0811E454/gUnk_0811E510.bin", - "start": 1172752, - "size": 4 - }, - { - "path": "data_0811E454/gUnk_0811E514.bin", - "start": 1172756, - "size": 16 - }, { "path": "data_0811E750/gUnk_0811E750.bin", "start": 1173328, @@ -43052,233 +43042,233 @@ "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_0.bin", + "path": "animations/gSpriteAnimations_EzloCap_0.bin", "start": 1175952, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_1.bin", + "path": "animations/gSpriteAnimations_EzloCap_1.bin", "start": 1175981, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_2.bin", + "path": "animations/gSpriteAnimations_EzloCap_2.bin", "start": 1176010, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_3.bin", + "path": "animations/gSpriteAnimations_EzloCap_3.bin", "start": 1176039, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_8.bin", + "path": "animations/gSpriteAnimations_EzloCap_8.bin", "start": 1176080, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_9.bin", + "path": "animations/gSpriteAnimations_EzloCap_9.bin", "start": 1176109, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_10.bin", + "path": "animations/gSpriteAnimations_EzloCap_10.bin", "start": 1176138, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_11.bin", + "path": "animations/gSpriteAnimations_EzloCap_11.bin", "start": 1176167, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_4.bin", + "path": "animations/gSpriteAnimations_EzloCap_4.bin", "start": 1176208, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_5.bin", + "path": "animations/gSpriteAnimations_EzloCap_5.bin", "start": 1176237, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_6.bin", + "path": "animations/gSpriteAnimations_EzloCap_6.bin", "start": 1176266, "size": 29, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_7.bin", + "path": "animations/gSpriteAnimations_EzloCap_7.bin", "start": 1176295, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_12.bin", + "path": "animations/gSpriteAnimations_EzloCap_12.bin", "start": 1176336, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_13.bin", + "path": "animations/gSpriteAnimations_EzloCap_13.bin", "start": 1176349, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_14.bin", + "path": "animations/gSpriteAnimations_EzloCap_14.bin", "start": 1176362, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_15.bin", + "path": "animations/gSpriteAnimations_EzloCap_15.bin", "start": 1176375, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_16.bin", + "path": "animations/gSpriteAnimations_EzloCap_16.bin", "start": 1176416, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_17.bin", + "path": "animations/gSpriteAnimations_EzloCap_17.bin", "start": 1176429, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_18.bin", + "path": "animations/gSpriteAnimations_EzloCap_18.bin", "start": 1176442, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_19.bin", + "path": "animations/gSpriteAnimations_EzloCap_19.bin", "start": 1176455, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_20.bin", + "path": "animations/gSpriteAnimations_EzloCap_20.bin", "start": 1176496, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_21.bin", + "path": "animations/gSpriteAnimations_EzloCap_21.bin", "start": 1176509, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_22.bin", + "path": "animations/gSpriteAnimations_EzloCap_22.bin", "start": 1176522, "size": 13, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_23.bin", + "path": "animations/gSpriteAnimations_EzloCap_23.bin", "start": 1176535, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_31.bin", + "path": "animations/gSpriteAnimations_EzloCap_31.bin", "start": 1176576, "size": 5, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_32.bin", + "path": "animations/gSpriteAnimations_EzloCap_32.bin", "start": 1176581, "size": 17, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_33.bin", + "path": "animations/gSpriteAnimations_EzloCap_33.bin", "start": 1176598, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_34.bin", + "path": "animations/gSpriteAnimations_EzloCap_34.bin", "start": 1176639, "size": 41, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_24.bin", + "path": "animations/gSpriteAnimations_EzloCap_24.bin", "start": 1176680, "size": 81, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_25.bin", + "path": "animations/gSpriteAnimations_EzloCap_25.bin", "start": 1176761, "size": 25, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_26.bin", + "path": "animations/gSpriteAnimations_EzloCap_26.bin", "start": 1176786, "size": 5, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_27.bin", + "path": "animations/gSpriteAnimations_EzloCap_27.bin", "start": 1176791, "size": 116, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_28.bin", + "path": "animations/gSpriteAnimations_EzloCap_28.bin", "start": 1176907, "size": 21, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_29.bin", + "path": "animations/gSpriteAnimations_EzloCap_29.bin", "start": 1176928, "size": 21, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_30.bin", + "path": "animations/gSpriteAnimations_EzloCap_30.bin", "start": 1176949, "size": 21, "type": "animation" }, { - "path": "animations/gSpriteAnimations_Object6_35.bin", + "path": "animations/gSpriteAnimations_EzloCap_35.bin", "start": 1176970, "size": 6, "type": "animation" }, { - "path": "object6/gUnk_0811F16C.bin", + "path": "ezloCap/gUnk_0811F16C.bin", "start": 1175916, "size": 12 }, { - "path": "object6/gUnk_0811F178.bin", + "path": "ezloCap/gUnk_0811F178.bin", "start": 1175928, "size": 20 }, { - "path": "object6/gUnk_0811F18C.bin", + "path": "ezloCap/gUnk_0811F18C.bin", "start": 1175948, "size": 4 }, diff --git a/data/animations/object/ezloCap.s b/data/animations/object/ezloCap.s new file mode 100644 index 00000000..4f83d368 --- /dev/null +++ b/data/animations/object/ezloCap.s @@ -0,0 +1,152 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +gSpriteAnimations_EzloCap_0:: @ 0811F190 + .include "animations/gSpriteAnimations_EzloCap_0.s" + +gSpriteAnimations_EzloCap_1:: @ 0811F1AD + .include "animations/gSpriteAnimations_EzloCap_1.s" + +gSpriteAnimations_EzloCap_2:: @ 0811F1CA + .include "animations/gSpriteAnimations_EzloCap_2.s" + +gSpriteAnimations_EzloCap_3:: @ 0811F1E7 + .include "animations/gSpriteAnimations_EzloCap_3.s" + +gSpriteAnimations_EzloCap_8:: @ 0811F210 + .include "animations/gSpriteAnimations_EzloCap_8.s" + +gSpriteAnimations_EzloCap_9:: @ 0811F22D + .include "animations/gSpriteAnimations_EzloCap_9.s" + +gSpriteAnimations_EzloCap_10:: @ 0811F24A + .include "animations/gSpriteAnimations_EzloCap_10.s" + +gSpriteAnimations_EzloCap_11:: @ 0811F267 + .include "animations/gSpriteAnimations_EzloCap_11.s" + +gSpriteAnimations_EzloCap_4:: @ 0811F290 + .include "animations/gSpriteAnimations_EzloCap_4.s" + +gSpriteAnimations_EzloCap_5:: @ 0811F2AD + .include "animations/gSpriteAnimations_EzloCap_5.s" + +gSpriteAnimations_EzloCap_6:: @ 0811F2CA + .include "animations/gSpriteAnimations_EzloCap_6.s" + +gSpriteAnimations_EzloCap_7:: @ 0811F2E7 + .include "animations/gSpriteAnimations_EzloCap_7.s" + +gSpriteAnimations_EzloCap_12:: @ 0811F310 + .include "animations/gSpriteAnimations_EzloCap_12.s" + +gSpriteAnimations_EzloCap_13:: @ 0811F31D + .include "animations/gSpriteAnimations_EzloCap_13.s" + +gSpriteAnimations_EzloCap_14:: @ 0811F32A + .include "animations/gSpriteAnimations_EzloCap_14.s" + +gSpriteAnimations_EzloCap_15:: @ 0811F337 + .include "animations/gSpriteAnimations_EzloCap_15.s" + +gSpriteAnimations_EzloCap_16:: @ 0811F360 + .include "animations/gSpriteAnimations_EzloCap_16.s" + +gSpriteAnimations_EzloCap_17:: @ 0811F36D + .include "animations/gSpriteAnimations_EzloCap_17.s" + +gSpriteAnimations_EzloCap_18:: @ 0811F37A + .include "animations/gSpriteAnimations_EzloCap_18.s" + +gSpriteAnimations_EzloCap_19:: @ 0811F387 + .include "animations/gSpriteAnimations_EzloCap_19.s" + +gSpriteAnimations_EzloCap_20:: @ 0811F3B0 + .include "animations/gSpriteAnimations_EzloCap_20.s" + +gSpriteAnimations_EzloCap_21:: @ 0811F3BD + .include "animations/gSpriteAnimations_EzloCap_21.s" + +gSpriteAnimations_EzloCap_22:: @ 0811F3CA + .include "animations/gSpriteAnimations_EzloCap_22.s" + +gSpriteAnimations_EzloCap_23:: @ 0811F3D7 + .include "animations/gSpriteAnimations_EzloCap_23.s" + +gSpriteAnimations_EzloCap_31:: @ 0811F400 + .include "animations/gSpriteAnimations_EzloCap_31.s" + +gSpriteAnimations_EzloCap_32:: @ 0811F405 + .include "animations/gSpriteAnimations_EzloCap_32.s" + +gSpriteAnimations_EzloCap_33:: @ 0811F416 + .include "animations/gSpriteAnimations_EzloCap_33.s" + +gSpriteAnimations_EzloCap_34:: @ 0811F43F + .include "animations/gSpriteAnimations_EzloCap_34.s" + +gSpriteAnimations_EzloCap_24:: @ 0811F468 + .include "animations/gSpriteAnimations_EzloCap_24.s" + +gSpriteAnimations_EzloCap_25:: @ 0811F4B9 + .include "animations/gSpriteAnimations_EzloCap_25.s" + +gSpriteAnimations_EzloCap_26:: @ 0811F4D2 + .include "animations/gSpriteAnimations_EzloCap_26.s" + +gSpriteAnimations_EzloCap_27:: @ 0811F4D7 + .include "animations/gSpriteAnimations_EzloCap_27.s" + +gSpriteAnimations_EzloCap_28:: @ 0811F54B + .include "animations/gSpriteAnimations_EzloCap_28.s" + +gSpriteAnimations_EzloCap_29:: @ 0811F560 + .include "animations/gSpriteAnimations_EzloCap_29.s" + +gSpriteAnimations_EzloCap_30:: @ 0811F575 + .include "animations/gSpriteAnimations_EzloCap_30.s" + +gSpriteAnimations_EzloCap_35:: @ 0811F58A + .include "animations/gSpriteAnimations_EzloCap_35.s" + +gSpriteAnimations_EzloCap:: @ 0811F590 + .4byte gSpriteAnimations_EzloCap_0 + .4byte gSpriteAnimations_EzloCap_1 + .4byte gSpriteAnimations_EzloCap_2 + .4byte gSpriteAnimations_EzloCap_3 + .4byte gSpriteAnimations_EzloCap_4 + .4byte gSpriteAnimations_EzloCap_5 + .4byte gSpriteAnimations_EzloCap_6 + .4byte gSpriteAnimations_EzloCap_7 + .4byte gSpriteAnimations_EzloCap_8 + .4byte gSpriteAnimations_EzloCap_9 + .4byte gSpriteAnimations_EzloCap_10 + .4byte gSpriteAnimations_EzloCap_11 + .4byte gSpriteAnimations_EzloCap_12 + .4byte gSpriteAnimations_EzloCap_13 + .4byte gSpriteAnimations_EzloCap_14 + .4byte gSpriteAnimations_EzloCap_15 + .4byte gSpriteAnimations_EzloCap_16 + .4byte gSpriteAnimations_EzloCap_17 + .4byte gSpriteAnimations_EzloCap_18 + .4byte gSpriteAnimations_EzloCap_19 + .4byte gSpriteAnimations_EzloCap_20 + .4byte gSpriteAnimations_EzloCap_21 + .4byte gSpriteAnimations_EzloCap_22 + .4byte gSpriteAnimations_EzloCap_23 + .4byte gSpriteAnimations_EzloCap_24 + .4byte gSpriteAnimations_EzloCap_25 + .4byte gSpriteAnimations_EzloCap_26 + .4byte gSpriteAnimations_EzloCap_27 + .4byte gSpriteAnimations_EzloCap_28 + .4byte gSpriteAnimations_EzloCap_29 + .4byte gSpriteAnimations_EzloCap_30 + .4byte gSpriteAnimations_EzloCap_31 + .4byte gSpriteAnimations_EzloCap_32 + .4byte gSpriteAnimations_EzloCap_33 + .4byte gSpriteAnimations_EzloCap_34 + .4byte gSpriteAnimations_EzloCap_35 + .4byte 00000000 diff --git a/data/animations/object/object6.s b/data/animations/object/object6.s deleted file mode 100644 index c4ab52b5..00000000 --- a/data/animations/object/object6.s +++ /dev/null @@ -1,152 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gSpriteAnimations_Object6_0:: @ 0811F190 - .include "animations/gSpriteAnimations_Object6_0.s" - -gSpriteAnimations_Object6_1:: @ 0811F1AD - .include "animations/gSpriteAnimations_Object6_1.s" - -gSpriteAnimations_Object6_2:: @ 0811F1CA - .include "animations/gSpriteAnimations_Object6_2.s" - -gSpriteAnimations_Object6_3:: @ 0811F1E7 - .include "animations/gSpriteAnimations_Object6_3.s" - -gSpriteAnimations_Object6_8:: @ 0811F210 - .include "animations/gSpriteAnimations_Object6_8.s" - -gSpriteAnimations_Object6_9:: @ 0811F22D - .include "animations/gSpriteAnimations_Object6_9.s" - -gSpriteAnimations_Object6_10:: @ 0811F24A - .include "animations/gSpriteAnimations_Object6_10.s" - -gSpriteAnimations_Object6_11:: @ 0811F267 - .include "animations/gSpriteAnimations_Object6_11.s" - -gSpriteAnimations_Object6_4:: @ 0811F290 - .include "animations/gSpriteAnimations_Object6_4.s" - -gSpriteAnimations_Object6_5:: @ 0811F2AD - .include "animations/gSpriteAnimations_Object6_5.s" - -gSpriteAnimations_Object6_6:: @ 0811F2CA - .include "animations/gSpriteAnimations_Object6_6.s" - -gSpriteAnimations_Object6_7:: @ 0811F2E7 - .include "animations/gSpriteAnimations_Object6_7.s" - -gSpriteAnimations_Object6_12:: @ 0811F310 - .include "animations/gSpriteAnimations_Object6_12.s" - -gSpriteAnimations_Object6_13:: @ 0811F31D - .include "animations/gSpriteAnimations_Object6_13.s" - -gSpriteAnimations_Object6_14:: @ 0811F32A - .include "animations/gSpriteAnimations_Object6_14.s" - -gSpriteAnimations_Object6_15:: @ 0811F337 - .include "animations/gSpriteAnimations_Object6_15.s" - -gSpriteAnimations_Object6_16:: @ 0811F360 - .include "animations/gSpriteAnimations_Object6_16.s" - -gSpriteAnimations_Object6_17:: @ 0811F36D - .include "animations/gSpriteAnimations_Object6_17.s" - -gSpriteAnimations_Object6_18:: @ 0811F37A - .include "animations/gSpriteAnimations_Object6_18.s" - -gSpriteAnimations_Object6_19:: @ 0811F387 - .include "animations/gSpriteAnimations_Object6_19.s" - -gSpriteAnimations_Object6_20:: @ 0811F3B0 - .include "animations/gSpriteAnimations_Object6_20.s" - -gSpriteAnimations_Object6_21:: @ 0811F3BD - .include "animations/gSpriteAnimations_Object6_21.s" - -gSpriteAnimations_Object6_22:: @ 0811F3CA - .include "animations/gSpriteAnimations_Object6_22.s" - -gSpriteAnimations_Object6_23:: @ 0811F3D7 - .include "animations/gSpriteAnimations_Object6_23.s" - -gSpriteAnimations_Object6_31:: @ 0811F400 - .include "animations/gSpriteAnimations_Object6_31.s" - -gSpriteAnimations_Object6_32:: @ 0811F405 - .include "animations/gSpriteAnimations_Object6_32.s" - -gSpriteAnimations_Object6_33:: @ 0811F416 - .include "animations/gSpriteAnimations_Object6_33.s" - -gSpriteAnimations_Object6_34:: @ 0811F43F - .include "animations/gSpriteAnimations_Object6_34.s" - -gSpriteAnimations_Object6_24:: @ 0811F468 - .include "animations/gSpriteAnimations_Object6_24.s" - -gSpriteAnimations_Object6_25:: @ 0811F4B9 - .include "animations/gSpriteAnimations_Object6_25.s" - -gSpriteAnimations_Object6_26:: @ 0811F4D2 - .include "animations/gSpriteAnimations_Object6_26.s" - -gSpriteAnimations_Object6_27:: @ 0811F4D7 - .include "animations/gSpriteAnimations_Object6_27.s" - -gSpriteAnimations_Object6_28:: @ 0811F54B - .include "animations/gSpriteAnimations_Object6_28.s" - -gSpriteAnimations_Object6_29:: @ 0811F560 - .include "animations/gSpriteAnimations_Object6_29.s" - -gSpriteAnimations_Object6_30:: @ 0811F575 - .include "animations/gSpriteAnimations_Object6_30.s" - -gSpriteAnimations_Object6_35:: @ 0811F58A - .include "animations/gSpriteAnimations_Object6_35.s" - -gSpriteAnimations_Object6:: @ 0811F590 - .4byte gSpriteAnimations_Object6_0 - .4byte gSpriteAnimations_Object6_1 - .4byte gSpriteAnimations_Object6_2 - .4byte gSpriteAnimations_Object6_3 - .4byte gSpriteAnimations_Object6_4 - .4byte gSpriteAnimations_Object6_5 - .4byte gSpriteAnimations_Object6_6 - .4byte gSpriteAnimations_Object6_7 - .4byte gSpriteAnimations_Object6_8 - .4byte gSpriteAnimations_Object6_9 - .4byte gSpriteAnimations_Object6_10 - .4byte gSpriteAnimations_Object6_11 - .4byte gSpriteAnimations_Object6_12 - .4byte gSpriteAnimations_Object6_13 - .4byte gSpriteAnimations_Object6_14 - .4byte gSpriteAnimations_Object6_15 - .4byte gSpriteAnimations_Object6_16 - .4byte gSpriteAnimations_Object6_17 - .4byte gSpriteAnimations_Object6_18 - .4byte gSpriteAnimations_Object6_19 - .4byte gSpriteAnimations_Object6_20 - .4byte gSpriteAnimations_Object6_21 - .4byte gSpriteAnimations_Object6_22 - .4byte gSpriteAnimations_Object6_23 - .4byte gSpriteAnimations_Object6_24 - .4byte gSpriteAnimations_Object6_25 - .4byte gSpriteAnimations_Object6_26 - .4byte gSpriteAnimations_Object6_27 - .4byte gSpriteAnimations_Object6_28 - .4byte gSpriteAnimations_Object6_29 - .4byte gSpriteAnimations_Object6_30 - .4byte gSpriteAnimations_Object6_31 - .4byte gSpriteAnimations_Object6_32 - .4byte gSpriteAnimations_Object6_33 - .4byte gSpriteAnimations_Object6_34 - .4byte gSpriteAnimations_Object6_35 - .4byte 00000000 diff --git a/data/const/object/object6.s b/data/const/object/ezloCap.s similarity index 79% rename from data/const/object/object6.s rename to data/const/object/ezloCap.s index 6b9aebe2..54828709 100644 --- a/data/const/object/object6.s +++ b/data/const/object/ezloCap.s @@ -19,10 +19,10 @@ gUnk_0811F15C:: @ 0811F15C .4byte sub_08082E6C gUnk_0811F16C:: @ 0811F16C - .incbin "object6/gUnk_0811F16C.bin" + .incbin "ezloCap/gUnk_0811F16C.bin" gUnk_0811F178:: @ 0811F178 - .incbin "object6/gUnk_0811F178.bin" + .incbin "ezloCap/gUnk_0811F178.bin" gUnk_0811F18C:: @ 0811F18C - .incbin "object6/gUnk_0811F18C.bin" + .incbin "ezloCap/gUnk_0811F18C.bin" diff --git a/data/data_081146D0.s b/data/data_081146D0.s index 269f070b..5dd1d12c 100644 --- a/data/data_081146D0.s +++ b/data/data_081146D0.s @@ -48,6 +48,6 @@ gUnk_08114F78:: @ 08114F78 gUnk_08114F80:: @ 08114F80 .incbin "data_081146D0/gUnk_08114F80.bin" -gUnk_08114F88:: @ 08114F88 - .incbin "data_081146D0/gUnk_08114F88.bin" +gPlayerHitbox:: @ 08114F88 + .incbin "data_081146D0/gPlayerHitbox.bin" diff --git a/data/data_0811B9E0.s b/data/data_0811B9E0.s index a134b2da..fed89541 100644 --- a/data/data_0811B9E0.s +++ b/data/data_0811B9E0.s @@ -4,156 +4,6 @@ .section .rodata .align 2 -gUnk_0811BA60:: @ 0811BA60 - .4byte sub_08070C3C - .4byte sub_08070CB4 - -gUnk_0811BA68:: @ 0811BA68 - .4byte sub_08070D38 - .4byte sub_08070DC4 - .4byte sub_08070E7C - -gUnk_0811BA74:: @ 0811BA74 - .4byte sub_08070EDC - .4byte sub_08070f24 - -gUnk_0811BA7C:: @ 0811BA7C - .4byte sub_08070FA4 - .4byte sub_08071020 - .4byte sub_08071038 - -gUnk_0811BA88:: @ 0811BA88 - .4byte sub_080710A8 - .4byte sub_08071130 - .4byte sub_08071208 - -gUnk_0811BA94:: @ 0811BA94 - .4byte sub_0807127C - .4byte sub_080712F0 - -gUnk_0811BA9C:: @ 0811BA9C - .4byte PortalJumpOnUpdate - .4byte PortalStandUpdate - .4byte PortalActivateInit - .4byte PortalActivateUpdate - .4byte PortalShrinkInit - .4byte PortalShrinkUpdate - .4byte PortalEnterUpdate - .4byte PortalUnknownUpdate - -gUnk_0811BABC:: @ 0811BABC - .incbin "data_0811B9E0/gUnk_0811BABC.bin" - -gUnk_0811BAC4:: @ 0811BAC4 - .incbin "data_0811B9E0/gUnk_0811BAC4.bin" - -gUnk_0811BAD4:: @ 0811BAD4 - .4byte sub_080718A0 - .4byte sub_0807193C - .4byte sub_08071990 - .4byte sub_08071A4C - -gUnk_0811BAE4:: @ 0811BAE4 - .4byte sub_08071AB0 - .4byte sub_08071AF0 - .4byte sub_08071B60 - -gUnk_0811BAF0:: @ 0811BAF0 - .incbin "data_0811B9E0/gUnk_0811BAF0.bin" - -gUnk_0811BB2C:: @ 0811BB2C - .4byte sub_08071BDC - .4byte sub_08071CAC - .4byte sub_08071D04 - .4byte sub_08071D80 - -gUnk_0811BB3C:: @ 0811BB3C - .4byte sub_08071DD0 - .4byte sub_08071E04 - .4byte sub_08071E74 - -gUnk_0811BB48:: @ 0811BB48 - .4byte sub_08071EB0 - .4byte sub_08071F14 - -gUnk_0811BB50:: @ 0811BB50 - .4byte sub_08071F50 - .4byte sub_08071F80 - -gUnk_0811BB58:: @ 0811BB58 - .4byte sub_08072064 - .4byte sub_08072098 - -gUnk_0811BB60:: @ 0811BB60 - .4byte sub_08072100 - .4byte sub_08072168 - -gUnk_0811BB68:: @ 0811BB68 - .4byte sub_08072214 - .4byte sub_08072260 - -gUnk_0811BB70:: @ 0811BB70 - .4byte sub_080722DC - .4byte sub_08072354 - .4byte sub_080723D0 - .4byte sub_0807240C - -gUnk_0811BB80:: @ 0811BB80 - .4byte sub_0807246C - .4byte sub_08072490 - -gUnk_0811BB88:: @ 0811BB88 - .4byte sub_080724DC - .4byte sub_0807258C - -gUnk_0811BB90:: @ 0811BB90 - .4byte sub_08072650 - .4byte sub_080726F4 - -gUnk_0811BB98:: @ 0811BB98 - .4byte sub_08072970 - .4byte sub_08072A60 - .4byte sub_08072ACC - .4byte sub_08072B5C - .4byte sub_08072C48 - -gUnk_0811BBAC:: @ 0811BBAC - .4byte sub_08072CC0 - .4byte sub_08072CFC - .4byte sub_08072D54 - .4byte sub_08072F14 - -gUnk_0811BBBC:: @ 0811BBBC - .incbin "data_0811B9E0/gUnk_0811BBBC.bin" - -gUnk_0811BBC2:: @ 0811BBC2 - .incbin "data_0811B9E0/gUnk_0811BBC2.bin" - -gUnk_0811BBC8:: @ 0811BBC8 - .incbin "data_0811B9E0/gUnk_0811BBC8.bin" - -gUnk_0811BBCE:: @ 0811BBCE - .incbin "data_0811B9E0/gUnk_0811BBCE.bin" - -gUnk_0811BBD4:: @ 0811BBD4 - .4byte gUnk_0811BBBC - .4byte gUnk_0811BBC2 - .4byte gUnk_0811BBC8 - .4byte gUnk_0811BBCE - -gUnk_0811BBE4:: @ 0811BBE4 - .4byte sub_08072F94 - .4byte sub_08073094 - -gUnk_0811BBEC:: @ 0811BBEC - .incbin "data_0811B9E0/gUnk_0811BBEC.bin" - -gUnk_0811BBF8:: @ 0811BBF8 - .4byte sub_080731D8 - .4byte sub_080732D0 - .4byte sub_0807332C - .4byte sub_080733BC - gUnk_0811BC08:: @ 0811BC08 .4byte sub_08073468 .4byte sub_080734D4 diff --git a/data/data_0811E454.s b/data/data_0811E454.s deleted file mode 100755 index 577fc188..00000000 --- a/data/data_0811E454.s +++ /dev/null @@ -1,11 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811E510:: @ 0811E510 - .incbin "data_0811E454/gUnk_0811E510.bin" - -gUnk_0811E514:: @ 0811E514 - .incbin "data_0811E454/gUnk_0811E514.bin" diff --git a/data/data_0811E750.s b/data/data_0811E750.s index 4f280273..df1745c8 100644 --- a/data/data_0811E750.s +++ b/data/data_0811E750.s @@ -4,15 +4,6 @@ .section .rodata .align 2 -gUnk_0811E750:: @ 0811E750 - .incbin "data_0811E750/gUnk_0811E750.bin" - -gUnk_0811E758:: @ 0811E758 - .incbin "data_0811E750/gUnk_0811E758.bin" - -gUnk_0811E760:: @ 0811E760 - .incbin "data_0811E750/gUnk_0811E760.bin" - gUnk_0811E768:: @ 0811E768 .4byte sub_0807FC64 .4byte sub_0807FC7C diff --git a/data/gfx/sprite_frames.s b/data/gfx/sprite_frames.s index f1a2f307..6dc4cd56 100644 --- a/data/gfx/sprite_frames.s +++ b/data/gfx/sprite_frames.s @@ -34,8 +34,8 @@ gSpriteFrames_9:: @ 08116A9C gSpriteFrames_Object4:: @ 08116D0C .include "sprites/gSpriteFrames_Object4.s" -gSpriteFrames_Object6:: @ 08116DD4 - .include "sprites/gSpriteFrames_Object6.s" +gSpriteFrames_EzloCap:: @ 08116DD4 + .include "sprites/gSpriteFrames_EzloCap.s" gSpriteFrames_12:: @ 08116F64 .include "sprites/gSpriteFrames_12.s" diff --git a/data/gfx/sprite_ptrs.s b/data/gfx/sprite_ptrs.s index 45ed5370..00f76d64 100644 --- a/data/gfx/sprite_ptrs.s +++ b/data/gfx/sprite_ptrs.s @@ -60,8 +60,8 @@ gSpritePtrs:: @ 080029B4 .4byte gSprite_Link .4byte 00000000 - .4byte gSpriteAnimations_Object6 - .4byte gSpriteFrames_Object6 + .4byte gSpriteAnimations_EzloCap + .4byte gSpriteFrames_EzloCap .4byte gSprite_Link .4byte 00000000 diff --git a/data/scripts/script_08008D8C.inc b/data/scripts/script_08008D8C.inc index 1dd05221..1b34fcb9 100644 --- a/data/scripts/script_08008D8C.inc +++ b/data/scripts/script_08008D8C.inc @@ -81,7 +81,7 @@ script_08008E12: _0807E5F8 0x00000001 WaitForSomething2 0x00000002 _0807F034 0x0035 - WaitPlayerAction8 + WaitPlayerGetItem StartPlayerScript script_08008FC0 WaitForSomething2 0x00000020 _0807E8E4_0 @@ -95,7 +95,7 @@ script_08008E12: _0807E5F8 0x00000001 WaitForSomething2 0x00000002 _0807F034 0x0047 - WaitPlayerAction8 + WaitPlayerGetItem SetIntVariable 0x00000003 Call sub_0807F420 _0807E8E4_0 diff --git a/data/scripts/script_08009464.inc b/data/scripts/script_08009464.inc index 26dafb65..05f2b9d0 100644 --- a/data/scripts/script_08009464.inc +++ b/data/scripts/script_08009464.inc @@ -20,7 +20,7 @@ SCRIPT_START script_08009464 .endif Call sub_0806D620 Wait 0x003c - WaitPlayerAction8 + WaitPlayerGetItem _0807EB8C MessageNoOverlap 0x1d0c WaitUntilTextboxCloses diff --git a/data/scripts/script_080095F2.inc b/data/scripts/script_080095F2.inc index 4b5abf8d..a0b52a09 100644 --- a/data/scripts/script_080095F2.inc +++ b/data/scripts/script_080095F2.inc @@ -10,7 +10,7 @@ SCRIPT_START script_080095F2 PlaySound SFX_109 _0807F088 0x003c MessageFromTarget 0x053c - WaitPlayerAction8 + WaitPlayerGetItem WaitUntilTextboxCloses _0807F078 0x003c, 0x0001 script_08009622: diff --git a/data/scripts/script_08009B78.inc b/data/scripts/script_08009B78.inc index 04b88f0d..10bffa01 100644 --- a/data/scripts/script_08009B78.inc +++ b/data/scripts/script_08009B78.inc @@ -42,7 +42,7 @@ SCRIPT_START script_08009B78 WaitForSomething2 0x00000008 Call sub_08053250 _0807F034 0x0034 - WaitPlayerAction8 + WaitPlayerGetItem _0807E8E4_1 DoPostScriptAction 0x0001 MessageFromTargetPos 0x100c, 0x0000 diff --git a/data/scripts/script_08009F14.inc b/data/scripts/script_08009F14.inc index 48c49a06..16130637 100644 --- a/data/scripts/script_08009F14.inc +++ b/data/scripts/script_08009F14.inc @@ -25,7 +25,7 @@ script_08009F36: WaitUntilTextboxCloses Wait 0x001e _0807F034 0x0065 - WaitPlayerAction8 + WaitPlayerGetItem DoPostScriptAction 0x000a Call sub_0807DF50 _0807E878 @@ -74,7 +74,7 @@ script_0800A002: Wait 0x0008 _0807F034 0x0008 Call sub_08060318 - WaitPlayerAction8 + WaitPlayerGetItem Wait 0x0008 _0807EB8C MessageFromTarget 0x1f13 @@ -108,7 +108,7 @@ script_0800A064: Wait 0x0008 _0807F034 0x0007 Call sub_08060318 - WaitPlayerAction8 + WaitPlayerGetItem Wait 0x0008 _0807EB8C MessageFromTarget 0x1f10 diff --git a/data/scripts/script_0800AB6E.inc b/data/scripts/script_0800AB6E.inc index da617bfc..6b859b90 100644 --- a/data/scripts/script_0800AB6E.inc +++ b/data/scripts/script_0800AB6E.inc @@ -5,7 +5,7 @@ SCRIPT_START script_0800AB6E _0807E8E4_0 _0807E5F8 0x00000040 WaitForSomething2 0x00000080 - SetEntityPosition 0x0000, 0xffe0 + OffsetEntityPosition 0x0000, 0xffe0 Call sub_0807F5C0 Wait 0x003c CallWithArg DeleteManager36, 0x00000001 @@ -26,7 +26,7 @@ SCRIPT_START script_0800AB6E _0807E5F8 0x00000008 _0807E5F8 0x00000002 WaitForSomething2 0x00000004 - SetEntityPosition 0x0000, 0x0020 + OffsetEntityPosition 0x0000, 0x0020 Call sub_0807F5C0 WaitForSomething2 0x00000010 StartPlayerScript script_0800ACE0 @@ -36,7 +36,7 @@ SCRIPT_START script_0800AB6E WaitUntilTextboxCloses MessageFromTargetPos 0x1663, 0x000e WaitUntilTextboxCloses - SetEntityPosition 0x0000, 0xffe0 + OffsetEntityPosition 0x0000, 0xffe0 Call sub_0807F5C0 _0807E5F8 0x00000002 WaitForSomething2 0x00000004 diff --git a/data/scripts/script_0800B41C.inc b/data/scripts/script_0800B41C.inc index 4eebd83c..edc7331b 100644 --- a/data/scripts/script_0800B41C.inc +++ b/data/scripts/script_0800B41C.inc @@ -17,7 +17,7 @@ SCRIPT_START script_0800B41C Wait 0x003c PlaySound SFX_TASK_COMPLETE _0807F088 0x0037 - WaitPlayerAction8 + WaitPlayerGetItem _0807EB8C MessageFromTarget 0x200c WaitUntilTextboxCloses diff --git a/data/scripts/script_0800B5EC.inc b/data/scripts/script_0800B5EC.inc index b00d322d..2ec4bf11 100644 --- a/data/scripts/script_0800B5EC.inc +++ b/data/scripts/script_0800B5EC.inc @@ -49,7 +49,7 @@ script_0800B68E: SetLocalFlag 0x009e _0807F034 0x0066 script_0800B698: - WaitPlayerAction8 + WaitPlayerGetItem _0807EB8C Wait 0x001e MessageNoOverlap 0x057f diff --git a/data/scripts/script_0800C550.inc b/data/scripts/script_0800C550.inc index 313ff8ec..14f85748 100644 --- a/data/scripts/script_0800C550.inc +++ b/data/scripts/script_0800C550.inc @@ -89,7 +89,7 @@ SCRIPT_START script_0800C634 _0807EB44 0x0004 CheckLocalFlag 0x0082 JumpIfNot script_0800C650 - SetEntityPosition 0x0010, 0x0000 + OffsetEntityPosition 0x0010, 0x0000 script_0800C650: EndBlock script_0800C652: diff --git a/data/scripts/script_0800CD7C.inc b/data/scripts/script_0800CD7C.inc index 69d3a300..5a3bef29 100644 --- a/data/scripts/script_0800CD7C.inc +++ b/data/scripts/script_0800CD7C.inc @@ -43,7 +43,7 @@ script_0800CDEC: JumpIfNot script_0800CF40 PlaySound SFX_TASK_COMPLETE _0807F088 0x0023 - WaitPlayerAction8 + WaitPlayerGetItem Jump script_0800CE32 script_0800CE14: _0807E48C 0x0022 @@ -54,7 +54,7 @@ script_0800CE14: JumpIfNot script_0800CF40 PlaySound SFX_TASK_COMPLETE _0807F088 0x0022 - WaitPlayerAction8 + WaitPlayerGetItem script_0800CE32: _0807EB8C SetGlobalFlag 0x0054 @@ -83,7 +83,7 @@ script_0800CE6E: JumpIfNot script_0800CF40 PlaySound SFX_TASK_COMPLETE _0807F088 0x0027 - WaitPlayerAction8 + WaitPlayerGetItem _0807EB8C SetGlobalFlag 0x0054 Call sub_08060340 @@ -111,7 +111,7 @@ script_0800CECE: JumpIfNot script_0800CF40 PlaySound SFX_TASK_COMPLETE _0807F088 0x0024 - WaitPlayerAction8 + WaitPlayerGetItem _0807EB8C SetGlobalFlag 0x0054 Call sub_08060340 diff --git a/data/scripts/script_0800D874.inc b/data/scripts/script_0800D874.inc index 9b20129e..6e7a1185 100644 --- a/data/scripts/script_0800D874.inc +++ b/data/scripts/script_0800D874.inc @@ -42,7 +42,7 @@ script_0800D8F4: JumpIfNot script_0800D8F4 Call sub_0807DF28 _0807E864 - WaitPlayerAction8 + WaitPlayerGetItem _0807EB28 0x1325 WaitUntilTextboxCloses PlaySound SFX_113 diff --git a/data/scripts/script_0800D954.inc b/data/scripts/script_0800D954.inc index 8ca3a5dd..3ddd4c9d 100644 --- a/data/scripts/script_0800D954.inc +++ b/data/scripts/script_0800D954.inc @@ -27,7 +27,7 @@ script_0800D962: _0807E5F8 0x00000004 WaitForSomething2 0x00000002 _0807F050 0x006d - WaitPlayerAction8 + WaitPlayerGetItem _0807EB28 0x1703 WaitUntilTextboxCloses Wait 0x003c diff --git a/data/scripts/script_0800E0BC.inc b/data/scripts/script_0800E0BC.inc index dadd18a9..3b30dd5e 100644 --- a/data/scripts/script_0800E0BC.inc +++ b/data/scripts/script_0800E0BC.inc @@ -227,7 +227,7 @@ script_0800E3C8: WaitUntilTextboxCloses Wait 0x000f _0807F034 0x0053 - WaitPlayerAction8 + WaitPlayerGetItem SetLocalFlag 0x0071 _0807E878 script_0800E3E8: diff --git a/data/scripts/script_0800E6B0.inc b/data/scripts/script_0800E6B0.inc index 6e3a7acd..3ecd0d05 100644 --- a/data/scripts/script_0800E6B0.inc +++ b/data/scripts/script_0800E6B0.inc @@ -41,7 +41,7 @@ script_0800E708: script_0800E722: WaitUntilTextboxCloses _0807F034 0x0057 - WaitPlayerAction8 + WaitPlayerGetItem WaitUntilTextboxCloses _0807E878 Jump script_0800E6F4 diff --git a/data/scripts/script_0800EA54.inc b/data/scripts/script_0800EA54.inc index ab672332..be000e41 100644 --- a/data/scripts/script_0800EA54.inc +++ b/data/scripts/script_0800EA54.inc @@ -220,7 +220,7 @@ script_0800ED20: WaitUntilTextboxCloses JumpIfNot script_0800ED46 _0807F050 0x0070 - WaitPlayerAction8 + WaitPlayerGetItem script_0800ED46: _0807E878 Call sub_08063874 diff --git a/data/scripts/script_0800EFC0.inc b/data/scripts/script_0800EFC0.inc index d8d298e3..58456975 100644 --- a/data/scripts/script_0800EFC0.inc +++ b/data/scripts/script_0800EFC0.inc @@ -66,7 +66,7 @@ script_0800F09A: MessageFromTargetPos 0x1202, 0x000c WaitUntilTextboxCloses _0807F034 0x0067 - WaitPlayerAction8 + WaitPlayerGetItem _0807E8E4_0 _0807E5F8 0x00000002 WaitForSomething2 0x00000040 diff --git a/data/scripts/script_0800F724.inc b/data/scripts/script_0800F724.inc index bf480cfd..acc3e12f 100644 --- a/data/scripts/script_0800F724.inc +++ b/data/scripts/script_0800F724.inc @@ -175,7 +175,7 @@ SCRIPT_START script_0800F73C MessageFromTargetPos 0x102b, 0x0000 WaitUntilTextboxCloses _0807F034 0x000d - WaitPlayerAction8 + WaitPlayerGetItem Call sub_0806DC3C Call sub_080791BC CallWithArg sub_0807F244, 0x0000000d diff --git a/data/scripts/script_080100C8.inc b/data/scripts/script_080100C8.inc index 5181354d..360411e1 100644 --- a/data/scripts/script_080100C8.inc +++ b/data/scripts/script_080100C8.inc @@ -107,7 +107,7 @@ script_080101AC: WaitUntilTextboxCloses JumpIfNot script_08010240 Call sub_080A13E8 - WaitPlayerAction8 + WaitPlayerGetItem Call sub_080A1460 WaitUntilTextboxCloses Call sub_080A14A8 diff --git a/data/scripts/script_08010264.inc b/data/scripts/script_08010264.inc index 6ca8b25e..d088e35d 100644 --- a/data/scripts/script_08010264.inc +++ b/data/scripts/script_08010264.inc @@ -246,7 +246,7 @@ script_08010570: MessageNoOverlap 0x2b07 WaitUntilTextboxCloses CallWithArg sub_0807F800, 0x00000000 - WaitPlayerAction8 + WaitPlayerGetItem WaitUntilTextboxCloses MessageNoOverlap 0x2b0c Jump script_080105E0 @@ -366,14 +366,14 @@ script_080106E0: MessageNoOverlap 0x3c04 Jump script_08010726 script_0801070C: - WaitPlayerAction8 + WaitPlayerGetItem ModHealth 0x0008 Call sub_08062EDC JumpIf script_08010724 MessageNoOverlap 0x3c06 Jump script_08010726 script_08010724: - WaitPlayerAction8 + WaitPlayerGetItem script_08010726: WaitUntilTextboxCloses _0807E878 @@ -489,7 +489,7 @@ script_08010860: JumpIfNot script_080108B2 Call GoronMerchant_TryToBuyKinstone JumpIfNot script_080108B2 - WaitPlayerAction8 + WaitPlayerGetItem WaitUntilTextboxCloses _0807EB8C CheckGlobalFlag 0x0042 diff --git a/data/scripts/script_08011B40.inc b/data/scripts/script_08011B40.inc index 3054956e..461cbf23 100644 --- a/data/scripts/script_08011B40.inc +++ b/data/scripts/script_08011B40.inc @@ -74,7 +74,7 @@ script_08011C28: CheckLocalFlag 0x0001 JumpIfNot script_08011C28 _0807E888 - WaitPlayerAction8 + WaitPlayerGetItem Wait 0x001e CallWithArg sub_0806C2A0, 0x00000000 WaitFor_2 diff --git a/data/scripts/script_08011C7C.inc b/data/scripts/script_08011C7C.inc index 519811d2..bc4f9a5e 100644 --- a/data/scripts/script_08011C7C.inc +++ b/data/scripts/script_08011C7C.inc @@ -362,7 +362,7 @@ script_08012070: MessageNoOverlap 0x3125 WaitUntilTextboxCloses _0807F034 0x0031 - WaitPlayerAction8 + WaitPlayerGetItem .ifdef USA Call sub_0807FC24 .else @@ -420,7 +420,7 @@ script_080120FC: MessageNoOverlap 0x3119 WaitUntilTextboxCloses _0807F034 0x002f - WaitPlayerAction8 + WaitPlayerGetItem .ifdef USA Call sub_0807FC24 .else @@ -478,7 +478,7 @@ script_08012188: MessageNoOverlap 0x311f WaitUntilTextboxCloses _0807F034 0x0030 - WaitPlayerAction8 + WaitPlayerGetItem .ifdef USA Call sub_0807FC24 .else diff --git a/data/scripts/script_0801232C.inc b/data/scripts/script_0801232C.inc index 326bc40e..82ed1d1a 100644 --- a/data/scripts/script_0801232C.inc +++ b/data/scripts/script_0801232C.inc @@ -15,7 +15,7 @@ script_08012338: JumpIf script_0801235A SetLocalFlag 0x0042 _0807F034 0x0057 - WaitPlayerAction8 + WaitPlayerGetItem script_0801235A: _0807E878 Jump script_08012338 diff --git a/data/scripts/script_08012430.inc b/data/scripts/script_08012430.inc index 0a87a50e..5390ddeb 100644 --- a/data/scripts/script_08012430.inc +++ b/data/scripts/script_08012430.inc @@ -17,7 +17,7 @@ script_08012440: JumpIf script_08012474 SetLocalFlag 0x00b3 _0807F034 0x0062 - WaitPlayerAction8 + WaitPlayerGetItem .ifdef USA SetLocalFlag 0x00d0 .else diff --git a/data/scripts/script_08012F86.inc b/data/scripts/script_08012F86.inc index fdd495d6..13ddc6bf 100644 --- a/data/scripts/script_08012F86.inc +++ b/data/scripts/script_08012F86.inc @@ -39,7 +39,7 @@ script_08013006: EndBlock PlaySound SFX_TASK_COMPLETE _0807F088 0x0038 - WaitPlayerAction8 + WaitPlayerGetItem Wait 0x001e _0807E8E4_0 Call sub_0806AB9C @@ -62,7 +62,7 @@ script_08013006: WaitUntilTextboxCloses _0807E5F8 0x00000200 _0807F034 0x0015 - WaitPlayerAction8 + WaitPlayerGetItem _0807EB8C MessageNoOverlap 0x4406 WaitUntilTextboxCloses diff --git a/data/scripts/script_0801319A.inc b/data/scripts/script_0801319A.inc index c32c850d..0f1b052e 100644 --- a/data/scripts/script_0801319A.inc +++ b/data/scripts/script_0801319A.inc @@ -24,7 +24,7 @@ SCRIPT_START script_080131AC StartPlayerScript script_08013330 WaitForSomething2 0x00000002 MoveEntityToPlayer - SetEntityPosition 0x0000, 0xfff0 + OffsetEntityPosition 0x0000, 0xfff0 Call sub_0807F844 CameraTargetEntity Call sub_080536B8 diff --git a/data/scripts/script_08014094.inc b/data/scripts/script_08014094.inc index 804c7748..ba91ee5c 100644 --- a/data/scripts/script_08014094.inc +++ b/data/scripts/script_08014094.inc @@ -3,7 +3,7 @@ SCRIPT_START script_08014094 DoPostScriptAction 0x0007 _0807E930 0x0002 Call sub_0807F738 - SetEntityPosition 0x0000, 0xfff0 + OffsetEntityPosition 0x0000, 0xfff0 EndBlock WaitForSomething 0x00000040 DoPostScriptAction 0x0006 diff --git a/data/scripts/script_080140B8.inc b/data/scripts/script_080140B8.inc index 94996896..200930ac 100644 --- a/data/scripts/script_080140B8.inc +++ b/data/scripts/script_080140B8.inc @@ -3,7 +3,7 @@ SCRIPT_START script_080140B8 DoPostScriptAction 0x0007 _0807E930 0x0003 Call sub_0807F738 - SetEntityPosition 0x0000, 0xfff0 + OffsetEntityPosition 0x0000, 0xfff0 EndBlock WaitForSomething 0x00000040 DoPostScriptAction 0x0006 diff --git a/data/scripts/script_08014154.inc b/data/scripts/script_08014154.inc index 5f7ddbf6..175080d4 100644 --- a/data/scripts/script_08014154.inc +++ b/data/scripts/script_08014154.inc @@ -2,7 +2,7 @@ SCRIPT_START script_08014154 BeginBlock DoPostScriptAction 0x0007 _0807E930 0x0006 - SetEntityPosition 0x0000, 0xfff0 + OffsetEntityPosition 0x0000, 0xfff0 EndBlock WaitForSomething2 0x00000800 _0807E930 0x000a diff --git a/data/scripts/script_08014198.inc b/data/scripts/script_08014198.inc index c3506e6f..23954b49 100644 --- a/data/scripts/script_08014198.inc +++ b/data/scripts/script_08014198.inc @@ -2,7 +2,7 @@ SCRIPT_START script_08014198 BeginBlock DoPostScriptAction 0x0007 _0807E930 0x0007 - SetEntityPosition 0x0000, 0xfff0 + OffsetEntityPosition 0x0000, 0xfff0 EndBlock WaitForSomething2 0x00001000 _0807E930 0x000b diff --git a/data/scripts/script_080143C0.inc b/data/scripts/script_080143C0.inc index dc3c8b0f..a47c473e 100644 --- a/data/scripts/script_080143C0.inc +++ b/data/scripts/script_080143C0.inc @@ -22,7 +22,7 @@ script_080143FA: SetIntVariable 0x00000000 Call sub_08065528 _0807F034 0x0036 - WaitPlayerAction8 + WaitPlayerGetItem MessageNoOverlap 0x2c19 WaitUntilTextboxCloses SetIntVariable 0x00000303 diff --git a/data/scripts/script_080145E8.inc b/data/scripts/script_080145E8.inc index cd83bffc..43290291 100644 --- a/data/scripts/script_080145E8.inc +++ b/data/scripts/script_080145E8.inc @@ -233,7 +233,7 @@ script_0801478A: Call sub_08088478 WaitUntilTextboxCloses Call sub_080885B0 - WaitPlayerAction8 + WaitPlayerGetItem _0807E5F8 0x00000008 Jump script_080147CE script_080147A4: diff --git a/data/scripts/script_08014B34.inc b/data/scripts/script_08014B34.inc index a53d3c1f..fd880ee7 100644 --- a/data/scripts/script_08014B34.inc +++ b/data/scripts/script_08014B34.inc @@ -60,7 +60,7 @@ script_08014BF2: WaitUntilTextboxCloses SetIntVariable 0x00000064 _0807F034 0x003f - WaitPlayerAction8 + WaitPlayerGetItem Jump script_08014C22 script_08014C1C: MessageNoOverlap 0x2f08 @@ -93,7 +93,7 @@ script_08014C56: MessageNoOverlap 0x2f0d WaitUntilTextboxCloses _0807F034 0x000a - WaitPlayerAction8 + WaitPlayerGetItem Jump script_08014C82 script_08014C7C: MessageNoOverlap 0x2f09 diff --git a/data/scripts/script_08014E14.inc b/data/scripts/script_08014E14.inc index a42da868..86972a81 100644 --- a/data/scripts/script_08014E14.inc +++ b/data/scripts/script_08014E14.inc @@ -38,7 +38,7 @@ script_08014E64: _0807E48C 0x0020 JumpIfNot script_08014EB8 CallWithArg sub_0807F800, 0x00000022 - WaitPlayerAction8 + WaitPlayerGetItem MessageNoOverlap 0x0a04 Jump script_08014EBC script_08014EB0: @@ -117,7 +117,7 @@ script_08014F4A: JumpIfNot script_08014FA2 ModRupees 0xff9c _0807F034 0x0022 - WaitPlayerAction8 + WaitPlayerGetItem MessageNoOverlap 0x3b11 Jump script_08014FA6 script_08014F9A: diff --git a/data/scripts/script_08016062.inc b/data/scripts/script_08016062.inc index d3b89b6b..fb0d6300 100644 --- a/data/scripts/script_08016062.inc +++ b/data/scripts/script_08016062.inc @@ -1,4 +1,4 @@ SCRIPT_START script_08016062 - SetEntityPosition 0xfff0, 0x0000 + OffsetEntityPosition 0xfff0, 0x0000 SCRIPT_END .2byte 0x0000 diff --git a/data/scripts/script_0801609E.inc b/data/scripts/script_0801609E.inc index 22853136..e11bf37f 100644 --- a/data/scripts/script_0801609E.inc +++ b/data/scripts/script_0801609E.inc @@ -1,4 +1,4 @@ SCRIPT_START script_0801609E - SetEntityPosition 0x0010, 0x0000 + OffsetEntityPosition 0x0010, 0x0000 SCRIPT_END .2byte 0x0000 diff --git a/data/scripts/script_080160A8.inc b/data/scripts/script_080160A8.inc index 576ed2c3..eba0a74e 100644 --- a/data/scripts/script_080160A8.inc +++ b/data/scripts/script_080160A8.inc @@ -33,7 +33,7 @@ script_080160E0: WaitUntilTextboxCloses Jump script_08016132 script_0801610C: - WaitPlayerAction8 + WaitPlayerGetItem .ifndef EU _0807EB8C MessageFromTarget 0x2d0d @@ -79,7 +79,7 @@ script_08016172: MessageFromTarget 0x2d0b Jump script_0801618A script_08016184: - WaitPlayerAction8 + WaitPlayerGetItem MessageFromTarget 0x2d06 script_0801618A: _0807E878 @@ -109,7 +109,7 @@ script_080161C6: Jump script_080161E2 script_080161D8: .ifndef EU - WaitPlayerAction8 + WaitPlayerGetItem WaitUntilTextboxCloses _0807EB8C MessageNoOverlap 0x2d06 @@ -205,7 +205,7 @@ script_0801631C: Call sub_08068E30 WaitUntilTextboxCloses Call sub_08068C6C - WaitPlayerAction8 + WaitPlayerGetItem WaitUntilTextboxCloses Jump script_08016346 script_08016332: diff --git a/data/scripts/script_08016384.inc b/data/scripts/script_08016384.inc index 34c36c59..ff750c90 100644 --- a/data/scripts/script_08016384.inc +++ b/data/scripts/script_08016384.inc @@ -61,7 +61,7 @@ SCRIPT_START script_08016384 Wait 0x001e WaitForSomething 0x00000001 WaitForSomething2 0x00000002 - WaitPlayerAction8 + WaitPlayerGetItem WaitForPlayerAction0x17 WaitFor_1 WaitFor_2 diff --git a/data/scripts/script_080165D8.inc b/data/scripts/script_080165D8.inc index 47de49ed..e9ef17f2 100644 --- a/data/scripts/script_080165D8.inc +++ b/data/scripts/script_080165D8.inc @@ -225,7 +225,7 @@ script_0801690A: WaitUntilTextboxCloses JumpIfNot script_08016926 _0807F034 0x003d - WaitPlayerAction8 + WaitPlayerGetItem script_08016926: _0807E878 SetGlobalFlag 0x005c diff --git a/include/definitions.h b/include/definitions.h index 83c42b30..f2d631d9 100644 --- a/include/definitions.h +++ b/include/definitions.h @@ -114,7 +114,7 @@ typedef enum { SPRITE_8, SPRITE_9, SPRITE_OBJECT4, - SPRITE_OBJECT6, + SPRITE_EZLOCAP, SPRITE_12, SPRITE_13, SPRITE_14, diff --git a/include/effects.h b/include/effects.h index 696ab9ab..95ad4105 100644 --- a/include/effects.h +++ b/include/effects.h @@ -115,4 +115,4 @@ typedef enum { FX_6C, } Effect; -#endif // EFFECTS_H \ No newline at end of file +#endif // EFFECTS_H diff --git a/include/entity.h b/include/entity.h index 8c54edf0..778a3f8e 100644 --- a/include/entity.h +++ b/include/entity.h @@ -5,6 +5,8 @@ #include "global.h" #include "sprite.h" +#define MAX_ENTITIES 71 + typedef enum { PLAYER = 1, ENEMY = 3, @@ -175,6 +177,13 @@ enum { #define COORD_TO_TILE_OFFSET(entity, xOff, yOff) \ TILE((entity)->x.HALF.HI - (xOff), (entity)->y.HALF.HI - (yOff)) +enum { + IdleNorth = 0x0, + IdleEast = 0x2, + IdleSouth = 0x4, + IdleWest = 0x6, +}; + enum { DirectionNorth = 0x00, DirectionEast = 0x08, @@ -182,6 +191,10 @@ enum { DirectionWest = 0x18, }; +#define AnimationStateTurnAround(expr) ((expr) ^ 0x4) +#define AnimationStateIdle(expr) ((expr) & 0x6) +#define AnimationStateWalk(expr) ((expr) & 0xe) + #define DirectionRound(expr) ((expr) & 0x18) #define DirectionRoundUp(expr) DirectionRound((expr) + 4) #define DirectionIsHorizontal(expr) ((expr) & 0x08) @@ -194,7 +207,7 @@ enum { #define Direction8Round(expr) ((expr) & 0x1c) #define Direction8RoundUp(expr) Direction8Round((expr) + 2) #define Direction8TurnAround(expr) (Direction8RoundUp(expr) ^ 0x10) -#define Direction8ToAnimationState(expr) (Direction8RoundUp(expr) >> 2) +#define Direction8ToAnimationState(expr) ((expr) >> 2) #define Direction8FromAnimationState(expr) ((expr) << 2) Entity* GetEmptyEntity(void); @@ -270,11 +283,10 @@ void EraseAllEntities(void); enum { PRIO_MIN = 0, PRIO_PLAYER = 1, - PRIO_REQUESTED = 2, - PRIO_MESSAGE = 2, - PRIO_OVERRIDE_MESSAGE = 3, - PRIO_PLAYER_EVENT = 6, - PRIO_INITIALIZING = 7, + PRIO_MESSAGE = 2, /* do not block during message */ + PRIO_NO_BLOCK = 3, /* do not block during entity requested priority */ + PRIO_PLAYER_EVENT = 6, /* do not block during special player event */ + PRIO_HIGHEST = 7, /* do not block EVER */ }; /** diff --git a/include/fileScreen.h b/include/fileScreen.h index fd4b7c7e..8cf2304b 100644 --- a/include/fileScreen.h +++ b/include/fileScreen.h @@ -12,6 +12,7 @@ typedef struct { u16 timer; u8 fillerA[0x26]; } ChooseFileState; +static_assert(sizeof(ChooseFileState) == 0x30); // TODO: This occupies the same memory region as gMenu extern ChooseFileState gChooseFileState; diff --git a/include/functions.h b/include/functions.h index 58e54500..09926f5d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -90,7 +90,7 @@ extern void sub_0804A720(Entity*); extern u32 sub_080AEFE0(Entity*); extern u32 sub_08049FA0(Entity*); extern u32 sub_08049FDC(Entity*, u32); -extern u32 sub_080041A0(Entity*, Entity*, u32, u32); +extern u32 EntityInRectRadius(Entity*, Entity*, u32, u32); extern u32 sub_08049EE4(Entity*); extern void sub_08077E54(ItemBehavior*); extern void sub_080042BA(Entity*, u32); @@ -260,7 +260,7 @@ extern void sub_0800455E(Entity*); extern u32* sub_08008790(Entity*, u32); extern void sub_0804ACF8(); extern void sub_08073904(Entity*); -extern u32 sub_08056134(void); +extern u32 CheckHeaderValid(void); extern void sub_08004484(Entity*, Entity*); extern void sub_0805F8E4(u32 r0, WStruct* r1); extern u32 sub_08002632(Entity*); diff --git a/include/hitbox.h b/include/hitbox.h index ce9c20e6..c9f7ef46 100644 --- a/include/hitbox.h +++ b/include/hitbox.h @@ -88,4 +88,5 @@ extern const Hitbox gUnk_080FD4E0; extern const Hitbox gUnk_080FD3F4; extern const Hitbox gUnk_080FD3FC; extern const Hitbox gUnk_080FD43C; -#endif \ No newline at end of file +extern const Hitbox gPlayerHitbox; +#endif diff --git a/include/npc.h b/include/npc.h index c30b628b..bf49ef0a 100644 --- a/include/npc.h +++ b/include/npc.h @@ -83,7 +83,7 @@ enum NPC { /*0x4a*/ GREGAL, /*0x4b*/ MAYOR_HAGEN, /*0x4c*/ BIG_GORON, - /*0x4d*/ EZLO_CAP, + /*0x4d*/ EZLO, /*0x4e*/ NPC_UNK_4E, /*0x4f*/ NPC_UNK_4F, /*0x50*/ CLOTHES_RACK, @@ -277,7 +277,7 @@ extern void Gregal_Fusion(Entity*); extern void MayorHagen(Entity*); extern void MayorHagen_Fusion(Entity*); extern void BigGoron(Entity*); -extern void EzloCap(Entity*); +extern void Ezlo(Entity*); extern void NPC4E(Entity*); extern void NPC4E_Fusion(Entity*); extern void NPC4F(Entity*); diff --git a/include/object.h b/include/object.h index dc2b6b43..029a88b2 100644 --- a/include/object.h +++ b/include/object.h @@ -11,7 +11,7 @@ typedef enum { BUTTON, OBJECT_4, POT, - OBJECT_6, + EZLO_CAP, PUSHED_BLOCK, LOCKED_DOOR, OBJECT_9, @@ -207,7 +207,7 @@ extern void ItemForSale(Entity*); extern void Button(Entity*); extern void Object4(Entity*); extern void Pot(Entity*); -extern void Object6(Entity*); +extern void EzloCap(Entity*); extern void BlockPushed(Entity*); extern void LockedDoor(Entity*); extern void Object9(Entity*); diff --git a/include/player.h b/include/player.h index e1ef7001..8512db67 100644 --- a/include/player.h +++ b/include/player.h @@ -63,8 +63,16 @@ typedef enum { } PlayerControlMode; enum PlayerFlags { + PL_BUSY = (1 << 0), + PL_DROWNING = (1 << 2), PL_NO_CAP = (1 << 3), + PL_USE_PORTAL = (1 << 5), PL_MINISH = (1 << 7), + PL_BURNING = (1 << 10), + PL_ROLLING = (1 << 18), + PL_IN_HOLE = (1 << 20), + PL_USE_LANTERN = (1 << 23), + PL_USE_OCARINA = (1 << 28), }; typedef struct { @@ -74,7 +82,7 @@ typedef struct { /*0x05*/ u8 heldObject; /*0x06*/ u8 pushedObject; /*0x07*/ u8 field_0x7; - /*0x08*/ u16 field_0x8; + /*0x08*/ u16 animation; /*0x0a*/ u8 field_0xa; /*0x0b*/ u8 keepFacing; /*0x0c*/ u8 playerAction; @@ -121,7 +129,7 @@ typedef struct { /*0x40*/ u8 hurtType[64]; /*0x80*/ u16 field_0x80; /*0x82*/ u8 field_0x82[9]; - /*0x8b*/ u8 field_0x8b; + /*0x8b*/ u8 controlMode; /*0x8c*/ u32 field_0x8c; /*0x90*/ union SplitWord field_0x90; /*0x94*/ u32 field_0x94; diff --git a/include/room.h b/include/room.h index 8561da49..fc699fc5 100644 --- a/include/room.h +++ b/include/room.h @@ -60,8 +60,8 @@ typedef struct { u8 field_0x3; u8 field_0x4; u8 filler1[1]; - u8 itemForSaleIndex; - u8 field_0x7; + u8 shopItemType; + u8 shopItemType2; u8 field_0x8; u8 field_0x9; u8 unk2; diff --git a/include/structures.h b/include/structures.h index 671e41ea..2073f1b0 100644 --- a/include/structures.h +++ b/include/structures.h @@ -32,7 +32,9 @@ typedef struct { u8 listenForKeyPresses; u8 field_0x6; u8 field_0x7; + u8 pad[24]; } struct_02000010; +static_assert(sizeof(struct_02000010) == 0x20); extern struct_02000010 gUnk_02000010; diff --git a/linker.ld b/linker.ld index 2013d083..153a69e9 100644 --- a/linker.ld +++ b/linker.ld @@ -407,8 +407,8 @@ SECTIONS { asm/wizzrobeWind.o(.text); asm/wizzrobeFire.o(.text); asm/wizzrobeIce.o(.text); - src/code_080300AC.o(.text); /* ??? */ - asm/code_080300AC.o(.text); /* ??? */ + src/code_080300AC.o(.text); + asm/code_080300AC.o(.text); asm/armos.o(.text); asm/eyegore.o(.text); src/enemy/rope.o(.text); @@ -641,7 +641,7 @@ SECTIONS { src/npc/gregal.o(.text); src/npc/mayorHagen.o(.text); src/npc/bigGoron.o(.text); - src/npc/ezloCap.o(.text); + src/npc/ezlo.o(.text); src/npc/npc4E.o(.text); src/npc/npc4F.o(.text); src/npc/clothesRack.o(.text); @@ -707,7 +707,7 @@ SECTIONS { src/object/button.o(.text); asm/object4.o(.text); src/object/pot.o(.text); - asm/object6.o(.text); + asm/ezloCap.o(.text); asm/blockPushed.o(.text); src/object/lockedDoor.o(.text); asm/object9.o(.text); @@ -971,9 +971,9 @@ SECTIONS { asm/libagbsyscall.o(.text); src/eeprom.o(.text); *libc.a:memcpy.o(.text); - /* handwritten assembly in arm mode */ asm/intr.o(.text); + /* data */ data/data_080B2A70.o(.rodata); src/interrupts.o(.rodata); @@ -1369,7 +1369,7 @@ SECTIONS { data/const/npc/mayorHagen.o(.rodata); data/animations/npc/mayorHagen.o(.rodata); data/const/npc/bigGoron.o(.rodata); - src/npc/ezloCap.o(.rodata); + src/npc/ezlo.o(.rodata); src/npc/npc4E.o(.rodata); src/npc/npc4F.o(.rodata); data/animations/npc/npc4F.o(.rodata); @@ -1409,7 +1409,6 @@ SECTIONS { data/map/room_headers.o(.rodata); src/flags.o(.rodata); src/save.o(.rodata); - data/data_0811E454.o(.rodata); src/script.o(.rodata); data/data_0811E750.o(.rodata); data/const/object/itemOnGround.o(.rodata); @@ -1421,8 +1420,8 @@ SECTIONS { data/animations/object/object4.o(.rodata); data/const/object/pot.o(.rodata); data/animations/object/pot.o(.rodata); - data/const/object/object6.o(.rodata); - data/animations/object/object6.o(.rodata); + data/const/object/ezloCap.o(.rodata); + data/animations/object/ezloCap.o(.rodata); data/const/object/blockPushed.o(.rodata); src/object/lockedDoor.o(.rodata); data/const/object/object9.o(.rodata); diff --git a/src/collision.c b/src/collision.c index 026724ed..9d3380e4 100644 --- a/src/collision.c +++ b/src/collision.c @@ -65,7 +65,7 @@ void CollisionMain(void) { doCollision = &gDoCollision; // Check to see if we should disable collision this frame - if (gPlayerState.field_0x8b != 0) { + if (gPlayerState.controlMode != CONTROL_ENABLED) { u32 flags = gPlayerEntity.flags; COLLISION_OFF(&gPlayerEntity); doCollision(); diff --git a/src/coord.c b/src/coord.c index 82d994ea..ffa12162 100644 --- a/src/coord.c +++ b/src/coord.c @@ -29,7 +29,7 @@ void PositionEntityOnTop(Entity* ent, Entity* ent2) { ResolveEntityOnTop(ent, ent2); } -void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { // r0, r1, r2, r3 +void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { s32 x; s32 y; @@ -39,7 +39,7 @@ void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) y = source->y.WORD; target->y.WORD = y + offsetY; - target->z = source->z; // ldr + target->z = source->z; target->collisionLayer = source->collisionLayer; UpdateSpriteForCollisionLayer(target); } diff --git a/src/createEnemy.c b/src/createEnemy.c index 73eb5e5c..b67546a1 100644 --- a/src/createEnemy.c +++ b/src/createEnemy.c @@ -6,7 +6,7 @@ Entity* CreateEnemy(u32 subtype, u32 form) { enemy = GetEmptyEntity(); if (enemy != NULL) { - enemy->kind = 3; + enemy->kind = ENEMY; enemy->id = subtype; enemy->type = form; AppendEntityToList(enemy, 4); diff --git a/src/debugScreen.c b/src/debugScreen.c index a12ec0a1..dcd22601 100644 --- a/src/debugScreen.c +++ b/src/debugScreen.c @@ -17,12 +17,12 @@ void sub_0805FA04(void) { DispReset(1); MemClear(&gBG0Buffer, sizeof(gBG0Buffer)); MemClear(&gBG3Buffer, sizeof(gBG3Buffer)); - gScreen.lcd.displayControl = 0x940; + gScreen.lcd.displayControl = DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_1D_MAP; gScreen.bg0.xOffset = 0; gScreen.bg0.yOffset = 0; gScreen.bg3.xOffset = 0; gScreen.bg3.yOffset = 0; - gScreen.bg3.control = 0x1e0f; + gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3); gScreen.bg3.updated = 1; MessageInitialize(); MemClear((void*)&gUnk_02032EC0, sizeof(UI)); @@ -39,35 +39,35 @@ void sub_0805FA98(void) { int iVar1; switch (gInput.newKeys) { - case 0x40: + case DPAD_UP: gMenu.focusCoords[1] -= 1; break; - case 0x80: + case DPAD_DOWN: gMenu.focusCoords[1] += 1; break; - case 0x200: + case L_BUTTON: gMenu.focusCoords[0] ^= 1; if (gMenu.focusCoords[0] == 0) { - gScreen.bg0.control = 0x1f0c; - gScreen.bg3.control = 0x1e0f; + gScreen.bg0.control = BGCNT_SCREENBASE(31) | BGCNT_CHARBASE(3); + gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_CHARBASE(3) | BGCNT_PRIORITY(3); } else { - gScreen.bg0.control = 0x1f0f; - gScreen.bg3.control = 0x1e0c; + gScreen.bg0.control = BGCNT_SCREENBASE(31) | BGCNT_CHARBASE(3) | BGCNT_PRIORITY(3); + gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_CHARBASE(3); } break; - case 0x100: + case R_BUTTON: gSaveHeader->gameLanguage = gMenu.unk16; MessageFromTarget(gMenu.unk14 * 0x100 + gMenu.unk15); break; - case 0x2: + case B_BUTTON: MessageInitialize(); break; default: switch (gInput.unk4) { - case 0x20: + case DPAD_LEFT: iVar1 = -1; break; - case 0x10: + case DPAD_RIGHT: iVar1 = 1; break; default: diff --git a/src/demoScreen.c b/src/demoScreen.c index b2620204..f2b3315a 100644 --- a/src/demoScreen.c +++ b/src/demoScreen.c @@ -31,14 +31,14 @@ void HandleChooseDemoScreen(void) { void sub_080A2E40(void) { DispReset(1); InitSoundPlayingInfo(); - MemClear((void*)0x6000000, 0x80); + MemClear((void*)VRAM, 0x80); MessageInitialize(); EraseAllEntities(); sub_080ADD30(); sub_0801CFA8(0); - MemClear(&gUnk_02032EC0, 0x3b4); - MemClear(&gChooseFileState, 0x30); - MemClear(&gBG0Buffer, 0x800); + MemClear(&gUnk_02032EC0, sizeof gUnk_02032EC0); + MemClear(&gChooseFileState, sizeof gChooseFileState); + MemClear(&gBG0Buffer, sizeof gBG0Buffer); sub_08053320(); LoadPaletteGroup(0xb5); LoadGfxGroup(0x56); diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 368606f2..c4784ee0 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -81,7 +81,7 @@ void sub_080318DC(Entity* this) { } if (this->health == 0) { - this->knockbackDirection = ((this->knockbackDirection + (7 & Random())) - 4) & 0x1f; + this->knockbackDirection = DirectionNormalize((this->knockbackDirection + (7 & Random())) - 4); this->knockbackDuration += this->type2 * 3; sub_08032338(this); } diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index c1b560d1..b2b3e5ed 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -150,7 +150,7 @@ void sub_08021984(Entity* this) { void sub_08021A10(Entity* this) { GetNextFrame(this); - if (sub_080041A0(this, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) { + if (EntityInRectRadius(this, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) { if (--this->actionDelay == 0) { this->action = 3; this->actionDelay = (Random() & 0x3f) + 30; diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index a0c18290..6e75d855 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -210,7 +210,7 @@ void sub_08028BC4(Entity* this) { if (iVar1 != NULL) { iVar1->spritePriority.b0 = 3; iVar1->z.HALF.HI -= 12; - SetDefaultPriority(iVar1, 2); + SetDefaultPriority(iVar1, PRIO_MESSAGE); } SetFlag(this->field_0x86.HWORD); sub_0802925C(this); @@ -390,14 +390,14 @@ void sub_08028F0C(Entity* this) { bool32 sub_08028F98(Entity* this, u32 param_2) { Entity* ent = sub_08049DF4(1); - if (ent == NULL || sub_080041A0(this, ent, 0x28, 0x28)) { + if (ent == NULL || EntityInRectRadius(this, ent, 0x28, 0x28)) { return FALSE; } if (param_2 != 2) { u32 distance = param_2 ? 0x58 : 0x50; - if (!sub_080041A0(this, ent, distance, distance)) { + if (!EntityInRectRadius(this, ent, distance, distance)) { return FALSE; } } diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index fa2fb63a..d3295203 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -134,7 +134,7 @@ u32 sub_08022B20(Entity* this) { if (!sub_08049DF4(2)) return 0; - return sub_080041A0(this, &gPlayerEntity, 0x24, 0x24); + return EntityInRectRadius(this, &gPlayerEntity, 36, 36); } void sub_08022B44(Entity* this) { diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index aa7d5993..e9061ad0 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -180,7 +180,7 @@ void sub_08020E78(Entity* this) { } void sub_08020E98(Entity* this) { - if (PlayerInRange(this, 1, 0x38)) { + if (PlayerInRange(this, 1, 56)) { if (sub_0802169C(this, gUnk_020000B0)) { this->action = 8; sub_08021218(this, 7, this->animationState); @@ -190,7 +190,7 @@ void sub_08020E98(Entity* this) { this->action = 8; sub_08021218(this, 7, this->animationState); } else { - this->direction ^= 0x10; + this->direction = DirectionTurnAround(this->direction); sub_0802124C(this); sub_08021644(this); } diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index 3ec57bc7..c6e0123e 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -67,7 +67,7 @@ void sub_08045454(Entity* this) { /* Can we create enough new entities? */ count = gUnk_080D180C[this->type]; - if (72 - count <= gEntCount) + if (MAX_ENTITIES + 1 - count <= gEntCount) return; /* Create 2-5 new MiniFireballGuy */ diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 0c9adb33..b5bbef3f 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -143,7 +143,7 @@ void sub_080325C4(Entity* this) { u32 sub_080325E8(Entity* this) { if (((sub_08049FA0(this) != 0) && (sub_08049FDC(this, 1) != 0)) && - (sub_080041A0(this, gUnk_020000B0, 0x68, 0x40) != 0)) { + (EntityInRectRadius(this, gUnk_020000B0, 0x68, 0x40) != 0)) { if (((GetFacingDirection(this, gUnk_020000B0) - (DirectionRound(this->frame)) + 2) & 0x1F) < 5) { this->action = 3; this->actionDelay = 0xC; diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index d96950d7..8e4ae08e 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -241,7 +241,7 @@ void Lakitu_Cloudless(Entity* this) { bool32 sub_0803CA4C(Entity* this) { if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) { - if (sub_080041A0(this, &gPlayerEntity, 0x70, 0x50)) { + if (EntityInRectRadius(this, &gPlayerEntity, 0x70, 0x50)) { return 1; } } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 6dce5fba..42e8d88f 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -58,7 +58,7 @@ void sub_08027DA4(Entity* this) { void sub_08027E40(Entity* this) { if (this->actionDelay == 2 && this->field_0x80.HALF.LO != 0xff) { - SetDefaultPriority(this, 3); + SetDefaultPriority(this, PRIO_NO_BLOCK); sub_08028224(this->field_0x80.HALF.LO); } sub_0804A7D4(this); diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index ce77d2c4..b282e776 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -224,7 +224,7 @@ void sub_08033FFC(Entity* this) { if (((*(Entity**)&this->field_0x74)->flags & 0x80) != 0) { gRoomControls.cameraTarget = &gPlayerEntity; sub_08034420(this); - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; sub_080791D0(); SoundReq(BGM_BOSS_THEME); } diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index 7fb15f46..ce7f9249 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -139,7 +139,7 @@ void sub_080231BC(Entity* this) { this->field_0x78.HWORD = 0x1e; this->palette.b.b0 = 5; this->direction = Random() & 0x1f; - this->animationState = Direction8ToAnimationState(this->direction); + this->animationState = Direction8ToAnimationState(Direction8RoundUp(this->direction)); InitializeAnimation(this, this->animationState); } } @@ -225,7 +225,7 @@ void sub_08023398(Entity* this) { u32 uVar4; sub_08004596(this, sub_08049F84(this, 1)); - uVar4 = Direction8ToAnimationState(this->direction); + uVar4 = Direction8ToAnimationState(Direction8RoundUp(this->direction)); if (uVar4 != this->animationState) { this->animationState = uVar4; InitializeAnimation(this, uVar4 + this->field_0x7a.HALF.HI); @@ -249,7 +249,7 @@ void sub_080234D8(Entity* this) { this->action = 2; this->palette.b.b0 = 5; this->direction = Random() & 0x1f; - this->animationState = Direction8ToAnimationState(this->direction); + this->animationState = Direction8ToAnimationState(Direction8RoundUp(this->direction)); sub_08023A88(this, this->animationState); } } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 3f0e0c51..472d982d 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -403,7 +403,7 @@ void sub_080244E8(Entity* this) { } break; case 1: - if (sub_080041A0(this, this->child, 6, 6)) { + if (EntityInRectRadius(this, this->child, 6, 6)) { Entity* ent; this->field_0x80.HALF.LO += 1; @@ -424,7 +424,7 @@ void sub_080244E8(Entity* this) { } break; case 2: - if (sub_080041A0(this, this->child, 6, 6)) { + if (EntityInRectRadius(this, this->child, 6, 6)) { Entity* ent; this->field_0x80.HALF.LO += 1; diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 92de7a7f..ab7666f8 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -95,7 +95,7 @@ void sub_080450A8(Entity* this) { /* Can we create enough new entities? */ count = gUnk_080D16D0[this->type]; - if (72 - count <= gEntCount) + if (MAX_ENTITIES + 1 - count <= gEntCount) return; /* Create 2-4 new MiniSlime */ diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 43d870c1..d96b04ee 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -220,7 +220,7 @@ void VaatiWrathType0Action1(Entity* this) { this->actionDelay = 0x1e; gScreenTransition.field_0x38 |= 1; gRoomControls.cameraTarget = &gPlayerEntity; - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; break; default: sub_08042004(this); @@ -567,7 +567,7 @@ void sub_08041BE8(Entity* this) { if (sub_08079F8C() != 0) { this->subAction = 1; this->actionDelay = 120; - this->updatePriority = 3; + this->updatePriority = PRIO_NO_BLOCK; InitAnimationForceUpdate(this, 10); entity = ((VaatiWrathHeapStruct*)this->myHeap)->type1; @@ -576,7 +576,7 @@ void sub_08041BE8(Entity* this) { ((VaatiWrathHeapStruct*)this->myHeap)->type1 = NULL; entity = ((VaatiWrathHeapStruct*)this->myHeap)->type2; - entity->updatePriority = 3; + entity->updatePriority = PRIO_NO_BLOCK; sub_080AE068(entity); LoadFixedGFX(entity, 0x1f5); sub_0801D2B4(entity, 0x16b); diff --git a/src/entity.c b/src/entity.c index c308b2b6..c0d5b62d 100644 --- a/src/entity.c +++ b/src/entity.c @@ -136,15 +136,15 @@ void ResetEntityPriority(void) { void RequestPriority(Entity* this) { this->updatePriorityPrev = this->updatePriority; - this->updatePriority = PRIO_REQUESTED; - if (SetMinPriority(PRIO_REQUESTED)) + this->updatePriority = PRIO_MESSAGE; + if (SetMinPriority(PRIO_MESSAGE)) gPriorityHandler.requester = this; } void RequestPriorityOverPlayer(Entity* this) { SetPlayerControl(1); this->updatePriorityPrev = this->updatePriority; - this->updatePriority = PRIO_OVERRIDE_MESSAGE; + this->updatePriority = PRIO_NO_BLOCK; if (SetMinPriority(PRIO_PLAYER)) gPriorityHandler.requester = this; } @@ -157,7 +157,7 @@ void RevokePriorityOverPlayer(Entity* this) { void RequestPriorityDuration(Entity* this, u32 time) { if (this != NULL) { this->updatePriorityPrev = this->updatePriority; - this->updatePriority = PRIO_OVERRIDE_MESSAGE; + this->updatePriority = PRIO_NO_BLOCK; } if (SetMinPriority(PRIO_PLAYER)) gPriorityHandler.requester = this; @@ -197,7 +197,7 @@ void SetRoomReloadPriority() { } void SetInitializationPriority() { - gPriorityHandler.sys_priority = PRIO_INITIALIZING; + gPriorityHandler.sys_priority = PRIO_HIGHEST; } void ResetSystemPriority() { diff --git a/src/fade.c b/src/fade.c index 1ed6ffd0..f3d1447e 100644 --- a/src/fade.c +++ b/src/fade.c @@ -38,9 +38,9 @@ void DoFade(u32 fadeType, u32 fadeSpeed) { } if ((fadeType & 8) != 0) { gUnk_03000000.spritesOffset = 1; - gScreen.bg1.control |= 0x40; - gScreen.bg2.control |= 0x40; - gScreen.bg3.control |= 0x40; + gScreen.bg1.control |= BGCNT_MOSAIC; + gScreen.bg2.control |= BGCNT_MOSAIC; + gScreen.bg3.control |= BGCNT_MOSAIC; } if ((fadeType & 0x10) != 0) { sub_0801E1B8(gFadeControl.field_0x16, gFadeControl.field_0x18); @@ -57,7 +57,7 @@ void sub_080500F4(u32 arg0) { gFadeControl.fadeSpeed = arg0; gFadeControl.fadeType ^= 1; gFadeControl.active = 1; - gFadeControl.fadeDuration = 0x100; + gFadeControl.fadeDuration = 256; } void sub_08050110(u32 param_1, u32 param_2, u32 fadeType, u32 fadeSpeed) { diff --git a/src/flagDebug.c b/src/flagDebug.c index e65edcf4..4f03efd9 100644 --- a/src/flagDebug.c +++ b/src/flagDebug.c @@ -1,12 +1,4 @@ -// #define DEF_FLAGS( name, ... ) \ -// const char* const name##_flags[] = { \ -// "BEGIN", \ -// __VA_ARGS__ \ -// "END" \ -// }; - -// DEF_FLAGS(global, "a", -// "b"); +#include "flags.h" const char* const globalFlagNames[] = { "BEGIN", diff --git a/src/interrupts.c b/src/interrupts.c index a7431d95..8a44a61b 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -71,8 +71,8 @@ void DummyIntr(void) { void EnableVBlankIntr(void) { INTR_VECTOR = gIntrMain; - REG_DISPSTAT = 0x5028; - REG_IE = 0x2005; + REG_DISPSTAT = DISPSTAT_VCOUNT_INTR | DISPSTAT_VBLANK_INTR | (80 << 8); + REG_IE = INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_GAMEPAK; REG_IME = 1; } @@ -89,7 +89,7 @@ void VBlankIntr(void) { } void HBlankIntr(void) { - REG_DISPSTAT = 0x5028; + REG_DISPSTAT = DISPSTAT_VCOUNT_INTR | DISPSTAT_VBLANK_INTR | (80 << 8); m4aSoundMain(); } @@ -111,9 +111,9 @@ void sub_08016BF8(void) { } void UpdateDisplayControls(void) { - if (gUnk_03000000.update && ((gScreen.lcd.displayControl & 0x1000) != 0)) { + if (gUnk_03000000.update && (gScreen.lcd.displayControl & DISPCNT_OBJ_ON)) { gUnk_03000000.update = 0; - DmaCopy32(3, &gUnk_03000000.oam, 0x07000000, 0x400); + DmaCopy32(3, &gUnk_03000000.oam, OAM, OAM_SIZE); } sub_08016CA8(&gScreen.bg0); sub_08016CA8(&gScreen.bg1); @@ -126,7 +126,7 @@ void sub_08016CA8(BgSettings* bg) { u32 dest; bg->updated = 0; dest = bg->control; - DmaCopy32(3, bg->tilemap, ((dest << 3) & 0xF800) + 0x06000000, gUnk_080B2CD8[dest >> 14]); + DmaCopy32(3, bg->tilemap, ((dest << 3) & 0xF800) + VRAM, gUnk_080B2CD8[dest >> 14]); } } @@ -189,9 +189,9 @@ void PlayerUpdate(Entity* this) { if ((gPlayerState.flags & 0x80000) != 0) { sub_08077B20(); if ((gPlayerState.flags & 0x200000) != 0) { - gPlayerState.playerAction = 0x18; + gPlayerState.playerAction = PLAYER_ROLL; gPlayerState.flags &= ~0x80000; - gPlayerState.hurtBlinkSpeed = 0xf0; + gPlayerState.hurtBlinkSpeed = 240; COLLISION_ON(this); } else { COLLISION_OFF(this); @@ -224,7 +224,7 @@ void HandlePlayerLife(Entity* this) { SoundReq(SFX_86); gPlayerState.flags &= ~(0x2000000 | 0x200); - if (gPlayerState.flags & 0x400) + if (gPlayerState.flags & PL_BURNING) ResetPlayer(); if ((gPlayerState.flags & 0x400000) && !gPlayerState.field_0xa0[0]) sub_0807A108(); @@ -242,7 +242,7 @@ void HandlePlayerLife(Entity* this) { return; } - if ((gPlayerState.field_0x8b != 0) || (gMessage.doTextBox & 0x7f)) + if ((gPlayerState.controlMode != CONTROL_ENABLED) || (gMessage.doTextBox & 0x7f)) return; gRoomVars.unk2 = gMessage.doTextBox & 0x7f; @@ -294,7 +294,7 @@ void sub_080171F0(void) { gPlayerEntity.field_0x7a.HWORD--; gPlayerEntity.bitfield &= ~0x80; - if (gPlayerEntity.action != 0x14) + if (gPlayerEntity.action != PLAYER_DROWN) COPY_FLAG_FROM_TO(gPlayerState.flags, 0x2, 0x10000); gPlayerState.flags &= ~2; @@ -318,7 +318,7 @@ void sub_080171F0(void) { if (gPlayerState.flags & 0x400000) gUnk_03004040[0]->spriteOffsetY = gUnk_03004040[1]->spriteOffsetY = gUnk_03004040[2]->spriteOffsetY = 0; - if (gPlayerEntity.action == 0x1d) + if (gPlayerEntity.action == PLAYER_08072F34) gPlayerState.flags |= 0x20000000; else gPlayerState.flags &= ~0x20000000; @@ -327,7 +327,7 @@ void sub_080171F0(void) { if (gPlayerState.jumpStatus & 0xc0) gPlayerEntity.iframes = 0xfe; - if (gPlayerEntity.action != 0x17) { + if (gPlayerEntity.action != PLAYER_ROOMTRANSITION) { sub_08077FEC(gPlayerEntity.action); } } diff --git a/src/intro.c b/src/intro.c index b74c67a8..4a563487 100644 --- a/src/intro.c +++ b/src/intro.c @@ -158,17 +158,17 @@ static void HandleTitlescreen(void) { // Blend first and second layer gScreen.controls.layerFXControl = BLDCNT_TGT1_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_EFFECT_BLEND; gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 9); - gScreen.bg1.control = 0x1c09; + gScreen.bg1.control = BGCNT_SCREENBASE(28) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2); gScreen.bg2.control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2); gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(3); gScreen.lcd.displayControl |= DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; - gScreen.bg1.yOffset = 0xff60; + gScreen.bg1.yOffset = -160; } else { gScreen.controls.layerFXControl = BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND; gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 9); gScreen.bg0.control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2); - gScreen.bg1.control = 0x1E03; - gScreen.bg2.control = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_256COLOR | BGCNT_SCREENBASE(28) | + gScreen.bg1.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(3); + gScreen.bg2.control = BGCNT_SCREENBASE(28) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_256COLOR | BGCNT_WRAP | BGCNT_TXT512x256; gScreen.lcd.displayControl |= DISPCNT_MODE_1; gScreen.lcd.displayControl |= DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON; @@ -284,7 +284,7 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) { if (GetAdvanceState() == ADVANCE_KEY_PRESSED || gScreen.bg1.yOffset == 0) { gIntroState.subState++; gScreen.bg1.yOffset = 0; - gScreen.bg1.control = 0xc09; + gScreen.bg1.control = BGCNT_SCREENBASE(12) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2); gFadeControl.mask = 0x00000040; DoFade(6, 0x10); SoundReq(SFX_F8); diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 6804c425..e66f8240 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -61,7 +61,7 @@ void sub_080768F8(ItemBehavior* this, u32 arg1) { if ((gPlayerState.flags & PL_MINISH) == 0) { this->field_0x5[2] = 0x10; } else { - gPlayerState.field_0x8 = 0xc14; + gPlayerState.animation = 0xc14; } sub_08077D38(this, arg1); sub_08076964(this, arg1); diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c index 56aa2947..dd4c69bd 100644 --- a/src/item/itemRocsCape.c +++ b/src/item/itemRocsCape.c @@ -72,7 +72,7 @@ void sub_08076758(ItemBehavior* this, u32 arg1) { gPlayerEntity.field_0x7a.HWORD = 2; gPlayerEntity.zVelocity = 0x20000; gPlayerState.jumpStatus |= 0x10; - gPlayerState.field_0x8 = 0x288; + gPlayerState.animation = 0x288; SoundReq(SFX_172); } } else { diff --git a/src/main.c b/src/main.c index 820b5560..906b6608 100644 --- a/src/main.c +++ b/src/main.c @@ -18,7 +18,7 @@ extern void HandleGameOverScreen(void); extern void HandleCreditsScreen(void); extern void HandleDebugTextScreen(void); -static void sub_08055F70(void); +static void InitOverlays(void); static bool32 SoftResetKeysPressed(void); void (*const sScreenHandlers[])(void) = { @@ -40,7 +40,7 @@ static void sub_080560B8(void); void AgbMain(void) { int var0; - sub_08055F70(); + InitOverlays(); InitSound(); InitDMA(); InitSaveData(); @@ -101,7 +101,7 @@ extern u8 gUnk_080B2CD8_2[]; extern u8 gUnk_080B2CD8_3[]; extern u8 gUnk_02000030[]; -static void sub_08055F70(void) { +static void InitOverlays(void) { u32 size; DisableInterruptsAndDMA(); @@ -185,15 +185,15 @@ NONMATCH("asm/non_matching/sub_080560B8.inc", static void sub_080560B8(void)) { u32 temp; u32 b; - if (!sub_08056134()) { - switch ((s32)Read_02000000((void*)0x2000000)) { + if (!CheckHeaderValid()) { + switch ((s32)Read_02000000(gSaveHeader)) { case 1: - if (sub_08056134()) + if (CheckHeaderValid()) break; case 0: case -1: default: - MemCopy(&sDefaultSettings, (void*)0x2000000, 16); + MemCopy(&sDefaultSettings, gSaveHeader, sizeof *gSaveHeader); Write_02000000(gSaveHeader); break; } @@ -206,14 +206,13 @@ NONMATCH("asm/non_matching/sub_080560B8.inc", static void sub_080560B8(void)) { b = TRUE; } if (b) { - MemClear((u8*)&gUnk_02000010.signature, 0x20); + MemClear(&gUnk_02000010, sizeof gUnk_02000010); gUnk_02000010.signature = SIGNATURE; } } END_NONMATCH -u32 sub_08056134(void) { - +u32 CheckHeaderValid(void) { if ((gSaveHeader->signature != SIGNATURE) || (gSaveHeader->saveFileId >= NUM_SAVE_SLOTS) || (gSaveHeader->messageSpeed >= MAX_MSG_SPEED) || (gSaveHeader->brightnessPref >= MAX_BRIGHTNESS) #ifdef EU @@ -259,26 +258,27 @@ void sub_08056250() { } void sub_08056260(void) { - u32 temp; - Main* temp2; + u32 restore; + Main* m; - REG_DISPCNT = 0x80; - REG_KEYCNT = 0x8304; + REG_DISPCNT = DISPCNT_FORCED_BLANK; + REG_KEYCNT = KEY_AND_INTR | L_BUTTON | R_BUTTON | SELECT_BUTTON; REG_IME = 0; - temp = REG_IE; - REG_IE = 0x3000; + restore = REG_IE; + REG_IE = INTR_FLAG_KEYPAD | INTR_FLAG_GAMEPAK; REG_IME = 1; Stop(); REG_IME = 0; - REG_IE = temp; + REG_IE = restore; REG_IME = 1; - temp2 = &gMain; - asm("ldrb r1, [r0, #0x1]"); - temp2->field_0x1 = 0; + m = &gMain; + *(vu8*)&m->field_0x1; // force a read + m->field_0x1 = 0; } + // Convert AABB to screen coordinates and check if it's within the viewport -u32 sub_080562CC(u32 x0, u32 y0, u32 x1, u32 y1) { +u32 CheckRegionOnScreen(u32 x0, u32 y0, u32 x1, u32 y1) { u32 result; u32 x = ((gRoomControls.roomScrollX - gRoomControls.roomOriginX) - x0 + DISPLAY_WIDTH); u32 y = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) - y0 + DISPLAY_HEIGHT); @@ -292,10 +292,10 @@ u32 sub_080562CC(u32 x0, u32 y0, u32 x1, u32 y1) { } // Iterate over array of AABBs and check if any fit on screen -u16 sub_08056300(u16* arr) { +u16 CheckRegionsOnScreen(u16* arr) { u16* i; for (i = arr; *i != 0xff; i += 5) { - if (sub_080562CC(i[1], i[2], i[3], i[4]) != 0) + if (CheckRegionOnScreen(i[1], i[2], i[3], i[4])) return *i; } return 0xff; diff --git a/src/manager/manager1.c b/src/manager/manager1.c index bbc743ce..51b28137 100644 --- a/src/manager/manager1.c +++ b/src/manager/manager1.c @@ -4,8 +4,6 @@ #include "functions.h" extern void sub_08056250(void); -extern void sub_080570B8(Entity*); -void sub_080570F8(void); extern void (*const gUnk_08107C5C[])(Entity*); extern void (*const gUnk_08107C48[])(Entity*); @@ -25,7 +23,7 @@ void Manager1_Main(Entity* this) { } } -void sub_080570B8(Entity* this) { +static void sub_080570B8(Entity* this) { u8* pbVar1; LoadGfxGroup(((u8*)&this->zVelocity)[0]); @@ -38,8 +36,8 @@ void sub_080570B8(Entity* this) { } } -void sub_080570F8(void) { - gScreen.lcd.displayControl &= 0xf7ff; +static void sub_080570F8(void) { + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0; sub_08056250(); } @@ -51,7 +49,7 @@ void sub_08057118(Entity* this) { ((u8*)&this->zVelocity)[2] = 0; this->action = 1; gScreen.bg3.control = 0x1e04; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0x3648; gScreen.controls.alphaBlend = 0x1000; RegisterTransitionManager(this, sub_080570B8, sub_080570F8); diff --git a/src/manager/manager12.c b/src/manager/manager12.c index 36a044d4..6a1c5982 100644 --- a/src/manager/manager12.c +++ b/src/manager/manager12.c @@ -15,7 +15,7 @@ void sub_08059A58(Manager12*); void sub_08059A2C(Manager12*); -u32 sub_08056300(u16* arr); +u32 CheckRegionsOnScreen(u16* arr); extern u16 gUnk_081083DA; extern u16 gUnk_081083F2; extern u16 gUnk_08108398; @@ -48,7 +48,7 @@ void Manager12_Main(Manager12* this) { this->field_0x21 = 0xff; this->field_0x20 = 0xff; RegisterTransitionManager(this, sub_08059A2C, NULL); - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); } sub_08059A58(this); } @@ -128,7 +128,7 @@ void sub_08059B18(void) { bool32 sub_08059C8C(Manager12* this, u32 param_2, u8* param_3, u16* param_4) { bool32 bVar2; - *param_3 = sub_08056300(param_4); + *param_3 = CheckRegionsOnScreen(param_4); if ((*param_3 != 0xff) && (gRoomVars.unk_10[param_2] != *param_3)) { gRoomVars.unk_10[param_2] = *param_3; return TRUE; @@ -154,24 +154,24 @@ void TryLoadPrologueHyruleTown(void) { u32 tmp; if (gRoomControls.areaID != AREA_FESTIVAL_TOWN) { - tmp = sub_08056300(&gUnk_08108398); + tmp = CheckRegionsOnScreen(&gUnk_08108398); if (tmp != 0xff) { sub_08059CC0(0, tmp); } - tmp = sub_08056300(&gUnk_081083AE); + tmp = CheckRegionsOnScreen(&gUnk_081083AE); if ((tmp != 0xff) && (sub_08059CC0(1, tmp), tmp == 2)) { sub_08059B18(); } - tmp = sub_08056300(&gUnk_081083C4); + tmp = CheckRegionsOnScreen(&gUnk_081083C4); if (tmp != 0xff) { sub_08059CC0(2, tmp); } } else { - tmp = sub_08056300(&gUnk_081083DA); + tmp = CheckRegionsOnScreen(&gUnk_081083DA); if (tmp != 0xff) { sub_08059CC0(0, tmp); } - tmp = sub_08056300(&gUnk_081083F2); + tmp = CheckRegionsOnScreen(&gUnk_081083F2); if (tmp != 0xff) { sub_08059CC0(2, tmp); } diff --git a/src/manager/manager14.c b/src/manager/manager14.c index 31f827c0..65bb296d 100644 --- a/src/manager/manager14.c +++ b/src/manager/manager14.c @@ -56,7 +56,7 @@ void sub_08059E80(Manager14* this) { this->manager.action = 4; this->manager.unk_10 |= 0x20; gScreen.bg3.control = 0x1E04; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0x3E48; gScreen.controls.alphaBlend = 0x1000; gScreen.bg3.xOffset = 0x80; @@ -142,7 +142,7 @@ void sub_0805A0C0(Manager14* this) { this->manager.unk_0f = 4; gScreen.controls.alphaBlend = gUnk_08108588[this->manager.unk_0e--]; if (this->manager.unk_0e == 0xFF) { - gScreen.lcd.displayControl &= ~0x800; + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; sub_08056250(); DeleteThisEntity(); } @@ -179,7 +179,7 @@ void sub_0805A1D8(Manager14* this) { gScreen.bg3.xOffset = gRoomControls.bg3OffsetX.HALF.HI; gRoomControls.bg3OffsetY.WORD -= 0x1000; gScreen.bg3.yOffset = gRoomControls.bg3OffsetY.HALF.HI; - if (gScreen.lcd.displayControl & 0x800) { + if (gScreen.lcd.displayControl & DISPCNT_BG3_ON) { sub_0805A114(6, this->unk_20 >> 1); if (this->unk_22 == 0 && (gMain.ticks & 0x1F) == 0) { this->unk_24++; @@ -194,6 +194,6 @@ void nullsub_495() { void sub_0805A25C() { gScreen.controls.layerFXControl = 0; - gScreen.lcd.displayControl &= ~0x800; + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; sub_08056250(); } diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 27a5e825..867a9429 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -46,7 +46,7 @@ void sub_0805A298(Manager15* this) { this->unk_23 = 2; } sub_0805AAF0(this->unk_23); - gScreen.lcd.displayControl |= 0x4800; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } sub_0805A8EC(this); } @@ -67,7 +67,7 @@ void sub_0805A2E4(Manager15* this) { } else { this->manager.action = 3; } - gScreen.lcd.displayControl |= 0x4800; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } } else { gUnk_081085F8[this->manager.action](this); @@ -96,7 +96,7 @@ void sub_0805A394(Manager15* this) { } SetLocalFlag(LV1_16_1STEND); ClearRoomFlag(0); - gScreen.lcd.displayControl &= 0xB7FF; + gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); DeleteThisEntity(); } @@ -117,11 +117,11 @@ void sub_0805A3D4(Manager15* this) { if (!CheckLocalFlag(this->unk_3e)) { ClearFlag(this->unk_3c); this->manager.action = 1; - gScreen.lcd.displayControl &= 0xB7FF; + gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); } else { SetFlag(this->unk_3c); this->manager.action = 3; - gScreen.lcd.displayControl |= 0x4800; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } } else { gUnk_0810860C[this->manager.action](this); @@ -181,16 +181,16 @@ void sub_0805A500(Manager15* this) { if (CheckLocalFlag(0x36)) { this->unk_23 = 3; this->manager.action = 5; - gScreen.lcd.displayControl |= 0x4800; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } else { if (CheckLocalFlag(0x34)) { this->unk_23 = 4; this->manager.action = 3; - gScreen.lcd.displayControl |= 0x4800; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } else { this->unk_23 = 4; this->manager.action = 1; - gScreen.lcd.displayControl &= 0xB7FF; + gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); } } sub_0805AAF0(this->unk_23); @@ -200,7 +200,7 @@ void sub_0805A500(Manager15* this) { sub_0805AA58(this); sub_0805A9CC(this); if (gRoomControls.unk2 == 1) { - gScreen.lcd.displayControl |= 0x80 << 7; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON; this->manager.unk_0d = 1; return; } @@ -209,7 +209,7 @@ void sub_0805A500(Manager15* this) { this->manager.unk_0d = 0; if (this->unk_20 == gRoomControls.roomID) return; - gScreen.lcd.displayControl &= 0xB7FF; + gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); DeleteThisEntity(); } @@ -281,12 +281,12 @@ void sub_0805A6E8(Manager15* this) { this->manager.action++; } this->unk_2c = 0x1000; - tmp = gScreen.lcd.displayControl | 0x4800; + tmp = gScreen.lcd.displayControl | DISPCNT_WIN1_ON | DISPCNT_BG3_ON; gScreen.lcd.displayControl = tmp; } u32 sub_0805A73C(Manager15* this) { - return CheckPlayerProximity(this->unk_38 - 0x6, this->unk_3a - 0x6, 0xC, 0xC); + return CheckPlayerProximity(this->unk_38 - 6, this->unk_3a - 6, 12, 12); } void sub_0805A758(Manager15* this) { @@ -304,10 +304,10 @@ void sub_0805A76C(Manager15* this) { this->manager.action++; sub_08004168(&gPlayerEntity); gPlayerEntity.animationState = 4; - RequestPriorityDuration((Entity*)this, 0x258); + RequestPriorityDuration((Entity*)this, 600); SetPlayerControl(0xFF); gUnk_02034490[0] = 1; - gRoomControls.cameraTarget = 0; + gRoomControls.cameraTarget = NULL; sub_08077B20(); } } @@ -315,8 +315,8 @@ void sub_0805A76C(Manager15* this) { } void sub_0805A7E4(Manager15* this) { - if (gPlayerState.playerAction != 0x12) { - gPlayerState.playerAction = 0x12; + if (gPlayerState.playerAction != PLAYER_WARP) { + gPlayerState.playerAction = PLAYER_WARP; gPlayerState.field_0x38 = 0; gPlayerState.field_0x39 = 0; } @@ -332,7 +332,7 @@ void sub_0805A804(Manager15* this) { } this->manager.unk_0d = 1; this->manager.unk_10 |= 0x20; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); break; case 1: if (CheckLocalFlag(this->unk_3e)) @@ -364,7 +364,7 @@ void sub_0805A804(Manager15* this) { void sub_0805AAC8(Manager15*); void sub_0805A89C(Manager15* this) { - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); this->manager.action = 1; this->manager.unk_10 |= 0x20; this->manager.unk_0e = 8; @@ -383,7 +383,7 @@ void sub_0805A8EC(Manager15* this) { sub_0805AA58(this); sub_0805A94C(this); if (gRoomControls.unk2 == 1) { - gScreen.lcd.displayControl |= 0x4000; + gScreen.lcd.displayControl |= DISPCNT_WIN1_ON; this->manager.unk_0d = 1; } else { if (!this->manager.unk_0d) @@ -391,7 +391,7 @@ void sub_0805A8EC(Manager15* this) { this->manager.unk_0d = 0; if (this->unk_20 == gRoomControls.roomID) return; - gScreen.lcd.displayControl &= 0xB7FF; + gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); DeleteThisEntity(); } } @@ -404,23 +404,23 @@ void sub_0805A94C(Manager15* this) { tmp2 = tmp1 + 0x100; if (tmp1 < 0) tmp1 = 0; - if (tmp1 > 0xF0) - tmp1 = 0xF0; + if (tmp1 > DISPLAY_WIDTH) + tmp1 = DISPLAY_WIDTH; if (tmp2 < 0) tmp2 = 0; - if (tmp2 > 0xF0) - tmp2 = 0xF0; + if (tmp2 > DISPLAY_WIDTH) + tmp2 = DISPLAY_WIDTH; gScreen.controls.window1HorizontalDimensions = (tmp1 << 8 | tmp2); tmp1 = -gScreen.bg3.yOffset; tmp2 = tmp1 + 0x100; if (tmp1 < 0) tmp1 = 0; - if (tmp1 > 0xA0) - tmp1 = 0xA0; + if (tmp1 > DISPLAY_HEIGHT) + tmp1 = DISPLAY_HEIGHT; if (tmp2 < 0) tmp2 = 0; - if (tmp2 > 0xA0) - tmp2 = 0xA0; + if (tmp2 > DISPLAY_HEIGHT) + tmp2 = DISPLAY_HEIGHT; gScreen.controls.window1VerticalDimensions = (tmp1 << 8 | tmp2); } @@ -432,18 +432,18 @@ void sub_0805A9CC(Manager15* this) { tmp2 = tmp1 + 0x100; if (tmp1 < 0) tmp1 = 0; - if (tmp1 > 0xF0) - tmp1 = 0xF0; + if (tmp1 > DISPLAY_WIDTH) + tmp1 = DISPLAY_WIDTH; if (tmp2 < 0) tmp2 = 0; - if (tmp2 > 0xF0) - tmp2 = 0xF0; + if (tmp2 > DISPLAY_WIDTH) + tmp2 = DISPLAY_WIDTH; gScreen.controls.window1HorizontalDimensions = tmp1 << 8 | tmp2; tmp1 = gRoomControls.roomScrollY - this->unk_26 + this->unk_36; gScreen.bg3.yOffset = tmp1 & 0x3F; tmp3 = (&gBG3Buffer[((tmp1 / 0x40) << 8)]); gScreen.bg3.tilemap = (u32*)tmp3; - gScreen.controls.window1VerticalDimensions = 0xa0; + gScreen.controls.window1VerticalDimensions = DISPLAY_HEIGHT; if (this->unk_28 == tmp3) return; this->unk_28 = tmp3; @@ -483,14 +483,16 @@ void sub_0805AADC(u32 unk0) { void sub_0805AAF0(u32 unk0) { sub_0805AADC(unk0); gScreen.controls.layerFXControl = 0x3E48; - gScreen.controls.alphaBlend = 0x1008; - gScreen.bg3.control = 0x1E04; + gScreen.controls.alphaBlend = BLDALPHA_BLEND(8, 16); + gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_CHARBASE(1); gScreen.bg3.tilemap = &gBG3Buffer; gScreen.bg3.xOffset = 0; gScreen.bg3.yOffset = 0; gScreen.bg3.updated = 1; - gScreen.controls.windowInsideControl = 0x3F3F; - gScreen.controls.windowOutsideControl = 0x37; - gScreen.controls.window1HorizontalDimensions = 0xF0; - gScreen.controls.window1VerticalDimensions = 0xA0; + gScreen.controls.windowInsideControl = + WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN0_CLR | WININ_WIN1_CLR; + gScreen.controls.windowOutsideControl = + WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; + gScreen.controls.window1HorizontalDimensions = DISPLAY_WIDTH; + gScreen.controls.window1VerticalDimensions = DISPLAY_HEIGHT; } diff --git a/src/manager/manager18.c b/src/manager/manager18.c index 1d797c5c..e18fd94e 100644 --- a/src/manager/manager18.c +++ b/src/manager/manager18.c @@ -24,7 +24,7 @@ void Manager18_Main(Manager18* this) { this->manager.unk_0e = 0; this->manager.unk_0f = 8; this->field_0x20 = gUnk_0810865C[0]; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805AEDC, sub_0805AF3C); } else { @@ -47,10 +47,10 @@ void Manager18_Main(Manager18* this) { } void sub_0805AEDC(Manager18* this) { - gScreen.bg3.control = 0x1e05; - gScreen.lcd.displayControl |= 0x800; - gScreen.controls.layerFXControl = 0x3648; - gScreen.controls.alphaBlend = (this != NULL) ? this->field_0x20 : 0x1000; + gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1); + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; + gScreen.controls.layerFXControl = BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD; + gScreen.controls.alphaBlend = (this != NULL) ? this->field_0x20 : BLDALPHA_BLEND(0, 16); gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI; gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI; if (this != NULL) { @@ -60,6 +60,6 @@ void sub_0805AEDC(Manager18* this) { void sub_0805AF3C(Manager18* this) { this->manager.unk_10 &= 0xdf; - gScreen.lcd.displayControl &= 0xf7ff; + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0; } diff --git a/src/manager/manager19.c b/src/manager/manager19.c index a6118c5c..0207ab56 100644 --- a/src/manager/manager19.c +++ b/src/manager/manager19.c @@ -15,7 +15,7 @@ void Manager19_Main(Manager* this) { if (this->action == 0) { this->action = 1; this->unk_10 |= 0x20; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805AFFC, NULL); } else { @@ -30,8 +30,8 @@ void Manager19_Main(Manager* this) { } void sub_0805AFFC(Manager* this) { - gScreen.bg3.control = 0x1e03; - gScreen.lcd.displayControl |= 0x800; + gScreen.bg3.control = BGCNT_PRIORITY(3) | BGCNT_SCREENBASE(30); + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI; gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI; } diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c index cc5ab45e..dc09ea5f 100644 --- a/src/manager/manager1A.c +++ b/src/manager/manager1A.c @@ -68,7 +68,7 @@ void sub_0805B328(Manager1A*); void sub_0805B048(Manager1A* this) { struct_08108764* tmp; Entity* obj; - SetDefaultPriority((Entity*)&this->manager, 6); + SetDefaultPriority((Entity*)&this->manager, PRIO_PLAYER_EVENT); MemClear(&this->unk_20, 0x20); this->manager.action = 1; this->unk_3f = gRoomControls.roomID; @@ -197,7 +197,7 @@ void sub_0805B2B0(Manager1A* this) { if (tmp2 > 12) { tmp2 = 12; } - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gRoomControls.bg3OffsetX.HALF.HI = gRoomControls.roomScrollX + this->unk_34 + tmp; gScreen.bg3.xOffset = gRoomControls.roomScrollX + this->unk_34 + tmp; gRoomControls.bg3OffsetY.HALF.HI = gRoomControls.roomScrollY + this->unk_36 + tmp2; @@ -211,7 +211,7 @@ void sub_0805B328(Manager1A* this) { tmp = &gUnk_08108764[this->manager.unk_0a]; LoadResourceAsync(&gGlobalGfxAndPalettes[tmp->unk_0c->unk_00], 0x0600F000, 0x800); gScreen.bg3.control = 0x1E07; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.bg3.xOffset = gRoomControls.bg3OffsetX.HALF.HI; gScreen.bg3.yOffset = gRoomControls.bg3OffsetY.HALF.HI; gScreen.controls.layerFXControl &= ~0x8; diff --git a/src/manager/manager1B.c b/src/manager/manager1B.c index c2392fdc..a172bcfc 100644 --- a/src/manager/manager1B.c +++ b/src/manager/manager1B.c @@ -29,7 +29,7 @@ void Manager1B_Main(Manager1B* this) { if (this->manager.action == 0) { this->manager.action = 1; this->manager.unk_10 |= 0x20; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (this->manager.unk_0a != 0) { RegisterTransitionManager(this, sub_0805B4B4, NULL); } @@ -70,7 +70,7 @@ void sub_0805B4D0(u32 param_1) { LoadGfxGroup(gUnk_08108C5C[param_1]); gScreen.bg3.control = 0x1e07; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.bg3.xOffset = (gRoomControls.roomScrollX - gRoomControls.roomOriginX) >> 2; uVar2 = (gRoomControls.roomScrollY - gRoomControls.roomOriginY) >> 1; diff --git a/src/manager/manager1D.c b/src/manager/manager1D.c index 63ffcf8c..b9039a05 100644 --- a/src/manager/manager1D.c +++ b/src/manager/manager1D.c @@ -13,7 +13,7 @@ void Manager1D_Main(Manager* this) { void sub_0805B5E0(Manager* this) { this->action = 1; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.bg3.control = gUnk_08108C88[this->unk_0a]; gRoomControls.bg3OffsetY.WORD = 0; gRoomControls.bg3OffsetX.WORD = 0; diff --git a/src/manager/manager2.c b/src/manager/manager2.c index 9dcb74f2..3f74d209 100644 --- a/src/manager/manager2.c +++ b/src/manager/manager2.c @@ -53,7 +53,7 @@ void sub_080575C8(u32 param) { s32 bgOffset; gUnk_0200B650 = 0; - *(u16*)0x4000000 = 0; + REG_DISPCNT = 0; LoadGfxGroup(param); gRoomVars.unk_10[0] = param; @@ -62,7 +62,7 @@ void sub_080575C8(u32 param) { gScreen.bg3.yOffset = bgOffset & 0x3f; gScreen.bg3.xOffset = 0; gScreen.bg3.tilemap = &gMapDataTopSpecial[(bgOffset / 0x40) * 0x200]; - gScreen.bg3.control = 0x1d49; + gScreen.bg3.control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_MOSAIC; gScreen.bg3.updated = 1; bgOffset = (gRoomControls.roomScrollY - gRoomControls.roomOriginY); @@ -70,16 +70,17 @@ void sub_080575C8(u32 param) { gScreen.bg1.yOffset = bgOffset & 0x3f; gScreen.bg1.xOffset = 0; gScreen.bg1.tilemap = &gMapDataTopSpecial[0x2000 + (bgOffset / 0x40) * 0x200]; - gScreen.bg1.control = 0x1e49; + gScreen.bg1.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_MOSAIC; gScreen.bg1.updated = 1; - gScreen.controls.layerFXControl = 0x3c48; - gScreen.controls.alphaBlend = 0x609; - gScreen.lcd.displayControl |= 0xa00; + gScreen.controls.layerFXControl = + BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD; + gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 6); + gScreen.lcd.displayControl |= DISPCNT_BG3_ON | DISPCNT_BG1_ON; } void sub_08057688(void) { - gScreen.bg3.control = 0x1d48; - gScreen.bg1.control = 0x1e48; + gScreen.bg3.control = BGCNT_SCREENBASE(29) | BGCNT_CHARBASE(2) | BGCNT_MOSAIC; + gScreen.bg1.control = BGCNT_SCREENBASE(30) | BGCNT_CHARBASE(2) | BGCNT_MOSAIC; } void sub_080576A0(Manager2* this) { diff --git a/src/manager/manager2E.c b/src/manager/manager2E.c index 19205a28..7dbb3aa5 100644 --- a/src/manager/manager2E.c +++ b/src/manager/manager2E.c @@ -42,7 +42,7 @@ void sub_0805D280(Manager2E* this) { if (this->manager.unk_0e == 0) { this->manager.unk_0e = 0x1e; } - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); } void sub_0805D2C0(Manager2E* this) { @@ -80,7 +80,7 @@ void sub_0805D344(Manager2E* this) { this->manager.unk_0e = 0x1e; } this->manager.unk_0f = this->manager.unk_0e; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); } void sub_0805D36C(Manager2E* this) { diff --git a/src/manager/manager2F.c b/src/manager/manager2F.c index 84619e66..d35c67a8 100644 --- a/src/manager/manager2F.c +++ b/src/manager/manager2F.c @@ -16,7 +16,7 @@ void Manager2F_Main(Manager* this) { if (this->action == 0) { this->action = 1; this->unk_10 |= 0x20; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805D470, NULL); } else { @@ -34,7 +34,7 @@ void Manager2F_Main(Manager* this) { void sub_0805D470(Manager* this) { LoadGfxGroup(0x4c); gScreen.bg3.control = 0x1e07; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI; gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI; } diff --git a/src/manager/manager31.c b/src/manager/manager31.c index 2dcf7727..bb7ebdde 100644 --- a/src/manager/manager31.c +++ b/src/manager/manager31.c @@ -28,7 +28,7 @@ void Manager31_Main(Manager31* this) { s32 count; if (this->manager.action == 0) { - this->manager.action += 1; + this->manager.action++; if (CheckGlobalFlag(GORON_KAKERA_L) != 0 && CheckGlobalFlag(GORON_KAKERA_M) != 0 && CheckGlobalFlag(GORON_KAKERA_R) != 0) { if (CheckGlobalFlag(GORON_KAKERA_LV2) == 0) { @@ -36,28 +36,22 @@ void Manager31_Main(Manager31* this) { SetGlobalFlag(GORON_KAKERA_LV2); goto clearGlobalFlags; } - } else { - if (CheckGlobalFlag(GORON_KAKERA_LV3) == 0) { - if (CheckGlobalFlag(LV2_CLEAR) != 0) { - SetGlobalFlag(GORON_KAKERA_LV3); - goto clearGlobalFlags; - } - } else { - if (CheckGlobalFlag(GORON_KAKERA_LV4) == 0) { - if (CheckGlobalFlag(LV3_CLEAR) != 0) { - SetGlobalFlag(GORON_KAKERA_LV4); - goto clearGlobalFlags; - } - } else { - if (CheckGlobalFlag(GORON_KAKERA_LV5) == 0 && CheckGlobalFlag(LV4_CLEAR) != 0) { - SetGlobalFlag(GORON_KAKERA_LV5); - clearGlobalFlags: - ClearGlobalFlag(GORON_KAKERA_L); - ClearGlobalFlag(GORON_KAKERA_M); - ClearGlobalFlag(GORON_KAKERA_R); - } - } + } else if (CheckGlobalFlag(GORON_KAKERA_LV3) == 0) { + if (CheckGlobalFlag(LV2_CLEAR) != 0) { + SetGlobalFlag(GORON_KAKERA_LV3); + goto clearGlobalFlags; } + } else if (CheckGlobalFlag(GORON_KAKERA_LV4) == 0) { + if (CheckGlobalFlag(LV3_CLEAR) != 0) { + SetGlobalFlag(GORON_KAKERA_LV4); + goto clearGlobalFlags; + } + } else if (CheckGlobalFlag(GORON_KAKERA_LV5) == 0 && CheckGlobalFlag(LV4_CLEAR) != 0) { + SetGlobalFlag(GORON_KAKERA_LV5); + clearGlobalFlags: + ClearGlobalFlag(GORON_KAKERA_L); + ClearGlobalFlag(GORON_KAKERA_M); + ClearGlobalFlag(GORON_KAKERA_R); } } this->itemActive[2] = 0; diff --git a/src/manager/manager32.c b/src/manager/manager32.c index 409840de..606f07ea 100644 --- a/src/manager/manager32.c +++ b/src/manager/manager32.c @@ -73,7 +73,7 @@ void sub_0805D860(Manager32* this) { case 0: this->manager.unk_0d = 1; this->field_0x20 = 0x80; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; break; case 1: if (--this->field_0x20 == 0x10) { @@ -95,7 +95,7 @@ void sub_0805D860(Manager32* this) { default: if (--this->manager.unk_0e == 0) { sub_0801E104(); - gScreen.lcd.displayControl &= 0xf7ff; + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; DeleteThisEntity(); } } @@ -107,7 +107,7 @@ void sub_0805D900(Manager32* this) { this->manager.unk_0d = 1; this->manager.unk_0e = 0x2d; this->field_0x20 = 1; - gScreen.lcd.displayControl |= 0x800; + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; break; case 1: if (--this->manager.unk_0e == 0) { @@ -126,7 +126,7 @@ void sub_0805D900(Manager32* this) { this->field_0x20 += 4; if (this->field_0x20 > 0x80) { sub_0801E104(); - gScreen.lcd.displayControl &= 0xf7ff; + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; DeleteThisEntity(); } break; @@ -164,7 +164,7 @@ void sub_0805DA08(u32 x, u32 y, u32 param_3) { affineDstData->pa = ((gSineTable[(param_3 + i + y) & 0xff] * x) >> 8) + gScreen.bg3.xOffset; affineDstData = (struct BgAffineDstData*)&affineDstData->pb; } - sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4[0] * 0xa0], 0x400001c, 0xa2600001); + sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4[0] * 0xa0], REG_ADDR_BG3HOFS, 0xa2600001); } void sub_0805DA90(Manager32* this, u32 param_2) { @@ -177,7 +177,7 @@ void sub_0805DA90(Manager32* this, u32 param_2) { AppendEntityToList((Entity*)manager, 8); } if (gArea.onEnter != NULL) { - gScreen.lcd.displayControl &= 0xf7ff; + gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; RoomExitCallback(); //! @bug: this always variable points to ROM, not a Manager* DeleteManager((Manager*)gArea.onEnter); diff --git a/src/manager/manager36.c b/src/manager/manager36.c index c955425f..96e8b1a3 100644 --- a/src/manager/manager36.c +++ b/src/manager/manager36.c @@ -32,7 +32,7 @@ void CreateManager36(Entity* entity, ScriptExecutionContext* context) { manager->subtype = 0x36; manager->unk_0a = context->intVariable; AppendEntityToList((Entity*)manager, 6); - SetDefaultPriority((Entity*)manager, 6); + SetDefaultPriority((Entity*)manager, PRIO_PLAYER_EVENT); } } diff --git a/src/manager/manager39.c b/src/manager/manager39.c index 1e51d22e..65355f84 100644 --- a/src/manager/manager39.c +++ b/src/manager/manager39.c @@ -48,7 +48,7 @@ void sub_0805E140(Manager39* this) { this->unk_20 = gRoomControls.roomID; this->manager.unk_0e = 0x78; this->manager.unk_0f = 0x3c; - SetDefaultPriority((Entity*)this, 7); + SetDefaultPriority((Entity*)this, PRIO_HIGHEST); sub_0805E1F8(gUnk_08108DE8[gArea.locationIndex], CheckIsDungeon()); } @@ -58,7 +58,7 @@ void sub_0805E18C(Manager39* this) { if (this->manager.unk_0b) { if (!--this->manager.unk_0f) { this->manager.unk_0b = 0; - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; ResetSystemPriority(); } } diff --git a/src/manager/manager7.c b/src/manager/manager7.c index b081b4ff..59cf85b6 100644 --- a/src/manager/manager7.c +++ b/src/manager/manager7.c @@ -14,7 +14,7 @@ void sub_08057E30(); u32 sub_08057E40(); void sub_08057E7C(u32); -extern u32 sub_08056300(const u16*); +extern u32 CheckRegionsOnScreen(const u16*); extern const u8 gGlobalGfxAndPalettes[]; @@ -66,7 +66,7 @@ void Manager7_Main(Manager7* this) { this->manager.unk_0e = 8; this->unk_20 = 0xFF; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); RegisterTransitionManager(this, sub_08057E30, 0); } if (sub_08057E40(this)) { @@ -113,7 +113,7 @@ void sub_08057E30(Manager7* this) { } u32 sub_08057E40(Manager7* this) { - u32 tmp = sub_08056300(gUnk_08108050); + u32 tmp = CheckRegionsOnScreen(gUnk_08108050); if (tmp != 0xFF) { gRoomVars.unk_10[0] = tmp; return 1; @@ -124,7 +124,7 @@ u32 sub_08057E40(Manager7* this) { void sub_08057E64() { u32 tmp; - tmp = sub_08056300(gUnk_08108050); + tmp = CheckRegionsOnScreen(gUnk_08108050); if (tmp != 0xFF) { sub_08057E7C(tmp); } diff --git a/src/manager/managerA.c b/src/manager/managerA.c index 76cab147..564c1cac 100644 --- a/src/manager/managerA.c +++ b/src/manager/managerA.c @@ -136,7 +136,7 @@ void sub_08058514(ManagerA* this) { case 3: if (gPlayerEntity.action != 1 && gPlayerEntity.action != 9) return; - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; ResetPlayerEventPriority(); SetFlag(this->unk_3c); DeleteThisEntity(); diff --git a/src/manager/managerB.c b/src/manager/managerB.c index f52c4138..82182094 100644 --- a/src/manager/managerB.c +++ b/src/manager/managerB.c @@ -42,7 +42,7 @@ void ManagerB_Init(ManagerB* this) { if (!this->unk_3c) { ManagerB_LoadFight(&this->manager); } - SetDefaultPriority((Entity*)this, 3); + SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK); } else { DeleteThisEntity(); } @@ -148,7 +148,7 @@ void ManagerBHelper_Main(Manager* this) { Entity* current; if (this->action == 0) { this->action = 1; - SetDefaultPriority((Entity*)this, 3); + SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK); } // go through and check all monitored enemies. anyRemaining = 0; diff --git a/src/manager/managerC.c b/src/manager/managerC.c index d4a83f64..2583ce98 100644 --- a/src/manager/managerC.c +++ b/src/manager/managerC.c @@ -286,7 +286,7 @@ void sub_08058D34() { LoadGfxGroup(0x16); tmp = gScreen.lcd.displayControl; tmp2 = 0; - gScreen.lcd.displayControl |= 1; + gScreen.lcd.displayControl |= DISPCNT_MODE_1; gScreen.bg2.control = 0xBC82; gScreen.bg1.control = 0x5E86; gScreen.bg1.xOffset = 0; diff --git a/src/manager/managerF.c b/src/manager/managerF.c index 432ec49f..2fb9972b 100644 --- a/src/manager/managerF.c +++ b/src/manager/managerF.c @@ -209,7 +209,7 @@ void sub_08059094(ManagerF* this) { void sub_080590E0(ManagerF* this) { if (!this->manager.action) { this->manager.action = 1; - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); } if (CheckLocalFlag(0x6c)) { if (CheckLocalFlag(0x4b)) { @@ -427,7 +427,7 @@ void sub_080594DC(ManagerF* this) { #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) void sub_08059548(ManagerF* this) { - SetDefaultPriority((Entity*)this, 6); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gPlayerEntity.action == 0x16) { DeleteThisEntity(); } diff --git a/src/npc.c b/src/npc.c index 328ce1af..ba3c0ada 100644 --- a/src/npc.c +++ b/src/npc.c @@ -82,7 +82,7 @@ void (*const gNPCFunctions[][3])(Entity* ent) = { [GREGAL] = { Gregal, NULL, Gregal_Fusion }, [MAYOR_HAGEN] = { MayorHagen, NULL, MayorHagen_Fusion }, [BIG_GORON] = { BigGoron, NULL, NULL }, - [EZLO_CAP] = { EzloCap, NULL, NULL }, + [EZLO] = { Ezlo, NULL, NULL }, [NPC_UNK_4E] = { NPC4E, NULL, NPC4E_Fusion }, [NPC_UNK_4F] = { NPC4F, NULL, NULL }, [CLOTHES_RACK] = { ClothesRack, NULL, NULL }, diff --git a/src/npc/beedle.c b/src/npc/beedle.c index ce9c7722..ada9a485 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -153,7 +153,7 @@ void sub_080634E4(Entity* this, ScriptExecutionContext* context) { } void sub_080634EC(Entity* this) { - gRoomVars.itemForSaleIndex = gUnk_0810C88C[this->type2]; + gRoomVars.shopItemType = gUnk_0810C88C[this->type2]; } void sub_08063504(Entity* this, ScriptExecutionContext* context) { diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 797c9f6f..e76a26e2 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -44,7 +44,7 @@ void sub_0806CF30(Entity* this) { this->action = 1; this->subAction = 1; this->field_0x68.HWORD = this->x.HALF.HI; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0806D0B0(this); sub_0807DD64(this); } else { @@ -133,7 +133,7 @@ void sub_0806D1D0(Entity* this) { this->spriteSettings.draw = 3; this->frameIndex = 0; this->actionDelay = 0x1e; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } switch (this->subAction) { @@ -174,7 +174,7 @@ void sub_0806D274(Entity* this) { this->spritePriority.b0 = 7; this->frameIndex = 2; this->actionDelay = 8; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); npc = CreateNPC(0x4c, 3, 0); if (npc != NULL) { npc->child = this; @@ -221,7 +221,7 @@ void sub_0806D348(Entity* this) { this->spritePriority.b0 = 6; this->spriteSettings.draw = 0; this->frameIndex = 5; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } if (this->child->frameIndex == 4) { this->spriteSettings.draw = 3; @@ -239,7 +239,7 @@ void sub_0806D3C0(Entity* this) { } this->action = 1; this->hitbox = &gHitbox_3; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD64(this); } else { this->x.HALF.HI = this->parent->x.HALF.HI; @@ -262,7 +262,7 @@ void sub_0806D41C(Entity* this) { sub_0806D4C0(this, 1); sub_0806D4C0(this, 2); sub_0806D4C0(this, 3); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } else { ExecuteScriptForEntity(this, NULL); HandleEntity0x82Actions(this); @@ -286,7 +286,7 @@ void sub_0806D4C0(Entity* this, u32 param) { npc->parent = this; CopyPosition(this, npc); ResolveEntityOnTop(this, npc); - SetDefaultPriority(npc, 2); + SetDefaultPriority(npc, PRIO_MESSAGE); } } diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index f489ad72..8663b241 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -24,7 +24,7 @@ void Carpenter(Entity* this) { break; this->action = 1; this->field_0x68.HALF.HI = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD64(this); case 1: @@ -52,14 +52,14 @@ void Carpenter(Entity* this) { void Carpenter_Head(Entity* this) { if (this->type < 2) { - SetExtraSpriteFrame(this, 0, this->frame & 0xffffff7f); + SetExtraSpriteFrame(this, 0, this->frame & ~0x80); SetExtraSpriteFrame(this, 1, this->frameIndex); SetExtraSpriteFrame(this, 2, this->frameSpriteSettings & 0x3f); SetSpriteSubEntryOffsetData1(this, 1, 0); SetSpriteSubEntryOffsetData2(this, 1, 2); sub_0807000C(this); } else { - SetExtraSpriteFrame(this, 0, this->frame & 0xffffff7f); + SetExtraSpriteFrame(this, 0, this->frame & ~0x80); SetExtraSpriteFrame(this, 1, this->frameIndex); SetSpriteSubEntryOffsetData1(this, 1, 0); sub_0807000C(this); @@ -94,7 +94,7 @@ void Carpenter_Fusion(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_08110CA8[this->type * 4]) != 0) { this->action = this->action + 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, (u32)this->type * 8 + 2); } } else { diff --git a/src/npc/cat.c b/src/npc/cat.c index 3371284c..3fec5ab9 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -153,7 +153,7 @@ void sub_0806799C(Entity* this) { UpdateAnimationSingleFrame(this); if ((gMessage.doTextBox & 0x7f) == 0) { sub_08067B08(this); - SetDefaultPriority(this, 1); + SetDefaultPriority(this, PRIO_PLAYER); } } @@ -319,7 +319,7 @@ void sub_08067C44(Entity* this) { } else { this->action = 4; sub_08067790(this); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } this->interactType = 0; SoundReq(SFX_VO_CAT); diff --git a/src/npc/cucco.c b/src/npc/cucco.c index 8bd30005..b935dc7b 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -21,7 +21,7 @@ void sub_0806E4B8(Entity* this) { this->action += 1; this->field_0x68.HALF.LO = sub_0801E99C(this); sub_080787A8(this, this->field_0x68.HALF.LO); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); this->subAction = 0; sub_0806E4EC(this); } diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index 0cb4b76c..bfadc897 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -22,7 +22,7 @@ void sub_0806E730(Entity* this) { this->action += 1; this->field_0x68.HALF.LO = sub_0801E99C(this); sub_080787A8(this, this->field_0x68.HALF.LO); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); this->subAction = 0; sub_0806E764(this); } diff --git a/src/npc/dampe.c b/src/npc/dampe.c index 096ac1e8..afb9ef63 100644 --- a/src/npc/dampe.c +++ b/src/npc/dampe.c @@ -16,7 +16,7 @@ void Dampe(Entity* this) { case 0: this->action = 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); return; case 1: diff --git a/src/npc/dog.c b/src/npc/dog.c index 3dc8641e..e749ea7e 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -66,7 +66,7 @@ void sub_08069B44(Entity* this) { this->animationState = 2; this->field_0x6a.HALF.LO = 0xff; this->field_0x74.HALF.LO = sub_0801E99C(this); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 10); if ((this->flags & 2) != 0) { sub_0807DD50(this); @@ -273,7 +273,7 @@ u32 sub_08069F90(Entity* this) { if ((this->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) { return 1; } else { - return sub_080041A0(this, &gPlayerEntity, 0x14, 0x14); + return EntityInRectRadius(this, &gPlayerEntity, 0x14, 0x14); } } @@ -362,7 +362,7 @@ void Dog_Fusion(Entity* this) { if (sub_08069EF0(this) != 0) { this->action += 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 0x23); } } else { diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index cdc05551..06de67f8 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -17,7 +17,7 @@ void DrLeft(Entity* this) { if (this->type == 0) { if (this->action == 0) { this->action += 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } ExecuteScriptForEntity(this, NULL); diff --git a/src/npc/emma.c b/src/npc/emma.c index fa75eea0..ed4d6025 100644 --- a/src/npc/emma.c +++ b/src/npc/emma.c @@ -10,7 +10,7 @@ extern ScreenTransitionData gUnk_0813AD38; void Emma(Entity* this) { if (this->action == 0) { this->action += 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } else { sub_0807DD94(this, 0); diff --git a/src/npc/epona.c b/src/npc/epona.c index 540184c2..4c3d9174 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -77,7 +77,7 @@ void sub_08065AA4(Entity* this) { sub_0806F118(this); } else { this->action = 3; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_08065A50(this); } InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); diff --git a/src/npc/ezloCap.c b/src/npc/ezlo.c similarity index 96% rename from src/npc/ezloCap.c rename to src/npc/ezlo.c index 6860455b..4f1dcd62 100644 --- a/src/npc/ezloCap.c +++ b/src/npc/ezlo.c @@ -9,10 +9,10 @@ const u8 gUnk_08114134[]; const u8 gUnk_08114144[]; // Ezlo as a cap in the Minish Woods, is destroyed as soon as link wears ezlo -void EzloCap(Entity* this) { +void Ezlo(Entity* this) { if (this->action == 0) { this->action += 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } ExecuteScriptForEntity(this, NULL); diff --git a/src/npc/farmers.c b/src/npc/farmers.c index c2f633fe..d31a7a3a 100644 --- a/src/npc/farmers.c +++ b/src/npc/farmers.c @@ -12,7 +12,7 @@ void sub_0806BC58(Entity* this); ASM_FUNC("asm/non_matching/farmers/Farmers.inc", void Farmers(Entity* this)) void sub_0806BC58(Entity* this) { - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } void Farmers_Head(Entity* this) { diff --git a/src/npc/festari.c b/src/npc/festari.c index 114ac046..49dde08c 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -18,7 +18,7 @@ void Festari(Entity* this) { void sub_0805FE10(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); this->field_0x68.HALF.LO = sub_0801E99C(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); @@ -113,7 +113,7 @@ void Festari_Fusion(Entity* this) { if (this->action == 0) { this->action += 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 8); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index c0a9f88d..a8e04f9c 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -32,7 +32,7 @@ void ForestMinish(Entity* this) { this->spriteSettings.draw = TRUE; this->field_0x68.HALF.HI = this->animationState = this->actionDelay << 1; this->actionDelay = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); StartCutscene(this, (u16*)gUnk_08109D18[this->type2]); sub_0807DD50(this); } @@ -267,7 +267,7 @@ void ForestMinish_Fusion(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_0810A348)) { this->action++; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 6); } } else { diff --git a/src/npc/gentari.c b/src/npc/gentari.c index 46b8500f..d4938806 100644 --- a/src/npc/gentari.c +++ b/src/npc/gentari.c @@ -10,7 +10,7 @@ void Gentari(Entity* this) { case 0: this->action = 1; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); this->field_0x68.HALF.LO = sub_0801E99C(this); sub_08078784(this, this->field_0x68.HALF.LO); sub_0807DD50(this); @@ -36,7 +36,7 @@ void Gentari_Fusion(Entity* this) { if (this->action == 0) { this->action++; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 10); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index 1cdbdd8a..de04427b 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -94,7 +94,7 @@ void sub_08065D18(Entity* this) { this->spriteSettings.draw = 1; this->spriteRendering.alphaBlend = 1; *(u32**)&this->field_0x6c = &gUnk_08110188; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 2); gScreen.controls.layerFXControl = 0x3f40; gScreen.controls.alphaBlend = 0x1000; diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 28962706..9c1b107c 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -8,12 +8,12 @@ #include "script.h" #include "save.h" -extern u32 GoronMerchant_GetSalePrice(Entity*); +static u32 GoronMerchant_GetSalePrice(Entity*); extern void (*const gUnk_08111B88[])(Entity*); extern void (*const gUnk_08111B98[])(Entity*); -const u16 GoronMerchant_KinstonePrices[]; +static const u16 sKinstonePrices[]; extern u32 sub_0801E7D0(u32); @@ -78,8 +78,6 @@ void sub_08069654(Entity* this) { } void sub_08069660(Entity* this) { - u32 uVar1; - MessageNoOverlap(0x2c1c, this); gMessage.field_0x10 = (u16)GoronMerchant_GetSalePrice(this); } @@ -98,16 +96,16 @@ void sub_08069684(void) { } void sub_080696B0(void) { - gRoomVars.itemForSaleIndex = 0; + gRoomVars.shopItemType = 0; } -u32 GoronMerchant_GetSalePrice(Entity* this) { +static u32 GoronMerchant_GetSalePrice(Entity* this) { u32 restockCount; u32 temp; u32 kinstoneType; s32 itemForSale; - itemForSale = gRoomVars.field_0x7; + itemForSale = gRoomVars.shopItemType2; if (itemForSale > 0x70) { kinstoneType = 1; } else { @@ -129,17 +127,17 @@ u32 GoronMerchant_GetSalePrice(Entity* this) { if (CheckGlobalFlag(GORON_KAKERA_LV5)) { restockCount = 4; } - return GoronMerchant_KinstonePrices[restockCount * 3 + kinstoneType]; + return sKinstonePrices[restockCount * 3 + kinstoneType]; } void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* context) { s32 salePrice = GoronMerchant_GetSalePrice(this); if (salePrice <= gSave.stats.rupees) { - if (sub_0801E7D0(gRoomVars.field_0x7) < 99) { + if (sub_0801E7D0(gRoomVars.shopItemType2) < 99) { ModRupees(-salePrice); - sub_080A7C18(0x5c, gRoomVars.field_0x7, 0); - gRoomVars.itemForSaleIndex = 0; - gRoomVars.field_0x7 = 0; + sub_080A7C18(0x5c, gRoomVars.shopItemType2, 0); + gRoomVars.shopItemType = 0; + gRoomVars.shopItemType2 = 0; context->condition = 1; } else { MessageNoOverlap(0x2c1f, this); @@ -149,7 +147,7 @@ void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* contex MessageNoOverlap(0x2c1e, this); context->condition = 0; } - gActiveScriptInfo.flags = gActiveScriptInfo.flags | 1; + gActiveScriptInfo.flags |= 1; } void (*const gUnk_08111B88[])(Entity*) = { @@ -163,7 +161,7 @@ void (*const gUnk_08111B98[])(Entity*) = { sub_08069654, }; -const u16 GoronMerchant_KinstonePrices[] = { +static const u16 sKinstonePrices[] = { #ifdef EU 200, 100, diff --git a/src/npc/gregal.c b/src/npc/gregal.c index db60132d..60003505 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -19,7 +19,7 @@ void sub_0806CAF4(Entity* this) { if (this->action == 0) { this->action += 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); npc = CreateNPC(0x4a, 1, 0); if (npc != NULL) { npc->parent = this; @@ -46,7 +46,7 @@ void sub_0806CB80(Entity* this) { this->action += 1; this->animationState = 2; this->frameIndex = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } if (this->parent != NULL) { this->frameIndex = (this->parent->frame & 3) + 0x21; @@ -57,7 +57,7 @@ void sub_0806CBB4(Entity* this) { if (this->action == 0) { this->action += 1; this->animationState = 2; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 0x11); } GetNextFrame(this); @@ -74,7 +74,7 @@ void sub_0806CC08(Entity* this) { case 0: this->action = 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD64(this); case 1: if (this->interactType == 2) { @@ -154,7 +154,7 @@ void Gregal_Fusion(Entity* this) { if (this->action == 0) { this->action += 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 6); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/hurdyGurdyMan.c b/src/npc/hurdyGurdyMan.c index 8fbd8b0d..52277dff 100644 --- a/src/npc/hurdyGurdyMan.c +++ b/src/npc/hurdyGurdyMan.c @@ -20,7 +20,7 @@ void HurdyGurdyMan(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_081144F0) != 0) { this->action = 1; this->field_0x68.HALF.HI = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } break; @@ -36,7 +36,7 @@ void HurdyGurdyMan(Entity* this) { pointerToArray = pointerToArray + 3; } sub_0801DFB4(this, (u32)*pointerToArray, (u32)pointerToArray[1], (u32)pointerToArray[2]); - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; } else { sub_0807DD94(this, NULL); } @@ -79,7 +79,7 @@ void HurdyGurdyMan_Fusion(Entity* this) { if (uVar1 != 0) { this->action += 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 10); } } else { diff --git a/src/npc/kingGustaf.c b/src/npc/kingGustaf.c index 596e0b90..a40a19f6 100644 --- a/src/npc/kingGustaf.c +++ b/src/npc/kingGustaf.c @@ -11,7 +11,7 @@ void KingGustaf(Entity* this) { this->action += 1; this->spriteRendering.alphaBlend = 1; this->collisionLayer = 2; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); gScreen.controls.layerFXControl = 0x3f40; gScreen.controls.alphaBlend = 0x1000; diff --git a/src/npc/librari.c b/src/npc/librari.c index 0d484d2a..509d790e 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -16,7 +16,7 @@ void Librari(Entity* this) { this->animationState = this->actionDelay; this->field_0x68.HALF.LO = sub_0801E99C(this); sub_08078784(this, this->field_0x68.HALF.LO); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); break; case 1: diff --git a/src/npc/mama.c b/src/npc/mama.c index 5c85f121..d5ea5950 100644 --- a/src/npc/mama.c +++ b/src/npc/mama.c @@ -48,7 +48,7 @@ bool32 sub_0806C454(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_08113754) == 0) { return FALSE; } else { - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); return TRUE; } } diff --git a/src/npc/marcy.c b/src/npc/marcy.c index 0b6d0dcc..01c94bc4 100644 --- a/src/npc/marcy.c +++ b/src/npc/marcy.c @@ -9,7 +9,7 @@ extern u16 gUnk_0810C34C[]; void Marcy(Entity* this) { if (this->action == 0) { this->action += 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD64(this); } sub_0807DD94(this, NULL); diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index a9353164..1c569e92 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -19,7 +19,7 @@ void MayorHagen(Entity* this) { this->action = 1; this->field_0x68.HALF.HI = 0; this->field_0x68.HALF.LO = sub_0801E99C(this); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); break; case 1: diff --git a/src/npc/melari.c b/src/npc/melari.c index e0879f3b..146ae078 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -65,7 +65,7 @@ void sub_08068780(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; this->animationState = this->type; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); break; case 1: diff --git a/src/npc/minishEzlo.c b/src/npc/minishEzlo.c index a6824c50..0d2d017b 100644 --- a/src/npc/minishEzlo.c +++ b/src/npc/minishEzlo.c @@ -12,7 +12,7 @@ void MinishEzlo(Entity* this) { } this->action += 1; this->animationState = this->actionDelay * 2; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } ExecuteScriptForEntity(this, NULL); diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index b1263127..7cae63d1 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -23,7 +23,7 @@ void Mutoh(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_08110C00)) { this->action = 1; this->spriteSettings.draw = TRUE; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } break; diff --git a/src/npc/percy.c b/src/npc/percy.c index 85eb80fc..90e10b28 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -79,7 +79,7 @@ void sub_0806B41C(Entity* this) { if (this->field_0x68.HALF.LO == 33) tmp += 3; sub_0801DFB4(this, tmp[0], tmp[1], tmp[2]); - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; } else { sub_0807DD94(this, NULL); } diff --git a/src/npc/pita.c b/src/npc/pita.c index b379ba8f..36856cb5 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -15,7 +15,7 @@ extern u32 sub_080028F4(const u8*); void Pita(Entity* this) { if (this->action == 0) { this->action += 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); ResolveEntityOnTop(this, this); this->hitbox = &gUnk_0810C428; sub_0807DD64(this); diff --git a/src/npc/rem.c b/src/npc/rem.c index 7298b531..09f4464e 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -55,7 +55,7 @@ void sub_0806A3D8(Entity* this) { this->action = 1; this->actionDelay = 0xb4; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0806A8C8(this); uVar1 = StartCutscene(this, &script_08012F0C); *(ScriptExecutionContext**)&this->cutsceneBeh = uVar1; @@ -196,7 +196,7 @@ void sub_0806A830(Entity* this) { if (this->action == 0) { this->action = 1; InitializeAnimation(this, 0x14); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } if ((gActiveScriptInfo.unk_00 & 0x200) != 0) { DeleteThisEntity(); @@ -215,7 +215,7 @@ void sub_0806A890(Entity* this) { if (this->action == 0) { this->action = 1; InitializeAnimation(this, 0x15); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } GetNextFrame(this); if ((this->frame & 0x80) != 0) { diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index dc38b634..ef0f0486 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -28,7 +28,7 @@ void sub_08065080(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 4); sub_08078778(this); #ifndef EU diff --git a/src/npc/syrup.c b/src/npc/syrup.c index 92b4c8b5..3554d95a 100644 --- a/src/npc/syrup.c +++ b/src/npc/syrup.c @@ -27,7 +27,7 @@ void sub_0806A1F8(Entity* this) { iVar1 = LoadExtraSpriteData(this, paVar2); if (iVar1) { this->action = 1; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); InitializeAnimation(this, 0); } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index dc811ab9..645361d2 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -18,7 +18,7 @@ void Teachers(Entity* this) { this->spriteSettings.draw = TRUE; this->animationState = this->actionDelay; this->field_0x68.HALF.HI = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } break; diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 5f97093c..cde7c526 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -57,7 +57,7 @@ void sub_0806AC3C(Entity* this) { if (this->animIndex <= 3) { s32 unk; Entity* link = &gPlayerEntity; - if (sub_080041A0(this, link, 0x18, 0x18)) { + if (EntityInRectRadius(this, link, 0x18, 0x18)) { unk = GetFacingDirection(this, link) & 0x1e; } else { unk = this->animationState * 4; diff --git a/src/npc/vaati.c b/src/npc/vaati.c index bae2bdac..751a1be6 100644 --- a/src/npc/vaati.c +++ b/src/npc/vaati.c @@ -27,7 +27,7 @@ void VaatiAction0(Entity* this) { this->spriteSettings.draw = 1; this->field_0x68.HALF.LO = 0; this->field_0x68.HALF.HI = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD64(this); VaatiAction1(this); } diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c index 338ff377..7eafda20 100644 --- a/src/npc/wheaton.c +++ b/src/npc/wheaton.c @@ -9,7 +9,7 @@ void Wheaton(Entity* this) { if (this->action == 0) { this->action++; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); ResolveEntityOnTop(this, this); diff --git a/src/npc/zelda.c b/src/npc/zelda.c index f1da1c47..834679fa 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -23,7 +23,7 @@ void sub_08066CCC(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; PrependEntityToList(this, 7); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); } diff --git a/src/npc/zeldaFollower.c b/src/npc/zeldaFollower.c index 72e650ff..93d1ca3f 100644 --- a/src/npc/zeldaFollower.c +++ b/src/npc/zeldaFollower.c @@ -16,7 +16,7 @@ void ZeldaFollower(Entity* this) { this->animationState = 4; this->field_0x68.HALF.LO = 0; this->field_0x68.HALF.HI = 0; - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 0); sub_0806854C(this, NULL); } diff --git a/src/object.c b/src/object.c index 18b401c3..1df8d22e 100644 --- a/src/object.c +++ b/src/object.c @@ -10,7 +10,7 @@ void (*const gObjectFunctions[])(Entity*) = { [BUTTON] = Button, [OBJECT_4] = Object4, [POT] = Pot, - [OBJECT_6] = Object6, + [EZLO_CAP] = EzloCap, [PUSHED_BLOCK] = BlockPushed, [LOCKED_DOOR] = LockedDoor, [OBJECT_9] = Object9, diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index f2743031..5e7f87eb 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -34,7 +34,7 @@ void sub_08098D1C(Entity* this) { this->spriteSettings.draw = TRUE; sub_08098E88(this); } - SetDefaultPriority(this, 6); + SetDefaultPriority(this, PRIO_PLAYER_EVENT); InitAnimationForceUpdate(this, 0); } diff --git a/src/object/book.c b/src/object/book.c index d069a149..3430e4ef 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -211,7 +211,7 @@ void sub_0809B5EC(Entity* this) { u32 sub_0809B688(Entity* this) { u32 ret; - ret = sub_080041A0(this, &gPlayerEntity, 6, 12); + ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12); if (ret == 1 && gPlayerState.field_0xd != 16) { ret = 0; } diff --git a/src/object/button.c b/src/object/button.c index c1efa9ae..4c026baf 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -16,7 +16,7 @@ extern u32 sub_08081E3C(Entity*); void sub_08081AE0(Entity* this) { COLLISION_OFF(this); - this->updatePriority = 3; + this->updatePriority = PRIO_NO_BLOCK; this->y.HALF.HI++; if (this->cutsceneBeh.HWORD != 0) { this->collisionLayer = this->cutsceneBeh.HWORD; @@ -158,11 +158,11 @@ Entity* sub_08081D74(Entity* this) { } } else { if (gPlayerState.flags & 0x400000) { - if (sub_080041A0(this, gUnk_03004040[0], 5, 6)) { + if (EntityInRectRadius(this, gUnk_03004040[0], 5, 6)) { ent = gUnk_03004040[0]; - } else if (sub_080041A0(this, gUnk_03004040[1], 5, 6)) { + } else if (EntityInRectRadius(this, gUnk_03004040[1], 5, 6)) { ent = gUnk_03004040[1]; - } else if (sub_080041A0(this, gUnk_03004040[2], 5, 6)) { + } else if (EntityInRectRadius(this, gUnk_03004040[2], 5, 6)) { ent = gUnk_03004040[2]; } } @@ -176,7 +176,7 @@ u32 sub_08081E0C(Entity* this) { if (tmp->z.HALF.HI != 0 || !sub_08079F8C()) { return 0; } else { - return sub_080041A0(this, tmp, 5, 6); + return EntityInRectRadius(this, tmp, 5, 6); } } @@ -234,13 +234,13 @@ u32 sub_08081F00(u32* unk1, u32* unk2) { void sub_08081F24(Entity* this) { Entity* fx = CreateFx(this, FX_DASH, 0x40); if (fx) { - fx->updatePriority = 3; + fx->updatePriority = PRIO_NO_BLOCK; fx->x.HALF.HI += 7; fx->y.HALF.HI += 5; } fx = CreateFx(this, FX_DASH, 0x40); if (fx) { - fx->updatePriority = 3; + fx->updatePriority = PRIO_NO_BLOCK; fx->x.HALF.HI -= 7; fx->y.HALF.HI += 5; } @@ -252,7 +252,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) { return 1; if (--this->actionDelay > 6) { if (this->child) - this->child->spriteOffsetY = 0xfc; + this->child->spriteOffsetY = -4; } else { if (this->actionDelay == 6) { SetFlag(this->field_0x86.HWORD); diff --git a/src/object/cloud.c b/src/object/cloud.c index 8b53e550..d8915514 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -120,7 +120,7 @@ void sub_0809F69C(Entity* this) { void sub_0809F6CC(Entity* this) { if (((gRoomControls.unk6 & 4) == 0) && (--this->actionDelay == 0)) { - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; DeleteThisEntity(); } } diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index 0aca5575..e5575a47 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -469,7 +469,7 @@ void GreatFairy_InitializeAnimation(Entity* this) { this->type2 = this->type % temp; this->collisionLayer = 2; InitializeAnimation(this, this->type2); - SetDefaultPriority(this, 2); + SetDefaultPriority(this, PRIO_MESSAGE); } Entity* GreatFairy_CreateForm(Entity* this, u32 curForm, u32 parameter) { @@ -516,7 +516,7 @@ void sub_08087424(Entity* this, ScriptExecutionContext* context) { if (ent != NULL) { ent->parent = &gPlayerEntity; CopyPosition(&gPlayerEntity, ent); - SetDefaultPriority(ent, 2); + SetDefaultPriority(ent, PRIO_MESSAGE); } switch (context->intVariable) { diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c index 7664546c..b0fb32e1 100644 --- a/src/object/heartContainer.c +++ b/src/object/heartContainer.c @@ -31,7 +31,7 @@ static void sub_0808E6A0(Entity* this) { this->spriteSettings.draw = 0; this->hitbox = &gUnk_08121C58; this->collisionLayer = 3; - this->updatePriority = 3; + this->updatePriority = PRIO_NO_BLOCK; } static void sub_0808E6E4(Entity* this) { diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index ae4f133d..b9747788 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -27,7 +27,7 @@ static bool32 sub_080867CC(u32); void sub_0808681C(Entity*); static u8 sub_08086954(Entity*); -extern u32 sub_080562CC(u32, u32, u32, u32); +extern u32 CheckRegionOnScreen(u32, u32, u32, u32); extern void sub_08078AC0(u32, u32, u32); extern void (*const gUnk_081206B4[])(Entity*); @@ -46,14 +46,14 @@ void sub_080866D8(Entity* this) { this->action = 1; *((u32*)(&this->field_0x68)) = 0; this->field_0x6c.HALF.LO = this->actionDelay; - SetDefaultPriority(this, 6); + SetDefaultPriority(this, PRIO_PLAYER_EVENT); } prop = GetCurrentRoomProperty(this->field_0x6c.HALF.LO); for (i = 0; prop->unk0 != 0xFFFF && i < 32; prop++, i++) { int mask = 1 << i; if ((*((u32*)(&this->field_0x68)) & mask) == 0 && sub_080867CC(prop->unk5) && - sub_080562CC(prop->unk0, prop->unk2, 32, 32)) { + CheckRegionOnScreen(prop->unk0, prop->unk2, 32, 32)) { entity = CreateObject(HOUSE_DOOR_EXT, prop->unk7, prop->unk6); if (entity) { entity->field_0x6c.HALF.LO = i; @@ -85,7 +85,7 @@ static bool32 sub_080867CC(u32 arg0) { } void sub_080867E4(Entity* this) { - if (!sub_080562CC(this->field_0x68.HWORD, this->field_0x6a.HWORD, 32, 32)) { + if (!CheckRegionOnScreen(this->field_0x68.HWORD, this->field_0x6a.HWORD, 32, 32)) { *((u32*)(&this->parent->field_0x68)) = *((u32*)(&this->parent->field_0x68)) & ~(1 << this->field_0x6c.HALF.LO); DeleteThisEntity(); } diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index de9e52a0..2c025c77 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -120,7 +120,7 @@ void sub_08080F20(Entity* this) { this->field_0x6c.HWORD = 0; this->field_0x68.HALF.LO = 0; this->actionDelay = 0; - SetDefaultPriority(this, 3); + SetDefaultPriority(this, PRIO_NO_BLOCK); this->field_0x1c = sub_0808147C(this->type); gUnk_0811E7E8[this->field_0x68.HALF.HI](this); } else { @@ -338,7 +338,7 @@ void sub_08081404(Entity* this, u32 arg1) { bool32 sub_08081420(Entity* this) { if (CheckShouldPlayItemGetCutscene(this)) { - SetDefaultPriority(this, 6); + SetDefaultPriority(this, PRIO_PLAYER_EVENT); CreateItemEntity(this->type, this->type2, 0); return TRUE; } else { diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index b98ff330..ae74c9c8 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -34,7 +34,7 @@ void LilypadSmall(Entity* this) { u32 sub_08097ADC(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) { return 0; - } else if (sub_080041A0(this, &gPlayerEntity, 8, 8) == 0) { + } else if (EntityInRectRadius(this, &gPlayerEntity, 8, 8) == 0) { return 0; } else if (sub_08079F8C() == 0) { return 0; diff --git a/src/object/minecart.c b/src/object/minecart.c index 002c4946..fe333927 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -94,7 +94,7 @@ void sub_080917DC(Entity* this) { } void sub_080918A4(Entity* this) { - if (sub_080041A0(this, &gPlayerEntity, 2, 2) != 0) { + if (EntityInRectRadius(this, &gPlayerEntity, 2, 2) != 0) { gPlayerEntity.x.HALF.HI = this->x.HALF.HI; gPlayerEntity.y.HALF.HI = this->y.HALF.HI; if (gPlayerEntity.z.HALF.HI > -0x10) { diff --git a/src/object/minishSizedEntrance.c b/src/object/minishSizedEntrance.c index 4d7bc406..9338bca5 100644 --- a/src/object/minishSizedEntrance.c +++ b/src/object/minishSizedEntrance.c @@ -31,7 +31,7 @@ void sub_08090F00(Entity* this) { DeleteThisEntity(); } } - if ((gPlayerState.flags & PL_MINISH) && sub_080041A0(this, &gPlayerEntity, 4, 4) && + if ((gPlayerState.flags & PL_MINISH) && EntityInRectRadius(this, &gPlayerEntity, 4, 4) && (gPlayerEntity.z.HALF.HI == 0) && (((u16)gPlayerState.field_0x90.HALF.LO) & gUnk_0812225C[this->type2])) { DoExitTransition(GetCurrentRoomProperty(this->actionDelay)); } diff --git a/src/object/object1A.c b/src/object/object1A.c index e515a30b..7f76d0f7 100644 --- a/src/object/object1A.c +++ b/src/object/object1A.c @@ -55,6 +55,6 @@ void sub_08086A6C(Entity* ent) { uVar1 = Random(); ent->zVelocity = 163840; - ent->direction = (uVar1 >> 16) & 31; + ent->direction = DirectionNormalize(uVar1 >> 16); ent->speed = uVar1 & 480; } diff --git a/src/object/object86.c b/src/object/object86.c index 6829c813..147e623c 100644 --- a/src/object/object86.c +++ b/src/object/object86.c @@ -56,7 +56,7 @@ void sub_08099E58(Entity* this) { } void sub_08099E8C(Entity* this) { - if (sub_080041A0(this, &gPlayerEntity, 0xc, 0xc)) { + if (EntityInRectRadius(this, &gPlayerEntity, 0xc, 0xc)) { if (this->subAction == 0) { sub_08099ECC(this); RequestPriorityDuration(this, 0x1e); diff --git a/src/object/objectA2.c b/src/object/objectA2.c index de21a664..4bcfa284 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -40,7 +40,7 @@ void sub_0809F318(Entity* this) { this->spriteOrientation.flipY = 2; this->action = 1; sub_0801D2B4(this, gUnk_08124704[this->type]); - SetDefaultPriority(this, 7); + SetDefaultPriority(this, PRIO_HIGHEST); } void sub_0809F374(Entity* this) { diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c index a43d9552..58b2722b 100644 --- a/src/object/warpPoint.c +++ b/src/object/warpPoint.c @@ -41,7 +41,7 @@ void sub_0808B474(Entity* this) { this->palette.b.b0 = tmp; this->spritePriority.b0 = 6; this->hitbox = &gHitbox_1; - this->updatePriority = 3; + this->updatePriority = PRIO_NO_BLOCK; InitializeAnimation(this, 0); if (CheckFlags(this->field_0x86.HWORD)) { sub_0808B830(this); @@ -207,7 +207,7 @@ void sub_0808B73C(Entity* this) { u32 sub_0808B7C8(Entity* this) { if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.field_0xa8 != 0x12 && gPlayerEntity.health != 0 && - sub_08079F8C() && sub_080041A0(this, &gPlayerEntity, 5, 5) && gPlayerEntity.z.HALF.HI == 0) { + sub_08079F8C() && EntityInRectRadius(this, &gPlayerEntity, 5, 5) && gPlayerEntity.z.HALF.HI == 0) { if (this->actionDelay == 0 && gPlayerEntity.action == 0x1b) { sub_080791D0(); } diff --git a/src/overworld.c b/src/overworld.c index c529f530..a61a665f 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -637,7 +637,7 @@ static void HandleRoomEnter(void) { u32 sub_08052B24(void) { s32 tmp = 1; - if (!(gInput.heldKeys & SELECT_BUTTON) || gPlayerState.field_0x8b || gUnk_02034490[0] || gUnk_0200AF00.filler0[1]) + if (!(gInput.heldKeys & SELECT_BUTTON) || gPlayerState.controlMode != CONTROL_ENABLED || gUnk_02034490[0] || gUnk_0200AF00.filler0[1]) return 0; if ((gPlayerState.flags & 0x118) || (gPlayerState.field_0xa9 > tmp) || gPlayerState.field_0x2c || diff --git a/src/player.c b/src/player.c index 78b22379..a31d841c 100644 --- a/src/player.c +++ b/src/player.c @@ -11,18 +11,170 @@ #include "functions.h" #include "object.h" #include "effects.h" +#include "random.h" +#include "hitbox.h" -static void (*const sPlayerActions[])(Entity*); -extern void (*const gUnk_0811BA60[])(Entity*); -extern void (*const gUnk_0811BA68[])(Entity*); -extern void (*const gUnk_0811BA74[])(Entity*); -extern void (*const gUnk_0811BA7C[])(Entity*); -extern void (*const gUnk_0811BA88[])(Entity*); -extern void (*const gUnk_0811BA94[])(Entity*); -extern void (*const gUnk_0811BA9C[])(Entity*); -extern void (*const gUnk_0811BAD4[])(Entity*); -extern void (*const gUnk_0811BAE4[])(Entity*); -extern void (*const gUnk_0811BB3C[])(Entity*); +typedef void(EntityAction)(Entity*); + +static EntityAction* const sPlayerActions[]; + +static EntityAction PlayerInit; +static EntityAction PlayerNormal; +static EntityAction PlayerInit; +static EntityAction PlayerFall; +static EntityAction PlayerJump; +static EntityAction PlayerPush; +static EntityAction PlayerBounce; +static EntityAction sub_08070E9C; +static EntityAction PlayerItemGet; +EntityAction PlayerMinish; +static EntityAction PlayerMinishDie; +static EntityAction sub_08071DB8; +static EntityAction PlayerEmptyBottle; +static EntityAction PlayerFrozen; +static EntityAction sub_0807204C; +static EntityAction sub_080720DC; +static EntityAction PlayerPull; +static EntityAction PlayerLava; +EntityAction PlayerWarp; +static EntityAction sub_08072454; +static EntityAction PlayerDrown; +static EntityAction PlayerUsePortal; +static EntityAction PlayerTalkEzlo; +static EntityAction PlayerRoomTransition; +static EntityAction PlayerRoll; +static EntityAction sub_080728AC; +static EntityAction PlayerInHole; +static EntityAction sub_08072C9C; +EntityAction sub_08074C44; +static EntityAction sub_08072F34; +static EntityAction PlayerUseEntrance; +EntityAction PlayerParachute; + +// PLAYER_FALL +static EntityAction sub_08070C3C; +static EntityAction sub_08070CB4; + +// PLAYER_BOUNCE +static EntityAction sub_08070D38; +static EntityAction sub_08070DC4; +static EntityAction sub_08070E7C; + +// PLAYER_08070E9C +static EntityAction sub_08070EDC; +static EntityAction sub_08070f24; + +// PLAYER_ITEMGET +static EntityAction sub_08070FA4; +static EntityAction sub_08071020; +static EntityAction sub_08071038; + +// PLAYER_JUMP +static EntityAction sub_080710A8; +static EntityAction sub_08071130; +static EntityAction sub_08071208; + +// PLAYER_DROWN +static EntityAction sub_0807127C; +static EntityAction sub_080712F0; + +// PLAYER_USEPORTAL +static EntityAction PortalJumpOnUpdate; +static EntityAction PortalStandUpdate; +static EntityAction PortalActivateInit; +static EntityAction PortalActivateUpdate; +static EntityAction PortalShrinkInit; +static EntityAction PortalShrinkUpdate; +static EntityAction PortalEnterUpdate; +static EntityAction PortalUnknownUpdate; + +// PLAYER_TALKEZLO +static EntityAction sub_080718A0; +static EntityAction sub_0807193C; +static EntityAction sub_08071990; +static EntityAction sub_08071A4C; + +// PLAYER_PUSH +static EntityAction sub_08071AB0; +static EntityAction sub_08071AF0; +static EntityAction sub_08071B60; + +// PLAYER_MINISHDIE +static EntityAction sub_08071BDC; +static EntityAction sub_08071CAC; +static EntityAction sub_08071D04; +static EntityAction sub_08071D80; + +// PLAYER_08071DB8 +static EntityAction sub_08071DD0; +static EntityAction sub_08071E04; +static EntityAction sub_08071E74; + +// PLAYER_EMPTYBOTTLE +static EntityAction sub_08071EB0; +static EntityAction sub_08071F14; + +// PLAYER_FROZEN +static EntityAction sub_08071F50; +static EntityAction sub_08071F80; + +// PLAYER_0807204C +static EntityAction sub_08072064; +static EntityAction sub_08072098; + +// PLAYER_080720DC +static EntityAction sub_08072100; +static EntityAction sub_08072168; + +// PLAYER_PULL +static EntityAction sub_08072214; +static EntityAction sub_08072260; + +// PLAYER_LAVA +static EntityAction sub_080722DC; +static EntityAction sub_08072354; +static EntityAction sub_080723D0; +static EntityAction sub_0807240C; + +// PLAYER_08072454 +static EntityAction sub_0807246C; +static EntityAction sub_08072490; + +// PLAYER_ROOMTRANSITION +static EntityAction sub_080724DC; +static EntityAction sub_0807258C; + +// PLAYER_ROLL +static EntityAction sub_08072650; +static EntityAction sub_080726F4; + +// PLAYER_INHOLE +static EntityAction sub_08072970; +static EntityAction sub_08072A60; +static EntityAction sub_08072ACC; +static EntityAction sub_08072B5C; +static EntityAction sub_08072C48; + +// PLAYER_08072C9C +static EntityAction sub_08072CC0; +static EntityAction sub_08072CFC; +static EntityAction sub_08072D54; +static EntityAction sub_08072F14; + +// PLAYER_08072F34 +static EntityAction sub_08072F94; +static EntityAction sub_08073094; + +// PLAYER_USEENTRANCE +EntityAction sub_080731D8; +EntityAction sub_080732D0; +EntityAction sub_0807332C; +EntityAction sub_080733BC; + +static void sub_080717F8(Entity*); +static void ResetPlayerPriority(); +static void sub_080728AC(Entity*); +static void BreakOut(); extern void RespawnPlayer(); extern void sub_080797EC(); @@ -30,63 +182,73 @@ extern void sub_08079E08(); extern void sub_08078F60(); extern void sub_0806F948(); extern void sub_08077698(); -extern void SetPlayerEventPriority(); -extern void sub_080717F8(); -extern void ResetPlayerEventPriority(); -extern void sub_08071A6C(); extern void DisplayEzloMessage(); extern void sub_08079258(); -extern void sub_08071AF0(); -extern void sub_080728AC(); extern void sub_0807A298(); extern u32 sub_08079B24(); extern void sub_08079708(); extern void sub_080792D8(); extern Entity* CreatePlayerBomb(); -extern void sub_08072008(); extern void sub_080791BC(); -extern void sub_08072168(); extern u32 sub_0806F854(); extern u32 sub_08019840(); -extern void sub_08072260(); extern void sub_08079744(); extern void sub_0807AE20(); extern u32 sub_0807A894(); extern u32 sub_080797C4(); -extern u32 Random(); extern u32 sub_0807AC54(); extern void sub_0800892E(); extern void sub_08078F24(); extern void sub_0807B068(); extern u32 sub_080001DA(); -extern void sub_08072A60(); extern u32 sub_0807A2F8(); extern u32 CheckIsOverworld(); extern u32 sub_0806F730(); extern u32 sub_08007DD6(); extern u32 GetSurfaceCalcType(); -extern void sub_08073094(); extern void sub_08074808(); -extern void RequestPriorityDuration(); -typedef struct { - u8 frame; - u8 dummy; - u16 speed; -} PushFrames; - -extern PushFrames gUnk_0811BAF0[]; - -extern Hitbox gUnk_08114F88; extern ScreenTransitionData gUnk_0813AB58; void DoPlayerAction(Entity* this) { + static void (*const sPlayerActions[])(Entity*) = { + [PLAYER_INIT] = PlayerInit, + [PLAYER_NORMAL] = PlayerNormal, + [PLAYER_DUMMY] = PlayerInit, + [PLAYER_FALL] = PlayerFall, + [PLAYER_JUMP] = PlayerJump, + [PLAYER_PUSH] = PlayerPush, + [PLAYER_BOUNCE] = PlayerBounce, + [PLAYER_08070E9C] = sub_08070E9C, + [PLAYER_ITEMGET] = PlayerItemGet, + [PLAYER_MINISH] = PlayerMinish, + [PLAYER_MINISHDIE] = PlayerMinishDie, + [PLAYER_08071DB8] = sub_08071DB8, + [PLAYER_EMPTYBOTTLE] = PlayerEmptyBottle, + [PLAYER_FROZEN] = PlayerFrozen, + [PLAYER_0807204C] = sub_0807204C, + [PLAYER_080720DC] = sub_080720DC, + [PLAYER_PULL] = PlayerPull, + [PLAYER_LAVA] = PlayerLava, + [PLAYER_WARP] = PlayerWarp, + [PLAYER_08072454] = sub_08072454, + [PLAYER_DROWN] = PlayerDrown, + [PLAYER_USEPORTAL] = PlayerUsePortal, + [PLAYER_TALKEZLO] = PlayerTalkEzlo, + [PLAYER_ROOMTRANSITION] = PlayerRoomTransition, + [PLAYER_ROLL] = PlayerRoll, + [PLAYER_080728AC] = sub_080728AC, + [PLAYER_INHOLE] = PlayerInHole, + [PLAYER_08072C9C] = sub_08072C9C, + [PLAYER_08074C44] = sub_08074C44, + [PLAYER_08072F34] = sub_08072F34, + [PLAYER_USEENTRANCE] = PlayerUseEntrance, + [PLAYER_PARACHUTE] = PlayerParachute, + }; sPlayerActions[this->action](this); } -void PlayerInit(Entity* this) { - Entity* ent; - +static void PlayerInit(Entity* this) { gPlayerState.field_0x0[0] = 0xff; gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; @@ -97,10 +259,10 @@ void PlayerInit(Entity* this) { this->field_0x16 = 0x20; this->flags2 = 8; this->hitType = 0x79; - this->hitbox = &gUnk_08114F88; + this->hitbox = (Hitbox*)&gPlayerHitbox; this->spriteIndex = 1; #ifndef EU - gPlayerState.field_0x8 = 0x100; + gPlayerState.animation = 0x100; #endif sub_0806FDA0(this); LoadSwapGFX(this, 1, 2); @@ -119,6 +281,7 @@ void PlayerInit(Entity* this) { sub_0807921C(); sub_0807A1B8(); if (gPlayerState.swimState != 0) { + Entity* ent; gPlayerState.swimState = 1; sub_08079938(); gPlayerState.field_0xa8 = 7; @@ -132,9 +295,9 @@ void PlayerInit(Entity* this) { } // PlayerState.flags need to be 100% before this one can reasonably be done -ASM_FUNC("asm/non_matching/player/PlayerNormal.inc", void PlayerNormal(Entity* this)) +static ASM_FUNC("asm/non_matching/player/PlayerNormal.inc", void PlayerNormal(Entity* this)); -void sub_08070BEC(Entity* this, u32 r0) { +static void sub_08070BEC(Entity* this, u32 r0) { if (r0 & 1) sub_080797EC(); else @@ -144,28 +307,33 @@ void sub_08070BEC(Entity* this, u32 r0) { sub_08079E08(); } -void PlayerFall(Entity* this) { +static void PlayerFall(Entity* this) { + static EntityAction* const sPlayerFallStates[] = { + sub_08070C3C, + sub_08070CB4, + }; + gPlayerState.field_0xd = 0xFF; gPlayerState.pushedObject = 0x80; gPlayerState.field_0xa8 = 10; - gUnk_0811BA60[this->subAction](this); + sPlayerFallStates[this->subAction](this); } -void sub_08070C3C(Entity* this) { +static void sub_08070C3C(Entity* this) { sub_08004168(this); - gPlayerState.flags |= 0x1 | 0x4; - gPlayerState.flags &= ~0x400; + gPlayerState.flags |= PL_BUSY | PL_DROWNING; + gPlayerState.flags &= ~PL_BURNING; gPlayerState.jumpStatus = 0; if ((gPlayerState.flags & PL_MINISH) != 0) - gPlayerState.field_0x8 = 0x1ba; + gPlayerState.animation = 0x1ba; else if ((gPlayerState.flags & 8) != 0) - gPlayerState.field_0x8 = 0x458; + gPlayerState.animation = 0x458; else - gPlayerState.field_0x8 = 0x1b8; + gPlayerState.animation = 0x1b8; this->subAction++; COLLISION_OFF(this); @@ -176,14 +344,14 @@ void sub_08070C3C(Entity* this) { SoundReq(SFX_FALL_HOLE); } -void sub_08070CB4(Entity* this) { +static void sub_08070CB4(Entity* this) { UpdateAnimationSingleFrame(this); if ((this->frame & 0x80) != 0) { if ((gSave.stats.health != 0) && ((gPlayerState.flags & 0x8000) != 0)) { - gPlayerState.flags &= ~(0x1 | 0x4); + gPlayerState.flags &= ~(PL_BUSY | PL_DROWNING); this->spriteSettings.draw = 0; } else { - gPlayerState.flags &= ~(0x4 | 0x8000); + gPlayerState.flags &= ~(PL_DROWNING | 0x8000); RespawnPlayer(); gPlayerState.field_0xa = 0; this->iframes = 32; @@ -192,13 +360,18 @@ void sub_08070CB4(Entity* this) { } } -void PlayerBounce(Entity* this) { - gUnk_0811BA68[this->subAction](this); +static void PlayerBounce(Entity* this) { + static EntityAction* const sPlayerBounceStates[] = { + sub_08070D38, + sub_08070DC4, + sub_08070E7C, + }; + sPlayerBounceStates[this->subAction](this); } -void sub_08070D38(Entity* this) { +static void sub_08070D38(Entity* this) { COLLISION_OFF(this); - this->direction = ((this->animationState & 0xe) << 2) ^ 0x10; + this->direction = DirectionTurnAround(Direction8FromAnimationState(AnimationStateWalk(this->animationState))); this->speed = 0x100; this->knockbackDuration = 0; this->subAction++; @@ -207,10 +380,10 @@ void sub_08070D38(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) { this->zVelocity = 0x20000; - gPlayerState.field_0x8 = 0x114; + gPlayerState.animation = 0x114; sub_08080964(16, 0); } else { - gPlayerState.field_0x8 = 0xc18; + gPlayerState.animation = 0xc18; this->zVelocity = 0x18000; } @@ -221,7 +394,7 @@ void sub_08070D38(Entity* this) { } // minor regalloc -NONMATCH("asm/non_matching/player/sub_08070DC4.inc", void sub_08070DC4(Entity* this)) { +static NONMATCH("asm/non_matching/player/sub_08070DC4.inc", void sub_08070DC4(Entity* this)) { UpdateAnimationSingleFrame(this); sub_080085B0(this); sub_08079E08(); @@ -260,20 +433,23 @@ NONMATCH("asm/non_matching/player/sub_08070DC4.inc", void sub_08070DC4(Entity* t this->subAction++; if ((gPlayerState.flags & PL_MINISH) == 0) - gPlayerState.field_0x8 = 0x100; + gPlayerState.animation = 0x100; } END_NONMATCH -void sub_08070E7C(Entity* this) { - u8 timer = --this->actionDelay; - - if (timer == 0) { - gPlayerState.jumpStatus = timer; +static void sub_08070E7C(Entity* this) { + if (--this->actionDelay == 0) { + gPlayerState.jumpStatus = 0; sub_080791D0(); } } -void sub_08070E9C(Entity* this) { +static void sub_08070E9C(Entity* this) { + static EntityAction* const gUnk_0811BA74[] = { + sub_08070EDC, + sub_08070f24, + }; + if (sub_08078EFC() != 0) { MessageClose(); } else { @@ -284,8 +460,8 @@ void sub_08070E9C(Entity* this) { } } -void sub_08070EDC(Entity* this) { - this->updatePriority = 2; +static void sub_08070EDC(Entity* this) { + this->updatePriority = PRIO_MESSAGE; if ((gMessage.doTextBox & 0x7f) != 0) this->subAction = 1; @@ -293,10 +469,10 @@ void sub_08070EDC(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) sub_08079938(); else - gPlayerState.field_0x8 = 0xc18; + gPlayerState.animation = 0xc18; } -void sub_08070f24(Entity* this) { +static void sub_08070f24(Entity* this) { UpdateAnimationSingleFrame(this); if ((gMessage.doTextBox & 0x7f) == 0) { this->updatePriority = this->updatePriorityPrev; @@ -304,47 +480,52 @@ void sub_08070f24(Entity* this) { } } -void PlayerItemGet(Entity* this) { +static void PlayerItemGet(Entity* this) { + static EntityAction* const sPlayerItemGetStates[] = { + sub_08070FA4, + sub_08071020, + sub_08071038, + }; + Entity* child; - u8* temp; // todo: retype + u8* temp; gPlayerState.field_0xa8 = 0x15; COLLISION_OFF(this); - gUnk_0811BA7C[this->subAction](this); + sPlayerItemGetStates[this->subAction](this); child = this->child; if (child != NULL) { PositionEntityOnTop(this, child); temp = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex); - child->spriteOffsetX = *temp; + child->spriteOffsetX = temp[0]; child->spriteOffsetY = temp[1]; } } -void sub_08070FA4(Entity* this) { - u16 temp; - +static void sub_08070FA4(Entity* this) { this->spriteSettings.flipX = FALSE; - this->animationState = 4; + this->animationState = IdleSouth; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerState.jumpStatus = 0; if ((gPlayerState.flags & PL_MINISH) == 0) { - if (gPlayerState.flags & 0x8) { + u32 anim; + if (gPlayerState.flags & PL_NO_CAP) { if (sub_080542AC(gPlayerState.field_0x38)) { - temp = 0x45e; + anim = 0x45e; } else { - temp = 0x45b; + anim = 0x45b; } } else { if (sub_080542AC(gPlayerState.field_0x38)) { - temp = 0x2e0; + anim = 0x2e0; } else { - temp = 0x1b9; + anim = 0x1b9; } } - gPlayerState.field_0x8 = temp; + gPlayerState.animation = anim; } this->subAction = 1; @@ -352,21 +533,20 @@ void sub_08070FA4(Entity* this) { sub_08078F60(); } -void sub_08071020(Entity* this) { +static void sub_08071020(Entity* this) { UpdateAnimationSingleFrame(this); if (this->frame != 0) this->subAction = 2; } -void sub_08071038(Entity* this) { - +static void sub_08071038(Entity* this) { UpdateAnimationSingleFrame(this); if (sub_08078EFC() || (gMessage.doTextBox & 0x7f)) return; if (this->frame & 0x80) { - this->child = 0; + this->child = NULL; this->knockbackDuration = 0; this->iframes = 248; gPlayerState.jumpStatus = 0; @@ -374,18 +554,24 @@ void sub_08071038(Entity* this) { } } -void PlayerJump(Entity* this) { +static void PlayerJump(Entity* this) { + static EntityAction* const sPlayerJumpStates[] = { + sub_080710A8, + sub_08071130, + sub_08071208, + }; + gPlayerState.field_0xa8 = 0xb; - gUnk_0811BA88[this->subAction](this); + sPlayerJumpStates[this->subAction](this); } -void sub_080710A8(Entity* this) { +static void sub_080710A8(Entity* this) { u32 temp; this->subAction++; - gPlayerState.flags |= 1; - gPlayerState.flags &= ~(0x400 | 0x800); + gPlayerState.flags |= PL_BUSY; + gPlayerState.flags &= ~(PL_BURNING | 0x800); gPlayerState.playerAction = 0; @@ -393,16 +579,16 @@ void sub_080710A8(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) { ResetPlayer(); - if ((gPlayerState.flags & 0x8) != 0) { - gPlayerState.field_0x8 = 0x420; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x420; } else { - gPlayerState.field_0x8 = 0x810; + gPlayerState.animation = 0x810; } } } gPlayerState.field_0x1d[1] = 0; - this->direction = ((this->animationState & 0xe) << 2); + this->direction = Direction8FromAnimationState(AnimationStateWalk(this->animationState)); temp = sub_08079FC4(1); asm("lsl r0, r0, #0x4"); @@ -414,7 +600,7 @@ void sub_080710A8(Entity* this) { SoundReq(SFX_PLY_VO4); } -void sub_08071130(Entity* this) { +static void sub_08071130(Entity* this) { if (sub_08078EFC(this)) return; @@ -456,10 +642,10 @@ void sub_08071130(Entity* this) { this->actionDelay = 6; if (((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) && ((gPlayerState.flags & PL_MINISH) == 0)) { - if (gPlayerState.flags & 0x8) { - gPlayerState.field_0x8 = 0x424; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x424; } else { - gPlayerState.field_0x8 = 0x820; + gPlayerState.animation = 0x820; } this->animIndex = 0xff; } @@ -470,7 +656,7 @@ void sub_08071130(Entity* this) { SoundReq(SFX_PLY_LAND); } -void sub_08071208(Entity* this) { +static void sub_08071208(Entity* this) { if ((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) { if ((gPlayerState.flags & PL_MINISH) == 0) { UpdateAnimationSingleFrame(this); @@ -483,20 +669,25 @@ void sub_08071208(Entity* this) { } } -void PlayerDrown(Entity* this) { +static void PlayerDrown(Entity* this) { + static EntityAction* const sPlayerDrownStates[] = { + sub_0807127C, + sub_080712F0, + }; + gPlayerState.field_0xa8 = 0x16; - gPlayerState.flags |= 4; + gPlayerState.flags |= PL_DROWNING; COLLISION_OFF(this); - gUnk_0811BA94[this->subAction](this); + sPlayerDrownStates[this->subAction](this); } -void sub_0807127C(Entity* this) { +static void sub_0807127C(Entity* this) { this->subAction = 1; this->spritePriority.b1 = 0; if (gPlayerState.flags & PL_MINISH) { this->actionDelay = 0x3c; - gPlayerState.field_0x8 = 0xc19; + gPlayerState.animation = 0xc19; SoundReq(SFX_WATER_SPLASH); } else { if ((gPlayerState.flags & 0x10000) == 0) @@ -504,15 +695,15 @@ void sub_0807127C(Entity* this) { CreateFx(this, FX_WATER_SPLASH, 0); - if ((gPlayerState.flags & 8) == 0) - gPlayerState.field_0x8 = 0x72c; + if ((gPlayerState.flags & PL_NO_CAP) == 0) + gPlayerState.animation = 0x72c; else - gPlayerState.field_0x8 = 0x44c; + gPlayerState.animation = 0x44c; } ResetPlayer(); } -void sub_080712F0(Entity* this) { +static void sub_080712F0(Entity* this) { u32 temp; UpdateAnimationSingleFrame(this); @@ -524,7 +715,7 @@ void sub_080712F0(Entity* this) { temp = TRUE; } else if ((this->frame & 0x80) != 0) { if (this->animIndex != 0xce) - gPlayerState.field_0x8 = 0x2ce; + gPlayerState.animation = 0x2ce; else temp = TRUE; } @@ -541,17 +732,22 @@ void sub_080712F0(Entity* this) { } static void PlayerUsePortal(Entity* this) { + static EntityAction* const sPlayerUsePortalStates[] = { + PortalJumpOnUpdate, PortalStandUpdate, PortalActivateInit, PortalActivateUpdate, + PortalShrinkInit, PortalShrinkUpdate, PortalEnterUpdate, PortalUnknownUpdate, + }; + gPlayerState.field_0xa8 = 0xe; - gUnk_0811BA9C[this->subAction](this); + sPlayerUsePortalStates[this->subAction](this); // probably a switch if ((this->subAction == 7) || (this->subAction < 3)) return; - if ((gPlayerState.flags & 0x20) == 0) + if ((gPlayerState.flags & PL_USE_PORTAL) == 0) return; - if ((gInput.newKeys & (0x100 | 0x2)) == 0) + if ((gInput.newKeys & (B_BUTTON | R_BUTTON)) == 0) return; if (CheckIsDungeon() || gArea.curPortalType == 3) { @@ -564,7 +760,7 @@ static void PlayerUsePortal(Entity* this) { } } -void PortalJumpOnUpdate(Entity* this) { +static void PortalJumpOnUpdate(Entity* this) { u16 x; u16 y; @@ -584,12 +780,12 @@ void PortalJumpOnUpdate(Entity* this) { UpdateAnimationSingleFrame(this); if (gPlayerState.jumpStatus == 0) { - gPlayerState.flags |= 0x20; + gPlayerState.flags |= PL_USE_PORTAL; this->subAction = 1; - this->animationState = 4; + this->animationState = IdleSouth; this->spriteSettings.flipX = FALSE; if (gArea.curPortalType == 4) { - gPlayerState.field_0x8 = 0x52c; + gPlayerState.animation = 0x52c; } } @@ -600,7 +796,7 @@ void PortalJumpOnUpdate(Entity* this) { } } -void PortalStandUpdate(Entity* this) { +static void PortalStandUpdate(Entity* this) { switch (gArea.curPortalType) { case 4: case 5: @@ -614,14 +810,14 @@ void PortalStandUpdate(Entity* this) { } if (--this->actionDelay == 0xff) { this->direction = gPlayerState.field_0xd; - this->animationState = this->direction >> 2; + this->animationState = Direction8ToAnimationState(this->direction); this->zVelocity = 0x20000; this->speed = 256; this->action = 9; this->subAction = 7; this->field_0xf = 0; - gPlayerState.field_0x8 = (gPlayerState.flags & 8) ? 0x41C : 0x80C; - gPlayerState.flags &= ~0x20; + gPlayerState.animation = (gPlayerState.flags & PL_NO_CAP) ? 0x41C : 0x80C; + gPlayerState.flags &= ~PL_USE_PORTAL; return; } this->direction = gPlayerState.field_0xd; @@ -640,18 +836,18 @@ void PortalStandUpdate(Entity* this) { sub_08079938(); } -void PortalActivateInit(Entity* this) { +static void PortalActivateInit(Entity* this) { gRoomControls.cameraTarget = NULL; gUnk_02034490[0] = 1; this->subAction = 3; this->field_0xf = 0x1e; - gPlayerState.field_0x8 = 0x738; - CreateObjectWithParent(this, OBJECT_6, 1, 0); + gPlayerState.animation = 0x738; + CreateObjectWithParent(this, EZLO_CAP, 1, 0); sub_08077B20(); SetPlayerEventPriority(); } -void PortalActivateUpdate(Entity* this) { +static void PortalActivateUpdate(Entity* this) { if (this->field_0xf) return; @@ -661,7 +857,7 @@ void PortalActivateUpdate(Entity* this) { this->subAction = 4; } -void PortalShrinkInit(Entity* this) { +static void PortalShrinkInit(Entity* this) { this->subAction = 5; this->spritePriority.b1 = 0; this->field_0xf = 0; @@ -669,15 +865,19 @@ void PortalShrinkInit(Entity* this) { *(u32*)&this->field_0x80.HWORD = 0x100; *(u32*)&this->cutsceneBeh = 0x100; sub_0805EC9C(this, 0x100, 0x100, 0); - gPlayerState.field_0x8 = 0x2c3; + gPlayerState.animation = 0x2c3; gPlayerState.flags |= 0x80; SoundReq(SFX_PLY_SHRINKING); } -// horrible -ASM_FUNC("asm/non_matching/player/PortalShrinkUpdate.inc", void PortalShrinkUpdate(Entity* this)) +static const u8 gUnk_0811BABC[] = { + 1, 1, 1, 1, 2, 4, 8, 16, +}; -void PortalEnterUpdate(Entity* this) { +// horrible +static ASM_FUNC("asm/non_matching/player/PortalShrinkUpdate.inc", void PortalShrinkUpdate(Entity* this)); + +static void PortalEnterUpdate(Entity* this) { if (this->actionDelay == 0) { if (sub_08003FC4(this, 0x2000)) return; @@ -699,7 +899,7 @@ void PortalEnterUpdate(Entity* this) { this->actionDelay--; } -void PortalUnknownUpdate(Entity* this) { +static void PortalUnknownUpdate(Entity* this) { if (gFadeControl.active) return; @@ -712,40 +912,49 @@ void PortalUnknownUpdate(Entity* this) { sub_080500F4(0x10); } -extern s16 gUnk_0811BAC4[]; +static void sub_080717F8(Entity* this) { + static const s16 sOffsets[] = { + 0, -22, 22, 0, 0, 22, -22, 0, + }; -void sub_080717F8(Entity* this) { u32 x; u32 y; this->animationState = gArea.curPortalExitDirection << 1; - this->x.HALF.HI = gArea.curPortalX + gUnk_0811BAC4[gArea.curPortalExitDirection * 2]; - this->y.HALF.HI = gArea.curPortalY + gUnk_0811BAC4[gArea.curPortalExitDirection * 2 + 1]; + this->x.HALF.HI = gArea.curPortalX + sOffsets[gArea.curPortalExitDirection * 2]; + this->y.HALF.HI = gArea.curPortalY + sOffsets[gArea.curPortalExitDirection * 2 + 1]; gArea.unk1A = 0xb4; gUnk_02034490[0] = 0; this->action = 9; this->subAction = 0; - gPlayerState.flags = (gPlayerState.flags & ~0x20) | 0x80; + gPlayerState.flags = (gPlayerState.flags & ~PL_USE_PORTAL) | 0x80; sub_0805EC60(this); ResetPlayerEventPriority(); } -void PlayerTalkEzlo(Entity* this) { +static void PlayerTalkEzlo(Entity* this) { + static EntityAction* const sPlayerTalkEzloStates[] = { + sub_080718A0, + sub_0807193C, + sub_08071990, + sub_08071A4C, + }; + if (sub_08078EFC()) { MessageClose(); - sub_08071A6C(); + ResetPlayerPriority(); } else { gPlayerState.field_0xa8 = 0x13; COLLISION_OFF(this); - gUnk_0811BAD4[this->subAction](this); + sPlayerTalkEzloStates[this->subAction](this); } } -void sub_080718A0(Entity* this) { +static void sub_080718A0(Entity* this) { ResetPlayer(); gUnk_03000B80.filler[0x63] = 0; this->iframes = 0; - gPriorityHandler.sys_priority = 6; - this->updatePriority = 6; + gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT; + this->updatePriority = PRIO_PLAYER_EVENT; if (gPlayerState.flags & PL_MINISH) { this->subAction = 2; @@ -757,10 +966,10 @@ void sub_080718A0(Entity* this) { if (gPlayerState.jumpStatus == 0) { this->subAction++; - if (this->animationState == 2) - gPlayerState.field_0x8 = 0x3ca; + if (this->animationState == IdleEast) + gPlayerState.animation = 0x3ca; else - gPlayerState.field_0x8 = 0x3c6; + gPlayerState.animation = 0x3c6; this->spriteSettings.flipX = 0; return; @@ -770,37 +979,37 @@ void sub_080718A0(Entity* this) { gPlayerState.jumpStatus = 0; } -void sub_0807193C(Entity* this) { +static void sub_0807193C(Entity* this) { Entity* child; UpdateAnimationSingleFrame(this); if (this->frame & 0x80) { this->subAction++; - child = CreateObjectWithParent(this, OBJECT_6, 0, 0); + child = CreateObjectWithParent(this, EZLO_CAP, 0, 0); this->child = child; if (child != NULL) { - if (this->animationState == 2) - gPlayerState.field_0x8 = 0x3cc; + if (this->animationState == IdleEast) + gPlayerState.animation = 0x3cc; else - gPlayerState.field_0x8 = 0x3c7; + gPlayerState.animation = 0x3c7; DisplayEzloMessage(); } } } -void sub_08071990(Entity* this) { +static void sub_08071990(Entity* this) { u32 temp; if ((gMessage.doTextBox & 0x7f) == 0) { this->subAction++; if ((gPlayerState.flags & PL_MINISH) == 0) { - if (this->animationState == 2) - gPlayerState.field_0x8 = 0x3cd; + if (this->animationState == IdleEast) + gPlayerState.animation = 0x3cd; else - gPlayerState.field_0x8 = 0x3c9; + gPlayerState.animation = 0x3c9; } else { - sub_08071A6C(); + ResetPlayerPriority(); sub_08079258(); } return; @@ -809,48 +1018,54 @@ void sub_08071990(Entity* this) { if (gPlayerState.flags & PL_MINISH) return; - if (this->animationState == 2) + if (this->animationState == IdleEast) temp = 4; else temp = 0; if (this->child->actionDelay != 0) { if ((u8)(temp + 200) != this->animIndex) { - gPlayerState.field_0x8 = temp + 0x3c8; + gPlayerState.animation = temp + 0x3c8; return; } } else { if ((u8)(temp + 199) != this->animIndex) { - gPlayerState.field_0x8 = temp + 0x3c7; + gPlayerState.animation = temp + 0x3c7; return; } } UpdateAnimationSingleFrame(this); } -void sub_08071A4C(Entity* this) { +static void sub_08071A4C(Entity* this) { UpdateAnimationSingleFrame(this); if (this->frame & 0x80) { - sub_08071A6C(); + ResetPlayerPriority(); sub_0807921C(); } } -void sub_08071A6C(void) { +static void ResetPlayerPriority(void) { gPriorityHandler.sys_priority = 0; gPlayerEntity.updatePriority = gPlayerEntity.updatePriorityPrev; } -void PlayerPush(Entity* this) { +static void PlayerPush(Entity* this) { + static EntityAction* const sPlayerPushStates[] = { + sub_08071AB0, + sub_08071AF0, + sub_08071B60, + }; + gPlayerState.field_0xa8 = 0x19; - gUnk_0811BAE4[this->subAction](this); + sPlayerPushStates[this->subAction](this); } -void sub_08071AB0(Entity* this) { +static void sub_08071AB0(Entity* this) { u32 speed; this->subAction++; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; if (this->type == 1) { this->speed = 0; this->actionDelay = 0; @@ -861,14 +1076,23 @@ void sub_08071AB0(Entity* this) { sub_08071AF0(this); } -void sub_08071AF0(Entity* this) { +static void sub_08071AF0(Entity* this) { + typedef struct { + u8 frame; + u16 speed; + } PushFrame; + + static const PushFrame sPushFrames[] = { { 5, 0x0 }, { 1, 0x100 }, { 5, 0x0 }, { 1, 0x100 }, { 2, 0x0 }, + { 1, 0x100 }, { 2, 0x0 }, { 1, 0x100 }, { 3, 0x0 }, { 1, 0x100 }, + { 8, 0x60 }, { 8, 0x60 }, { 8, 0x60 }, { 8, 0x40 }, { 0xFF, 0x0 } }; + gPlayerState.field_0x80 = 0; UpdateAnimationSingleFrame(this); if (this->type == 1) { if (--this->field_0xf == 0) { - if (gUnk_0811BAF0[this->actionDelay].frame != 0xff) { - this->field_0xf = gUnk_0811BAF0[this->actionDelay].frame; - this->speed = gUnk_0811BAF0[this->actionDelay].speed; + if (sPushFrames[this->actionDelay].frame != 0xff) { + this->field_0xf = sPushFrames[this->actionDelay].frame; + this->speed = sPushFrames[this->actionDelay].speed; this->actionDelay++; } else { this->subAction++; @@ -884,7 +1108,7 @@ void sub_08071AF0(Entity* this) { sub_08079E08(); } -void sub_08071B60(Entity* this) { +static void sub_08071B60(Entity* this) { gPlayerState.pushedObject = 2; gPlayerState.flags &= ~0x1; this->type = 0; @@ -892,31 +1116,36 @@ void sub_08071B60(Entity* this) { sub_080728AC(this); this->field_0xf = 6; if ((gPlayerState.flags & PL_MINISH) == 0) { - gPlayerState.field_0x8 = 0x104; + gPlayerState.animation = 0x104; this->spriteIndex = 3; InitAnimationForceUpdate(this, (this->animationState >> 1) + 0x3c); } } -extern void (*const gUnk_0811BB2C[])(Entity*); +static void PlayerMinishDie(Entity* this) { + static EntityAction* const sPlayerMinishDieStates[] = { + sub_08071BDC, + sub_08071CAC, + sub_08071D04, + sub_08071D80, + }; -void PlayerMinishDie(Entity* this) { COLLISION_OFF(this); - gUnk_0811BB2C[this->subAction](this); + sPlayerMinishDieStates[this->subAction](this); gPlayerState.field_0xa8 = 0x12; } -void sub_08071BDC(Entity* this) { +static void sub_08071BDC(Entity* this) { u32 temp; if (gPlayerState.flags & (0x10 | 0x100)) return; if (sub_08003FC4(this, 0x2000)) { - if ((gPlayerState.flags & 8) != 0) - gPlayerState.field_0x8 = 0x420; + if (gPlayerState.flags & PL_NO_CAP) + gPlayerState.animation = 0x420; else - gPlayerState.field_0x8 = 0x810; + gPlayerState.animation = 0x810; return; } @@ -931,11 +1160,11 @@ void sub_08071BDC(Entity* this) { } else { temp = (gPlayerState.flags & 8) ? 0x459 : 0x1bc; } - gPlayerState.field_0x8 = temp; + gPlayerState.animation = temp; - gPlayerState.flags &= ~(0x1000000 | 0x200000 | 0x40000 | 0x800 | 0x400 | 0x100 | 0x1); + gPlayerState.flags &= ~(0x1000000 | 0x200000 | 0x40000 | 0x800 | 0x400 | 0x100 | PL_BUSY); this->subAction = 1; - this->animationState = 4; + this->animationState = IdleSouth; this->spritePriority.b1 = 1; this->spriteSettings.draw = 3; gPlayerState.jumpStatus = 0; @@ -945,7 +1174,7 @@ void sub_08071BDC(Entity* this) { SoundReq(SFX_PLY_DIE); } -void sub_08071CAC(Entity* this) { +static void sub_08071CAC(Entity* this) { UpdateAnimationSingleFrame(this); if (this->frame & 0x80) { u32 temp; @@ -953,7 +1182,7 @@ void sub_08071CAC(Entity* this) { temp = (gPlayerState.flags & 8) ? 0x45a : 0x2bd; else temp = 0xc1b; - gPlayerState.field_0x8 = temp; + gPlayerState.animation = temp; this->subAction = 2; this->actionDelay = 0xf0; @@ -961,7 +1190,7 @@ void sub_08071CAC(Entity* this) { } } -void sub_08071D04(Entity* this) { +static void sub_08071D04(Entity* this) { int idx; int deltaHealth; @@ -992,7 +1221,7 @@ void sub_08071D04(Entity* this) { gScreenTransition.field_0x4[1] = 1; } -void sub_08071D80(Entity* this) { +static void sub_08071D80(Entity* this) { UpdateAnimationSingleFrame(this); gPlayerState.field_0x14 = 1; sub_08073904(this); @@ -1004,23 +1233,29 @@ void sub_08071D80(Entity* this) { } } -void sub_08071DB8(Entity* this) { +static void sub_08071DB8(Entity* this) { + static EntityAction* const gUnk_0811BB3C[] = { + sub_08071DD0, + sub_08071E04, + sub_08071E74, + }; + gUnk_0811BB3C[this->subAction](this); } -void sub_08071DD0(Entity* this) { +static void sub_08071DD0(Entity* this) { this->actionDelay = gPlayerState.field_0x38; if (gPlayerState.field_0x39 != 0) { gPlayerState.field_0x39 = 0; this->subAction = 2; - gPlayerState.field_0x8 = 0x100; + gPlayerState.animation = 0x100; } else { this->subAction = 1; - gPlayerState.field_0x8 = 0x114; + gPlayerState.animation = 0x114; } } -void sub_08071E04(Entity* this) { +static void sub_08071E04(Entity* this) { if ((this->z.WORD != 0) && (gPlayerState.field_0x14 == '\0')) { sub_0807A1B8(); if (gPlayerState.field_0x10[2] == 1) { @@ -1047,7 +1282,7 @@ void sub_08071E04(Entity* this) { sub_080791BC(); } -void sub_08071E74(Entity* this) { +static void sub_08071E74(Entity* this) { u32 temp; sub_08003FC4(this, 0x2000); @@ -1057,13 +1292,16 @@ void sub_08071E74(Entity* this) { sub_080791BC(); } -extern void (*const gUnk_0811BB48[])(Entity*); +static void PlayerEmptyBottle(Entity* this) { + static EntityAction* const sPlayerEmptyBottleStates[] = { + sub_08071EB0, + sub_08071F14, + }; -void PlayerEmptyBottle(Entity* this) { - gUnk_0811BB48[this->subAction](this); + sPlayerEmptyBottleStates[this->subAction](this); } -void sub_08071EB0(Entity* this) { +static void sub_08071EB0(Entity* this) { Entity* ent; ResetPlayer(); @@ -1073,20 +1311,20 @@ void sub_08071EB0(Entity* this) { this->subAction++; switch (gPlayerState.field_0x38) { case 0x20: - gPlayerState.field_0x8 = 0x614; + gPlayerState.animation = 0x614; break; case 0x21 ... 0x25: - gPlayerState.field_0x8 = 0x2df; + gPlayerState.animation = 0x2df; break; default: - gPlayerState.field_0x8 = 0x610; + gPlayerState.animation = 0x610; sub_0807CAA0(gPlayerState.field_0x38, 2); break; } } } -void sub_08071F14(Entity* this) { +static void sub_08071F14(Entity* this) { UpdateAnimationSingleFrame(this); if (this->frame & 0x80) { gPlayerState.field_0x2c = NULL; @@ -1094,28 +1332,31 @@ void sub_08071F14(Entity* this) { } } -extern void (*const gUnk_0811BB50[])(Entity*); +static void PlayerFrozen(Entity* this) { + static EntityAction* const sPlayerFrozenStates[] = { + sub_08071F50, + sub_08071F80, + }; -void PlayerFrozen(Entity* this) { - gUnk_0811BB50[this->subAction](this); + sPlayerFrozenStates[this->subAction](this); } -void sub_08071F50(Entity* this) { +static void sub_08071F50(Entity* this) { COLLISION_OFF(this); - this->actionDelay = 0x78; + this->actionDelay = 120; this->subAction++; - gPlayerState.field_0x8 = 0x294; + gPlayerState.animation = 0x294; sub_08077B20(); SoundReq(SFX_195); } -void sub_08071F80(Entity* this) { +static void sub_08071F80(Entity* this) { if (sub_08003FC4(this, 0x2000) == 0) { UpdateSpriteForCollisionLayer(this); gPlayerState.jumpStatus = 0; if (gPlayerState.field_0x14 == 0) { if (sub_08079D48() == 0) { - sub_08072008(this); + BreakOut(this); return; } } @@ -1135,34 +1376,37 @@ void sub_08071F80(Entity* this) { } } } - sub_08072008(this); + BreakOut(this); } -void sub_08072008(Entity* this) { +static void BreakOut(Entity* this) { this->iframes = 160; this->knockbackDuration = 0; COLLISION_ON(this); this->spriteOffsetX = 0; - gPlayerState.flags &= ~(0x800 | 0x1); + gPlayerState.flags &= ~(0x800 | PL_BUSY); CreateFx(this, FX_ICE, 0); sub_080791BC(); } -extern void (*const gUnk_0811BB58[])(Entity*); +static void sub_0807204C(Entity* this) { + static EntityAction* const gUnk_0811BB58[] = { + sub_08072064, + sub_08072098, + }; -void sub_0807204C(Entity* this) { gUnk_0811BB58[this->subAction](this); } -void sub_08072064(Entity* this) { +static void sub_08072064(Entity* this) { this->subAction = 1; COLLISION_OFF(this); this->actionDelay = gPlayerState.field_0x3a; - gPlayerState.field_0x8 = gPlayerState.field_0x38 | (gPlayerState.field_0x39 << 8); + gPlayerState.animation = gPlayerState.field_0x38 | (gPlayerState.field_0x39 << 8); ResetPlayer(); } -void sub_08072098(Entity* this) { +static void sub_08072098(Entity* this) { UpdateAnimationSingleFrame(this); if (this->actionDelay != 0) if (--this->actionDelay != 0xFF) @@ -1177,33 +1421,36 @@ void sub_08072098(Entity* this) { sub_080791BC(); } -extern void (*const gUnk_0811BB60[])(Entity*); +static void sub_080720DC(Entity* this) { + static EntityAction* const gUnk_0811BB60[] = { + sub_08072100, + sub_08072168, + }; -void sub_080720DC(Entity* this) { if (sub_08078EFC() == 0) gUnk_0811BB60[this->subAction](this); } -void sub_08072100(Entity* this) { +static void sub_08072100(Entity* this) { this->spriteSettings.draw = 3; this->speed = 0x140; - this->hitbox = &gUnk_08114F88; + this->hitbox = (Hitbox*)&gPlayerHitbox; this->actionDelay = gPlayerState.field_0x38; this->subAction = 1; COLLISION_OFF(this); if (gPlayerState.field_0x39) this->direction = 0xff; - if ((gPlayerState.flags & 8)) { - gPlayerState.field_0x8 = 0x404; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x404; } else { - gPlayerState.field_0x8 = 0x104; + gPlayerState.animation = 0x104; } ResetPlayer(); sub_08072168(this); } -void sub_08072168(Entity* this) { +static void sub_08072168(Entity* this) { u32 i; UpdateAnimationSingleFrame(this); @@ -1224,75 +1471,83 @@ void sub_08072168(Entity* this) { } } -extern void (*const gUnk_0811BB68[])(Entity*); +static void PlayerPull(Entity* this) { + static EntityAction* const sPlayerPullStates[] = { + sub_08072214, + sub_08072260, + }; -void PlayerPull(Entity* this) { gPlayerState.field_0xa8 = 0x1a; - gUnk_0811BB68[this->subAction](this); + sPlayerPullStates[this->subAction](this); gUnk_0200AF00.filler25[9] = 8; } -void sub_08072214(Entity* this) { +static void sub_08072214(Entity* this) { this->subAction = 1; this->speed = 128; this->actionDelay = gPlayerState.field_0x38; - this->direction = (this->animationState ^ 4) << 2; - if (!(gPlayerState.flags & 8)) { - gPlayerState.field_0x8 = 0x34c; + this->direction = Direction8FromAnimationState(AnimationStateTurnAround(this->animationState)); + if ((gPlayerState.flags & PL_NO_CAP) == 0) { + gPlayerState.animation = 0x34c; } else { - gPlayerState.field_0x8 = 0x944; + gPlayerState.animation = 0x944; } - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; sub_08072260(this); } -void sub_08072260(Entity* this) { +static void sub_08072260(Entity* this) { gPlayerState.field_0x80 = 0; sub_08079E08(); UpdateAnimationSingleFrame(this); if (--this->actionDelay == 0) { - gPlayerState.flags &= ~0x1; - if (!(gPlayerState.flags & 8)) { - gPlayerState.field_0x8 = 0x34c; + gPlayerState.flags &= ~PL_BUSY; + if ((gPlayerState.flags & PL_NO_CAP) == 0) { + gPlayerState.animation = 0x34c; } else { - gPlayerState.field_0x8 = 0x944; + gPlayerState.animation = 0x944; } this->knockbackDuration = 0; sub_080791BC(); } } -extern void (*const gUnk_0811BB70[])(Entity*); +static void PlayerLava(Entity* this) { + static EntityAction* const sPlayerLavaStates[] = { + sub_080722DC, + sub_08072354, + sub_080723D0, + sub_0807240C, + }; -void PlayerLava(Entity* this) { gPlayerState.field_0xa8 = 10; - gUnk_0811BB70[this->subAction](this); + sPlayerLavaStates[this->subAction](this); } -void sub_080722DC(Entity* this) { +static void sub_080722DC(Entity* this) { Entity* ent; COLLISION_OFF(this); - if (!(gPlayerState.flags & PL_MINISH)) { + if ((gPlayerState.flags & PL_MINISH) == 0) { this->subAction = 1; this->zVelocity = 0x28000; ent = CreateObject(OBJECT_42, 0x80, 0); if (ent != NULL) { ent->child = this; } - gPlayerState.field_0x8 = 0x114; + gPlayerState.animation = 0x114; } else { this->spriteSettings.draw = 0; this->subAction = 3; this->knockbackDuration = 10; } - gPlayerState.flags |= (0x400 | 0x1); + gPlayerState.flags |= (PL_BURNING | PL_BUSY); ResetPlayer(); SoundReq(SFX_124); SoundReq(SFX_PLY_VO6); } -void sub_08072354(Entity* this) { +static void sub_08072354(Entity* this) { sub_0806F854(this, 0, -12); UpdateAnimationSingleFrame(this); sub_08079744(this); @@ -1303,47 +1558,50 @@ void sub_08072354(Entity* this) { this->knockbackDuration = 0; this->subAction = 2; this->actionDelay = 0x3c; - gPlayerState.field_0x8 = 0x2c1; - gPlayerState.flags &= ~0x400; + gPlayerState.animation = 0x2c1; + gPlayerState.flags &= ~PL_BURNING; UpdateSpriteForCollisionLayer(this); CreateFx(this, FX_LAVA_SPLASH, 0); SoundReq(SFX_1A6); } -void sub_080723D0(Entity* this) { +static void sub_080723D0(Entity* this) { UpdateAnimationSingleFrame(this); if (--this->actionDelay == 0xff) { this->spritePriority.b1 = 1; - this->iframes = 0x14; + this->iframes = 20; ModHealth(-2); RespawnPlayer(); } } -void sub_0807240C(Entity* this) { +static void sub_0807240C(Entity* this) { if (--this->knockbackDuration == 0xff) { this->spriteSettings.draw = 3; - this->iframes = 0x14; - gPlayerState.flags &= ~0x400; + this->iframes = 20; + gPlayerState.flags &= ~PL_BURNING; ModHealth(-2); RespawnPlayer(); } } -extern void (*const gUnk_0811BB80[])(Entity*); +static void sub_08072454(Entity* this) { + static EntityAction* const gUnk_0811BB80[] = { + sub_0807246C, + sub_08072490, + }; -void sub_08072454(Entity* this) { gUnk_0811BB80[this->subAction](this); } -void sub_0807246C(Entity* this) { +static void sub_0807246C(Entity* this) { this->subAction = 1; this->actionDelay = gPlayerState.field_0x38; - gPlayerState.field_0x8 = 0x3c0; + gPlayerState.animation = 0x3c0; SoundReq(0x7b); } -void sub_08072490(Entity* this) { +static void sub_08072490(Entity* this) { if (--this->actionDelay != 0xff) { UpdateAnimationSingleFrame(this); sub_08079E08(); @@ -1354,13 +1612,15 @@ void sub_08072490(Entity* this) { } } -extern void (*const gUnk_0811BB88[])(Entity*); - -void PlayerRoomTransition(Entity* this) { - gUnk_0811BB88[this->subAction](this); +static void PlayerRoomTransition(Entity* this) { + static EntityAction* const sPlayerRoomTransitionStates[] = { + sub_080724DC, + sub_0807258C, + }; + sPlayerRoomTransitionStates[this->subAction](this); } -void sub_080724DC(Entity* this) { +static void sub_080724DC(Entity* this) { this->knockbackDuration = 0; sub_0807A108(); if (sub_080002B8(this) != 0x29) { @@ -1378,16 +1638,16 @@ void sub_080724DC(Entity* this) { this->subAction = 1; if (gRoomVars.field_0x0 == 0) { if (gPlayerState.flags & PL_MINISH) { - gPlayerState.field_0x8 = 0xc18; + gPlayerState.animation = 0xc18; } else { - gPlayerState.field_0x8 = 0x104; + gPlayerState.animation = 0x104; } - this->direction = this->animationState << 2; + this->direction = Direction8FromAnimationState(this->animationState); } } } -void sub_0807258C(Entity* this) { +static void sub_0807258C(Entity* this) { if (gRoomControls.unk2 == 0) { if (sub_0807A894(this) == 0x29) { sub_08079E08(); @@ -1411,14 +1671,17 @@ void sub_0807258C(Entity* this) { } } -extern void (*const gUnk_0811BB90[])(Entity*); +static void PlayerRoll(Entity* this) { + static EntityAction* const sPlayerRollStates[] = { + sub_08072650, + sub_080726F4, + }; -void PlayerRoll(Entity* this) { gPlayerState.field_0xa8 = 9; - gUnk_0811BB90[this->subAction](this); + sPlayerRollStates[this->subAction](this); } -void sub_08072650(Entity* this) { +static void sub_08072650(Entity* this) { u32 temp; if ((gPlayerState.flags & 0x200000) == 0) { @@ -1431,16 +1694,16 @@ void sub_08072650(Entity* this) { temp = gPlayerState.flags; if (gPlayerState.flags & PL_MINISH) { this->spritePriority.b1 = 0; - gPlayerState.field_0x8 = 0xc08; + gPlayerState.animation = 0xc08; } else { this->hurtType = 0x1e; if (temp & 8) { - gPlayerState.field_0x8 = 0x438; + gPlayerState.animation = 0x438; } else { - gPlayerState.field_0x8 = 0x2ac; + gPlayerState.animation = 0x2ac; } } - gPlayerState.flags |= 0x40000; + gPlayerState.flags |= PL_ROLLING; if (Random() & 1) { SoundReq(SFX_PLY_VO5); } else { @@ -1449,16 +1712,16 @@ void sub_08072650(Entity* this) { SoundReq(SFX_7E); } -void sub_080726F4(Entity* this) { - if (((gPlayerState.flags & (0x40000 | 0x80000)) != 0x40000) || +static void sub_080726F4(Entity* this) { + if (((gPlayerState.flags & (PL_ROLLING | 0x80000)) != PL_ROLLING) || (!(gPlayerState.flags & 0x200000) && (this->iframes != 0) && (this->bitfield & 0x80))) { - gPlayerState.flags &= ~0x40000; + gPlayerState.flags &= ~PL_ROLLING; if (!sub_08078EFC()) sub_080728AC(this); return; } - this->direction = (this->animationState & 6) << 2; + this->direction = Direction8FromAnimationState(AnimationStateIdle(this->animationState)); if (((gPlayerState.flags & PL_MINISH) == 0) && (--this->actionDelay == 0xff)) { CreateFx(&gPlayerEntity, FX_DASH, 0x40); this->actionDelay = 4; @@ -1467,12 +1730,12 @@ void sub_080726F4(Entity* this) { sub_0807A1B8(); } if (sub_08078EFC()) { - gPlayerState.flags &= ~0x40000; + gPlayerState.flags &= ~PL_ROLLING; return; } if ((gPlayerState.flags & 0x80000) != 0) { - gPlayerState.flags &= ~0x40000; + gPlayerState.flags &= ~PL_ROLLING; return; } @@ -1480,8 +1743,8 @@ void sub_080726F4(Entity* this) { return; } - if (gPlayerState.flags & 0x250) { - gPlayerState.flags &= ~0x40000; + if (gPlayerState.flags & (0x200 | 0x40 | 0x10)) { + gPlayerState.flags &= ~PL_ROLLING; sub_080728AC(this); return; } @@ -1518,12 +1781,12 @@ void sub_080726F4(Entity* this) { sub_080791D0(); } if ((this->frame & 0x80) != 0) { - gPlayerState.flags &= ~(0x200000 | 0x40000); + gPlayerState.flags &= ~(0x200000 | PL_ROLLING); } UpdateAnimationSingleFrame(this); } -void sub_080728AC(Entity* this) { +static void sub_080728AC(Entity* this) { sub_08079938(); if (gPlayerState.flags & PL_MINISH) sub_0807B068(this); @@ -1547,14 +1810,16 @@ void sub_080728AC(Entity* this) { } } -extern void (*const gUnk_0811BB98[])(Entity*); +static void PlayerInHole(Entity* this) { + static EntityAction* const sPlayerInHoleStates[] = { + sub_08072970, sub_08072A60, sub_08072ACC, sub_08072B5C, sub_08072C48, + }; -void PlayerInHole(Entity* this) { gPlayerState.field_0xa8 = 0x17; - gUnk_0811BB98[this->subAction](this); + sPlayerInHoleStates[this->subAction](this); } -void sub_08072970(Entity* this) { +static void sub_08072970(Entity* this) { if (this->health != 0) { this->subAction = 1; this->x.HALF.HI = (this->x.HALF.HI & ~0xF) | 8; @@ -1563,11 +1828,11 @@ void sub_08072970(Entity* this) { this->spritePriority.b0 = 7; this->spritePriority.b1 = 0; this->actionDelay = 0; - gPlayerState.flags |= 0x100000; - if (gPlayerState.flags & 8) { - gPlayerState.field_0x8 = 0x950; + gPlayerState.flags |= PL_IN_HOLE; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x950; } else { - gPlayerState.field_0x8 = 0x61c; + gPlayerState.animation = 0x61c; if (sub_080001DA(COORD_TO_TILE(this), this->collisionLayer) == 0x4020) { this->actionDelay = 1; } @@ -1579,47 +1844,47 @@ void sub_08072970(Entity* this) { } } -void sub_08072A60(Entity* this) { +static void sub_08072A60(Entity* this) { if (this->frame & 0x80) { if (this->actionDelay == 1) { this->subAction = 3; this->actionDelay = 0x28; this->spritePriority.b1 = 1; - gPlayerState.field_0x8 = 0x624; + gPlayerState.animation = 0x624; return; } this->subAction = 2; - if (gPlayerState.flags & 8) { - gPlayerState.field_0x8 = 0x954; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x954; } else { - gPlayerState.field_0x8 = 0x620; + gPlayerState.animation = 0x620; } } else { UpdateAnimationSingleFrame(this); } } -void sub_08072ACC(Entity* this) { +static void sub_08072ACC(Entity* this) { if (gPlayerState.field_0xd == 0xff) { this->field_0xf = 0; } else if (this->field_0xf > 7) { COLLISION_ON(this); this->direction = gPlayerState.field_0xd; this->zVelocity = 0x1a000; - this->speed = 0x78; + this->speed = 120; this->spritePriority.b0 = 4; this->spritePriority.b1 = 1; gPlayerState.jumpStatus = 0x41; sub_0807921C(); sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer); } else { - this->animationState = gPlayerState.field_0xd >> 2; + this->animationState = Direction8ToAnimationState(gPlayerState.field_0xd); this->field_0xf++; } } -void sub_08072B5C(Entity* this) { +static void sub_08072B5C(Entity* this) { u32 temp; sub_080042BA(this, ((0x28 - this->actionDelay) >> 4) + 1); @@ -1630,7 +1895,7 @@ void sub_08072B5C(Entity* this) { } SetTile(0x4021, COORD_TO_TILE(this), this->collisionLayer); - this->direction = this->animationState << 2; + this->direction = Direction8FromAnimationState(this->animationState); temp = sub_0807A2F8(1); if (!temp) { COLLISION_ON(this); @@ -1653,11 +1918,11 @@ void sub_08072B5C(Entity* this) { temp <<= 12; this->zVelocity = temp; this->speed = 0x100; - gPlayerState.field_0x8 = 0x810; + gPlayerState.animation = 0x810; SoundReq(0x7c); } -void sub_08072C48(Entity* this) { +static void sub_08072C48(Entity* this) { UpdateAnimationSingleFrame(this); sub_0806F69C(this); if (sub_08003FC4(this, 0x2000)) @@ -1676,24 +1941,28 @@ void sub_08072C48(Entity* this) { } } -extern void (*const gUnk_0811BBAC[])(Entity*); - -void sub_08072C9C(Entity* this) { +static void sub_08072C9C(Entity* this) { + static EntityAction* const gUnk_0811BBAC[] = { + sub_08072CC0, + sub_08072CFC, + sub_08072D54, + sub_08072F14, + }; gPlayerState.field_0xa8 = 0x11; gUnk_0811BBAC[this->subAction](this); } -void sub_08072CC0(Entity* this) { +static void sub_08072CC0(Entity* this) { this->subAction = 1; COLLISION_OFF(this); this->field_0xf = (gPlayerState.field_0x3a >> 2) + 1; this->direction = gPlayerState.field_0x39; this->speed = 0x400; - gPlayerState.field_0x8 = 0x524; + gPlayerState.animation = 0x524; gPlayerState.heldObject = 0; } -void sub_08072CFC(Entity* this) { +static void sub_08072CFC(Entity* this) { sub_080042BA(this, 2); if (--this->field_0xf != 0xff) { sub_0806F69C(this); @@ -1706,15 +1975,24 @@ void sub_08072CFC(Entity* this) { } this->zVelocity = gPlayerState.field_0x38 << 0xc; this->speed = 0x200; - gPlayerState.field_0x8 = 0x810; + gPlayerState.animation = 0x810; this->actionDelay = 5; this->field_0xf = 0; ResetPlayer(); } -extern const u16* gUnk_0811BBD4[]; +static const u16 sTiles[] = { + 0x1AD, 1, 0, 0x1AE, 1, 0, 0x1AC, 1, 0, 0x1AF, 1, 0, +}; -NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* this)) { +static const u16* const sTileTable[] = { + sTiles, + sTiles + 3, + sTiles + 6, + sTiles + 9, +}; + +static NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* this)) { u32 bVar1; u32 uVar2; u32 iVar3; @@ -1728,13 +2006,13 @@ NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* t uVar2 = GetTileType(uVar2, this->collisionLayer); switch (this->field_0xf) { case 0: - if (sub_08007DD6(uVar2, gUnk_0811BBD4[gPlayerEntity.animationState >> 1])) { + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1])) { this->actionDelay = 1; this->field_0xf = 1; } break; case 1: - if (sub_08007DD6(uVar2, gUnk_0811BBD4[gPlayerEntity.animationState >> 1])) { + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1])) { this->actionDelay = 1; this->field_0xf = 1; } @@ -1748,14 +2026,14 @@ NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* t break; case 2: this->animationState ^= 4; - if (sub_08007DD6(uVar2, gUnk_0811BBD4[gPlayerEntity.animationState >> 1]) != 0) { + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1]) != 0) { this->actionDelay = 1; this->field_0xf = 3; } break; default: this->animationState ^= 4; - if (sub_08007DD6(uVar2, gUnk_0811BBD4[gPlayerEntity.animationState >> 1])) { + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1])) { this->field_0xf = 4; } else { this->actionDelay = 1; @@ -1789,9 +2067,9 @@ NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* t } } else { if ((gPlayerState.flags & 8)) { - gPlayerState.field_0x8 = 0x424; + gPlayerState.animation = 0x424; } else { - gPlayerState.field_0x8 = 0x820; + gPlayerState.animation = 0x820; } this->actionDelay = 6; this->subAction = 3; @@ -1802,7 +2080,7 @@ NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* t } END_NONMATCH -void sub_08072F14(Entity* this) { +static void sub_08072F14(Entity* this) { if (--this->actionDelay != 0xff) { sub_0807921C(); } else { @@ -1810,9 +2088,12 @@ void sub_08072F14(Entity* this) { } } -extern void (*const gUnk_0811BBE4[])(Entity*); +static void sub_08072F34(Entity* this) { + static EntityAction* const gUnk_0811BBE4[] = { + sub_08072F94, + sub_08073094, + }; -void sub_08072F34(Entity* this) { if (!sub_08078EFC()) { gPlayerState.field_0xa8 = 0x18; gPlayerState.field_0x10[2] = GetSurfaceCalcType(this, 0, 0); @@ -1823,13 +2104,13 @@ void sub_08072F34(Entity* this) { this->action = 0x1d; this->subAction = 0; this->y.HALF.LO = 0; - gPlayerState.field_0x8 = 0x2cf; + gPlayerState.animation = 0x2cf; } } } } -void sub_08072F94(Entity* this) { +static void sub_08072F94(Entity* this) { u32 bVar1; switch (gPlayerState.field_0x10[2]) { @@ -1847,9 +2128,9 @@ void sub_08072F94(Entity* this) { return; } if ((this->frame & 0x10)) { - gPlayerState.field_0x8 = 0x2d4; + gPlayerState.animation = 0x2d4; } else { - gPlayerState.field_0x8 = 0x2d5; + gPlayerState.animation = 0x2d5; } sub_08073094(this); } else { @@ -1858,38 +2139,40 @@ void sub_08072F94(Entity* this) { } if (this->direction & 0x10) { if (this->frame & 0x10) { - gPlayerState.field_0x8 = 0x2d1; + gPlayerState.animation = 0x2d1; } else { - gPlayerState.field_0x8 = 0x2d2; + gPlayerState.animation = 0x2d2; } } else { if (this->frame & 0x10) { - gPlayerState.field_0x8 = 0x2cf; + gPlayerState.animation = 0x2cf; } else { - gPlayerState.field_0x8 = 0x2d0; + gPlayerState.animation = 0x2d0; } } } this->subAction++; } else { if (this->frame & 0x10) { - gPlayerState.field_0x8 = 0x2d4; + gPlayerState.animation = 0x2d4; } else { - gPlayerState.field_0x8 = 0x2d5; + gPlayerState.animation = 0x2d5; } } break; } } -extern const u16 gUnk_0811BBEC[]; +static void sub_08073094(Entity* this) { + static const u16 sSpeeds[] = { + 0x0, 0x40, 0x60, 0x80, 0x100, 0xC0, + }; -void sub_08073094(Entity* this) { this->spritePriority.b1 = 0; - this->speed = gUnk_0811BBEC[this->frame & 0xf]; + this->speed = sSpeeds[this->frame & 0xf]; sub_08079E08(); if (!sub_08019840()) { - gPlayerState.pushedObject = gPlayerState.pushedObject ^ 0x80; + gPlayerState.pushedObject ^= 0x80; if ((gPlayerState.field_0x10[2] != 0x2a) && (gPlayerState.field_0x10[2] != 0x2c)) { sub_0807A1B8(); } @@ -1930,78 +2213,15 @@ void sub_08073094(Entity* this) { } } -extern void (*const gUnk_0811BBF8[])(Entity*); +static void PlayerUseEntrance(Entity* this) { + static EntityAction* const sPlayerUseEntranceStates[] = { + sub_080731D8, + sub_080732D0, + sub_0807332C, + sub_080733BC, + }; -void PlayerUseEntrance(Entity* this) { gPlayerState.field_0xa8 = 0x1c; RequestPriorityDuration(NULL, 8); - gUnk_0811BBF8[this->subAction](this); + sPlayerUseEntranceStates[this->subAction](this); } - -void PlayerInit(Entity*); -void PlayerNormal(Entity*); -void PlayerInit(Entity*); -void PlayerFall(Entity*); -void PlayerJump(Entity*); -void PlayerPush(Entity*); -void PlayerBounce(Entity*); -void sub_08070E9C(Entity*); -void PlayerItemGet(Entity*); -void PlayerMinish(Entity*); -void PlayerMinishDie(Entity*); -void sub_08071DB8(Entity*); -void PlayerEmptyBottle(Entity*); -void PlayerFrozen(Entity*); -void sub_0807204C(Entity*); -void sub_080720DC(Entity*); -void PlayerPull(Entity*); -void PlayerLava(Entity*); -void PlayerWarp(Entity*); -void sub_08072454(Entity*); -void PlayerDrown(Entity*); -void PlayerUsePortal(Entity*); -void PlayerTalkEzlo(Entity*); -void PlayerRoomTransition(Entity*); -void PlayerRoll(Entity*); -void sub_080728AC(Entity*); -void PlayerInHole(Entity*); -void sub_08072C9C(Entity*); -void sub_08074C44(Entity*); -void sub_08072F34(Entity*); -void PlayerUseEntrance(Entity*); -void PlayerParachute(Entity*); - -static void (*const sPlayerActions[])(Entity*) = { - [PLAYER_INIT] = PlayerInit, - [PLAYER_NORMAL] = PlayerNormal, - [PLAYER_DUMMY] = PlayerInit, - [PLAYER_FALL] = PlayerFall, - [PLAYER_JUMP] = PlayerJump, - [PLAYER_PUSH] = PlayerPush, - [PLAYER_BOUNCE] = PlayerBounce, - [PLAYER_08070E9C] = sub_08070E9C, - [PLAYER_ITEMGET] = PlayerItemGet, - [PLAYER_MINISH] = PlayerMinish, - [PLAYER_MINISHDIE] = PlayerMinishDie, - [PLAYER_08071DB8] = sub_08071DB8, - [PLAYER_EMPTYBOTTLE] = PlayerEmptyBottle, - [PLAYER_FROZEN] = PlayerFrozen, - [PLAYER_0807204C] = sub_0807204C, - [PLAYER_080720DC] = sub_080720DC, - [PLAYER_PULL] = PlayerPull, - [PLAYER_LAVA] = PlayerLava, - [PLAYER_WARP] = PlayerWarp, - [PLAYER_08072454] = sub_08072454, - [PLAYER_DROWN] = PlayerDrown, - [PLAYER_USEPORTAL] = PlayerUsePortal, - [PLAYER_TALKEZLO] = PlayerTalkEzlo, - [PLAYER_ROOMTRANSITION] = PlayerRoomTransition, - [PLAYER_ROLL] = PlayerRoll, - [PLAYER_080728AC] = sub_080728AC, - [PLAYER_INHOLE] = PlayerInHole, - [PLAYER_08072C9C] = sub_08072C9C, - [PLAYER_08074C44] = sub_08074C44, - [PLAYER_08072F34] = sub_08072F34, - [PLAYER_USEENTRANCE] = PlayerUseEntrance, - [PLAYER_PARACHUTE] = PlayerParachute, -}; diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 9d4d7187..4a805082 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -97,7 +97,7 @@ void DirtBallProjectile_Action1(Entity* this) { break; case 2: this->z.HALF.HI += 0xe; - if (sub_080041A0(this, &gPlayerEntity, 0xe, 0xe) != 0) { + if (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe) != 0) { this->action = 2; parent->field_0x82.HALF.HI = 0xc0; } diff --git a/src/room.c b/src/room.c index aad169d9..2068c71d 100644 --- a/src/room.c +++ b/src/room.c @@ -96,12 +96,9 @@ u32 sub_unk3_ArmosInteriors_FortressOfWindsLeft() { } void sub_StateChange_ArmosInteriors_FortressOfWindsLeft() { - Area* a; - sub_08030118(9); - a = &gArea; - *((u8*)&a->localFlagOffset - 1) = 3; - a->areaMetadata = 0x4e; + gArea.dungeon_idx = 3; + gArea.areaMetadata = 0x4e; } u32 sub_unk3_ArmosInteriors_FortressOfWindsRight() { @@ -109,12 +106,9 @@ u32 sub_unk3_ArmosInteriors_FortressOfWindsRight() { } void sub_StateChange_ArmosInteriors_FortressOfWindsRight() { - Area* a; - sub_08030118(10); - a = &gArea; - *((u8*)&a->localFlagOffset - 1) = 3; - a->areaMetadata = 0x4e; + gArea.dungeon_idx = 3; + gArea.areaMetadata = 0x4e; } u32 sub_unk3_CrenelMinishPaths_CrenelBean() { @@ -279,14 +273,14 @@ void sub_StateChange_HouseInteriors1_PostOffice(void) { j++; } } - if (CheckLocalFlag(0x8b)) { + if (CheckLocalFlag(BILL01_TESSIN_RESERVED)) { flagArr = &gUnk_080D6508; i = 0; while (i < j) { if (CheckLocalFlag(*flagArr) == 0) { SetLocalFlag(*flagArr); - ClearLocalFlag(0x8b); - SetLocalFlag(0x8c); + ClearLocalFlag(BILL01_TESSIN_RESERVED); + SetLocalFlag(BILL01_TESSIN_BRANDNEW); break; } i++; @@ -294,28 +288,28 @@ void sub_StateChange_HouseInteriors1_PostOffice(void) { } } - if (CheckLocalFlag(0x1f)) + if (CheckLocalFlag(BILL01_TESSIN_1)) LoadRoomEntityList(&gUnk_080D6360); - if (CheckLocalFlag(0x20)) + if (CheckLocalFlag(BILL01_TESSIN_2)) LoadRoomEntityList(&gUnk_080D6380); - if (CheckLocalFlag(0x21)) + if (CheckLocalFlag(BILL01_TESSIN_3)) LoadRoomEntityList(&gUnk_080D63A0); - if (CheckLocalFlag(0x22)) + if (CheckLocalFlag(BILL01_TESSIN_4)) LoadRoomEntityList(&gUnk_080D63C0); - if (CheckLocalFlag(0x23)) + if (CheckLocalFlag(BILL01_TESSIN_5)) LoadRoomEntityList(&gUnk_080D63E0); - if (CheckLocalFlag(0x24)) + if (CheckLocalFlag(BILL01_TESSIN_6)) LoadRoomEntityList(&gUnk_080D6400); - if (CheckLocalFlag(0x25)) + if (CheckLocalFlag(BILL01_TESSIN_7)) LoadRoomEntityList(&gUnk_080D6420); - if (CheckLocalFlag(0x26)) + if (CheckLocalFlag(BILL01_TESSIN_8)) LoadRoomEntityList(&gUnk_080D6440); } @@ -332,7 +326,7 @@ void sub_StateChange_HouseInteriors1_Library2F(void) { // flippers if (GetInventoryValue(0x46) == 0) { LoadRoomEntityList(&gUnk_080D6578); - if (CheckLocalFlag(0x73) == 0) { + if (CheckLocalFlag(MIZUKAKI_BOOK_ALLBACK) == 0) { LoadRoomEntityList(&gUnk_080D6638); return; } @@ -355,7 +349,7 @@ void sub_StateChange_HouseInteriors1_Library1F(void) { LoadRoomEntityList(&gUnk_080D6714); } // flippers - if (!GetInventoryValue(0x46) && CheckGlobalFlag(MIZUKAKI_START) && CheckLocalFlag(0x6a)) { + if (!GetInventoryValue(0x46) && CheckGlobalFlag(MIZUKAKI_START) && CheckLocalFlag(MIZUKAKI_KOBITO)) { LoadRoomEntityList(&gUnk_additional_9_HouseInteriors1_Library1F); } else { LoadRoomEntityList(&gUnk_additional_8_HouseInteriors1_Library1F); @@ -379,12 +373,12 @@ extern u32* gUnk_080D6A74[]; u32 sub_unk3_HouseInteriors1_InnWestRoom(void) { u32 index; - if (CheckLocalFlag(0x91) != 0) { + if (CheckLocalFlag(YADO_CHECKIN) != 0) { index = (s32)Random() % 3; - ClearLocalFlag(1); + ClearLocalFlag(BILL05_YADO1F_MATSU_T0); } else { index = 0; - SetLocalFlag(1); + SetLocalFlag(BILL05_YADO1F_MATSU_T0); } gRoomVars.field_0x6c[3] = gUnk_080D6A74[index]; return 1; @@ -393,8 +387,8 @@ u32 sub_unk3_HouseInteriors1_InnWestRoom(void) { extern void* script_08010A5C[]; void sub_StateChange_HouseInteriors1_InnWestRoom(void) { - if (CheckLocalFlag(0x91)) { - ClearLocalFlag(0x91); + if (CheckLocalFlag(YADO_CHECKIN)) { + ClearLocalFlag(YADO_CHECKIN); DoFade(5, 0x100); gPlayerEntity.x.HALF.HI = gRoomControls.roomOriginX + 0x50; gPlayerEntity.y.HALF.HI = gRoomControls.roomOriginY + 0x38; @@ -407,20 +401,20 @@ extern u32* gUnk_080D6B18[]; u32 sub_unk3_HouseInteriors1_InnMiddleRoom(void) { u32 index; - if (CheckLocalFlag(0x91) != 0) { + if (CheckLocalFlag(YADO_CHECKIN) != 0) { index = Random() & 1; - ClearLocalFlag(2); + ClearLocalFlag(BILL06_YADO1F_TAKE_T0); } else { index = 0; - SetLocalFlag(2); + SetLocalFlag(BILL06_YADO1F_TAKE_T0); } gRoomVars.field_0x6c[3] = gUnk_080D6B18[index]; return 1; } void sub_StateChange_HouseInteriors1_InnMiddleRoom(void) { - if (CheckLocalFlag(0x91) != 0) { - ClearLocalFlag(0x91); + if (CheckLocalFlag(YADO_CHECKIN) != 0) { + ClearLocalFlag(YADO_CHECKIN); DoFade(5, 0x100); gPlayerEntity.x.HALF.HI = gRoomControls.roomOriginX + 0x50; gPlayerEntity.y.HALF.HI = gRoomControls.roomOriginY + 0x38; @@ -433,20 +427,20 @@ extern u32* gUnk_080D6BB8[]; u32 sub_unk3_HouseInteriors1_InnEastRoom(void) { s32 index; - if (CheckLocalFlag(0x91) != 0) { + if (CheckLocalFlag(YADO_CHECKIN) != 0) { index = (s32)Random() % 3; - ClearLocalFlag(3); + ClearLocalFlag(BILL07_YADO1F_UME_T0); } else { index = 0; - SetLocalFlag(3); + SetLocalFlag(BILL07_YADO1F_UME_T0); } gRoomVars.field_0x6c[3] = gUnk_080D6BB8[index]; return 1; } void sub_StateChange_HouseInteriors1_InnEastRoom(void) { - if (CheckLocalFlag(0x91)) { - ClearLocalFlag(0x91); + if (CheckLocalFlag(YADO_CHECKIN)) { + ClearLocalFlag(YADO_CHECKIN); DoFade(5, 0x100); gPlayerEntity.x.HALF.HI = gRoomControls.roomOriginX + 0x60; gPlayerEntity.y.HALF.HI = gRoomControls.roomOriginY + 0x38; @@ -567,20 +561,22 @@ void sub_StateChange_HyruleCastle_0(void) { if (!CheckGlobalFlag(LV2_CLEAR)) { LoadRoomEntityList(&gUnk_080D7328); } + #if defined(JP) || defined(DEMO_JP) if (CheckGlobalFlag(CASTLE_BGM) || CheckGlobalFlag(ENDING)) { -#else -#ifdef EU - if (CheckGlobalFlag(ENDING)) { -#else - if (CheckGlobalFlag(CASTLE_BGM)) { - - gArea.pMusicIndex = 0x1b; - } else if (CheckGlobalFlag(ENDING)) { -#endif -#endif gArea.pMusicIndex = gArea.musicIndex; } +#elif defined(EU) + if (CheckGlobalFlag(ENDING)) { + gArea.pMusicIndex = gArea.musicIndex; + } +#else + if (CheckGlobalFlag(CASTLE_BGM)) { + gArea.pMusicIndex = BGM_HYRULE_CASTLE_NOINTRO; + } else if (CheckGlobalFlag(ENDING)) { + gArea.pMusicIndex = gArea.musicIndex; + } +#endif } extern u32 gUnk_080D7410; @@ -597,7 +593,6 @@ extern EntityData gUnk_080D73B0; extern EntityData gUnk_080D73E0; void sub_StateChange_HyruleCastle_1(void) { -#ifdef EU if (CheckGlobalFlag(ENDING)) { gArea.pMusicIndex = gArea.musicIndex; } else { @@ -607,22 +602,12 @@ void sub_StateChange_HyruleCastle_1(void) { if (!CheckGlobalFlag(LV1_CLEAR) && CheckGlobalFlag(TABIDACHI)) { LoadRoomEntityList(&gUnk_080D73E0); } - } -#else - if (!CheckGlobalFlag(ENDING)) { - if (!CheckGlobalFlag(LV2_CLEAR)) { - LoadRoomEntityList(&gUnk_080D73B0); - } - if (!CheckGlobalFlag(LV1_CLEAR) && CheckGlobalFlag(TABIDACHI)) { - LoadRoomEntityList(&gUnk_080D73E0); - } +#ifndef EU if (CheckGlobalFlag(CASTLE_BGM)) { gArea.pMusicIndex = gArea.musicIndex; } - } else { - gArea.pMusicIndex = gArea.musicIndex; - } #endif + } } u32 sub_unk3_HyruleCastle_2() { @@ -646,7 +631,7 @@ void sub_StateChange_HyruleCastle_2(void) { gArea.pMusicIndex = gArea.musicIndex; } else if (CheckGlobalFlag(TABIDACHI) == 0) { LoadRoomEntityList(&gUnk_080D74C8); - gArea.pMusicIndex = 0x1b; + gArea.pMusicIndex = BGM_HYRULE_CASTLE_NOINTRO; } else if (CheckGlobalFlag(LV1_CLEAR) == 0) { LoadRoomEntityList(&gUnk_080D7588); } else { @@ -661,21 +646,13 @@ u32 sub_unk3_HyruleCastle_3() { extern EntityData gUnk_additional_8_HyruleCastle_3; void sub_StateChange_HyruleCastle_3(void) { -#if defined(JP) || defined(EU) || defined(DEMO_JP) - if (CheckLocalFlag(0x9b)) { -#else - if (CheckLocalFlag(0x9c)) { -#endif + if (CheckLocalFlag(SOUGEN_08_TORITSUKI)) { LoadRoomEntityList(&gUnk_additional_8_HyruleCastle_3); } } u32 sub_unk3_HyruleCastle_4(void) { -#if defined(JP) || defined(EU) || defined(DEMO_JP) - if (!CheckLocalFlag(0x9e)) { -#else - if (!CheckLocalFlag(0x9f)) { -#endif + if (!CheckLocalFlag(CASTLE_04_MEZAME)) { gScreenTransition.player_status.spawn_type = 5; ClearGlobalFlag(ZELDA_CHASE); } @@ -685,11 +662,7 @@ u32 sub_unk3_HyruleCastle_4(void) { extern u32 script_08009E88; void sub_StateChange_HyruleCastle_4(void) { -#if defined(JP) || defined(DEMO_JP) || defined(EU) - if (!CheckLocalFlag(0x9e)) { -#else - if (!CheckLocalFlag(0x9f)) { -#endif + if (!CheckLocalFlag(CASTLE_04_MEZAME)) { DoFade(5, 0x100); gPlayerEntity.x.HALF.HI = gRoomControls.roomOriginX + 0xb0; gPlayerEntity.y.HALF.HI = gRoomControls.roomOriginY + 0x40; @@ -958,8 +931,8 @@ extern u32 gUnk_080D8BFA; extern u32 gUnk_080D8C68; void sub_StateChange_GoronCave_Main(void) { - if (!CheckLocalFlag(0x68)) - SetLocalFlag(0x68); + if (!CheckLocalFlag(GORON_DOUKUTU_APPEAR)) + SetLocalFlag(GORON_DOUKUTU_APPEAR); if (CheckKinstoneFused(0x2f)) LoadRoomEntityList(&gUnk_080D8B24); @@ -1220,7 +1193,7 @@ void sub_StateChange_CastorCaves_HeartPiece() { extern u32 gUnk_080DA230; u32 sub_unk3_CastorDarknut_Main(void) { - if (!CheckLocalFlag(0x39)) + if (!CheckLocalFlag(LV4_0a_TSUBO)) gRoomVars.field_0x6c[0] = &gUnk_080DA230; return 1; @@ -1542,7 +1515,7 @@ extern EntityData gUnk_080DB4A0; void sub_StateChange_TownMinishHoles_MayorsHouse(void) { // flippers and history of masks book - if (!GetInventoryValue(0x46) && !GetInventoryValue(0x3b) && CheckLocalFlag(0x71)) + if (!GetInventoryValue(0x46) && !GetInventoryValue(0x3b) && CheckLocalFlag(KOBITO_DOUKUTU_04_T0)) LoadRoomEntityList(&gUnk_080DB4D0); else LoadRoomEntityList(&gUnk_080DB4A0); @@ -1593,7 +1566,7 @@ void sub_StateChange_TownMinishHoles_5() { extern u32 gUnk_080DB910; u32 sub_unk3_TownMinishHoles_LibraryBookshelf(void) { - if (CheckGlobalFlag(MIZUKAKI_START) && !CheckLocalFlag(0x73)) { + if (CheckGlobalFlag(MIZUKAKI_START) && !CheckLocalFlag(KOBITO_DOUKUTU_09_T0)) { gRoomVars.field_0x6c[1] = &gUnk_080DB910; } return 1; @@ -1621,7 +1594,7 @@ extern EntityData gUnk_080DBA08; void sub_StateChange_TownMinishHoles_LibrariBookHouse(void) { // flippers - if (GetInventoryValue(0x46) || !CheckLocalFlag(0x73)) { + if (GetInventoryValue(0x46) || !CheckLocalFlag(KOBITO_DOUKUTU_09_T0)) { LoadRoomEntityList(&gUnk_080DBA08); } sub_0801AFE4(); @@ -1641,7 +1614,7 @@ void sub_StateChange_TownMinishHoles_RemShoeShop(void) { u32 tilePos; u32 i; - if (!CheckLocalFlag(0x60)) { + if (!CheckLocalFlag(KOBITO_DOUKUTU_00_T0)) { LoadRoomEntityList(&gUnk_080DBB50); } @@ -1652,7 +1625,7 @@ void sub_StateChange_TownMinishHoles_RemShoeShop(void) { } else { LoadRoomEntityList(&gUnk_080DBAD0); } - if (!CheckLocalFlag(0x62)) { + if (!CheckLocalFlag(KOBITO_DOUKUTU_05_T0)) { tilePos = 0x140; for (i = 0; i < 0x13; i++, tilePos++) { SetTileType(0x4072, tilePos, 1); @@ -6756,5 +6729,5 @@ void sub_StateChange_CrenelCaves_ToGrayblade() { void sub_0804FF84(u32 arg0) { ((struct_02000000*)0x02000000)->brightnessPref = arg0; - gUsedPalettes = (u32)-1; + gUsedPalettes = 0xffffffff; } diff --git a/src/save.c b/src/save.c index 36727c41..1f3102b2 100644 --- a/src/save.c +++ b/src/save.c @@ -79,7 +79,7 @@ static const SaveFileStatus sSaveDescInit = { 0xffff, 0xffff, 'TINI' }; // Save file is deleted static const SaveFileStatus sSaveDescDeleted = { 0xffff, 0xffff, 'FleD' }; -const char gUnk_0811E4B4[8] = "DAMEDAME"; +const char sDummyData[8] = "DAMEDAME"; const SaveFileEEPROMAddresses gSaveFileEEPROMAddresses[] = { { 0x500, 0x30, 0x1030, 0x80, 0x1080 }, { 0x500, 0x40, 0x1040, 0x580, 0x1580 }, { 0x500, 0x50, 0x1050, 0xa80, 0x1a80 }, @@ -438,7 +438,7 @@ bool32 DataWrite(u32 address, const void* data, u32 size) { address /= 8; while (size-- > 0) { if (EEPROMWrite0_8k_Check(address, data)) { - EEPROMWrite0_8k_Check(address, (const u16*)gUnk_0811E4B4); + EEPROMWrite0_8k_Check(address, (const u16*)sDummyData); return FALSE; } address++; diff --git a/src/script.c b/src/script.c index 34da5deb..7f5d1fb9 100644 --- a/src/script.c +++ b/src/script.c @@ -70,7 +70,7 @@ void ScriptCommand_ClearRoomFlag(Entity* entity, ScriptExecutionContext* context void ScriptCommand_Wait(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitForSomething(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitForSomething2(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_WaitPlayerAction8(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_WaitPlayerGetItem(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitForPlayerAction0x17(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitFor_1(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitFor_2(Entity* entity, ScriptExecutionContext* context); @@ -122,7 +122,7 @@ void ScriptCommand_SetEntityDirectionWithAnimationState(Entity* entity, ScriptEx void ScriptCommand_SetEntitySpeed(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_SetEntity0x20(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_SetEntityPositionRelative(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_SetEntityPosition(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_OffsetEntityPosition(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_MoveEntityToPlayer(Entity* entity, ScriptExecutionContext* context); void ScriptCommandNop3(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807EC1C(Entity* entity, ScriptExecutionContext* context); @@ -163,145 +163,7 @@ extern void RecoverUI(u32); typedef void (*ScriptCommand)(Entity*, ScriptExecutionContext*); -const ScriptCommand gScriptCommands[] = { ScriptCommandNop, - ScriptCommand_BeginBlock, - ScriptCommand_EndBlock, - ScriptCommand_Jump, - ScriptCommand_JumpIf, - ScriptCommand_JumpIfNot, - ScriptCommand_JumpTable, - ScriptCommand_JumpAbsolute, - ScriptCommand_JumpAbsoluteIf, - ScriptCommand_JumpAbsoluteIfNot, - ScriptCommand_JumpAbsoluteTable, - ScriptCommand_Call, - ScriptCommand_CallWithArg, - ScriptCommand_LoadRoomEntityList, - ScriptCommand_TestBit, - ScriptCommand_CheckInventory1, - ScriptCommand_CheckInventory2, - ScriptCommand_HasRoomItemForSale, - ScriptCommand_CheckLocalFlag, - ScriptCommand_CheckLocalFlagByBank, - ScriptCommand_CheckGlobalFlag, - ScriptCommand_CheckRoomFlag, - ScriptCommand_CheckPlayerInRegion, - ScriptCommand_CheckPlayerInRegion2, - ScriptCommand_CheckEntityInteractType, - ScriptCommand_0807E30C, - ScriptCommand_HasRupees, - ScriptCommand_0807E3BC, - ScriptCommand_0807E3E8, - ScriptCommand_CheckKinstoneFused, - ScriptCommand_BuyItem, - ScriptCommand_0807E48C, - ScriptCommand_0807E4CC, - ScriptCommand_0807E4EC, - ScriptCommand_0807E514, - ScriptCommand_CheckPlayerFlags, - ScriptCommand_0807E564, - ScriptCommand_EntityHasHeight, - ScriptCommand_ComparePlayerAction, - ScriptCommand_ComparePlayerAnimationState, - ScriptCommand_0807E5F8, - ScriptCommand_0807E610, - ScriptCommand_SetLocalFlag, - ScriptCommand_SetLocalFlagByBank, - ScriptCommand_ClearLocalFlag, - ScriptCommand_SetGlobalFlag, - ScriptCommand_ClearGlobalFlag, - ScriptCommand_SetRoomFlag, - ScriptCommand_ClearRoomFlag, - ScriptCommand_Wait, - ScriptCommand_WaitForSomething, - ScriptCommand_WaitForSomething2, - ScriptCommand_WaitPlayerAction8, - ScriptCommand_WaitForPlayerAction0x17, - ScriptCommand_WaitFor_1, - ScriptCommand_WaitFor_2, - ScriptCommand_0807E778, - ScriptCommand_SetFadeMask, - ScriptCommand_0807E79C, - ScriptCommandNop2, - ScriptCommand_DoFade4, - ScriptCommand_DoFade5, - ScriptCommand_DoFade6, - ScriptCommand_DoFade7, - ScriptCommand_0807E800, - ScriptCommand_0807E80C, - ScriptCommand_0807E858, - ScriptCommand_0807E864, - ScriptCommand_0807E878, - ScriptCommand_0807E888, - ScriptCommand_SetPlayerAction, - ScriptCommand_StartPlayerScript, - ScriptCommand_0807E8D4, - ScriptCommand_0807E8E4, - ScriptCommand_0807E8E4, - ScriptCommand_0807E8E4, - ScriptCommand_0807E8E4, - ScriptCommand_0807E908, - ScriptCommand_SetIntVariable, - ScriptCommand_0807E924, - ScriptCommand_0807E930, - ScriptCommand_0807E944, - ScriptCommand_0807E974, - ScriptCommand_0807E9D4, - ScriptCommand_0807E9DC, - ScriptCommand_0807E9E4, - ScriptCommand_0807E9F0, - ScriptCommand_0807EA4C, - ScriptCommand_0807EA88, - ScriptCommand_WaitUntilTextboxCloses, - ScriptCommand_MessageFromTarget, - ScriptCommand_MessageNoOverlap, - ScriptCommand_MessageFromTargetPos, - ScriptCommand_MessageFromTargetTable, - ScriptCommand_MessageNoOverlapVar, - ScriptCommand_0807EB28, - ScriptCommand_0807EB38, - ScriptCommand_0807EB44, - ScriptCommand_0807EB4C, - ScriptCommand_0807EB74, - ScriptCommand_0807EB8C, - ScriptCommand_SetEntityDirection, - ScriptCommand_SetEntityDirectionWithAnimationState, - ScriptCommand_SetEntitySpeed, - ScriptCommand_SetEntity0x20, - ScriptCommand_SetEntityPositionRelative, - ScriptCommand_SetEntityPosition, - ScriptCommand_MoveEntityToPlayer, - ScriptCommandNop3, - ScriptCommand_0807EC1C, - ScriptCommand_0807EC64, - ScriptCommand_0807EC94, - ScriptCommand_0807ECC4, - ScriptCommand_0807ECF4, - ScriptCommand_0807ED24, - ScriptCommand_0807EDD4, - ScriptCommand_0807EE04, - ScriptCommand_0807EE30, - ScriptCommand_0807EEB4, - ScriptCommand_0807EEF4, - ScriptCommand_0807EF3C, - ScriptCommand_DoPostScriptAction, - ScriptCommand_DoPostScriptAction2, - ScriptCommand_PlaySound, - ScriptCommand_PlayBgm, - ScriptCommand_SoundReq, - ScriptCommand_StopBgm, - ScriptCommand_ModRupees, - ScriptCommand_ModHealth, - ScriptCommand_IncreaseMaxHealth, - ScriptCommand_0807F034, - ScriptCommand_0807F050, - ScriptCommand_GetInventoryValue, - ScriptCommand_0807F078, - ScriptCommand_0807F088, - ScriptCommand_CameraTargetEntity, - ScriptCommand_CameraTargetPlayer, - ScriptCommand_0807F0B4, - ScriptCommand_0807F0C8 }; +extern const ScriptCommand gScriptCommands[]; extern u16* gUnk_08001A7C[]; extern u8 gUnk_08114F30[]; @@ -432,10 +294,10 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) { entity->field_0x82.HWORD |= 2; break; case 1 << 0x0b: - entity->field_0x82.HWORD &= 0xfffd; + entity->field_0x82.HWORD &= ~2; break; case 1 << 0x0c: - entity->field_0x82.HWORD &= 0xfffe; + entity->field_0x82.HWORD &= ~1; break; case 1 << 0x0d: entity->field_0x82.HWORD |= 1; @@ -456,7 +318,7 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) { entity->field_0x82.HWORD |= 0x20; break; case 1 << 0x13: - entity->field_0x82.HWORD &= 0xffdf; + entity->field_0x82.HWORD &= ~0x20; break; default: break; @@ -515,22 +377,23 @@ void HandleEntity0x82Actions(Entity* entity) { loopVar = loopVar ^ bit; switch (bit) { case 1 << 1: - if (entity->kind == 7) { + if (entity->kind == NPC) { sub_0806ED78(entity); } else { sub_0800445C(entity); } break; case 1 << 3: - if ((gScreenTransition.frameCount & 3) == 0) { - temp = (entity->field_0xf + 2U) & 7; + if (gScreenTransition.frameCount % 4 == 0) { + temp = (entity->field_0xf + 2) & 7; entity->animationState = temp; entity->field_0xf = temp; } break; case 1 << 4: - if ((gScreenTransition.frameCount & 1) == 0) { - entity->spriteOffsetX = gUnk_0811E510[Random() & 3]; + if (gScreenTransition.frameCount % 2 == 0) { + static const s8 sOffsets[] = { -1, -2, 0, 1 }; + entity->spriteOffsetX = sOffsets[Random() % 4]; } break; case 1 << 5: @@ -573,6 +436,7 @@ void sub_0807DE80(Entity* entity) { } void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 x, u32 y) { + static const u8 sDirectionTable[] = { 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 0, 0 }; int direction; s32 xOffset, yOffset; @@ -585,7 +449,7 @@ void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 x, u32 y) yOffset = context->y.HALF.HI - entity->y.HALF.HI; direction = sub_080045DA(xOffset, yOffset); entity->direction = direction; - entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(direction << 0x18) >> 0x1c]; + entity->animationState = (entity->animationState & 0x80) | sDirectionTable[(u8)direction >> 4]; } void sub_0807DF28(void) { @@ -608,6 +472,148 @@ void sub_0807DF50(void) { } void ExecuteScript(Entity* entity, ScriptExecutionContext* context) { + static const ScriptCommand gScriptCommands[] = { + ScriptCommandNop, + ScriptCommand_BeginBlock, + ScriptCommand_EndBlock, + ScriptCommand_Jump, + ScriptCommand_JumpIf, + ScriptCommand_JumpIfNot, + ScriptCommand_JumpTable, + ScriptCommand_JumpAbsolute, + ScriptCommand_JumpAbsoluteIf, + ScriptCommand_JumpAbsoluteIfNot, + ScriptCommand_JumpAbsoluteTable, + ScriptCommand_Call, + ScriptCommand_CallWithArg, + ScriptCommand_LoadRoomEntityList, + ScriptCommand_TestBit, + ScriptCommand_CheckInventory1, + ScriptCommand_CheckInventory2, + ScriptCommand_HasRoomItemForSale, + ScriptCommand_CheckLocalFlag, + ScriptCommand_CheckLocalFlagByBank, + ScriptCommand_CheckGlobalFlag, + ScriptCommand_CheckRoomFlag, + ScriptCommand_CheckPlayerInRegion, + ScriptCommand_CheckPlayerInRegion2, + ScriptCommand_CheckEntityInteractType, + ScriptCommand_0807E30C, + ScriptCommand_HasRupees, + ScriptCommand_0807E3BC, + ScriptCommand_0807E3E8, + ScriptCommand_CheckKinstoneFused, + ScriptCommand_BuyItem, + ScriptCommand_0807E48C, + ScriptCommand_0807E4CC, + ScriptCommand_0807E4EC, + ScriptCommand_0807E514, + ScriptCommand_CheckPlayerFlags, + ScriptCommand_0807E564, + ScriptCommand_EntityHasHeight, + ScriptCommand_ComparePlayerAction, + ScriptCommand_ComparePlayerAnimationState, + ScriptCommand_0807E5F8, + ScriptCommand_0807E610, + ScriptCommand_SetLocalFlag, + ScriptCommand_SetLocalFlagByBank, + ScriptCommand_ClearLocalFlag, + ScriptCommand_SetGlobalFlag, + ScriptCommand_ClearGlobalFlag, + ScriptCommand_SetRoomFlag, + ScriptCommand_ClearRoomFlag, + ScriptCommand_Wait, + ScriptCommand_WaitForSomething, + ScriptCommand_WaitForSomething2, + ScriptCommand_WaitPlayerGetItem, + ScriptCommand_WaitForPlayerAction0x17, + ScriptCommand_WaitFor_1, + ScriptCommand_WaitFor_2, + ScriptCommand_0807E778, + ScriptCommand_SetFadeMask, + ScriptCommand_0807E79C, + ScriptCommandNop2, + ScriptCommand_DoFade4, + ScriptCommand_DoFade5, + ScriptCommand_DoFade6, + ScriptCommand_DoFade7, + ScriptCommand_0807E800, + ScriptCommand_0807E80C, + ScriptCommand_0807E858, + ScriptCommand_0807E864, + ScriptCommand_0807E878, + ScriptCommand_0807E888, + ScriptCommand_SetPlayerAction, + ScriptCommand_StartPlayerScript, + ScriptCommand_0807E8D4, + ScriptCommand_0807E8E4, + ScriptCommand_0807E8E4, + ScriptCommand_0807E8E4, + ScriptCommand_0807E8E4, + ScriptCommand_0807E908, + ScriptCommand_SetIntVariable, + ScriptCommand_0807E924, + ScriptCommand_0807E930, + ScriptCommand_0807E944, + ScriptCommand_0807E974, + ScriptCommand_0807E9D4, + ScriptCommand_0807E9DC, + ScriptCommand_0807E9E4, + ScriptCommand_0807E9F0, + ScriptCommand_0807EA4C, + ScriptCommand_0807EA88, + ScriptCommand_WaitUntilTextboxCloses, + ScriptCommand_MessageFromTarget, + ScriptCommand_MessageNoOverlap, + ScriptCommand_MessageFromTargetPos, + ScriptCommand_MessageFromTargetTable, + ScriptCommand_MessageNoOverlapVar, + ScriptCommand_0807EB28, + ScriptCommand_0807EB38, + ScriptCommand_0807EB44, + ScriptCommand_0807EB4C, + ScriptCommand_0807EB74, + ScriptCommand_0807EB8C, + ScriptCommand_SetEntityDirection, + ScriptCommand_SetEntityDirectionWithAnimationState, + ScriptCommand_SetEntitySpeed, + ScriptCommand_SetEntity0x20, + ScriptCommand_SetEntityPositionRelative, + ScriptCommand_OffsetEntityPosition, + ScriptCommand_MoveEntityToPlayer, + ScriptCommandNop3, + ScriptCommand_0807EC1C, + ScriptCommand_0807EC64, + ScriptCommand_0807EC94, + ScriptCommand_0807ECC4, + ScriptCommand_0807ECF4, + ScriptCommand_0807ED24, + ScriptCommand_0807EDD4, + ScriptCommand_0807EE04, + ScriptCommand_0807EE30, + ScriptCommand_0807EEB4, + ScriptCommand_0807EEF4, + ScriptCommand_0807EF3C, + ScriptCommand_DoPostScriptAction, + ScriptCommand_DoPostScriptAction2, + ScriptCommand_PlaySound, + ScriptCommand_PlayBgm, + ScriptCommand_SoundReq, + ScriptCommand_StopBgm, + ScriptCommand_ModRupees, + ScriptCommand_ModHealth, + ScriptCommand_IncreaseMaxHealth, + ScriptCommand_0807F034, + ScriptCommand_0807F050, + ScriptCommand_GetInventoryValue, + ScriptCommand_0807F078, + ScriptCommand_0807F088, + ScriptCommand_CameraTargetEntity, + ScriptCommand_CameraTargetPlayer, + ScriptCommand_0807F0B4, + ScriptCommand_0807F0C8, + }; + if (!context->scriptInstructionPointer) return; if (context->wait) { @@ -714,13 +720,13 @@ void ScriptCommand_LoadRoomEntityList(Entity* entity, ScriptExecutionContext* co } void ScriptCommand_TestBit(Entity* entity, ScriptExecutionContext* context) { - u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); - u32 tmp2 = 0; - u32 tmp3 = gActiveScriptInfo.unk_00; - if ((tmp3 & tmp) == tmp) - tmp2 = 1; - context->condition = tmp2; - gActiveScriptInfo.unk_00 = tmp3 & ~tmp; + u32 flag = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); + u32 set = 0; + u32 field = gActiveScriptInfo.unk_00; + if ((field & flag) == flag) + set = 1; + context->condition = set; + gActiveScriptInfo.unk_00 = field & ~flag; gActiveScriptInfo.flags |= 1; } @@ -807,7 +813,7 @@ void ScriptCommand_CheckEntityInteractType(Entity* entity, ScriptExecutionContex void ScriptCommand_0807E30C(Entity* entity, ScriptExecutionContext* context) { if ((context->unk_1A & 0xF) == 0 && (gPlayerState.flags & PL_MINISH) == 0 && - sub_080041A0(entity, &gPlayerEntity, 0x28, 0x28)) { + EntityInRectRadius(entity, &gPlayerEntity, 40, 40)) { entity->animationState = sub_0806F5B0(GetFacingDirection(entity, &gPlayerEntity)); } context->unk_1A++; @@ -847,16 +853,16 @@ void ScriptCommand_BuyItem(Entity* entity, ScriptExecutionContext* context) { item = context->scriptInstructionPointer[1]; tmp2 = context->scriptInstructionPointer[2]; if (!item) { - item = gRoomVars.itemForSaleIndex; - tmp2 = gRoomVars.field_0x7; + item = gRoomVars.shopItemType; + tmp2 = gRoomVars.shopItemType2; } price = GetItemPrice(item); context->condition = (price <= gSave.stats.rupees); if (context->condition) { ModRupees(-price); sub_080A7C18(item, tmp2, 0); - gRoomVars.itemForSaleIndex = 0; - gRoomVars.field_0x7 = 0; + gRoomVars.shopItemType = 0; + gRoomVars.shopItemType2 = 0; } gActiveScriptInfo.flags |= 1; } @@ -867,7 +873,7 @@ void ScriptCommand_0807E48C(Entity* entity, ScriptExecutionContext* context) { } void ScriptCommand_HasRoomItemForSale(Entity* entity, ScriptExecutionContext* context) { - context->condition = !!gRoomVars.itemForSaleIndex; + context->condition = !!gRoomVars.shopItemType; gActiveScriptInfo.flags |= 1; } @@ -971,11 +977,11 @@ void ScriptCommand_WaitForSomething2(Entity* entity, ScriptExecutionContext* con } } -void ScriptCommand_WaitPlayerAction8(Entity* entity, ScriptExecutionContext* context) { - if (gPlayerEntity.action == 8) { +void ScriptCommand_WaitPlayerGetItem(Entity* entity, ScriptExecutionContext* context) { + if (gPlayerEntity.action == PLAYER_ITEMGET) { gActiveScriptInfo.commandSize = 0; } else { - context->wait = 0x2D; + context->wait = 45; } } @@ -1058,16 +1064,16 @@ void ScriptCommand_0807E858(Entity* entity, ScriptExecutionContext* context) { } void ScriptCommand_0807E864(Entity* entity, ScriptExecutionContext* context) { - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; sub_08078B48(); } void ScriptCommand_0807E878(Entity* entity, ScriptExecutionContext* context) { - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; } void ScriptCommand_0807E888(Entity* entity, ScriptExecutionContext* context) { - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; } void ScriptCommand_SetPlayerAction(Entity* entity, ScriptExecutionContext* context) { @@ -1083,7 +1089,7 @@ void ScriptCommand_StartPlayerScript(Entity* entity, ScriptExecutionContext* con } void ScriptCommand_0807E8D4(Entity* entity, ScriptExecutionContext* context) { - gPlayerState.field_0x8 = context->scriptInstructionPointer[1]; + gPlayerState.animation = context->scriptInstructionPointer[1]; } void ScriptCommand_0807E8E4(Entity* entity, ScriptExecutionContext* context) { @@ -1161,7 +1167,7 @@ void ScriptCommand_0807E9F0(Entity* entity, ScriptExecutionContext* context) { tmp = 1; switch (gUnk_02022740[0]) { case 2: - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; gUnk_02034490[0] = tmp; context->condition = tmp; break; @@ -1173,7 +1179,7 @@ void ScriptCommand_0807E9F0(Entity* entity, ScriptExecutionContext* context) { } if (tmp) { sub_0807919C(); - gPlayerState.field_0x8b = 1; + gPlayerState.controlMode = 1; } else { lbl: gActiveScriptInfo.commandSize = 0; @@ -1275,7 +1281,7 @@ void ScriptCommand_SetEntityPositionRelative(Entity* entity, ScriptExecutionCont entity->y.HALF.HI = gRoomControls.roomOriginY + context->scriptInstructionPointer[2]; } -void ScriptCommand_SetEntityPosition(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_OffsetEntityPosition(Entity* entity, ScriptExecutionContext* context) { entity->x.HALF.HI += context->scriptInstructionPointer[1]; entity->y.HALF.HI += context->scriptInstructionPointer[2]; } @@ -1308,7 +1314,7 @@ void ScriptCommand_0807EC64(Entity* entity, ScriptExecutionContext* context) { context->unk_18 = 1; context->unk_12 = context->scriptInstructionPointer[1]; entity->animationState = 0; - entity->direction = 0; + entity->direction = DirectionNorth; context->postScriptActions |= 2; } sub_0807EC44(entity, context); @@ -1319,7 +1325,7 @@ void ScriptCommand_0807EC94(Entity* entity, ScriptExecutionContext* context) { context->unk_18 = 1; context->unk_12 = context->scriptInstructionPointer[1]; entity->animationState = 2; - entity->direction = 8; + entity->direction = DirectionEast; context->postScriptActions |= 2; } sub_0807EC44(entity, context); @@ -1330,7 +1336,7 @@ void ScriptCommand_0807ECC4(Entity* entity, ScriptExecutionContext* context) { context->unk_18 = 1; context->unk_12 = context->scriptInstructionPointer[1]; entity->animationState = 4; - entity->direction = 0x10; + entity->direction = DirectionSouth; context->postScriptActions |= 2; } sub_0807EC44(entity, context); @@ -1341,7 +1347,7 @@ void ScriptCommand_0807ECF4(Entity* entity, ScriptExecutionContext* context) { context->unk_18 = 1; context->unk_12 = context->scriptInstructionPointer[1]; entity->animationState = 6; - entity->direction = 0x18; + entity->direction = DirectionWest; context->postScriptActions |= 2; } sub_0807EC44(entity, context); @@ -1543,19 +1549,20 @@ void sub_0807F0EC(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F100(Entity* entity, ScriptExecutionContext* context) { - u32 rand; + static const u8 sValues[] = { 0xa, 0x14, 0x1e, 0x12, 0x1c, 0x26, 0xc, 0x18 }; - rand = Random(); + u32 rand = Random(); entity->animationState = rand & 6; - context->unk_1A = gUnk_0811E750[(rand >> 8) & 7]; + context->unk_1A = sValues[(rand >> 8) % 8]; } void sub_0807F128(Entity* entity, ScriptExecutionContext* context) { - u32 rand; + static const u8 sAnimations[] = { 6, 2, 6, 2, 4, 6, 4, 2 }; + static const u8 sValues[] = { 0xa, 0x14, 0x1e, 0x12, 0x1c, 0x26, 0xc, 0x18 }; - rand = Random(); - entity->animationState = gUnk_0811E758[rand & 7]; - context->unk_1A = gUnk_0811E760[(rand >> 8) & 7]; + u32 rand = Random(); + entity->animationState = sAnimations[rand & 7]; + context->unk_1A = sValues[(rand >> 8) % 8]; } void sub_0807F158(Entity* entity, ScriptExecutionContext* context) { @@ -1583,31 +1590,31 @@ void sub_0807F1A0(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F1C4(Entity* entity, ScriptExecutionContext* context) { - if ((gPlayerState.flags & 8) != 0) { - gPlayerState.field_0x8 = 0x459; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x459; } else { - gPlayerState.field_0x8 = 0x1bc; + gPlayerState.animation = 0x1bc; } } void sub_0807F1E8(Entity* entity, ScriptExecutionContext* context) { - if ((gPlayerState.flags & 8) != 0) { - gPlayerState.field_0x8 = 0x45a; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x45a; } else { - gPlayerState.field_0x8 = 0x2bd; + gPlayerState.animation = 0x2bd; } } void sub_0807F210(Entity* entity, ScriptExecutionContext* context) { - if ((gPlayerState.flags & 8) != 0) { - gPlayerState.field_0x8 = 0x41c; + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 0x41c; } else { - gPlayerState.field_0x8 = 0x80c; + gPlayerState.animation = 0x80c; } } void sub_0807F238(Entity* entity, ScriptExecutionContext* context) { - gPlayerState.field_0x8 = context->intVariable; + gPlayerState.animation = context->intVariable; } void sub_0807F244(Entity* entity, ScriptExecutionContext* context) { @@ -1672,15 +1679,15 @@ void sub_0807F338(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F348(Entity* entity, ScriptExecutionContext* context) { - SetDefaultPriority(entity, 2); + SetDefaultPriority(entity, PRIO_MESSAGE); } void sub_0807F354(Entity* entity, ScriptExecutionContext* context) { - SetDefaultPriority(entity, 6); + SetDefaultPriority(entity, PRIO_PLAYER_EVENT); } void sub_0807F360(Entity* entity, ScriptExecutionContext* context) { - SetDefaultPriority(entity, 3); + SetDefaultPriority(entity, PRIO_NO_BLOCK); } void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) { @@ -1688,7 +1695,7 @@ void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) { fx = CreateFx(entity, FX_REFLECT4, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; - PositionRelative(entity, fx, 0, -524288); + PositionRelative(entity, fx, 0, -0x80000); if (Random() & 1) fx->spriteSettings.flipX = 1; if (Random() & 1) @@ -1823,13 +1830,13 @@ void sub_0807F5C0(Entity* entity, ScriptExecutionContext* context) { void sub_0807F634(Entity* entity, ScriptExecutionContext* context) { u16* p = (u16*)context->intVariable; sub_0801DFB4(entity, p[0], p[1], p[2]); - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; } void sub_0807F650(Entity* entity, ScriptExecutionContext* context) { u32 p = sub_08002632(entity); sub_0801DFB4(entity, gUnk_08001A7C[p][0], gUnk_08001A7C[p][1], gUnk_08001A7C[p][2]); - gPlayerState.field_0x8b = 3; + gPlayerState.controlMode = CONTROL_DISABLED; } void sub_0807F680(Entity* entity, ScriptExecutionContext* context) { @@ -1883,7 +1890,7 @@ void sub_0807F78C(Entity* entity, ScriptExecutionContext* context) { u32 price; if (context->intVariable == 0) - item = gRoomVars.itemForSaleIndex; + item = gRoomVars.shopItemType; msg = GetSaleItemConfirmMessageID(item); price = GetItemPrice(item); @@ -1897,7 +1904,7 @@ void sub_0807F7C4(Entity* entity, ScriptExecutionContext* context) { u32 price; if (context->intVariable == 0) - item = gRoomVars.itemForSaleIndex; + item = gRoomVars.shopItemType; context->condition = GetItemPrice(item) <= gSave.stats.rupees; gActiveScriptInfo.flags |= 1; @@ -1909,12 +1916,12 @@ void sub_0807F800(Entity* entity, ScriptExecutionContext* context) { u32 price; if (context->intVariable == 0) - item = gRoomVars.itemForSaleIndex; + item = gRoomVars.shopItemType; price = GetItemPrice(item); ModRupees(-price); sub_080A7C18(item, 0, 0); - gRoomVars.itemForSaleIndex = 0; + gRoomVars.shopItemType = 0; gActiveScriptInfo.flags |= 1; }