mirror of
https://github.com/zeldaret/tmc
synced 2026-09-02 02:02:30 -04:00
more entity stuff
This commit is contained in:
+327
-12
@@ -1,6 +1,13 @@
|
||||
#include "global.h"
|
||||
#include "entity.h"
|
||||
|
||||
typedef struct OtherEntity {
|
||||
struct OtherEntity* prev;
|
||||
struct OtherEntity* next;
|
||||
Entity* field_0x8;
|
||||
u8 field_0xC[0x34];
|
||||
} OtherEntity;
|
||||
|
||||
extern Entity gUnk_030011E8[7];
|
||||
|
||||
Entity* sub_0805E744(void)
|
||||
@@ -19,16 +26,18 @@ Entity* sub_0805E744(void)
|
||||
}
|
||||
|
||||
extern Entity* GetEmptyEntity();
|
||||
extern Entity* sub_0805E8D4();
|
||||
OtherEntity* sub_0805E8D4();
|
||||
|
||||
Entity* sub_0805E768(int type)
|
||||
typedef void* (*Getter)(void);
|
||||
|
||||
void* sub_0805E768(int type)
|
||||
|
||||
{
|
||||
Entity* (*getter)(void) = NULL;
|
||||
Getter getter = NULL;
|
||||
if (type == 9) {
|
||||
getter = sub_0805E8D4;
|
||||
getter = (Getter)sub_0805E8D4;
|
||||
} else {
|
||||
getter = GetEmptyEntity;
|
||||
getter = (Getter)GetEmptyEntity;
|
||||
}
|
||||
return getter();
|
||||
}
|
||||
@@ -41,7 +50,7 @@ typedef struct {
|
||||
|
||||
extern struct_03003DD0 gUnk_03003DD0;
|
||||
extern u32 _call_via_r0(u32*);
|
||||
extern void gUnk_03005F24();
|
||||
extern u32 gUnk_03005F24;
|
||||
extern void sub_0805E79C(Entity*);
|
||||
|
||||
void DeleteThisEntity(void)
|
||||
@@ -52,17 +61,19 @@ void DeleteThisEntity(void)
|
||||
return;
|
||||
}
|
||||
|
||||
extern void DeleteEntity(Entity*);
|
||||
extern void sub_0805E900(Entity*);
|
||||
void DeleteEntity(Entity*);
|
||||
void sub_0805E900(OtherEntity*);
|
||||
|
||||
typedef void (*Deleter)(void*);
|
||||
|
||||
void sub_0805E79C(Entity* ent)
|
||||
|
||||
{
|
||||
void (*deleter)(Entity*) = NULL;
|
||||
Deleter deleter = NULL;
|
||||
if (ent->entityType.type == 9) {
|
||||
deleter = sub_0805E900;
|
||||
deleter = (Deleter)sub_0805E900;
|
||||
} else {
|
||||
deleter = DeleteEntity;
|
||||
deleter = (Deleter)DeleteEntity;
|
||||
}
|
||||
deleter(ent);
|
||||
}
|
||||
@@ -109,7 +120,7 @@ void DeleteEntity(Entity* ent)
|
||||
ent->currentHealth = 0;
|
||||
sub_0805EA98(ent);
|
||||
ent->field_0x4 = NULL;
|
||||
ent->field_0x0 = (u32*)0xffffffff;
|
||||
ent->field_0x0 = (Entity*)0xffffffff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,3 +139,307 @@ void sub_0805E84C(void)
|
||||
} while (pEVar1 < (&gLinkEntity + 80));
|
||||
return;
|
||||
}
|
||||
|
||||
extern u8 gUnk_03003DBC;
|
||||
|
||||
void sub_0805E870(Entity* ent)
|
||||
|
||||
{
|
||||
DmaClear32(3, ent, sizeof(Entity));
|
||||
gUnk_03003DBC--;
|
||||
}
|
||||
|
||||
typedef struct struct_03003D70 {
|
||||
void* field_0x0;
|
||||
void* field_0x4;
|
||||
} struct_03003D70;
|
||||
|
||||
extern struct_03003D70 gUnk_03003D70[9];
|
||||
extern EntityType gUnk_03003DB8;
|
||||
|
||||
void sub_0805E89C(void)
|
||||
|
||||
{
|
||||
Entity* pEVar1;
|
||||
Entity* next;
|
||||
struct_03003D70* it;
|
||||
|
||||
it = gUnk_03003D70;
|
||||
if (it->field_0x4 != 0) {
|
||||
do {
|
||||
next = it->field_0x4;
|
||||
while (pEVar1 = next, (u32)pEVar1 != (u32)it) {
|
||||
next = pEVar1->field_0x4;
|
||||
sub_0805E79C(pEVar1);
|
||||
}
|
||||
it++;
|
||||
} while (it < (gUnk_03003D70 + 9));
|
||||
sub_0805E84C();
|
||||
}
|
||||
}
|
||||
|
||||
extern OtherEntity gUnk_02033290;
|
||||
|
||||
OtherEntity* sub_0805E8D4(void)
|
||||
|
||||
{
|
||||
OtherEntity* it;
|
||||
for (it = &gUnk_02033290; it < (&gUnk_02033290 + 32); it++) {
|
||||
if (it->prev == 0) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern void _DmaZero(void*, u32);
|
||||
extern u8 gUnk_020354B4;
|
||||
|
||||
void sub_0805E900(OtherEntity* ent)
|
||||
|
||||
{
|
||||
if (!ent->next)
|
||||
return;
|
||||
|
||||
sub_0805E92C(ent);
|
||||
sub_0805EA98(ent);
|
||||
_DmaZero(ent, 0x40);
|
||||
gUnk_020354B4--;
|
||||
}
|
||||
|
||||
#include "area.h"
|
||||
|
||||
void sub_0805E92C(u32 param_1)
|
||||
|
||||
{
|
||||
if (param_1 == gArea.unk2) {
|
||||
gArea.unk2 = 0;
|
||||
gArea.unk3 = 0;
|
||||
gArea.unk4 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern Entity gUnk_020369F0;
|
||||
extern void sub_0801D66C(void* dst, void* src, size_t size); // dma copy
|
||||
extern void sub_0805E98C(void);
|
||||
|
||||
void sub_0805E958(void)
|
||||
|
||||
{
|
||||
sub_0801D66C(&gUnk_03003D70, &gUnk_020369F0, 0x48);
|
||||
sub_0805E98C();
|
||||
}
|
||||
|
||||
void sub_0805E974(void)
|
||||
|
||||
{
|
||||
sub_0801D66C(&gUnk_020369F0, &gUnk_03003D70, 0x48);
|
||||
}
|
||||
|
||||
void sub_0805E98C(void)
|
||||
|
||||
{
|
||||
struct_03003D70* it;
|
||||
|
||||
for (it = gUnk_03003D70; it < &gUnk_03003D70[9]; it++) {
|
||||
it->field_0x0 = it;
|
||||
it->field_0x4 = (Entity*)it;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805E9A8(void)
|
||||
|
||||
{
|
||||
Entity* entry;
|
||||
struct_03003D70* it;
|
||||
|
||||
it = gUnk_03003D70;
|
||||
do {
|
||||
for (entry = (Entity*)it->field_0x4; (u32)entry != (u32)it; entry = entry->field_0x4) {
|
||||
entry->flags &= 0xfd;
|
||||
if ((entry->flags & 0x20) == 0) {
|
||||
entry->flags |= 0x10;
|
||||
}
|
||||
}
|
||||
it++;
|
||||
} while (it < (gUnk_03003D70 + 9));
|
||||
}
|
||||
|
||||
void sub_0805E9F4(void)
|
||||
|
||||
{
|
||||
Entity* pEVar1;
|
||||
Entity* next;
|
||||
struct_03003D70* it;
|
||||
|
||||
it = gUnk_03003D70;
|
||||
do {
|
||||
next = it->field_0x4;
|
||||
while (pEVar1 = next, (u32)pEVar1 != (u32)it) {
|
||||
next = pEVar1->field_0x4;
|
||||
if ((pEVar1->flags & 0x10) != 0) {
|
||||
sub_0805E79C(pEVar1);
|
||||
}
|
||||
}
|
||||
it++;
|
||||
} while (it < (gUnk_03003D70 + 9));
|
||||
}
|
||||
|
||||
extern void sub_0805E374(Entity*);
|
||||
|
||||
void sub_0805EA2C(Entity* ent, int kind)
|
||||
|
||||
{
|
||||
Entity* pEVar1;
|
||||
struct_03003D70* pEVar2;
|
||||
|
||||
pEVar2 = (gUnk_03003D70 + kind);
|
||||
ent->field_0x4 = (Entity*)pEVar2;
|
||||
pEVar1 = pEVar2->field_0x0;
|
||||
ent->field_0x0 = pEVar1;
|
||||
pEVar1->field_0x4 = ent;
|
||||
pEVar2->field_0x0 = ent;
|
||||
if ((ent->entityType).type != 9) {
|
||||
ent->spritePriority.b0 = 4;
|
||||
gUnk_03003DBC++;
|
||||
} else {
|
||||
gUnk_020354B4++;
|
||||
}
|
||||
sub_0805E374(ent);
|
||||
}
|
||||
|
||||
void sub_0805EA78(Entity* ent, int kind)
|
||||
|
||||
{
|
||||
struct_03003D70* it;
|
||||
|
||||
sub_0805EA98(ent);
|
||||
it = &gUnk_03003D70[kind];
|
||||
ent->field_0x0 = (Entity*)it;
|
||||
ent->field_0x4 = it->field_0x4;
|
||||
((Entity*)it->field_0x4)->field_0x0 = ent;
|
||||
it->field_0x4 = ent;
|
||||
}
|
||||
|
||||
void sub_0805EA98(Entity* ent)
|
||||
|
||||
{
|
||||
if (ent == gUnk_03003DD0.field_0x8) {
|
||||
gUnk_03003DD0.field_0x8 = ent->field_0x0;
|
||||
}
|
||||
ent->field_0x0->field_0x4 = ent->field_0x4;
|
||||
ent->field_0x4->field_0x0 = ent->field_0x0;
|
||||
}
|
||||
|
||||
int sub_0805EABC(Entity* ent)
|
||||
|
||||
{
|
||||
Entity* psVar1;
|
||||
struct_03003D70 *it, *end;
|
||||
|
||||
it = gUnk_03003D70;
|
||||
end = (gUnk_03003D70 + 9);
|
||||
do {
|
||||
psVar1 = (Entity*)it->field_0x4;
|
||||
while ((u32)psVar1 != (u32)it) {
|
||||
if ((u32)psVar1 != (u32)ent && psVar1->entityType.type == ent->entityType.type &&
|
||||
psVar1->entityType.subtype == ent->entityType.subtype) {
|
||||
return 1;
|
||||
}
|
||||
psVar1 = psVar1->field_0x4;
|
||||
}
|
||||
it++;
|
||||
} while (it < end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Entity* sub_0805EB00(int type, int subtype, int kind)
|
||||
|
||||
{
|
||||
Entity* it;
|
||||
struct_03003D70* node;
|
||||
|
||||
node = &gUnk_03003D70[kind];
|
||||
it = (Entity*)node->field_0x4;
|
||||
while ((u32)it != (u32)node) {
|
||||
if ((type == (it->entityType).type) && (subtype == (it->entityType).subtype))
|
||||
return it;
|
||||
it = it->field_0x4;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Entity* sub_0805EB2C(int type, int subtype, int kind, int form, int parameter)
|
||||
|
||||
{
|
||||
Entity* it;
|
||||
struct_03003D70* node;
|
||||
|
||||
node = &gUnk_03003D70[kind];
|
||||
it = (Entity*)node->field_0x4;
|
||||
while ((u32)it != (u32)node) {
|
||||
if (type == it->entityType.type && subtype == it->entityType.subtype && form == it->entityType.form &&
|
||||
parameter == it->entityType.parameter)
|
||||
return it;
|
||||
it = it->field_0x4;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Entity* sub_0805EB64(Entity* ent, int kind)
|
||||
|
||||
{
|
||||
Entity* it;
|
||||
struct_03003D70* end;
|
||||
|
||||
end = &gUnk_03003D70[kind];
|
||||
it = ent->field_0x4;
|
||||
while ((u32)it != (u32)end) {
|
||||
if (it->entityType.type == ent->entityType.type && it->entityType.subtype == ent->entityType.subtype)
|
||||
return it;
|
||||
it = it->field_0x4;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Entity* sub_0805EB9C(int type, int subtype)
|
||||
|
||||
{
|
||||
Entity* it2;
|
||||
struct_03003D70 *it, *end;
|
||||
|
||||
it = gUnk_03003D70;
|
||||
end = (gUnk_03003D70 + 9);
|
||||
do {
|
||||
it2 = (Entity*)it->field_0x4;
|
||||
while ((u32)it2 != (u32)it) {
|
||||
if ((type == (it2->entityType).type) && (subtype == (it2->entityType).subtype))
|
||||
return it2;
|
||||
it2 = it2->field_0x4;
|
||||
}
|
||||
it++;
|
||||
} while (it < end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sub_0805EBCC(void)
|
||||
|
||||
{
|
||||
Entity* pEVar1;
|
||||
Entity* next;
|
||||
struct_03003D70* it;
|
||||
|
||||
it = gUnk_03003D70;
|
||||
do {
|
||||
next = it->field_0x4;
|
||||
while (pEVar1 = next, (u32)pEVar1 != (u32)it) {
|
||||
next = pEVar1->field_0x4;
|
||||
if (pEVar1->entityType.type == 3)
|
||||
DeleteEntity(pEVar1);
|
||||
}
|
||||
it++;
|
||||
} while (it < (gUnk_03003D70 + 9));
|
||||
sub_0805E84C();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user