summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2021-12-19 17:57:42 -0800
committertheo3 <arisstephenson2@gmail.com>2021-12-19 17:57:42 -0800
commit3c4e1762d9aefa7840d3e6ec8343e551e2e6607c (patch)
tree16c9b2ca2b824feccc9720de5398669913a32302 /src
parent227703e4966071b98af129185ed7d70c782ceed2 (diff)
util files
Diffstat (limited to 'src')
-rw-r--r--src/coord.c251
-rw-r--r--src/createEntity.c50
-rw-r--r--src/createNPC.c67
-rw-r--r--src/enemyUtils.c (renamed from src/enemyInit.c)0
-rw-r--r--src/npcUtils.c312
-rw-r--r--src/objectUtils.c (renamed from src/createObject.c)0
-rw-r--r--src/player.c1
-rw-r--r--src/playerItemUtils.c106
-rw-r--r--src/projectileUtils.c (renamed from src/projectileInit.c)0
-rw-r--r--src/room.c11
-rw-r--r--src/roomInit.c4
11 files changed, 669 insertions, 133 deletions
diff --git a/src/coord.c b/src/coord.c
index 4beb4c9b..3fe17296 100644
--- a/src/coord.c
+++ b/src/coord.c
@@ -1,10 +1,261 @@
+#include "area.h"
+#include "player.h"
#include "global.h"
#include "entity.h"
#include "coord.h"
+#include "utils.h"
+#include "audio.h"
+#include "room.h"
+#include "functions.h"
extern u8 gUnk_08114F78[];
extern u8 gUnk_08114F80[];
+typedef struct {
+ u32 _0;
+ u16 _4[0x1000];
+ u8 _2004[0x2000];
+} struct_02025EB0;
+extern struct_02025EB0 gUnk_02025EB0;
+
+extern s8 gUnk_08126EE4[];
+extern u8 gUnk_08114F38[];
+extern u8 gUnk_08114F58[];
+
+void sub_080027EA(Entity*, u32, u32);
+void sub_0806F5BC(Entity*, u32, u32);
+u32 sub_0806F58C(Entity*, Entity*);
+u32 sub_0806FCA0(Entity*, Entity*);
+
+void sub_0806F364(void) {
+ gArea.filler[2] ^= 0x80;
+ MemClear(&gArea.filler5[(gArea.filler[2] + 7) / 8], 16);
+}
+
+void sub_0806F38C(void) {
+ gArea.filler[2] ^= 0x80;
+}
+
+u32 sub_0806F39C(Entity* ent) {
+ s32 dist;
+
+ if (gPlayerEntity.animationState & 2) {
+ dist = ent->x.HALF.HI - gPlayerEntity.x.HALF.HI;
+ } else {
+ dist = ent->y.HALF.HI - gPlayerEntity.y.HALF.HI;
+ }
+ if (dist < 0) {
+ dist = -dist;
+ }
+
+ if (dist > 64) {
+ sub_080027EA(&gPlayerEntity, ent->speed, ent->direction);
+ return 1;
+ }
+ return 0;
+}
+
+u32 sub_0806F3E4(Entity* ent) {
+ Entity tmp_ent;
+ s8* p;
+
+ if ((gPlayerState.field_0x1c & 0x7F) != 1)
+ return 0;
+ switch (gPlayerState.field_0x1d[0]) {
+ case 1:
+ ent->field_0x46 += 64;
+ break;
+ case 2:
+ ent->field_0x46 += 128;
+ break;
+ case 3:
+ ent->field_0x46 += 192;
+ break;
+ }
+ if (ent->field_0x46 > 0x500)
+ ent->field_0x46 = 0x500;
+ p = &gUnk_08126EE4[gPlayerEntity.animationState & 0xE];
+ tmp_ent.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI;
+ tmp_ent.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI;
+ sub_0806F5BC(ent, ent->field_0x46, GetFacingDirection(ent, &tmp_ent));
+ if (sub_0800419C(&tmp_ent, ent, 4, 4)) {
+ u32 state = ent->field_0x1c & 0xF;
+ if (state == 2) {
+ Entity* item;
+ ent->subAction = 3;
+ (Entity*)gPlayerEntity.field_0x70.WORD = ent;
+ gPlayerState.field_0x1c = 7;
+ item = CreatePlayerItem(0x11, 0, 0, 0);
+ if (item != NULL) {
+ item->child = ent;
+ ent->parent = item;
+ }
+ SoundReq(SFX_ED);
+ } else if (state == 1) {
+ gPlayerState.field_0x2c[10] = 1;
+ SoundReq(SFX_EF);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void sub_0806F4E8(Entity* ent) {
+ switch (ent->field_0x1d & 3) {
+ case 2:
+ ent->spriteOffsetX = -2;
+ break;
+ case 1:
+ ent->spriteOffsetX = 0;
+ break;
+ case 0:
+ ent->spriteOffsetX = 2;
+ break;
+ case 3:
+ ent->spriteOffsetX = 0;
+ break;
+ }
+}
+
+u32 sub_0806F520(Entity* ent) {
+ if (ent->bitfield == 0x93)
+ return 1;
+ ent->field_0x3a &= ~4;
+ ent->spriteOffsetY = 0;
+ return 0;
+}
+
+u32 sub_0806F548(Entity* a, Entity* b, u32 x, u32 y) {
+ if (EntityInRectRadius(a, b, x, y))
+ return sub_0806F58C(a, b);
+ return 0;
+}
+
+u32 sub_0806F564(Entity* ent, u32 b, u32 c) {
+ u32 tmp = sub_080045D4(ent->x.HALF.HI, ent->y.HALF.HI, b, c);
+ return ent->animationState == sub_0806F5A4(tmp);
+}
+
+u32 sub_0806F58C(Entity* a, Entity* b) {
+ return a->animationState >> 1 == sub_0806FCA0(a, b);
+}
+
+u32 sub_0806F5A4(u32 idx) {
+ return gUnk_08114F38[idx];
+}
+
+u32 sub_0806F5B0(u32 idx) {
+ return gUnk_08114F58[idx];
+}
+
+void sub_0806F5BC(Entity* ent, u32 a, u32 b) {
+ if ((b & 0x80) == 0) {
+ u32 m1 = b;
+
+ ent->x.WORD += FixedDiv(FixedMul(gSineTable[m1 *= 8], a), 256) << 8;
+ ent->y.WORD -= FixedDiv(FixedMul(gSineTable[m1 + 64], a), 256) << 8;
+ }
+}
+
+void sub_0806F62C(Entity* ent, u32 a, u32 b) {
+ ent->x.WORD += FixedDiv(FixedMul(gSineTable[(u8)b], a), 256) << 8;
+ ent->y.WORD -= FixedDiv(FixedMul(gSineTable[(u8)b + 64], a), 256) << 8;
+}
+
+void sub_0806F69C(Entity* ent) {
+ if ((ent->direction & 0x80) == 0) {
+ ent->x.WORD += FixedDiv(FixedMul(gSineTable[ent->direction * 8], ent->speed), 256) << 8;
+ ent->y.WORD -= FixedDiv(FixedMul(gSineTable[ent->direction * 8 + 64], ent->speed), 256) << 8;
+ }
+}
+
+void sub_0806F704(Entity* ent, u32 a2) {
+ ent->x.HALF.HI = (((16 * a2) & 0x3F0) | 8) + gRoomControls.roomOriginX;
+ ent->y.HALF.HI = (((a2 >> 2) & 0x3F0) | 8) + gRoomControls.roomOriginY;
+}
+
+u32 sub_0806F730(Entity* ent) {
+ u32 tmp = 0x3F;
+ u32 x = ent->x.HALF.HI + ent->hitbox->offset_x - gRoomControls.roomOriginX;
+ u32 y = ent->y.HALF.HI + ent->hitbox->offset_y - gRoomControls.roomOriginY;
+ switch (ent->animationState) {
+ case 0:
+ y -= ent->hitbox->unk2[3];
+ break;
+ case 4:
+ y += ent->hitbox->unk2[3];
+ break;
+ case 2:
+ x += ent->hitbox->unk2[0];
+ break;
+ case 6:
+ x -= ent->hitbox->unk2[0];
+ break;
+ }
+ return ((x >> 4) & tmp) + (((y >> 4) & tmp) << 6);
+}
+
+ASM_FUNC("asm/non_matching/sub_0806F798.inc", u32 sub_0806F798(Entity* ent));
+
+u32 sub_0806F7D0(Entity* ent) {
+ return gUnk_02025EB0._2004[sub_0806F730(ent)];
+}
+
+u32 sub_0806F7EC(Entity* ent) {
+ return gUnk_02025EB0._4[sub_0806F730(ent)];
+}
+
+u32 sub_0806F804(u32 x, u32 y) {
+ u32 idx = ((x >> 4) & 0x3F) + 4 * (y & 0x3F0);
+ return gUnk_02025EB0._4[idx];
+}
+
+ASM_FUNC("asm/non_matching/sub_0806F824.inc", void sub_0806F824(Entity* a, Entity* b, u32 x, u32 y));
+
+u32 sub_0806F854(Entity* ent, s32 x, s32 y) {
+ if (ent->z.WORD == 0 || (ent->collisionLayer & 2))
+ return 0;
+ if (!sub_080002F0(TILE(ent->x.HALF.HI + x, ent->y.HALF.HI + y), 2, 8)) {
+ ent->spriteRendering.b3 = 1;
+ ent->spriteOrientation.flipY = 1;
+ return 0;
+ }
+ ent->spriteRendering.b3 = 2;
+ ent->spriteOrientation.flipY = 2;
+ return 1;
+}
+
+u32 sub_0806F8DC(Entity* ent) {
+ if (ent->collisionLayer & 2)
+ return 0;
+ if (!GetTileTypeByPos(ent->x.HALF.HI, ent->y.HALF.HI - 4, 2)) {
+ GetTileTypeByPos(ent->x.HALF.HI, ent->y.HALF.HI - 4, ent->collisionLayer);
+ ent->spriteRendering.b3 = 1;
+ ent->spriteOrientation.flipY = 1;
+ return 0;
+ }
+ ent->spriteRendering.b3 = 2;
+ ent->spriteOrientation.flipY = 2;
+ return 1;
+}
+
+u32 sub_0806F948(Entity* ent) {
+ u32 v1;
+ if (gPlayerState.field_0xd == 0xFF)
+ return ent->animationState;
+
+ v1 = gPlayerState.field_0xd / 4;
+ if ((v1 & 1) && !(((v1 + 1) - ent->animationState) & 4)) {
+ return ent->animationState;
+ } else {
+ ent->spriteSettings.flipX = v1 > 4;
+ ent->animationState = v1 & 6;
+ }
+ return ent->animationState;
+}
+
+ASM_FUNC("asm/non_matching/sub_0806F998.inc", u32 sub_0806F998(Entity* ent));
+
s16 FixedMul(s16 r0, s16 r1) {
s32 temp = r0 * r1;
if (temp < 0)
diff --git a/src/createEntity.c b/src/createEntity.c
deleted file mode 100644
index 9948a780..00000000
--- a/src/createEntity.c
+++ /dev/null
@@ -1,50 +0,0 @@
-// #include "entity.h"
-// #include "entityData.h"
-// #include "global.h"
-
-// extern Entity * DeepFindEntityByID(u32, u32);
-// extern Entity * GetEmptyEntityByKind();
-// extern void RegisterRoomEntity(Entity *, EntityData *);
-// extern u32 sub_0804AF0C(Entity *, EntityData *);
-// extern void sub_08016A30(Entity *);
-// extern u32 gRoomControls;
-
-// Entity * LoadRoomEntity(EntityData *param_1)
-// {
-// Entity *preexisting;
-// Entity *entity;
-// s32 type;
-
-// type = param_1->entityType & 15;
-// if (((param_1->field_0x1 & 240) == 80) &&
-// (preexisting = DeepFindEntityByID(type,param_1->entitySubtype), preexisting != NULL)) {
-// entity = NULL;
-// }
-// else {
-// entity = GetEmptyEntityByKind(); //Get empty entity
-// if (entity != NULL) {
-// (entity->entityType).type = type;
-// (entity->entityType).subtype = param_1->entitySubtype;
-// (entity->entityType).form = param_1->entityform;
-// RegisterRoomEntity(entity,param_1);
-// if ((param_1->field_0x1 & 240) != 16) {
-// (entity->type2 = *(u8 *)&param_1->entityparameter;
-// entity->actionDelay = (u8)((u32)param_1->entityparameter >> 8);
-// if ((type != 9) && (sub_0804AF0C(entity,param_1), entity->field_0x4 != NULL)) {
-// if ((param_1->entityType & 16) == 0) {
-// if ((param_1->entityType & 32) != 0) {
-// entity->collisionLayer = 2;
-// return entity;
-// }
-// if ((gRoomControls & 2) == 0) {
-// sub_08016A30(entity);
-// return entity;
-// }
-// }
-// entity->collisionLayer = 1;
-// }
-// }
-// }
-// }
-// return entity;
-// }
diff --git a/src/createNPC.c b/src/createNPC.c
deleted file mode 100644
index 8ef66a81..00000000
--- a/src/createNPC.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "global.h"
-#include "entity.h"
-#include "functions.h"
-#include "definitions.h"
-
-extern const NPCDefinition gNPCDefinitions[];
-
-extern Hitbox* gNPCHitboxes[];
-const NPCDefinition* GetNPCDefinition(Entity*);
-
-const NPCDefinition* GetNPCDefinition(Entity* this) {
- const NPCDefinition* definition = &gNPCDefinitions[this->id];
- if (definition->bitfield.type == 2) {
- definition = &definition->data.definition[this->type];
- }
- return definition;
-}
-
-void NPCInit(Entity* this) {
- u32 tmp;
- u32 tmp2;
-
- if ((this->flags & 1) == 0) {
- const NPCDefinition* definition = GetNPCDefinition(this);
- if (definition->bitfield.type == 0) {
- // No sprite for this NPC
- this->flags |= 1;
- } else {
- tmp = definition->bitfield.gfx;
- switch (definition->bitfield.gfx_type) {
- case 2:
- this->spriteVramOffset = definition->bitfield.gfx;
- break;
- case 1:
- LoadSwapGFX(this, tmp, 0);
- break;
- default:
- LoadFixedGFX(this, tmp);
- break;
- }
- tmp = definition->data.sprite.paletteIndex;
- LoadObjPalette(this, tmp);
- this->spriteIndex = definition->data.sprite.spriteIndex;
- this->spriteSettings.shadow = definition->data.sprite.shadow;
- this->spritePriority.b1 = definition->data.sprite.spritePriority;
- this->spriteSettings.draw = definition->data.sprite.draw;
- this->hitbox = gNPCHitboxes[definition->bitfield.hitbox];
- this->flags |= ENT_DID_INIT;
- tmp2 = 0xff;
- this->animIndex = tmp2;
- this->frameIndex = tmp2;
- UpdateSpriteForCollisionLayer(this);
- }
- }
-}
-
-Entity* CreateNPC(u32 subtype, u32 form, u32 parameter) {
- Entity* entity = GetEmptyEntity();
- if (entity != NULL) {
- entity->kind = 7;
- entity->id = subtype;
- entity->type = form;
- entity->type2 = parameter;
- AppendEntityToList(entity, 7);
- }
- return entity;
-}
diff --git a/src/enemyInit.c b/src/enemyUtils.c
index 111ed63f..111ed63f 100644
--- a/src/enemyInit.c
+++ b/src/enemyUtils.c
diff --git a/src/npcUtils.c b/src/npcUtils.c
new file mode 100644
index 00000000..7511beff
--- /dev/null
+++ b/src/npcUtils.c
@@ -0,0 +1,312 @@
+#include "global.h"
+#include "entity.h"
+#include "functions.h"
+#include "definitions.h"
+#include "save.h"
+
+extern const NPCDefinition gNPCDefinitions[];
+
+extern Hitbox* gNPCHitboxes[];
+const NPCDefinition* GetNPCDefinition(Entity*);
+extern u32 (*gUnk_08114EFC[])();
+extern u32 (*gUnk_08114F0C[])(Entity*, u8*);
+
+typedef struct {
+ u16 _0;
+ u16 _2;
+ u16 _4;
+} NPCData;
+extern NPCData* gUnk_08001A7C[];
+
+u32 sub_0800445C(Entity*);
+void sub_08077B20(void);
+void sub_0806EF14(Entity*);
+void sub_0806F69C(Entity*);
+void sub_0806EF4C(Entity*, u16*);
+u32 sub_080041DC(Entity*, u32, u32);
+u32 sub_0806EF74(Entity*, u32);
+u32 sub_0806EF88(Entity*);
+
+void sub_0806EC20(Entity* ent) {
+ Entity* e = CreateNPC(0x58, 0, 0);
+ if (e != NULL) {
+ e->parent = ent;
+ }
+}
+
+void sub_0806EC38(void) {
+ Entity* e = FindEntityByID(7, 0x58, 7);
+ if (e != NULL)
+ DeleteEntity(e);
+}
+
+const NPCDefinition* GetNPCDefinition(Entity* this) {
+ const NPCDefinition* definition = &gNPCDefinitions[this->id];
+ if (definition->bitfield.type == 2) {
+ definition = &definition->data.definition[this->type];
+ }
+ return definition;
+}
+
+void NPCInit(Entity* this) {
+ u32 tmp;
+ u32 tmp2;
+
+ if ((this->flags & 1) == 0) {
+ const NPCDefinition* definition = GetNPCDefinition(this);
+ if (definition->bitfield.type == 0) {
+ // No sprite for this NPC
+ this->flags |= 1;
+ } else {
+ tmp = definition->bitfield.gfx;
+ switch (definition->bitfield.gfx_type) {
+ case 2:
+ this->spriteVramOffset = definition->bitfield.gfx;
+ break;
+ case 1:
+ LoadSwapGFX(this, tmp, 0);
+ break;
+ default:
+ LoadFixedGFX(this, tmp);
+ break;
+ }
+ tmp = definition->data.sprite.paletteIndex;
+ LoadObjPalette(this, tmp);
+ this->spriteIndex = definition->data.sprite.spriteIndex;
+ this->spriteSettings.shadow = definition->data.sprite.shadow;
+ this->spritePriority.b1 = definition->data.sprite.spritePriority;
+ this->spriteSettings.draw = definition->data.sprite.draw;
+ this->hitbox = gNPCHitboxes[definition->bitfield.hitbox];
+ this->flags |= ENT_DID_INIT;
+ tmp2 = 0xff;
+ this->animIndex = tmp2;
+ this->frameIndex = tmp2;
+ UpdateSpriteForCollisionLayer(this);
+ }
+ }
+}
+
+Entity* CreateNPC(u32 subtype, u32 form, u32 parameter) {
+ Entity* entity = GetEmptyEntity();
+ if (entity != NULL) {
+ entity->kind = 7;
+ entity->id = subtype;
+ entity->type = form;
+ entity->type2 = parameter;
+ AppendEntityToList(entity, 7);
+ }
+ return entity;
+}
+
+u32 sub_0806ED78(Entity* ent) {
+ u32 result = sub_0800445C(ent);
+ if (result) {
+ if (gPlayerState.field_0x1d[1] & 0x40) {
+ sub_08077B20();
+ }
+ }
+ return result;
+}
+
+s32 sub_0806ED9C(Entity* ent, u32 x, u32 y) {
+ s32 anim = -1;
+ if (EntityInRectRadius(ent, &gPlayerEntity, x, y))
+ anim = GetAnimationState(ent);
+ return anim;
+}
+
+u32 GetAnimationState(Entity* ent) {
+ u32 direction = GetFacingDirection(ent, &gPlayerEntity);
+ return sub_0806F5A4(direction);
+}
+
+s32 sub_0806EDD8(Entity* ent, u32 x, u32 y) {
+ s32 anim = -1;
+ if (EntityInRectRadius(ent, &gPlayerEntity, x, y))
+ anim = GetFacingDirection(ent, &gPlayerEntity);
+ return anim;
+}
+
+void sub_0806EE04(Entity* ent, void* a2, u32 a3) {
+ ent->child = a2;
+ ent->field_0x3c = a3;
+ ent->hitType = 0;
+ ent->field_0x46 = 0;
+ ent->field_0x16 = 0;
+}
+
+u32 sub_0806EE20(Entity* ent) {
+ u32 v3;
+
+ if (!ent->interactType) {
+ if (ent->child)
+ return gUnk_08114EFC[ent->field_0x16](ent);
+ } else {
+ ent->field_0x46 = 8;
+ v3 = GetFacingDirection(ent, &gPlayerEntity);
+ ent->knockbackDirection = sub_0806F5A4(v3);
+ }
+ return 0;
+}
+
+u32 sub_0806EE70(Entity* ent) {
+ s32 tmp1;
+ s32 tmp2;
+ u32 result;
+ u16 xy[2];
+
+ if (++ent->field_0x46 > 8) {
+ ent->field_0x46 = 0;
+ sub_0806EF14(ent);
+ }
+ sub_0806F69C(ent);
+ sub_0806EF4C(ent, xy);
+ tmp1 = sub_080041DC(ent, xy[0], xy[1]);
+ tmp2 = ent->speed;
+ if (tmp2 < 0)
+ tmp2 = -tmp2;
+ if ((u32)tmp2 / 8 <= tmp1)
+ result = 0;
+ else
+ result = sub_0806EF74(ent, 3);
+ return result;
+}
+
+u32 sub_0806EED0(Entity* ent) {
+ if (!--ent->field_0x46)
+ return sub_0806EF74(ent, 2);
+ return 0;
+}
+
+u32 sub_0806EEF4(Entity* ent) {
+ if (ent->frame & 0x80)
+ return sub_0806EF74(ent, 1);
+ return 0;
+}
+
+void sub_0806EF14(Entity* ent) {
+ u16 xy[2];
+ sub_0806EF4C(ent, xy);
+ ent->direction = sub_080045B4(ent, xy[0], xy[1]);
+ if ((ent->field_0x3c & 1) == 0)
+ ent->knockbackDirection = sub_0806F5A4(ent->direction);
+}
+
+void sub_0806EF4C(Entity* ent, u16* xy) {
+ u16* src = &((u16*)ent->child)[ent->hitType];
+ xy[0] = gRoomControls.roomOriginX + src[1];
+ xy[1] = gRoomControls.roomOriginY + src[2];
+}
+
+u32 sub_0806EF74(Entity* ent, u32 a2) {
+ ent->hitType += a2;
+ return sub_0806EF88(ent);
+}
+
+u32 sub_0806EF88(Entity* ent) {
+ u8* v1 = (u8*)&((u16*)ent->child)[ent->hitType];
+ return gUnk_08114F0C[*v1](ent, v1);
+}
+
+u32 sub_0806EFAC(Entity* ent, u16* a2) {
+ ent->hitType = 0;
+ return sub_0806EF88(ent);
+}
+
+u32 sub_0806EFBC(Entity* ent, u16* a2) {
+ ent->field_0x16 = 1;
+ ent->field_0x46 = 8;
+ return 0;
+}
+
+u32 sub_0806EFCC(Entity* ent, u16* a2) {
+ ent->field_0x16 = 2;
+ ent->field_0x46 = a2[1];
+ return 0;
+}
+
+u32 sub_0806EFDC(Entity* ent, u16* a2) {
+ if (*a2 >> 8) {
+ ent->field_0x3c &= ~1;
+ } else {
+ ent->field_0x3c |= 1;
+ }
+ ent->hitType++;
+ return sub_0806EF88(ent);
+}
+
+u32 sub_0806F014(Entity* ent, u16* a2) {
+ ent->speed = a2[1];
+ ent->hitType += 2;
+ return sub_0806EF88(ent);
+}
+
+u32 sub_0806F02C(Entity* ent, u16* a2) {
+ ent->knockbackDirection = *a2 >> 8;
+ ent->hitType++;
+ return sub_0806EF88(ent);
+}
+
+u32 sub_0806F048(Entity* ent, u16* a2) {
+ ent->field_0x16 = 3;
+ return 0;
+}
+
+u32 sub_0806F050(Entity* ent, u16* a2) {
+ (u16*)ent->child = a2 + 1;
+ ent->hitType = 0;
+ return sub_0806EF88(ent);
+}
+
+u32 sub_0806F064(Entity* ent, u16* a2) {
+ ent->field_0x16 = 0;
+ ent->hitType++;
+ return *a2 >> 8;
+}
+
+s32 sub_0806F078(Entity* ent, s32 a2) {
+ if (a2 != ent->animIndex) {
+ if (ent->spriteAnimation[0])
+ InitAnimationForceUpdate(ent, a2);
+ else
+ InitializeAnimation(ent, a2);
+ return 1;
+ }
+ return 0;
+}
+
+ASM_FUNC("asm/non_matching/sub_0806FOA4.inc", void sub_0806F0A4(void));
+
+void sub_0806F118(Entity* ent) {
+ u32 idx = sub_08002632(ent);
+ NPCData* data = gUnk_08001A7C[idx];
+ sub_0801DFB4(ent, data->_0, data->_2, data->_4);
+ gPlayerState.controlMode = 3;
+}
+
+u32 UpdateFuseInteraction(void) {
+ u32 ret;
+ sub_0801E00C();
+ ret = -1;
+ switch (gUnk_02022740[0]) {
+ default:
+ ret = 0;
+ break;
+ case 2:
+ gPlayerState.controlMode = 3;
+ ret = 1;
+ case 1:
+ sub_0807919C();
+ gPlayerState.controlMode = 1;
+ break;
+ }
+ return ret;
+}
+
+void sub_0806F188(Entity* ent) {
+ u32 idx = sub_08002632(ent);
+ if (idx != 0)
+ gSave.unk1C1[idx] = 0xF3;
+}
+
+ASM_FUNC("asm/non_matching/showNPCDialogue.inc", void ShowNPCDialogue(Entity* ent, Dialog* dia));
diff --git a/src/createObject.c b/src/objectUtils.c
index 01fe8c6c..01fe8c6c 100644
--- a/src/createObject.c
+++ b/src/objectUtils.c
diff --git a/src/player.c b/src/player.c
index eefd0d92..3f2c89e5 100644
--- a/src/player.c
+++ b/src/player.c
@@ -180,7 +180,6 @@ extern void RespawnPlayer();
extern void sub_080797EC();
extern void sub_08079E08();
extern void sub_08078F60();
-extern void sub_0806F948();
extern void sub_08077698();
extern void DisplayEzloMessage();
extern void sub_08079258();
diff --git a/src/playerItemUtils.c b/src/playerItemUtils.c
new file mode 100644
index 00000000..98bd0309
--- /dev/null
+++ b/src/playerItemUtils.c
@@ -0,0 +1,106 @@
+#include "entity.h"
+#include "functions.h"
+#include "room.h"
+#include "save.h"
+#include "utils.h"
+#include "audio.h"
+#include "flags.h"
+#include "textbox.h"
+
+Entity* GiveItemWithCutscene(u32, u32, u32);
+Entity* sub_080A276C(Entity*, u32, u32);
+void sub_08078AF0(Entity*, u32, u32);
+Entity* sub_0805E744(void);
+void sub_080A7D44(u32, u32);
+
+void CreateItemEntity(u32 a, u32 b, u32 c) {
+ Entity* e = GiveItemWithCutscene(a, b, c);
+ if (e != NULL) {
+ e->parent = sub_080A276C(e, e->type, 0);
+ }
+}
+
+void sub_080A7C18(u32 a, u32 b, u32 c) {
+ Entity* e = GiveItemWithCutscene(a, b, c);
+ if (e != NULL) {
+ e->parent = &gPlayerEntity;
+ sub_08078AF0(e, e->type, 0);
+ }
+}
+
+Entity* GiveItemWithCutscene(u32 type, u32 type2, u32 delay) {
+ Entity* e;
+ if (type == 63 && gSave.stats.filler3[0]) {
+ type = 87;
+ type2 = 0;
+ }
+ e = sub_0805E744();
+ if (e != NULL) {
+ e->type = type;
+ e->type2 = type2;
+ e->actionDelay = delay;
+ e->id = 11;
+ e->kind = 6;
+ AppendEntityToList(e, 6);
+ }
+ return e;
+}
+
+void sub_080A7C7C(void) {
+ MemClear(gUnk_02017660, 0x40);
+}
+
+void sub_080A7C8C(u32 pos, u32 layer) {
+ TileEntity* t = gUnk_02017660;
+ u32 found = 0;
+ u32 i;
+ for (i = 0; i < 8; ++i, ++t) {
+ if (*(u16*)&t->_4 == pos) {
+ found = 1;
+ break;
+ }
+ }
+ if ((layer >> 1) == ((u32)(t->_6 << 31) >> 31)) {
+ if (found) {
+ SetLocalFlag(t->_1);
+ CreateItemEntity(t->_2, t->_3, 0);
+ } else {
+ CreateItemEntity(0x60, 0, 0);
+ }
+ sub_0807B7D8(0x74, pos, layer);
+ RequestPriorityDuration(NULL, 120);
+ SoundReq(283);
+ }
+}
+
+u32 sub_080A7CFC(u32 a1) {
+ u32 ta = 0x600;
+ u32 tb = 0;
+ TileEntity* t = GetCurrentRoomProperty(3);
+ if (t != 0) {
+ do {
+ if (t->_4 == a1) {
+ switch (t->type) {
+ case 5:
+ tb = 0;
+ ta = *(u16*)&t->_6;
+ break;
+ case 6:
+ tb = 1;
+ ta = *(u16*)&t->_6;
+ break;
+ }
+ break;
+ }
+ t++;
+ } while (t->_4 != 0);
+ }
+ sub_080A7D44(ta, tb);
+}
+
+void sub_080A7D44(u32 msg, u32 a2) {
+ if (a2)
+ sub_08078AA8(msg, 0);
+ else
+ MessageFromTarget(msg);
+}
diff --git a/src/projectileInit.c b/src/projectileUtils.c
index 5c82f3cf..5c82f3cf 100644
--- a/src/projectileInit.c
+++ b/src/projectileUtils.c
diff --git a/src/room.c b/src/room.c
index 45af78fe..e892739e 100644
--- a/src/room.c
+++ b/src/room.c
@@ -29,17 +29,6 @@ void sub_0806F704(Entity*, u32);
void sub_0805BB00(u32, u32);
-typedef struct {
- u8 type;
- u8 _1;
- u8 _2;
- u8 _3;
- u16 _4;
- u8 _6;
- u8 _7;
-} TileEntity;
-extern TileEntity gUnk_02017660[];
-
static void sub_0804B290(TileEntity*);
static void sub_0804B29C(TileEntity*);
static void sub_0804B300(TileEntity*);
diff --git a/src/roomInit.c b/src/roomInit.c
index f6484343..0ab8138f 100644
--- a/src/roomInit.c
+++ b/src/roomInit.c
@@ -2011,11 +2011,7 @@ void sub_StateChange_Ruins_TripleTektites(void) {
}
void sub_unk1_Ruins_TripleTektites(void) {
-#if defined(JP) || defined(EU) || defined(DEMO_JP)
- if (CheckLocalFlagByBank(FLAG_BANK_1, LOST_03_00)) {
-#else
if (CheckLocalFlagByBank(FLAG_BANK_1, LOST_02_00)) {
-#endif
SetDirtTile(0x85);
}
}