fix entity.c search prototypes, add documentation

This commit is contained in:
theo3 2021-03-21 22:00:07 -07:00
parent bd50d449de
commit f0d610f385
56 changed files with 266 additions and 156 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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();

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -6,7 +6,6 @@
void sub_08045374(Entity*);
//extern u32 FixedDiv(u32, u32);
extern void sub_080452E4();
extern void ReplaceMonitoredEntity(Entity*, Entity*);

View File

@ -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) {

View File

@ -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);

View File

@ -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]);

View File

@ -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();

View File

@ -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);

View File

@ -107,7 +107,7 @@ static void sub_08055F70(void) {
MemCopy(gUnk_080B2CD8_3, gUnk_02038560, size);
}
sub_0801DA90(0);
DispReset(0);
sub_08016B34();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);