diff options
| author | theo3 <arisstephenson2@gmail.com> | 2021-11-11 21:18:48 -0800 |
|---|---|---|
| committer | theo3 <arisstephenson2@gmail.com> | 2021-11-11 21:18:48 -0800 |
| commit | fddb4abd534ef1ef623cb044bc97c45713fbcfd1 (patch) | |
| tree | 4668fa2e16aa441da3c2f06b8d9b54c9762c2523 /src/npc.c | |
| parent | 313cc336f21fcf81e3e336b4fe45ca5053771f93 (diff) | |
move entity update functions
Diffstat (limited to 'src/npc.c')
| -rw-r--r-- | src/npc.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include "global.h" #include "entity.h" +#include "room.h" #include "npc.h" //clang-format off @@ -135,3 +136,36 @@ void (*const gNPCFunctions[][3])(Entity* ent) = { }; //clang-format on const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 }; + +extern u8 gUnk_020342F8; +typedef struct { + u16 unk0; + u16 unk1; + u16 x; + u16 y; +} NPCStruct; +extern NPCStruct gUnk_02031EC0[100]; + +void InitNPC(Entity*); +u32 ReadBit(void*, u32); + +// regalloc +NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) { + if ((this->currentHealth & 0x7f) && !ReadBit(&gUnk_020342F8, this->currentHealth - 1)) + DeleteThisEntity(); + if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0) + InitNPC(this); + if (!CheckDontUpdate(this)) + gNPCFunctions[this->id][0](this); + if (this->next != NULL) { + if (gNPCFunctions[this->id][1] != NULL) + gNPCFunctions[this->id][1](this); + if ((this->currentHealth & 0x7f) != 0) { + u32 temp = this->currentHealth & 0x7f; + gUnk_02031EC0[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.roomOriginX; + gUnk_02031EC0[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.roomOriginY; + } + DrawEntity(this); + } +} +END_NONMATCH |
