From f0d610f385dcbac0973a3c4b2f48621417492b5a Mon Sep 17 00:00:00 2001 From: theo3 Date: Sun, 21 Mar 2021 22:00:07 -0700 Subject: [PATCH] fix entity.c search prototypes, add documentation --- asm/bigGoron.s | 22 +++++----- asm/bird.s | 2 +- asm/book.s | 2 +- asm/code_0801D79C.s | 14 +++--- asm/code_0804AA84.s | 2 +- asm/code_080526F8.s | 12 ++--- asm/code_0805436C.s | 4 +- asm/code_0806EC20.s | 2 +- asm/code_0806FA6C.s | 2 +- asm/code_080732D0.s | 6 +-- asm/code_08078778.s | 2 +- asm/code_0807F0D8.s | 2 +- asm/code_080A3480.s | 4 +- asm/code_080A5574.s | 2 +- asm/dust.s | 2 +- asm/fileScreen.s | 8 ++-- asm/fourElements.s | 2 +- asm/guardWithSpear.s | 2 +- asm/lilypadLarge.s | 4 +- asm/loadRoomEntity.s | 4 +- asm/macroBook.s | 4 +- asm/manager14.s | 2 +- asm/manager1B.s | 2 +- asm/manager22.s | 2 +- asm/manager36.s | 2 +- asm/managerF.s | 2 +- asm/object3E.s | 4 +- asm/object6A.s | 12 ++--- asm/object97.s | 4 +- asm/pina.s | 10 ++--- asm/rem.s | 6 +-- include/entity.h | 97 +++++++++++++++++++++++++++++------------ include/functions.h | 2 +- include/main.h | 1 - include/textbox.h | 30 +++++++++++++ include/utils.h | 45 +++++++++++++++++++ src/code_08077B98.c | 2 +- src/createEntity.c | 8 ++-- src/debugScreen.c | 2 +- src/enemy/miniSlime.c | 1 - src/enemy/pesto.c | 10 ++--- src/enemy/slime.c | 1 - src/entity.c | 38 ++++++++-------- src/fileScreen.c | 2 +- src/intro.c | 4 +- src/main.c | 2 +- src/manager/manager15.c | 2 +- src/npc/bigGoron.c | 2 +- src/npc/forestMinish.c | 2 +- src/npc/goronMerchant.c | 2 +- src/npc/malon.c | 4 +- src/npc/zelda.c | 6 +-- src/object/greatFairy.c | 4 +- src/player.c | 2 +- src/room.c | 2 +- src/sub_0807B820.c | 1 - 56 files changed, 266 insertions(+), 156 deletions(-) diff --git a/asm/bigGoron.s b/asm/bigGoron.s index f2926a00..8e59000e 100644 --- a/asm/bigGoron.s +++ b/asm/bigGoron.s @@ -120,7 +120,7 @@ sub_0806D0F8: @ 0x0806D0F8 movs r0, #7 movs r1, #0x4c movs r2, #7 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 beq _0806D10C bl sub_0806D0B0 @@ -928,7 +928,7 @@ sub_0806D6D0: @ 0x0806D6D0 movs r1, #0x4c movs r2, #7 movs r3, #2 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D6EE @@ -940,7 +940,7 @@ _0806D6EE: movs r1, #0x4c movs r2, #7 movs r3, #1 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D706 @@ -961,7 +961,7 @@ sub_0806D70C: @ 0x0806D70C movs r1, #0x4c movs r2, #7 movs r3, #2 - bl FindEntityInListByForm + bl FindEntity adds r2, r0, #0 cmp r2, #0 beq _0806D728 @@ -972,7 +972,7 @@ _0806D728: movs r1, #0x4c movs r2, #7 movs r3, #1 - bl FindEntityInListByForm + bl FindEntity adds r2, r0, #0 cmp r2, #0 beq _0806D746 @@ -996,7 +996,7 @@ sub_0806D74C: @ 0x0806D74C movs r1, #0x4c movs r2, #7 movs r3, #2 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D76A @@ -1008,7 +1008,7 @@ _0806D76A: movs r1, #0x4c movs r2, #7 movs r3, #1 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D782 @@ -1029,7 +1029,7 @@ sub_0806D788: @ 0x0806D788 movs r1, #0x4c movs r2, #7 movs r3, #2 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D7A6 @@ -1041,7 +1041,7 @@ _0806D7A6: movs r1, #0x4c movs r2, #7 movs r3, #1 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D7BE @@ -1070,7 +1070,7 @@ sub_0806D7C4: @ 0x0806D7C4 movs r1, #0x4c movs r2, #7 movs r3, #2 - bl FindEntityInListByForm + bl FindEntity cmp r0, #0 beq _0806D7FC movs r1, #0x2e @@ -1098,7 +1098,7 @@ sub_0806D804: @ 0x0806D804 movs r1, #0x4c movs r2, #7 movs r3, #2 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0806D83A diff --git a/asm/bird.s b/asm/bird.s index fed030cc..a6c53b75 100644 --- a/asm/bird.s +++ b/asm/bird.s @@ -639,7 +639,7 @@ CreateBird: @ 0x0809D700 movs r1, #0x95 movs r2, #6 movs r3, #8 - bl FindEntityInListByForm + bl FindEntity adds r4, r0, #0 cmp r4, #0 bne _0809D732 diff --git a/asm/book.s b/asm/book.s index 325205d1..fe75a238 100644 --- a/asm/book.s +++ b/asm/book.s @@ -327,7 +327,7 @@ _0809B606: movs r0, #7 movs r1, #0x1a movs r2, #7 - bl FindEntityInListBySubtype + bl FindEntityByID adds r2, r0, #0 cmp r2, #0 beq _0809B682 diff --git a/asm/code_0801D79C.s b/asm/code_0801D79C.s index f1aab2ca..4cbc3a6f 100644 --- a/asm/code_0801D79C.s +++ b/asm/code_0801D79C.s @@ -217,8 +217,8 @@ _0801DA02: mov sl, r5 pop {r4, r5, r6, r7, pc} - thumb_func_start sub_0801DA0C -sub_0801DA0C: @ 0x0801DA0C + thumb_func_start zFree +zFree: @ 0x0801DA0C push {r4, r5, lr} ldr r3, _0801DA44 @ =gzHeap subs r1, r0, r3 @@ -287,8 +287,8 @@ zMallocInit: @ 0x0801DA7C .align 2, 0 _0801DA8C: .4byte gzHeap - thumb_func_start sub_0801DA90 -sub_0801DA90: @ 0x0801DA90 + thumb_func_start DispReset +DispReset: @ 0x0801DA90 push {r4, r5, lr} adds r4, r0, #0 ldr r1, _0801DAEC @ =gMain @@ -319,7 +319,7 @@ sub_0801DA90: @ 0x0801DA90 movs r0, #0x80 lsls r0, r0, #0x13 strh r3, [r0] - bl sub_0801DB10 + bl ClearOAM bl sub_0801DB34 ldr r0, _0801DB08 @ =0x0600C000 movs r1, #0x20 @@ -341,8 +341,8 @@ _0801DB04: .4byte 0x00007FFF _0801DB08: .4byte 0x0600C000 _0801DB0C: .4byte gBG0Buffer - thumb_func_start sub_0801DB10 -sub_0801DB10: @ 0x0801DB10 + thumb_func_start ClearOAM +ClearOAM: @ 0x0801DB10 push {r4, lr} ldr r3, _0801DB30 @ =gUnk_03000020 movs r1, #0xe0 diff --git a/asm/code_0804AA84.s b/asm/code_0804AA84.s index c6424780..3174946c 100644 --- a/asm/code_0804AA84.s +++ b/asm/code_0804AA84.s @@ -9,7 +9,7 @@ sub_0804AB70: @ 0x0804AB70 push {r4, r5, lr} movs r0, #0 - bl sub_0801DA90 + bl DispReset ldr r1, _0804ABF8 @ =gScreen movs r2, #0 movs r0, #0x92 diff --git a/asm/code_080526F8.s b/asm/code_080526F8.s index a6574bbf..150d4fea 100644 --- a/asm/code_080526F8.s +++ b/asm/code_080526F8.s @@ -2013,7 +2013,7 @@ sub_0805368C: @ 0x0805368C movs r0, #6 movs r1, #0x5d movs r2, #6 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 beq _080536A6 bl DeleteEntity @@ -2139,7 +2139,7 @@ sub_08053758: @ 0x08053758 strh r2, [r0, #0xa] bl sub_0801B170 movs r0, #0 - bl sub_0801DA90 + bl DispReset ldr r2, _080537F0 @ =gScreen movs r0, #0x99 lsls r0, r0, #6 @@ -2380,7 +2380,7 @@ sub_08053974: @ 0x08053974 bne _080539A8 bl sub_0804FFE4 movs r0, #1 - bl sub_0801DA90 + bl DispReset bl sub_080197AC bl sub_08051F78 ldr r0, _080539B0 @ =gUnk_080FCBC4 @@ -2437,7 +2437,7 @@ sub_080539F4: @ 0x080539F4 cmp r0, #0 bne _08053A10 movs r0, #1 - bl sub_0801DA90 + bl DispReset ldr r0, _08053A18 @ =gMenu ldrb r1, [r0, #6] adds r1, #1 @@ -2587,7 +2587,7 @@ sub_08053B10: @ 0x08053B10 adds r1, #1 strb r1, [r0, #5] movs r0, #1 - bl sub_0801DA90 + bl DispReset movs r1, #0x80 lsls r1, r1, #1 movs r0, #4 @@ -2673,7 +2673,7 @@ sub_08053BBC: @ 0x08053BBC adds r1, #1 strb r1, [r0, #5] movs r0, #1 - bl sub_0801DA90 + bl DispReset movs r1, #0x80 lsls r1, r1, #1 movs r0, #4 diff --git a/asm/code_0805436C.s b/asm/code_0805436C.s index 4ab2c097..6e6c053a 100644 --- a/asm/code_0805436C.s +++ b/asm/code_0805436C.s @@ -33,7 +33,7 @@ sub_0805488C: @ 0x0805488C lsls r0, r0, #1 strh r0, [r2, #8] movs r0, #0 - bl sub_0801DA90 + bl DispReset ldrb r0, [r4, #3] movs r1, #1 bl sub_08054974 @@ -2571,7 +2571,7 @@ _08055C6C: movs r1, #0x9e movs r2, #6 movs r3, #0 - bl FindEntityInListByForm + bl FindEntity adds r4, r0, #0 cmp r4, #0 beq _08055C8C diff --git a/asm/code_0806EC20.s b/asm/code_0806EC20.s index 293d4e87..ff7f71a1 100644 --- a/asm/code_0806EC20.s +++ b/asm/code_0806EC20.s @@ -27,7 +27,7 @@ sub_0806EC38: @ 0x0806EC38 movs r0, #7 movs r1, #0x58 movs r2, #7 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 beq _0806EC4C bl DeleteEntity diff --git a/asm/code_0806FA6C.s b/asm/code_0806FA6C.s index 347c2fa1..f006651f 100644 --- a/asm/code_0806FA6C.s +++ b/asm/code_0806FA6C.s @@ -139,7 +139,7 @@ UnloadHitbox: @ 0x0806FBEC push {r4, lr} adds r4, r0, #0 ldr r0, [r4, #0x48] - bl sub_0801DA0C + bl zFree movs r0, #0 str r0, [r4, #0x48] pop {r4, pc} diff --git a/asm/code_080732D0.s b/asm/code_080732D0.s index ef443c26..f2e7f6fa 100644 --- a/asm/code_080732D0.s +++ b/asm/code_080732D0.s @@ -4592,7 +4592,7 @@ _080754F2: movs r0, #8 movs r1, #0xf movs r2, #2 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 bne _08075538 adds r0, r4, #0 @@ -6017,7 +6017,7 @@ sub_08075FF8: @ 0x08075FF8 movs r0, #8 movs r1, #2 movs r2, #2 - bl FindEntityInListBySubtype + bl FindEntityByID b _08076026 .align 2, 0 _08076018: .4byte gPlayerState @@ -6025,7 +6025,7 @@ _0807601C: adds r5, #1 adds r0, r4, #0 movs r1, #2 - bl FindNextEntityOfSameSubtype + bl FindNextDuplicateID _08076026: adds r4, r0, #0 cmp r4, #0 diff --git a/asm/code_08078778.s b/asm/code_08078778.s index fe9f34f1..323f2c4f 100644 --- a/asm/code_08078778.s +++ b/asm/code_08078778.s @@ -44,7 +44,7 @@ _080788BA: movs r0, #6 movs r1, #9 movs r2, #6 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 bne _080788D6 movs r0, #9 diff --git a/asm/code_0807F0D8.s b/asm/code_0807F0D8.s index 16552c65..22e915bf 100644 --- a/asm/code_0807F0D8.s +++ b/asm/code_0807F0D8.s @@ -1228,7 +1228,7 @@ sub_0807F950: @ 0x0807F950 movs r1, #0x56 movs r2, #6 movs r3, #0 - bl FindEntityInListByForm + bl FindEntity cmp r0, #0 beq _0807F96C bl DeleteEntity diff --git a/asm/code_080A3480.s b/asm/code_080A3480.s index a30dd9c2..879e0852 100644 --- a/asm/code_080A3480.s +++ b/asm/code_080A3480.s @@ -266,7 +266,7 @@ _080A365C: _080A365E: str r0, [r2, #0xc] movs r0, #0 - bl sub_0801DA90 + bl DispReset movs r0, #0xb bl LoadPaletteGroup movs r0, #0xc @@ -699,7 +699,7 @@ _080A39C8: strh r0, [r2, #8] strb r4, [r2, #3] movs r0, #1 - bl sub_0801DA90 + bl DispReset bl sub_080A3210 bl sub_080A4D34 movs r0, #0xa diff --git a/asm/code_080A5574.s b/asm/code_080A5574.s index 6a218289..05b47ec9 100644 --- a/asm/code_080A5574.s +++ b/asm/code_080A5574.s @@ -3782,7 +3782,7 @@ sub_080A7328: @ 0x080A7328 movs r0, #8 strb r0, [r4, #8] movs r0, #1 - bl sub_0801DA90 + bl DispReset bl MessageInitialize bl sub_080ADD30 movs r0, #0 diff --git a/asm/dust.s b/asm/dust.s index 2a5392c6..f010f3dc 100644 --- a/asm/dust.s +++ b/asm/dust.s @@ -160,7 +160,7 @@ _080441F2: cmp r2, #0 bne _08044248 ldr r0, [r4, #0x64] - bl sub_0801DA0C + bl zFree b _0804429A .align 2, 0 _08044244: .4byte 0x000001EB diff --git a/asm/fileScreen.s b/asm/fileScreen.s index 287c9992..ba7813d0 100755 --- a/asm/fileScreen.s +++ b/asm/fileScreen.s @@ -33,7 +33,7 @@ sub_080519B0: @ 0x080519B0 cmp r5, #0 bne _08051A02 movs r0, #1 - bl sub_0801DA90 + bl DispReset bl sub_080A3210 bl zMallocInit bl sub_080A7124 @@ -69,7 +69,7 @@ _08051A10: .4byte gMain sub_08051A14: @ 0x08051A14 push {lr} movs r0, #1 - bl sub_0801DA90 + bl DispReset ldr r1, _08051A70 @ =gFadeControl movs r0, #1 rsbs r0, r0, #0 @@ -368,7 +368,7 @@ sub_08051CF0: @ 0x08051CF0 cmp r4, #0 bne _08051D1E movs r0, #1 - bl sub_0801DA90 + bl DispReset strb r6, [r5, #3] strb r4, [r5, #4] ldr r0, _08051D28 @ =gScreenTransition @@ -729,7 +729,7 @@ sub_08052010: @ 0x08052010 bl sub_080A3210 bl MessageInitialize movs r0, #1 - bl sub_0801DA90 + bl DispReset ldr r0, _0805207C @ =gBG1Buffer movs r4, #0x80 lsls r4, r4, #4 diff --git a/asm/fourElements.s b/asm/fourElements.s index 42e2badb..dd5ffa82 100644 --- a/asm/fourElements.s +++ b/asm/fourElements.s @@ -355,7 +355,7 @@ sub_080A0464: @ 0x080A0464 movs r0, #6 movs r1, #0xac movs r2, #6 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 beq _080A048A movs r1, #0x2e diff --git a/asm/guardWithSpear.s b/asm/guardWithSpear.s index 14da7633..4d328260 100644 --- a/asm/guardWithSpear.s +++ b/asm/guardWithSpear.s @@ -153,7 +153,7 @@ sub_08064180: @ 0x08064180 movs r0, #7 movs r1, #0x15 movs r2, #7 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 beq _08064194 bl DeleteEntity diff --git a/asm/lilypadLarge.s b/asm/lilypadLarge.s index c89575a1..4d2e643d 100644 --- a/asm/lilypadLarge.s +++ b/asm/lilypadLarge.s @@ -73,7 +73,7 @@ _08085566: b _0808557A _0808556C: adds r0, r4, #0 - bl DoesSimilarEntityExist + bl EntityHasDuplicateID cmp r0, #0 beq _0808557A bl DeleteThisEntity @@ -1072,7 +1072,7 @@ _08085D0C: sub_08085D10: @ 0x08085D10 push {r4, lr} adds r4, r0, #0 - bl DoesSimilarEntityExist + bl EntityHasDuplicateID cmp r0, #0 beq _08085D26 ldrb r0, [r4, #0xb] diff --git a/asm/loadRoomEntity.s b/asm/loadRoomEntity.s index 81a81688..50933176 100644 --- a/asm/loadRoomEntity.s +++ b/asm/loadRoomEntity.s @@ -19,14 +19,14 @@ LoadRoomEntity: @ 0x0804ADF8 bne _0804AE1C ldrb r1, [r4, #2] adds r0, r6, #0 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _0804AE1C movs r0, #0 b _0804AEAC _0804AE1C: adds r0, r6, #0 - bl GetEmptyEntityByType + bl GetEmptyEntityByKind adds r5, r0, #0 cmp r5, #0 beq _0804AEAA diff --git a/asm/macroBook.s b/asm/macroBook.s index 7836e99b..654f182a 100644 --- a/asm/macroBook.s +++ b/asm/macroBook.s @@ -360,7 +360,7 @@ sub_0809AA00: @ 0x0809AA00 movs r0, #7 movs r1, #0x38 movs r2, #7 - bl FindEntityInListBySubtype + bl FindEntityByID adds r4, r0, #0 adds r7, r5, #0 adds r7, #0x78 @@ -380,7 +380,7 @@ _0809AA30: _0809AA3A: adds r0, r4, #0 movs r1, #7 - bl FindNextEntityOfSameSubtype + bl FindNextDuplicateID adds r4, r0, #0 cmp r4, #0 bne _0809AA30 diff --git a/asm/manager14.s b/asm/manager14.s index cfdf3e17..cae54bf4 100644 --- a/asm/manager14.s +++ b/asm/manager14.s @@ -30,7 +30,7 @@ _08059E7C: .4byte gUnk_081085A4 sub_08059E80: @ 0x08059E80 push {r4, r5, lr} adds r4, r0, #0 - bl DoesSimilarEntityExist + bl EntityHasDuplicateID cmp r0, #0 beq _08059E90 bl DeleteThisEntity diff --git a/asm/manager1B.s b/asm/manager1B.s index c591eaa4..31e610bc 100644 --- a/asm/manager1B.s +++ b/asm/manager1B.s @@ -10,7 +10,7 @@ sub_0805B3B4: @ 0x0805B3B4 push {r4, r5, lr} adds r4, r0, #0 - bl DoesSimilarEntityExist + bl EntityHasDuplicateID cmp r0, #0 beq _0805B3C4 bl DeleteThisEntity diff --git a/asm/manager22.s b/asm/manager22.s index 4159a42b..aae066dc 100644 --- a/asm/manager22.s +++ b/asm/manager22.s @@ -342,7 +342,7 @@ _0805BB82: strh r1, [r2, #0xc] movs r0, #9 movs r1, #0x22 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _0805BBAE bl sub_0805B8EC diff --git a/asm/manager36.s b/asm/manager36.s index 5245d37b..e4fae5aa 100644 --- a/asm/manager36.s +++ b/asm/manager36.s @@ -72,7 +72,7 @@ sub_0805DE18: @ 0x0805DE18 movs r0, #9 movs r1, #0x36 movs r2, #6 - bl FindEntityInListByForm + bl FindEntity cmp r0, #0 beq _0805DE34 bl DeleteEntityAny diff --git a/asm/managerF.s b/asm/managerF.s index b9d9444a..1e268250 100644 --- a/asm/managerF.s +++ b/asm/managerF.s @@ -492,7 +492,7 @@ sub_08059278: @ 0x08059278 movs r0, #9 movs r1, #0xf movs r2, #6 - bl FindEntityInListBySubtype + bl FindEntityByID cmp r0, #0 beq _0805928C bl sub_08058ECC diff --git a/asm/object3E.s b/asm/object3E.s index 786ee7ba..ee4b5d42 100644 --- a/asm/object3E.s +++ b/asm/object3E.s @@ -247,7 +247,7 @@ sub_0808D280: @ 0x0808D280 movs r1, #0x3e movs r2, #6 movs r3, #9 - bl FindEntityInListByForm + bl FindEntity adds r2, r0, #0 cmp r2, #0 beq _0808D2C4 @@ -287,7 +287,7 @@ sub_0808D2CC: @ 0x0808D2CC movs r1, #0x3e movs r2, #6 movs r3, #1 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _0808D2F2 diff --git a/asm/object6A.s b/asm/object6A.s index 761e95e4..fb464dcb 100644 --- a/asm/object6A.s +++ b/asm/object6A.s @@ -235,7 +235,7 @@ sub_08094BE0: @ 0x08094BE0 movs r1, #0x6a movs r2, #6 movs r3, #0x22 - bl FindEntityInListByForm + bl FindEntity adds r4, r0, #0 cmp r4, #0 beq _08094C22 @@ -390,7 +390,7 @@ sub_08094D10: @ 0x08094D10 movs r1, #0x6a movs r2, #6 movs r3, #3 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _08094D2E @@ -442,7 +442,7 @@ sub_08094D70: @ 0x08094D70 movs r1, #0x6a movs r2, #6 movs r3, #0x15 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _08094D8E @@ -527,7 +527,7 @@ sub_08094E0C: @ 0x08094E0C movs r1, #0x6a movs r2, #6 movs r3, #4 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _08094E2A @@ -951,7 +951,7 @@ sub_08095164: @ 0x08095164 movs r1, #0x6a movs r2, #6 movs r3, #8 - bl FindEntityInListByForm + bl FindEntity cmp r0, #0 beq _08095182 movs r1, #3 @@ -2103,7 +2103,7 @@ sub_08095A68: @ 0x08095A68 movs r1, #0x6a movs r2, #6 movs r3, #0x16 - bl FindEntityInListByForm + bl FindEntity adds r1, r0, #0 cmp r1, #0 beq _08095A86 diff --git a/asm/object97.s b/asm/object97.s index 74fca837..380c921b 100644 --- a/asm/object97.s +++ b/asm/object97.s @@ -62,7 +62,7 @@ sub_0809D9D8: @ 0x0809D9D8 bl InitAnimationForceUpdate adds r0, r4, #0 movs r1, #6 - bl FindNextEntityOfSameSubtype + bl FindNextDuplicateID cmp r0, #0 beq _0809DA1E str r4, [r0, #0x50] @@ -436,7 +436,7 @@ sub_0809DC80: @ 0x0809DC80 bl InitAnimationForceUpdate adds r0, r4, #0 movs r1, #6 - bl FindNextEntityOfSameSubtype + bl FindNextDuplicateID cmp r0, #0 beq _0809DD00 str r4, [r0, #0x50] diff --git a/asm/pina.s b/asm/pina.s index 39aeaf15..c92b8889 100644 --- a/asm/pina.s +++ b/asm/pina.s @@ -235,7 +235,7 @@ sub_08063C14: @ 0x08063C14 push {lr} movs r0, #7 movs r1, #0x14 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _08063C28 movs r1, #8 @@ -249,7 +249,7 @@ sub_08063C2C: @ 0x08063C2C push {lr} movs r0, #7 movs r1, #0x14 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _08063C40 movs r1, #4 @@ -263,7 +263,7 @@ sub_08063C44: @ 0x08063C44 push {lr} movs r0, #7 movs r1, #0x14 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _08063C58 movs r1, #0 @@ -277,7 +277,7 @@ sub_08063C5C: @ 0x08063C5C push {lr} movs r0, #7 movs r1, #0x14 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _08063C70 movs r1, #9 @@ -291,7 +291,7 @@ sub_08063C74: @ 0x08063C74 push {lr} movs r0, #7 movs r1, #0x14 - bl FindEntityBySubtype + bl DeepFindEntityByID cmp r0, #0 beq _08063C8C movs r2, #0x18 diff --git a/asm/rem.s b/asm/rem.s index a4906475..4f86ff07 100644 --- a/asm/rem.s +++ b/asm/rem.s @@ -938,7 +938,7 @@ _0806AAEE: adds r0, #0xac ldr r0, [r0] movs r1, #7 - bl FindNextEntityOfSameSubtype + bl FindNextDuplicateID adds r1, r0, #0 adds r0, r4, #0 adds r0, #0xb0 @@ -948,7 +948,7 @@ _0806AB02: adds r0, #0xb0 ldr r0, [r0] movs r1, #7 - bl FindNextEntityOfSameSubtype + bl FindNextDuplicateID adds r1, r0, #0 mov r0, r8 adds r0, #0xb4 @@ -1041,7 +1041,7 @@ sub_0806AB9C: @ 0x0806AB9C movs r1, #0x37 movs r2, #7 movs r3, #1 - bl FindEntityInListByForm + bl FindEntity cmp r0, #0 beq _0806ABBC bl DeleteEntity diff --git a/include/entity.h b/include/entity.h index 10867f53..f19e0876 100644 --- a/include/entity.h +++ b/include/entity.h @@ -175,34 +175,6 @@ extern LinkedList gUnk_03003DA0; #define COORD_TO_TILE_OFFSET(entity, xOff, yOff) \ TILE((entity)->x.HALF.HI - (xOff), (entity)->y.HALF.HI - (yOff)) -Entity* GetEmptyEntity(void); -extern Entity* CreateEnemy(u32 subtype, u32 form); -extern Entity* CreateObject(u32 subtype, u32 form, u32 parameter); -extern Entity* CreateNPC(u32 subtype, u32 form, u32 parameter); -extern Entity* CreateObjectWithParent(Entity* parent, u32 subtype, u32 form, u32 parameter); -extern Entity* CreateFx(Entity* parent, u32 form, u32 parameter); - -extern void InitializeAnimation(Entity*, u32); -extern void InitAnimationForceUpdate(Entity*, u32); -extern void UpdateAnimationSingleFrame(Entity*); -extern void UpdateSpriteForCollisionLayer(Entity*); -extern void GetNextFrame(Entity*); -extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); -extern void SetExtraSpriteFrame(Entity*, u32, u32); -extern void SetSpriteSubEntryOffsetData1(Entity*, u32, u32); -extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32); - -extern u32 GetFacingDirection(Entity*, Entity*); - -void DeleteThisEntity(void); -void DeleteEntity(Entity*); - -void AppendEntityToList(Entity* entity, u32 listIndex); -void PrependEntityToList(Entity* entity, int listIndex); - -Entity* FindEntityInListBySubtype(u32 type, u32 subtype, u32 listIndex); -Entity* FindEntityInListByForm(u32 type, u32 subtype, u32 listIndex, u32 form, u32 parameter); - enum { DirectionNorth = 0x00, DirectionEast = 0x08, @@ -224,4 +196,73 @@ enum { #define Direction8ToAnimationState(expr) (Direction8RoundUp(expr) >> 2) #define Direction8FromAnimationState(expr) (((expr) << 2) +Entity* GetEmptyEntity(void); +extern Entity* CreateEnemy(u32 id, u32 type); +extern Entity* CreateNPC(u32 id, u32 type, u32 type2); +extern Entity* CreateObject(u32 id, u32 type, u32 type2); +extern Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2); +extern Entity* CreateFx(Entity* parent, u32 type, u32 type2); + +extern void InitializeAnimation(Entity*, u32); +extern void InitAnimationForceUpdate(Entity*, u32); +extern void UpdateAnimationSingleFrame(Entity*); +extern void UpdateSpriteForCollisionLayer(Entity*); +extern void GetNextFrame(Entity*); +extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); +extern void SetExtraSpriteFrame(Entity*, u32, u32); +extern void SetSpriteSubEntryOffsetData1(Entity*, u32, u32); +extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32); + +extern u32 GetFacingDirection(Entity*, Entity*); + +/** + * @brief Delete the entity currently in execution. + */ +void DeleteThisEntity(void); + +/** + * @brief Delete an entity. + */ +void DeleteEntity(Entity*); + +/** + * @brief Append entity to linked list. + */ +void AppendEntityToList(Entity* entity, u32 listIndex); + +/** + * @brief Prepend entity to linked list. + */ +void PrependEntityToList(Entity* entity, u32 listIndex); + +/** + * @brief Find an entity for a given kind and ID. + * @return Entity* First result or NULL if none found + */ +Entity* FindEntityByID(u32 kind, u32 id, u32 listIndex); + +/** + * @brief Search all lists for an entity of same kind and id. + * @return Entity* First result or NULL if none found + */ +Entity* DeepFindEntityByID(u32 kind, u32 id); + +/** + * @brief Search all lists for entity of same kind and id. + * @return bool32 Duplicate was entity found + */ +bool32 EntityHasDuplicateID(Entity* ent); + +/** + * @brief Find an entity of same kind and id in list. + * @return Entity* First result or NULL if none found + */ +Entity* FindNextDuplicateID(Entity* ent, int listIndex); + +/** + * @brief Find Entity with full identifiers. + * @return Entity* First result or NULL if none found + */ +Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2); + #endif diff --git a/include/functions.h b/include/functions.h index 049f3bd1..5c62cced 100644 --- a/include/functions.h +++ b/include/functions.h @@ -119,7 +119,7 @@ extern u32 sub_08060354(void); extern void sub_08057E64(void); extern void sub_0809F814(u32); extern void sub_080300E8(void); -extern void sub_0801DA90(u32); +extern void DispReset(u32); extern void sub_08058D34(void); extern void sub_0807AABC(Entity*); extern void sub_08078A90(u32); diff --git a/include/main.h b/include/main.h index 32eceb8f..1653a40e 100644 --- a/include/main.h +++ b/include/main.h @@ -84,7 +84,6 @@ extern void sub_08056208(void); extern void sub_0804FFE4(void); extern void sub_080ADD30(void); -extern void ReadKeyInput(void); extern void DoSoftReset(void); extern void sub_08056260(void); extern void VBlankIntrWait(); diff --git a/include/textbox.h b/include/textbox.h index e6433cf2..817d50a0 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -56,10 +56,40 @@ typedef struct { extern struct_02022780 gUnk_02022780; static_assert(sizeof(struct_02022780) == 0xa8); +/** + * @brief Initialize the message system. + */ void MessageInitialize(void); + +/** + * @brief Show a message on screen. + * + * @param index u32 Message index + */ void ShowTextbox(u32 index); + +/** + * @brief Show a message at screen posiiton. + * + * @param index u32 Message index + * @param x u32 Screen x + * @param y u32 Screen y + */ void TextboxAtPosition(u32 index, u32 x, u32 y); + +/** + * @brief Show a message that attempts not to obscure the entity. + * + * @param index u32 Message index + * @param ent Entity* Your important entity + */ void TextboxNoOverlap(u32 index, Entity* ent); + +/** + * @brief Show a message that attempts not to obscure the camera target. + * + * @param index u32 Message index + */ void TextboxNoOverlapFollow(u32 index); #endif diff --git a/include/utils.h b/include/utils.h index 1703c991..040eacee 100644 --- a/include/utils.h +++ b/include/utils.h @@ -8,12 +8,57 @@ typedef struct { extern Input gInput; +/** + * Fill memory with 16 bit value. + */ void MemFill16(u32 value, void* dest, u32 size); + +/** + * Fill memory with 32 bit value. + */ void MemFill32(u32 value, void* dest, u32 size); + +/** + * Clear memory. + */ void MemClear(void* dest, u32 size); + +/** + * Copy memory. + */ void MemCopy(const void* src, void* dest, u32 size); +/** + * Refresh gInput from hardware registers. + */ void ReadKeyInput(void); void LoadPalettes(const u8*, int, int); void LoadPaletteGroup(u32 group); + +/** + * Allocate memory on heap. + * + * The heap size is 0x1000 bytes and should be used sparingly. + * It is customary for entities store the returned handle in their 'myHeap' field. + * + * @param size u32 Size to be allocated + * @return void* Pointer to allocated memory + */ +void* zMalloc(u32 size); + +/** + * Free memory from heap. + * + * The entity system will automatically free the address stored in the 'myHeap' field. + * + * @param ptr void* Handle to be freed + */ +void zFree(void* ptr); + +/** + * Reset All display hardware registers. + * + * @param updateHUD bool32 Request refresh of HUD layer (bg 0) + */ +void DispReset(bool32 updateHUD); diff --git a/src/code_08077B98.c b/src/code_08077B98.c index c3fbf5dd..856dc44b 100644 --- a/src/code_08077B98.c +++ b/src/code_08077B98.c @@ -82,7 +82,7 @@ void* sub_08077C54(UnkItemStruct* unk) { Entity* sub_08077C94(ItemBehavior* arg0, u32 arg1) { Entity* iVar1; - iVar1 = FindEntityInListBySubtype(8, gUnk_0811BE48[arg1].unk[3], 2); + iVar1 = FindEntityByID(8, gUnk_0811BE48[arg1].unk[3], 2); if (iVar1 == NULL) { return NULL; } diff --git a/src/createEntity.c b/src/createEntity.c index e83312a1..9948a780 100644 --- a/src/createEntity.c +++ b/src/createEntity.c @@ -2,8 +2,8 @@ // #include "entityData.h" // #include "global.h" -// extern Entity * FindEntityBySubtype(u32, u32); -// extern Entity * GetEmptyEntityByType(); +// extern Entity * DeepFindEntityByID(u32, u32); +// extern Entity * GetEmptyEntityByKind(); // extern void RegisterRoomEntity(Entity *, EntityData *); // extern u32 sub_0804AF0C(Entity *, EntityData *); // extern void sub_08016A30(Entity *); @@ -17,11 +17,11 @@ // type = param_1->entityType & 15; // if (((param_1->field_0x1 & 240) == 80) && -// (preexisting = FindEntityBySubtype(type,param_1->entitySubtype), preexisting != NULL)) { +// (preexisting = DeepFindEntityByID(type,param_1->entitySubtype), preexisting != NULL)) { // entity = NULL; // } // else { -// entity = GetEmptyEntityByType(); //Get empty entity +// entity = GetEmptyEntityByKind(); //Get empty entity // if (entity != NULL) { // (entity->entityType).type = type; // (entity->entityType).subtype = param_1->entitySubtype; diff --git a/src/debugScreen.c b/src/debugScreen.c index c5fcd45f..bc034e8e 100644 --- a/src/debugScreen.c +++ b/src/debugScreen.c @@ -16,7 +16,7 @@ void HandleDebugTextScreen() { } void sub_0805FA04(void) { - sub_0801DA90(1); + DispReset(1); MemClear(&gBG0Buffer, sizeof(BGBuffer)); MemClear(&gBG3Buffer, 0x1000); gScreen.lcd.displayControl = 0x940; diff --git a/src/enemy/miniSlime.c b/src/enemy/miniSlime.c index baa1e04e..68c1303a 100644 --- a/src/enemy/miniSlime.c +++ b/src/enemy/miniSlime.c @@ -6,7 +6,6 @@ void sub_08045374(Entity*); -//extern u32 FixedDiv(u32, u32); extern void sub_080452E4(); extern void ReplaceMonitoredEntity(Entity*, Entity*); diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 9d7520e1..3eeda562 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -10,7 +10,7 @@ extern void sub_0800449C(Entity*, u32); extern u32 sub_08049F1C(Entity*, Entity*, u32); extern u32 PlayerInRange(Entity*, u32, u32); extern void sub_080AEFB4(Entity*); -extern Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex); +extern Entity* FindNextDuplicateID(Entity* ent, int listIndex); void sub_080249F4(Entity*); void sub_08024940(Entity*); @@ -666,7 +666,7 @@ bool32 sub_08024B38(Entity* this) { } } - ent = FindEntityInListBySubtype(8, 2, 2); + ent = FindEntityByID(8, 2, 2); if (ent) { do { if (ent->action != 2 && ent->height.HALF.HI == 0 && sub_08049F1C(this, ent, 0xa0)) { @@ -676,14 +676,14 @@ bool32 sub_08024B38(Entity* this) { this->field_0x82.HALF.HI &= ~0x40; break; } - } while (ent = FindNextEntityOfSameSubtype(ent, 2), ent != NULL); + } while (ent = FindNextDuplicateID(ent, 2), ent != NULL); } if (iVar4 != 0) { return iVar4; } - ent = FindEntityInListBySubtype(6, 5, 6); + ent = FindEntityByID(6, 5, 6); if (ent) { do { if (ent->action == 1 && sub_08049F1C(this, ent, 0xa0)) { @@ -693,7 +693,7 @@ bool32 sub_08024B38(Entity* this) { this->field_0x82.HALF.HI &= ~0x40; break; } - } while (ent = FindNextEntityOfSameSubtype(ent, 6), ent != NULL); + } while (ent = FindNextDuplicateID(ent, 6), ent != NULL); } if (iVar4 == 0) { diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 95112c2c..fc7714e3 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -12,7 +12,6 @@ typedef struct { void sub_08044FF8(Entity*); void sub_08045178(Entity*, Entity*, int, int); -//extern u32 FixedDiv(u32, u32); extern void sub_0804A4E4(Entity*, Entity*); extern u32 sub_080002CC(Entity*, s32, s32); diff --git a/src/entity.c b/src/entity.c index 82f6a058..acc2795c 100644 --- a/src/entity.c +++ b/src/entity.c @@ -1,4 +1,5 @@ #include "global.h" +#include "area.h" #include "entity.h" #include "utils.h" #include "script.h" @@ -28,9 +29,9 @@ OtherEntity* GetEmptyManager(void); typedef void* (*Getter)(void); -void* GetEmptyEntityByType(int type) { +void* GetEmptyEntityByKind(u32 kind) { Getter getter = NULL; - if (type == 9) { + if (kind == MANAGER) { getter = (Getter)GetEmptyManager; } else { getter = (Getter)GetEmptyEntity; @@ -61,7 +62,7 @@ typedef void (*Deleter)(void*); void DeleteEntityAny(Entity* ent) { Deleter deleter = NULL; - if (ent->kind == 9) { + if (ent->kind == MANAGER) { deleter = (Deleter)DeleteManager; } else { deleter = (Deleter)DeleteEntity; @@ -78,7 +79,6 @@ extern void sub_0805EC60(); extern void sub_08017744(); extern void sub_0805E92C(); extern void UnloadHitbox(); -extern void sub_0801DA0C(); extern void sub_0804AA1C(); void UnlinkEntity(); @@ -94,9 +94,9 @@ void DeleteEntity(Entity* ent) { sub_0805E92C(ent); UnloadCutsceneData(ent); UnloadHitbox(ent); - sub_0801DA0C(ent->myHeap); + zFree(ent->myHeap); ent->myHeap = NULL; - if (ent->kind == 3) { + if (ent->kind == ENEMY) { sub_0804AA1C(ent); } ent->flags = ent->flags & 0x7f; @@ -171,8 +171,6 @@ void DeleteManager(OtherEntity* ent) { gManagerCount--; } -#include "area.h" - void sub_0805E92C(u32 param_1) { if (param_1 == gArea.unk2) { gArea.unk2 = 0; @@ -209,7 +207,7 @@ void sub_0805E9A8(void) { list = &gEntityLists[0]; do { for (i = list->first; (u32)i != (u32)list; i = i->next) { - i->flags &= 0xfd; + i->flags &= ~2; if ((i->flags & 0x20) == 0) { i->flags |= 0x10; } @@ -242,7 +240,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) { entity->prev = list->last; list->last->next = entity; list->last = entity; - if (entity->kind != 9) { + if (entity->kind != MANAGER) { entity->spritePriority.b0 = 4; gEntCount++; } else { @@ -251,7 +249,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) { sub_0805E374(entity); } -void PrependEntityToList(Entity* entity, int listIndex) { +void PrependEntityToList(Entity* entity, u32 listIndex) { LinkedList* list; UnlinkEntity(entity); @@ -270,7 +268,7 @@ void UnlinkEntity(Entity* ent) { ent->next->prev = ent->prev; } -bool32 DoesSimilarEntityExist(Entity* ent) { +bool32 EntityHasDuplicateID(Entity* ent) { Entity* i; LinkedList* list; @@ -286,31 +284,31 @@ bool32 DoesSimilarEntityExist(Entity* ent) { return FALSE; } -Entity* FindEntityInListBySubtype(u32 type, u32 subtype, u32 listIndex) { +Entity* FindEntityByID(u32 kind, u32 id, u32 listIndex) { Entity* it; LinkedList* list; list = &gEntityLists[listIndex]; for (it = list->first; (u32)it != (u32)list; it = it->next) { - if (type == it->kind && subtype == it->id) + if (kind == it->kind && id == it->id) return it; } return NULL; } -Entity* FindEntityInListByForm(u32 type, u32 subtype, u32 listIndex, u32 form, u32 parameter) { +Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2) { Entity* i; LinkedList* list; list = &gEntityLists[listIndex]; for (i = list->first; (u32)i != (u32)list; i = i->next) { - if (type == i->kind && subtype == i->id && form == i->type && parameter == i->type2) + if (kind == i->kind && id == i->id && type == i->type && type2 == i->type2) return i; } return NULL; } -Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex) { +Entity* FindNextDuplicateID(Entity* ent, int listIndex) { Entity* i; LinkedList* list; @@ -322,14 +320,14 @@ Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex) { return NULL; } -Entity* FindEntityBySubtype(int type, int subtype) { +Entity* DeepFindEntityByID(u32 kind, u32 id) { Entity* i; LinkedList* list; list = &gEntityLists[0]; do { for (i = (Entity*)list->first; (u32)i != (u32)list; i = i->next) { - if (type == i->kind && (subtype == i->id)) + if (kind == i->kind && (id == i->id)) return i; } } while (++list < &gEntityLists[9]); @@ -346,7 +344,7 @@ void DeleteAllEnemies(void) { do { for (ent = list->first; (u32)ent != (u32)list; ent = next) { next = ent->next; - if (ent->kind == 3) + if (ent->kind == ENEMY) DeleteEntity(ent); } } while (++list < &gEntityLists[9]); diff --git a/src/fileScreen.c b/src/fileScreen.c index 3f0bec26..068bb27b 100644 --- a/src/fileScreen.c +++ b/src/fileScreen.c @@ -189,7 +189,7 @@ void HandleChooseFileScreen(void) { static void HandleFileScreenEnter(void) { u32 i; - sub_0801DA90(1); + DispReset(1); sub_080A3210(); MemClear((void*)VRAM, 0x80); // clear palettes MessageInitialize(); diff --git a/src/intro.c b/src/intro.c index 899122dc..c8648715 100644 --- a/src/intro.c +++ b/src/intro.c @@ -74,7 +74,7 @@ void HandleIntroScreen(void) { if (gFadeControl.active) { return; } - sub_0801DA90(1); + DispReset(1); gMain.funcIndex = 1; break; } @@ -87,7 +87,7 @@ static void HandleNintendoCapcomLogos(void) { advance = GetAdvanceState(); if (gIntroState.state == 0) { - sub_0801DA90(1); + DispReset(1); gIntroState.state = 1; gIntroState.timer = 120; LoadGfxGroup(16); diff --git a/src/main.c b/src/main.c index 9e60f6f4..d7d8203d 100644 --- a/src/main.c +++ b/src/main.c @@ -107,7 +107,7 @@ static void sub_08055F70(void) { MemCopy(gUnk_080B2CD8_3, gUnk_02038560, size); } - sub_0801DA90(0); + DispReset(0); sub_08016B34(); } diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 2707be06..e3d97ea7 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -86,7 +86,7 @@ void sub_0805A370(Manager15* this) { void sub_0805A394(Manager15* this) { Entity* ent; - if ((ent = FindEntityInListBySubtype(0x3, 0x13, 0x4))) { + if ((ent = FindEntityByID(0x3, 0x13, 0x4))) { if (ent->type != 4) { return; } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 5b5aa0fa..3123b036 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -56,7 +56,7 @@ void sub_0806CF30(Entity* this) { void sub_0806D00C(Entity* this) { Entity* pEVar1; - pEVar1 = FindEntityInListByForm(7, 76, 7, 0, 0); + pEVar1 = FindEntity(7, 76, 7, 0, 0); if (pEVar1 != NULL) { this->parent = pEVar1; } diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 27d0df3d..e42500e8 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -225,7 +225,7 @@ void sub_08060318(void) { int i; for (i = 2; i >= 0; i--) { - ent = FindEntityInListBySubtype(8, 2, 2); + ent = FindEntityByID(8, 2, 2); if (ent != NULL) { CreateDust(ent); DeleteEntity(ent); diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index b4a44355..5329bd15 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -84,7 +84,7 @@ void sub_08069660(Entity* this) { void sub_08069684(void) { Manager* mgr; - if (FindEntityInListBySubtype(9, 0x31, 8) == NULL) { + if (FindEntityByID(9, 0x31, 8) == NULL) { mgr = GetEmptyManager(); if (mgr != NULL) { mgr->type = 9; diff --git a/src/npc/malon.c b/src/npc/malon.c index 0799e8b3..64febefe 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -57,12 +57,12 @@ void sub_08065900(Entity* this) { void sub_08065914(Entity* this) { Entity* target; - target = FindEntityInListBySubtype(7, 0x1F, 7); + target = FindEntityByID(7, 0x1F, 7); if (target != NULL) { PositionRelative(this, target, 0x180000, -0x10000); target->parent = this; } - target = FindEntityInListBySubtype(7, 0x20, 7); + target = FindEntityByID(7, 0x20, 7); if (target != NULL) { PositionRelative(this, target, 0x280000, 0); target->parent = this; diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 88fb53c3..916bb4cd 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -5,7 +5,7 @@ #include "flags.h" #include "script.h" -extern Entity* FindEntityBySubtype(u32, u32); +extern Entity* DeepFindEntityByID(u32, u32); void sub_08068680(Entity*, Entity*); void sub_08068694(Entity*, Entity*); extern Entity* GetEntityByType(u32, u32); @@ -31,7 +31,7 @@ void sub_08066CF8(Entity* this) { } void sub_08066D04(Entity* this) { - this->parent = FindEntityBySubtype(7, 0x2E); + this->parent = DeepFindEntityByID(7, 0x2E); } void sub_08066D14(Entity* this, ScriptExecutionContext* context) { @@ -86,7 +86,7 @@ void sub_08066D94(Entity* this) { void sub_08066DE4(Entity* this) { Entity* pEVar1; - pEVar1 = FindEntityBySubtype(7, 0x2E); + pEVar1 = DeepFindEntityByID(7, 0x2E); if (pEVar1 != NULL) { CopyPosition(this, pEVar1); sub_080686C4(this, pEVar1); diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index 3a0157fc..3ec961eb 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -504,7 +504,7 @@ void sub_080873FC(void) { SoundReq(0xf7); gRoomControls.cameraTarget = NULL; - while (ent = FindEntityInListBySubtype(0x6, 0x1b, 0x6), ent != NULL) { + while (ent = FindEntityByID(0x6, 0x1b, 0x6), ent != NULL) { DeleteEntity(ent); } } @@ -533,7 +533,7 @@ void sub_08087424(Entity* this, ScriptExecutionContext* context) { void sub_0808747C(Entity* this, ScriptExecutionContext* context) { u32 iVar1 = 0; - iVar1 = (u32)FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0); + iVar1 = (u32)FindEntity(0x6, 0xf, 0x6, 0xb, 0x0); if (iVar1 != 0) { iVar1 = 1; } diff --git a/src/player.c b/src/player.c index 1e0d32ae..d34024b2 100644 --- a/src/player.c +++ b/src/player.c @@ -92,7 +92,7 @@ void PlayerInit(Entity* this) { sub_08079938(); gPlayerState.field_0xa8 = 7; sub_0807ACCC(this); - ent = FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0); + ent = FindEntity(0x6, 0xf, 0x6, 0xb, 0x0); if (ent != NULL) { DeleteEntity(ent); } diff --git a/src/room.c b/src/room.c index 9c94aa9f..e196f379 100644 --- a/src/room.c +++ b/src/room.c @@ -2235,7 +2235,7 @@ void sub_0804CD48(void) { gFadeControl.active = 0; gUsedPalettes = 0; *(u16*)0x5000000 = 0x7fff; - sub_0801DA90(1); + DispReset(1); } if (CheckGlobalFlag(LV1_CLEAR)) { LoadRoomEntityList(&gUnk_080DF94C); diff --git a/src/sub_0807B820.c b/src/sub_0807B820.c index f26e6974..fabdc8d9 100644 --- a/src/sub_0807B820.c +++ b/src/sub_0807B820.c @@ -41,7 +41,6 @@ void sub_0807B8A8(u32 param_1) { SetTileType(642, param_1 + 1, 1); } - void sub_0807B930(int param_1) { SetTileType(652, param_1 + -65, 1); SetTileType(659, param_1 + -65, 2);