summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenny022p <info@henny022.de>2022-01-31 17:30:51 +0100
committerHenny022p <info@henny022.de>2022-01-31 17:30:51 +0100
commit2a53ee4bf2ee7eea617280118c2188bffec77ae5 (patch)
tree85ed631ab330f9ca3734bb77253a374e3ef0de21 /src
parent9b60d9c5e24ed592524c25a9dc013417d6e7ee0c (diff)
parent2b8d880ffc0a4548d25dc613d53a908d36362d84 (diff)
merge master
Diffstat (limited to 'src')
-rw-r--r--src/code_0805436C.c14
-rw-r--r--src/code_08077B98.c12
-rw-r--r--src/collision.c41
-rw-r--r--src/color.c17
-rw-r--r--src/coord.c783
-rw-r--r--src/enemy.c4
-rw-r--r--src/enemy/acroBandits.c26
-rw-r--r--src/enemy/ballChainSoldier.c342
-rw-r--r--src/enemy/beetle.c10
-rw-r--r--src/enemy/bladeTrap.c2
-rw-r--r--src/enemy/bobomb.c12
-rw-r--r--src/enemy/bombPeahat.c118
-rw-r--r--src/enemy/bowMoblin.c2
-rw-r--r--src/enemy/businessScrub.c11
-rw-r--r--src/enemy/chuchu.c10
-rw-r--r--src/enemy/crow.c2
-rw-r--r--src/enemy/cuccoAggr.c383
-rw-r--r--src/enemy/cuccoChickAggr.c14
-rw-r--r--src/enemy/curtain.c4
-rw-r--r--src/enemy/darkNut.c16
-rw-r--r--src/enemy/doorMimic.c5
-rw-r--r--src/enemy/enemy66.c16
-rw-r--r--src/enemy/fallingBoulder.c10
-rw-r--r--src/enemy/fireballGuy.c2
-rw-r--r--src/enemy/flyingSkull.c9
-rw-r--r--src/enemy/gibdo.c436
-rw-r--r--src/enemy/gleerok.c1254
-rw-r--r--src/enemy/gyorgChild.c6
-rw-r--r--src/enemy/gyorgFemaleEye.c8
-rw-r--r--src/enemy/gyorgMale.c34
-rw-r--r--src/enemy/helmasaur.c12
-rw-r--r--src/enemy/keaton.c2
-rw-r--r--src/enemy/keese.c4
-rw-r--r--src/enemy/lakitu.c32
-rw-r--r--src/enemy/lakituCloud.c2
-rw-r--r--src/enemy/likeLike.c8
-rw-r--r--src/enemy/madderpillar.c18
-rw-r--r--src/enemy/mazaalBracelet.c36
-rw-r--r--src/enemy/mazaalHead.c8
-rw-r--r--src/enemy/miniFireballGuy.c2
-rw-r--r--src/enemy/moldworm.c8
-rw-r--r--src/enemy/octorok.c4
-rw-r--r--src/enemy/octorokBoss.c17
-rw-r--r--src/enemy/peahat.c4
-rw-r--r--src/enemy/pesto.c16
-rw-r--r--src/enemy/puffstool.c26
-rw-r--r--src/enemy/rollobite.c8
-rw-r--r--src/enemy/rope.c2
-rw-r--r--src/enemy/ropeGolden.c2
-rw-r--r--src/enemy/rupeeLike.c8
-rw-r--r--src/enemy/sensorBladeTrap.c2
-rw-r--r--src/enemy/slime.c1
-rw-r--r--src/enemy/sluggula.c8
-rw-r--r--src/enemy/spearMoblin.c7
-rw-r--r--src/enemy/spikedBeetle.c8
-rw-r--r--src/enemy/spinyBeetle.c394
-rw-r--r--src/enemy/spinyChuchu.c18
-rw-r--r--src/enemy/sub_080451CC.c2
-rw-r--r--src/enemy/takkuri.c4
-rw-r--r--src/enemy/tektiteGolden.c4
-rw-r--r--src/enemy/torchTrap.c156
-rw-r--r--src/enemy/treeItem.c2
-rw-r--r--src/enemy/vaatiArm.c48
-rw-r--r--src/enemy/vaatiBall.c14
-rw-r--r--src/enemy/vaatiEyesMacro.c1
-rw-r--r--src/enemy/vaatiProjectile.c12
-rw-r--r--src/enemy/vaatiRebornEnemy.c18
-rw-r--r--src/enemy/vaatiTransfigured.c12
-rw-r--r--src/enemy/vaatiTransfiguredEye.c4
-rw-r--r--src/enemy/vaatiWrath.c6
-rw-r--r--src/enemy/vaatiWrathEye.c2
-rw-r--r--src/enemy/wallMaster.c4
-rw-r--r--src/enemy/wallMaster2.c4
-rw-r--r--src/enemy/waterDrop.c4
-rw-r--r--src/enemyUtils.c2
-rw-r--r--src/interrupts.c18
-rw-r--r--src/item/itemJarEmpty.c6
-rw-r--r--src/item/itemOcarina.c4
-rw-r--r--src/item/itemRocsCape.c2
-rw-r--r--src/item/itemSword.c79
-rw-r--r--src/item/itemTryPickupObject.c2
-rw-r--r--src/manager/manager1.c232
-rw-r--r--src/manager/manager1A.c6
-rw-r--r--src/manager/manager22.c2
-rw-r--r--src/manager/manager28.c2
-rw-r--r--src/manager/manager2C.c2
-rw-r--r--src/manager/manager4.c8
-rw-r--r--src/manager/manager7.c57
-rw-r--r--src/manager/managerB.c2
-rw-r--r--src/manager/managerC.c3
-rw-r--r--src/manager/managerF.c6
-rw-r--r--src/message.c2
-rw-r--r--src/npc/beedle.c2
-rw-r--r--src/npc/bigGoron.c2
-rw-r--r--src/npc/bladeBrothers.c4
-rw-r--r--src/npc/brocco.c2
-rw-r--r--src/npc/carlov.c4
-rw-r--r--src/npc/castleMaid.c2
-rw-r--r--src/npc/castorWildsStatue.c8
-rw-r--r--src/npc/cat.c4
-rw-r--r--src/npc/cuccoChick.c2
-rw-r--r--src/npc/dog.c2
-rw-r--r--src/npc/drLeft.c2
-rw-r--r--src/npc/ezlo.c2
-rw-r--r--src/npc/ghostBrothers.c2
-rw-r--r--src/npc/gorman.c2
-rw-r--r--src/npc/goron.c14
-rw-r--r--src/npc/goronMerchant.c2
-rw-r--r--src/npc/gregal.c4
-rw-r--r--src/npc/guard.c2
-rw-r--r--src/npc/kid.c4
-rw-r--r--src/npc/kingDaltus.c2
-rw-r--r--src/npc/malon.c6
-rw-r--r--src/npc/melari.c4
-rw-r--r--src/npc/ministerPotho.c2
-rw-r--r--src/npc/mountainMinish.c2
-rw-r--r--src/npc/npc23.c4
-rw-r--r--src/npc/npc26.c2
-rw-r--r--src/npc/npc4E.c4
-rw-r--r--src/npc/npc5.c22
-rw-r--r--src/npc/percy.c4
-rw-r--r--src/npc/phonograph.c169
-rw-r--r--src/npc/pina.c2
-rw-r--r--src/npc/pita.c2
-rw-r--r--src/npc/postman.c4
-rw-r--r--src/npc/rem.c4
-rw-r--r--src/npc/smith.c2
-rw-r--r--src/npc/stamp.c2
-rw-r--r--src/npc/stockwell.c4
-rw-r--r--src/npc/sturgeon.c2
-rw-r--r--src/npc/talon.c2
-rw-r--r--src/npc/tingleSiblings.c2
-rw-r--r--src/npc/townMinish.c8
-rw-r--r--src/npc/townsperson.c4
-rw-r--r--src/npc/vaatiReborn.c6
-rw-r--r--src/npc/wheaton.c2
-rw-r--r--src/npc/zelda.c8
-rw-r--r--src/npcUtils.c166
-rw-r--r--src/object/bakerOven.c6
-rw-r--r--src/object/bigPushableLever.c155
-rw-r--r--src/object/bigVortex.c6
-rw-r--r--src/object/bird.c16
-rw-r--r--src/object/book.c6
-rw-r--r--src/object/button.c12
-rw-r--r--src/object/fileScreenObjects.c6
-rw-r--r--src/object/furniture.c7
-rw-r--r--src/object/greatFairy.c14
-rw-r--r--src/object/gyorgBossObject.c3
-rw-r--r--src/object/heartContainer.c2
-rw-r--r--src/object/hittableLever.c79
-rw-r--r--src/object/houseDoorExterior.c6
-rw-r--r--src/object/itemOnGround.c16
-rw-r--r--src/object/jarPortal.c10
-rw-r--r--src/object/lightableSwitch.c6
-rw-r--r--src/object/lilypadLarge.c385
-rw-r--r--src/object/lockedDoor.c7
-rw-r--r--src/object/mask.c14
-rw-r--r--src/object/metalDoor.c9
-rw-r--r--src/object/minecart.c7
-rw-r--r--src/object/object2A.c64
-rw-r--r--src/object/object49.c4
-rw-r--r--src/object/object6A.c90
-rw-r--r--src/object/object7E.c2
-rw-r--r--src/object/objectA2.c8
-rw-r--r--src/object/objectAF.c2
-rw-r--r--src/object/objectB5.c2
-rw-r--r--src/object/octorokBossObject.c29
-rw-r--r--src/object/pot.c9
-rw-r--r--src/object/pressurePlate.c185
-rw-r--r--src/object/pullableLever.c284
-rw-r--r--src/object/pushableLever.c148
-rw-r--r--src/object/railtrack.c6
-rw-r--r--src/object/rupee.c2
-rw-r--r--src/object/warpPoint.c12
-rw-r--r--src/objectUtils.c4
-rw-r--r--src/player.c58
-rw-r--r--src/playerHitbox.c7
-rw-r--r--src/playerItem/playerItem13.c2
-rw-r--r--src/playerItem/playerItem3.c6
-rw-r--r--src/playerItem/playerItemC.c4
-rw-r--r--src/playerItem/playerItemLantern.c2
-rw-r--r--src/projectile/arrowProjectile.c2
-rw-r--r--src/projectile/ballAndChain.c4
-rw-r--r--src/projectile/boneProjectile.c4
-rw-r--r--src/projectile/cannonballProjectile.c4
-rw-r--r--src/projectile/dekuSeedProjectile.c4
-rw-r--r--src/projectile/dirtBallProjectile.c12
-rw-r--r--src/projectile/gleerokProjectile.c5
-rw-r--r--src/projectile/gyorgMaleEnergyProjectile.c6
-rw-r--r--src/projectile/lakituCloudProjectile.c6
-rw-r--r--src/projectile/mandiblesProjectile.c29
-rw-r--r--src/projectile/octorokBossProjectile.c15
-rw-r--r--src/projectile/rockProjectile.c4
-rw-r--r--src/projectile/spiderWeb.c6
-rw-r--r--src/projectile/stalfosProjectile.c4
-rw-r--r--src/projectile/v1DarkMagicProjectile.c10
-rw-r--r--src/projectile/v1EyeLaser.c2
-rw-r--r--src/projectile/v1FireProjectile.c5
-rw-r--r--src/projectile/v2Projectile.c4
-rw-r--r--src/projectile/v3ElectricProjectile.c2
-rw-r--r--src/projectile/v3TennisBallProjectile.c2
-rw-r--r--src/projectileUtils.c2
-rw-r--r--src/respawnPlayer.c2
-rw-r--r--src/room.c2
-rw-r--r--src/roomInit.c10
-rw-r--r--src/script.c16
-rw-r--r--src/scroll.c11
-rw-r--r--src/sineTable.c328
-rw-r--r--src/sound.c8
-rw-r--r--src/sub_0807CA18.c2
210 files changed, 6307 insertions, 1405 deletions
diff --git a/src/code_0805436C.c b/src/code_0805436C.c
index 72da2bf9..abf54825 100644
--- a/src/code_0805436C.c
+++ b/src/code_0805436C.c
@@ -48,7 +48,7 @@ u32 IsItemEquipped(u32 itemID) {
void PutItemOnSlot(u32 itemID) {
u32 itemSlot;
- register u32 itemID2 asm("r5") = itemID;
+ u32 itemID2 = itemID;
if (itemID2 < 0x47) {
sub_0807CAA0(0, 1);
}
@@ -60,7 +60,7 @@ void PutItemOnSlot(u32 itemID) {
itemSlot = 1;
}
if (itemSlot == 2) {
- u8 temp = gUnk_080FD5B4[itemID2].unk;
+ u32 temp = gUnk_080FD5B4[itemID2].unk;
if (temp == gUnk_080FD5B4[gSave.stats.itemButtons[SLOT_A]].unk) {
itemSlot = 0;
} else {
@@ -171,11 +171,7 @@ void sub_08054570(void) {
gRoomVars.field_0x2 = 0;
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0805457C.inc", u32 sub_0805457C(u32 arg0, u32 arg1));
-#else
ASM_FUNC("asm/non_matching/sub_0805457C.inc", u32 sub_0805457C(u32 arg0, u32 arg1));
-#endif
u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
u32 prereqID;
@@ -244,13 +240,13 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
} else {
itemEntity->actionDelay = 0;
}
- if (arg0->kind == 6) {
+ if (arg0->kind == OBJECT) {
if (arg0->id == 99) {
arg0->child = itemEntity;
} else if (arg0->id == 0x1e) {
itemEntity->direction = arg0->animationState << 3 | 0x80;
itemEntity->speed = 0xc0;
- itemEntity->zVelocity = 0x18000;
+ itemEntity->zVelocity = Q_16_16(1.5);
}
}
CopyPosition(arg0, itemEntity);
@@ -336,7 +332,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) {
} else {
itemEntity->actionDelay = 0;
}
- if (arg0->kind == 6) {
+ if (arg0->kind == OBJECT) {
if (arg0->id == 99) {
arg0->child = itemEntity;
} else if (arg0->id == 0x1e) {
diff --git a/src/code_08077B98.c b/src/code_08077B98.c
index 7ad3703f..7ef7687e 100644
--- a/src/code_08077B98.c
+++ b/src/code_08077B98.c
@@ -26,7 +26,7 @@ void sub_08077BB8(ItemBehavior* beh) {
UnkItemStruct* unk = (UnkItemStruct*)beh; // @nocheckin
Entity* temp = sub_08077C54(unk);
if (temp != NULL) {
- temp->flags = 0x20;
+ temp->flags = ENT_PERSIST;
}
gPlayerState.item = temp;
}
@@ -68,7 +68,7 @@ void* sub_08077C54(UnkItemStruct* unk) {
item = sub_0805E744();
if (item != NULL) {
item->id = gUnk_0811BE48[unk->field_0x1].unk[3];
- item->kind = 8;
+ item->kind = PLAYER_ITEM;
item->flags = 0xa0;
item->parent = (Entity*)unk;
item->field_0x68.HALF.LO = unk->field_0x1;
@@ -92,8 +92,8 @@ Entity* CreatePlayerItem(u32 subtype, u32 form, u32 parameter, u32 unk) {
ent = GetEmptyEntity();
if (ent != NULL) {
- ent->flags = 0x80;
- ent->kind = 8;
+ ent->flags = ENT_COLLIDE;
+ ent->kind = PLAYER_ITEM;
ent->id = subtype;
ent->type = form;
ent->type2 = parameter;
@@ -108,8 +108,8 @@ Entity* sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk) {
ent = sub_0805E744();
if (ent != NULL) {
- ent->flags = 0x80;
- ent->kind = 8;
+ ent->flags = ENT_COLLIDE;
+ ent->kind = PLAYER_ITEM;
ent->id = subtype;
ent->type = form;
ent->type2 = parameter;
diff --git a/src/collision.c b/src/collision.c
index f33bcb3f..4af9296e 100644
--- a/src/collision.c
+++ b/src/collision.c
@@ -177,7 +177,7 @@ NONMATCH("asm/non_matching/arm_proxy/sub_08017744.inc", void sub_08017744(Entity
}
END_NONMATCH
-bool32 sub_080177A0(Entity* this, Entity* that) {
+bool32 IsColliding(Entity* this, Entity* that) {
u32 this_d;
u32 depth;
@@ -206,9 +206,9 @@ bool32 sub_080177A0(Entity* this, Entity* that) {
return FALSE;
}
-bool32 sub_08017850(Entity* this) {
+bool32 IsCollidingPlayer(Entity* this) {
if (sub_08079F8C())
- return sub_080177A0(this, &gPlayerEntity);
+ return IsColliding(this, &gPlayerEntity);
return FALSE;
}
@@ -218,7 +218,7 @@ s32 sub_08017874(Entity* a, Entity* b) {
s32 v6;
asm("" ::: "r1");
- if (a->kind == 1) {
+ if (a->kind == PLAYER) {
newDmg = b->damage;
switch (gSave.stats.charm) {
case 47:
@@ -231,10 +231,10 @@ s32 sub_08017874(Entity* a, Entity* b) {
if (newDmg <= 0)
newDmg = 1;
v5 = ModHealth(-newDmg);
- SoundReqClipped(a, 122);
+ SoundReqClipped(a, SFX_PLY_VO6);
} else {
v6 = b->damage;
- if (b->kind == 8) {
+ if (b->kind == PLAYER_ITEM) {
switch (gSave.stats.charm) {
case 48:
v6 = 3 * v6 / 2;
@@ -245,11 +245,11 @@ s32 sub_08017874(Entity* a, Entity* b) {
}
}
v5 = a->health - v6;
- if (a->kind == 3) {
+ if (a->kind == ENEMY) {
if ((a->field_0x6c.HALF.HI & 1) != 0)
- SoundReqClipped(a, 295);
+ SoundReqClipped(a, SFX_BOSS_HIT);
else
- SoundReqClipped(a, 254);
+ SoundReqClipped(a, SFX_HIT);
}
}
if (v5 <= 0) {
@@ -290,7 +290,7 @@ void sub_080179EC(Entity* a1, Entity* a2) {
u32 rand = Random();
Entity* e = CreateFx(a2, p[rand & 3], 0);
if (e != NULL) {
- PositionRelative(a2, e, a2->hitbox->offset_x << 16, a2->hitbox->offset_y << 16);
+ PositionRelative(a2, e, Q_16_16(a2->hitbox->offset_x), Q_16_16(a2->hitbox->offset_y));
e->spritePriority.b0 = 2;
e->spriteOffsetX = (a1->x.HALF.HI + a1->hitbox->offset_x - (a2->x.HALF.HI + a2->hitbox->offset_x)) >> 1;
e->spriteOffsetY = (a1->y.HALF.HI + a1->hitbox->offset_y - (a2->y.HALF.HI + a2->hitbox->offset_y)) >> 1;
@@ -510,7 +510,7 @@ s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
gPlayerEntity.knockbackDuration = 12;
gPlayerEntity.iframes = 16;
gPlayerEntity.field_0x46 = 384;
- } else if (org->kind == 8 && org->id == 5) {
+ } else if (org->kind == PLAYER_ITEM && org->id == 5) {
org->knockbackDuration = 8;
org->iframes = -6;
org->field_0x46 = 384;
@@ -541,9 +541,9 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
gPlayerState.jump_status = 0;
if (tgt->kind == ENEMY && (tgt->id == GHINI || tgt->id == ENEMY_50)) {
org->z.HALF.HI = 0;
- PositionRelative(org, tgt, 0, 0x10000);
+ PositionRelative(org, tgt, 0, Q_16_16(1.0));
} else {
- PositionRelative(tgt, org, 0, 0x10000);
+ PositionRelative(tgt, org, 0, Q_16_16(1.0));
}
COLLISION_OFF(org);
org->spriteRendering.b3 = tgt->spriteRendering.b3;
@@ -556,7 +556,7 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else {
org->health = 0;
}
- } else if (tgt->kind == 3 && org == &gPlayerEntity) {
+ } else if (tgt->kind == ENEMY && org == &gPlayerEntity) {
sub_08004484(tgt, org);
}
return 0;
@@ -644,7 +644,7 @@ s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
} else {
org->health = 0;
}
- } else if ((tgt->kind == 3) && (org == &gPlayerEntity)) {
+ } else if ((tgt->kind == ENEMY) && (org == &gPlayerEntity)) {
sub_08004484(tgt, &gPlayerEntity);
}
return 0;
@@ -690,11 +690,12 @@ s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 temp = 0;
- if (tgt->field_0x43 && tgt->kind == 3 && org == &gPlayerEntity) {
+ if (tgt->field_0x43 && tgt->kind == ENEMY && org == &gPlayerEntity) {
sub_08004484(tgt, org);
temp = 1;
}
- if ((org->kind == 8 && org->id == 0x5) && gPlayerEntity.animationState == ((((direction + 4) & 0x18) >> 2) ^ 4)) {
+ if ((org->kind == PLAYER_ITEM && org->id == 0x5) &&
+ gPlayerEntity.animationState == ((((direction + 4) & 0x18) >> 2) ^ 4)) {
return 0;
}
if (!temp) {
@@ -738,7 +739,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
parent->field_0x4c = org;
}
}
- if (org->kind == 8) {
+ if (org->kind == PLAYER_ITEM) {
if (org->id == 1) {
if (settings->_8) {
sub_080179EC(org, tgt);
@@ -749,13 +750,13 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)
}
} else if (org->id == 3) {
if (settings->_9) {
- SoundReqClipped(tgt, 254);
+ SoundReqClipped(tgt, SFX_HIT);
}
} else if (org->id == 5) {
gPlayerEntity.iframes = 0x80;
}
}
- if (tgt->kind == 8 && org->id == 5) {
+ if (tgt->kind == PLAYER_ITEM && org->id == 5) {
gPlayerEntity.iframes = 0x80;
}
return 1;
diff --git a/src/color.c b/src/color.c
index 4a5e0ed5..557cda39 100644
--- a/src/color.c
+++ b/src/color.c
@@ -27,9 +27,22 @@ void sub_0801CFD0(u32 a1) {
ASM_FUNC("asm/non_matching/color/sub_0801D000.inc", void sub_0801D000(u32 a1));
-ASM_FUNC("asm/non_matching/color/LoadObjPalette.inc", void LoadObjPalette(Entity* entity, u32 a2));
+ASM_FUNC("asm/non_matching/color/LoadObjPalette.inc", u32 LoadObjPalette(Entity* entity, u32 a2));
-ASM_FUNC("asm/non_matching/color/FindPalette.inc", s32 FindPalette(u32 a1));
+s32 FindPalette(u32 a1) {
+ u32 index;
+ Palette* palette;
+ if (a1 <= 5)
+ return a1;
+
+ for (index = 6, palette = gPaletteList; index < 0x10; index++) {
+ if (a1 == palette[index]._2) {
+ return index;
+ }
+ }
+
+ return -1;
+}
ASM_FUNC("asm/non_matching/color/FindFreeObjPalette.inc", u32 FindFreeObjPalette(u32 a1));
diff --git a/src/coord.c b/src/coord.c
index 1d1f346a..ef5f2c12 100644
--- a/src/coord.c
+++ b/src/coord.c
@@ -7,8 +7,33 @@
#include "room.h"
#include "functions.h"
-extern u8 gUnk_08114F78[];
-extern u8 gUnk_08114F80[];
+const u8 gSpriteSortAboveTable[];
+const u8 gSpriteSortBelowTable[];
+const u8 gUnk_08114F58[];
+const u8 gUnk_08114F38[];
+
+typedef struct {
+ struct {
+ u8 unk0 : 1;
+ u8 unk1 : 1;
+ u8 unk2 : 1;
+ u8 unk3 : 1;
+ u8 unk4 : 4;
+ } PACKED unk_00;
+ u8 unk_01;
+ u16 unk_02;
+ union SplitWord unk_04;
+ union SplitWord unk_08;
+ union SplitWord unk_0C;
+} struct_gUnk_020000C0_1;
+typedef struct {
+ struct_gUnk_020000C0_1 unk_00[4];
+} struct_gUnk_020000C0;
+
+static_assert(sizeof(struct_gUnk_020000C0) == 0x40);
+
+extern struct_gUnk_020000C0 gUnk_020000C0[0x30];
+extern u32 gSpritePtrs[];
typedef struct {
u32 _0;
@@ -17,14 +42,21 @@ typedef struct {
} struct_02025EB0;
extern struct_02025EB0 gUnk_02025EB0;
+extern u16 gExtraFrameOffsets[];
extern s8 gUnk_08126EE4[];
-extern u8 gUnk_08114F38[];
-extern u8 gUnk_08114F58[];
+extern const u16 gUnk_080046A4[];
+extern const u16 gUnk_080047F6[];
void sub_080027EA(Entity*, u32, u32);
-void sub_0806F5BC(Entity*, u32, u32);
u32 sub_0806F58C(Entity*, Entity*);
u32 sub_0806FCA0(Entity*, Entity*);
+void UnloadHitbox(Entity*);
+extern u32 sub_08007DD6(u32, const u16*);
+extern u32 sub_080041DC(Entity*, u32, u32);
+u32 PointInsideRadius(s32 x, s32 y, s32 radius);
+extern void sub_0806FEE8(struct_gUnk_020000C0_1*, u32, u32, u32);
+void sub_0806FEFC(struct_gUnk_020000C0_1*, Entity*);
+bool32 sub_0807007C(struct_gUnk_020000C0*, u32);
void sub_0806F364(void) {
gArea.filler[2] ^= 0x80;
@@ -76,7 +108,7 @@ u32 sub_0806F3E4(Entity* ent) {
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));
+ LinearMoveDirection(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) {
@@ -147,7 +179,7 @@ u32 sub_0806F5B0(u32 idx) {
return gUnk_08114F58[idx];
}
-void sub_0806F5BC(Entity* ent, u32 a, u32 b) {
+void LinearMoveDirection(Entity* ent, u32 a, u32 b) {
if ((b & 0x80) == 0) {
u32 m1 = b;
@@ -156,15 +188,15 @@ void sub_0806F5BC(Entity* ent, u32 a, u32 b) {
}
}
-void sub_0806F62C(Entity* ent, u32 a, u32 b) {
+void LinearMoveAngle(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 LinearMoveUpdate(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;
+ ent->x.WORD += FixedDiv(FixedMul(gSineTable[ent->direction * 8], ent->speed), (1 << 8)) << 8;
+ ent->y.WORD -= FixedDiv(FixedMul(gSineTable[ent->direction * 8 + 64], ent->speed), (1 << 8)) << 8;
}
}
@@ -214,8 +246,8 @@ u32 sub_0806F804(u32 x, u32 y) {
return gUnk_02025EB0._4[idx];
}
-void sub_0806F824(Entity* a, Entity* b, s32 x, s32 y) {
- sub_080045D4(a->x.HALF.HI, a->y.HALF.HI, b->x.HALF.HI + x, b->y.HALF.HI + y);
+u32 sub_0806F824(Entity* a, Entity* b, s32 x, s32 y) {
+ return sub_080045D4(a->x.HALF.HI, a->y.HALF.HI, b->x.HALF.HI + x, b->y.HALF.HI + y);
}
u32 sub_0806F854(Entity* ent, s32 x, s32 y) {
@@ -291,13 +323,13 @@ s16 FixedDiv(s16 r0, s16 r1) {
return (r0 * 256) / r1;
}
-void CopyPosition(Entity* param_1, Entity* param_2) {
- PositionRelative(param_1, param_2, 0, 0);
+void CopyPosition(Entity* source, Entity* target) {
+ PositionRelative(source, target, 0, 0);
}
-void PositionEntityOnTop(Entity* ent, Entity* ent2) {
- PositionRelative(ent, ent2, 0, 0);
- ResolveEntityOnTop(ent, ent2);
+void PositionEntityOnTop(Entity* source, Entity* target) {
+ PositionRelative(source, target, 0, 0);
+ SortEntityAbove(source, target);
}
void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) {
@@ -315,349 +347,380 @@ void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY)
UpdateSpriteForCollisionLayer(target);
}
-void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2) {
- param_2->spriteOffsetX = param_1->spriteOffsetX;
- param_2->spriteOffsetY = param_1->spriteOffsetY;
- PositionRelative(param_1, param_2, 0, 0);
-}
-
-void sub_0806FA90(Entity* param_1, Entity* param_2, s32 offsetX, s32 offsetY) {
- param_2->spriteOffsetX = param_1->spriteOffsetX;
- param_2->spriteOffsetY = param_1->spriteOffsetY;
- PositionRelative(param_1, param_2, offsetX * 64 * 32 * 32, offsetY * 64 * 32 * 32);
-}
-
-void ResolveEntityOnTop(Entity* param_1, Entity* param_2) {
- param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0];
-}
-
-void ResolveEntityBelow(Entity* param_1, Entity* param_2) {
- param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0];
-}
-
-// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319
-const s16 gSineTable[64] = {
- Q_8_8(0), // sin(0*(π/128))
- Q_8_8(0.0234375), // sin(1*(π/128))
- Q_8_8(0.046875), // sin(2*(π/128))
- Q_8_8(0.0703125), // sin(3*(π/128))
- Q_8_8(0.09765625), // sin(4*(π/128))
- Q_8_8(0.12109375), // sin(5*(π/128))
- Q_8_8(0.14453125), // sin(6*(π/128))
- Q_8_8(0.16796875), // sin(7*(π/128))
- Q_8_8(0.19140625), // sin(8*(π/128))
- Q_8_8(0.21875), // sin(9*(π/128))
- Q_8_8(0.2421875), // sin(10*(π/128))
- Q_8_8(0.265625), // sin(11*(π/128))
- Q_8_8(0.2890625), // sin(12*(π/128))
- Q_8_8(0.3125), // sin(13*(π/128))
- Q_8_8(0.3359375), // sin(14*(π/128))
- Q_8_8(0.359375), // sin(15*(π/128))
- Q_8_8(0.37890625), // sin(16*(π/128))
- Q_8_8(0.40234375), // sin(17*(π/128))
- Q_8_8(0.42578125), // sin(18*(π/128))
- Q_8_8(0.44921875), // sin(19*(π/128))
- Q_8_8(0.46875), // sin(20*(π/128))
- Q_8_8(0.4921875), // sin(21*(π/128))
- Q_8_8(0.51171875), // sin(22*(π/128))
- Q_8_8(0.53125), // sin(23*(π/128))
- Q_8_8(0.5546875), // sin(24*(π/128))
- Q_8_8(0.57421875), // sin(25*(π/128))
- Q_8_8(0.59375), // sin(26*(π/128))
- Q_8_8(0.61328125), // sin(27*(π/128))
- Q_8_8(0.6328125), // sin(28*(π/128))
- Q_8_8(0.65234375), // sin(29*(π/128))
- Q_8_8(0.66796875), // sin(30*(π/128))
- Q_8_8(0.6875), // sin(31*(π/128))
- Q_8_8(0.70703125), // sin(32*(π/128))
- Q_8_8(0.72265625), // sin(33*(π/128))
- Q_8_8(0.73828125), // sin(34*(π/128))
- Q_8_8(0.75390625), // sin(35*(π/128))
- Q_8_8(0.76953125), // sin(36*(π/128))
- Q_8_8(0.78515625), // sin(37*(π/128))
- Q_8_8(0.80078125), // sin(38*(π/128))
- Q_8_8(0.81640625), // sin(39*(π/128))
- Q_8_8(0.828125), // sin(40*(π/128))
- Q_8_8(0.84375), // sin(41*(π/128))
- Q_8_8(0.85546875), // sin(42*(π/128))
- Q_8_8(0.8671875), // sin(43*(π/128))
- Q_8_8(0.87890625), // sin(44*(π/128))
- Q_8_8(0.890625), // sin(45*(π/128))
- Q_8_8(0.90234375), // sin(46*(π/128))
- Q_8_8(0.9140625), // sin(47*(π/128))
- Q_8_8(0.921875), // sin(48*(π/128))
- Q_8_8(0.9296875), // sin(49*(π/128))
- Q_8_8(0.94140625), // sin(50*(π/128))
- Q_8_8(0.94921875), // sin(51*(π/128))
- Q_8_8(0.953125), // sin(52*(π/128))
- Q_8_8(0.9609375), // sin(53*(π/128))
- Q_8_8(0.96875), // sin(54*(π/128))
- Q_8_8(0.97265625), // sin(55*(π/128))
- Q_8_8(0.98046875), // sin(56*(π/128))
- Q_8_8(0.984375), // sin(57*(π/128))
- Q_8_8(0.98828125), // sin(58*(π/128))
- Q_8_8(0.9921875), // sin(59*(π/128))
- Q_8_8(0.9921875), // sin(60*(π/128))
- Q_8_8(0.99609375), // sin(61*(π/128))
- Q_8_8(0.99609375), // sin(62*(π/128))
- Q_8_8(0.99609375), // sin(63*(π/128))
+void CopyPositionAndSpriteOffset(Entity* source, Entity* target) {
+ target->spriteOffsetX = source->spriteOffsetX;
+ target->spriteOffsetY = source->spriteOffsetY;
+ PositionRelative(source, target, 0, 0);
+}
+
+void sub_0806FA90(Entity* source, Entity* target, s32 offsetX, s32 offsetY) {
+ target->spriteOffsetX = source->spriteOffsetX;
+ target->spriteOffsetY = source->spriteOffsetY;
+ PositionRelative(source, target, Q_16_16(offsetX), Q_16_16(offsetY));
+}
+
+void SortEntityAbove(Entity* param_1, Entity* param_2) {
+ param_2->spritePriority.b0 = gSpriteSortAboveTable[param_1->spritePriority.b0];
+}
+
+void SortEntityBelow(Entity* param_1, Entity* param_2) {
+ param_2->spritePriority.b0 = gSpriteSortBelowTable[param_1->spritePriority.b0];
+}
+
+void sub_0806FB00(Entity* ent, u32 param_1, u32 param_2, u32 param_3) {
+ if (param_3 == 0) {
+ param_3 = 1;
+ }
+
+ ent->field_0x7c.BYTES.byte2 = 0;
+ ent->field_0x7c.BYTES.byte3 = param_3;
+ ent->field_0x80.HWORD = ent->x.HALF.HI;
+ ent->field_0x82.HWORD = ent->y.HALF.HI;
+ ent->cutsceneBeh.HWORD = param_1;
+ ent->field_0x86.HWORD = param_2;
+}
+
+bool32 sub_0806FB38(Entity* ent, u32 param_1, u32 param_2, u32 param_3) {
+ s32 val;
+ u32 rv;
+ if (ent->field_0x7c.BYTES.byte2 < ent->field_0x7c.BYTES.byte3) {
+ ent->field_0x7c.BYTES.byte2++;
+ ent->x.HALF.HI =
+ ((((((s16)ent->cutsceneBeh.HWORD - (s16)ent->field_0x80.HWORD) * ent->field_0x7c.BYTES.byte2) << 8) /
+ ent->field_0x7c.BYTES.byte3) >>
+ 8) +
+ ent->field_0x80.HWORD;
+ ent->y.HALF.HI =
+ (((((((s16)ent->field_0x86.HWORD - (s16)ent->field_0x82.HWORD) * ent->field_0x7c.BYTES.byte2) << 8) /
+ ent->field_0x7c.BYTES.byte3) >>
+ 8)) +
+ ent->field_0x82.HWORD;
+ rv = 0;
+ } else {
+ ent->x.HALF.HI = ent->cutsceneBeh.HWORD;
+ ent->y.HALF.HI = ent->field_0x86.HWORD;
+ rv = 1;
+ }
+ return rv;
+}
+
+void sub_0806FBB4(Entity* ent) {
+ if (gRoomTransition.field_0x4[1] != 0 || gPlayerState.heldObject == 0) {
+ ent->subAction = 6;
+ }
+}
+
+void AllocMutableHitbox(Entity* ent) {
+ UnloadHitbox(ent);
+ ent->hitbox = zMalloc(sizeof(Hitbox3D));
+}
+
+void UnloadHitbox(Entity* ent) {
+ zFree(ent->hitbox);
+ ent->hitbox = NULL;
+}
+
+bool32 CheckPlayerProximity(u32 x, u32 y, u32 distX, u32 DistY) {
+ s32 diffx = gPlayerEntity.x.HALF.HI - x;
+ s32 diffy = gPlayerEntity.y.HALF.HI - y;
+ u32 rv = 0;
+ if (diffx < distX && diffy < DistY) {
+ rv = 1;
+ }
+ return rv;
+}
+
+NONMATCH("asm/non_matching/coord/sub_0806FC24.inc", bool32 sub_0806FC24(u32 param_1, u32 param_2)) {
+ u32 rv;
+ u32 val = sub_08007DD6(param_1, gUnk_080046A4);
+ if (val) {
+ rv = (*(gUnk_080047F6 + (val << 2)) >> param_2) & 0x1;
+ } else {
+ rv = 0;
+ }
+
+ return rv;
+}
+END_NONMATCH
+
+const u16* sub_0806FC50(u32 param_1, u32 param_2) {
+ const u16* rv;
+ u32 val = sub_08007DD6(param_1, gUnk_080046A4);
+ if (!val || ((gUnk_080047F6[val << 2] >> param_2) & 0x1) == 0) {
+ rv = 0;
+ } else {
+ rv = gUnk_080047F6 + (val << 2);
+ }
+
+ return rv;
+}
+
+bool32 sub_0806FC80(Entity* ent, Entity* ent2, s32 param_3) {
+ u32 rv;
+ s16 x, y;
+ param_3 <<= 4;
+ if (param_3 >= sub_080041DC(ent, ent2->x.HALF.HI, ent2->y.HALF.HI)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+u32 sub_0806FCA0(Entity* this, Entity* other) {
+ return sub_0806F5A4(GetFacingDirection(this, other));
+}
+
+u32 sub_0806FCAC(Entity* this, Entity* other) {
+ return sub_0806F5B0(GetFacingDirection(this, other));
+}
+
+u32 EntityWithinDistance(Entity* ent, s32 x, s32 y, s32 distance) {
+ return PointInsideRadius(ent->x.HALF.HI - x, ent->y.HALF.HI - y, distance);
+}
+
+bool32 PointInsideRadius(s32 x, s32 y, s32 distance) {
+ return distance * distance >= (x * x + y * y);
+}
+
+void sub_0806FCF4(Entity* ent, s32 param_2, s32 param_3, s32 param_4) {
+ u32 r2 = 0;
+ if (param_2 < 0) {
+ param_2 = -param_2;
+ }
+
+ if (param_3) {
+ param_2 = (0x10000 / param_2);
+ param_2 = ((u32)(param_3 * param_2) >> 8);
+ r2 = param_3 - param_2;
+ }
+
+ if (param_4 == 0 || param_4 == 3) {
+ r2 = -r2;
+ }
+
+ if (param_4 == 0 || param_4 == 2) {
+ ent->spriteOffsetY = r2;
+ } else {
+ ent->spriteOffsetX = r2;
+ }
+}
+
+void sub_0806FD3C(Entity* this) {
+ this->spriteSettings.shadow = 0;
+ this->spritePriority.b1 = 0;
+}
+
+bool32 sub_0806FD54(Entity* this) {
+ u32 rv;
+ if ((gPlayerState.flags & 0x800000) == 0) {
+ rv = 0;
+ } else {
+ rv = EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 9, 0x48);
+ }
+
+ return rv;
+}
+
+void sub_0806FD8C() {
+ MemClear(&gUnk_020000C0, sizeof(gUnk_020000C0));
+}
+
+bool32 sub_0806FDA0(Entity* this) {
+ u32 index;
+ for (index = 1; index < ARRAY_COUNT(gUnk_020000C0); index++) {
+ if ((gUnk_020000C0[index].unk_00[0].unk_00.unk0) == 0) {
+ u32 tmp = 0xFF;
+ this->spriteAnimation[2] = index;
+ gUnk_020000C0[index].unk_00[0].unk_00.unk0 = 1;
+ gUnk_020000C0[index].unk_00[0].unk_01 = tmp;
+ gUnk_020000C0[index].unk_00[1].unk_01 = tmp;
+ gUnk_020000C0[index].unk_00[2].unk_01 = tmp;
+ gUnk_020000C0[index].unk_00[3].unk_01 = tmp;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+u32 LoadExtraSpriteData(Entity* ent, SpriteLoadData* data) {
+ SpriteLoadData* ptr;
+ u32 index;
+ struct_gUnk_020000C0_1* ptr2;
+ if (sub_0806FDA0(ent) == 0)
+ return 0;
+
+ UnloadOBJPalette(ent);
+ ptr2 = gUnk_020000C0[ent->spriteAnimation[2]].unk_00;
+ ptr = data;
+
+ for (index = 0; index < 4 && (((u16*)ptr)[1] & 0x3ff); index++) {
+ u32 pal = LoadObjPalette(ent, ((*(u32*)ptr) << 0x16) >> 0x16);
+ sub_0806FEE8(ptr2, (*(u32*)ptr << 6) >> 0x16, pal, (*(u32*)ptr << 0x10) >> 0x1a);
+ if (((u8*)ptr)[3] & 4) {
+ sub_0806FEFC(ptr2, ent);
+ }
+
+ ptr2++;
+ ptr++;
+ }
+
+ ent->spriteAnimation[1] = 0;
+ return 1;
+}
+
+void sub_0806FE84(Entity* ent) {
+ u32 index;
+ u32 spriteAnimation = ent->spriteAnimation[2];
+ ent->spriteAnimation[2] = 0;
+
+ if (spriteAnimation > 0 && spriteAnimation < 0x80) {
+ struct_gUnk_020000C0_1* startptr = gUnk_020000C0[spriteAnimation].unk_00;
+
+ for (index = 0; index <= 3; index++) {
+ sub_0801D244(startptr[index].unk_04.BYTES.byte1);
+ }
+
+ MemClear(startptr, sizeof(struct_gUnk_020000C0));
+ }
+}
+
+void sub_0806FEBC(Entity* ent, u32 param_2, u32 param_3) {
+ struct_gUnk_020000C0_1* ptr = &gUnk_020000C0[ent->spriteAnimation[2]].unk_00[param_2];
+ *((u32*)ptr) = 0;
+ ptr->unk_04.WORD = 0;
+ ptr->unk_08.WORD = 0;
+ ptr->unk_0C.WORD = param_3;
+ ptr->unk_00.unk0 = 1;
+ ptr->unk_00.unk1 = 1;
+}
+
+void sub_0806FEE8(struct_gUnk_020000C0_1* this, u32 param_2, u32 param_3, u32 param_4) {
+ this->unk_08.BYTES.byte0 = param_4;
+ this->unk_02 = param_2;
+ this->unk_04.BYTES.byte1 = param_3;
+ this->unk_00.unk3 = 1;
+ this->unk_00.unk0 = 1;
+}
+
+void sub_0806FEFC(struct_gUnk_020000C0_1* this, Entity* ent) {
+ this->unk_08.HALF.HI = ent->spriteVramOffset + this->unk_08.BYTES.byte0;
+ this->unk_00.unk2 = 1;
+}
+
+void sub_0806FF10(Entity* this, u32 param_2, u32 param_3) {
+ struct_gUnk_020000C0_1* ptr = &gUnk_020000C0[this->spriteAnimation[2]].unk_00[param_2];
+ s32 pallete = FindPalette(param_3);
+ if (ptr->unk_04.BYTES.byte1 != pallete) {
+ sub_0801D244(ptr->unk_04.BYTES.byte1);
+ ptr->unk_04.BYTES.byte1 = LoadObjPalette(this, param_3);
+ }
+}
+
+void sub_0806FF48(Entity* this, u32 param_2, u32 param_3) {
+ struct_gUnk_020000C0_1* ptr = &gUnk_020000C0[this->spriteAnimation[2]].unk_00[param_2];
+ ptr->unk_04.BYTES.byte0 = param_3;
+}
+
+void SetExtraSpriteFrame(Entity* this, u32 param_2, u32 param_3) {
+ struct_gUnk_020000C0* ptr1 = &gUnk_020000C0[this->spriteAnimation[2]];
+ struct_gUnk_020000C0_1* ptr2 = &ptr1->unk_00[param_2];
+ if (ptr2->unk_01 != param_3) {
+ ptr2->unk_01 = param_3;
+ ptr2->unk_00.unk3 = 1;
+ }
+}
+
+void SetSpriteSubEntryOffsetData1(Entity* this, u32 param_2, u32 param_3) {
+ struct_gUnk_020000C0* ptr1 = &gUnk_020000C0[this->spriteAnimation[2]];
+ struct_gUnk_020000C0_1* ptr2 = &ptr1->unk_00[param_2];
+ struct_gUnk_020000C0_1* ptr3 = &ptr1->unk_00[param_3];
+
+ u8* ptr4 = GetSpriteSubEntryOffsetDataPointer(ptr2->unk_02, ptr2->unk_01);
+ u8 val1 = ptr2->unk_04.BYTES.byte2;
+ u8 val2 = ptr4[0];
+ ptr3->unk_04.BYTES.byte2 = val1 + val2;
+ val1 = ptr2->unk_04.BYTES.byte3;
+ val2 = ptr4[1];
+ ptr3->unk_04.BYTES.byte3 = val1 + val2;
+}
+
+void sub_0806FFBC(Entity* this, u32 param_2, u32 param_3, u32 param_4) {
+ struct_gUnk_020000C0_1* ptr = &gUnk_020000C0[this->spriteAnimation[2]].unk_00[param_2];
+ ptr->unk_04.BYTES.byte2 = param_3;
+ ptr->unk_04.BYTES.byte3 = param_4;
+}
+
+void SetSpriteSubEntryOffsetData2(Entity* this, u32 param_2, u32 param_3) {
+ struct_gUnk_020000C0* ptr1 = &gUnk_020000C0[this->spriteAnimation[2]];
+ struct_gUnk_020000C0_1* ptr2 = &ptr1->unk_00[param_2];
+ struct_gUnk_020000C0_1* ptr3 = &ptr1->unk_00[param_3];
+
+ u8* ptr4 = GetSpriteSubEntryOffsetDataPointer(ptr2->unk_02, ptr2->unk_01);
+ u8 val1 = ptr2->unk_04.BYTES.byte2;
+ u8 val2 = ptr4[2];
+ ptr3->unk_04.BYTES.byte2 = val1 + val2;
+ val1 = ptr2->unk_04.BYTES.byte3;
+ val2 = ptr4[3];
+ ptr3->unk_04.BYTES.byte3 = val1 + val2;
+}
+
+void sub_0807000C(Entity* this) {
+ struct_gUnk_020000C0* ptr = &gUnk_020000C0[this->spriteAnimation[2]];
+ u32 val = sub_0807007C(ptr, 0);
+ val |= sub_0807007C(ptr, 1);
+ val |= sub_0807007C(ptr, 2);
+ val |= sub_0807007C(ptr, 3);
+
+ if (val) {
+ u8* ptr2 = (u8*)&gGFXSlots;
+ ptr2[this->spriteAnimation[0] * 12 + 7] = this->spriteAnimation[2];
+ ptr2[this->spriteAnimation[0] * 12 + 4] = (ptr2[this->spriteAnimation[0] * 12 + 4] & 0xf) | 0x30;
+ }
+}
+
+bool32 sub_0807007C(struct_gUnk_020000C0* this, u32 param_2) {
+ u8* ptr2;
+ u8* ptr3;
+ u32* spritePtr;
+ struct_gUnk_020000C0_1* ptr1 = &this->unk_00[param_2];
+ if ((ptr1->unk_00.unk3) == 0)
+ return 0;
+ if ((ptr1->unk_00.unk2) == 0)
+ return 0;
+ if (ptr1->unk_01 == 0xff)
+ return 0;
+
+ spritePtr = &gSpritePtrs[ptr1->unk_02 * 4];
+ ptr2 = (u8*)(spritePtr[1]);
+ if (ptr2 == 0)
+ return 0;
+
+ ptr3 = &ptr2[ptr1->unk_01 * 4];
+ ptr1->unk_08.BYTES.byte1 = *ptr3;
+ ptr1->unk_0C.WORD = spritePtr[2] + ((*(u16*)&ptr3[2]) << 5);
+ return 1;
+}
+
+NONMATCH("asm/non_matching/coord/GetSpriteSubEntryOffsetDataPointer.inc",
+ u8* GetSpriteSubEntryOffsetDataPointer(u32 param_1, u32 param_2)) {
+ u8* rv;
+ u32 val;
+ u32 val2;
+ val = ((u16*)(((u8*)gExtraFrameOffsets) + 0x10))[param_1];
+ val2 = ((u8*)gExtraFrameOffsets)[val + param_2] * 4;
+ rv = val2 + ((u8*)gExtraFrameOffsets);
+ rv = rv + *((u32*)((u8*)gExtraFrameOffsets));
+ return rv;
+}
+END_NONMATCH
+
+const u8 gUnk_08114F38[] = {
+ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0,
};
-const s16 gCosineTable[256] = {
- Q_8_8(1), // sin(64*(π/128))
- Q_8_8(0.99609375), // sin(65*(π/128))
- Q_8_8(0.99609375), // sin(66*(π/128))
- Q_8_8(0.99609375), // sin(67*(π/128))
- Q_8_8(0.9921875), // sin(68*(π/128))
- Q_8_8(0.9921875), // sin(69*(π/128))
- Q_8_8(0.98828125), // sin(70*(π/128))
- Q_8_8(0.984375), // sin(71*(π/128))
- Q_8_8(0.98046875), // sin(72*(π/128))
- Q_8_8(0.97265625), // sin(73*(π/128))
- Q_8_8(0.96875), // sin(74*(π/128))
- Q_8_8(0.9609375), // sin(75*(π/128))
- Q_8_8(0.953125), // sin(76*(π/128))
- Q_8_8(0.94921875), // sin(77*(π/128))
- Q_8_8(0.94140625), // sin(78*(π/128))
- Q_8_8(0.9296875), // sin(79*(π/128))
- Q_8_8(0.921875), // sin(80*(π/128))
- Q_8_8(0.9140625), // sin(81*(π/128))
- Q_8_8(0.90234375), // sin(82*(π/128))
- Q_8_8(0.890625), // sin(83*(π/128))
- Q_8_8(0.87890625), // sin(84*(π/128))
- Q_8_8(0.8671875), // sin(85*(π/128))
- Q_8_8(0.85546875), // sin(86*(π/128))
- Q_8_8(0.84375), // sin(87*(π/128))
- Q_8_8(0.828125), // sin(88*(π/128))
- Q_8_8(0.81640625), // sin(89*(π/128))
- Q_8_8(0.80078125), // sin(90*(π/128))
- Q_8_8(0.78515625), // sin(91*(π/128))
- Q_8_8(0.76953125), // sin(92*(π/128))
- Q_8_8(0.75390625), // sin(93*(π/128))
- Q_8_8(0.73828125), // sin(94*(π/128))
- Q_8_8(0.72265625), // sin(95*(π/128))
- Q_8_8(0.70703125), // sin(96*(π/128))
- Q_8_8(0.6875), // sin(97*(π/128))
- Q_8_8(0.66796875), // sin(98*(π/128))
- Q_8_8(0.65234375), // sin(99*(π/128))
- Q_8_8(0.6328125), // sin(100*(π/128))
- Q_8_8(0.61328125), // sin(101*(π/128))
- Q_8_8(0.59375), // sin(102*(π/128))
- Q_8_8(0.57421875), // sin(103*(π/128))
- Q_8_8(0.5546875), // sin(104*(π/128))
- Q_8_8(0.53125), // sin(105*(π/128))
- Q_8_8(0.51171875), // sin(106*(π/128))
- Q_8_8(0.4921875), // sin(107*(π/128))
- Q_8_8(0.46875), // sin(108*(π/128))
- Q_8_8(0.44921875), // sin(109*(π/128))
- Q_8_8(0.42578125), // sin(110*(π/128))
- Q_8_8(0.40234375), // sin(111*(π/128))
- Q_8_8(0.37890625), // sin(112*(π/128))
- Q_8_8(0.359375), // sin(113*(π/128))
- Q_8_8(0.3359375), // sin(114*(π/128))
- Q_8_8(0.3125), // sin(115*(π/128))
- Q_8_8(0.2890625), // sin(116*(π/128))
- Q_8_8(0.265625), // sin(117*(π/128))
- Q_8_8(0.2421875), // sin(118*(π/128))
- Q_8_8(0.21875), // sin(119*(π/128))
- Q_8_8(0.19140625), // sin(120*(π/128))
- Q_8_8(0.16796875), // sin(121*(π/128))
- Q_8_8(0.14453125), // sin(122*(π/128))
- Q_8_8(0.12109375), // sin(123*(π/128))
- Q_8_8(0.09765625), // sin(124*(π/128))
- Q_8_8(0.0703125), // sin(125*(π/128))
- Q_8_8(0.046875), // sin(126*(π/128))
- Q_8_8(0.0234375), // sin(127*(π/128))
- Q_8_8(0), // sin(128*(π/128))
- Q_8_8(-0.0234375), // sin(129*(π/128))
- Q_8_8(-0.046875), // sin(130*(π/128))
- Q_8_8(-0.0703125), // sin(131*(π/128))
- Q_8_8(-0.09765625), // sin(132*(π/128))
- Q_8_8(-0.12109375), // sin(133*(π/128))
- Q_8_8(-0.14453125), // sin(134*(π/128))
- Q_8_8(-0.16796875), // sin(135*(π/128))
- Q_8_8(-0.19140625), // sin(136*(π/128))
- Q_8_8(-0.21875), // sin(137*(π/128))
- Q_8_8(-0.2421875), // sin(138*(π/128))
- Q_8_8(-0.265625), // sin(139*(π/128))
- Q_8_8(-0.2890625), // sin(140*(π/128))
- Q_8_8(-0.3125), // sin(141*(π/128))
- Q_8_8(-0.3359375), // sin(142*(π/128))
- Q_8_8(-0.359375), // sin(143*(π/128))
- Q_8_8(-0.37890625), // sin(144*(π/128))
- Q_8_8(-0.40234375), // sin(145*(π/128))
- Q_8_8(-0.42578125), // sin(146*(π/128))
- Q_8_8(-0.44921875), // sin(147*(π/128))
- Q_8_8(-0.46875), // sin(148*(π/128))
- Q_8_8(-0.4921875), // sin(149*(π/128))
- Q_8_8(-0.51171875), // sin(150*(π/128))
- Q_8_8(-0.53125), // sin(151*(π/128))
- Q_8_8(-0.5546875), // sin(152*(π/128))
- Q_8_8(-0.57421875), // sin(153*(π/128))
- Q_8_8(-0.59375), // sin(154*(π/128))
- Q_8_8(-0.61328125), // sin(155*(π/128))
- Q_8_8(-0.6328125), // sin(156*(π/128))
- Q_8_8(-0.65234375), // sin(157*(π/128))
- Q_8_8(-0.66796875), // sin(158*(π/128))
- Q_8_8(-0.6875), // sin(159*(π/128))
- Q_8_8(-0.70703125), // sin(160*(π/128))
- Q_8_8(-0.72265625), // sin(161*(π/128))
- Q_8_8(-0.73828125), // sin(162*(π/128))
- Q_8_8(-0.75390625), // sin(163*(π/128))
- Q_8_8(-0.76953125), // sin(164*(π/128))
- Q_8_8(-0.78515625), // sin(165*(π/128))
- Q_8_8(-0.80078125), // sin(166*(π/128))
- Q_8_8(-0.81640625), // sin(167*(π/128))
- Q_8_8(-0.828125), // sin(168*(π/128))
- Q_8_8(-0.84375), // sin(169*(π/128))
- Q_8_8(-0.85546875), // sin(170*(π/128))
- Q_8_8(-0.8671875), // sin(171*(π/128))
- Q_8_8(-0.87890625), // sin(172*(π/128))
- Q_8_8(-0.890625), // sin(173*(π/128))
- Q_8_8(-0.90234375), // sin(174*(π/128))
- Q_8_8(-0.9140625), // sin(175*(π/128))
- Q_8_8(-0.921875), // sin(176*(π/128))
- Q_8_8(-0.9296875), // sin(177*(π/128))
- Q_8_8(-0.94140625), // sin(178*(π/128))
- Q_8_8(-0.94921875), // sin(179*(π/128))
- Q_8_8(-0.953125), // sin(180*(π/128))
- Q_8_8(-0.9609375), // sin(181*(π/128))
- Q_8_8(-0.96875), // sin(182*(π/128))
- Q_8_8(-0.97265625), // sin(183*(π/128))
- Q_8_8(-0.98046875), // sin(184*(π/128))
- Q_8_8(-0.984375), // sin(185*(π/128))
- Q_8_8(-0.98828125), // sin(186*(π/128))
- Q_8_8(-0.9921875), // sin(187*(π/128))
- Q_8_8(-0.9921875), // sin(188*(π/128))
- Q_8_8(-0.99609375), // sin(189*(π/128))
- Q_8_8(-0.99609375), // sin(190*(π/128))
- Q_8_8(-0.99609375), // sin(191*(π/128))
- Q_8_8(-1), // sin(192*(π/128))
- Q_8_8(-0.99609375), // sin(193*(π/128))
- Q_8_8(-0.99609375), // sin(194*(π/128))
- Q_8_8(-0.99609375), // sin(195*(π/128))
- Q_8_8(-0.9921875), // sin(196*(π/128))
- Q_8_8(-0.9921875), // sin(197*(π/128))
- Q_8_8(-0.98828125), // sin(198*(π/128))
- Q_8_8(-0.984375), // sin(199*(π/128))
- Q_8_8(-0.98046875), // sin(200*(π/128))
- Q_8_8(-0.97265625), // sin(201*(π/128))
- Q_8_8(-0.96875), // sin(202*(π/128))
- Q_8_8(-0.9609375), // sin(203*(π/128))
- Q_8_8(-0.953125), // sin(204*(π/128))
- Q_8_8(-0.94921875), // sin(205*(π/128))
- Q_8_8(-0.94140625), // sin(206*(π/128))
- Q_8_8(-0.9296875), // sin(207*(π/128))
- Q_8_8(-0.921875), // sin(208*(π/128))
- Q_8_8(-0.9140625), // sin(209*(π/128))
- Q_8_8(-0.90234375), // sin(210*(π/128))
- Q_8_8(-0.890625), // sin(211*(π/128))
- Q_8_8(-0.87890625), // sin(212*(π/128))
- Q_8_8(-0.8671875), // sin(213*(π/128))
- Q_8_8(-0.85546875), // sin(214*(π/128))
- Q_8_8(-0.84375), // sin(215*(π/128))
- Q_8_8(-0.828125), // sin(216*(π/128))
- Q_8_8(-0.81640625), // sin(217*(π/128))
- Q_8_8(-0.80078125), // sin(218*(π/128))
- Q_8_8(-0.78515625), // sin(219*(π/128))
- Q_8_8(-0.76953125), // sin(220*(π/128))
- Q_8_8(-0.75390625), // sin(221*(π/128))
- Q_8_8(-0.73828125), // sin(222*(π/128))
- Q_8_8(-0.72265625), // sin(223*(π/128))
- Q_8_8(-0.70703125), // sin(224*(π/128))
- Q_8_8(-0.6875), // sin(225*(π/128))
- Q_8_8(-0.66796875), // sin(226*(π/128))
- Q_8_8(-0.65234375), // sin(227*(π/128))
- Q_8_8(-0.6328125), // sin(228*(π/128))
- Q_8_8(-0.61328125), // sin(229*(π/128))
- Q_8_8(-0.59375), // sin(230*(π/128))
- Q_8_8(-0.57421875), // sin(231*(π/128))
- Q_8_8(-0.5546875), // sin(232*(π/128))
- Q_8_8(-0.53125), // sin(233*(π/128))
- Q_8_8(-0.51171875), // sin(234*(π/128))
- Q_8_8(-0.4921875), // sin(235*(π/128))
- Q_8_8(-0.46875), // sin(236*(π/128))
- Q_8_8(-0.44921875), // sin(237*(π/128))
- Q_8_8(-0.42578125), // sin(238*(π/128))
- Q_8_8(-0.40234375), // sin(239*(π/128))
- Q_8_8(-0.37890625), // sin(240*(π/128))
- Q_8_8(-0.359375), // sin(241*(π/128))
- Q_8_8(-0.3359375), // sin(242*(π/128))
- Q_8_8(-0.3125), // sin(243*(π/128))
- Q_8_8(-0.2890625), // sin(244*(π/128))
- Q_8_8(-0.265625), // sin(245*(π/128))
- Q_8_8(-0.2421875), // sin(246*(π/128))
- Q_8_8(-0.21875), // sin(247*(π/128))
- Q_8_8(-0.19140625), // sin(248*(π/128))
- Q_8_8(-0.16796875), // sin(249*(π/128))
- Q_8_8(-0.14453125), // sin(250*(π/128))
- Q_8_8(-0.12109375), // sin(251*(π/128))
- Q_8_8(-0.09765625), // sin(252*(π/128))
- Q_8_8(-0.0703125), // sin(253*(π/128))
- Q_8_8(-0.046875), // sin(254*(π/128))
- Q_8_8(-0.0234375), // sin(255*(π/128))
- Q_8_8(0), // sin(256*(π/128))
- Q_8_8(0.0234375), // sin(257*(π/128))
- Q_8_8(0.046875), // sin(258*(π/128))
- Q_8_8(0.0703125), // sin(259*(π/128))
- Q_8_8(0.09765625), // sin(260*(π/128))
- Q_8_8(0.12109375), // sin(261*(π/128))
- Q_8_8(0.14453125), // sin(262*(π/128))
- Q_8_8(0.16796875), // sin(263*(π/128))
- Q_8_8(0.19140625), // sin(264*(π/128))
- Q_8_8(0.21875), // sin(265*(π/128))
- Q_8_8(0.2421875), // sin(266*(π/128))
- Q_8_8(0.265625), // sin(267*(π/128))
- Q_8_8(0.2890625), // sin(268*(π/128))
- Q_8_8(0.3125), // sin(269*(π/128))
- Q_8_8(0.3359375), // sin(270*(π/128))
- Q_8_8(0.359375), // sin(271*(π/128))
- Q_8_8(0.37890625), // sin(272*(π/128))
- Q_8_8(0.40234375), // sin(273*(π/128))
- Q_8_8(0.42578125), // sin(274*(π/128))
- Q_8_8(0.44921875), // sin(275*(π/128))
- Q_8_8(0.46875), // sin(276*(π/128))
- Q_8_8(0.4921875), // sin(277*(π/128))
- Q_8_8(0.51171875), // sin(278*(π/128))
- Q_8_8(0.53125), // sin(279*(π/128))
- Q_8_8(0.5546875), // sin(280*(π/128))
- Q_8_8(0.57421875), // sin(281*(π/128))
- Q_8_8(0.59375), // sin(282*(π/128))
- Q_8_8(0.61328125), // sin(283*(π/128))
- Q_8_8(0.6328125), // sin(284*(π/128))
- Q_8_8(0.65234375), // sin(285*(π/128))
- Q_8_8(0.66796875), // sin(286*(π/128))
- Q_8_8(0.6875), // sin(287*(π/128))
- Q_8_8(0.70703125), // sin(288*(π/128))
- Q_8_8(0.72265625), // sin(289*(π/128))
- Q_8_8(0.73828125), // sin(290*(π/128))
- Q_8_8(0.75390625), // sin(291*(π/128))
- Q_8_8(0.76953125), // sin(292*(π/128))
- Q_8_8(0.78515625), // sin(293*(π/128))
- Q_8_8(0.80078125), // sin(294*(π/128))
- Q_8_8(0.81640625), // sin(295*(π/128))
- Q_8_8(0.828125), // sin(296*(π/128))
- Q_8_8(0.84375), // sin(297*(π/128))
- Q_8_8(0.85546875), // sin(298*(π/128))
- Q_8_8(0.8671875), // sin(299*(π/128))
- Q_8_8(0.87890625), // sin(300*(π/128))
- Q_8_8(0.890625), // sin(301*(π/128))
- Q_8_8(0.90234375), // sin(302*(π/128))
- Q_8_8(0.9140625), // sin(303*(π/128))
- Q_8_8(0.921875), // sin(304*(π/128))
- Q_8_8(0.9296875), // sin(305*(π/128))
- Q_8_8(0.94140625), // sin(306*(π/128))
- Q_8_8(0.94921875), // sin(307*(π/128))
- Q_8_8(0.953125), // sin(308*(π/128))
- Q_8_8(0.9609375), // sin(309*(π/128))
- Q_8_8(0.96875), // sin(310*(π/128))
- Q_8_8(0.97265625), // sin(311*(π/128))
- Q_8_8(0.98046875), // sin(312*(π/128))
- Q_8_8(0.984375), // sin(313*(π/128))
- Q_8_8(0.98828125), // sin(314*(π/128))
- Q_8_8(0.9921875), // sin(315*(π/128))
- Q_8_8(0.9921875), // sin(316*(π/128))
- Q_8_8(0.99609375), // sin(317*(π/128))
- Q_8_8(0.99609375), // sin(318*(π/128))
- Q_8_8(0.99609375), // sin(319*(π/128))
+const u8 gUnk_08114F58[] = {
+ 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 0, 0,
};
+
+const u8 gSpriteSortAboveTable[] = { 0, 0, 1, 2, 3, 4, 5, 6 };
+const u8 gSpriteSortBelowTable[] = { 1, 2, 3, 4, 5, 6, 7, 7 };
diff --git a/src/enemy.c b/src/enemy.c
index b0594e0f..faf5d59f 100644
--- a/src/enemy.c
+++ b/src/enemy.c
@@ -468,7 +468,7 @@ void (*const gEnemyFunctions[])(Entity* ent) = {
[FALLING_BOULDER] = FallingBoulder,
[BOBOMB] = Bobomb,
[WALL_MASTER_2] = WallMaster2,
- [GLEEROCK] = Gleerok,
+ [GLEEROK] = Gleerok,
[VAATI_EYES_MACRO] = VaatiEyesMacro,
[TEKTITE] = Tektite,
[WIZZROBE_WIND] = WizzrobeWind,
@@ -505,7 +505,7 @@ void (*const gEnemyFunctions[])(Entity* ent) = {
[BOW_MOBLIN] = BowMoblin,
[LAKITU] = Lakitu,
[LAKITU_CLOUD] = LakituCloud,
- [ENEMY_49] = Enemy49,
+ [TORCH_TRAP] = TorchTrap,
[VAATI_REBORN_ENEMY] = VaatiRebornEnemy,
[VAATI_PROJECTILE] = VaatiProjectile,
[BALL_CHAIN_SOLIDER] = BallChainSoldier,
diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c
index b73c8104..1df406b1 100644
--- a/src/enemy/acroBandits.c
+++ b/src/enemy/acroBandits.c
@@ -8,16 +8,6 @@
#include "enemy.h"
#include "functions.h"
-extern u32 sub_080002D4(s32, s32, u32);
-extern s32 sub_080012DC(Entity*);
-extern u32 sub_08031E04(Entity*);
-extern void sub_08031E48(Entity*, Entity*);
-extern void sub_08032290(Entity*);
-extern u32 sub_080322A4(Entity*);
-void sub_080322E8(Entity*);
-extern void sub_08032338(Entity*);
-extern Entity* sub_08049DF4(u32);
-
extern Entity* gUnk_020000B0;
extern void (*const gUnk_080012C8[])(Entity*);
extern void (*const gUnk_080CE56C[])(Entity*);
@@ -114,7 +104,7 @@ void sub_080318DC(Entity* this) {
void sub_08031A60(Entity* this) {
if (this->iframes > 0)
- GravityUpdate(this, 0x1800);
+ GravityUpdate(this, Q_8_8(24.0));
sub_08001324(this);
}
@@ -305,7 +295,7 @@ u32 sub_08031E04(Entity* this) {
return 0;
tmp = &gUnk_080CE5C0[this->frame & 6];
- return sub_0806FCB8(this, ent->x.HALF.HI + tmp[0], ent->y.HALF.HI + tmp[1], 0x50);
+ return EntityWithinDistance(this, ent->x.HALF.HI + tmp[0], ent->y.HALF.HI + tmp[1], 0x50);
}
void sub_08031E48(Entity* this, Entity* child) {
@@ -325,7 +315,7 @@ void sub_08031E90(Entity* this) {
void sub_08031EA8(Entity* this) {
this->action = 1;
this->spritePriority.b1 = 1;
- this->zVelocity = 0x40000;
+ this->zVelocity = Q_16_16(4.0);
this->z.HALF.HI = (4 - this->type2) * 0xe;
this->field_0x78.HALF.HI = Random();
InitializeAnimation(this, 4);
@@ -335,12 +325,12 @@ void sub_08031EE8(Entity* this) {
int draw;
this->z.WORD -= this->zVelocity;
- this->zVelocity -= 0x1800;
+ this->zVelocity -= Q_16_16(3.0 / 32.0);
if (this->z.HALF.HI < 1) {
draw = this->spriteSettings.draw;
if (!draw)
- EnqueueSFX(299);
+ EnqueueSFX(SFX_12B);
this->spriteSettings.draw = 1;
}
@@ -413,7 +403,7 @@ void sub_08032008(Entity* this) {
ProcessMovement(this);
} else {
if (this->field_0x76.HALF.HI == 0) {
- if (sub_0806FCB8(this, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) {
+ if (EntityWithinDistance(this, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) {
this->field_0x76.HALF.HI = 1;
this->direction = GetFacingDirection(this, parent);
sub_080322E8(this);
@@ -452,7 +442,7 @@ void sub_08032160(Entity* this) {
this->spriteSettings.flipX = 0;
}
this->speed = 0xf0;
- this->zVelocity = 0x12000;
+ this->zVelocity = Q_16_16(1.125);
this->spritePriority.b1 = 1;
InitializeAnimation(this, 12);
}
@@ -487,7 +477,7 @@ void sub_08032204(Entity* this) {
}
void sub_08032248(Entity* this) {
- if (GravityUpdate(this, 0x1800) == 0) {
+ if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
if (this->frame & 0x80) {
((Entity*)this->field_0x7c.WORD)->actionDelay--;
diff --git a/src/enemy/ballChainSoldier.c b/src/enemy/ballChainSoldier.c
new file mode 100644
index 00000000..dad421f3
--- /dev/null
+++ b/src/enemy/ballChainSoldier.c
@@ -0,0 +1,342 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "enemy.h"
+#include "functions.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0x10];
+ u16 unk_78;
+ u8 unk_7a;
+ u8 unk_7b;
+ u8 unk_7c;
+ u8 unk_7d;
+ u8 unk_7e;
+ u8 unk_7f;
+} BallChainSoldierEntity;
+
+extern Entity* gUnk_020000B0;
+
+void (*const gUnk_080D06E0[])(BallChainSoldierEntity*);
+void (*const gUnk_080D06F8[])(BallChainSoldierEntity*);
+const u8 gUnk_080D0724[];
+const u16 gUnk_080D0728[];
+const u16 gUnk_080D0730[];
+
+extern u32 sub_0804A044(Entity*, Entity*, u32);
+extern void sub_0803E86C(BallChainSoldierEntity*);
+extern void sub_0803E9A4(BallChainSoldierEntity*);
+extern bool32 sub_0803E9D4(BallChainSoldierEntity*);
+extern void sub_0803E8CC(BallChainSoldierEntity*);
+extern void sub_0803E92C(BallChainSoldierEntity*);
+extern bool32 sub_0803EA64(BallChainSoldierEntity*);
+extern void sub_0803E94C(BallChainSoldierEntity*, u32);
+extern bool32 sub_0803EAD0(BallChainSoldierEntity*, u32);
+
+void BallChainSoldier(Entity* this) {
+ EnemyFunctionHandler(this, (EntityActionArray)gUnk_080D06E0);
+}
+
+void sub_0803E538(BallChainSoldierEntity* this) {
+ gUnk_080D06F8[super->action](this);
+}
+
+void sub_0803E550(BallChainSoldierEntity* this) {
+ sub_0804AA30(super, gUnk_080D06E0);
+}
+
+void sub_0803E560(BallChainSoldierEntity* this) {
+ sub_08001324(super);
+ sub_0803E538(this);
+}
+
+void BallChainSoldier_CreateDeathFx(BallChainSoldierEntity* this) {
+ CreateDeathFx(super, 0xff, 0x57);
+}
+
+void nullsub_20(BallChainSoldierEntity* this) {
+}
+
+void BallChainSoldier_Init(BallChainSoldierEntity* this) {
+ Entity* ent;
+ sub_0804A720(super);
+ ent = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
+ if (ent == NULL)
+ return;
+
+ ent->parent = super;
+ super->child = ent;
+ COLLISION_ON(super);
+ super->spriteSettings.draw = 1;
+ super->animationState = Random() & 3;
+ this->unk_7b = 0;
+ this->unk_7c = 0;
+ this->unk_7e = 0x20;
+ this->unk_7f = 0xfe;
+ InitAnimationForceUpdate(super, super->animationState << 2);
+ sub_0803E86C(this);
+}
+
+void sub_0803E5E8(BallChainSoldierEntity* this) {
+ this->unk_7c -= 0xa;
+ sub_0803E9A4(this);
+ if (sub_0803E9D4(this) == 0) {
+ if (--this->unk_78 == 0) {
+ sub_0803E8CC(this);
+ }
+ }
+}
+
+void sub_0803E61C(BallChainSoldierEntity* this) {
+ this->unk_7c -= 0xa;
+ sub_0803E9A4(this);
+ if (sub_0803E9D4(this) == 0) {
+ if (super->knockbackDuration == 0) {
+ if (ProcessMovement(super) == 0) {
+ sub_0803E86C(this);
+ return;
+ }
+ }
+
+ if (--this->unk_78 == 0) {
+ sub_0803E92C(this);
+ }
+ }
+}
+
+void sub_0803E66C(BallChainSoldierEntity* this) {
+ this->unk_7c -= 0x10;
+ sub_0803E9A4(this);
+ if (this->unk_7e <= 0x21) {
+ this->unk_7e++;
+ }
+
+ if (!sub_08049FDC(super, 1) || sub_0803EA64(this) == 0) {
+ super->action = 4;
+ this->unk_7b = 0;
+ }
+}
+
+void sub_0803E6B4(BallChainSoldierEntity* this) {
+ this->unk_7c -= 0xa;
+ sub_0803E9A4(this);
+ if (this->unk_7e > 0x20) {
+ this->unk_7e--;
+ } else {
+ sub_0803E86C(this);
+ }
+}
+
+void sub_0803E6E0(BallChainSoldierEntity* this) {
+ this->unk_7c -= 0xc;
+ sub_0803E9A4(this);
+ this->unk_7e -= 4;
+ if ((s8)this->unk_7e <= 0) {
+ this->unk_7e = 0;
+ super->action = 6;
+ super->actionDelay = 0x1e;
+ InitAnimationForceUpdate(super, super->animationState + 0x20);
+ }
+}
+
+void sub_0803E71C(BallChainSoldierEntity* this) {
+ if (--super->actionDelay == 0) {
+ super->action = 7;
+ super->actionDelay = 1;
+ this->unk_7c = gUnk_080D0724[super->animationState];
+ this->unk_7b = 0;
+ this->unk_7f = 0xf6;
+ EnqueueSFX(SFX_15B);
+ }
+}
+
+void sub_0803E75C(BallChainSoldierEntity* this) {
+ if ((super->frame & 0x80) == 0) {
+ UpdateAnimationSingleFrame(super);
+ } else {
+ if (--super->actionDelay == 0) {
+ super->actionDelay = 2;
+ this->unk_7f++;
+ }
+
+ if (this->unk_7f) {
+ this->unk_7e += 5;
+ } else {
+ super->action = 8;
+ super->actionDelay = 0x1e;
+ InitScreenShake(8, 0);
+ }
+ }
+}
+
+void sub_0803E7B4(BallChainSoldierEntity* this) {
+ if (--super->actionDelay == 0) {
+ super->action = 9;
+ }
+}
+
+void sub_0803E7CC(BallChainSoldierEntity* this) {
+ this->unk_7e -= 2;
+ if (this->unk_7e <= 0xa) {
+ super->action = 0xa;
+ super->actionDelay = 0x5a;
+ super->direction = DirectionFromAnimationState(super->animationState);
+ this->unk_7c = 0;
+ this->unk_7f = 0xfe;
+ sub_0803E94C(this, 0x10);
+ } else if (this->unk_7e <= 0x12) {
+ COLLISION_OFF(super->child);
+ }
+}
+
+void sub_0803E818(BallChainSoldierEntity* this) {
+ if (super->actionDelay) {
+ if (--super->actionDelay == 0) {
+ COLLISION_ON(super->child);
+ sub_0803E94C(this, 0);
+ }
+ } else {
+ this->unk_7c -= 0xa;
+ sub_0803E9A4(this);
+ if (++this->unk_7e > 0x1f) {
+ sub_0803E86C(this);
+ }
+ }
+}
+
+void sub_0803E86C(BallChainSoldierEntity* this) {
+ if (sub_08049FDC(super, 1) && sub_0803EAD0(this, 0x50)) {
+ super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
+ }
+
+ super->action = 1;
+ this->unk_78 = gUnk_080D0728[Random() & 3];
+ this->unk_7a = 4;
+ sub_0803E94C(this, 0);
+}
+
+void sub_0803E8CC(BallChainSoldierEntity* this) {
+ u32 rand = Random();
+ u32 temp;
+ u32 dir;
+ if (sub_08049FA0(super) == 0 && (rand & 3)) {
+ dir = sub_08049EE4(super) + 4;
+ temp = 0x18;
+ } else {
+ temp = 0x18;
+ dir = rand;
+ }
+
+ super->direction = dir & temp;
+ super->action = 2;
+ this->unk_78 = gUnk_080D0730[(rand >> 0x10) & 3];
+ this->unk_7a = 4;
+ sub_0803E94C(this, 0x10);
+}
+
+void sub_0803E92C(BallChainSoldierEntity* this) {
+ if (Random() & 1) {
+ sub_0803E86C(this);
+ } else {
+ sub_0803E8CC(this);
+ }
+}
+
+void sub_0803E94C(BallChainSoldierEntity* this, u32 arg2) {
+ s32 animationState = DirectionToAnimationState(super->direction);
+ if ((super->animIndex & 0x10) == arg2) {
+ u32 dir = super->direction & 7;
+ s32 currentAnimationState = super->animationState;
+ if (dir == 4) {
+ if (((currentAnimationState - (super->direction >> 3)) & 3) <= 1)
+ return;
+ }
+ if (animationState == currentAnimationState)
+ return;
+ }
+
+ super->animationState = animationState;
+ animationState = arg2 + (super->animIndex & 3) + animationState * 4;
+ InitAnimationForceUpdate(super, animationState);
+}
+
+void sub_0803E9A4(BallChainSoldierEntity* this) {
+ s32 val = ((this->unk_7c + 0x20) & 0xff) >> 6;
+ if ((super->animIndex & 3) == val)
+ return;
+ InitAnimationForceUpdate(super, val + (super->animIndex & -4));
+}
+
+bool32 sub_0803E9D4(BallChainSoldierEntity* this) {
+ u32 dir;
+ if (sub_08049FDC(super, 1)) {
+ if (sub_0803EAD0(this, 0x38)) {
+ super->action = 3;
+ super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
+ this->unk_7b = 1;
+ sub_0803E94C(this, 0);
+ return 1;
+ } else if (sub_0803EAD0(this, 0x4e)) {
+ dir = sub_0804A044(super, gUnk_020000B0, 0x12);
+ if (dir != 0xff) {
+ if (--this->unk_7a != 0)
+ return 0;
+ super->action = 5;
+ super->direction = dir;
+ this->unk_7a = 4;
+ sub_0803E94C(this, 0);
+ return 1;
+ }
+ }
+ }
+
+ this->unk_7a = 4;
+ return 0;
+}
+
+bool32 sub_0803EA64(BallChainSoldierEntity* this) {
+ u32 dir;
+ if (sub_08049FDC(super, 1)) {
+ if (sub_0803EAD0(this, 0x4e)) {
+ dir = sub_0804A044(super, gUnk_020000B0, 0x12);
+ if (dir != 0xff) {
+ if (--this->unk_7a != 0)
+ return 1;
+ super->action = 5;
+ super->direction = dir;
+ sub_0803E94C(this, 0);
+ return 1;
+ }
+ }
+
+ if (sub_0803EAD0(this, 0x38))
+ return 1;
+ }
+
+ this->unk_7a = 4;
+ return 0;
+}
+
+bool32 sub_0803EAD0(BallChainSoldierEntity* this, u32 distance) {
+ return EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI - 4, distance);
+}
+
+void (*const gUnk_080D06E0[])(BallChainSoldierEntity*) = {
+ sub_0803E538,
+ sub_0803E550,
+ sub_0803E560,
+ BallChainSoldier_CreateDeathFx,
+ (void (*const)(BallChainSoldierEntity*))sub_08001242,
+ nullsub_20,
+};
+
+void (*const gUnk_080D06F8[])(BallChainSoldierEntity*) = {
+ BallChainSoldier_Init, sub_0803E5E8, sub_0803E61C, sub_0803E66C, sub_0803E6B4, sub_0803E6E0,
+ sub_0803E71C, sub_0803E75C, sub_0803E7B4, sub_0803E7CC, sub_0803E818,
+};
+
+const u8 gUnk_080D0724[] = { 0, 0x44, 0x80, 0xBC };
+
+const u16 gUnk_080D0728[] = { 0x1E, 0x32, 0x46, 0x5A };
+
+const u16 gUnk_080D0730[] = { 0x3C, 0x5A, 0x78, 0x96 };
diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c
index c03ff919..6b5ddbb6 100644
--- a/src/enemy/beetle.c
+++ b/src/enemy/beetle.c
@@ -109,7 +109,7 @@ void sub_080218CC(Entity* this) {
this->spriteSettings.draw = 1;
this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
this->speed = 0x100;
- this->zVelocity = 0x12000;
+ this->zVelocity = Q_16_16(1.125);
}
GetNextFrame(this);
@@ -137,7 +137,7 @@ void sub_08021984(Entity* this) {
this->z.HALF.HI = -0x80;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
- EnqueueSFX(0x12d);
+ EnqueueSFX(SFX_12D);
}
if (GravityUpdate(this, 0x1800) == 0) {
@@ -204,7 +204,7 @@ void sub_08021AD8(Entity* this) {
return;
}
this->direction = (u8)tmp;
- EnqueueSFX(0x7c);
+ EnqueueSFX(SFX_PLY_JUMP);
}
sub_080AEFE0(this);
if (!GravityUpdate(this, 0x1800))
@@ -242,7 +242,7 @@ void sub_08021B64(Entity* this) {
if (iVar4 == 0) {
this->action = 6;
- this->zVelocity = 0x10000;
+ this->zVelocity = Q_16_16(1.0);
((u8*)&this->field_0x86)[1] = 0;
if (gPlayerEntity.direction != 0xff) {
this->direction = 0x10 ^ gPlayerEntity.direction;
@@ -303,7 +303,7 @@ u32 sub_08021D00(Entity* this) {
} else {
this->action = 4;
this->actionDelay = 1;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
InitializeAnimation(this, 4);
ret = 1;
}
diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c
index 815b0dcd..3af99a33 100644
--- a/src/enemy/bladeTrap.c
+++ b/src/enemy/bladeTrap.c
@@ -24,7 +24,7 @@ void BladeTrap(Entity* this) {
if (!(--this->field_0x74.HWORD)) {
if (!(this->direction & 0x80)) {
- EnqueueSFX(0x74);
+ EnqueueSFX(SFX_METAL_CLINK);
}
sub_080A2CC0(this, &this->child, &this->field_0x74.HWORD);
}
diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c
index ebc47375..116febb2 100644
--- a/src/enemy/bobomb.c
+++ b/src/enemy/bobomb.c
@@ -55,13 +55,13 @@ void sub_0802C688(Entity* this) {
switch (this->field_0x82.HALF.LO) {
case 1:
sub_0802CB68(this);
- EnqueueSFX(0x14d);
+ EnqueueSFX(SFX_14D);
break;
case 2:
this->action = 3;
this->hitType = 0x6e;
this->field_0xf = 1;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->speed = 0;
this->field_0x80.HALF.HI = 1;
InitializeAnimation(this, this->direction >> 4 | 6);
@@ -79,7 +79,7 @@ void sub_0802C7AC(Entity* this) {
if (this->field_0x82.HALF.LO != 2) {
this->speed = this->field_0x82.HALF.LO ? 0x200 : 0x80;
}
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
} else {
@@ -232,7 +232,7 @@ void sub_0802CA94(Entity* this) {
COLLISION_OFF(this);
this->field_0xf = 1;
this->spritePriority.b1 = 1;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->speed = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
@@ -245,7 +245,7 @@ void sub_0802CAF8(Entity* this) {
sub_0802CBC4(this);
} else {
if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) {
- EnqueueSFX(0x104);
+ EnqueueSFX(SFX_104);
}
sub_0802CC18(this);
sub_08078930(this);
@@ -300,7 +300,7 @@ void sub_0802CBC4(Entity* this) {
void sub_0802CC18(Entity* this) {
if (--this->field_0x80.HALF.LO == 0) {
this->field_0x80.HALF.LO = 28;
- EnqueueSFX(0x14d);
+ EnqueueSFX(SFX_14D);
}
}
diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c
index dbdda527..1ceea7db 100644
--- a/src/enemy/bombPeahat.c
+++ b/src/enemy/bombPeahat.c
@@ -12,12 +12,6 @@
#include "object.h"
#include "functions.h"
-extern void sub_08078954(Entity*);
-extern void sub_08078930(Entity*);
-extern s32 sub_080012DC(Entity*);
-extern Entity* sub_08049DF4(u32);
-extern void sub_08079BD8(Entity*);
-
void sub_0802AD1C(Entity*, u32);
void sub_0802AD54(Entity*);
void sub_0802B048(Entity*);
@@ -194,9 +188,6 @@ void sub_0802AA40(Entity* this) {
}
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0802AAC0.inc", void sub_0802AAC0(Entity* this))
-#else
void sub_0802AAC0(Entity* this) {
sub_0802AC40(this);
if (--this->field_0xf == 0) {
@@ -210,24 +201,52 @@ void sub_0802AAC0(Entity* this) {
} else if (ent->next == NULL) {
this->field_0x80.HALF.HI = 0;
this->child = NULL;
+#ifdef EU
+ } else if (ent->actionDelay == 0) {
+ if (sub_080002E0(COORD_TO_TILE(this), 1) == 0) {
+ if (EntityInRectRadius(this, &gPlayerEntity, 0x10, 0x10) && ent->field_0xf <= 0x50) {
+ this->field_0x80.HALF.HI = 0;
+ }
+ } else if (ent->field_0xf <= 0x13) {
+ this->field_0x80.HALF.HI = 0;
+ }
+ }
+#else
} else if (ent->actionDelay == 0 && ent->field_0xf < 0x51) {
this->field_0x80.HALF.HI = 0;
}
+#endif
} else {
this->action = 4;
this->actionDelay = 0xc0;
this->field_0xf = 4;
this->field_0x80.HALF.LO ^= 1;
+#ifndef EU
this->field_0x78.HALF.LO = 0;
this->field_0x78.HALF.HI = 4;
this->direction = 0xff;
+#endif
InitializeAnimation(this, 0);
}
}
-#endif
#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0802AB40.inc", void sub_0802AB40(Entity* this));
+void sub_0802AB40(Entity* this) {
+ sub_0802AC40(this);
+ if (--this->actionDelay == 0) {
+ if (this->field_0x7a.HALF.LO <= 4) {
+ this->action = 5;
+ this->speed = 0;
+ InitializeAnimation(this, this->type + 1);
+ } else {
+ this->actionDelay = 0xc0;
+ this->field_0xf = 0x4;
+ this->field_0x80.HALF.LO ^= 1;
+ }
+ } else if ((--this->field_0xf & 0xff) == 0) {
+ sub_0802ACDC(this, 4);
+ }
+}
#else
void sub_0802AB40(Entity* this) {
sub_0802AC40(this);
@@ -281,9 +300,6 @@ void sub_0802AC08(Entity* this) {
GetNextFrame(this);
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0802AC40.inc", void sub_0802AC40(Entity* this))
-#else
void sub_0802AC40(Entity* this) {
GetNextFrame(this);
LinearMoveUpdate(this);
@@ -291,6 +307,7 @@ void sub_0802AC40(Entity* this) {
if (sub_0802B234(this) == 0) {
this->field_0x7a.HALF.LO = 0;
this->spritePriority.b1 = 0;
+#ifndef EU
} else {
if (this->z.HALF.HI == 0) {
if (this->spritePriority.b1 != 1) {
@@ -301,19 +318,23 @@ void sub_0802AC40(Entity* this) {
this->spritePriority.b1 = 3;
}
}
+#endif
}
} else {
if (sub_0802B234(this)) {
this->field_0x7a.HALF.LO = 1;
+#ifndef EU
if (this->z.HALF.HI == 0) {
this->spritePriority.b1 = 1;
} else {
this->spritePriority.b1 = 3;
}
+#else
+ this->spritePriority.b1 = 3;
+#endif
}
}
}
-#endif
void sub_0802ACDC(Entity* this, u32 param_2) {
u32 x;
@@ -362,10 +383,6 @@ void sub_0802AD54(Entity* this) {
}
}
-#ifdef EU
-// TODO regalloc in EU version
-ASM_FUNC("asm/non_matching/eu/sub_0802ADDC.inc", void sub_0802ADDC(Entity* this))
-#else
void sub_0802ADDC(Entity* this) {
Entity* ent = CreateEnemy(BOMB_PEAHAT, this->type + 2);
if (ent != NULL) {
@@ -373,21 +390,20 @@ void sub_0802ADDC(Entity* this) {
ent->parent = this;
this->child = ent;
CopyPosition(this, ent);
- /*#ifdef EU
- this->z.HALF.HI += 8;
- #endif*/
+#ifdef EU
+ ent->z.HALF.HI += 8;
+#endif
this->field_0x80.HALF.HI = 1;
if (this->type == 0) {
this->field_0x7a.HALF.LO++;
}
}
}
-#endif
void sub_0802AE24(Entity* this) {
this->action = 1;
this->actionDelay = 0xf0;
- this->zVelocity = 0x8000;
+ this->zVelocity = Q_16_16(0.5);
this->hitbox = (Hitbox*)&gUnk_080CD174;
this->field_0x3c = 3;
this->field_0x16 = 0;
@@ -398,7 +414,30 @@ void sub_0802AE24(Entity* this) {
}
#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0802AE68.inc", void sub_0802AE68(Entity* this))
+void sub_0802AE68(Entity* this) {
+ Entity* ent = this->parent;
+ if (ent == 0) {
+ this->action = 3;
+ this->spriteSettings.draw = 1;
+ this->field_0x80.HALF.LO = 1;
+ }
+
+ if (ent->field_0x80.HALF.HI) {
+ CopyPosition(ent, this);
+ this->z.HALF.HI += 8;
+ this->spriteSettings.draw = 0;
+ } else {
+ this->action = 3;
+ this->field_0x80.HALF.LO = 1;
+ this->spriteSettings.draw = 1;
+ if (sub_0802B234(this)) {
+ this->spritePriority.b1 = 3;
+ } else {
+ this->spritePriority.b1 = 0;
+ }
+ GetNextFrame(this);
+ }
+}
#else
void sub_0802AE68(Entity* this) {
Entity* ent = sub_0802B250(this);
@@ -575,7 +614,34 @@ void sub_0802B1A0(Entity* this) {
}
#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0802B1BC.inc", void sub_0802B1BC(Entity* this))
+void sub_0802B1BC(Entity* this) {
+ Entity* ent;
+
+ if (this->actionDelay) {
+ this->actionDelay--;
+ }
+
+ ent = this->parent;
+ if (ent == 0) {
+ this->action = 2;
+ this->spriteSettings.draw = 1;
+ }
+
+ if (ent->field_0x80.HALF.HI) {
+ CopyPosition(ent, this);
+ this->z.HALF.HI += 8;
+ } else {
+ this->action = 2;
+ this->spriteSettings.draw = 1;
+ if (sub_0802B234(this)) {
+ this->spritePriority.b1 = 3;
+ } else {
+ this->spritePriority.b1 = 0;
+ }
+
+ GetNextFrame(this);
+ }
+}
#else
void sub_0802B1BC(Entity* this) {
Entity* ent;
diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c
index 61f93cae..19615fe9 100644
--- a/src/enemy/bowMoblin.c
+++ b/src/enemy/bowMoblin.c
@@ -33,8 +33,6 @@ void sub_0803C714(BowMoblinEntity*);
void sub_0803C634(BowMoblinEntity*);
u32 sub_0803C6F8(BowMoblinEntity*);
u32 sub_0803C568(BowMoblinEntity*);
-extern Entity* sub_08049DF4(u32);
-extern u32 sub_0806FC80(Entity*, Entity*, s32);
void sub_0803C664(BowMoblinEntity*);
void (*const gUnk_080CFF78[])(Entity*);
diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c
index 9c52774f..580ece27 100644
--- a/src/enemy/businessScrub.c
+++ b/src/enemy/businessScrub.c
@@ -14,15 +14,10 @@
#include "game.h"
#include "item.h"
-extern Entity* sub_08049DF4(u32);
-extern bool32 sub_08056338(void);
-extern void UnloadOBJPalette(Entity*);
-
bool32 sub_0802915C(Entity*);
bool32 sub_080291DC(Entity*);
void sub_0802922C(Entity*);
void sub_08028E9C(Entity*);
-u32 sub_080001DA(u32, u32);
void sub_08028FFC(Entity*);
void sub_0802925C(Entity*);
void sub_080290E0(Entity*, u32);
@@ -70,7 +65,7 @@ void sub_08028934(Entity* this) {
if (pEVar1 != NULL) {
pEVar1->z.HALF.HI -= 8;
}
- EnqueueSFX(0x1bb);
+ EnqueueSFX(SFX_EM_DEKUSCRUB_HIT);
}
}
@@ -94,7 +89,7 @@ void sub_08028994(Entity* this) {
} else {
this->actionDelay = 0;
this->field_0x76.HWORD = COORD_TO_TILE(this);
- this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer);
+ this->field_0x74.HWORD = GetTileIndex(this->field_0x76.HWORD, this->collisionLayer);
this->hurtType = 0x41;
sub_08028FFC(this);
}
@@ -302,7 +297,7 @@ void sub_08028CE8(Entity* this) {
}
void sub_08028DE8(Entity* this) {
- if (gPlayerEntity.action == 8) {
+ if (gPlayerEntity.action == PLAYER_ITEMGET) {
if (this->field_0x80.HALF.HI == 0) {
SetPlayerControl(1);
this->field_0x80.HALF.HI = 1;
diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c
index 9d8d4ff3..8a5f90fb 100644
--- a/src/enemy/chuchu.c
+++ b/src/enemy/chuchu.c
@@ -220,7 +220,7 @@ void sub_0801F1B0(Entity* this) {
if (this->frame & 1) {
this->frame ^= 1;
this->hitType = 90;
- EnqueueSFX(299);
+ EnqueueSFX(SFX_12B);
}
sub_080AEFE0(this);
if (GravityUpdate(this, 0x4000) == 0)
@@ -416,7 +416,7 @@ void sub_0801F584(Entity* this) {
if (this->frame & 0x1) {
this->frame ^= 1;
this->hitType = 91;
- EnqueueSFX(299);
+ EnqueueSFX(SFX_12B);
}
sub_080AEFE0(this);
if (GravityUpdate(this, 0x4000) == 0)
@@ -564,7 +564,7 @@ void sub_0801F884(Entity* this) {
ent->type2 = 64;
this->action = 4;
this->hitType = 165;
- EnqueueSFX(0x193);
+ EnqueueSFX(SFX_193);
}
}
}
@@ -593,7 +593,7 @@ void sub_0801F940(Entity* this) {
if (this->frame & 0x10) {
if (this->frame & 1) {
this->frame ^= 1;
- EnqueueSFX(299);
+ EnqueueSFX(SFX_12B);
}
sub_080AEFE0(this);
if (GravityUpdate(this, 0x4000) == 0)
@@ -722,7 +722,7 @@ u32 sub_0801FBD0(Entity* this) {
void Chuchu_JumpAtPlayer(Entity* this) {
this->speed = 0x180;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->direction = sub_08049F84(this, 1);
InitializeAnimation(this, 3);
}
diff --git a/src/enemy/crow.c b/src/enemy/crow.c
index 8fdb1547..4dfdc773 100644
--- a/src/enemy/crow.c
+++ b/src/enemy/crow.c
@@ -20,8 +20,6 @@ void (*const gUnk_080CE990[])(CrowEntity*);
void (*const gUnk_080CE9A4[])(CrowEntity*);
extern Entity* gUnk_020000B0;
-extern Entity* sub_08049DF4(u32);
-
void sub_08032AF4(CrowEntity* this);
void sub_08032AB0(CrowEntity* this);
void sub_08032B38(CrowEntity* this);
diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c
new file mode 100644
index 00000000..fa6f8bf8
--- /dev/null
+++ b/src/enemy/cuccoAggr.c
@@ -0,0 +1,383 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "enemy.h"
+#include "functions.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0x10];
+ u16 unk_78;
+ u8 unk_7a;
+ u8 unk_7b;
+} CuccoAggrEntity;
+
+extern void (*const gUnk_080012C8[])(Entity*);
+
+typedef struct {
+ u16 x;
+ u16 y;
+} PosOffset;
+
+void (*const gUnk_080CF778[])(Entity*);
+void (*const gUnk_080CF790[])(CuccoAggrEntity*);
+void (*const gUnk_080CF7AC[])(CuccoAggrEntity*);
+const u8 gUnk_080CF7BC[];
+const u8 gUnk_080CF7BE[];
+const u8 gUnk_080CF7C2[];
+const PosOffset gCuccoAggrSpawnPoints[];
+const u16 gUnk_080CF824[];
+const u16 gUnk_080CF828[];
+const s8 gCuccoAggrFxHorizontalOffsets[];
+const u8 gCuccoAggrFx[];
+
+extern void sub_080391B4(CuccoAggrEntity* this);
+extern void sub_08039218(CuccoAggrEntity* this);
+extern void CuccoAggr_CreateFx(CuccoAggrEntity* this);
+extern void sub_08039120(CuccoAggrEntity* this);
+extern void sub_08039140(CuccoAggrEntity* this);
+extern void sub_0803901C(CuccoAggrEntity* this);
+extern void sub_08039298(CuccoAggrEntity* this);
+extern void sub_080390F8(CuccoAggrEntity* this);
+extern void sub_080390C0(CuccoAggrEntity* this);
+extern bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this);
+
+void CuccoAggr(Entity* this) {
+ u32 index = sub_080012DC(this);
+ if (index) {
+ gUnk_080012C8[index](this);
+ } else {
+ gUnk_080CF778[GetNextFunction(this)](this);
+ SetChildOffset(this, 0, 1, -0x10);
+ sub_080391B4((CuccoAggrEntity*)this);
+ }
+}
+
+void sub_08038CF8(CuccoAggrEntity* this) {
+ gUnk_080CF790[super->action](this);
+}
+
+void sub_08038D10(CuccoAggrEntity* this) {
+ if (super->type != 2) {
+ if (this->unk_7a == 0 && CheckRoomFlag(1) == 0) {
+ if (super->health <= 0xbf) {
+ this->unk_7a = 1;
+ }
+ } else {
+ super->health = 0xff;
+ }
+
+ sub_08039218(this);
+ CuccoAggr_CreateFx(this);
+ }
+
+ if (super->field_0x43) {
+ sub_0804A9FC(super, 0x1c);
+ }
+
+ sub_0804AA30(super, gUnk_080CF778);
+}
+
+void nullsub_165(CuccoAggrEntity* this) {
+}
+
+void sub_08038D78(CuccoAggrEntity* this) {
+ sub_0804A720(super);
+ if (super->type != 2) {
+ super->type2 = 0;
+ super->field_0x16 = 0x30;
+ sub_08039120(this);
+ } else {
+ sub_08039140(this);
+ }
+}
+
+void sub_08038DA0(CuccoAggrEntity* this) {
+ if (--super->actionDelay == 0) {
+ sub_0803901C(this);
+ }
+
+ sub_08039298(this);
+}
+
+void sub_08038DC0(CuccoAggrEntity* this) {
+ gUnk_080CF7AC[super->subAction](this);
+}
+
+void sub_08038DD8(CuccoAggrEntity* this) {
+ super->subAction = 1;
+ super->actionDelay = 0x10;
+ super->field_0xf = gUnk_080CF7BC[super->type];
+ COLLISION_OFF(super);
+ super->spritePriority.b1 = 0;
+ InitializeAnimation(super, 4);
+ EnqueueSFX(SFX_VO_CUCCO4);
+}
+
+void sub_08038E18(CuccoAggrEntity* this) {
+ if (super->field_0xf) {
+ if (--super->field_0xf == 0) {
+ sub_08079184();
+ sub_08039218(this);
+ COLLISION_ON(super);
+ super->spritePriority.b1 = 1;
+ super->spritePriority.b0 = 4;
+ super->direction = Random() & 0x1f;
+ ProcessMovement(super);
+ UpdateSpriteForCollisionLayer(super);
+ }
+ }
+
+ if (--super->actionDelay == 0) {
+ super->actionDelay = 0x10;
+ super->spriteSettings.flipX ^= (Random() & 1);
+ CuccoAggr_CreateFx(this);
+ }
+
+ GetNextFrame(super);
+}
+
+void sub_08038EAC(CuccoAggrEntity* this) {
+ super->spritePriority.b1 = 1;
+ sub_080390F8(this);
+ GetNextFrame(super);
+}
+
+void sub_08038ED0(CuccoAggrEntity* this) {
+ COLLISION_ON(super);
+ sub_08039218(this);
+}
+
+void sub_08038EE0(CuccoAggrEntity* this) {
+ ProcessMovement(super);
+ GetNextFrame(super);
+ sub_08039298(this);
+ if (GravityUpdate(super, 0x1C00) == 0) {
+ if (--super->actionDelay == 0) {
+ sub_0803901C(this);
+ } else {
+ super->zVelocity = 0x8000;
+ }
+ }
+}
+
+void sub_08038F20(CuccoAggrEntity* this) {
+ sub_08039298(this);
+ GetNextFrame(super);
+
+ if (super->frame & 0x80) {
+ sub_0803901C(this);
+ }
+}
+
+void sub_08038F44(CuccoAggrEntity* this) {
+ super->direction = GetFacingDirection(&gPlayerEntity, super);
+ sub_080390F8(this);
+ ProcessMovement(super);
+ sub_080044EC(super, 0x1800);
+ GetNextFrame(super);
+ sub_08039298(this);
+ if (--this->unk_78 == 0) {
+ sub_08039120(this);
+ } else if ((this->unk_78 & 0x1f) == 0) {
+ CuccoAggr_CreateFx(this);
+ }
+}
+
+void sub_08038FA0(CuccoAggrEntity* this) {
+ if ((super->actionDelay++ & 0x1f) == 0) {
+ CuccoAggr_CreateFx(this);
+ }
+
+ if (this->unk_78) {
+ if ((this->unk_78-- & 0x7) == 0) {
+ sub_08004596(super, GetFacingDirection(super, &gPlayerEntity));
+ }
+
+ sub_080390F8(this);
+ LinearMoveUpdate(super);
+ GetNextFrame(super);
+ } else {
+ LinearMoveUpdate(super);
+ GetNextFrame(super);
+ if (CuccoAggr_IsOutsideScroll(this)) {
+ DeleteEntity(super);
+ }
+ }
+}
+
+void sub_0803901C(CuccoAggrEntity* this) {
+ u32 r3 = Random();
+ u32 r5 = r3 & 3;
+
+ //! @bug This if was meant to check r5 instead of r3.
+ // The result is that this if practically never happens and
+ // there's a higher chance of the default branch of the next switch.
+ if (r3 == 3) {
+ switch (super->action) {
+ case 3:
+ r5 = 1;
+ break;
+ case 4:
+ r5 = 2;
+ break;
+ default:
+ r5 = 0;
+ }
+ }
+
+ switch (r5) {
+ default:
+ super->action = 1;
+ super->actionDelay = gUnk_080CF7BE[(r3 >> 0x10) & 3];
+ InitializeAnimation(super, 0);
+ break;
+ case 1:
+ super->action = 3;
+ super->actionDelay = ((r3 >> 8) & 3) + 2;
+ super->zVelocity = 0x8000;
+ sub_080390C0(this);
+ InitializeAnimation(super, 1);
+ if (Random() & 1) {
+ r5 = Random() & 1;
+ EnqueueSFX(SFX_VO_CUCCO1 + r5);
+ }
+ break;
+ case 2:
+ super->action = 4;
+ InitializeAnimation(super, ((r3 >> 0x10) & 1) + 2);
+ break;
+ }
+}
+
+void sub_080390C0(CuccoAggrEntity* this) {
+ u32 rand = Random();
+ if (sub_08049FA0(super) && (rand & 1)) {
+ super->direction = (rand >> 0x10) & 0x1c;
+ } else {
+ super->direction = (sub_08049EE4(super) + 2) & 0x1c;
+ }
+
+ sub_080390F8(this);
+}
+
+void sub_080390F8(CuccoAggrEntity* this) {
+ if (super->direction & 0xf) {
+ super->spriteSettings.flipX = ((super->direction >> 4) ^ 1);
+ }
+}
+
+void sub_08039120(CuccoAggrEntity* this) {
+ super->speed = gUnk_080CF7C2[super->type];
+ this->unk_7a = 0;
+ sub_0803901C(this);
+}
+
+void sub_08039140(CuccoAggrEntity* this) {
+ super->action = 6;
+ super->actionDelay = Random();
+ super->direction = GetFacingDirection(super, &gPlayerEntity);
+ super->z.HALF.HI = 0xfffc;
+ this->unk_78 = 0xb4;
+ sub_080390F8(this);
+ InitializeAnimation(super, 4);
+}
+
+bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this) {
+ if ((u32)super->x.HALF.HI - 0xc - gRoomControls.scroll_x > 0x108)
+ return 1;
+ if ((u32)super->y.HALF.HI - 0xc - gRoomControls.scroll_y > 0xb8)
+ return 1;
+
+ return 0;
+}
+
+void sub_080391B4(CuccoAggrEntity* this) {
+ if (this->unk_7a) {
+ if ((this->unk_7b++ & 0x1f) == 0) {
+ Entity* ent = CreateEnemy(CUCCO_AGGR, 2);
+ if (ent) {
+ u32 rand = (Random() & 0x17);
+ const PosOffset* ptr = &gCuccoAggrSpawnPoints[rand];
+ ent->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
+ ent->y.HALF.HI = gRoomControls.scroll_y + ptr->y;
+ ent->collisionLayer = super->collisionLayer;
+ }
+ }
+ }
+}
+
+void sub_08039218(CuccoAggrEntity* this) {
+ super->action = 5;
+ super->speed = gUnk_080CF824[super->type];
+ this->unk_78 = gUnk_080CF828[super->type];
+
+ if (super->animIndex != 4) {
+ InitializeAnimation(super, 4);
+ }
+
+ EnqueueSFX(SFX_VO_CUCCO4);
+}
+
+void CuccoAggr_CreateFx(CuccoAggrEntity* this) {
+ Entity* ent = CreateFx(super, gCuccoAggrFx[super->type], 0);
+
+ if (ent) {
+ ent->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
+ }
+}
+
+void sub_08039298(CuccoAggrEntity* this) {
+ if (super->type2 == 0) {
+ sub_08078930(super);
+ }
+}
+
+void (*const gUnk_080CF778[])(Entity*) = {
+ (EntityActionPtr)sub_08038CF8, (EntityActionPtr)sub_08038D10, sub_08001324, sub_0804A7D4, sub_08001242,
+ (EntityActionPtr)nullsub_165,
+};
+
+void (*const gUnk_080CF790[])(CuccoAggrEntity*) = {
+ sub_08038D78, sub_08038DA0, sub_08038DC0, sub_08038EE0, sub_08038F20, sub_08038F44, sub_08038FA0,
+};
+
+void (*const gUnk_080CF7AC[])(CuccoAggrEntity*) = {
+ sub_08038DD8,
+ sub_08038E18,
+ sub_08038EAC,
+ sub_08038ED0,
+};
+
+const u8 gUnk_080CF7BC[] = { 0, 0x78 };
+
+const u8 gUnk_080CF7BE[] = { 0x1e, 0x2d, 0x3c, 0x4b };
+
+const u8 gUnk_080CF7C2[] = { 0x80, 0xc0 };
+
+const PosOffset gCuccoAggrSpawnPoints[] = {
+ { 0x18, -0x8 }, { 0x38, -0x8 }, { 0x58, -0x8 }, { 0x78, -0x8 }, { 0x98, -0x8 }, { 0xB8, -0x8 },
+ { 0xD8, -0x8 }, { 0x18, 0xA8 }, { 0x38, 0xA8 }, { 0x58, 0xA8 }, { 0x78, 0xA8 }, { 0x98, 0xA8 },
+ { 0xB8, 0xA8 }, { 0xD8, 0xA8 }, { -0x8, 0x10 }, { -0x8, 0x30 }, { -0x8, 0x50 }, { -0x8, 0x70 },
+ { -0x8, 0x90 }, { 0xF8, 0x10 }, { 0xF8, 0x30 }, { 0xF8, 0x50 }, { 0xF8, 0x70 }, { 0xF8, 0x90 },
+};
+
+const u16 gUnk_080CF824[] = {
+ 0x140,
+ 0x200,
+};
+
+const u16 gUnk_080CF828[] = {
+ 0x384,
+ 0x3c,
+};
+
+const s8 gCuccoAggrFxHorizontalOffsets[] = {
+ 8,
+ -8,
+};
+
+const u8 gCuccoAggrFx[] = {
+ FX_EGG,
+ FX_WOOD2,
+ FX_EGG,
+};
diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c
index e4946da6..5acaf9d3 100644
--- a/src/enemy/cuccoChickAggr.c
+++ b/src/enemy/cuccoChickAggr.c
@@ -8,8 +8,6 @@
#include "enemy.h"
#include "functions.h"
-extern Entity* sub_08049DF4(u32);
-
void sub_08022A88(Entity*);
void sub_08022AA4(Entity*);
void sub_08022B0C(Entity*);
@@ -54,8 +52,8 @@ void sub_08022988(Entity* this) {
return;
this->frameIndex = 1;
- this->zVelocity = 0x10000;
- EnqueueSFX(0xd6);
+ this->zVelocity = Q_16_16(1.0);
+ EnqueueSFX(SFX_VO_CHEEP);
}
ProcessMovement(this);
@@ -80,8 +78,8 @@ void sub_080229F8(Entity* this) {
this->speed = 0xc0;
sub_08022B44(this);
} else {
- this->zVelocity = 0x10000;
- EnqueueSFX(0xd6);
+ this->zVelocity = Q_16_16(1.0);
+ EnqueueSFX(SFX_VO_CHEEP);
}
}
}
@@ -143,13 +141,13 @@ u32 sub_08022B20(Entity* this) {
}
void sub_08022B44(Entity* this) {
- this->zVelocity = 0xc000;
+ this->zVelocity = Q_16_16(0.75);
this->direction = GetFacingDirection(this, &gPlayerEntity);
if (this->direction & 0xf)
this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
- EnqueueSFX(0xd6);
+ EnqueueSFX(SFX_VO_CHEEP);
}
// clang-format off
diff --git a/src/enemy/curtain.c b/src/enemy/curtain.c
index 895a578c..d52c80b3 100644
--- a/src/enemy/curtain.c
+++ b/src/enemy/curtain.c
@@ -15,7 +15,7 @@ void sub_080481D0(Entity* this) {
void sub_080481E8(Entity* this) {
if (this->field_0x46) {
this->action = 2;
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
this->spritePriority.b0 = 7;
this->actionDelay = 3;
} else {
@@ -36,7 +36,7 @@ void sub_08048224(Entity* this) {
this->actionDelay = 0;
} else {
this->action = 3;
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
this->actionDelay = 1;
}
diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c
index 7084ae0c..ad692d3b 100644
--- a/src/enemy/darkNut.c
+++ b/src/enemy/darkNut.c
@@ -97,7 +97,7 @@ void sub_08020BB8(Entity* this) {
}
this->action = 10;
sub_08021218(this, 0xb, this->animationState);
- EnqueueSFX(0x15d);
+ EnqueueSFX(SFX_15D);
sub_08021588(this);
break;
case 0x4c:
@@ -280,7 +280,7 @@ void sub_08021038(Entity* this) {
pEVar2->parent = this;
this->child = pEVar2;
}
- EnqueueSFX(270);
+ EnqueueSFX(SFX_10E);
}
if (this->frame & 0x80) {
@@ -302,7 +302,7 @@ void sub_080210A8(Entity* this) {
if (this->frame & 1) {
this->frame = 0;
sub_08021588(this);
- EnqueueSFX(349);
+ EnqueueSFX(SFX_15D);
} else if (this->frame & 0x80) {
sub_08021390(this);
}
@@ -320,7 +320,7 @@ void sub_080210E4(Entity* this) {
this->child = ent;
}
- EnqueueSFX(270);
+ EnqueueSFX(SFX_10E);
}
sub_08021644(this);
@@ -578,13 +578,13 @@ void sub_0802159C(Entity* this) {
ent->parent = this;
this->child = ent;
}
- EnqueueSFX(0x116);
+ EnqueueSFX(SFX_116);
} else if (this->frame == 2) {
this->frame = 0;
sub_08021588(this);
} else if (this->frame & 0x20) {
this->frame &= ~0x20;
- EnqueueSFX(0x115);
+ EnqueueSFX(SFX_115);
}
}
@@ -599,7 +599,7 @@ void sub_08021600(Entity* this) {
ent->parent = this;
this->child = ent;
}
- EnqueueSFX(0x10e);
+ EnqueueSFX(SFX_10E);
} else if (this->frame == 2) {
this->frame = 0;
sub_08021588(this);
@@ -609,7 +609,7 @@ void sub_08021600(Entity* this) {
void sub_08021644(Entity* this) {
if (this->frame & 0x20) {
this->frame &= ~0x20;
- EnqueueSFX(0x7d);
+ EnqueueSFX(SFX_PLY_LAND);
}
}
diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c
index bcb1e1af..a5b63e9d 100644
--- a/src/enemy/doorMimic.c
+++ b/src/enemy/doorMimic.c
@@ -9,7 +9,6 @@
#include "enemy.h"
#include "functions.h"
-extern s16 sub_080001DA(u32, u32); // ?
extern void sub_08049CF4(Entity*);
void sub_080221C0(Entity*);
@@ -92,7 +91,7 @@ void sub_080220F0(Entity* this) {
fx->y.HALF.HI += off->v;
}
}
- EnqueueSFX(260);
+ EnqueueSFX(SFX_104);
} else if (this->frame & 1) {
this->damage = 4;
}
@@ -118,7 +117,7 @@ void sub_08022198(Entity* this) {
void sub_080221C0(Entity* this) {
u32 tile = COORD_TO_TILE(this) + gUnk_080B4488[this->type2];
this->field_0x7c.HALF.HI = tile;
- this->field_0x7c.HALF.LO = sub_080001DA(tile, this->collisionLayer);
+ this->field_0x7c.HALF.LO = GetTileIndex(tile, this->collisionLayer);
SetTile(gUnk_080CB79C[this->type2], tile, this->collisionLayer);
}
diff --git a/src/enemy/enemy66.c b/src/enemy/enemy66.c
new file mode 100644
index 00000000..6975e5e8
--- /dev/null
+++ b/src/enemy/enemy66.c
@@ -0,0 +1,16 @@
+#include "entity.h"
+
+void (*const gUnk_080D2ABC[])(Entity*);
+extern void sub_08029270(Entity* this);
+
+void Enemy66(Entity* this) {
+ if (gUnk_080D2ABC[this->field_0xf]) {
+ gUnk_080D2ABC[this->field_0xf](this);
+ } else {
+ DeleteThisEntity();
+ }
+}
+
+void (*const gUnk_080D2ABC[103])(Entity*) = {
+ [22] = sub_08029270,
+};
diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c
index d414ce52..1bb932af 100644
--- a/src/enemy/fallingBoulder.c
+++ b/src/enemy/fallingBoulder.c
@@ -37,7 +37,7 @@ void sub_0802C254(Entity* this) {
void sub_0802C258(Entity* this) {
sub_0804A720(this);
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->actionDelay = 2;
this->field_0x7a.HWORD = Random() & 0x70;
switch (this->type) {
@@ -80,7 +80,7 @@ NONMATCH("asm/non_matching/fallingBoulder/sub_0802C334.inc", void sub_0802C334(E
GetNextFrame(this);
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
if (sub_080044EC(this, *(u32*)&this->cutsceneBeh) == 1) {
- EnqueueSFX(0x14c);
+ EnqueueSFX(SFX_14C);
COLLISION_ON(this);
this->field_0x7a.HWORD = 0xc;
sub_0802C4B0(this);
@@ -137,14 +137,12 @@ void nullsub_148(Entity* this) {
/* ... */
}
-extern u32 sub_080001DA(u32, u32);
-
void sub_0802C4B0(Entity* this) {
u32 offset;
u32 index;
u32 rand;
- switch (sub_080001DA(this->field_0x7c.HALF_U.HI, this->collisionLayer)) {
+ switch (GetTileIndex(this->field_0x7c.HALF_U.HI, this->collisionLayer)) {
case 0x1ab ... 0x1af:
offset = 8;
break;
@@ -195,7 +193,7 @@ void sub_0802C4B0(Entity* this) {
}
rand = Random() & 7;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
if (rand & 4) {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 1];
diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c
index 5e81c1d6..a0546fb8 100644
--- a/src/enemy/fireballGuy.c
+++ b/src/enemy/fireballGuy.c
@@ -102,7 +102,7 @@ u32 sub_0804A024(Entity*, u32, u32);
void sub_08045524(Entity* this) {
u32 tmp, tmp1, tmp2;
- this->zVelocity = 0x1c000;
+ this->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(this, 1, 8);
if (tmp != 0xff && (Random() & 3) == 0) {
this->actionDelay = Random() & 3;
diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c
index 9a824c35..adf57523 100644
--- a/src/enemy/flyingSkull.c
+++ b/src/enemy/flyingSkull.c
@@ -21,7 +21,6 @@ void (*const gUnk_080CFBD4[])(FlyingSkullEntity*);
const s8 gUnk_080CFBE4[4];
extern s32 sub_080012DC(Entity*);
-extern u32 sub_080001DA(u32, u32);
extern void sub_08078930(Entity*);
void sub_0803A100(FlyingSkullEntity* this);
@@ -46,7 +45,7 @@ void sub_08039BF8(FlyingSkullEntity* this) {
if (super->bitfield == 0x9d) {
super->action = 7;
COLLISION_OFF(super);
- super->zVelocity = 0x2A000;
+ super->zVelocity = Q_16_16(2.625);
super->spritePriority.b1 = 1;
SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer);
} else if (super->z.HALF.HI) {
@@ -118,7 +117,7 @@ void sub_08039D74(FlyingSkullEntity* this) {
super->y.HALF.HI += 3;
tmp = COORD_TO_TILE(super);
- this->unk_0x74 = sub_080001DA(tmp, super->collisionLayer);
+ this->unk_0x74 = GetTileIndex(tmp, super->collisionLayer);
SetTile(0x4060, tmp, super->collisionLayer);
InitializeAnimation(super, 0);
}
@@ -136,7 +135,7 @@ void sub_08039DD8(FlyingSkullEntity* this) {
} else {
if ((gPlayerState.flags & 0x80) == 0) {
Entity* ent = &gPlayerEntity;
- if (sub_0806FCB8(super, ent->x.HALF.HI, ent->y.HALF.HI, 0x30)) {
+ if (EntityWithinDistance(super, ent->x.HALF.HI, ent->y.HALF.HI, 0x30)) {
if (super->type == 1) {
super->action = 3;
super->actionDelay = 0x1e;
@@ -246,7 +245,7 @@ void sub_0803A0E0(FlyingSkullEntity* this) {
void sub_0803A100(FlyingSkullEntity* this) {
u32 tile = COORD_TO_TILE(super);
- if (sub_080001DA(tile, super->collisionLayer) == 0x4067) {
+ if (GetTileIndex(tile, super->collisionLayer) == 0x4067) {
SetTile(this->unk_0x74, tile, super->collisionLayer);
DeleteThisEntity();
}
diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c
index a8ca9c69..f1eec3f0 100644
--- a/src/enemy/gibdo.c
+++ b/src/enemy/gibdo.c
@@ -5,34 +5,48 @@
* @brief Gibdo enemy
*/
+#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "object.h"
#include "functions.h"
+typedef struct {
+ Entity base;
+ u8 filler[0xc];
+ u16 field_0x74;
+ u8 field_0x76;
+ u8 field_0x77;
+ u16 field_0x78;
+ u16 field_0x7a;
+ u8 field_0x7c;
+ u8 field_0x7d;
+ u8 filler2[2];
+ Entity* field_0x80;
+ Entity* field_0x84;
+} GibdoEntity;
+
// Gibudo
-void sub_08037794(Entity*);
-void sub_08037B10(Entity*);
-void sub_0803797C(Entity*);
-void sub_080379BC(Entity*);
-void sub_08037C0C(Entity*, Entity*);
-u32 sub_08037810(Entity*);
-void sub_080377B0(Entity*);
-u32 sub_080378B0(Entity*);
-u32 sub_08037914(Entity*);
-u32 sub_080379EC(Entity*);
-void sub_08037A58(Entity*);
-void sub_08037ACC(Entity*);
-void sub_08037B48(Entity*);
-void sub_08037A14(Entity*);
+void sub_08037794(GibdoEntity*);
+void sub_08037B10(GibdoEntity*);
+void sub_0803797C(GibdoEntity*);
+void sub_080379BC(GibdoEntity*);
+void Gibdo_MoveObjectsToStalfos(GibdoEntity*, Entity*);
+u32 sub_08037810(GibdoEntity*);
+void sub_080377B0(GibdoEntity*);
+u32 sub_080378B0(GibdoEntity*);
+u32 sub_08037914(GibdoEntity*);
+u32 sub_080379EC(GibdoEntity*);
+void sub_08037A58(GibdoEntity*);
+void sub_08037ACC(GibdoEntity*);
+void Gibdo_CreateObjects(GibdoEntity*);
+void sub_08037A14(GibdoEntity*);
extern void sub_0804A4E4(Entity*, Entity*);
-extern Entity* sub_08049DF4(u32);
u32 sub_0804A044(Entity*, Entity*, u32);
-extern void SoundReqClipped(Entity*, u32);
-extern void (*const gGibdo[6])(Entity*);
-extern void (*const gUnk_080CF2AC[9])(Entity*);
+void (*const gGibdo[6])(Entity*);
+void (*const gUnk_080CF2AC[9])(GibdoEntity*);
extern Entity* gUnk_020000B0;
void Gibdo(Entity* this) {
@@ -40,35 +54,33 @@ void Gibdo(Entity* this) {
SetChildOffset(this, 0, 1, -0x15);
}
-void Gibdo_OnTick(Entity* this) {
- gUnk_080CF2AC[this->action](this);
+void Gibdo_OnTick(GibdoEntity* this) {
+ gUnk_080CF2AC[super->action](this);
}
-// Non-matching
-NONMATCH("asm/non_matching/gibdo/sub_080374A4.inc", void sub_080374A4(Entity* this)) {
+
+void sub_080374A4(GibdoEntity* this) {
u8 x;
- if (this->bitfield == 0x87) {
- if (this->action == 0x6) {
+ if (super->bitfield == 0x87) {
+ if (super->action == 0x6) {
sub_08037ACC(this);
}
- this->action = 0x8;
- this->actionDelay = 0x3c;
- COLLISION_OFF(this);
- sub_08037B48(this);
+ super->action = 0x8;
+ super->actionDelay = 0x3c;
+ COLLISION_OFF(super);
+ Gibdo_CreateObjects(this);
} else {
- if (this->action != 0x6) {
- if (this->hitType == 0x27) {
- if (this->bitfield == 0x80) {
- sub_08037A14(this);
- }
+ if (super->action != 0x6) {
+ if (super->hitType == 0x27 && super->bitfield == 0x80) {
+ sub_08037A14(this);
} else {
- if ((u8)(this->action - 1) < 2) {
- this->action = 1;
- x = DirectionTurnAround(DirectionRoundUp(this->knockbackDirection));
- this->direction = x;
- this->animationState = x >> 3;
- InitAnimationForceUpdate(this, this->animationState);
+ if ((u8)(super->action - 1) < 2) {
+ super->action = 1;
+ x = DirectionRoundUp(DirectionTurnAround(super->knockbackDirection));
+ super->direction = x;
+ super->animationState = x >> 3;
+ InitAnimationForceUpdate(super, super->animationState);
if (sub_08037810(this) != 0) {
- this->actionDelay = 4;
+ super->actionDelay = 4;
}
}
}
@@ -76,41 +88,40 @@ NONMATCH("asm/non_matching/gibdo/sub_080374A4.inc", void sub_080374A4(Entity* th
sub_08037A58(this);
}
}
- if (this->field_0x43 != 0) {
- sub_0804A9FC(this, 0x1c);
+ if (super->field_0x43 != 0) {
+ sub_0804A9FC(super, 0x1c);
}
- sub_0804AA30(this, gGibdo);
+ sub_0804AA30(super, gGibdo);
}
-END_NONMATCH
-void nullsub_162(Entity* this) {
+void nullsub_162(GibdoEntity* this) {
}
-void sub_08037558(Entity* this) {
- sub_0804A720(this);
- this->animationState = Random() & 0x3;
- this->field_0x76.HALF.LO = 0;
- this->field_0x76.HALF.HI = 0;
+void sub_08037558(GibdoEntity* this) {
+ sub_0804A720(super);
+ super->animationState = Random() & 0x3;
+ this->field_0x76 = 0;
+ this->field_0x77 = 0;
sub_08037794(this);
}
-void sub_08037580(Entity* this) {
+void sub_08037580(GibdoEntity* this) {
if (sub_08037810(this) == 0) {
- if (!(--this->field_0x74.HWORD)) {
+ if (!(--this->field_0x74)) {
sub_080377B0(this);
}
}
}
-void sub_080375A4(Entity* this) {
+void sub_080375A4(GibdoEntity* this) {
if (sub_080378B0(this) == 0) {
if (sub_08037810(this) == 0) {
- if (!(--this->field_0x74.HWORD)) {
+ if (!(--this->field_0x74)) {
sub_08037794(this);
} else {
- UpdateAnimationSingleFrame(this);
- if (ProcessMovement(this) == 0) {
- if (!(--this->field_0xf)) {
+ UpdateAnimationSingleFrame(super);
+ if (ProcessMovement(super) == 0) {
+ if (!(--super->field_0xf)) {
sub_080379BC(this);
}
}
@@ -119,30 +130,30 @@ void sub_080375A4(Entity* this) {
}
}
-void sub_080375F8(Entity* this) {
+void sub_080375F8(GibdoEntity* this) {
if (sub_080378B0(this) == 0) {
- if (!(--this->actionDelay)) {
- this->action = 4;
- this->actionDelay = 0x18;
- InitAnimationForceUpdate(this, this->animationState + 4);
+ if (!(--super->actionDelay)) {
+ super->action = 4;
+ super->actionDelay = 0x18;
+ InitAnimationForceUpdate(super, super->animationState + 4);
}
}
}
-void sub_08037624(Entity* this) {
+void sub_08037624(GibdoEntity* this) {
if (sub_080378B0(this) == 0) {
if (sub_08037914(this) == 0) {
- if (!(--this->field_0x74.HWORD)) {
+ if (!(--this->field_0x74)) {
sub_08037794(this);
} else {
- UpdateAnimationSingleFrame(this);
- UpdateAnimationSingleFrame(this);
- if (ProcessMovement(this) == 0) {
- if (!(--this->field_0xf)) {
+ UpdateAnimationSingleFrame(super);
+ UpdateAnimationSingleFrame(super);
+ if (ProcessMovement(super) == 0) {
+ if (!(--super->field_0xf)) {
sub_080379BC(this);
}
} else {
- if (!(--this->actionDelay)) {
+ if (!(--super->actionDelay)) {
sub_0803797C(this);
}
}
@@ -151,172 +162,172 @@ void sub_08037624(Entity* this) {
}
}
-void sub_08037690(Entity* this) {
- UpdateAnimationSingleFrame(this);
- if ((this->frame & 0x80) != 0) {
- this->field_0x76.HALF.HI = 0x14;
+void sub_08037690(GibdoEntity* this) {
+ UpdateAnimationSingleFrame(super);
+ if ((super->frame & 0x80) != 0) {
+ this->field_0x77 = 0x14;
sub_08037794(this);
} else {
- if ((this->frame & 1) != 0) {
- this->hitType = 0x27;
- ProcessMovement(this);
+ if ((super->frame & 1) != 0) {
+ super->hitType = 0x27;
+ ProcessMovement(super);
}
}
}
-void sub_080376D0(Entity* this) {
+void sub_080376D0(GibdoEntity* this) {
u8* x;
if (sub_080379EC(this) == 0) {
ResetPlayer();
gPlayerState.mobility = gPlayerState.mobility | 0x80;
gPlayerState.field_0xa = gPlayerState.field_0xa | 0x80;
- CopyPositionAndSpriteOffset(&gPlayerEntity, this);
- UpdateAnimationSingleFrame(this);
- if ((this->frame & 0x1) != 0) {
- if (--this->field_0x7c.BYTES.byte0 == 0) {
+ CopyPositionAndSpriteOffset(&gPlayerEntity, super);
+ UpdateAnimationSingleFrame(super);
+ if ((super->frame & 0x1) != 0) {
+ if (--this->field_0x7c == 0) {
sub_08037A58(this);
} else {
- this->frame ^= 1;
+ super->frame ^= 1;
sub_08037B10(this);
}
}
}
}
-void sub_0803773C(Entity* this) {
- UpdateAnimationSingleFrame(this);
- if ((this->frame & 0x80) != 0) {
+void sub_0803773C(GibdoEntity* this) {
+ UpdateAnimationSingleFrame(super);
+ if ((super->frame & 0x80) != 0) {
sub_08037794(this);
}
}
+
// Turn into Stalfos
-void sub_0803775C(Entity* this) {
+void sub_0803775C(GibdoEntity* this) {
Entity* x;
- if (!(--this->actionDelay)) {
+ if (!(--super->actionDelay)) {
x = CreateEnemy(STALFOS, 0);
if (x != 0) {
- sub_0804A4E4(this, x);
- sub_08037C0C(this, x);
+ sub_0804A4E4(super, x);
+ Gibdo_MoveObjectsToStalfos(this, x);
}
- DeleteEntity(this);
+ DeleteEntity(super);
}
}
-void sub_08037794(Entity* this) {
- this->action = 1;
- this->field_0x74.HWORD = 0x1e;
- this->hitType = 0x26;
- InitAnimationForceUpdate(this, this->animationState);
+void sub_08037794(GibdoEntity* this) {
+ super->action = 1;
+ this->field_0x74 = 0x1e;
+ super->hitType = 0x26;
+ InitAnimationForceUpdate(super, super->animationState);
}
-void sub_080377B0(Entity* this) {
+void sub_080377B0(GibdoEntity* this) {
u32 r1;
u32 r2;
- this->action = 2;
- this->field_0xf = 8;
+ super->action = 2;
+ super->field_0xf = 8;
r1 = Random();
- this->field_0x74.HWORD = (r1 & 0x38) + 0x78;
- this->speed = 0x40;
+ this->field_0x74 = (r1 & 0x38) + 0x78;
+ super->speed = 0x40;
r2 = Random();
- if (!sub_08049FA0(this) && (r2 & 3)) {
- this->direction = DirectionRoundUp(sub_08049EE4(this));
+ if (!sub_08049FA0(super) && (r2 & 3)) {
+ super->direction = DirectionRoundUp(sub_08049EE4(super));
} else {
- this->direction = DirectionRound(r2);
+ super->direction = DirectionRound(r2);
}
- this->animationState = this->direction / 8;
- InitAnimationForceUpdate(this, this->animationState + 4);
+ super->animationState = super->direction / 8;
+ InitAnimationForceUpdate(super, super->animationState + 4);
}
-u32 sub_08037810(Entity* this) {
+u32 sub_08037810(GibdoEntity* this) {
u32 x;
u32 y;
- if (this->field_0x76.HALF.LO == 0) {
- if (sub_08049FDC(this, 1) != 0) {
- if (sub_0806FCB8(this, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x40) != 0) {
- x = GetFacingDirection(this, gUnk_020000B0);
- if (((x - this->direction + 6) & 0x1f) <= 0xc) {
- this->action = 3;
- this->actionDelay = 0x18;
- this->field_0xf = 0x8;
- this->speed = 0xc0;
- this->direction = DirectionRoundUp(GetFacingDirection(this, gUnk_020000B0));
- this->animationState = this->direction >> 3;
- this->field_0x74.HWORD = 300;
- this->field_0x78.HWORD = gUnk_020000B0->x.HALF.HI;
- this->field_0x7a.HWORD = gUnk_020000B0->y.HALF.HI;
- InitAnimationForceUpdate(this, this->animationState);
+ if (this->field_0x76 == 0) {
+ if (sub_08049FDC(super, 1) != 0) {
+ if (EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x40) != 0) {
+ x = GetFacingDirection(super, gUnk_020000B0);
+ if (((x - super->direction + 6) & 0x1f) <= 0xc) {
+ super->action = 3;
+ super->actionDelay = 0x18;
+ super->field_0xf = 0x8;
+ super->speed = 0xc0;
+ super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
+ super->animationState = super->direction >> 3;
+ this->field_0x74 = 300;
+ this->field_0x78 = gUnk_020000B0->x.HALF.HI;
+ this->field_0x7a = gUnk_020000B0->y.HALF.HI;
+ InitAnimationForceUpdate(super, super->animationState);
return 1;
}
}
}
} else {
- this->field_0x76.HALF.LO--;
+ this->field_0x76--;
}
return 0;
}
-u32 sub_080378B0(Entity* this) {
- if (this->field_0x76.HALF.HI == 0) {
+u32 sub_080378B0(GibdoEntity* this) {
+ if (this->field_0x77 == 0) {
if (sub_08049DF4(1) != 0) {
- if (sub_0804A044(this, gUnk_020000B0, 0xa) == this->direction)
- if (sub_0806FCB8(this, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x18) != 0) {
- this->action = 5;
- this->speed = 0x100;
- InitAnimationForceUpdate(this, this->animationState + 8);
+ if (sub_0804A044(super, gUnk_020000B0, 0xa) == super->direction)
+ if (EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x18) != 0) {
+ super->action = 5;
+ super->speed = 0x100;
+ InitAnimationForceUpdate(super, super->animationState + 8);
return 1;
}
}
} else {
- this->field_0x76.HALF.HI--;
+ this->field_0x77--;
}
return 0;
}
-u32 sub_08037914(Entity* this) {
- if (sub_08049FDC(this, 1) != 0) {
- if (sub_0806FCB8(gUnk_020000B0, this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x28) == 0) {
- this->field_0x78.HWORD = gUnk_020000B0->x.HALF_U.HI;
- this->field_0x7a.HWORD = gUnk_020000B0->y.HALF_U.HI;
+u32 sub_08037914(GibdoEntity* this) {
+ if (sub_08049FDC(super, 1) != 0) {
+ if (EntityWithinDistance(gUnk_020000B0, this->field_0x78, this->field_0x7a, 0x28) == 0) {
+ this->field_0x78 = gUnk_020000B0->x.HALF_U.HI;
+ this->field_0x7a = gUnk_020000B0->y.HALF_U.HI;
sub_0803797C(this);
return 0;
}
- if (sub_0806FCB8(this, this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x8) == 0) {
+ if (EntityWithinDistance(super, this->field_0x78, this->field_0x7a, 0x8) == 0) {
return 0;
}
- this->field_0x76.HALF.LO = 0x3c;
+ this->field_0x76 = 0x3c;
}
sub_08037794(this);
return 1;
}
-NONMATCH("asm/non_matching/gibdo/sub_0803797C.inc", void sub_0803797C(Entity* this)) {
- u32 z;
+
+void sub_0803797C(GibdoEntity* this) {
u32 m;
- this->actionDelay = 0x18;
- this->field_0xf = 0x8;
- z = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, this->field_0x78.HWORD, this->field_0x7a.HWORD);
- m = (z + 4) & 0x18;
- this->direction = m;
+ super->actionDelay = 0x18;
+ super->field_0xf = 8;
+ m = super->direction =
+ (sub_080045D4(super->x.HALF.HI, super->y.HALF.HI, this->field_0x78, this->field_0x7a) + 4) & 0x18;
+ ;
m = m / 8;
- if (m != this->animationState) {
- this->animationState = m;
- InitAnimationForceUpdate(this, m + 4);
+ if (m != super->animationState) {
+ super->animationState = m;
+ InitAnimationForceUpdate(super, m + 4);
}
}
-END_NONMATCH
-void sub_080379BC(Entity* this) {
+void sub_080379BC(GibdoEntity* this) {
u32 r;
- this->actionDelay = 0x18;
- this->field_0xf = 0x8;
+ super->actionDelay = 0x18;
+ super->field_0xf = 0x8;
r = Random();
- this->animationState = ((this->animationState + (r & 2)) - 1) & 3;
- this->direction = DirectionFromAnimationState(this->animationState);
- InitAnimationForceUpdate(this, this->animationState + 4);
+ super->animationState = ((super->animationState + (r & 2)) - 1) & 3;
+ super->direction = DirectionFromAnimationState(super->animationState);
+ InitAnimationForceUpdate(super, super->animationState + 4);
}
-u32 sub_080379EC(Entity* this) {
+u32 sub_080379EC(GibdoEntity* this) {
if (sub_0807953C() != 0) {
- if (!(--this->actionDelay)) {
+ if (!(--super->actionDelay)) {
sub_08037A58(this);
return 1;
}
@@ -324,96 +335,113 @@ u32 sub_080379EC(Entity* this) {
return 0;
}
-void sub_08037A14(Entity* this) {
- this->action = 6;
- this->actionDelay = 0x18;
- this->spritePriority.b0 = (this->spritePriority.b0 & (this->actionDelay - 0x20));
- this->spritePriority.b0 |= 3;
- this->flags2 &= 0xfe;
- this->field_0x7c.BYTES.byte0 = 5;
- CopyPosition(this, this->field_0x4c);
- InitAnimationForceUpdate(this, this->animationState + 0xc);
+void sub_08037A14(GibdoEntity* this) {
+ super->action = 6;
+ super->actionDelay = 0x18;
+ super->spritePriority.b0 = (super->spritePriority.b0 & (super->actionDelay - 0x20));
+ super->spritePriority.b0 |= 3;
+ super->flags2 &= 0xfe;
+ this->field_0x7c = 5;
+ CopyPosition(super, super->field_0x4c);
+ InitAnimationForceUpdate(super, super->animationState + 0xc);
}
+
// Take Damage maybe?
-void sub_08037A58(Entity* this) {
+void sub_08037A58(GibdoEntity* this) {
sub_08037ACC(this);
- this->action = 7;
- this->spritePriority.b0 = 4;
- if (this->iframes == 0) {
- this->iframes = 0xec;
+ super->action = 7;
+ super->spritePriority.b0 = 4;
+ if (super->iframes == 0) {
+ super->iframes = 0xec;
}
- this->hitType = 0x26;
- this->flags2 |= 1;
- this->iframes = 0xf4;
- this->knockbackDirection = DirectionFromAnimationState(this->animationState) ^ 0x10;
- this->knockbackDuration = 8;
- this->field_0x46 = 0x180;
- this->field_0x76.HALF.LO = 0x3c;
- InitAnimationForceUpdate(this, this->animationState + 0x10);
+ super->hitType = 0x26;
+ super->flags2 |= 1;
+ super->iframes = 0xf4;
+ super->knockbackDirection = DirectionFromAnimationState(super->animationState) ^ 0x10;
+ super->knockbackDuration = 8;
+ super->field_0x46 = 0x180;
+ this->field_0x76 = 0x3c;
+ InitAnimationForceUpdate(super, super->animationState + 0x10);
}
-void sub_08037ACC(Entity* this) {
+void sub_08037ACC(GibdoEntity* this) {
gPlayerState.flags &= ~PL_DISABLE_ITEMS;
COLLISION_ON(&gPlayerEntity);
gPlayerEntity.iframes = 0x1e;
- gPlayerEntity.knockbackDirection = DirectionFromAnimationState(this->animationState);
+ gPlayerEntity.knockbackDirection = DirectionFromAnimationState(super->animationState);
gPlayerEntity.knockbackDuration = 4;
gPlayerEntity.field_0x46 = 0x180;
}
+
// Damage player maybe?
-void sub_08037B10(Entity* this) {
+void sub_08037B10(GibdoEntity* this) {
u32 h;
gPlayerEntity.iframes = 0xc;
h = ModHealth(-8);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
if (h == 0) {
sub_08037A58(this);
- this->field_0x76.HALF.LO = 0xf0;
+ this->field_0x76 = 0xf0;
}
}
-void sub_08037B48(Entity* this) {
+
+void Gibdo_CreateObjects(GibdoEntity* this) {
Entity* E;
E = CreateObject(OBJECT_2A, 3, 0);
if (E != 0) {
- E->type2 = this->actionDelay;
+ E->type2 = super->actionDelay;
E->spritePriority.b0 = 3;
E->spriteOffsetX = 0;
E->spriteOffsetY = 0xfc;
- E->parent = this;
+ E->parent = super;
}
- *(Entity**)&this->field_0x80.HWORD = E;
+ this->field_0x80 = E;
E = CreateObject(OBJECT_2A, 3, 0);
if (E != 0) {
- E->type2 = this->actionDelay;
+ E->type2 = super->actionDelay;
E->spritePriority.b0 = 3;
E->spriteOffsetX = 0xfd;
E->spriteOffsetY = 0xf8;
- E->parent = this;
+ E->parent = super;
}
- *(Entity**)&this->cutsceneBeh.HWORD = E;
+ this->field_0x84 = E;
E = CreateObject(OBJECT_2A, 3, 0);
if (E != 0) {
- E->type2 = this->actionDelay;
+ E->type2 = super->actionDelay;
E->spritePriority.b0 = 3;
E->spriteOffsetX = 0x5;
E->spriteOffsetY = 0xf5;
- E->parent = this;
+ E->parent = super;
}
- this->child = E;
+ super->child = E;
}
-NONMATCH("asm/non_matching/gibdo/sub_08037C0C.inc", void sub_08037C0C(Entity* this, Entity* that)) {
- if (this->field_0x80.HWORD != 0) {
- this->actionDelay = 0xf;
- this->parent = that;
+void Gibdo_MoveObjectsToStalfos(GibdoEntity* this, Entity* that) {
+ Entity* ent = this->field_0x80;
+ if (ent != NULL) {
+ ent->actionDelay = 0xf;
+ ent->parent = that;
}
- if (this->cutsceneBeh.HWORD != 0) {
- this->actionDelay = 0xf;
- this->parent = that;
+
+ ent = this->field_0x84;
+ if (ent != NULL) {
+ ent->actionDelay = 0xf;
+ ent->parent = that;
}
- if (this->child != 0) {
- this->actionDelay = 0xf;
- this->parent = that;
+
+ ent = super->child;
+ if (ent != NULL) {
+ ent->actionDelay = 0xf;
+ ent->parent = that;
}
}
-END_NONMATCH
+
+void (*const gGibdo[6])(Entity*) = {
+ (EntityActionPtr)Gibdo_OnTick, (EntityActionPtr)sub_080374A4, sub_08001324, sub_0804A7D4, sub_08001242,
+ (EntityActionPtr)nullsub_162,
+};
+
+void (*const gUnk_080CF2AC[9])(GibdoEntity*) = {
+ sub_08037558, sub_08037580, sub_080375A4, sub_080375F8, sub_08037624,
+ sub_08037690, sub_080376D0, sub_0803773C, sub_0803775C,
+};
diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c
new file mode 100644
index 00000000..9e57a024
--- /dev/null
+++ b/src/enemy/gleerok.c
@@ -0,0 +1,1254 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "enemy.h"
+#include "player.h"
+#include "screen.h"
+#include "functions.h"
+#include "object.h"
+
+typedef struct {
+ /*0x00*/ u8 filler[0x30];
+ /*0x30*/ u8 unk_30[6];
+ /*0x36*/ u8 filler_36[0x2];
+ /*0x38*/ Entity* ent;
+ /*0x3c*/ Entity* entities[5];
+ /*0x50*/ Entity* ent2;
+} Gleerok_HeapStruct;
+
+typedef struct {
+ Entity base;
+ u8 filler[0xc];
+ u8 unk_74;
+ u8 unk_75;
+ u8 unk_76;
+ u8 unk_77;
+ u8 unk_78;
+ u8 unk_79;
+ u8 unk_7a;
+ u8 unk_7b;
+ union SplitWord unk_7c;
+ u8 unk_80;
+ u8 unk_81;
+ u8 unk_82;
+ u8 unk_83;
+ Gleerok_HeapStruct* unk_84;
+} GleerokEntity;
+
+extern void (*const gUnk_080CD748[])(Entity*);
+extern void (*const gUnk_080CD75C[])(GleerokEntity*);
+extern void (*const gUnk_080CD7B8[])(GleerokEntity*);
+extern void (*const gUnk_080CD7E4[])(GleerokEntity*);
+extern void (*const gUnk_080CD810[])(GleerokEntity*);
+extern void (*const gUnk_080CD828[])(GleerokEntity*);
+extern void (*const gUnk_080CD848[])(GleerokEntity*);
+
+extern u8 gUnk_080CD774[];
+extern u8 gUnk_080CD7C4[];
+extern u8 gUnk_080CD884[];
+extern u8 gUnk_080CD7F8[];
+extern u8 gUnk_080CD840[];
+extern u8 gUnk_080CD844[];
+
+extern u32 sub_0806FC80(Entity*, Entity*, s32);
+
+extern void sub_0802E518(GleerokEntity* this);
+extern void sub_0802E7E4(Gleerok_HeapStruct* this);
+extern void sub_0802E1D0(GleerokEntity* this);
+extern u32 sub_0802EB9C(GleerokEntity* this);
+extern void sub_0802D86C(GleerokEntity* this);
+extern void sub_0802E430(GleerokEntity* this);
+extern void sub_0802EBC4(GleerokEntity* this);
+extern void sub_0802E9B0(GleerokEntity* this);
+
+extern bool32 sub_0802EB08(Gleerok_HeapStruct* param_1, u32 param_2, u32 param_3);
+extern bool32 sub_0802EA18(u16 param_1, u16 param_2, u32 param_3);
+extern bool32 sub_0802EA48(Gleerok_HeapStruct* param_1, u32 param_2, u32 param_3, u32 param_4);
+extern bool32 sub_0802EA68(Gleerok_HeapStruct* param_1, u32 param_2, u32 param_3, u32 param_4);
+extern bool32 sub_0802E7CC(Gleerok_HeapStruct* param_1, u32 param_2, u32 param_3, u32 param_4);
+extern bool32 sub_0802EA88(Gleerok_HeapStruct* param_1);
+extern bool32 sub_0802E768(Gleerok_HeapStruct* param_1);
+
+void Gleerok(Entity* this) {
+ gUnk_080CD748[GetNextFunction(this)](this);
+}
+
+void sub_0802D034(GleerokEntity* this) {
+ sub_08078B48();
+
+ switch (super->type) {
+ case 2:
+ if (super->type2 == 0) {
+ super->type2 = 1;
+ super->actionDelay = 0;
+ super->field_0xf = 0x3c;
+ this->unk_74 = 0x10;
+ this->unk_75 = 0;
+ gScreen.controls.alphaBlend = this->unk_74;
+ gScreen.controls.layerFXControl = 0x1442;
+ SoundReq(SFX_EVAPORATE);
+ } else {
+ ++super->actionDelay;
+ if ((super->actionDelay & 0xf) == 0) {
+ this->unk_75++;
+ this->unk_74--;
+ gScreen.controls.alphaBlend = this->unk_74 | (this->unk_75 << 8);
+ if (gScreen.controls.alphaBlend == 0x1000) {
+ sub_0807AABC(&gPlayerEntity);
+ DeleteThisEntity();
+ }
+ }
+
+ if (super->field_0xf) {
+ if (--super->field_0xf == 0) {
+ SoundReq(SFX_APPARATE);
+ }
+ }
+ }
+ break;
+ case 1:
+ SoundReq(SFX_BOSS_DIE);
+ sub_0804A7D4(super);
+ break;
+ case 0:
+ gPlayerState.field_0x14 = 1;
+
+ if (sub_0806FC80(super, &gPlayerEntity, super->frame & 0x3f)) {
+ gPlayerState.field_0x3f = 0xfa;
+ }
+
+ gUnk_080CD75C[super->action](this);
+ sub_0802E518(this);
+ sub_0802E7E4(this->unk_84);
+ break;
+ }
+}
+
+void sub_0802D158(GleerokEntity* this) {
+ super->action = 1;
+ gUnk_02034490.unk0 = 1;
+ SetFade(7, 8);
+}
+
+void sub_0802D170(GleerokEntity* this) {
+ if (gFadeControl.active)
+ return;
+
+ if (super->action == 1) {
+ this->unk_84->filler[1] = 0x10;
+ this->unk_84->filler[0x19] = 0x10;
+ if (sub_0802EB08(this->unk_84, 0x40, 2) == 0 && sub_0802EA88(this->unk_84) == 0) {
+ super->action = 2;
+ gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x98;
+ gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0xd8;
+ gPlayerEntity.animationState = 0;
+ sub_0807BA8C(COORD_TO_TILE(&gPlayerEntity), 2);
+ gRoomControls.camera_target = super;
+ SetFade(6, 8);
+ }
+ } else {
+ super->action = 3;
+ this->unk_80 = 0;
+ ((Entity*)this->unk_84)->parent->actionDelay = 0x18;
+ this->unk_84->filler[0x19] = 0;
+ }
+}
+
+void sub_0802D218(GleerokEntity* this) {
+ if (sub_0802EB08(this->unk_84, 0x40, 2))
+ return;
+
+ super->action = 4;
+ super->actionDelay = 0;
+ super->field_0xf = 0;
+ this->unk_7c.HALF_U.LO = 0xb4;
+ ((Entity*)(this->unk_84))->parent->actionDelay = 0xc;
+ CreateObjectWithParent(super, 0x67, 0x2, this->unk_7c.HALF_U.LO);
+}
+
+void sub_0802D258(GleerokEntity* this) {
+ if (this->unk_7c.HALF_U.LO == 0) {
+ sub_0802E1D0(this);
+ if (super->type2 == 5) {
+ super->action = 5;
+ return;
+ }
+ } else {
+ if (--this->unk_7c.HALF_U.LO == 0) {
+ InitializeAnimation(super, 0x4e);
+ }
+ }
+
+ if (super->actionDelay == 0) {
+ super->actionDelay = gUnk_080CD774[super->field_0xf];
+ super->direction = gUnk_080CD774[super->field_0xf + 1];
+ super->field_0xf = (super->field_0xf & 0x3f) + 2;
+ } else {
+ super->actionDelay--;
+ }
+
+ if (super->direction <= 1) {
+ sub_0802EA48(this->unk_84, 5, 0x40, super->direction);
+ } else {
+ Gleerok_HeapStruct** tmp = &this->unk_84;
+ if (super->direction != 0xff) {
+ sub_0802EA68(*tmp, 5, 0x40, super->direction);
+ }
+ }
+
+ if ((gRoomTransition.frameCount & 0x1f) == 0) {
+ SoundReq(SFX_BOSS_DIE);
+ }
+
+ if ((gRoomTransition.frameCount & 0xf) == 0) {
+ Entity* fx;
+ u32 rand = Random() & 5;
+ u8* ptr = (u8*)this->unk_84;
+ rand *= 4;
+ ptr += 0x3c;
+ fx = CreateFx(*(Entity**)(ptr + rand), FX_GIANT_EXPLOSION3, 0);
+ if (fx) {
+ fx->spritePriority.b0 = 0;
+ }
+ }
+
+ sub_0802E768(this->unk_84);
+}
+
+NONMATCH("asm/non_matching/gleerok/sub_0802D33C.inc", void sub_0802D33C(GleerokEntity* this)) {
+ u8* unk_84 = (u8*)this->unk_84;
+ u8* ptr = unk_84;
+ u8* ptr2;
+ u32 i = 0;
+ ptr += 0x3c;
+ ptr2 = ptr;
+
+ do {
+ DeleteEntity(*(Entity**)ptr);
+ ptr += 4;
+ } while (i < 4);
+
+ ptr2 += (i << 2);
+ *(u32*)((*(u8**)ptr2) + 0x45) = 0;
+ *((*(u8**)ptr2) + 0x6d) |= 1;
+ ((Entity*)(*(u8**)(unk_84 + 0x50)))->health = 0;
+ ((Entity*)(*(u8**)(unk_84 + 0x50)))->type2 = 0;
+ ((Entity*)(*(u8**)(unk_84 + 0x50)))->spriteSettings.draw &= ~1;
+ DeleteThisEntity();
+}
+END_NONMATCH
+
+void sub_0802D394(GleerokEntity* this) {
+ gUnk_080CD7B8[super->action](this);
+ super->spriteRendering.b3 = 3;
+}
+
+NONMATCH("asm/non_matching/gleerok/sub_0802D3B8.inc", void sub_0802D3B8(GleerokEntity* this)) {
+ u32 uvar1;
+ Entity* ent;
+ Gleerok_HeapStruct* heap;
+ u32 val;
+ u8* ptr;
+ u8* ptr2;
+
+ if (CheckGlobalFlag(3)) {
+ gScreen.lcd.displayControl &= 0xFDFF;
+ sub_0807AABC(&gPlayerEntity);
+ DeleteThisEntity();
+ }
+
+ super->action = 1;
+
+ switch (super->type) {
+ case 0:
+ super->action = 2;
+ COLLISION_OFF(super);
+ super->spritePriority.b0 = 7;
+ this->unk_75 = 0;
+ this->unk_80 = 0;
+ this->unk_79 = 0;
+ this->unk_7c.WORD = 0x96;
+
+ sub_0802EB9C(this);
+ this->unk_84 = zMalloc(0x54);
+ heap = this->unk_84;
+
+ if (heap == NULL) {
+ sub_0804A7D4(super);
+ DeleteThisEntity();
+ }
+
+ super->myHeap = this->unk_84;
+ uvar1 = 0;
+
+ do {
+ ent = CreateEnemy(GLEEROK, 1);
+ super->child = ent;
+ if (ent) {
+ ent->type2 = uvar1 + 1;
+ super->child->collisionLayer = super->collisionLayer;
+ super->child->x.HALF.HI = super->x.HALF.HI;
+ super->child->y.HALF.HI = super->y.HALF.HI + ((uvar1 + 1) * 12);
+ super->child->parent = super;
+ ((GleerokEntity*)super->child)->unk_84 = this->unk_84;
+ this->unk_84->entities[uvar1] = super->child;
+ ptr = this->unk_84->filler;
+ ptr2 = ptr + uvar1 * 4;
+ ptr2[1] = 0x10;
+ ptr2[0x19] = 0;
+ ptr[0x35] = 0;
+ }
+ } while (++uvar1 < 5);
+
+ ent = CreateEnemy(GLEEROK, 2);
+ super->child = ent;
+ if (ent) {
+ super->child->collisionLayer = super->collisionLayer;
+ super->child->x.HALF.HI = super->x.HALF.HI;
+ super->child->y.HALF.HI = super->y.HALF.HI + ((uvar1 + 1) * 12);
+ super->child->parent = super;
+ ((GleerokEntity*)super->child)->unk_84 = this->unk_84;
+ heap->ent2 = super->child;
+ heap->filler[0x15] = 0x10;
+ heap->filler[0x2d] = 0;
+ heap->filler[0x35] = 0;
+ }
+#ifndef EU
+ gPlayerState.controlMode = 3;
+#endif
+ InitializeAnimation(super, 0x4c);
+ break;
+ case 1:
+ if (super->type2 == 1) {
+ COLLISION_ON(super);
+ super->flags2 |= 0x80;
+ }
+ ptr = gUnk_080CD7C4;
+ ptr += super->type2 * 4;
+ super->spritePriority.b0 = *(ptr + 1);
+ super->field_0xf = 0;
+ InitializeAnimation(super, 0x24);
+ break;
+ case 2:
+ super->spritePriority.b0 = 0;
+ super->field_0xf = 0;
+ InitAnimationForceUpdate(super, 0);
+ break;
+ case 3:
+ this->unk_74 = gUnk_080CD884[0];
+ this->unk_75 = 0;
+ super->spritePriority.b0 = 6;
+ super->flags2 |= 0x80;
+ CopyPosition(super->parent, super);
+ InitializeAnimation(super, 0x4f);
+ break;
+ case 4:
+ InitAnimationForceUpdate(super, 0x2c);
+ break;
+ case 5:
+ super->spritePriority.b0 = 6;
+ CopyPosition(super->parent, super);
+ InitAnimationForceUpdate(super, 0x2d);
+ break;
+ case 6:
+ super->spritePriority.b0 = 6;
+ CopyPosition(super->parent, super);
+ InitializeAnimation(super, 0x50);
+ break;
+ }
+
+ if (super->type) {
+ sub_0802D86C(this);
+ }
+}
+END_NONMATCH
+
+void sub_0802D650(GleerokEntity* this) {
+#ifdef EU
+ sub_08078B48();
+#endif
+
+ gUnk_080CD7E4[super->subAction](this);
+ sub_0802E7E4(this->unk_84);
+}
+
+void sub_0802D674(GleerokEntity* this) {
+ u32 val;
+ gUnk_02034490.unk0 = 1;
+
+ if (gPlayerEntity.z.WORD != 0)
+ return;
+ if (this->unk_7c.WORD == 0x96) {
+ SoundReq(SFX_BOSS_HIT);
+ }
+
+ val = --this->unk_7c.WORD;
+ if (val == -1) {
+ super->subAction = 1;
+ this->unk_7c.WORD = 0x5a;
+ gRoomControls.camera_target = super;
+ SoundReq(SFX_BOSS_HIT);
+ } else if (val <= 0x3c) {
+ if (val == 0x3c) {
+ CreateSpeechBubbleExclamationMark(&gPlayerEntity, 0xc, -0x18);
+ }
+ gPlayerEntity.animationState = 0;
+ } else if (val <= 0x59) {
+ gPlayerEntity.animationState = 2;
+ } else if (val <= 0x77) {
+ gPlayerEntity.animationState = 6;
+ }
+}
+
+void sub_0802D6F0(GleerokEntity* this) {
+ if (--this->unk_7c.WORD == -1) {
+ super->subAction = 2;
+ this->unk_7c.WORD = 0x5a;
+ InitScreenShake(0x96, 0);
+ }
+}
+
+void sub_0802D714(GleerokEntity* this) {
+ Entity* enemy;
+ u32 index;
+ u32 val1, val2;
+ u8* ptr;
+ Gleerok_HeapStruct* heap;
+ if (--this->unk_7c.WORD != -1)
+ return;
+
+ for (heap = this->unk_84, index = 0, val1 = 0, val2 = 0x10, ptr = this->unk_84->filler; index < 6;
+ ptr += 4, ++index) {
+ *(u16*)(ptr + 0x18) = val1;
+ *(ptr + 1) = val2;
+ }
+
+ super->subAction = 3;
+ super->type2 = 0;
+ super->spriteSettings.draw = 1;
+ InitializeAnimation(super, 0x4d);
+ enemy = CreateEnemy(GLEEROK, 5);
+ super->child = enemy;
+ if (enemy) {
+ enemy->parent = super;
+ heap->ent = super->child;
+ ((GleerokEntity*)(super->child))->unk_84 = heap;
+ }
+
+ heap->ent2->actionDelay = 0x18;
+}
+
+void sub_0802D77C(GleerokEntity* this) {
+ if (gRoomTransition.frameCount & 1)
+ return;
+
+ sub_0802E430(this);
+
+ if (super->type2 != 2)
+ return;
+
+ super->field_0xf = 0;
+ super->actionDelay = 0;
+ super->subAction = 4;
+ this->unk_84->ent2->actionDelay = 0xc;
+}
+
+void sub_0802D7B4(GleerokEntity* this) {
+ if (super->actionDelay == 0) {
+ if (gUnk_080CD7F8[super->field_0xf] == 0xff) {
+ super->field_0xf = 0;
+ super->actionDelay = 0;
+ super->action = 1;
+ super->subAction = 0;
+ this->unk_84->ent2->actionDelay = 0x18;
+ gRoomControls.camera_target = &gPlayerEntity;
+#ifndef EU
+ gPlayerState.controlMode = 1;
+#endif
+ gUnk_02034490.unk0 = 0;
+ SoundReq(BGM_BOSS_THEME);
+ return;
+ } else {
+ super->actionDelay = gUnk_080CD7F8[super->field_0xf];
+ super->direction = gUnk_080CD7F8[super->field_0xf + 1];
+ super->field_0xf += 2;
+ SoundReq(SFX_BOSS_HIT);
+ }
+ } else {
+ super->actionDelay--;
+ }
+
+ if (super->direction <= 1) {
+ sub_0802EA48(this->unk_84, 5, 0x40, super->direction);
+ } else if (super->direction != 0xff) {
+ sub_0802EA68(this->unk_84, 5, 0x40, super->direction);
+ }
+
+ sub_0802E768(this->unk_84);
+ sub_0802E518(this);
+}
+
+NONMATCH("asm/non_matching/gleerok/sub_0802D86C.inc", void sub_0802D86C(GleerokEntity* this)) {
+ Entity* enemy;
+ Entity* enemy2;
+ switch (super->type) {
+ case 1:
+ if (super->type2 == 1) {
+ if (((GleerokEntity*)(super->parent))->unk_80 != 0 || super->spriteSettings.draw != 1) {
+ COLLISION_OFF(super);
+ } else {
+ COLLISION_ON(super);
+ }
+ }
+ case 2:
+ if ((super->spriteSettings.draw & 1) == 0)
+ return;
+
+ super->iframes = super->parent->iframes;
+ if (super->iframes == 0) {
+ if (super->field_0xf == 0) {
+ UnloadOBJPalette(super);
+ LoadObjPalette(super, 0xc9);
+ } else {
+ super->field_0xf--;
+ UnloadOBJPalette(super);
+ LoadObjPalette(super, 0xca);
+ }
+ }
+
+ if (((GleerokEntity*)(super->parent))->unk_80 == 0)
+ return;
+ if (!EntityInRectRadius(super, &gPlayerEntity, 8, 8))
+ return;
+
+ gPlayerState.field_0x14 = 1;
+ gPlayerState.field_0x3f = 0xfc;
+
+ break;
+ case 4:
+ if (super->frame == 0) {
+ UpdateAnimationSingleFrame(super);
+ return;
+ }
+
+ if (GravityUpdate(super, 0x1800))
+ return;
+
+ ((GleerokEntity*)(super->parent))->unk_7b = 1;
+ super->actionDelay = 0;
+
+ do {
+ CreateObjectWithParent(super, OBJECT_67, 0, super->actionDelay);
+ } while (++super->actionDelay < 8);
+
+ SoundReq(SFX_150);
+ DeleteThisEntity();
+ break;
+ case 5:
+ if ((gRoomTransition.frameCount & 1) && super->parent->action == 2)
+ return;
+
+ UpdateAnimationSingleFrame(super);
+
+ if ((super->frame & 0x80) == 0)
+ return;
+
+ enemy = CreateEnemy(GLEEROK, 6);
+
+ super->child = enemy;
+ if (enemy) {
+ enemy->parent = super->parent;
+ this->unk_84->ent = super->child;
+ ((GleerokEntity*)super->child)->unk_84 = this->unk_84;
+ }
+
+ DeleteThisEntity();
+ break;
+ case 6:
+ if ((gRoomTransition.frameCount & 1) && super->parent->action == 2)
+ return;
+
+ GetNextFrame(super);
+
+ if ((super->frame & 0x80) == 0)
+ return;
+
+ enemy = CreateEnemy(GLEEROK, 3);
+
+ super->child = enemy;
+ if (enemy) {
+ enemy->parent = super->parent;
+ super->actionDelay = this->unk_84->filler[1];
+ this->unk_84->ent = super->child;
+ ((GleerokEntity*)super->child)->unk_84 = this->unk_84;
+ }
+
+ DeleteThisEntity();
+ break;
+ case 3:
+ if (this->unk_74) {
+ if (--this->unk_74 == 0) {
+ u32 unk_74;
+ this->unk_75 += 2;
+ unk_74 = gUnk_080CD884[this->unk_75];
+ this->unk_74 = unk_74;
+
+ if (unk_74) {
+ UnloadOBJPalette(super);
+ LoadObjPalette(super, gUnk_080CD884[this->unk_75 + 1]);
+ }
+ }
+ }
+
+ if ((super->bitfield & 0x80) && this->unk_74 == 0) {
+ if ((super->bitfield & 0x7f) == 0x1d) {
+ super->zVelocity = 0x30000;
+ super->parent->subAction = 4;
+ super->parent->type2 = 0;
+ ((GleerokEntity*)super->parent)->unk_7b = 0;
+ SoundReq(SFX_BUTTON_PRESS);
+ }
+ } else {
+ if (super->actionDelay != this->unk_84->filler[1]) {
+ if (((super->actionDelay - this->unk_84->filler[1]) & 0x1f) > 0x10) {
+ if (++super->frameIndex >= 0x31) {
+ super->frameIndex = 0x28;
+ }
+ } else {
+ if (--super->frameIndex <= 0x27) {
+ super->frameIndex = 0x30;
+ }
+ }
+
+ super->actionDelay = this->unk_84->filler[1];
+ }
+ }
+
+ if (super->zVelocity <= 0)
+ return;
+
+ GravityUpdate(super, 0x1800);
+
+ if (super->zVelocity > 0)
+ return;
+
+ enemy = CreateEnemy(GLEEROK, 4);
+ super->child = enemy;
+ if (enemy) {
+ enemy->parent = super->parent;
+ this->unk_84->ent = super->child;
+ ((GleerokEntity*)super->child)->unk_84 = this->unk_84;
+ // Making super in super->child volatile solves this but ugly
+ CopyPosition(super, super->child);
+ DeleteThisEntity();
+ }
+
+ break;
+ case 0:
+ gUnk_080CD810[super->subAction](this);
+ sub_0802E7E4(this->unk_84);
+ break;
+ }
+}
+END_NONMATCH
+
+void sub_0802DB84(GleerokEntity* this) {
+ u32 actionDelay;
+ super->direction = GetFacingDirection(super, &gPlayerEntity);
+ if (this->unk_84->filler[0x1] == super->direction) {
+ super->subAction = 1;
+ this->unk_78 = 0;
+ return;
+ }
+
+ if (((this->unk_84->filler[0x1] - super->direction) & 0x1f) > 0x10) {
+ actionDelay = 0;
+ super->actionDelay &= 0xfe;
+ } else {
+ actionDelay = 1;
+ super->actionDelay = actionDelay;
+ }
+
+ switch (this->unk_79) {
+ case 0:
+ super->speed = 0x30;
+ break;
+ case 1:
+ super->speed = 0x40;
+ break;
+ case 2:
+ super->speed = 0x50;
+ break;
+ }
+
+ sub_0802EA48(this->unk_84, 5, super->speed, actionDelay);
+ sub_0802E768(this->unk_84);
+ sub_0802E518(this);
+ sub_0802EBC4(this);
+}
+
+void sub_0802DC1C(GleerokEntity* this) {
+ u32 diff = GetFacingDirection(super, &gPlayerEntity);
+ diff = (this->unk_84->filler[1] - diff) & 0x1f;
+
+ if (diff > 0x10) {
+ if (diff <= 0x1d) {
+ super->subAction = 0;
+ this->unk_84->ent2->actionDelay = 0;
+ return;
+ }
+ } else if (diff >= 3) {
+ super->subAction = 0;
+ this->unk_84->ent2->actionDelay = 0;
+ return;
+ }
+ if (this->unk_78) {
+ this->unk_78--;
+ } else {
+ u8 actionDelay = super->actionDelay;
+ diff = 0;
+ if (actionDelay == 1) {
+ diff = 1;
+ }
+
+ sub_0802EA48(this->unk_84, 5, 0x20, diff);
+ if (sub_0802EA18(*(u16*)&this->unk_84->filler[0], *(u16*)&this->unk_84->filler[0x14], 4)) {
+ if (super->actionDelay == 1) {
+ *(u16*)&this->unk_84->filler[0x14] = (((this->unk_84->filler[0x1] - 4) & 0x1f) << 8) | 0xff;
+ } else {
+ *(u16*)&this->unk_84->filler[0x14] = (((this->unk_84->filler[0x1] + 4) & 0x1f) << 8);
+ }
+
+ super->actionDelay ^= 1;
+ this->unk_78 = 0xc;
+ }
+ }
+
+ sub_0802E9B0(this);
+ sub_0802E768(this->unk_84);
+ sub_0802E518(this);
+ sub_0802EBC4(this);
+}
+
+void sub_0802DCE0(GleerokEntity* this) {
+ if (this->unk_84->ent2->actionDelay != 0xc) {
+ super->direction = GetFacingDirection(super, &gPlayerEntity);
+ if (this->unk_84->filler[0x15] == super->direction) {
+ this->unk_84->ent2->actionDelay = 0xc;
+ this->unk_82 = 4;
+ super->field_0xf = 0;
+ } else {
+ s32 svar1, diff;
+ diff = ((this->unk_84->filler[0x15] - super->direction) & 0x1f);
+ svar1 = 1;
+ if (diff > 0x10) {
+ svar1 = 0;
+ }
+
+ sub_0802EA48(this->unk_84, 5, 0x20, svar1);
+ sub_0802E768(this->unk_84);
+ }
+ } else {
+ if (super->field_0xf < 6) {
+ if (this->unk_82 == 0) {
+ this->unk_82 = 4;
+ this->unk_84->entities[super->field_0xf]->field_0xf = 4;
+ super->field_0xf++;
+ } else {
+ this->unk_82--;
+ }
+ } else {
+ if (this->unk_84->ent2->field_0xf == 0) {
+ super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0);
+
+ if (super->child) {
+ super->child->direction = this->unk_84->filler[0x15];
+ super->child->type2 = this->unk_84->ent2->frame & 0xf;
+ super->child->parent = this->unk_84->ent2;
+ super->child->child = this->unk_84->entities[0];
+ }
+
+ this->unk_84->ent2->actionDelay = 0;
+ if (this->unk_74 == 0) {
+ this->unk_74 = 1;
+ } else {
+ super->subAction = 0;
+ sub_0802EB9C(this);
+ }
+ }
+ }
+ }
+ sub_0802E518(this);
+}
+
+void sub_0802DDD8(GleerokEntity* this) {
+ u32 r2, r8, r4;
+ u32 rv;
+ u32 unk_76 = this->unk_76;
+ u32 uvar1 = 4;
+ if (unk_76) {
+ uvar1 = 6;
+ if (this->unk_79 == 2) {
+ if ((Random() & 1) == 0) {
+ uvar1 = 0xc;
+ }
+ }
+ }
+
+ switch (super->type2) {
+ case 0:
+ rv = sub_0802EA88(this->unk_84);
+ if (rv != 0)
+ break;
+
+ super->type2 = 1;
+ super->field_0xf = 0;
+
+ if ((Random() & 1) == 0) {
+ super->direction = 0;
+ this->unk_7a = (this->unk_84->filler[1] + uvar1) & 0x1f;
+ } else {
+ super->direction = 1;
+ this->unk_7a = (this->unk_84->filler[1] - uvar1) & 0x1f;
+ }
+
+ break;
+ case 1:
+ case 2:
+ if (super->type2 == 1)
+ goto code13;
+ if (this->unk_76 == 0) {
+ r2 = 1;
+ r8 = 2;
+ r4 = 1;
+ } else {
+ r2 = 2;
+ r8 = 6;
+ r4 = 0;
+ }
+
+ if (this->unk_84->ent2->field_0xf == 1) {
+ super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, r2);
+ if (super->child) {
+ super->child->direction = this->unk_84->filler[0x15];
+ super->child->type2 = this->unk_84->ent2->frame & 0xf;
+ super->child->parent = this->unk_84->ent2;
+ super->child->child = this->unk_84->entities[0];
+ }
+ }
+
+ if (this->unk_74 == 0) {
+ this->unk_74 = r4;
+ this->unk_84->entities[super->field_0xf]->field_0xf = r8;
+
+ if (++super->field_0xf > 5) {
+ super->field_0xf = 0;
+ }
+ } else {
+ this->unk_74--;
+ }
+
+ if (super->type2 == 1) {
+ code13:
+ sub_0802EA48(this->unk_84, 5, 0x40, super->direction);
+ } else {
+ if (this->unk_76 == 0) {
+ sub_0802EA48(this->unk_84, 5, 0x20, super->direction);
+ } else {
+ sub_0802EA48(this->unk_84, 5, 0x10, super->direction);
+ }
+ }
+ sub_0802E768(this->unk_84);
+
+ if (this->unk_7a == this->unk_84->filler[0x15]) {
+ if (super->type2 == 1) {
+ super->type2 = 2;
+ super->direction ^= 1;
+ if (super->direction == 1) {
+ this->unk_7a = (this->unk_7a - (uvar1 * 2)) & 0x1f;
+ super->actionDelay = 1;
+ } else {
+ this->unk_7a = (this->unk_7a + (uvar1 * 2)) & 0x1f;
+ super->actionDelay &= 0xfe;
+ }
+
+ this->unk_84->ent2->actionDelay = 0xc;
+ } else {
+ super->subAction = 0;
+ this->unk_84->ent2->actionDelay = 0;
+ sub_0802EB9C(this);
+ }
+ }
+
+ break;
+ }
+ sub_0802E518(this);
+}
+
+void sub_0802DFA8(GleerokEntity* this) {
+ gUnk_080CD828[super->type2](this);
+}
+
+void sub_0802DFC0(GleerokEntity* this) {
+ u32 val = this->unk_84->filler[1] & 7;
+ if (val) {
+ if (val > 4) {
+ super->direction = 0;
+ } else {
+ super->direction = 1;
+ }
+
+ sub_0802EA48(this->unk_84, 0, 0x20, super->direction);
+ sub_0802EA88(this->unk_84);
+ } else {
+ if (sub_0802EA88(this->unk_84) == 0) {
+ if (this->unk_7b) {
+ COLLISION_ON(super);
+ super->type2 = 1;
+ this->unk_84->ent2->actionDelay = 0x18;
+ SoundReq(SFX_BOSS_HIT);
+ }
+ }
+ }
+
+ sub_0802E518(this);
+}
+
+void sub_0802E034(GleerokEntity* this) {
+ Gleerok_HeapStruct* heap = this->unk_84;
+ u32 val;
+
+ if (super->type2 == 1) {
+ super->direction = 2;
+ val = 0;
+ } else {
+ super->direction = 3;
+ val = gUnk_080CD840[heap->filler[1] >> 3];
+ }
+
+ if (val != heap->filler[0x19]) {
+ sub_0802EA68(heap, 0, 0x40, super->direction);
+ sub_0802EB08(heap, 0x40, 2);
+ } else {
+ if (sub_0802EB08(heap, 0x80, 2) == 0) {
+ if (super->type2 == 2) {
+ this->unk_7c.HALF.LO = 0x168;
+ this->unk_80 = 1;
+ heap->ent2->actionDelay = 0;
+ }
+
+ super->type2++;
+ heap->filler[0x19] = 1;
+ }
+ }
+
+ sub_0802E518(this);
+}
+
+void sub_0802E0B8(GleerokEntity* this) {
+ u32 val;
+
+ super->y.HALF.HI -= 4;
+ sub_0800445C(super);
+ super->y.HALF.HI += 4;
+
+ val = super->frame & 0x3f;
+ if (val) {
+ if (sub_0806FC80(super, &gPlayerEntity, val)) {
+ gPlayerState.field_0x14 = 1;
+ gPlayerState.field_0x3f = 0xfa;
+ }
+ }
+
+ if (gUnk_080CD844[this->unk_79 & 0x7f] >= super->health) {
+ if (this->unk_79 > 1) {
+ super->health = 0;
+ super->action = 0;
+ sub_08078B48();
+ SoundReq(SFX_BOSS_DIE);
+ return;
+ } else {
+ COLLISION_OFF(super);
+ this->unk_79++;
+ this->unk_79 |= 0x80;
+ super->health = 0xff;
+ if (this->unk_7c.HALF_U.LO > 0x78) {
+ this->unk_7c.HALF.LO = 0x78;
+ }
+ }
+ }
+
+ if ((--this->unk_7c.HALF.LO << 16) == 0xffff0000) {
+ COLLISION_OFF(super);
+ super->spriteOffsetX = 0;
+ super->type2 = 4;
+ InitializeAnimation(super, 0x4e);
+ } else {
+ if (super->bitfield & 0x80) {
+ if (super->iframes > 0) {
+ SoundReq(SFX_BOSS_HIT);
+ }
+ }
+
+ if (this->unk_7c.HALF_U.LO < 0x78) {
+ super->spriteOffsetX ^= 1;
+ }
+ }
+
+ sub_0802E518(this);
+}
+
+void sub_0802E1D0(GleerokEntity* this) {
+ Gleerok_HeapStruct* heap = this->unk_84;
+ if (!(super->frame & 0x80)) {
+ GetNextFrame(super);
+ }
+ if (super->frame & 0x3f) {
+ if (sub_0806FC80(super, &gPlayerEntity, super->frame & 0x3f)) {
+ gPlayerState.field_0x14 = 1;
+ gPlayerState.field_0x3f = 0xfa;
+ }
+ }
+ if (super->frame & 0x40) {
+ u32 i;
+ for (i = 0; i < 6; i++) {
+ if (heap->unk_30[i]) {
+ heap->unk_30[i]--;
+ if (heap->unk_30[i] == 0) {
+ CreateFx(heap->entities[0], FX_LAVA_SPLASH, 0);
+ SoundReq(SFX_124);
+ if (i == 5) {
+ if (!(this->unk_79 & 0x80)) {
+ this->unk_7c.HALF_U.LO = 0xF0;
+ InitScreenShake(0xF0, 0);
+ } else {
+ for (this->unk_7c.HALF_U.LO = 0; this->unk_7c.HALF_U.LO < 4; this->unk_7c.HALF_U.LO++) {
+ CreateObjectWithParent(super, OBJECT_67, 1, this->unk_7c.HALF_U.LO);
+ }
+ this->unk_74 = 0;
+ this->unk_75 = 0x10;
+ this->unk_7c.HALF_U.LO = 0xB;
+ gScreen.controls.alphaBlend = this->unk_74 | (this->unk_75 << 8);
+ gScreen.controls.layerFXControl = 0x240;
+ InitScreenShake(0x1e, 0);
+ }
+ super->type2 = 5;
+ }
+ }
+ break;
+ }
+ }
+ }
+ sub_0802E518(this);
+}
+
+void sub_0802E300(GleerokEntity* this) {
+ u32 dir, tmp;
+ u32 index;
+ u8* ptr;
+ u8* ptr2;
+ Entity* ent;
+ Gleerok_HeapStruct* heap;
+ if ((this->unk_79 & 0x80) == 0) {
+ this->unk_7c.HALF.LO--;
+ } else {
+ if (this->unk_74 != 0x10) {
+ if (this->unk_7c.HALF_U.LO) {
+ --this->unk_7c.HALF_U.LO;
+ if (this->unk_7c.HALF_U.LO == 0) {
+ this->unk_7c.HALF_U.LO = 0xb;
+ this->unk_75--;
+ this->unk_74++;
+ gScreen.controls.alphaBlend = this->unk_74 | (this->unk_75 << 8);
+ }
+ }
+ }
+ }
+
+ if (this->unk_7c.HALF_U.LO == 0) {
+ if (this->unk_79 & 0x80) {
+ if (this->unk_75 != 0x10) {
+ this->unk_7c.HALF_U.LO = 0xb;
+ this->unk_75++;
+ this->unk_74--;
+ gScreen.controls.alphaBlend = this->unk_74 | (this->unk_75 << 8);
+ return;
+ }
+ }
+
+ this->unk_79 &= 0x7f;
+ heap = this->unk_84;
+ dir = sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)) << 3;
+ index = 0;
+ ptr2 = &this->unk_80;
+ tmp = 0;
+ ptr = heap->filler;
+ do {
+ ((u16*)ptr)[0xc] = tmp;
+ ptr[1] = dir;
+ ptr += 4;
+ index++;
+ } while (index <= 5);
+
+ super->subAction = 5;
+ super->type2 = 0;
+ *ptr2 = 0;
+ InitializeAnimation(super, 0x4d);
+ ent = CreateEnemy(GLEEROK, 5);
+ super->child = ent;
+ if (super->child) {
+ super->child->parent = super;
+ heap->ent = super->child;
+ ((GleerokEntity*)super->child)->unk_84 = heap;
+ }
+
+ heap->ent2->actionDelay = 0x18;
+ } else {
+ if ((gRoomTransition.frameCount & 0xf) == 0) {
+ CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0x3);
+ }
+ }
+
+ sub_0802E518(this);
+}
+
+void sub_0802E430(GleerokEntity* this) {
+ gUnk_080CD848[super->type2](this);
+}
+
+void sub_0802E448(GleerokEntity* this) {
+ Gleerok_HeapStruct* heap = this->unk_84;
+ s32 index;
+ for (index = 5; index >= 0; index--) {
+ u8* ptr = &heap->filler[0x30];
+ if (ptr[index] == 0) {
+ CreateFx(heap->entities[0], FX_LAVA_SPLASH, 0);
+ SoundReq(SFX_PLY_LAND);
+ }
+
+ if (ptr[index] != 10) {
+ if (++ptr[index] == 10 && index == 0) {
+ super->type2 = 1;
+ }
+ break;
+ }
+ }
+
+ if (heap->filler[0x2d] <= 9) {
+ sub_0802EA68(heap, 5, 0x40, 3);
+ }
+
+ GetNextFrame(super);
+ sub_0802E768(this->unk_84);
+ sub_0802E518(this);
+}
+
+void sub_0802E4C0(GleerokEntity* this) {
+ GetNextFrame(super);
+
+ if (super->frame & 0x80) {
+ if (super->action != 2) {
+ this->unk_74 = 0;
+ this->unk_75 = 8;
+
+ if (this->unk_79) {
+ this->unk_76 = 0;
+ this->unk_77 = 3;
+ }
+
+ sub_0802EBC4(this);
+ } else {
+ super->type2++;
+ }
+ }
+
+ sub_0802E518(this);
+}
+
+NONMATCH("asm/non_matching/gleerok/sub_0802E518.inc", void sub_0802E518(GleerokEntity* this)) {
+ u32 index;
+ u32 r6;
+ u32 sp4;
+ u32 sp8;
+ s32 r7;
+ Gleerok_HeapStruct* heap = this->unk_84;
+ CopyPosition(heap->entities[0]->parent, heap->entities[0]);
+ heap->entities[0]->direction = heap->filler[1];
+
+ r6 = heap->filler[1];
+ if (r6 > 0x10) {
+ r6 ^= 0xf;
+ r6 = (r6 + 1) & 0xf;
+ }
+
+ if (r6 == 0x10) {
+ r6 = 0xf;
+ }
+
+ heap->entities[0]->speed = ((r6 ^ 0xf) + 0x12) << 8;
+ LinearMoveUpdate(heap->entities[0]);
+ sp4 = *(u32*)&heap->filler[0x30];
+ sp8 = this->unk_80;
+
+ for (index = 0; index <= 4; index++) {
+ s32 result;
+ CopyPosition(heap->entities[index], heap->entities[index + 1]);
+ result = FixedMul(gSineTable[heap->filler[0x19 + (index + 1) * 4]], ((u8*)sp4)[r6]);
+ result = FixedDiv(result, 0x100);
+ result = FixedMul(gSineTable[heap->filler[0x1 + (index + 1) * 4]], result);
+ result = FixedDiv(result, 0x100);
+ heap->entities[index]->x.WORD += result << 8;
+
+ result = FixedMul(gSineTable[heap->filler[0x19 + (index + 1) * 4]], ((u8*)sp4)[r6]);
+ result = FixedDiv(result, 0x100);
+ heap->entities[index]->y.WORD -= result << 8;
+ }
+
+ if (heap->ent2->actionDelay == 0x18) {
+ r7 = (heap->filler[0x15] >> 3) << 2;
+ if (heap->filler[0x2d] > 0xc) {
+ r7 += 3;
+ } else {
+ r7 += heap->filler[0x2d] >> 2;
+ }
+
+ if (heap->ent2->animIndex != r7 + 0x18) {
+ InitAnimationForceUpdate(heap->ent2, r7 + 0x18);
+ }
+ } else {
+ if (this->unk_80 == 0) {
+ sub_0802E7CC(heap, 5, 0, 0);
+ r7 = (heap->ent2->animationState / 2 + heap->ent2->animationState) / 4;
+ r7 += heap->ent2->actionDelay;
+ } else {
+ if (super->iframes == 0) {
+ if ((super->animIndex != (heap->filler[0x15] >> 3) + 0x2f) || (super->frame & 0x80) != 0) {
+ r7 = (heap->filler[0x15] >> 3) + 0x28;
+ }
+ } else {
+ r7 = (heap->filler[0x15] >> 3) + 0x2f;
+ }
+ }
+
+ if (heap->ent2->animIndex != r7) {
+ InitAnimationForceUpdate(heap->ent2, r7);
+ } else {
+ UpdateAnimationSingleFrame(heap->ent2);
+ }
+ }
+
+ for (index = 0; index <= 4; index++) {
+ if (this->unk_80 == 0) {
+ u32 val;
+ sub_0802E7CC(heap, (u8)index, 0, 0);
+ r7 = heap->entities[index]->animationState * 12;
+ r7 += (((s32)heap->filler[0x19 + (index + 1) * 4]) / 3) * 12;
+ } else {
+ r7 = heap->filler[0x1 + index * 4] >> 3;
+ r7 += 0x48;
+ }
+ if (heap->entities[index]->animIndex != r7) {
+ InitializeAnimation(heap->entities[index], r7);
+ }
+ }
+}
+END_NONMATCH
diff --git a/src/enemy/gyorgChild.c b/src/enemy/gyorgChild.c
index c57e7dce..e260fb25 100644
--- a/src/enemy/gyorgChild.c
+++ b/src/enemy/gyorgChild.c
@@ -20,7 +20,7 @@ void (*const gUnk_080D1E6C[])(GyorgChildEntity*) = {
void GyorgChild(Entity* this) {
if (gRoomTransition.field_0x39 == 0) {
- this->flags &= ~0x80;
+ this->flags &= ~ENT_COLLIDE;
this->health = 0;
this->collisionLayer = 2;
}
@@ -89,7 +89,7 @@ void sub_080486F4(GyorgChildEntity* this) {
s32 r;
InitializeAnimation(super, super->animationState);
super->action = 1;
- super->flags |= 0x80;
+ super->flags |= ENT_COLLIDE;
r = (signed)Random() % 0xB;
super->direction += r;
super->direction -= 5;
@@ -143,7 +143,7 @@ void sub_0804877C(GyorgChildEntity* this) {
void sub_0804882C(GyorgChildEntity* this) {
if (--super->actionDelay == 0) {
super->action = 3;
- super->flags |= 0x80;
+ super->flags |= ENT_COLLIDE;
Random();
super->spriteSettings.draw = 1;
super->spritePriority.b0 = 4;
diff --git a/src/enemy/gyorgFemaleEye.c b/src/enemy/gyorgFemaleEye.c
index af10a307..7137532e 100644
--- a/src/enemy/gyorgFemaleEye.c
+++ b/src/enemy/gyorgFemaleEye.c
@@ -125,7 +125,7 @@ void sub_08048B84(GyorgFemaleEyeEntity* this) {
GetNextFrame(super);
if (super->frame & 0x80) {
super->action = 3;
- super->flags |= 0x80;
+ super->flags |= ENT_COLLIDE;
super->hitType = 0x1E;
}
}
@@ -135,11 +135,11 @@ void sub_08048BB0(GyorgFemaleEyeEntity* this) {
if (!((parent->unk_78 >> super->type) & 1)) {
if (parent->base.health != 0) {
super->action = 4;
- super->flags &= ~0x80;
+ super->flags &= ~ENT_COLLIDE;
InitializeAnimation(super, gUnk_080D2030[(super->animationState << 3) + super->type]);
} else {
super->action = 1;
- super->flags &= ~0x80;
+ super->flags &= ~ENT_COLLIDE;
super->spriteSettings.draw = 0;
InitializeAnimation(super, gUnk_080D2010[(super->animationState << 3) + super->type]);
CreateFx(super, 2, 0x40);
@@ -150,7 +150,7 @@ void sub_08048BB0(GyorgFemaleEyeEntity* this) {
super->iframes = 0xF4;
super->hitType = 0x89;
InitializeAnimation(super, (parent->base.animationState >> 6) + 0x14);
- SoundReq(0x119);
+ SoundReq(SFX_ITEM_GLOVES_KNOCKBACK);
}
GetNextFrame(super);
if (super->frame & 0x80) {
diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c
index 4763fe56..357af79b 100644
--- a/src/enemy/gyorgMale.c
+++ b/src/enemy/gyorgMale.c
@@ -106,7 +106,7 @@ void GyorgMale(GyorgMaleEntity* this) {
}
gUnk_080D1AFC[super->action](this);
if (super->action != 7) {
- sub_0805EC9C(this, 0xaa, 0xaa, this->unk_78);
+ sub_0805EC9C(super, 0xaa, 0xaa, this->unk_78);
}
super->animationState = -(this->unk_78 >> 8);
sub_08048004(this);
@@ -279,7 +279,7 @@ void sub_08046B18(GyorgMaleEntity* this) {
}
void sub_08046B8C(GyorgMaleEntity* this) {
- if (sub_0806FCB8(super, this->unk_80, this->unk_82, 4)) {
+ if (EntityWithinDistance(super, this->unk_80, this->unk_82, 4)) {
super->subAction = 3;
this->unk_76 = super->direction << 8;
this->unk_80 = gRoomControls.origin_x + 0x200;
@@ -309,7 +309,7 @@ void sub_08046C04(GyorgMaleEntity* this) {
}
void sub_08046C88(GyorgMaleEntity* this) {
- if (sub_0806FCB8(super, this->unk_80, this->unk_82, 4)) {
+ if (EntityWithinDistance(super, this->unk_80, this->unk_82, 4)) {
super->subAction = 1;
sub_08048178(this, sub_08048158(this->unk_70));
sub_08047D88(this);
@@ -367,7 +367,7 @@ void sub_08046D98(GyorgMaleEntity* this) {
}
void sub_08046E0C(GyorgMaleEntity* this) {
- if (sub_0806FCB8(super, this->unk_80, this->unk_82, 4)) {
+ if (EntityWithinDistance(super, this->unk_80, this->unk_82, 4)) {
super->subAction = 3;
this->unk_76 = super->direction << 8;
sub_08047D88(this);
@@ -468,7 +468,7 @@ void sub_0804702C(GyorgMaleEntity* this) {
}
}
sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8);
- if (sub_0806FCB8(super, this->unk_80, this->unk_82, (super->speed >> 0x10) + 0x10)) {
+ if (EntityWithinDistance(super, this->unk_80, this->unk_82, (super->speed >> 0x10) + 0x10)) {
super->subAction = 2;
this->unk_76 = super->direction << 8;
super->speed = 0x280;
@@ -628,7 +628,7 @@ void sub_080473F0(GyorgMaleEntity* this) {
}
}
sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8);
- if (sub_0806FCB8(super, this->unk_80, this->unk_82, 8)) {
+ if (EntityWithinDistance(super, this->unk_80, this->unk_82, 8)) {
super->subAction = 2;
this->unk_76 = super->direction << 8;
super->speed = 0x180;
@@ -796,7 +796,7 @@ void sub_080477F0(GyorgMaleEntity* this) {
}
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
sub_08047E48(this);
- if (!sub_0806FCB8(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
+ if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
super->action = 2;
super->subAction = 0;
super->spriteOrientation.flipY = 2;
@@ -804,11 +804,11 @@ void sub_080477F0(GyorgMaleEntity* this) {
super->direction = super->animationState;
return;
}
- if (!sub_0806FCB8(super, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, 0x100)) {
+ if (!EntityWithinDistance(super, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, 0x100)) {
super->spriteOrientation.flipY = 3;
super->spriteRendering.b3 = 3;
}
- if (sub_0806FCB8(super, this->unk_80, this->unk_82, 4)) {
+ if (EntityWithinDistance(super, this->unk_80, this->unk_82, 4)) {
super->subAction = 2;
this->unk_76 = super->animationState << 8;
this->unk_74 = gUnk_080D1BF0[Random() & 1];
@@ -861,7 +861,7 @@ void sub_08047978(GyorgMaleEntity* this) {
tmp->parent = super;
}
}
- if (!sub_0806FCB8(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
+ if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
super->action = 2;
super->subAction = 0;
super->spriteOrientation.flipY = 2;
@@ -902,7 +902,7 @@ void sub_08047B08(GyorgMaleEntity* this) {
super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
super->speed = 0x200;
sub_08047E58(this);
- if (!sub_0806FCB8(super, this->unk_80, this->unk_82, 4))
+ if (!EntityWithinDistance(super, this->unk_80, this->unk_82, 4))
return;
if (super->type == 0) {
super->action = 7;
@@ -986,7 +986,7 @@ void sub_08047BF0(GyorgMaleEntity* this) {
}
}
}
- sub_0805EC9C(this, 0xAA, 0xAA, this->unk_78);
+ sub_0805EC9C(super, 0xAA, 0xAA, this->unk_78);
}
void sub_08047D24(GyorgMaleEntity* this) {
@@ -1005,7 +1005,7 @@ void sub_08047D24(GyorgMaleEntity* this) {
} else {
sub_08047E58(this);
}
- sub_0805EC9C(this, this->unk_7e, this->unk_7e, this->unk_78);
+ sub_0805EC9C(super, this->unk_7e, this->unk_7e, this->unk_78);
}
}
@@ -1019,7 +1019,7 @@ void sub_08047D88(GyorgMaleEntity* this) {
return;
if (super->animIndex == 1)
return;
- if (!sub_0806FCB8(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x20))
+ if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x20))
return;
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.z.HALF.HI != 0)
@@ -1033,7 +1033,7 @@ void sub_08047DF0(GyorgMaleEntity* this, u32 unk1) {
sub_08047EA4(this, unk1);
oldX = super->x.HALF.HI;
oldY = super->y.HALF.HI;
- sub_0806F62C(super, super->speed, super->direction);
+ LinearMoveAngle(super, super->speed, super->direction);
if (this->unk_7c & 1) {
if (sub_08079F8C()) {
gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX;
@@ -1051,7 +1051,7 @@ void sub_08047E58(GyorgMaleEntity* this) {
u32 oldX, oldY;
oldX = super->x.HALF.HI;
oldY = super->y.HALF.HI;
- sub_0806F62C(super, super->speed, super->direction);
+ LinearMoveAngle(super, super->speed, super->direction);
if (this->unk_7c & 1) {
if (sub_08079F8C()) {
gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX;
@@ -1149,7 +1149,7 @@ void sub_08048004(GyorgMaleEntity* this) {
} else {
u32 b = super->spriteRendering.b3;
if (b != 3) {
- if (sub_0806FCB8(&gPlayerEntity, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
+ if (EntityWithinDistance(&gPlayerEntity, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
if (!(this->unk_7c & 2)) {
u32 tmp = sub_080045DA(gPlayerEntity.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.y.HALF.HI - super->y.HALF.HI);
diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c
index 3187c340..be7f9dad 100644
--- a/src/enemy/helmasaur.c
+++ b/src/enemy/helmasaur.c
@@ -95,7 +95,7 @@ void sub_0802BCA8(Entity* this) {
this->action = 7;
this->actionDelay = 0x5a;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->hitType = 0x19;
this->field_0x3a = this->field_0x3a & 0xfb;
this->field_0x1c = 0x12;
@@ -222,7 +222,7 @@ void sub_0802BEBC(Entity* this) {
this->direction ^= 0x10;
sub_080AEFE0(this);
this->direction ^= 0x10;
- if (!sub_080044EC(this, 0x2000)) {
+ if (!sub_080044EC(this, Q_16_16(0.125))) {
sub_0802C1C0(this);
}
}
@@ -234,7 +234,7 @@ void sub_0802BEEC(Entity* this) {
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 4);
}
- } else if (!GravityUpdate(this, 0x1c00)) {
+ } else if (!GravityUpdate(this, Q_16_16(0.109375))) {
this->action = 8;
this->actionDelay = 30;
this->speed = 0x120;
@@ -356,7 +356,7 @@ void sub_0802C18C(Entity* this) {
if ((this->field_0x78.HALF.LO & 7) == 0) {
Entity* ent = CreateObject(SPECIAL_FX, 0x11, 0x40);
if (ent) {
- PositionRelative(this, ent, 0, 0x10000);
+ PositionRelative(this, ent, 0, Q_16_16(1.0));
}
}
}
@@ -374,8 +374,8 @@ void sub_0802C1CC(Entity* this) {
void sub_0802C218(Entity* this) {
this->action = 6;
- this->speed = 0xe0;
- this->zVelocity = 0x18000;
+ this->speed = Q_8_8(0.875);
+ this->zVelocity = Q_16_16(1.5);
}
// clang-format off
diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c
index 3e1a0679..78349fbb 100644
--- a/src/enemy/keaton.c
+++ b/src/enemy/keaton.c
@@ -229,7 +229,7 @@ void sub_08032794(Entity* this) {
target = CreateFx(this, FX_DASH, 0x40);
if (target != NULL) {
temp = &gUnk_080CE810[this->animationState * 2];
- PositionRelative(this, target, temp[0] << 0x10, temp[1] << 0x10);
+ PositionRelative(this, target, Q_16_16(temp[0]), Q_16_16(temp[1]));
}
}
diff --git a/src/enemy/keese.c b/src/enemy/keese.c
index 9eb4ecbb..1d276078 100644
--- a/src/enemy/keese.c
+++ b/src/enemy/keese.c
@@ -98,7 +98,7 @@ void Keese_Sleep(Entity* this) {
if (this->actionDelay != 0) {
this->actionDelay--;
} else {
- if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))
+ if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))
Keese_StartFly(this);
}
}
@@ -116,7 +116,7 @@ void sub_08021F24(Entity* this) {
this->actionDelay = gKeeseRestDurations[Random() & 0xf];
InitializeAnimation(this, KeeseAnimation_Rest);
} else if (!this->field_0x7a.HWORD &&
- !(sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))) {
+ !(EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))) {
this->action = 3;
this->actionDelay = 30;
InitializeAnimation(this, KeeseAnimation_Rest);
diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c
index 25dd93ea..d201bf87 100644
--- a/src/enemy/lakitu.c
+++ b/src/enemy/lakitu.c
@@ -59,7 +59,7 @@ void Lakitu_DoAction(Entity* this) {
void sub_0803C784(Entity* this) {
if ((this->bitfield & 0x7f) == 0x1d) {
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
sub_0803CBAC(this);
} else {
@@ -242,7 +242,7 @@ void Lakitu_Cloudless(Entity* this) {
}
bool32 sub_0803CA4C(Entity* this) {
- if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) {
+ if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) {
if (EntityInRectRadius(this, &gPlayerEntity, 0x70, 0x50)) {
return 1;
}
@@ -267,7 +267,7 @@ void sub_0803CA84(Entity* this, u32 unkParameter) {
}
void sub_0803CAD0(Entity* this) {
- if (sub_0806FCB8(this, this->field_0x74.HWORD, this->field_0x76.HWORD, 1) == 0) {
+ if (EntityWithinDistance(this, this->field_0x74.HWORD, this->field_0x76.HWORD, 1) == 0) {
this->direction =
sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74.HWORD, this->field_0x76.HWORD);
@@ -316,9 +316,9 @@ void Lakitu_SpawnLightning(Entity* this) {
lightning->direction = this->field_0x78.HALF.LO;
- PositionRelative(this, lightning, offset->x << 16, offset->y << 16);
+ PositionRelative(this, lightning, Q_16_16(offset->x), Q_16_16(offset->y));
- EnqueueSFX(0x193);
+ EnqueueSFX(SFX_193);
}
void sub_0803CBAC(Entity* this) {
@@ -326,7 +326,7 @@ void sub_0803CBAC(Entity* this) {
cloud = this->child;
if (cloud != NULL) {
- cloud->flags |= 0x80;
+ cloud->flags |= ENT_COLLIDE;
cloud->hitType = 0x43;
}
@@ -346,6 +346,8 @@ void sub_0803CC08(Entity* this) {
Entity* cloud;
Entity* fx;
+ const s32 diff = Q_8_8(3.0 / 128.0);
+
cloud = this->child;
if (cloud == NULL) {
return;
@@ -359,32 +361,32 @@ void sub_0803CC08(Entity* this) {
return;
}
- if (!sub_0806FCB8(this, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
+ if (!EntityWithinDistance(this, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
return;
}
fx = CreateFx(this, FX_DEATH, 0);
if (fx != NULL) {
- fx->x.HALF.HI += 6;
- fx->y.HALF.HI += 6;
+ fx->x.HALF.HI += diff;
+ fx->y.HALF.HI += diff;
}
fx = CreateFx(this, FX_DEATH, 0);
if (fx != NULL) {
- fx->x.HALF.HI -= 6;
- fx->y.HALF.HI += 6;
+ fx->x.HALF.HI -= diff;
+ fx->y.HALF.HI += diff;
}
fx = CreateFx(this, FX_DEATH, 0);
if (fx != NULL) {
- fx->x.HALF.HI += 6;
- fx->y.HALF.HI -= 6;
+ fx->x.HALF.HI += diff;
+ fx->y.HALF.HI -= diff;
}
fx = CreateFx(this, FX_DEATH, 0);
if (fx != NULL) {
- fx->x.HALF.HI -= 6;
- fx->y.HALF.HI -= 6;
+ fx->x.HALF.HI -= diff;
+ fx->y.HALF.HI -= diff;
}
this->child = NULL;
diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c
index 3caf7608..3cf330c2 100644
--- a/src/enemy/lakituCloud.c
+++ b/src/enemy/lakituCloud.c
@@ -64,7 +64,7 @@ void sub_0803CD40(Entity* this) {
ModHealth(-2);
- SoundReqClipped(&gPlayerEntity, 122);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
sub_08079D84();
sub_0803CE3C(this);
diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c
index ca5f59e0..20c5f188 100644
--- a/src/enemy/likeLike.c
+++ b/src/enemy/likeLike.c
@@ -193,7 +193,7 @@ void sub_0802805C(Entity* this) {
} else {
ResetPlayer();
gPlayerState.mobility |= 0x80;
- PositionRelative(this, &gPlayerEntity, 0, 0x10000);
+ PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0));
tmp = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
gPlayerEntity.spriteOffsetX = tmp[0];
@@ -205,7 +205,7 @@ void sub_0802805C(Entity* this) {
}
if ((this->actionDelay & 3) == 0) {
- EnqueueSFX(0x104);
+ EnqueueSFX(SFX_104);
}
}
}
@@ -214,8 +214,8 @@ NONMATCH("asm/non_matching/likeLike/sub_0802810C.inc", void sub_0802810C(Entity*
gPlayerState.jump_status = 0x41;
gPlayerState.field_0xa = 0;
gPlayerState.flags &= 0xffffffef;
- gPlayerEntity.flags |= 0x80;
- gPlayerEntity.zVelocity = 0x18000;
+ gPlayerEntity.flags |= ENT_COLLIDE;
+ gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.iframes = -60;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.spritePriority.b1 = this->field_0x82.HALF.HI;
diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c
index a804035b..e68df9fd 100644
--- a/src/enemy/madderpillar.c
+++ b/src/enemy/madderpillar.c
@@ -61,7 +61,7 @@ void sub_080298A4(Entity* this) {
this->hitType = 0x6b;
this->field_0x76.HALF.HI = 0;
ChangeObjPalette(this, 0x7f);
- EnqueueSFX(0xfe);
+ EnqueueSFX(SFX_HIT);
this->child->action = 2;
break;
}
@@ -145,7 +145,7 @@ void sub_08029AA4(Entity* this) {
this->field_0x7a.HWORD = 0x168;
this->field_0x74.HALF.HI = 4;
sub_08029EEC(this);
- EnqueueSFX(0x19d);
+ EnqueueSFX(SFX_19D);
}
}
@@ -159,7 +159,7 @@ void sub_08029AE0(Entity* this) {
this->field_0x74.HALF.HI = 0;
sub_08029EEC(this);
ChangeObjPalette(this, 0x77);
- EnqueueSFX(0x182);
+ EnqueueSFX(SFX_182);
}
}
@@ -221,7 +221,7 @@ void sub_08029C2C(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 4;
ChangeObjPalette(this, 0x7f);
- EnqueueSFX(0x6c);
+ EnqueueSFX(SFX_MENU_CANCEL);
}
}
@@ -275,7 +275,7 @@ void sub_08029D14(Entity* this) {
if (--this->actionDelay == 0) {
InitializeAnimation(this, this->animationState + 0xc);
ChangeObjPalette(this, 0x7f);
- EnqueueSFX(0x6c);
+ EnqueueSFX(SFX_MENU_CANCEL);
}
} else {
GetNextFrame(this);
@@ -284,7 +284,7 @@ void sub_08029D14(Entity* this) {
this->actionDelay = 0x78;
this->hitType = 0x6c;
this->hitbox = &gUnk_080FD298;
- EnqueueSFX(0x6b);
+ EnqueueSFX(SFX_6B);
}
}
}
@@ -454,7 +454,7 @@ void sub_0802A098(Entity* this) {
if (sub_08029F48(this)) {
sub_08029E0C(this);
sub_08029EEC(this);
- EnqueueSFX(0x104);
+ EnqueueSFX(SFX_104);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
@@ -471,7 +471,7 @@ void sub_0802A0F8(Entity* this) {
}
}
} else {
- this->parent->flags &= ~0x80;
+ this->parent->flags &= ~ENT_COLLIDE;
this->parent->health = 0;
this->parent->field_0xf = 0x69;
}
@@ -505,7 +505,7 @@ void sub_0802A18C(Entity* this) {
case 0x1e:
break;
default:
- EnqueueSFX(0x12e);
+ EnqueueSFX(SFX_12E);
break;
}
}
diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c
index e2254ca2..eea86ae3 100644
--- a/src/enemy/mazaalBracelet.c
+++ b/src/enemy/mazaalBracelet.c
@@ -189,7 +189,7 @@ void sub_0803A274(Entity* this) {
pEVar1 = CreateObject(OBJECT_7E, 1, 0);
pEVar1->parent = this;
pEVar1->child = this->child;
- PositionRelative(this->parent, this, 0x100000, 0x200000);
+ PositionRelative(this->parent, this, Q_16_16(16.0), Q_16_16(32.0));
} else {
pEVar1 = CreateEnemy(MAZAAL_HAND, 1);
pEVar1->parent = this;
@@ -201,7 +201,7 @@ void sub_0803A274(Entity* this) {
pEVar1->parent = this;
pEVar1->child = this->child;
this->spriteSettings.flipX = 1;
- PositionRelative(this->parent, this, -0x100000, 0x200000);
+ PositionRelative(this->parent, this, Q_16_16(-16.0), Q_16_16(32.0));
}
if (gRoomTransition.field_0x38 != 0) {
this->action = 3;
@@ -590,8 +590,7 @@ void sub_0803AA00(Entity* this) {
}
}
}
-
-NONMATCH("asm/non_matching/mazaal/sub_0803AA98.inc", void sub_0803AA98(Entity* this)) {
+void sub_0803AA98(Entity* this) {
Entity* temp;
s8* ptr;
u32 index;
@@ -605,7 +604,8 @@ NONMATCH("asm/non_matching/mazaal/sub_0803AA98.inc", void sub_0803AA98(Entity* t
this->action = 0x14;
this->speed = 0x40;
InitializeAnimation(this, 10);
- (*(Entity**)&this->field_0x74)->flags |= 0x80;
+ temp = (*(Entity**)&this->field_0x74);
+ temp->flags |= ENT_COLLIDE;
temp = this->child;
temp->hitType = 0x13;
InitAnimationForceUpdate(temp, 5);
@@ -613,7 +613,6 @@ NONMATCH("asm/non_matching/mazaal/sub_0803AA98.inc", void sub_0803AA98(Entity* t
}
}
}
-END_NONMATCH
void sub_0803AB10(Entity* this) {
s8* ptr;
@@ -755,7 +754,7 @@ void sub_0803ADAC(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 0x16;
this->spriteSettings.draw = 1;
- (*(Entity**)&this->field_0x74)->flags |= 0x80;
+ (*(Entity**)&this->field_0x74)->flags |= ENT_COLLIDE;
InitializeAnimation(this, 0xb);
InitAnimationForceUpdate(this->child, 6);
sub_0803B798();
@@ -918,7 +917,7 @@ void sub_0803B100(Entity* this) {
Entity* temp;
this->action = 0x29;
- this->zVelocity = 0x14000;
+ this->zVelocity = Q_16_16(1.25);
if (this->type == 0) {
this->hitbox = &gUnk_080FD364;
} else {
@@ -975,7 +974,7 @@ void sub_0803B1B8(Entity* this) {
if (temp != (Entity*)0x0) {
temp->actionDelay = 0;
temp->direction = 0x90;
- PositionRelative(this, temp, this->hitbox->offset_x << 0x10, this->hitbox->offset_y << 0x10);
+ PositionRelative(this, temp, Q_16_16(this->hitbox->offset_x), Q_16_16(this->hitbox->offset_y));
}
temp = *(Entity**)&this->field_0x74;
temp->field_0x74.HALF.LO = 0x40;
@@ -1087,7 +1086,7 @@ void sub_0803B480(Entity* this) {
Entity* target;
if (((this->field_0x7c.HALF.HI & 0x1f) == 0) && (target = CreateObject(SMOKE, 1, 0), target != (Entity*)0x0)) {
- PositionRelative(this, target, gUnk_080CFD08[this->type] << 0x10, 0);
+ PositionRelative(this, target, Q_16_16(gUnk_080CFD08[this->type]), 0);
}
if (--this->field_0x7c.HALF.HI == 0) {
sub_0803B6A4(this);
@@ -1105,7 +1104,7 @@ u32 sub_0803B4E4(Entity* this) {
xoff = this->parent->x.HALF.HI + gUnk_080CFD0A[this->type];
yoff = this->parent->y.HALF.HI + 0x10;
- if (sub_0806FCB8(this, xoff, yoff, 2)) {
+ if (EntityWithinDistance(this, xoff, yoff, 2)) {
this->x.HALF.HI = xoff;
this->y.HALF.HI = yoff;
return 1;
@@ -1116,8 +1115,8 @@ u32 sub_0803B4E4(Entity* this) {
}
void sub_0803B538(Entity* this) {
- PositionRelative(this, this->child, 0, -0x10000);
- PositionRelative(this, *(Entity**)&this->field_0x74, 0, -0x20000);
+ PositionRelative(this, this->child, 0, Q_16_16(-1.0));
+ PositionRelative(this, *(Entity**)&this->field_0x74, 0, Q_16_16(-2.0));
}
void sub_0803B55C(Entity* this) {
@@ -1165,7 +1164,8 @@ void sub_0803B5C0(Entity* this) {
}
u32 sub_0803B610(Entity* this) {
- return sub_0806FCB8(this, gPlayerEntity.x.HALF.HI + gUnk_080CFD19[this->type], gPlayerEntity.y.HALF.HI - 0xc, 8);
+ return EntityWithinDistance(this, gPlayerEntity.x.HALF.HI + gUnk_080CFD19[this->type],
+ gPlayerEntity.y.HALF.HI - 0xc, 8);
}
// sub_0803B698 was the tail of this function
@@ -1230,8 +1230,8 @@ void sub_0803B798(void) {
gPlayerState.jump_status = 0x41;
gPlayerState.field_0xa = 0;
gPlayerState.flags &= ~(0xffff0000 | PL_CAPTURED);
- gPlayerEntity.flags |= 0x80;
- gPlayerEntity.zVelocity = 0x18000;
+ gPlayerEntity.flags |= ENT_COLLIDE;
+ gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.z.HALF.HI = -10;
gPlayerEntity.direction = 0x10;
gPlayerEntity.animationState = 4;
@@ -1244,7 +1244,7 @@ void sub_0803B798(void) {
void sub_0803B804(Entity* this) {
gPlayerEntity.iframes = 30;
ModHealth(-4);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
}
void sub_0803B824(Entity* this) {
@@ -1263,7 +1263,7 @@ u32 sub_0803B870(Entity* this) {
this->action = 0x18;
this->actionDelay = 0x44;
this->spriteSettings.draw = 0;
- gPlayerEntity.flags = gPlayerEntity.flags & 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.iframes = -0x10;
sub_0803B824(this);
entity->hitType = 0x13;
diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c
index af37d745..55e4923b 100644
--- a/src/enemy/mazaalHead.c
+++ b/src/enemy/mazaalHead.c
@@ -221,7 +221,7 @@ void sub_08033FFC(Entity* this) {
}
break;
default:
- if (((*(Entity**)&this->field_0x74)->flags & 0x80) != 0) {
+ if (((*(Entity**)&this->field_0x74)->flags & ENT_COLLIDE) != 0) {
gRoomControls.camera_target = &gPlayerEntity;
sub_08034420(this);
gPlayerState.controlMode = 1;
@@ -659,7 +659,7 @@ u32 sub_080348A4(Entity* this, Entity* hand_, u32 unk) {
break;
case 7:
hand_->action = 0x1b;
- hand_->flags = hand_->flags & 0x7f;
+ hand_->flags = hand_->flags & ~ENT_COLLIDE;
InitializeAnimation(hand_, 5);
break;
case 8:
@@ -741,7 +741,7 @@ void sub_08034A84(Entity* this) {
}
void sub_08034AC4(Entity* this) {
- PositionRelative(this->parent, this, 0, 0x10000);
+ PositionRelative(this->parent, this, 0, Q_16_16(1.0));
gUnk_080CED74[this->action](this);
}
@@ -782,7 +782,7 @@ void sub_08034B38(Entity* this) {
target->direction = this->actionDelay + 0x58;
}
ptr = &gUnk_080CED84[target->type * 2];
- PositionRelative(this, target, *(ptr++) << 0x10, *ptr << 0x10);
+ PositionRelative(this, target, Q_16_16(*(ptr++)), Q_16_16(*ptr));
}
}
}
diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c
index b9a64caf..fd6f54e2 100644
--- a/src/enemy/miniFireballGuy.c
+++ b/src/enemy/miniFireballGuy.c
@@ -57,7 +57,7 @@ void sub_08045654(Entity* this) {
void sub_08045678(Entity* this) {
- this->zVelocity = 0x1c000;
+ this->zVelocity = Q_16_16(1.75);
if (this->actionDelay != 0) {
this->actionDelay--;
} else {
diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c
index cb055f0b..695271ae 100644
--- a/src/enemy/moldworm.c
+++ b/src/enemy/moldworm.c
@@ -85,9 +85,9 @@ void sub_080230E4(Entity* this) {
if (this->health == 0 && this->field_0x7c.BYTES.byte3 == 0 && this->action == 7) {
CopyPosition(this, &gPlayerEntity);
- gPlayerEntity.flags = gPlayerEntity.flags | 0x80;
+ gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.spriteSettings.draw = 1;
- gPlayerEntity.zVelocity = 0x18000;
+ gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.direction = 0xff;
gPlayerEntity.iframes = -0x14;
gPlayerState.jump_status = 0x41;
@@ -270,7 +270,7 @@ void sub_0802351C(Entity* this) {
if (this->type2 == 0) {
gPlayerEntity.animationState = this->animationState & 7;
gPlayerState.flags |= PL_MOLDWORM_CAPTURED;
- PositionRelative(this, &gPlayerEntity, 0, gUnk_080CBC90[this->animationState & 7] << 0x10);
+ PositionRelative(this, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[this->animationState & 7]));
gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7];
}
} else {
@@ -411,7 +411,7 @@ void sub_08023894(Entity* this) {
gPlayerEntity.animationState = gPlayerEntity.direction >> 2;
gPlayerEntity.iframes = 12;
ModHealth(-0x10);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
}
}
}
diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c
index b1aedfc6..f94b4743 100644
--- a/src/enemy/octorok.c
+++ b/src/enemy/octorok.c
@@ -8,8 +8,6 @@
#include "enemy.h"
#include "functions.h"
-extern Entity* sub_08049DF4(u32);
-
void Octorok_Pause(Entity*);
bool32 Octorok_FacesPlayer(Entity*);
void Octorok_Turn(Entity*);
@@ -139,7 +137,7 @@ void Octorok_ShootNut(Entity* this) {
ent->y.HALF.HI += off[1];
ent->z.HALF.HI = -3;
this->frame &= 0xfe;
- EnqueueSFX(0x18d);
+ EnqueueSFX(SFX_18D);
}
}
diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c
index a0112901..bdbd9144 100644
--- a/src/enemy/octorokBoss.c
+++ b/src/enemy/octorokBoss.c
@@ -13,7 +13,6 @@
extern void sub_08078AC0(u32, u32, u32);
extern u32 GetRandomByWeight(const u8*);
-extern u32 sub_0806FC80(Entity*, Entity*, s32);
extern void sub_080792BC(s32, u32, u32);
enum OctorokRotation { ROTATION_CW, ROTATION_CCW, NO_ROTATION = 0xff };
@@ -618,7 +617,7 @@ void OctorokBoss_Action1(Entity* this) {
this->field_0x74.HWORD += 4;
}
}
- ResolveEntityBelow(this->parent, this);
+ SortEntityBelow(this->parent, this);
if (((GET_HELPER(this)->field_0x2 != 0) || (this->parent->action == INTRO)) ||
(1 < (u8)(this->parent->subAction - 3))) {
if ((s8)this->field_0xf < 0) {
@@ -650,9 +649,9 @@ void OctorokBoss_Action1(Entity* this) {
if ((GET_HELPER(this)->tailCount - 2) < this->type2) {
DeleteThisEntity();
}
- ResolveEntityOnTop(this->parent, this);
+ SortEntityAbove(this->parent, this);
if (GET_HELPER(this)->tailCount - 2 == this->type2) {
- ResolveEntityOnTop(this->parent, this);
+ SortEntityAbove(this->parent, this);
radius = 0x10000 / this->parent->field_0x74.HWORD;
radius = radius << 0xd >> 0x8;
angle = -this->parent->field_0x7a.HALF.HI;
@@ -694,7 +693,7 @@ void OctorokBoss_Action1(Entity* this) {
if (this->health == 1) {
this->health = 0;
} else {
- ResolveEntityBelow(this->parent, this);
+ SortEntityBelow(this->parent, this);
if ((this->parent->subAction != 4) && (this->health != 1)) {
if (GET_TIMER(this) > 0x1c) {
GET_TIMER(this)--;
@@ -833,7 +832,7 @@ void OctorokBoss_Action1_Attack(Entity* this) {
if (this->field_0x80.HALF.LO != 0) {
gPlayerEntity.spriteSettings.draw = 0;
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.collisionLayer = 2;
sub_08078B48();
sub_08077B20();
@@ -940,7 +939,7 @@ void OctorokBoss_ExecuteAttackVacuum(Entity* this) {
if (sub_0806FC80(this, &gPlayerEntity, 0xf0) != 0) {
if ((gPlayerState.flags & PL_FROZEN) == 0) {
if ((gPlayerEntity.flags & PL_MINISH) != 0) {
- sub_0806F62C(&gPlayerEntity, 0x280, -GET_ANGLE_HI(this));
+ LinearMoveAngle(&gPlayerEntity, 0x280, -GET_ANGLE_HI(this));
if (sub_0806FC80(this, &gPlayerEntity, 0x48) != 0) {
this->field_0x80.HALF.LO = 1;
GET_TIMER(this) = 2;
@@ -973,7 +972,7 @@ void OctorokBoss_ExecuteAttackVacuum(Entity* this) {
GET_ANGULAR_VEL(this) = 0x100;
GET_HELPER(this)->mouthObject->field_0x78.HALF.HI++;
gPlayerEntity.spriteSettings.draw = 1;
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.collisionLayer = 1;
sub_080792BC(0x400, (u32)(-(GET_ANGLE_HI(this) + 0x80) * 0x1000000) >> 0x1b, 0x30);
OctorokBoss_SetAttackTimer(this);
@@ -1113,7 +1112,7 @@ void OctorokBoss_Burning_SubAction2(Entity* this) {
void sub_080368D8(Entity* this) {
if (this->field_0x80.HALF.LO != 0) {
gPlayerEntity.spriteSettings.draw = 1;
- gPlayerEntity.flags |= 0x80;
+ gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.collisionLayer = 1;
}
this->field_0x76.HWORD = 0xa0;
diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c
index 2f08e47a..6389b179 100644
--- a/src/enemy/peahat.c
+++ b/src/enemy/peahat.c
@@ -265,7 +265,7 @@ void Peahat_RepairPropeller(Entity* this) {
return;
this->action = 9;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->direction = Random() & 0x1f;
sub_0804AA1C(this);
this->animationState = PeahatAnimation_RepairPropeller;
@@ -291,7 +291,7 @@ void Peahat_Hop(Entity* this) {
if (--this->actionDelay == 0) {
if (this->frame & 0x80) {
this->action = 9;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->animationState = PeahatAnimation_NewPropeller;
InitializeAnimation(this, this->animationState);
} else {
diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c
index 7d5db56e..3de6ecab 100644
--- a/src/enemy/pesto.c
+++ b/src/enemy/pesto.c
@@ -11,12 +11,6 @@
#include "functions.h"
#include "save.h"
-extern u32 sub_080002E0(u16, u32);
-extern void SoundReqClipped(Entity*, u32);
-extern u32 sub_08049F1C(Entity*, Entity*, u32);
-extern u32 PlayerInRange(Entity*, u32, u32);
-extern void sub_080AEFB4(Entity*);
-
void sub_080249F4(Entity*);
void sub_08024940(Entity*);
void sub_080249DC(Entity*);
@@ -188,7 +182,7 @@ void sub_080241C0(Entity* this) {
switch (this->field_0x80.HALF.LO) {
case 0:
if (PlayerInRange(this, 3, (gPlayerState.hurtBlinkSpeed != 0) ? 0xa0 : 0x40) && sub_08049FDC(this, 3) &&
- gPlayerEntity.action != 0x1e) {
+ gPlayerEntity.action != PLAYER_USEENTRANCE) {
this->field_0x80.HALF.LO++;
this->speed = 0;
sub_08024A14(this, 3, 10);
@@ -398,7 +392,7 @@ void sub_080244E8(Entity* this) {
this->flags2 &= 0xfc;
sub_080249DC(this);
this->cutsceneBeh.HALF.HI = gPlayerEntity.spritePriority.b1;
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerState.flags |= PL_DISABLE_ITEMS;
gPlayerState.field_0xa |= 0x80;
if (gPlayerState.swim_state != 0) {
@@ -817,7 +811,7 @@ void sub_08024E4C(Entity* this) {
gPlayerState.field_0x38 = 0x14;
gPlayerState.field_0x39 = 1;
*(u8*)&gPlayerState.field_0x3a = 0;
- PositionRelative(this, player, 0, 0x10000);
+ PositionRelative(this, player, 0, Q_16_16(1.0));
player->spriteOffsetY = 0x1a;
player->animationState = 4;
player->spritePriority.b1 = 0;
@@ -825,7 +819,7 @@ void sub_08024E4C(Entity* this) {
this->field_0x86.HALF.HI++;
player->iframes = 8;
ModHealth(-2);
- SoundReqClipped(player, 0x7a);
+ SoundReqClipped(player, SFX_PLY_VO6);
}
}
}
@@ -835,7 +829,7 @@ void sub_08024F50(Entity* this) {
gPlayerState.field_0xa = 0;
gPlayerState.flags &= ~PL_DISABLE_ITEMS;
CopyPosition(this, &gPlayerEntity);
- gPlayerEntity.action = 1;
+ gPlayerEntity.action = PLAYER_NORMAL;
COLLISION_ON(&gPlayerEntity);
gPlayerEntity.iframes = -0x3c;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c
index b42e5b2f..f444b65a 100644
--- a/src/enemy/puffstool.c
+++ b/src/enemy/puffstool.c
@@ -9,12 +9,6 @@
#include "object.h"
#include "functions.h"
-extern u32 sub_080002E0(u32, u32);
-extern u32 sub_080002C8(u16, u8);
-extern u8 sub_080002D4(u32, u32, u32);
-extern void sub_0804AA1C(Entity*);
-extern Entity* sub_08049DF4(u32);
-
extern u8 gUnk_080B37A0[];
extern u8 gUnk_080B3E80[];
@@ -95,7 +89,7 @@ void sub_08025020(Entity* this) {
ent->spritePriority.b0 = 3;
CopyPosition(this, ent);
}
- EnqueueSFX(0x186);
+ EnqueueSFX(SFX_186);
}
break;
}
@@ -204,7 +198,7 @@ void sub_080252E0(Entity* this) {
this->action = 3;
this->actionDelay = 0x1e;
this->field_0xf = 0;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
InitializeAnimation(this, 1);
}
}
@@ -216,8 +210,8 @@ void sub_0802538C(Entity* this) {
if (this->frame == 0) {
GetNextFrame(this);
} else {
- GravityUpdate(this, 0x2000);
- if (this->zVelocity < 0x2000) {
+ GravityUpdate(this, Q_16_16(0.125));
+ if (this->zVelocity < Q_16_16(0.125)) {
this->action = 4;
InitializeAnimation(this, 2);
}
@@ -246,7 +240,7 @@ void sub_0802541C(Entity* this) {
if (this->frame & 0x80) {
this->action = 3;
this->field_0xf = 1;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2);
InitializeAnimation(this, 1);
}
}
@@ -263,7 +257,7 @@ void sub_0802544C(Entity* this) {
}
void sub_0802547C(Entity* this) {
- GravityUpdate(this, 0x2000);
+ GravityUpdate(this, Q_16_16(0.125));
GetNextFrame(this);
if ((this->actionDelay & 7) == 0) {
sub_08025BD4(this);
@@ -275,7 +269,7 @@ void sub_0802547C(Entity* this) {
}
void sub_080254B4(Entity* this) {
- GravityUpdate(this, 0x2000);
+ GravityUpdate(this, Q_16_16(0.125));
if (this->frame & 0x80) {
if (this->z.HALF.HI == 0) {
if (this->cutsceneBeh.HWORD == 0) {
@@ -559,7 +553,7 @@ void sub_08025B18(Entity* this) {
ent = CreateObject(OBJECT_21, 2, 0);
if (ent) {
- PositionRelative(this, ent, offset[0] * 0x10000, offset[1] * 0x10000);
+ PositionRelative(this, ent, Q_16_16(offset[0]), Q_16_16(offset[1]));
ent->x.HALF.HI &= -0x10;
ent->x.HALF.HI += 8;
ent->y.HALF.HI &= -0x10;
@@ -573,8 +567,8 @@ void sub_08025BD4(Entity* this) {
if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) {
Entity* ent = CreateObject(OBJECT_21, 0, 0);
if (ent) {
- PositionRelative(this, ent, gUnk_080CC0BA[this->animationState * 2 + 0] * 0x10000,
- gUnk_080CC0BA[this->animationState * 2 + 1] * 0x10000);
+ PositionRelative(this, ent, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 0]),
+ Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 1]));
ent->z.HALF.HI = -10;
}
}
diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c
index 9a86c115..4b8e07b0 100644
--- a/src/enemy/rollobite.c
+++ b/src/enemy/rollobite.c
@@ -37,7 +37,7 @@ void Rollobite_OnTick(Entity* this) {
void sub_08020668(Entity* this) {
if (this->hitType == 34 && this->health != 0xff) {
this->action = 4;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->direction = 0xff;
this->health = 0xff;
this->hitType = 35;
@@ -107,7 +107,7 @@ void sub_080207A8(Entity* this) {
this->spritePriority.b0 = 4;
this->field_0x3a &= 0xfb;
this->direction ^= 0x10;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->speed = 0x80;
InitializeAnimation(this, this->animationState + 0x10);
}
@@ -190,7 +190,7 @@ void Rollobite_RolledUp(Entity* this) {
sub_08078930(this);
} else {
if (unk == 1)
- EnqueueSFX(260);
+ EnqueueSFX(SFX_104);
if ((this->direction & 0x80) == 0)
sub_080AEFE0(this);
@@ -267,7 +267,7 @@ bool32 Rollobite_TryToHoleUp(Entity* this) {
this->x.HALF.HI += 8;
this->y.HALF.HI &= 0xfff0;
this->y.HALF.HI += 13;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
InitializeAnimation(this, this->animationState + 0x14);
SetTile(0x4034, tile, this->collisionLayer);
return TRUE;
diff --git a/src/enemy/rope.c b/src/enemy/rope.c
index d2ca5b18..05e1c85e 100644
--- a/src/enemy/rope.c
+++ b/src/enemy/rope.c
@@ -95,7 +95,7 @@ void sub_08031480(Entity* this) {
this->field_0xf = 0xf;
this->spriteSettings.draw = 1;
UpdateSpriteForCollisionLayer(this);
- EnqueueSFX(0x84);
+ EnqueueSFX(SFX_WATER_SPLASH);
}
}
}
diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c
index 581c92d3..f31229aa 100644
--- a/src/enemy/ropeGolden.c
+++ b/src/enemy/ropeGolden.c
@@ -63,7 +63,7 @@ void sub_0803827C(Entity* this) {
this->field_0xf--;
} else {
if ((sub_0804A044(this, &gPlayerEntity, 0x8) != 0xff) ||
- (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x24) != 0)) {
+ (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x24) != 0)) {
sub_080383E4(this);
return;
}
diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c
index d2393187..40964971 100644
--- a/src/enemy/rupeeLike.c
+++ b/src/enemy/rupeeLike.c
@@ -71,7 +71,7 @@ void sub_08029318(Entity* this) {
this->field_0x82.HALF.HI = 0x41;
this->flags2 &= 0xfc;
this->field_0x80.HALF.LO = gPlayerEntity.spritePriority.b1;
- EnqueueSFX(0x104);
+ EnqueueSFX(SFX_104);
} else {
if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c);
@@ -171,7 +171,7 @@ void sub_0802953C(Entity* this) {
} else {
ResetPlayer();
gPlayerState.mobility |= 0x80;
- PositionRelative(this, &gPlayerEntity, 0, 0x10000);
+ PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
gPlayerEntity.spriteOffsetX = pbVar3[0];
gPlayerEntity.spriteOffsetY = pbVar3[1] - 1;
@@ -239,8 +239,8 @@ void sub_080296C8(Entity* this) {
void sub_080296D8(Entity* this) {
gPlayerState.jump_status = 0x41;
gPlayerState.flags &= ~PL_CAPTURED;
- gPlayerEntity.flags |= 0x80;
- gPlayerEntity.zVelocity = 0x18000;
+ gPlayerEntity.flags |= ENT_COLLIDE;
+ gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.iframes = 0xa6;
gPlayerEntity.z.HALF.HI = -2;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c
index 0db62349..77af113a 100644
--- a/src/enemy/sensorBladeTrap.c
+++ b/src/enemy/sensorBladeTrap.c
@@ -95,7 +95,7 @@ void sub_0802BB10(Entity* this) {
this->action = 3;
this->speed = 0xc0;
this->direction = this->direction ^ 0x10;
- EnqueueSFX(0x74);
+ EnqueueSFX(SFX_METAL_CLINK);
}
bool32 sub_0802BB2C(Entity* this, u32 param_2) {
diff --git a/src/enemy/slime.c b/src/enemy/slime.c
index e95bc8c7..0ef493dd 100644
--- a/src/enemy/slime.c
+++ b/src/enemy/slime.c
@@ -16,7 +16,6 @@ void sub_08044FF8(Entity*);
void sub_08045178(Entity*, Entity*, int, int);
extern void sub_0804A4E4(Entity*, Entity*);
-extern u32 sub_080002CC(Entity*, s32, s32);
extern void (*const gUnk_080D16BC[])(Entity*);
extern void (*const gUnk_080D16A4[])(Entity*);
diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c
index 308d914f..7d6b68e9 100644
--- a/src/enemy/sluggula.c
+++ b/src/enemy/sluggula.c
@@ -121,13 +121,13 @@ void sub_08023CE0(Entity* this) {
case 2:
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
- EnqueueSFX(0x12d);
+ EnqueueSFX(SFX_12D);
InitializeAnimation(this, 4);
}
- } else if (!GravityUpdate(this, 0x1800)) {
+ } else if (!GravityUpdate(this, Q_8_8(24))) {
this->action = 3;
this->spriteSettings.draw = 1;
- EnqueueSFX(0x84);
+ EnqueueSFX(SFX_WATER_SPLASH);
UpdateSpriteForCollisionLayer(this);
}
break;
@@ -169,7 +169,7 @@ void sub_08023E54(Entity* this) {
ent = CreateEnemy(SLUGGULA, 2);
if (ent) {
const s8* ptr = &gUnk_080CBDF7[this->animationState * 2];
- PositionRelative(this, ent, ptr[0] << 0x10, ptr[1] << 0x10);
+ PositionRelative(this, ent, Q_16_16(ptr[0]), Q_16_16(ptr[1]));
}
}
}
diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c
index 91475342..8490f9d6 100644
--- a/src/enemy/spearMoblin.c
+++ b/src/enemy/spearMoblin.c
@@ -8,9 +8,6 @@
#include "enemy.h"
#include "functions.h"
-extern bool32 sub_0806FC80(Entity*, Entity*, u32);
-extern Entity* sub_08049DF4(u32);
-
void sub_08028604(Entity*);
void sub_08028754(Entity*);
void sub_08028784(Entity*);
@@ -171,7 +168,7 @@ void sub_08028488(Entity* this) {
this->action = 4;
this->speed = 0x180;
this->direction = sub_08049F84(this, 1);
- EnqueueSFX(0x11e);
+ EnqueueSFX(SFX_EM_MOBLIN_SPEAR);
break;
case 2:
this->action = 2;
@@ -228,7 +225,7 @@ void sub_08028528(Entity* this) {
}
if ((this->actionDelay & 7) == 0) {
- EnqueueSFX(0xf0);
+ EnqueueSFX(SFX_F0);
CreateFx(this, FX_DEATH, 0x40);
}
diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c
index a6fa4ae6..fa3d70b4 100644
--- a/src/enemy/spikedBeetle.c
+++ b/src/enemy/spikedBeetle.c
@@ -54,7 +54,7 @@ void sub_0802B628(Entity* this) {
case 0x1d:
if (this->action < 6) {
this->action = 6;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->speed = 0xc0;
this->direction = this->knockbackDirection;
this->knockbackDuration = 0;
@@ -159,7 +159,7 @@ void sub_0802B8B0(Entity* this) {
this->actionDelay = 0x96;
/* fallthrough */
case 1:
- EnqueueSFX(299);
+ EnqueueSFX(SFX_12B);
break;
}
}
@@ -171,11 +171,11 @@ void sub_0802B8E0(Entity* this) {
}
} else {
this->action = 8;
- this->zVelocity = 0x10000;
+ this->zVelocity = Q_16_16(1.0);
this->speed = 0x60;
this->hitType = 99;
InitializeAnimation(this, this->animationState);
- EnqueueSFX(299);
+ EnqueueSFX(SFX_12B);
}
}
diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c
new file mode 100644
index 00000000..81a45577
--- /dev/null
+++ b/src/enemy/spinyBeetle.c
@@ -0,0 +1,394 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "enemy.h"
+#include "functions.h"
+#include "object.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0xc];
+ u16 tile;
+ u16 tileIndex;
+ u8 unk_78;
+ u8 unk_79;
+ u8 unk_7a;
+ u8 unk_7b;
+ s32 unk_7c;
+ s32 unk_80;
+ u16 unk_84;
+} SpinyBeetleEntity;
+
+void (*const gUnk_080CEBEC[])(Entity*);
+void (*const gUnk_080CEC04[])(SpinyBeetleEntity*);
+const s8 gUnk_080CEC1C[];
+
+extern void sub_08033E1C(SpinyBeetleEntity*);
+extern void sub_08033D78(SpinyBeetleEntity*);
+extern u32 sub_08033DF0(SpinyBeetleEntity*);
+extern void SpinyBeetle_SetHitType(SpinyBeetleEntity*);
+extern void sub_0804AA30(Entity*, EntityActionArray);
+extern void sub_0807B9B8(s32, s32, s32);
+extern u32 sub_0804A024(Entity*, u32, u32);
+
+void SpinyBeetle(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CEBEC);
+ SetChildOffset(this, 0, 1, -0x10);
+}
+
+void sub_080337BC(SpinyBeetleEntity* this) {
+ gUnk_080CEC04[super->action](this);
+}
+
+void sub_080337D4(SpinyBeetleEntity* this) {
+ if (super->field_0x43) {
+ sub_0804A9FC(super, 0x1c);
+ }
+
+ sub_0804AA30(super, gUnk_080CEBEC);
+ if (super->bitfield & 0x80) {
+ if (super->iframes > 0 && super->child) {
+ sub_08033E1C(this);
+ }
+
+ if ((super->bitfield & 0x3f) == 0x14 && super->action != 5) {
+ super->action = 3;
+ super->actionDelay = 0x5a;
+ super->field_0xf = 0x10;
+ super->spritePriority.b1 = 1;
+ super->direction = DirectionRoundUp(sub_08049F84(super, 1));
+ sub_08033D78(this);
+ InitializeAnimation(super, 3);
+ }
+ }
+}
+
+void nullsub_159(SpinyBeetleEntity* this) {
+}
+
+void sub_08033870(SpinyBeetleEntity* this) {
+ sub_08001242(super);
+
+ if (super->action != 5) {
+ if (sub_08033DF0(this)) {
+ sub_08033E1C(this);
+ }
+ }
+}
+
+void SpinyBeetle_Init(SpinyBeetleEntity* this) {
+ Entity* obj;
+ super->action = 1;
+ super->actionDelay = 0;
+ super->field_0xf = 0;
+ this->unk_7c = (super->x.WORD & 0xfff00000) | 0x80000;
+ this->unk_80 = (super->y.WORD & 0xfff00000) | 0x80000;
+ super->x.WORD = this->unk_7c;
+ super->y.WORD = this->unk_80;
+ this->unk_79 = 0;
+ this->unk_7a = 0;
+ this->unk_78 = 0;
+ this->unk_7b = 0;
+ this->tile = COORD_TO_TILE(super);
+ this->tileIndex = GetTileIndex(this->tile, super->collisionLayer);
+ SetTile(0x4022, this->tile, super->collisionLayer);
+ obj = CreateObject(OBJECT_ON_BEETLE, super->type, 0);
+
+ if (obj == NULL) {
+ DeleteThisEntity();
+ }
+
+ CopyPosition(super, obj);
+ super->child = obj;
+ obj->parent = super;
+
+ if (super->type == 1) {
+ SpinyBeetle_SetHitType(this);
+ }
+
+ InitializeAnimation(super, 0);
+}
+
+void sub_08033958(SpinyBeetleEntity* this) {
+ u32 direction;
+ if (sub_08033DF0(this)) {
+ sub_08033E1C(this);
+ sub_0807B9B8(this->tileIndex, this->tile, super->collisionLayer);
+ return;
+ }
+
+ if (this->unk_7b) {
+ this->unk_7b--;
+ return;
+ }
+
+ super->x.WORD = this->unk_7c;
+ super->y.WORD = this->unk_80;
+ direction = sub_0804A024(super, 1, 0x10);
+ switch (direction) {
+ case 0xff:
+ return;
+ case 0:
+ if (this->unk_78 == 0)
+ return;
+ if (super->y.HALF.HI - gPlayerEntity.y.HALF.HI > 0x30)
+ return;
+ break;
+ case 0x10:
+ if (gPlayerEntity.y.HALF.HI - super->y.HALF.HI > 0x30)
+ return;
+ break;
+ case 8:
+ if (gPlayerEntity.x.HALF.HI - super->x.HALF.HI > 0x30)
+ return;
+ break;
+ case 0x18:
+ if (super->x.HALF.HI - gPlayerEntity.x.HALF.HI > 0x30)
+ return;
+ break;
+ }
+
+ if (super->child && sub_0806F520(super->child)) {
+ return;
+ }
+
+ if (this->unk_78 == 0) {
+ this->unk_78 = 1;
+ }
+
+ super->action = 2;
+ super->direction = direction;
+ super->spriteSettings.draw = 1;
+ COLLISION_ON(super);
+
+ super->y.WORD = (super->y.WORD & 0xfff00000) | 0xC0000;
+ sub_0807B9B8(this->tileIndex, this->tile, super->collisionLayer);
+ InitializeAnimation(super, 2);
+}
+
+void sub_08033A7C(SpinyBeetleEntity* this) {
+ if (sub_08033DF0(this)) {
+ sub_08033E1C(this);
+ return;
+ }
+
+ GetNextFrame(super);
+ if ((super->frame & 0x80) == 0)
+ return;
+
+ super->action = 3;
+ super->actionDelay = 0x78;
+ super->field_0xf = 0x20;
+ super->spritePriority.b1 = 1;
+ InitializeAnimation(super, 3);
+}
+
+void sub_08033ACC(SpinyBeetleEntity* this) {
+ if (sub_08033DF0(this)) {
+ sub_08033E1C(this);
+ return;
+ }
+
+ GetNextFrame(super);
+ GetNextFrame(super);
+
+ if (super->field_0xf) {
+ super->field_0xf--;
+ return;
+ }
+
+ if (--super->actionDelay == 0) {
+ super->action = 4;
+ super->actionDelay = 0x78;
+ super->x.WORD = (super->x.WORD & 0xfff00000) | 0x80000;
+ super->y.WORD = (super->y.WORD & 0xfff00000) | 0xC0000;
+ this->unk_7c = super->x.WORD;
+ this->unk_80 = super->y.WORD;
+ InitializeAnimation(super, 4);
+ } else {
+ sub_08033D78(this);
+ }
+}
+
+void sub_08033B44(SpinyBeetleEntity* this) {
+ u32 stop;
+ if (sub_08033DF0(this)) {
+ sub_08033E1C(this);
+ return;
+ }
+
+ GetNextFrame(super);
+ if (--super->actionDelay)
+ return;
+
+ super->action = 1;
+ super->spriteSettings.draw = 0;
+ COLLISION_OFF(super);
+
+ stop = 0;
+ while (!stop) {
+ super->x.WORD = (super->x.WORD & 0xfff00000) | 0x80000;
+ super->y.WORD = (super->y.WORD & 0xfff00000) | 0x80000;
+ this->unk_7c = super->x.WORD;
+ this->unk_80 = super->y.WORD;
+ super->spritePriority.b1 = 0;
+ this->unk_7b = 0x78;
+ this->tile = COORD_TO_TILE(super);
+ this->tileIndex = GetTileIndex(this->tile, super->collisionLayer);
+
+ if (this->tileIndex != 0x4022) {
+ stop += 1;
+ } else {
+ switch (DirectionRound(super->direction) >> 2) {
+ case 0:
+ super->y.HALF.HI += 0x10;
+ break;
+ case 2:
+ super->x.HALF.HI -= 0x10;
+ break;
+ case 4:
+ super->y.HALF.HI -= 0x10;
+ break;
+ case 6:
+ super->x.HALF.HI += 0x10;
+ break;
+ }
+ }
+ }
+
+ SetTile(0x4022, this->tile, super->collisionLayer);
+ InitializeAnimation(super, 0);
+}
+
+void sub_08033C94(SpinyBeetleEntity* this) {
+ UpdateAnimationVariableFrames(super, 3);
+ switch (this->unk_79) {
+ case 0:
+ this->unk_79 = 1;
+ if (super->spriteSettings.draw != 1) {
+ super->spriteSettings.draw = 1;
+ }
+ case 1:
+ if (--super->actionDelay)
+ return;
+ this->unk_79 = 2;
+ super->actionDelay = 0x78;
+ super->spriteOffsetY = 0;
+ super->direction = sub_08049F84(super, 1) + 0x14;
+
+ switch (Random() & 3) {
+ case 0:
+ super->direction += 8;
+ break;
+ case 2:
+ super->direction += 0x18;
+ break;
+ }
+
+ super->direction &= 0x18;
+ break;
+ case 2:
+ if (super->field_0xf != 0) {
+ super->field_0xf--;
+ } else {
+ sub_08033D78(this);
+ }
+
+ if (--super->actionDelay)
+ return;
+ super->actionDelay = (Random() & 0x1f) + 0x20;
+ super->direction = sub_08049F84(super, 1) + 0x14;
+ switch (Random() & 3) {
+ case 1:
+ super->direction += 8;
+ break;
+ case 3:
+ super->direction += 0x18;
+ break;
+ }
+
+ super->direction &= 0x18;
+ break;
+ }
+}
+
+void sub_08033D78(SpinyBeetleEntity* this) {
+ u32 dir = DirectionRound(super->direction) >> 2;
+ const s8* ptr = gUnk_080CEC1C + dir;
+ s32 tile;
+ u32 type;
+ tile = COORD_TO_TILE_OFFSET(super, -ptr[0], -ptr[1]);
+ type = GetTileType(tile, super->collisionLayer);
+
+ switch (type) {
+ case 0x1c4:
+ case 0x1c5:
+ break;
+ default:
+ if (sub_080002E0(tile, super->collisionLayer) - 1 > 0x3e)
+ ProcessMovement(super);
+ break;
+ }
+}
+
+bool32 sub_08033DF0(SpinyBeetleEntity* this) {
+ bool32 rv = 0;
+ if (super->child == NULL) {
+ rv = 1;
+ } else {
+ switch (super->child->action) {
+ case 4:
+ rv = 1;
+ break;
+ case 3:
+ if (super->child->subAction > 1) {
+ rv = 1;
+ }
+ break;
+ case 2:
+ rv = 1;
+ break;
+ }
+ }
+
+ return rv;
+}
+
+void sub_08033E1C(SpinyBeetleEntity* this) {
+ super->action = 5;
+ this->unk_79 = 0;
+ super->spriteSettings.draw = 1;
+ COLLISION_ON(super);
+ super->spritePriority.b0 = 5;
+ super->y.WORD = (super->y.WORD & 0xfff00000) | 0xC0000;
+ super->hitType = 0x19;
+ super->spritePriority.b1 = 1;
+ super->actionDelay = 0x30;
+ super->field_0xf = 0;
+ super->speed = 0x100;
+ super->child = NULL;
+ InitializeAnimation(super, 3);
+ CreateSpeechBubbleExclamationMark(super, 0xa, -12);
+}
+
+void SpinyBeetle_SetHitType(SpinyBeetleEntity* this) {
+ if ((gPlayerState.field_0xac & 8)) {
+ super->hitType = 0x95;
+ } else {
+ super->hitType = 0x63;
+ }
+}
+
+const u16 unusedLabel_0CEBDC[] = {
+ 0x3F, 0x1C, 0x50, 0x2A, 0x55, 0x1D, 0x5C, 0x2B,
+};
+
+void (*const gUnk_080CEBEC[])(Entity*) = {
+ (EntityActionPtr)sub_080337BC, (EntityActionPtr)sub_080337D4, sub_08001324, sub_0804A7D4,
+ (EntityActionPtr)sub_08033870, (EntityActionPtr)nullsub_159,
+};
+
+void (*const gUnk_080CEC04[])(SpinyBeetleEntity*) = {
+ SpinyBeetle_Init, sub_08033958, sub_08033A7C, sub_08033ACC, sub_08033B44, sub_08033C94,
+};
+
+const s8 gUnk_080CEC1C[] = { 0, -8, 8, 0, 0, 8, -8, 0 };
diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c
index a51c8ac4..68df4b69 100644
--- a/src/enemy/spinyChuchu.c
+++ b/src/enemy/spinyChuchu.c
@@ -75,7 +75,7 @@ void sub_0802244C(Entity* this) {
if (this->action == 3) {
this->action = 4;
InitializeAnimation(this, 3);
- EnqueueSFX(0x194);
+ EnqueueSFX(SFX_194);
}
}
} else {
@@ -93,7 +93,7 @@ void sub_080225A0(Entity* this) {
}
void sub_080225BC(Entity* this) {
- GravityUpdate(this, 0x1800);
+ GravityUpdate(this, Q_8_8(24.0));
if (this->frame & 1) {
sub_0804A7D4(this);
} else {
@@ -132,13 +132,13 @@ void sub_08022654(Entity* this) {
InitializeAnimation(this, 0);
/* fallthrough */
case 1:
- if (GravityUpdate(this, 0x1800))
+ if (GravityUpdate(this, Q_8_8(24.0)))
return;
this->subAction = 2;
this->spriteSettings.draw = 1;
InitializeAnimation(this, 5);
- EnqueueSFX(0x7d);
+ EnqueueSFX(SFX_PLY_LAND);
UpdateSpriteForCollisionLayer(this);
/* fallthrough */
case 2:
@@ -163,7 +163,7 @@ void sub_080226EC(Entity* this) {
if (sub_080228F0(this)) {
this->action = 6;
- this->zVelocity = 0x12000;
+ this->zVelocity = Q_16_16(1.125);
this->speed = 0x140;
this->direction = GetFacingDirection(this, gUnk_020000B0);
this->hitType = 0x5a;
@@ -186,7 +186,7 @@ void sub_08022780(Entity* this) {
if (this->frame & 0x80) {
this->action = 4;
InitializeAnimation(this, 3);
- EnqueueSFX(0x194);
+ EnqueueSFX(SFX_194);
}
}
@@ -211,7 +211,7 @@ void sub_080227AC(Entity* this) {
}
void sub_0802281C(Entity* this) {
- GravityUpdate(this, 0x1800);
+ GravityUpdate(this, Q_8_8(24.0));
GetNextFrame(this);
if (this->frame & 0x80) {
this->action = 2;
@@ -225,11 +225,11 @@ void sub_08022854(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
sub_080AEFE0(this);
- if (GravityUpdate(this, 0x1800) == 0) {
+ if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 7;
this->hitType = 0x5c;
InitializeAnimation(this, 5);
- EnqueueSFX(0x7d);
+ EnqueueSFX(SFX_PLY_LAND);
}
}
}
diff --git a/src/enemy/sub_080451CC.c b/src/enemy/sub_080451CC.c
index 14220d47..c7a82990 100644
--- a/src/enemy/sub_080451CC.c
+++ b/src/enemy/sub_080451CC.c
@@ -3,7 +3,7 @@
void sub_080451CC(Entity* this, Entity* other) {
u8* pThis;
u8* pOther;
- other->flags = this->flags & 0xfe;
+ other->flags = this->flags & ~ENT_DID_INIT;
other->x.WORD = this->x.WORD;
other->y.WORD = this->y.WORD;
other->z.WORD = this->z.WORD;
diff --git a/src/enemy/takkuri.c b/src/enemy/takkuri.c
index a0fc0dbb..a9a29a9b 100644
--- a/src/enemy/takkuri.c
+++ b/src/enemy/takkuri.c
@@ -20,8 +20,6 @@ typedef struct {
static_assert(sizeof(TakkuriEntity) == 0x88);
-extern void sub_0803C0AC(Entity*);
-extern Entity* sub_08049DF4(u32);
extern Entity* gUnk_020000B0;
void (*const gUnk_080CFF3C[])(Entity*);
@@ -341,7 +339,7 @@ void sub_0803C0AC(Entity* this) {
void sub_0803C120(TakkuriEntity* this) {
super->action = 5;
super->spriteSettings.draw = 0;
- super->flags &= 0x7f;
+ super->flags &= ~ENT_COLLIDE;
super->x.HALF.HI = this->x_0x78;
super->y.HALF.HI = this->y_0x7a;
super->z.HALF.HI += 8;
diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c
index 4c63076d..3841377e 100644
--- a/src/enemy/tektiteGolden.c
+++ b/src/enemy/tektiteGolden.c
@@ -89,7 +89,7 @@ void sub_08037Fe0(Entity* this) {
this->action = 2;
this->actionDelay = 6;
this->field_0xf = 0;
- this->zVelocity = 0x38000;
+ this->zVelocity = Q_16_16(3.5);
sub_08038168(this);
InitializeAnimation(this, 2);
}
@@ -145,7 +145,7 @@ void sub_08038110(Entity* this) {
if (this->field_0x80.HALF.LO < 5) {
this->action = 2;
this->actionDelay = 8;
- this->zVelocity = 0x38000;
+ this->zVelocity = Q_16_16(3.5);
sub_08038168(this);
InitializeAnimation(this, 2);
} else {
diff --git a/src/enemy/torchTrap.c b/src/enemy/torchTrap.c
new file mode 100644
index 00000000..527a87b7
--- /dev/null
+++ b/src/enemy/torchTrap.c
@@ -0,0 +1,156 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "enemy.h"
+#include "functions.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0xc];
+ u16 unk_74;
+ u16 filler2;
+ u16 unk_78;
+ u16 projectileTimer;
+ u16 unk_7c;
+ u8 filler3[0x2];
+ u16 unk_80;
+ u16 unk_82;
+ u16 unk_84;
+} TorchTrapEntity;
+
+void (*const gTorchTrapActions[])(TorchTrapEntity*);
+const u16 gTorchTrapTimerLengths[];
+const u16 gTorchTrapProjectileSpeeds[];
+
+extern Entity* gUnk_020000B0;
+
+bool32 sub_0803CFF0(TorchTrapEntity*);
+bool32 sub_0803CFD8(TorchTrapEntity*);
+void sub_0803D0B0(TorchTrapEntity*);
+void TorchTrap_Reset(TorchTrapEntity*);
+void TorchTrap_CreateProjectile(TorchTrapEntity*);
+
+void TorchTrap(Entity* this) {
+ gTorchTrapActions[this->action]((TorchTrapEntity*)this);
+}
+
+void TorchTrap_Init(TorchTrapEntity* this) {
+ super->speed = (this->unk_84 & 0xf000) >> 5;
+ this->unk_84 &= 0xfff;
+ sub_0804A720(super);
+ super->action = 1;
+ this->unk_74 = this->unk_82 & 0xfff;
+ super->x.HALF.HI = ((this->unk_82 & 0x3f) << 4) + 8 + gRoomControls.origin_x;
+ super->y.HALF.HI = ((this->unk_82 & 0xfc0) >> 2) + (gRoomControls.origin_y + 8);
+ super->direction = ((s16)this->unk_82 & 0xf000) >> 10;
+ this->unk_78 = super->type << 2;
+ if (sub_0803CFF0(this)) {
+ sub_0803D0B0(this);
+ }
+}
+
+void sub_0803CF24(TorchTrapEntity* this) {
+ if (sub_0803CFD8(this)) {
+ TorchTrap_Reset(this);
+ }
+}
+
+void sub_0803CF38(TorchTrapEntity* this) {
+ if (sub_0803CFF0(this)) {
+ sub_0803D0B0(this);
+ } else if (sub_08049FDC(super, 0)) {
+ if (EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x20) == 0) {
+ if (--this->projectileTimer == 0) {
+ TorchTrap_CreateProjectile(this);
+ TorchTrap_Reset(this);
+ }
+ }
+ }
+}
+
+void sub_0803CF94(TorchTrapEntity* this) {
+ if (GetTileType(this->unk_74, super->collisionLayer) == 0x76) {
+ this->unk_80 = 0;
+ TorchTrap_Reset(this);
+ } else if (this->unk_7c && sub_0803CFD8(this)) {
+ TorchTrap_Reset(this);
+ }
+}
+
+bool32 sub_0803CFD8(TorchTrapEntity* this) {
+ u32 rv;
+ if (this->unk_7c == 0) {
+ rv = 1;
+ } else {
+ rv = CheckFlags(this->unk_7c);
+ }
+ return rv;
+}
+
+bool32 sub_0803CFF0(TorchTrapEntity* this) {
+ u32 rv;
+ if (this->unk_80 != 0) {
+ if (this->unk_80 == this->unk_7c) {
+ u32 val = CheckFlags(this->unk_80);
+ rv = 0;
+ if (val == 0) {
+ rv = 1;
+ }
+ return rv;
+ } else {
+ return CheckFlags(this->unk_80);
+ }
+ }
+
+ return 0;
+}
+
+void TorchTrap_Reset(TorchTrapEntity* this) {
+ u32 val;
+ super->action = 2;
+ if (this->unk_78) {
+ this->projectileTimer = this->unk_78;
+ } else {
+ this->projectileTimer = gTorchTrapTimerLengths[Random() & 7];
+ }
+}
+
+void TorchTrap_CreateProjectile(TorchTrapEntity* this) {
+ Entity* proj = CreateProjectileWithParent(super, TORCH_TRAP_PROJECTILE, 0);
+ if (proj) {
+ u16 speed = super->speed;
+ if (super->speed) {
+ proj->speed = speed;
+ } else {
+ proj->speed = gTorchTrapProjectileSpeeds[Random() & 3];
+ }
+
+ if (super->direction & 0x20) {
+ proj->direction = GetFacingDirection(super, gUnk_020000B0);
+ } else {
+ proj->direction = super->direction;
+ }
+ }
+}
+
+void sub_0803D0B0(TorchTrapEntity* this) {
+ super->action = 3;
+ sub_0807B7D8(0x75, this->unk_74, super->collisionLayer);
+}
+
+void (*const gTorchTrapActions[])(TorchTrapEntity*) = {
+ TorchTrap_Init,
+ sub_0803CF24,
+ sub_0803CF38,
+ sub_0803CF94,
+};
+
+const u16 gTorchTrapTimerLengths[] = {
+ 0x3c, 0x3c, 0x5a, 0x5a, 0x5a, 0x78, 0x78, 0x96,
+};
+
+const u16 gTorchTrapProjectileSpeeds[] = {
+ 0x80,
+ 0x100,
+ 0x180,
+ 0x200,
+};
diff --git a/src/enemy/treeItem.c b/src/enemy/treeItem.c
index 188476a4..3e5eca1e 100644
--- a/src/enemy/treeItem.c
+++ b/src/enemy/treeItem.c
@@ -80,7 +80,7 @@ static bool32 ShouldSpawnTreeItem(Entity* this) {
int expectedStateX, expectedStateY;
int playerState;
- if (gPlayerEntity.action != 0x6) {
+ if (gPlayerEntity.action != PLAYER_BOUNCE) {
return FALSE;
}
diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c
index b4e2100b..33dc556f 100644
--- a/src/enemy/vaatiArm.c
+++ b/src/enemy/vaatiArm.c
@@ -269,15 +269,15 @@ void sub_08042654(Entity* this) {
break;
this->subAction = 5;
this->actionDelay = 0x5a;
- ((VaatiArm_HeapStruct*)this->myHeap)->entities[0]->flags |= 0x80;
+ ((VaatiArm_HeapStruct*)this->myHeap)->entities[0]->flags |= ENT_COLLIDE;
((VaatiArm_HeapStruct*)this->myHeap)->entities[0]->spritePriority.b0 = 4;
- ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->flags |= 0x80;
+ ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->flags |= ENT_COLLIDE;
((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->spritePriority.b0 = 4;
- ((VaatiArm_HeapStruct*)this->myHeap)->entities[2]->flags |= 0x80;
+ ((VaatiArm_HeapStruct*)this->myHeap)->entities[2]->flags |= ENT_COLLIDE;
((VaatiArm_HeapStruct*)this->myHeap)->entities[2]->spritePriority.b0 = 4;
- ((VaatiArm_HeapStruct*)this->myHeap)->entities[3]->flags |= 0x80;
+ ((VaatiArm_HeapStruct*)this->myHeap)->entities[3]->flags |= ENT_COLLIDE;
((VaatiArm_HeapStruct*)this->myHeap)->entities[3]->spritePriority.b0 = 4;
- ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]->flags |= 0x80;
+ ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]->flags |= ENT_COLLIDE;
((VaatiArm_HeapStruct*)this->myHeap)->entities[4]->spritePriority.b0 = 4;
InitAnimationForceUpdate(this, 7);
SoundReq(SFX_15E);
@@ -495,7 +495,7 @@ void sub_08042B20(Entity* this) {
CopyPosition(((VaatiArm_HeapStruct*)this->myHeap)->entities[4], object);
}
}
- entity->flags &= 0x7f;
+ entity->flags &= ~ENT_COLLIDE;
entity->spriteSettings.draw = 0;
SoundReq(SFX_161);
}
@@ -599,7 +599,7 @@ void sub_08042D6C(Entity* this) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
if (entity->z.HALF.HI < 4) {
if (i != 2) {
- entity->flags = entity->flags | 0x80;
+ entity->flags = entity->flags | ENT_COLLIDE;
}
if ((entity->spriteSettings.draw == 0u) && (object = CreateObject(OBJECT_AF, 2, 0), object != NULL)) {
CopyPosition(entity, object);
@@ -671,7 +671,7 @@ void sub_08042EF4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (sub_08043C98(this) == 0) {
if (--this->actionDelay == 0) {
- if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x50)) {
+ if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x50)) {
this->subAction = 6;
this->actionDelay = 0x28;
} else {
@@ -686,7 +686,7 @@ void sub_08042EF4(Entity* this) {
}
x = this->parent->x.HALF.HI;
y = this->parent->y.HALF.HI - 0x10;
- if (sub_0806FCB8(this, x, y, 0x30)) {
+ if (EntityWithinDistance(this, x, y, 0x30)) {
temp = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
if ((this->field_0x78.HALF.HI - temp) + 4 < 9) {
this->field_0x78.HALF.HI = temp ^ 0x10;
@@ -803,7 +803,7 @@ void sub_08043130(Entity* this) {
for (i = 0; i < 4; i++) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
if (entity->z.HALF.HI > -4) {
- entity->flags = entity->flags & 0x7f;
+ entity->flags = entity->flags & ~ENT_COLLIDE;
if (entity->spriteSettings.draw == 1) {
SoundReq(SFX_161);
}
@@ -872,7 +872,7 @@ NONMATCH("asm/non_matching/vaati/sub_0804334C.inc", void sub_0804334C(Entity* th
}
for (i = 0; i < 5; i++) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
- entity->flags = entity->flags | 0x80;
+ entity->flags = entity->flags | ENT_COLLIDE;
entity->spriteSettings.draw = 1;
}
}
@@ -951,22 +951,22 @@ void sub_08043490(Entity* this) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4];
if (entity->z.HALF.HI < -4) {
- entity->zVelocity = 0x18000;
+ entity->zVelocity = Q_16_16(1.5);
this->subAction = 2;
this->field_0x7c.BYTES.byte2 = 0;
((VaatiArm_HeapStruct*)this->myHeap)->parent->subAction = 2;
} else {
entity->z.HALF.HI -= 2;
if (entity->z.HALF.HI < 0) {
- entity->flags = entity->flags | 0x80;
+ entity->flags = entity->flags | ENT_COLLIDE;
entity->spriteSettings.draw = 1;
entity->field_0x3c = entity->field_0x3c & 0xef;
entity->hitType = 0x3a;
entity->hitbox = (Hitbox*)&gUnk_080FD450;
entity2 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[2];
- entity2->flags = entity2->flags | 0x80;
+ entity2->flags = entity2->flags | ENT_COLLIDE;
entity3 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[3];
- entity3->flags = entity3->flags & 0x7f;
+ entity3->flags = entity3->flags & ~ENT_COLLIDE;
}
}
UpdateAnimationSingleFrame(this);
@@ -976,7 +976,7 @@ void sub_08043520(Entity* this) {
Entity* entity;
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4];
- GravityUpdate(entity, 0x1a00);
+ GravityUpdate(entity, Q_8_8(26.0));
if ((entity->zVelocity < 0) && (-6 < entity->z.HALF.HI)) {
entity->z.HALF.HI = -6;
this->subAction = 3;
@@ -1000,7 +1000,7 @@ void sub_08043580(Entity* this) {
for (i = 0; i < 5; i++) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
if (-4 < entity->z.HALF.HI) {
- entity->flags = entity->flags & 0x7f;
+ entity->flags = entity->flags & ~ENT_COLLIDE;
entity->spriteSettings.draw = 0;
}
}
@@ -1052,7 +1052,7 @@ void sub_08043698(Entity* this) {
this->actionDelay = 0x3c;
for (i = 0; i < 5; i++) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
- entity->flags = entity->flags & 0x7f;
+ entity->flags = entity->flags & ~ENT_COLLIDE;
}
}
@@ -1325,7 +1325,7 @@ void sub_08043D08(Entity* this) {
this->subAction = 0;
InitAnimationForceUpdate(this, 0xd);
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4];
- entity->flags &= 0x7f;
+ entity->flags &= ~ENT_COLLIDE;
entity->spriteSettings.draw = 0;
InitializeAnimation(entity, 0x13);
sub_0804AA1C(entity);
@@ -1392,17 +1392,17 @@ void sub_08043EB8(Entity* this) {
this->spritePriority.b0 = 4;
InitAnimationForceUpdate(this, 0xd);
pEVar4 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[1];
- pEVar4->flags = pEVar4->flags | 0x80;
+ pEVar4->flags = pEVar4->flags | ENT_COLLIDE;
pEVar4->spritePriority.b0 = 4;
pEVar4 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[2];
- pEVar4->flags = pEVar4->flags | 0x80;
+ pEVar4->flags = pEVar4->flags | ENT_COLLIDE;
pEVar4->spritePriority.b0 = 4;
pEVar4 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[3];
- pEVar4->flags = pEVar4->flags & 0x7f;
+ pEVar4->flags = pEVar4->flags & ~ENT_COLLIDE;
pEVar4->spriteSettings.draw = 1;
pEVar4->spritePriority.b0 = 4;
pEVar4 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4];
- pEVar4->flags = pEVar4->flags | 0x80;
+ pEVar4->flags = pEVar4->flags | ENT_COLLIDE;
pEVar4->spriteSettings.draw = 1;
pEVar4->spritePriority.b0 = 4;
pEVar4->x.HALF.HI = (this->type2 == 0) ? gRoomTransition.field_0x44 : gRoomTransition.field_0x48;
@@ -1432,7 +1432,7 @@ NONMATCH("asm/non_matching/vaati/sub_08044000.inc", void sub_08044000(Entity* th
ptr2 = &gUnk_080D1400[this->type2 * 5];
for (i = 0; i < 5; ptr2++, i++) {
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
- entity->flags = entity->flags | 0x80;
+ entity->flags = entity->flags | ENT_COLLIDE;
entity->spritePriority.b0 = 4;
ptr = &((VaatiArm_HeapStruct*)this->myHeap)->s1[i];
ptr->unk00.HWORD = *ptr2;
diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c
index 760bcb5d..7b9a57fb 100644
--- a/src/enemy/vaatiBall.c
+++ b/src/enemy/vaatiBall.c
@@ -71,7 +71,7 @@ void sub_0804468C(Entity* this) {
this->field_0x82.HALF.HI = 0;
this->spriteSettings.draw = 0;
off = &gUnk_080D1620[this->field_0x78.HALF.HI & 3];
- PositionRelative(this->parent, this, off->h << 0x10, (off->v - 0x10) * 0x10000);
+ PositionRelative(this->parent, this, Q_16_16(off->h), Q_16_16(off->v - 0x10));
this->z.HALF.HI = this->parent->z.HALF.HI;
InitAnimationForceUpdate(this, 0);
break;
@@ -170,7 +170,7 @@ void sub_08044868(Entity* this) {
break;
case 1:
LinearMoveUpdate(this);
- if (sub_0806FCB8(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc)) {
+ if (EntityWithinDistance(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc)) {
this->field_0x74.HALF.LO++;
this->x.HALF.HI = vaati->x.HALF.HI;
this->y.HALF.HI = vaati->y.HALF.HI - 0x10;
@@ -383,7 +383,7 @@ void sub_08044B04(Entity* this) {
}
}
if (this->field_0x78.HALF.HI == 3)
- if (sub_0806FCB8(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc))
+ if (EntityWithinDistance(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc))
vaati->actionDelay++;
this->direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
return;
@@ -397,7 +397,7 @@ void sub_08044B04(Entity* this) {
this->field_0x74.HALF.LO = 1;
this->actionDelay = 80;
COLLISION_OFF(this);
- PositionRelative(vaati, this, 0, -0x100000);
+ PositionRelative(vaati, this, 0, Q_16_16(-16.0));
if (this->field_0xf)
this->spriteSettings.draw = 0;
break;
@@ -463,7 +463,7 @@ void sub_08044DEC(Entity* this) {
this->speed = 0x300;
off = this->parent->field_0x80.HALF.LO - 1;
this->direction = gUnk_080D1628[off][this->field_0x78.HALF.HI];
- PositionRelative(this->parent, this, 0, -0x100000);
+ PositionRelative(this->parent, this, 0, Q_16_16(-16.0));
}
void sub_08044E74(Entity* this, u32 state) {
@@ -475,7 +475,7 @@ void sub_08044E74(Entity* this, u32 state) {
this->action = 2;
this->direction += 0x18;
this->direction &= 0x1f;
- PositionRelative(this->parent, this, 0, -0x100000);
+ PositionRelative(this->parent, this, 0, Q_16_16(-16.0));
this->speed = 12288;
LinearMoveUpdate(this);
this->direction += 0x8;
@@ -509,5 +509,5 @@ void sub_08044E74(Entity* this, u32 state) {
}
this->actionDelay = 1;
this->field_0x78.HALF.LO = 0;
- this->speed = 1280;
+ this->speed = Q_8_8(5);
}
diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c
index d268a30e..e53d51f1 100644
--- a/src/enemy/vaatiEyesMacro.c
+++ b/src/enemy/vaatiEyesMacro.c
@@ -8,7 +8,6 @@
#include "enemy.h"
#include "functions.h"
-extern u32 sub_080002E0(u32, u32);
extern s16 gUnk_080B4488[];
void VaatiEyesMacroFunction0(Entity*);
diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c
index d4194d4d..440a4287 100644
--- a/src/enemy/vaatiProjectile.c
+++ b/src/enemy/vaatiProjectile.c
@@ -8,8 +8,6 @@
#include "enemy.h"
#include "functions.h"
-extern bool32 PlayerInRange(Entity*, u32, u32);
-extern u32 sub_080002E0(u32, u32);
extern Entity* gUnk_020000B0;
extern const ScreenTransitionData gUnk_0813AB94;
@@ -67,7 +65,7 @@ void VaatiProjectileFunction1(Entity* this) {
this->action = 5;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.spriteOrientation.flipY = this->spriteOrientation.flipY;
gPlayerEntity.spriteRendering.b3 = this->spriteRendering.b3;
sub_0803E444(this);
@@ -75,12 +73,12 @@ void VaatiProjectileFunction1(Entity* this) {
SetPlayerControl(2);
entity = this->parent;
if (entity != NULL) {
- entity->flags = entity->flags & 0x7f;
+ entity->flags = entity->flags & ~ENT_COLLIDE;
}
} else {
gPlayerState.flags &= ~PL_DISABLE_ITEMS;
entity = &gPlayerEntity;
- entity->flags = gPlayerEntity.flags | 0x80;
+ entity->flags = gPlayerEntity.flags | ENT_COLLIDE;
}
#endif
}
@@ -123,7 +121,7 @@ void VaatiProjectileFunction0Action0(Entity* this) {
this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY;
this->spriteRendering.b3 = this->parent->spriteRendering.b3;
this->spritePriority.b1 = 0;
- PositionRelative(this->parent, this, 0, -0x10000);
+ PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
InitializeAnimation(this, 1);
}
}
@@ -209,7 +207,7 @@ void VaatiProjectileFunction0Action8(Entity* this) {
if (this->parent->next == NULL) {
DeleteThisEntity();
}
- PositionRelative(this->parent, this, 0, -0x10000);
+ PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
GetNextFrame(this);
}
diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c
index 612e3af4..0d625249 100644
--- a/src/enemy/vaatiRebornEnemy.c
+++ b/src/enemy/vaatiRebornEnemy.c
@@ -135,7 +135,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) {
entity->parent = this;
entity->spriteSettings.flipX = i;
ptr = &gUnk_080D04A8[i];
- PositionRelative(this, entity, ptr->x << 0x10, ptr->y << 0x10);
+ PositionRelative(this, entity, Q_16_16(ptr->x), Q_16_16(ptr->y));
}
InitAnimationForceUpdate(this, 0);
}
@@ -292,7 +292,7 @@ void VaatiRebornEnemyType0Action3(Entity* this) {
break;
case 0xff:
if (this->z.HALF.HI != -4) {
- this->z.WORD -= 0x2000;
+ this->z.WORD -= Q_16_16(0.125);
}
if (this->actionDelay == 2) {
this->field_0x74.HALF.LO = 0xfe;
@@ -442,7 +442,7 @@ void VaatiRebornEnemyType0Action6(Entity* this) {
SoundReq(SFX_150);
target = CreateProjectileWithParent(this, 0x18, 0);
if (target != NULL) {
- PositionRelative(this, target, 0, -0x100000);
+ PositionRelative(this, target, 0, Q_16_16(-16.0));
target->parent = this;
}
} else if (this->actionDelay == 0x40) {
@@ -500,7 +500,7 @@ void VaatiRebornEnemyType1Action0(Entity* this) {
this->field_0x74.HALF.HI = 1;
this->actionDelay = 0;
this->spriteOffsetY = -1;
- PositionRelative(this->parent, this, 0, 0x10000);
+ PositionRelative(this->parent, this, 0, Q_16_16(1.0));
enemy = CreateEnemy(VAATI_REBORN_ENEMY, 2);
enemy->parent = this;
enemy->child = this->parent;
@@ -546,7 +546,7 @@ void VaatiRebornEnemyType1Action1(Entity* this) {
}
this->spriteSettings.draw = parent->spriteSettings.draw;
this->spriteOffsetX = parent->spriteOffsetX;
- PositionRelative(this->parent, this, 0, 0x10000);
+ PositionRelative(this->parent, this, 0, Q_16_16(1.0));
UpdateAnimationSingleFrame(this);
}
@@ -559,7 +559,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) {
this->field_0x74.HALF.HI = 0;
this->spriteOffsetY = -2;
this->direction = 0xff;
- PositionRelative(source, this, 0, 0x20000);
+ PositionRelative(source, this, 0, Q_16_16(2.0));
InitAnimationForceUpdate(this, 2);
}
@@ -595,7 +595,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) {
}
this->spriteSettings.draw = parent->spriteSettings.draw;
this->spriteOffsetX = parent->spriteOffsetX;
- PositionRelative(parent->parent, this, 0, 0x20000);
+ PositionRelative(parent->parent, this, 0, Q_16_16(2.0));
UpdateAnimationSingleFrame(this);
}
@@ -637,7 +637,7 @@ void sub_0803DC0C(Entity* this) {
tmp = &gUnk_080D04C8[this->actionDelay];
this->spriteSettings.draw = parent->spriteSettings.draw;
this->spriteOffsetX = parent->spriteOffsetX;
- PositionRelative(parent, this, tmp->x << 0x10, (tmp->y + 1) * 0x10000);
+ PositionRelative(parent, this, Q_16_16(tmp->x), Q_16_16(tmp->y + 1));
UpdateAnimationSingleFrame(this);
}
@@ -654,7 +654,7 @@ void VaatiRebornEnemyType1PreAction(Entity* this) {
if (2 < ++parent->field_0x86.HALF.LO) {
COLLISION_OFF(this);
parent->action = 7;
- parent->flags &= 0x7f;
+ parent->flags &= ~ENT_COLLIDE;
parent->actionDelay = 0x80;
parent->spriteOffsetX = 0;
parent->direction = -1;
diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c
index 62ac8918..94732451 100644
--- a/src/enemy/vaatiTransfigured.c
+++ b/src/enemy/vaatiTransfigured.c
@@ -314,7 +314,7 @@ void VaatiTransfiguredType0Action3(Entity* this) {
if (this->actionDelay != 0) {
if (--this->actionDelay == 0) {
COLLISION_OFF(this);
- this->zVelocity = 0x38000;
+ this->zVelocity = Q_16_16(3.5);
this->field_0xf = 0x10;
}
break;
@@ -380,12 +380,12 @@ void VaatiTransfiguredType0Action4(Entity* this) {
this->field_0x74.HALF.LO = 0;
this->actionDelay = 0x80;
this->field_0xf = 0;
- this->zVelocity = 0x24000;
+ this->zVelocity = Q_16_16(2.25);
SoundReq(SFX_12B);
}
break;
case 1:
- if (GravityUpdate(this, 0x2800) != 0)
+ if (GravityUpdate(this, Q_8_8(40)) != 0)
break;
this->field_0x80.HALF.LO += 1;
switch (this->cutsceneBeh.HALF.LO) {
@@ -866,7 +866,7 @@ void sub_080406A0(Entity* this) {
uVar6 = gRoomControls.origin_x + gUnk_080D0B58[tmp = uVar5 * 2];
uVar4 = gRoomControls.origin_y + gUnk_080D0B58[tmp + 1];
}
- if (sub_0806FCB8(this, uVar6, uVar4, 0x1c)) {
+ if (EntityWithinDistance(this, uVar6, uVar4, 0x1c)) {
if (uVar5 != 0) {
uVar5 = 0;
} else {
@@ -901,7 +901,7 @@ void sub_08040770(Entity* this) {
tmp5 = gRoomControls.origin_x + gUnk_080D0B64[index = tmp2 * 2];
tmp6 = gRoomControls.origin_y + gUnk_080D0B64[index + 1];
}
- if (sub_0806FCB8(this, tmp5, tmp6, 0x1c)) {
+ if (EntityWithinDistance(this, tmp5, tmp6, 0x1c)) {
if (this->animationState != 2) {
if (tmp & 8) {
tmp2 += 1;
@@ -1062,7 +1062,7 @@ void sub_080409B0(Entity* this) {
this->field_0x80.HALF.HI = 3;
COLLISION_OFF(this);
this->hitType = 0x36;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
SoundReq(SFX_164);
}
}
diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c
index 80fbb07f..e02f2f1b 100644
--- a/src/enemy/vaatiTransfiguredEye.c
+++ b/src/enemy/vaatiTransfiguredEye.c
@@ -215,7 +215,7 @@ void VaatiTransfiguredEyeFunction0Action4(Entity* this) {
void sub_08045A00(Entity* this) {
const struct xy* t = &gUnk_080D18B4[this->type2];
- PositionRelative(this->parent, this, t->x << 0x10, (t->y + 3) * 0x10000);
+ PositionRelative(this->parent, this, Q_16_16(t->x), Q_16_16(t->y + 3));
}
void sub_08045A28(Entity* this) {
@@ -291,7 +291,7 @@ void sub_08045A28(Entity* this) {
break;
}
} else {
- PositionRelative(this->parent, this, 0, -0x10000);
+ PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
switch (this->field_0x82.HALF.HI) {
case 0:
switch (this->frame & 0x70) {
diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c
index e77a11cd..e8e9ebad 100644
--- a/src/enemy/vaatiWrath.c
+++ b/src/enemy/vaatiWrath.c
@@ -453,7 +453,7 @@ void VaatiWrathType0ActionA(Entity* this) {
this->subAction = 0;
this->direction = 0;
this->speed = 0x100;
- this->zVelocity = 0x12000;
+ this->zVelocity = Q_16_16(1.125);
ChangeObjPalette(this, 0x16b);
InitAnimationForceUpdate(this, 5);
type1 = ((VaatiWrathHeapStruct*)this->myHeap)->type1;
@@ -828,11 +828,11 @@ u32 sub_0804207C(Entity* this) {
x = this->x.HALF.HI;
y = this->y.HALF.HI - 0x10;
arm = ((VaatiWrathHeapStruct*)this->myHeap)->arms[0];
- if ((arm != NULL) && (arm->action >= 5) && sub_0806FCB8(arm, x, y, 0x30)) {
+ if ((arm != NULL) && (arm->action >= 5) && EntityWithinDistance(arm, x, y, 0x30)) {
return sub_080045D4(arm->x.HALF.HI, arm->y.HALF.HI, x, y);
} else {
arm = ((VaatiWrathHeapStruct*)this->myHeap)->arms[1];
- if (((arm != NULL) && (arm->action >= 5)) && sub_0806FCB8(arm, x, y, 0x30)) {
+ if (((arm != NULL) && (arm->action >= 5)) && EntityWithinDistance(arm, x, y, 0x30)) {
return sub_080045D4(arm->x.HALF.HI, arm->y.HALF.HI, x, y);
} else {
if (gPlayerEntity.y.HALF.HI < 0x40) {
diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c
index 3a076bb6..360ba2eb 100644
--- a/src/enemy/vaatiWrathEye.c
+++ b/src/enemy/vaatiWrathEye.c
@@ -148,7 +148,7 @@ void VaatiWrathEyeAction6(Entity* this) {
if (pEVar3 != NULL) {
pEVar3->parent = this;
this->child = pEVar3;
- PositionRelative(this, pEVar3, 0, 0xc0000);
+ PositionRelative(this, pEVar3, 0, Q_16_16(12.0));
}
}
}
diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c
index 554ca1c5..9c91c691 100644
--- a/src/enemy/wallMaster.c
+++ b/src/enemy/wallMaster.c
@@ -9,8 +9,6 @@
#include "area.h"
#include "functions.h"
-extern void sub_08001328(Entity*);
-extern Entity* sub_08049DF4(u32);
extern ScreenTransitionData* gUnk_0813AB1C[];
void sub_0802A78C(Entity*);
@@ -94,7 +92,7 @@ void sub_0802A5B8(Entity* this) {
sub_0802A7D0(this);
if (this->actionDelay) {
if (--this->actionDelay == 0) {
- EnqueueSFX(0x12d);
+ EnqueueSFX(SFX_12D);
InitializeAnimation(this, 0);
}
} else {
diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c
index 1e4538dc..b2d5ba9f 100644
--- a/src/enemy/wallMaster2.c
+++ b/src/enemy/wallMaster2.c
@@ -41,7 +41,7 @@ void sub_0802CC80(Entity* this) {
this->action = 3;
COLLISION_OFF(this);
InitializeAnimation(this, 1);
- gPlayerEntity.flags &= ~0x80;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
break;
}
if (this->field_0x43 != 0) {
@@ -125,7 +125,7 @@ void sub_0802CE68(Entity* this) {
gPlayerState.field_0xa |= 0x80;
gPlayerState.mobility |= 0x80;
gPlayerState.flags |= PL_DISABLE_ITEMS;
- if (!sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 4)) {
+ if (!EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 4)) {
this->direction = GetFacingDirection(this, &gPlayerEntity);
LinearMoveUpdate(this);
}
diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c
index 3ce0985c..39c329a2 100644
--- a/src/enemy/waterDrop.c
+++ b/src/enemy/waterDrop.c
@@ -26,7 +26,7 @@ void sub_0802A250(Entity* this) {
this->action = 1;
this->actionDelay = 0;
- this->zVelocity = -0x30000;
+ this->zVelocity = Q_16_16(-3.0);
this->speed = gUnk_080CD03C[Random() & 3];
this->direction = gUnk_080CD040[Random() & 3] + 0x18;
this->collisionLayer = 2;
@@ -43,7 +43,7 @@ void sub_0802A2B4(Entity* this) {
if (!GravityUpdate(this, 0x2800)) {
this->action = 2;
this->spritePriority.b0 = 7;
- EnqueueSFX(0x84);
+ EnqueueSFX(SFX_WATER_SPLASH);
} else {
LinearMoveUpdate(this);
}
diff --git a/src/enemyUtils.c b/src/enemyUtils.c
index 956ba639..0e0929e6 100644
--- a/src/enemyUtils.c
+++ b/src/enemyUtils.c
@@ -54,7 +54,7 @@ bool32 EnemyInit(Entity* this) {
object->spritePriority.b0 = 3;
object->parent = this;
CopyPosition(this, object);
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
this->spriteSettings.draw = 0;
this->field_0x6c.HALF.HI |= 0x10;
}
diff --git a/src/interrupts.c b/src/interrupts.c
index 1668d859..97b40a36 100644
--- a/src/interrupts.c
+++ b/src/interrupts.c
@@ -245,9 +245,6 @@ void PlayerUpdate(Entity* this) {
}
// Responsible for some life things like low health beep and initiating the death sequence
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/HandlePlayerLife.inc", void HandlePlayerLife(Entity* this));
-#else
void HandlePlayerLife(Entity* this) {
u32 temp;
@@ -280,6 +277,19 @@ void HandlePlayerLife(Entity* this) {
if ((gPlayerState.controlMode != CONTROL_ENABLED) || (gMessage.doTextBox & 0x7f))
return;
+#ifdef EU
+ if ((gUnk_0200AF00.filler0[1] == 0) && gRoomTransition.frameCount % 90 == 0) {
+ temp = gSave.stats.maxHealth / 4;
+ if (temp > 24)
+ temp = 24;
+ if (temp < 8)
+ temp = 8;
+
+ if (gSave.stats.health <= temp) {
+ EnqueueSFX(SFX_LOW_HEALTH);
+ }
+ }
+#else
gRoomVars.unk2 = gMessage.doTextBox & 0x7f;
temp = gSave.stats.maxHealth / 4;
if (temp > 24)
@@ -293,6 +303,7 @@ void HandlePlayerLife(Entity* this) {
EnqueueSFX(SFX_LOW_HEALTH);
}
}
+#endif
if (gSave.stats.charm == 0) {
gSave.stats.charmTimer = 0;
@@ -318,7 +329,6 @@ void HandlePlayerLife(Entity* this) {
CreateFx(this, (FX_RED_AURA - 1) + gSave.stats.effect, 0);
}
}
-#endif
void sub_080171F0(void) {
if (gPlayerState.mobility != 0)
diff --git a/src/item/itemJarEmpty.c b/src/item/itemJarEmpty.c
index 4fcf4668..11a27fcc 100644
--- a/src/item/itemJarEmpty.c
+++ b/src/item/itemJarEmpty.c
@@ -46,7 +46,7 @@ void sub_08077534(ItemBehavior* this, u32 arg1) {
sub_08077DF4(this, 0x610);
break;
}
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
}
void sub_08077618(ItemBehavior* this, u32 arg1) {
@@ -61,7 +61,7 @@ void sub_08077618(ItemBehavior* this, u32 arg1) {
void sub_08077640(ItemBehavior* this, u32 arg1) {
UpdateItemAnim(this);
if ((this->field_0x5[9] & 0x80) != 0) {
- gPlayerEntity.flags |= 0x80;
+ gPlayerEntity.flags |= ENT_COLLIDE;
sub_08077E78(this, arg1);
}
}
@@ -69,7 +69,7 @@ void sub_08077640(ItemBehavior* this, u32 arg1) {
void sub_0807766C(ItemBehavior* this, u32 arg1) {
UpdateItemAnim(this);
if ((this->field_0x5[9] & 0x80) != 0) {
- gPlayerEntity.flags |= 0x80;
+ gPlayerEntity.flags |= ENT_COLLIDE;
sub_08077E78(this, arg1);
}
}
diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c
index 035e7e23..fff83945 100644
--- a/src/item/itemOcarina.c
+++ b/src/item/itemOcarina.c
@@ -20,7 +20,7 @@ void OcarinaUse(ItemBehavior* this, u32 arg1) {
this->field_0x5[4] |= 0xf;
gPlayerEntity.animationState = 0x04;
gPlayerEntity.spriteSettings.flipX = 0;
- gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.field_0x7a.HWORD = 2;
gPlayerState.flags |= PL_USE_OCARINA;
gPlayerState.field_0x27[0] = -1;
@@ -38,7 +38,7 @@ NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBe
// TODO regalloc
UpdateItemAnim(this);
if ((this->field_0x5[9] & 0x80) != 0) {
- gPlayerEntity.flags |= 0x80;
+ gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerState.flags &= ~PL_USE_OCARINA;
gPlayerState.field_0x27[0] = 0;
gUnk_02034490.unk0 = 0;
diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c
index ddba77c5..c3af396c 100644
--- a/src/item/itemRocsCape.c
+++ b/src/item/itemRocsCape.c
@@ -68,7 +68,7 @@ void sub_08076758(ItemBehavior* this, u32 arg1) {
if ((gPlayerEntity.zVelocity < 1) && ((gPlayerState.jump_status & 0x10) == 0)) {
this->stateID = 2;
gPlayerEntity.field_0x7a.HWORD = 2;
- gPlayerEntity.zVelocity = 0x20000;
+ gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerState.jump_status |= 0x10;
gPlayerState.animation = 0x288;
SoundReq(SFX_172);
diff --git a/src/item/itemSword.c b/src/item/itemSword.c
index 2c888629..3716f8f5 100644
--- a/src/item/itemSword.c
+++ b/src/item/itemSword.c
@@ -4,8 +4,11 @@
#include "object.h"
extern void (*const gUnk_0811BD44[])(ItemBehavior*, u32);
+extern void sub_08077B98(ItemBehavior*);
void sub_080759B8(ItemBehavior*, u32);
+void sub_080754B8(ItemBehavior*, u32);
+void sub_08075898(ItemBehavior*, u32);
extern u32 sub_08077EC8(ItemBehavior*);
@@ -16,11 +19,79 @@ void ItemSword(ItemBehavior* this, u32 arg1) {
gUnk_0811BD44[this->stateID](this, arg1);
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_08075338.inc", void sub_08075338(ItemBehavior* this, u32 arg1))
-#else
-ASM_FUNC("asm/non_matching/itemSword/sub_08075338.inc", void sub_08075338(ItemBehavior* this, u32 arg1))
+void sub_08075338(ItemBehavior* this, u32 arg1) {
+ u32 temp, temp2;
+ if (gPlayerState.flags & 0x80) {
+ this->field_0x5[4] |= 0x80;
+ sub_08077D38(this, arg1);
+ gPlayerState.animation = 0xc00;
+ SoundReq(SFX_PLY_VO1);
+ return;
+ }
+
+ if (gPlayerState.jump_status) {
+ if ((gPlayerState.jump_status & 7) != 3) {
+ if ((gPlayerState.jump_status & 0x78) == 0 && (u32)gPlayerEntity.zVelocity <= 0x17fff &&
+ (gPlayerState.field_0xac & 0x40) && gPlayerEntity.z.WORD) {
+ gPlayerState.jump_status |= 0x20;
+ gPlayerState.field_0xab = 7;
+ gPlayerState.field_0x3[1] |= (8 >> arg1) | ((8 >> arg1) << 4);
+ sub_08077B98(this);
+ this->stateID = 6;
+ sub_08075898(this, arg1);
+ return;
+ }
+ }
+#ifndef EU
+ sub_080759B8(this, arg1);
+ return;
+ } else if (gPlayerEntity.z.WORD) {
#endif
+ sub_080759B8(this, arg1);
+ return;
+ }
+
+ if (gPlayerState.flags & 0x40000) {
+ if ((gPlayerState.field_0xac & 2) == 0) {
+ if (gPlayerState.item == NULL)
+ return;
+ DeleteEntity(gPlayerState.item);
+ gPlayerState.item = NULL;
+ return;
+ }
+
+ sub_08077D38(this, arg1);
+ sub_08077B98(this);
+ temp = (8 >> arg1);
+ gPlayerState.field_0x3[1] |= temp | (temp << 4);
+ gPlayerState.field_0xa |= temp;
+ gPlayerState.keepFacing |= temp;
+ this->stateID = 8;
+ this->field_0x5[2] = 0x14;
+ this->field_0xf = 6;
+ this->field_0x5[4] |= 0x80;
+ gPlayerState.field_0xab = 2;
+ gPlayerState.flags |= 0x8000000;
+ sub_08077DF4(this, 0x130);
+ SoundReq(SFX_PLY_VO3);
+ return;
+ }
+
+ if ((gPlayerState.sword_state & 0x80) == 0) {
+ gPlayerState.sword_state = 0;
+ sub_0806F948(&gPlayerEntity);
+ }
+
+ if (gPlayerState.item) {
+ if (gPlayerState.item->id != 1) {
+ DeleteEntity(gPlayerState.item);
+ gPlayerState.item = NULL;
+ }
+ }
+
+ sub_08077D38(this, arg1);
+ sub_08077B98(this);
+}
ASM_FUNC("asm/non_matching/itemSword/sub_080754B8.inc", void sub_080754B8(ItemBehavior* this, u32 arg1))
diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c
index 3e161d89..1eb0c3e2 100644
--- a/src/item/itemTryPickupObject.c
+++ b/src/item/itemTryPickupObject.c
@@ -30,7 +30,7 @@ void sub_08076488(ItemBehavior* this, u32 arg1) {
}
UpdateItemAnim(this);
if ((this->field_0x5[9] & 0x80) != 0) {
- gPlayerEntity.flags |= 0x80;
+ gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerState.heldObject = 4;
bVar1 = ~(8 >> arg1);
gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing;
diff --git a/src/manager/manager1.c b/src/manager/manager1.c
index a47dd57b..8664caab 100644
--- a/src/manager/manager1.c
+++ b/src/manager/manager1.c
@@ -3,23 +3,39 @@
#include "screen.h"
#include "functions.h"
#include "common.h"
+#include "main.h"
extern void sub_08056250(void);
-extern void (*const gUnk_08107C5C[])(Entity*);
-extern void (*const gUnk_08107C48[])(Entity*);
+void (*const gUnk_08107C5C[])(Entity*);
+void (*const gUnk_08107C48[])(Entity*);
+const u16 gUnk_08107C1C[];
+const u16 gUnk_08107C30[];
+const u8 gManager1GfxGroups[];
-extern u8 gUnk_08107C40[];
+extern u16 gUnk_02017AA0[];
+extern u16 gUnk_085B4180[];
+
+typedef struct {
+ u8 unk0;
+ u8 unk1;
+ u8 unk2;
+ u8 unk3;
+ u8 unk4;
+} PACKED Manager1Prop;
+
+#define ZV(this) ((u8*)&this->zVelocity)
+#define ZS(this) ((u8*)&this->speed)
void Manager1_Main(Entity* this) {
u8 bVar1;
u8* pbVar2;
gUnk_08107C5C[this->action](this);
- gUnk_08107C48[((u8*)&this->zVelocity)[1]](this);
- bVar1 = gUnk_08107C40[((u8*)&this->zVelocity)[1]];
- if ((bVar1 != 0) && (*(u8*)&this->zVelocity != bVar1)) {
- ((u8*)&this->zVelocity)[0] = bVar1;
+ gUnk_08107C48[ZV(this)[1]](this);
+ bVar1 = gManager1GfxGroups[ZV(this)[1]];
+ if ((bVar1 != 0) && (ZV(this)[0] != bVar1)) {
+ ZV(this)[0] = bVar1;
LoadGfxGroup(bVar1);
}
}
@@ -27,9 +43,9 @@ void Manager1_Main(Entity* this) {
static void sub_080570B8(Entity* this) {
u8* pbVar1;
- LoadGfxGroup(((u8*)&this->zVelocity)[0]);
+ LoadGfxGroup(ZV(this)[0]);
this->z.WORD = 0;
- pbVar1 = ((u8*)&this->zVelocity + 1);
+ pbVar1 = &ZV(this)[1];
if (*pbVar1 == 3) {
gScreen.bg3.updated = 1;
} else {
@@ -45,9 +61,9 @@ static void sub_080570F8(void) {
void sub_08057118(Entity* this) {
this->actionDelay = 0;
- *(u8*)&this->zVelocity = 0;
- ((u8*)&this->zVelocity)[1] = 0;
- ((u8*)&this->zVelocity)[2] = 0;
+ ZV(this)[0] = 0;
+ ZV(this)[1] = 0;
+ ZV(this)[2] = 0;
this->action = 1;
gScreen.bg3.control = 0x1e04;
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
@@ -56,16 +72,194 @@ void sub_08057118(Entity* this) {
RegisterTransitionManager(this, sub_080570B8, sub_080570F8);
}
-ASM_FUNC("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174())
+// regalloc
+NONMATCH("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174(Entity* this)) {
+ Manager1Prop* prop = GetCurrentRoomProperty(this->type);
+ s32 temp;
+ s32 x;
+ s32 y;
+
+ if (prop->unk0 == 0xff)
+ return;
+ temp = gPlayerEntity.x.HALF.HI;
+ if (temp < 0) {
+ temp += 0xf;
+ }
+
+ x = temp >> 4;
+ temp = gPlayerEntity.y.HALF.HI;
+ if (temp < 0) {
+ temp += 0xf;
+ }
+
+ y = temp >> 4;
+
+ for (; prop->unk0 != 0xff; prop++) {
+ if (prop->unk0 != ZV(this)[1]) {
+ u32 x2 = (gRoomControls.origin_x >> 4) + prop->unk1;
+ u32 y2 = (gRoomControls.origin_y >> 4) + prop->unk2;
+
+ if (y - y2 < prop->unk4 && x - x2 < prop->unk3) {
+ switch (prop->unk0) {
+ case 1:
+ if (ZV(this)[1] == 2) {
+ this->action = 3;
+ this->actionDelay = 9;
+ }
+ break;
+ case 5:
+ if (ZV(this)[1] == 6) {
+ this->action = 3;
+ this->actionDelay = 9;
+ }
+ break;
+ case 2:
+ if (ZV(this)[1] == 0) {
+ this->action = 2;
+ this->actionDelay = 0;
+ ZV(this)[0] = 0;
+ }
+ break;
+ case 6:
+ if (ZV(this)[1] == 0) {
+ this->action = 2;
+ this->actionDelay = 0;
+ }
+ break;
+ case 4:
+ if (ZV(this)[1] == 0) {
+ this->action = 2;
+ this->actionDelay = 0;
+ this->z.WORD = 0;
+ }
+ break;
+ case 3:
+ if (ZV(this)[1] == 4) {
+ this->action = 3;
+ this->actionDelay = 9;
+ }
+ break;
+ }
+
+ if (this->action != 1) {
+ this->field_0xf = 8;
+ ZV(this)[1] = prop->unk0;
+ ZV(this)[2] = 1;
+ return;
+ }
+ }
+ }
+ }
+}
+END_NONMATCH
+
+void sub_0805728C(Entity* this) {
+ if (--this->field_0xf == 0) {
+ this->field_0xf = 8;
+ gScreen.controls.alphaBlend = gUnk_08107C1C[this->actionDelay++];
+
+ if (this->actionDelay == 10) {
+ this->action = 1;
+ ZV(this)[2] = 0;
+ }
+ }
+}
+
+void sub_080572D4(Entity* this) {
+ if (--this->field_0xf == 0) {
+ this->field_0xf = 8;
+ gScreen.controls.alphaBlend = gUnk_08107C1C[this->actionDelay--];
+
+ if (this->actionDelay == 0xff) {
+ this->action = 1;
+ ZV(this)[2] = 0;
+ ZV(this)[1] = 0;
+ gScreen._6c = 0;
+ }
+ }
+}
+
+void sub_0805732C(u32 param_1, u32 param_2) {
+ u32 index;
+ u16* ptr = &gUnk_02017AA0[gUnk_03003DE4 * 0x500];
+
+ for (index = 0; index < 0xa0; ptr++, index++) {
+ *ptr = gSineTable[(param_2 + index) & 0xff] * param_1 / 0x100 + gScreen.bg3.xOffset;
+ }
+
+ sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4 * 0x500], REG_ADDR_BG3HOFS, 0xa2600001UL);
+}
+
+void nullsub_494() {
+}
+
+void sub_080573AC(Entity* this) {
+ s32 sin, frameCount;
+ gRoomControls.bg3OffsetX.WORD -= 0x2000;
+ gRoomControls.bg3OffsetY.WORD -= 0x1000;
+ gScreen.bg3.xOffset = ((gRoomControls.scroll_x - gRoomControls.origin_x) >> 1) + gRoomControls.bg3OffsetX.HALF.HI;
+ gScreen.bg3.yOffset = ((gRoomControls.scroll_y - gRoomControls.origin_y) >> 1) + gRoomControls.bg3OffsetY.HALF.HI;
+ sin = gSineTable[(gRoomTransition.frameCount & 0xff) + 0x40];
+ sub_0805732C((sin >> 5) + 0x10, gRoomTransition.frameCount);
+ if (ZV(this)[2] == 0) {
+ if ((gRoomTransition.frameCount & 0x1f) == 0) {
+ ZS(this)[0] = (ZS(this)[0] + 1) & 7;
+ gScreen.controls.alphaBlend = gUnk_08107C30[ZS(this)[0]];
+ }
+ }
+}
+
+void sub_08057450(Entity* this) {
+ s32 y;
+ gScreen.bg3.xOffset = 0x10;
+ y = gRoomControls.scroll_y;
+ y -= gRoomControls.origin_y;
+ y >>= 2;
+
+ gScreen.bg3.yOffset = y & 0x3f;
+ gScreen.bg3.tilemap = &gBG3Buffer[(y / 0x40) << 8];
+ if ((void*)this->z.WORD != gScreen.bg3.tilemap) {
+ this->z.WORD = (u32)gScreen.bg3.tilemap;
+ gScreen.bg3.updated = 1;
+ }
+
+ if (ZV(this)[2] == 0 && (gRoomTransition.frameCount & 0x1f) == 0) {
+ ZS(this)[0] = (ZS(this)[0] + 1) & 7;
+ gScreen.controls.alphaBlend = gUnk_08107C30[ZS(this)[0]];
+ }
+
+ if ((gRoomTransition.frameCount & 0x7) == 0) {
+ u32 index;
+ u16* ptr = &gUnk_085B4180[(ZV(this)[3] << 4)];
+
+ for (index = 0, ptr = ptr + 7; index <= 3; index++) {
+ SetColor(index + 0x87, *(ptr + index));
+ SetColor(index + 0x8c, *(ptr + index + 5));
+ }
-ASM_FUNC("asm/non_matching/manager1/sub_0805728C.inc", void sub_0805728C())
+ ZV(this)[3] = (ZV(this)[3] + 1) & 3;
+ }
+}
-ASM_FUNC("asm/non_matching/manager1/sub_080572D4.inc", void sub_080572D4())
+const u16 gUnk_08107C1C[] = {
+ 0x1000, 0xF01, 0xE02, 0xD03, 0xC04, 0xB05, 0xA06, 0x907, 0x908, 0x909,
+};
-ASM_FUNC("asm/non_matching/manager1/sub_0805732C.inc", void sub_0805732C())
+const u16 gUnk_08107C30[] = {
+ 0x909, 0xA08, 0xB07, 0xC06, 0xD05, 0xC06, 0xB07, 0xA08,
+};
-ASM_FUNC("asm/non_matching/manager1/nullsub_494.inc", void nullsub_494())
+const u8 gManager1GfxGroups[] = {
+ 0x25, 0x00, 0x24, 0x00, 0x25, 0x00, 0x00, 0x00,
+};
-ASM_FUNC("asm/non_matching/manager1/sub_080573AC.inc", void sub_080573AC())
+void (*const gUnk_08107C48[])(Entity*) = {
+ nullsub_494, nullsub_494, sub_080573AC, nullsub_494, sub_08057450,
+};
-ASM_FUNC("asm/non_matching/manager1/sub_08057450.inc", void sub_08057450())
+void (*const gUnk_08107C5C[])(Entity*) = {
+ sub_08057118,
+ sub_08057174,
+ sub_0805728C,
+ sub_080572D4,
+};
diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c
index 9aea4722..cb8c6eeb 100644
--- a/src/manager/manager1A.c
+++ b/src/manager/manager1A.c
@@ -155,9 +155,9 @@ void sub_0805B210(Manager1A* this) {
gRoomTransition.player_status.room_next = tmp->unk_02;
gRoomTransition.player_status.layer = tmp->unk_03;
if (gPlayerState.flags & PL_MINISH) {
- gRoomTransition.player_status.spawn_type = 6;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_DROP_MINISH;
} else {
- gRoomTransition.player_status.spawn_type = 2;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_DROP;
}
switch (tmp->unk_00) {
case 0:
@@ -171,7 +171,7 @@ void sub_0805B210(Manager1A* this) {
case 2:
gRoomTransition.player_status.start_pos_x = tmp->unk_04;
gRoomTransition.player_status.start_pos_y = tmp->unk_06;
- gRoomTransition.player_status.spawn_type = 6;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_DROP_MINISH;
break;
}
}
diff --git a/src/manager/manager22.c b/src/manager/manager22.c
index b06295e2..5faa1a2c 100644
--- a/src/manager/manager22.c
+++ b/src/manager/manager22.c
@@ -11,7 +11,7 @@ ASM_FUNC("asm/non_matching/manager22/sub_0805BB00.inc", void sub_0805BB00())
ASM_FUNC("asm/non_matching/manager22/sub_0805BB74.inc", void sub_0805BB74())
-ASM_FUNC("asm/non_matching/manager22/sub_0805BBBC.inc", void UpdateLightLevel())
+ASM_FUNC("asm/non_matching/manager22/UpdateLightLevel.inc", void UpdateLightLevel())
ASM_FUNC("asm/non_matching/manager22/sub_0805BC04.inc", void sub_0805BC04())
diff --git a/src/manager/manager28.c b/src/manager/manager28.c
index 98bfa916..c921d4a5 100644
--- a/src/manager/manager28.c
+++ b/src/manager/manager28.c
@@ -113,7 +113,7 @@ Entity* Manager28_FindMatchingEntity(EntityData* unk1) {
y = unk1->yPos + gRoomControls.origin_y;
tmp = &gEntityLists[4];
for (i = tmp->first; (u32)i != (u32)tmp; i = i->next) {
- if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->id == i->id && 3 == i->kind && unk1->type == i->type) {
+ if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->id == i->id && ENEMY == i->kind && unk1->type == i->type) {
return i;
}
}
diff --git a/src/manager/manager2C.c b/src/manager/manager2C.c
index 3ad27242..83601282 100644
--- a/src/manager/manager2C.c
+++ b/src/manager/manager2C.c
@@ -25,7 +25,7 @@ void Manager2C_Main(Manager2C* manager) {
MemClear(&gRoomTransition.player_status, 0x20);
gRoomTransition.transitioningOut = 1;
gRoomTransition.type = TRANSITION_DEFAULT;
- gRoomTransition.player_status.spawn_type = 0xb;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_PARACHUTE_UP;
gRoomTransition.player_status.area_next = manager->manager.unk_0b;
gRoomTransition.player_status.room_next = manager->manager.unk_0e;
gRoomTransition.player_status.start_anim = manager->field_0x37;
diff --git a/src/manager/manager4.c b/src/manager/manager4.c
index f73c9514..7568960d 100644
--- a/src/manager/manager4.c
+++ b/src/manager/manager4.c
@@ -91,9 +91,6 @@ u32 sub_0805795C(Manager* this, DiggingCaveEntrance* entr) {
extern void sub_08080930(u32);
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_08057A18.inc", void sub_08057A18(Manager* this, DiggingCaveEntrance* entr))
-#else
void sub_08057A18(Manager* this, DiggingCaveEntrance* entr) {
u16 tmp;
SetInitializationPriority();
@@ -106,6 +103,8 @@ void sub_08057A18(Manager* this, DiggingCaveEntrance* entr) {
gUnk_03004030.unk_00 = entr;
gUnk_03004030.unk_04 = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x - ((entr->unk_00 & 0x3F) * 16);
gUnk_03004030.unk_06 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y - ((entr->unk_00 & 0xFC0) >> 2);
+
+#ifndef EU
tmp = gUnk_03004030.unk_08;
if (!tmp) {
if ((entr->target_room | 0x80) != gUnk_03004030.unk_0b) {
@@ -113,10 +112,11 @@ void sub_08057A18(Manager* this, DiggingCaveEntrance* entr) {
}
gUnk_03004030.unk_0b = entr->target_room | 0x80;
}
+#endif
+
sub_08080930(entr->unk_03);
DeleteManager(this);
}
-#endif
DiggingCaveEntrance* sub_08057AA8(DiggingCaveEntrance* entr, int room) {
for (; entr->unk_00 != 0xFFFF; entr++) {
diff --git a/src/manager/manager7.c b/src/manager/manager7.c
index 0560a005..25a73eb4 100644
--- a/src/manager/manager7.c
+++ b/src/manager/manager7.c
@@ -55,7 +55,54 @@ const u32 gUnk_081080A4[0x50] = {
const u8 gUnk_081081E4[] = { 0x16, 0x17, 0x17, 0x18, 0x18 };
#ifdef EU
-ASM_FUNC("asm/non_matching/eu/Manager7_Main.inc", void Manager7_Main(Manager7* this))
+void Manager7_Main(Manager7* this) {
+ u32 tmp;
+ const u32* tmp2;
+ s32 tmp3;
+ if (!this->manager.action) {
+ this->manager.action = 1;
+ this->manager.unk_0e = 8;
+ this->unk_20 = 0xFF;
+
+ RegisterTransitionManager(this, sub_08057E30, 0);
+ }
+ if (gRoomControls.reload_flags)
+ return;
+
+ if (sub_08057E40(this)) {
+ tmp = (u32)gRoomVars.unk_10[0];
+ if (this->unk_20 != tmp) {
+ this->unk_20 = tmp;
+ this->manager.unk_0e = 0;
+ }
+ }
+
+ tmp2 = &gUnk_081080A4[tmp << 4];
+ tmp3 = this->manager.unk_0e;
+ if (tmp3 == 0) {
+ gUnk_02034490.unk0 = 1;
+ LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
+ LoadPaletteGroup(gUnk_081081E4[tmp]);
+ this->manager.unk_0e++;
+ } else {
+ switch (tmp3) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(this->manager.unk_0e << 1)]],
+ tmp2[(this->manager.unk_0e << 1) + 1], 0x1000);
+ this->manager.unk_0e++;
+ gUnk_02034490.unk0 = 0;
+ case 8:
+ break;
+ }
+ }
+}
#else
void Manager7_Main(Manager7* this) {
u32 tmp;
@@ -129,14 +176,15 @@ void sub_08057E64(void) {
}
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_08057E7C.inc", void sub_08057E7C(u32 unk1))
-#else
void sub_08057E7C(u32 unk1) {
u32 tmp;
const u32* tmp2;
+
+#ifndef EU
if (unk1 > 4)
return;
+#endif
+
LoadPaletteGroup(gUnk_081081E4[unk1]);
tmp2 = &gUnk_081080A4[unk1 << 4];
for (tmp = 0; tmp < 8; tmp++, tmp2 += 2) {
@@ -144,4 +192,3 @@ void sub_08057E7C(u32 unk1) {
}
gRoomVars.unk_10[0] = unk1;
}
-#endif
diff --git a/src/manager/managerB.c b/src/manager/managerB.c
index a476efe7..a54ae310 100644
--- a/src/manager/managerB.c
+++ b/src/manager/managerB.c
@@ -98,7 +98,7 @@ void ManagerB_LoadFight(Manager* this) {
if (prop) {
while (*((u8*)prop) != 0xFF) {
ent = LoadRoomEntity(prop++);
- if (ent && (ent->kind == 3)) {
+ if (ent && (ent->kind == ENEMY)) {
ent->field_0x6c.HALF.HI |= 0x40;
ManagerBHelper_Monitor(monitor, ent, counter++);
}
diff --git a/src/manager/managerC.c b/src/manager/managerC.c
index 5f498695..c3fdaa8a 100644
--- a/src/manager/managerC.c
+++ b/src/manager/managerC.c
@@ -46,7 +46,6 @@ u32 sub_08058B08(ManagerC*, u32, u32, const struct_08108228*);
void sub_08058B5C(ManagerC*, u32);
extern void sub_0805622C(struct BgAffineDstData*, u32, u32);
-extern void sub_080044AE(Entity*, u32, u32);
extern u8 gUnk_03003DE4[0xC];
@@ -207,7 +206,7 @@ const u16 gUnk_081082E8[0xC] = { 0xB8, 0x80, 0x0, 0xB8, 0x110, 0x2, 0x118, 0x80,
void sub_08058B5C(ManagerC* this, u32 unk1) {
gRoomTransition.transitioningOut = 1;
gRoomTransition.type = TRANSITION_DEFAULT;
- gRoomTransition.player_status.spawn_type = 4;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_STEP_IN;
gRoomTransition.player_status.area_next = gRoomControls.area;
gRoomTransition.player_status.room_next = 6;
gRoomTransition.player_status.start_anim = unk1 & 1 ? 4 : 0;
diff --git a/src/manager/managerF.c b/src/manager/managerF.c
index 93724172..39f3ca47 100644
--- a/src/manager/managerF.c
+++ b/src/manager/managerF.c
@@ -361,7 +361,7 @@ void sub_0805938C(ManagerF* this) {
u32 sub_080593CC(ManagerF* this) {
if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 &&
(gPlayerState.field_0x90 & 0xF00) == 0x400) {
- return sub_0806FCB8(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
+ return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
}
return 0;
}
@@ -379,7 +379,7 @@ void sub_08059424(ManagerF* this) {
tmp->collisionLayer = 2;
tmp->x.HALF.HI = this->unk_38 + gRoomControls.origin_x;
tmp->y.HALF.HI = this->unk_3a + gRoomControls.origin_y;
- EnqueueSFX(0x1B0);
+ EnqueueSFX(SFX_1B0);
DeleteThisEntity();
}
@@ -427,7 +427,7 @@ void sub_080594DC(ManagerF* this) {
#if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP)
void sub_08059548(ManagerF* this) {
SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT);
- if (gPlayerEntity.action == 0x16) {
+ if (gPlayerEntity.action == PLAYER_TALKEZLO) {
DeleteThisEntity();
}
gInput.heldKeys |= 0x4;
diff --git a/src/message.c b/src/message.c
index 3d719fba..4136fb06 100644
--- a/src/message.c
+++ b/src/message.c
@@ -502,7 +502,7 @@ const u8 gUnk_08107C0F[] = { 0x8, 0x1e, 0x4, 0x12, 0x0 };
const u8 gUnk_08107C14[] = { 0x8, 0x1e, 0x8, 0xFE, 0x0 };
#ifdef EU
-ASM_FUNC("asm/non_matching/eu/TextBoxHandlerQuestion.inc", static void TextDispEnquiry(TextRender* ctb))
+ASM_FUNC("asm/non_matching/eu/TextDispEnquiry.inc", static void TextDispEnquiry(TextRender* ctb))
#else
static void TextDispEnquiry(TextRender* this) {
diff --git a/src/npc/beedle.c b/src/npc/beedle.c
index 703773ff..9a9717ab 100644
--- a/src/npc/beedle.c
+++ b/src/npc/beedle.c
@@ -26,7 +26,7 @@ s32 sub_080633C8(Entity* this);
void sub_0806346C(Entity* this);
void Beedle(Entity* this) {
- if (this->flags & 0x2) {
+ if (this->flags & ENT_SCRIPTED) {
sub_08063410(this);
} else {
sub_080632C8(this);
diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c
index 7bb9f3e3..0245c49c 100644
--- a/src/npc/bigGoron.c
+++ b/src/npc/bigGoron.c
@@ -275,7 +275,7 @@ void sub_0806D4C0(Entity* this, u32 param) {
if (npc != NULL) {
npc->parent = this;
CopyPosition(this, npc);
- ResolveEntityOnTop(this, npc);
+ SortEntityAbove(this, npc);
SetDefaultPriority(npc, PRIO_MESSAGE);
}
}
diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c
index 0b7de9f5..63bc4310 100644
--- a/src/npc/bladeBrothers.c
+++ b/src/npc/bladeBrothers.c
@@ -35,7 +35,7 @@ extern EntityData gUnk_080F3494;
static void sub_08068BEC(Entity* this, u32 unused);
void BladeBrothers(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_081115D0[this->action](this);
} else {
gUnk_081115C0[this->action](this);
@@ -167,7 +167,7 @@ static void sub_08068BEC(Entity* this, u32 unused) {
target = CreateFx(this, FX_WHITE_SPLASH, 0);
if (target) {
target->spritePriority.b0 = 1;
- PositionRelative(this, target, 0, -0x100000);
+ PositionRelative(this, target, 0, Q_16_16(-16.0));
SoundReq(SFX_FA);
}
}
diff --git a/src/npc/brocco.c b/src/npc/brocco.c
index b960237c..0030dd0f 100644
--- a/src/npc/brocco.c
+++ b/src/npc/brocco.c
@@ -11,7 +11,7 @@ extern void (*gUnk_0810CAA0[])(Entity*);
extern Dialog gUnk_0810CAAC[];
void Brocco(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_0806362C(this);
} else {
sub_08063544(this);
diff --git a/src/npc/carlov.c b/src/npc/carlov.c
index 6fc9ad81..8f830b11 100644
--- a/src/npc/carlov.c
+++ b/src/npc/carlov.c
@@ -12,11 +12,11 @@ void Carlov(Entity* this) {
}
if ((this->frame & 0x10) != 0) {
this->frame = this->frame & 0xef;
- EnqueueSFX(0x104);
+ EnqueueSFX(SFX_104);
InitScreenShake(0x10, 0);
}
if ((this->frame & 0x20) != 0) {
this->frame = this->frame & 0xdf;
- EnqueueSFX(0x7c);
+ EnqueueSFX(SFX_PLY_JUMP);
}
}
diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c
index 3322656f..154d1b0c 100644
--- a/src/npc/castleMaid.c
+++ b/src/npc/castleMaid.c
@@ -17,7 +17,7 @@ extern SpriteLoadData gUnk_0810F874[];
extern u32 _call_via_r0(u32*);
void Maid(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_08064570(this);
} else {
DeleteThisEntity();
diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c
index f3614564..1d3d80c2 100644
--- a/src/npc/castorWildsStatue.c
+++ b/src/npc/castorWildsStatue.c
@@ -23,7 +23,7 @@ extern PosOffset gUnk_08110E78[];
extern PosOffset gUnk_08110E8A[];
void CastorWildsStatue(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_08110E5C[this->action](this);
} else {
gUnk_08110E4C[this->action](this);
@@ -103,7 +103,7 @@ void sub_08067534(Entity* this) {
entity->y.HALF.HI += 0x1c;
}
}
- EnqueueSFX(0x14c);
+ EnqueueSFX(SFX_14C);
InitScreenShake(0x28, 4);
}
@@ -134,7 +134,7 @@ void sub_080675D4(Entity* this) {
ent->collisionLayer = this->collisionLayer;
ent->spriteOrientation.flipY = this->spriteOrientation.flipY;
ent->spriteRendering.b3 = this->spriteRendering.b3;
- ResolveEntityOnTop(this, ent);
+ SortEntityAbove(this, ent);
}
};
gUnk = gUnk_08110E8A;
@@ -147,7 +147,7 @@ void sub_080675D4(Entity* this) {
ent->collisionLayer = this->collisionLayer;
ent->spriteOrientation.flipY = this->spriteOrientation.flipY;
ent->spriteRendering.b3 = this->spriteRendering.b3;
- ResolveEntityOnTop(this, ent);
+ SortEntityAbove(this, ent);
}
};
if (this->subAction > 2) {
diff --git a/src/npc/cat.c b/src/npc/cat.c
index 1b69f913..a5cba705 100644
--- a/src/npc/cat.c
+++ b/src/npc/cat.c
@@ -40,8 +40,6 @@ extern u16 gUnk_08111104[];
extern u32 sub_0806FCA0(Entity*, Entity*);
-extern Entity* sub_08049DF4(u32);
-
void sub_08067790(Entity* this) {
ShowNPCDialogue(this, &gUnk_08110EF8 + this->type * 10 + gSave.global_progress);
}
@@ -50,7 +48,7 @@ void sub_08067790(Entity* this) {
void Cat(Entity* ent) {
gCat[ent->action](ent);
sub_08067C44(ent);
- if (((ent->flags & 128) == 0) && (ent->type != 5)) {
+ if (((ent->flags & ENT_COLLIDE) == 0) && (ent->type != 5)) {
sub_0806ED78(ent);
}
}
diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c
index 0ccc0d17..46b564ad 100644
--- a/src/npc/cuccoChick.c
+++ b/src/npc/cuccoChick.c
@@ -75,7 +75,7 @@ void CuccoChick_Fusion(Entity* this) {
this->frameIndex = 1;
} else {
if (GravityUpdate(this, 0x3000) == 0) {
- this->zVelocity = 0x10000;
+ this->zVelocity = Q_16_16(1.0);
}
}
}
diff --git a/src/npc/dog.c b/src/npc/dog.c
index 85ed9568..111b27e0 100644
--- a/src/npc/dog.c
+++ b/src/npc/dog.c
@@ -62,7 +62,7 @@ void sub_08069B44(Entity* this) {
this->field_0x74.HALF.LO = sub_0801E99C(this);
SetDefaultPriority(this, PRIO_MESSAGE);
InitAnimationForceUpdate(this, 10);
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_0807DD50(this);
}
if (((this->type == 0) && ((gPlayerState.flags & PL_MINISH) == 0)) && (GetInventoryValue(0x36) != 2)) {
diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c
index a4942f0f..65eabde0 100644
--- a/src/npc/drLeft.c
+++ b/src/npc/drLeft.c
@@ -22,7 +22,7 @@ void DrLeft(Entity* this) {
if (this->action == 0) {
this->action += 1;
this->frameIndex = 0;
- ResolveEntityBelow(this, this);
+ SortEntityBelow(this, this);
}
}
}
diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c
index 77a69331..872a99c6 100644
--- a/src/npc/ezlo.c
+++ b/src/npc/ezlo.c
@@ -54,7 +54,7 @@ void sub_0806D96C(Entity* this) {
Entity* fx = CreateFx(this, FX_STEAM_EFC, 0);
if (fx != NULL) {
fx->spritePriority.b0 = 1;
- PositionRelative(this, fx, 0, 0xFFE80000);
+ PositionRelative(this, fx, 0, Q_16_16(-24.0));
}
}
diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c
index 1093a14d..466b5285 100644
--- a/src/npc/ghostBrothers.c
+++ b/src/npc/ghostBrothers.c
@@ -23,7 +23,7 @@ void sub_08065C0C(Entity* this);
static EntityAction* const gUnk_08110164[];
void GhostBrothers(Entity* this) {
- if (this->flags & 0x2) {
+ if (this->flags & ENT_SCRIPTED) {
sub_08065C0C(this);
} else {
gUnk_08110164[this->type](this);
diff --git a/src/npc/gorman.c b/src/npc/gorman.c
index 7dfaf6ca..af735017 100644
--- a/src/npc/gorman.c
+++ b/src/npc/gorman.c
@@ -21,7 +21,7 @@ void sub_08069888(Entity* this);
extern u16 gUnk_08111C50[];
void Gorman(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_08069838(this);
} else {
sub_080697A4(this);
diff --git a/src/npc/goron.c b/src/npc/goron.c
index 22a217ca..ab17ce82 100644
--- a/src/npc/goron.c
+++ b/src/npc/goron.c
@@ -10,7 +10,7 @@ extern void (*gUnk_08111A8C[])(Entity*);
extern Dialog gUnk_08111A94[];
void Goron(Entity* this) {
- if (this->flags & 2) {
+ if (this->flags & ENT_SCRIPTED) {
gUnk_08111A8C[this->action](this);
} else {
gUnk_08111A80[this->action](this);
@@ -70,11 +70,11 @@ void sub_080693D0(Entity* this) {
if (this->frame == 1) {
this->frame = 0;
- sub_08069428(this, 0xFFF80000, createFx65);
+ sub_08069428(this, Q_16_16(-8.0), createFx65);
}
if (this->frame == 2) {
this->frame = 0;
- sub_08069428(this, 0x80 << 12, createFx65);
+ sub_08069428(this, Q_16_16(8.0), createFx65);
}
}
}
@@ -82,14 +82,14 @@ void sub_080693D0(Entity* this) {
void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) {
Entity* fx = CreateFx(this, FX_ROCK, 0);
if (fx) {
- PositionRelative(this, fx, offsetX, 0xFFF00000);
- ResolveEntityOnTop(this, fx);
+ PositionRelative(this, fx, offsetX, Q_16_16(-16.0));
+ SortEntityAbove(this, fx);
}
if (createFx65 != 0) {
fx = CreateFx(this, FX_REFLECT4, 0);
if (fx) {
- PositionRelative(this, fx, offsetX, 0xFFF00000);
- ResolveEntityOnTop(this, fx);
+ PositionRelative(this, fx, offsetX, Q_16_16(-16.0));
+ SortEntityAbove(this, fx);
}
}
}
diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c
index df239bd4..8862610f 100644
--- a/src/npc/goronMerchant.c
+++ b/src/npc/goronMerchant.c
@@ -16,7 +16,7 @@ static const u16 sKinstonePrices[];
extern u32 sub_0801E7D0(u32);
void GoronMerchant(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_08111B98[this->action](this);
} else {
gUnk_08111B88[this->action](this);
diff --git a/src/npc/gregal.c b/src/npc/gregal.c
index f7038e95..5769c8ac 100644
--- a/src/npc/gregal.c
+++ b/src/npc/gregal.c
@@ -22,13 +22,13 @@ void sub_0806CAF4(Entity* this) {
if (npc != NULL) {
npc->parent = this;
CopyPosition(this, npc);
- ResolveEntityBelow(this, npc);
+ SortEntityBelow(this, npc);
}
npc = CreateNPC(0x4a, 2, 0);
if (npc != NULL) {
npc->parent = this;
CopyPosition(this, npc);
- ResolveEntityOnTop(this, npc);
+ SortEntityAbove(this, npc);
}
sub_0807DD64(this);
sub_08078778(this);
diff --git a/src/npc/guard.c b/src/npc/guard.c
index d8afe8b2..9c36c7f9 100644
--- a/src/npc/guard.c
+++ b/src/npc/guard.c
@@ -32,7 +32,7 @@ extern SpriteLoadData gUnk_0810F524[];
extern void* gUnk_0810F6BC[];
void Guard(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_0810F544[this->action](this);
} else {
sub_08063D24(this);
diff --git a/src/npc/kid.c b/src/npc/kid.c
index 7e08592c..011327db 100644
--- a/src/npc/kid.c
+++ b/src/npc/kid.c
@@ -27,7 +27,7 @@ extern Dialog gUnk_0810BE10[];
extern u8 gUnk_0810C0A0[];
void Kid(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_080621AC(this);
} else {
gUnk_0810BE0C[this->action](this);
@@ -243,7 +243,7 @@ void sub_080626E0(Entity* this, ScriptExecutionContext* context) {
uVar4 = Random();
this->direction = (this->direction + uVar4 % 0xb) - 5;
}
- sub_0806F62C(this, (s32)this->speed, (u32)this->direction);
+ LinearMoveAngle(this, (s32)this->speed, (u32)this->direction);
if ((u32)((this->x.HALF.HI - context->x.HALF.HI) * 0x100 + ((s32)((u32)(u16)this->speed << 0x10) >> 0x11)) <=
(u32)(s32)this->speed) {
this->x.HALF.HI = context->x.HALF.HI;
diff --git a/src/npc/kingDaltus.c b/src/npc/kingDaltus.c
index e159c531..5fa29df2 100644
--- a/src/npc/kingDaltus.c
+++ b/src/npc/kingDaltus.c
@@ -9,7 +9,7 @@ extern void (*const gUnk_081104E0[])(Entity*);
extern void (*const gUnk_081104EC[])(Entity*);
void KingDaltus(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
if (this->interactType == 2) {
this->interactType = 0;
this->action = 2;
diff --git a/src/npc/malon.c b/src/npc/malon.c
index deb17fe7..77d6a20c 100644
--- a/src/npc/malon.c
+++ b/src/npc/malon.c
@@ -7,7 +7,7 @@ extern void (*gUnk_0810FF5C[])(Entity* this);
extern void (*gUnk_0810FF64[])(Entity* this);
void Malon(Entity* this) {
- if (this->flags & 0x2) {
+ if (this->flags & ENT_SCRIPTED) {
gUnk_0810FF64[this->action](this);
} else {
gUnk_0810FF5C[this->action](this);
@@ -58,12 +58,12 @@ void sub_08065914(Entity* this) {
target = FindEntityByID(7, 0x1F, 7);
if (target != NULL) {
- PositionRelative(this, target, 0x180000, -0x10000);
+ PositionRelative(this, target, Q_16_16(24.0), Q_16_16(-1.0));
target->parent = this;
}
target = FindEntityByID(7, 0x20, 7);
if (target != NULL) {
- PositionRelative(this, target, 0x280000, 0);
+ PositionRelative(this, target, Q_16_16(40.0), 0);
target->parent = this;
}
}
diff --git a/src/npc/melari.c b/src/npc/melari.c
index f2d408b2..4bdae9d3 100644
--- a/src/npc/melari.c
+++ b/src/npc/melari.c
@@ -10,7 +10,7 @@ extern u16 gUnk_0811153E[];
extern u16 gUnk_08111538[];
void Melari(Entity* this) {
- if ((this->flags & 2) == 0) {
+ if ((this->flags & ENT_SCRIPTED) == 0) {
gUnk_08111530[this->action](this);
sub_0806ED78(this);
} else {
@@ -86,7 +86,7 @@ void sub_08068780(Entity* this) {
}
ent = CreateFx(this, FX_STARS2, 0x20);
if (ent != NULL) {
- PositionRelative(this, ent, 0x180000, -0xa0000);
+ PositionRelative(this, ent, Q_16_16(24.0), Q_16_16(-10.0));
}
}
}
diff --git a/src/npc/ministerPotho.c b/src/npc/ministerPotho.c
index 70e012eb..e86bca42 100644
--- a/src/npc/ministerPotho.c
+++ b/src/npc/ministerPotho.c
@@ -9,7 +9,7 @@ void sub_08066864(Entity*);
extern u16 gUnk_08110650[];
void MinisterPotho(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_08066864(this);
} else {
gUnk_08110644[this->action](this);
diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c
index ed76f1e1..90a370db 100644
--- a/src/npc/mountainMinish.c
+++ b/src/npc/mountainMinish.c
@@ -13,7 +13,7 @@ void sub_08067EF0(Entity*);
extern u16 gUnk_0811130E[];
void MountainMinish(Entity* this) {
- if ((this->flags & 2) == 0) {
+ if ((this->flags & ENT_SCRIPTED) == 0) {
gUnk_08111368[this->action](this);
sub_0806ED78(this);
} else {
diff --git a/src/npc/npc23.c b/src/npc/npc23.c
index 28000a79..9630e18a 100644
--- a/src/npc/npc23.c
+++ b/src/npc/npc23.c
@@ -64,7 +64,7 @@ void nullsub_110(void) {
void sub_080663D4(Entity* this) {
if (this->x.HALF.HI == this->field_0x7c.HALF_U.HI - 8) {
- if (gPlayerEntity.action != 0xf) {
+ if (gPlayerEntity.action != PLAYER_080720DC) {
this->action = 4;
this->direction = 0;
this->speed = 0;
@@ -95,7 +95,7 @@ void sub_0806643C(Entity* this) {
}
void sub_08066474(void) {
- if (gPlayerEntity.action != 0xf) {
+ if (gPlayerEntity.action != PLAYER_080720DC) {
gUnk_02034490.unk0 = 0;
}
}
diff --git a/src/npc/npc26.c b/src/npc/npc26.c
index 3a4fbf75..3603d246 100644
--- a/src/npc/npc26.c
+++ b/src/npc/npc26.c
@@ -6,7 +6,7 @@ static void (*const gUnk_081106D4[])(Entity*);
static void (*const gUnk_081106E0[])(Entity*);
void NPC26(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_081106E0[this->action](this);
} else {
gUnk_081106D4[this->action](this);
diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c
index 2d59b83e..b842076f 100644
--- a/src/npc/npc4E.c
+++ b/src/npc/npc4E.c
@@ -140,12 +140,12 @@ void sub_0806DB84(Entity* this, ScriptExecutionContext* context) {
this->hitbox = (Hitbox*)&gUnk_08114154;
ent = CreateObject(OBJECT_3E, 4, 0);
if (ent != NULL) {
- PositionRelative(this, ent, -0x80000, 0);
+ PositionRelative(this, ent, Q_16_16(-8.0), 0);
*(ScriptExecutionContext**)&ent->cutsceneBeh = StartCutscene(ent, &script_Object3ELeftStoneOpening);
}
ent = CreateObject(OBJECT_3E, 5, 0);
if (ent != NULL) {
- PositionRelative(this, ent, 0x80000, 0);
+ PositionRelative(this, ent, Q_16_16(8.0), 0);
*(ScriptExecutionContext**)&ent->cutsceneBeh = StartCutscene(ent, &script_Object3ERightStoneOpening);
}
}
diff --git a/src/npc/npc5.c b/src/npc/npc5.c
index 3c2f89b3..3305d1a3 100644
--- a/src/npc/npc5.c
+++ b/src/npc/npc5.c
@@ -37,7 +37,7 @@ void sub_08061358(Entity*);
void sub_08060E94(Entity*);
-u32 sub_0806FCD0(u32, u32, u32);
+u32 PointInsideRadius(s32, s32, s32);
extern Entity gUnk_0200D654;
extern Entity gUnk_02027EB4;
@@ -53,7 +53,6 @@ extern struct {
s8 unk_1;
} gUnk_0810AC4C[];
extern u8 gUnk_0810AC54[8];
-extern u32 sub_080002B4(Entity*, u32, u32);
extern u8 gUnk_0810AC5D;
@@ -86,7 +85,7 @@ void CreateZeldaFollower(void) {
npc = CreateNPC(0x2e, 0, 0);
if (npc != NULL) {
CopyPosition(&gPlayerEntity, npc);
- npc->flags |= 0x20;
+ npc->flags |= ENT_PERSIST;
npc->animationState = GetAnimationState(npc);
}
}
@@ -183,12 +182,13 @@ void sub_08060BA0(Entity* this) {
this->speed = 0x1e0;
sub_08061120(this, ((UnkHeap*)this->myHeap)->unk_7, ((UnkHeap*)this->myHeap)->unk_8, 0xc);
sub_08061170(this);
- if (sub_0806FCB8(this, ((UnkHeap*)this->myHeap)->unk_7, ((UnkHeap*)this->myHeap)->unk_8, 4) != 0) {
+ if (EntityWithinDistance(this, ((UnkHeap*)this->myHeap)->unk_7, ((UnkHeap*)this->myHeap)->unk_8, 4) != 0) {
((UnkHeap*)this->myHeap)->unk_0 &= 0xf7;
}
} else {
if (sub_08060FD0(this, ((UnkHeap*)this->myHeap)->unk_5, ((UnkHeap*)this->myHeap)->unk_6) != 0) {
- if (sub_0806FCB8(this, ((UnkHeap*)this->myHeap)->unk_5, ((UnkHeap*)this->myHeap)->unk_6, 4) != 0) {
+ if (EntityWithinDistance(this, ((UnkHeap*)this->myHeap)->unk_5, ((UnkHeap*)this->myHeap)->unk_6, 4) !=
+ 0) {
((UnkHeap*)this->myHeap)->unk_0 &= 0xfb;
this->action = 5;
this->direction = r5->direction;
@@ -215,7 +215,8 @@ void sub_08060BA0(Entity* this) {
this->speed = 0x1e0;
sub_08061120(this, ((UnkHeap*)this->myHeap)->unk_7, ((UnkHeap*)this->myHeap)->unk_8, 0xc);
sub_08061170(this);
- if (sub_0806FCB8(this, ((UnkHeap*)this->myHeap)->unk_7, ((UnkHeap*)this->myHeap)->unk_8, 4) != 0) {
+ if (EntityWithinDistance(this, ((UnkHeap*)this->myHeap)->unk_7, ((UnkHeap*)this->myHeap)->unk_8, 4) !=
+ 0) {
((UnkHeap*)this->myHeap)->unk_0 &= 0xf7;
}
} else {
@@ -228,7 +229,8 @@ void sub_08060BA0(Entity* this) {
this->speed = 0x1e0;
sub_08061120(this, ((UnkHeap*)this->myHeap)->unk_3, ((UnkHeap*)this->myHeap)->unk_4, 0xc);
sub_08061170(this);
- if (sub_0806FCB8(this, ((UnkHeap*)this->myHeap)->unk_3, ((UnkHeap*)this->myHeap)->unk_4, 4) != 0) {
+ if (EntityWithinDistance(this, ((UnkHeap*)this->myHeap)->unk_3, ((UnkHeap*)this->myHeap)->unk_4,
+ 4) != 0) {
((UnkHeap*)this->myHeap)->unk_0 &= 0xfd;
}
} else {
@@ -344,8 +346,8 @@ u32 sub_08060F80(Entity* this) {
return 0;
}
((UnkHeap*)this->myHeap)->unk_0 &= 0xfb;
- if (sub_0806FCD0(gPlayerEntity.x.HALF.HI - this->x.HALF.HI, gPlayerEntity.y.HALF.HI - this->y.HALF.HI,
- ((UnkHeap*)this->myHeap)->unk_0b) != 0) {
+ if (PointInsideRadius(gPlayerEntity.x.HALF.HI - this->x.HALF.HI, gPlayerEntity.y.HALF.HI - this->y.HALF.HI,
+ ((UnkHeap*)this->myHeap)->unk_0b) != 0) {
return 1;
}
return 0;
@@ -818,7 +820,7 @@ void sub_08061AA8(Entity* this) {
}
void sub_08061ACC(Entity* this) {
- this->flags = this->flags | 0x20;
+ this->flags = this->flags | ENT_PERSIST;
this->action = 1;
this->subAction = 0xff;
this->actionDelay = 0;
diff --git a/src/npc/percy.c b/src/npc/percy.c
index db53c99d..5514e0ac 100644
--- a/src/npc/percy.c
+++ b/src/npc/percy.c
@@ -21,7 +21,7 @@ void Percy_Head(Entity* this) {
}
void Percy(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_0806B41C(this);
} else {
sub_0806B3CC(this);
@@ -132,7 +132,7 @@ void sub_0806B540(Entity* this) {
}
break;
case 3:
- if ((gPlayerEntity.action != 8)) {
+ if ((gPlayerEntity.action != PLAYER_ITEMGET)) {
context->wait = 0x2d;
return;
}
diff --git a/src/npc/phonograph.c b/src/npc/phonograph.c
index 8bde7e7c..3627a725 100644
--- a/src/npc/phonograph.c
+++ b/src/npc/phonograph.c
@@ -3,9 +3,18 @@
#include "functions.h"
#include "fileselect.h"
#include "screen.h"
+#include "common.h"
+#include "flags.h"
+
+#ifdef EU
+void sub_0806EABC(Entity* this);
+#else
+void sub_0806EABC(Entity* this, u32 param);
+#endif
extern void sub_08057044(u32, struct_020227E8*, u32);
extern u32 gUnk_081146B8;
+extern s8 gUnk_081145E4[];
void Phonograph(Entity* this) {
if (this->action == 0) {
@@ -20,15 +29,167 @@ void Phonograph(Entity* this) {
HandleEntity0x82Actions(this);
}
-ASM_FUNC("asm/non_matching/phonograph/sub_0806E964.inc",
- void sub_0806E964(Entity* this, ScriptExecutionContext* context))
+#ifdef EU
+void sub_0806E964(Entity* this, ScriptExecutionContext* context) {
+ if (gInput.newKeys & B_BUTTON) {
+ sub_08050384();
+ return;
+ }
+
+ if (context->unk_18 == 0) {
+ context->unk_18++;
+ this->field_0x6c.HWORD = 0;
+ sub_0806EABC(this);
+ }
+
+ if (gInput.unk4 & 0xc0) {
+ s32 val2, val3;
+ s32 val = (s16)this->field_0x68.HWORD;
+ if (gInput.unk4 & 0x40) {
+ val++;
+ } else {
+ val--;
+ }
+
+ if (val <= 0) {
+ val = 1;
+ }
+
+ val2 = 0x1c;
+ if (CheckGlobalFlag(0x55)) {
+ val2 = 0x34;
+ }
+
+ if (val > val2) {
+ val = val2;
+ }
+
+ this->field_0x68.HWORD = val;
+ sub_0806EABC(this);
+ if ((s16)this->field_0x6c.HWORD > 0) {
+ this->field_0x6c.HWORD--;
+ }
+ }
+
+ if (gInput.newKeys & A_BUTTON) {
+ if ((s16)this->field_0x68.HWORD != (s16)this->field_0x6a.HWORD || (s16)this->field_0x6c.HWORD == 0) {
+ s8* ptr2 = gUnk_081145E4;
+ s32 field_0x68;
+ SoundReq(*(s16*)(ptr2 + (s16)this->field_0x68.HWORD * 4));
+ this->field_0x6a.HWORD = this->field_0x68.HWORD;
+ field_0x68 = (s16)this->field_0x68.HWORD * 4;
+ ptr2 += 2;
+ this->field_0x6c.HWORD = *(s16*)(((ptr2 + field_0x68)));
+ } else {
+ SoundReq(SONG_STOP_ALL);
+ this->field_0x6a.HWORD = 0;
+ }
+ }
+
+ if ((s16)this->field_0x6c.HWORD > 0) {
+ if ((s16)-- this->field_0x6c.HWORD <= 0) {
+ this->field_0x6a.HWORD = 0;
+ this->field_0x6c.HWORD = 0;
+ }
+ }
+
+ gActiveScriptInfo.commandSize = 0;
+}
+#else
+void sub_0806E964(Entity* this, ScriptExecutionContext* context) {
+ s32 val, val2, val3;
+ if (gInput.newKeys & B_BUTTON) {
+ sub_08050384();
+ return;
+ }
+
+ if (context->unk_18 == 0) {
+ context->unk_18++;
+ this->field_0x6c.HWORD = 0;
+ sub_0806EABC(this, (s16)this->field_0x68.HWORD);
+ }
+
+ val2 = 0x1c;
+ if (CheckGlobalFlag(0x55)) {
+ val2 = 0x34;
+ }
+ val = (s16)this->field_0x68.HWORD;
+ if (gInput.newKeys & 0xc0) {
+ if (gInput.newKeys & 0x40) {
+ val++;
+ } else {
+ val--;
+ }
+
+ if (val <= 0) {
+ val = val2;
+ }
+
+ if (val > val2) {
+ val = 1;
+ }
+ } else if (gInput.unk4 & 0xc0) {
+ if (gInput.unk4 & 0x40) {
+ val++;
+ } else {
+ val--;
+ }
+
+ if (val <= 0) {
+ val = 1;
+ }
+
+ if (val > val2) {
+ val = val2;
+ }
+ }
+
+ if (val != (s16)this->field_0x68.HWORD) {
+ sub_0806EABC(this, val);
+ if ((s16)this->field_0x6c.HWORD > 0) {
+ this->field_0x6c.HWORD--;
+ }
+ }
+
+ this->field_0x68.HWORD = val;
+
+ if (gInput.newKeys & A_BUTTON) {
+ if ((s16)this->field_0x68.HWORD != (s16)this->field_0x6a.HWORD || (s16)this->field_0x6c.HWORD == 0) {
+ s8* ptr2 = gUnk_081145E4;
+ s32 field_0x68;
+ SoundReq(*(s16*)(ptr2 + (s16)this->field_0x68.HWORD * 4));
+ this->field_0x6a.HWORD = this->field_0x68.HWORD;
+ field_0x68 = (s16)this->field_0x68.HWORD * 4;
+ ptr2 += 2;
+ this->field_0x6c.HWORD = *(s16*)(((ptr2 + field_0x68)));
+ } else {
+ SoundReq(SONG_STOP_ALL);
+ this->field_0x6a.HWORD = 0;
+ }
+ }
+
+ if ((s16)this->field_0x6c.HWORD > 0) {
+ if ((s16)-- this->field_0x6c.HWORD <= 0) {
+ this->field_0x6a.HWORD = 0;
+ this->field_0x6c.HWORD = 0;
+ }
+ }
+
+ gActiveScriptInfo.commandSize = 0;
+}
+#endif
#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0806EABC.inc", void sub_0806EABC(Entity* this, u32 param))
+void sub_0806EABC(Entity* this) {
+ sub_08050384();
+ sub_08057044((s16)this->field_0x68.HWORD, gUnk_020227E8, 0x202020);
+ sub_0805F46C(0x3302, &gUnk_081146B8);
+ gScreen.bg0.updated = 1;
+}
#else
void sub_0806EABC(Entity* this, u32 param) {
sub_08050384();
- sub_08057044(param, &gUnk_020227E8[0], 0x202020);
+ sub_08057044(param, gUnk_020227E8, 0x202020);
sub_0805F46C(0x3302, &gUnk_081146B8);
gScreen.bg0.updated = 1;
}
diff --git a/src/npc/pina.c b/src/npc/pina.c
index 1ca1e56e..703a8061 100644
--- a/src/npc/pina.c
+++ b/src/npc/pina.c
@@ -13,7 +13,7 @@ extern void (*gUnk_0810CDF8[])(Entity*);
extern Dialog gUnk_0810CE04[];
void Pina(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_08063B68(this);
} else {
sub_08063A80(this);
diff --git a/src/npc/pita.c b/src/npc/pita.c
index b5a2e065..1f1f2308 100644
--- a/src/npc/pita.c
+++ b/src/npc/pita.c
@@ -12,7 +12,7 @@ void Pita(Entity* this) {
if (this->action == 0) {
this->action += 1;
SetDefaultPriority(this, PRIO_MESSAGE);
- ResolveEntityOnTop(this, this);
+ SortEntityAbove(this, this);
this->hitbox = &gUnk_0810C428;
sub_0807DD64(this);
}
diff --git a/src/npc/postman.c b/src/npc/postman.c
index 48e7aa9e..63c6fcf1 100644
--- a/src/npc/postman.c
+++ b/src/npc/postman.c
@@ -21,7 +21,7 @@ extern void (*const gUnk_0810AA24[])(Entity*);
extern Dialog gUnk_0810AA30[];
void Postman(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_08060528(this);
} else {
gUnk_0810AA24[this->action](this);
@@ -143,7 +143,7 @@ void sub_08060528(Entity* this) {
if (0 < (s16)this->field_0x6a.HWORD) {
if ((s16)this->field_0x6a.HWORD > 0x12b) {
this->field_0x6a.HWORD = 0;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->field_0x6c.HALF.HI = 1;
sub_080788E0(this);
EnqueueSFX(0x7c);
diff --git a/src/npc/rem.c b/src/npc/rem.c
index b846ab31..84fca459 100644
--- a/src/npc/rem.c
+++ b/src/npc/rem.c
@@ -235,7 +235,7 @@ void sub_0806A914(Entity* this) {
Entity* npc = CreateNPC(0x37, 1, 0);
if (npc != NULL) {
CopyPosition(this, npc);
- ResolveEntityOnTop(this, npc);
+ SortEntityAbove(this, npc);
}
}
@@ -279,7 +279,7 @@ void sub_0806A9E8(Entity* this) {
Entity* npc = CreateNPC(0x37, 4, 0);
if (npc != NULL) {
CopyPosition(this, npc);
- ResolveEntityBelow(this, npc);
+ SortEntityBelow(this, npc);
}
}
diff --git a/src/npc/smith.c b/src/npc/smith.c
index 764a2aa8..9667b16c 100644
--- a/src/npc/smith.c
+++ b/src/npc/smith.c
@@ -14,7 +14,7 @@ extern u32 gUnk_081103E0;
void Smith(Entity* this) {
u32 index;
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
if (this->interactType == 2) {
this->action = 4;
this->interactType = 0;
diff --git a/src/npc/stamp.c b/src/npc/stamp.c
index 4fd6944b..2390a2a9 100644
--- a/src/npc/stamp.c
+++ b/src/npc/stamp.c
@@ -13,7 +13,7 @@ extern void (*gStampBehaviors2[2])(Entity*);
extern Dialog gUnk_0810C2E4[2];
void Stamp(Entity* ent) {
- if ((ent->flags & 2) != 0) {
+ if ((ent->flags & ENT_SCRIPTED) != 0) {
gStampBehaviors2[ent->action](ent);
} else {
gStampBehaviors1[ent->action](ent);
diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c
index 05f38e8c..16d7b5f7 100644
--- a/src/npc/stockwell.c
+++ b/src/npc/stockwell.c
@@ -11,8 +11,6 @@ extern void (*const gUnk_0810FDC8[])(Entity*);
extern void (*const gUnk_0810FDA4[])(Entity*);
-extern bool32 sub_08056338(void);
-
extern void sub_08078850(Entity*, u32, u8, u32*);
extern u32 gUnk_0810FDA0;
extern u16 script_Stockwell;
@@ -107,7 +105,7 @@ void sub_080652E4(Entity* this) {
if (this->actionDelay != 0) {
this->actionDelay -= 1;
} else {
- if (gPlayerEntity.action != 8) {
+ if (gPlayerEntity.action != PLAYER_ITEMGET) {
this->subAction += 1;
MessageNoOverlap(0x2c19, this);
}
diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c
index 5961a0e1..60f77c1c 100644
--- a/src/npc/sturgeon.c
+++ b/src/npc/sturgeon.c
@@ -14,7 +14,7 @@ extern void (*const gUnk_0810FA44[])(Entity*);
void sub_08064C9C(Entity* this);
void Sturgeon(Entity* this) {
- if ((this->flags & 2) == 0) {
+ if ((this->flags & ENT_SCRIPTED) == 0) {
gUnk_0810FA44[this->action](this);
sub_0806ED78(this);
} else {
diff --git a/src/npc/talon.c b/src/npc/talon.c
index d991ab1f..075e4df4 100644
--- a/src/npc/talon.c
+++ b/src/npc/talon.c
@@ -10,7 +10,7 @@ extern u8 gUnk_0810FED8[];
void sub_0806574C(Entity* this);
void Talon(Entity* this) {
- if (this->flags & 2) {
+ if (this->flags & ENT_SCRIPTED) {
gUnk_0810FEC4[this->action](this);
} else {
gUnk_0810FEBC[this->action](this);
diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c
index 490f15ee..48c46b6c 100644
--- a/src/npc/tingleSiblings.c
+++ b/src/npc/tingleSiblings.c
@@ -10,7 +10,7 @@ extern void sub_08064EE8(Entity*);
extern void (*const gUnk_0810FBFC[])(Entity*);
void TingleSiblings(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
sub_08064DE4(this);
} else {
sub_08064D78(this);
diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c
index 50045270..96bc355e 100644
--- a/src/npc/townMinish.c
+++ b/src/npc/townMinish.c
@@ -24,7 +24,7 @@ extern u16 gUnk_08112C5C[2];
extern u16 gUnk_08112C60[4];
void TownMinish(Entity* this) {
- if ((this->flags & 2) == 0) {
+ if ((this->flags & ENT_SCRIPTED) == 0) {
gUnk_081126E8[this->action](this);
sub_0806ED78(this);
} else {
@@ -139,7 +139,7 @@ void sub_0806ADFC(Entity* this) {
void TownMinish_Head(Entity* this) {
u32 frames;
- if ((this->flags & 2) == 0) {
+ if ((this->flags & ENT_SCRIPTED) == 0) {
frames = this->field_0x68.HALF.HI / 2;
if ((this->frameSpriteSettings & 1)) {
SetExtraSpriteFrame(this, 0, frames + 0x1c);
@@ -216,7 +216,7 @@ void sub_0806AF60(Entity* this, ScriptExecutionContext* context) {
}
void sub_0806AF70(Entity* this, ScriptExecutionContext* context) {
- this->zVelocity = 0x24000;
+ this->zVelocity = Q_16_16(2.25);
}
void sub_0806AF78(Entity* this, ScriptExecutionContext* context) {
@@ -229,7 +229,7 @@ void sub_0806AF78(Entity* this, ScriptExecutionContext* context) {
void sub_0806AFA0(Entity* this) {
if (sub_0806ED78(this)) {
- sub_0806F62C(this, -this->speed, this->direction);
+ LinearMoveAngle(this, -this->speed, this->direction);
}
}
diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c
index 17cd48e5..8cfd33c1 100644
--- a/src/npc/townsperson.c
+++ b/src/npc/townsperson.c
@@ -26,7 +26,7 @@ extern u16 gUnk_0810B7BA[];
extern Dialog gUnk_0810B7C0[];
void Townsperson(Entity* this) {
- if ((this->flags & 2) != 0) {
+ if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_0810B77C[this->action](this);
} else {
gUnk_0810B774[this->action](this);
@@ -220,7 +220,7 @@ void sub_08061F94(Entity* this) {
ent = CreateFx(this, FX_BIG_EXPLOSION, 0);
if (ent != NULL) {
- ResolveEntityOnTop(this, ent);
+ SortEntityAbove(this, ent);
}
}
diff --git a/src/npc/vaatiReborn.c b/src/npc/vaatiReborn.c
index 3ed28ca8..fb59284e 100644
--- a/src/npc/vaatiReborn.c
+++ b/src/npc/vaatiReborn.c
@@ -44,7 +44,7 @@ void VaatiRebornAction0(Entity* this) {
entity = CreateNPC(VAATI_REBORN, 1, 0);
entity->parent = this;
entity->spriteOffsetY = -1;
- PositionRelative(this, entity, 0, 0x10000);
+ PositionRelative(this, entity, 0, Q_16_16(1.0));
InitAnimationForceUpdate(this, 0);
break;
case 1:
@@ -115,7 +115,7 @@ void VaatiRebornAction1(Entity* this) {
if (entity == NULL) {
DeleteThisEntity();
}
- PositionRelative(entity, this, 0, 0x210000);
+ PositionRelative(entity, this, 0, Q_16_16(33.0));
UpdateAnimationSingleFrame(this);
break;
case 2:
@@ -194,7 +194,7 @@ void sub_0806B96C(Entity* this) {
}
ptr = &gUnk_08112F80[this->type2];
this->spriteSettings.draw = entity->spriteSettings.draw;
- PositionRelative(entity, this, ptr->x << 0x10, (ptr->y + 0x21) << 0x10);
+ PositionRelative(entity, this, Q_16_16(ptr->x), Q_16_16(ptr->y + 0x21));
UpdateAnimationSingleFrame(this);
}
diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c
index 3182eda3..e7c5e69b 100644
--- a/src/npc/wheaton.c
+++ b/src/npc/wheaton.c
@@ -7,7 +7,7 @@ void Wheaton(Entity* this) {
this->action++;
SetDefaultPriority(this, PRIO_MESSAGE);
- ResolveEntityOnTop(this, this);
+ SortEntityAbove(this, this);
this->hitbox = &gUnk_0810C3C0;
this->spriteOffsetY = 0xfe;
sub_0807DD64(this);
diff --git a/src/npc/zelda.c b/src/npc/zelda.c
index b0ac945f..4842ec83 100644
--- a/src/npc/zelda.c
+++ b/src/npc/zelda.c
@@ -73,7 +73,7 @@ void sub_08066D94(Entity* this) {
npc = CreateNPC(0x2E, 0, 0);
if (npc != NULL) {
npc->animationState = gPlayerEntity.animationState;
- npc->flags |= 0x20;
+ npc->flags |= ENT_PERSIST;
npc->animationState = GetAnimationState(this);
room = gRoomControls.room;
npc->field_0x74.HWORD = room;
@@ -127,13 +127,13 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) {
UpdateAnimationSingleFrame(this);
if (this->frame & 1) {
context->unk_18++;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->frame &= 0xFE;
SoundReq(SFX_PLY_JUMP);
}
break;
case 2:
- sub_0806F62C(this, 0x100, 0x80);
+ LinearMoveAngle(this, 0x100, 0x80);
GravityUpdate(this, 0x2000);
if (!(this->frame & 1)) {
UpdateAnimationSingleFrame(this);
@@ -143,7 +143,7 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) {
}
break;
case 3:
- sub_0806F62C(this, 0x100, 0x80);
+ LinearMoveAngle(this, 0x100, 0x80);
UpdateAnimationSingleFrame(this);
if (GravityUpdate(this, 0x2000) == 0) {
context->unk_18++;
diff --git a/src/npcUtils.c b/src/npcUtils.c
index f1b97dd6..e89e1471 100644
--- a/src/npcUtils.c
+++ b/src/npcUtils.c
@@ -56,7 +56,7 @@ void NPCInit(Entity* this) {
const NPCDefinition* definition = GetNPCDefinition(this);
if (definition->bitfield.type == 0) {
// No sprite for this NPC
- this->flags |= 1;
+ this->flags |= ENT_DID_INIT;
} else {
tmp = definition->bitfield.gfx;
switch (definition->bitfield.gfx_type) {
@@ -89,7 +89,7 @@ void NPCInit(Entity* this) {
Entity* CreateNPC(u32 subtype, u32 form, u32 parameter) {
Entity* entity = GetEmptyEntity();
if (entity != NULL) {
- entity->kind = 7;
+ entity->kind = NPC;
entity->id = subtype;
entity->type = form;
entity->type2 = parameter;
@@ -275,7 +275,35 @@ s32 sub_0806F078(Entity* ent, s32 a2) {
return 0;
}
-ASM_FUNC("asm/non_matching/sub_0806FOA4.inc", void sub_0806F0A4(void));
+void sub_0806F0A4(void) {
+ LinkedList* entityList = gEntityLists + 7;
+ Entity* currentEntity;
+ u32 val;
+
+ for (currentEntity = entityList->first, val = 0; currentEntity != (Entity*)entityList;
+ currentEntity = currentEntity->next) {
+ val++;
+ }
+
+ if (val <= 1)
+ return;
+
+ for (currentEntity = entityList->first; currentEntity != (Entity*)entityList; currentEntity = currentEntity->next) {
+ Entity* nextEnt;
+ if ((currentEntity->flags & ENT_DID_INIT) == 0)
+ continue;
+ if ((currentEntity->field_0x17 & 1) == 0)
+ continue;
+
+ for (nextEnt = currentEntity->next; nextEnt != (Entity*)entityList; nextEnt = nextEnt->next) {
+ if ((nextEnt->flags & ENT_DID_INIT) == 0)
+ continue;
+ if ((nextEnt->field_0x17 & 1) == 0)
+ continue;
+ sub_08004484(currentEntity, nextEnt);
+ }
+ }
+}
void sub_0806F118(Entity* ent) {
u32 idx = sub_08002632(ent);
@@ -309,4 +337,134 @@ void sub_0806F188(Entity* ent) {
gSave.unk1C1[idx] = 0xF3;
}
-ASM_FUNC("asm/non_matching/showNPCDialogue.inc", void ShowNPCDialogue(Entity* ent, Dialog* dia));
+void ShowNPCDialogue(Entity* ent, Dialog* dia) {
+ u32 uVar1;
+ s32 temp;
+ u32 uVar2;
+ u32 uVar3;
+ s32 uVar4;
+ int iVar5;
+
+ temp = *(((u16*)dia) + 1);
+ uVar1 = (temp >> 4) & 1;
+ temp &= 0xf;
+ switch (temp) {
+ case 2:
+ uVar3 = (int)*(u32*)dia;
+ temp = (s32)uVar3 >> 0xc & 0xf;
+ uVar3 = uVar3 & 0xfff;
+ iVar5 = 0;
+ switch (temp) {
+ case 0:
+ iVar5 = CheckRoomFlag(uVar3);
+ _SetRoomFlag:
+ SetRoomFlag(uVar3);
+ break;
+ case 1:
+ iVar5 = CheckLocalFlag(uVar3);
+ _SetLocalFlag:
+ SetLocalFlag(uVar3);
+ break;
+ case 2:
+ iVar5 = CheckGlobalFlag(uVar3);
+ SetGlobalFlag(uVar3);
+ break;
+ }
+ _check:
+ if (iVar5 == 0) {
+ uVar2 = dia->data.indices.b;
+ } else {
+ uVar2 = dia->data.indices.a;
+ }
+ break;
+ case 3:
+ uVar3 = (int)*(u32*)dia;
+ uVar4 = (s32)uVar3 >> 0xc & 0xf;
+ uVar3 = uVar3 & 0xfff;
+ iVar5 = 0;
+ switch (uVar4) {
+ case 0:
+ iVar5 = CheckRoomFlag(uVar3);
+ if (iVar5 == 0) {
+ goto _SetRoomFlag;
+ } else {
+ ClearRoomFlag(uVar3);
+ }
+ break;
+ case 1:
+ iVar5 = CheckLocalFlag(uVar3);
+ if (iVar5 == 0) {
+ goto _SetLocalFlag;
+ } else {
+ ClearLocalFlag(uVar3);
+ }
+ break;
+ case 2:
+ iVar5 = CheckGlobalFlag(uVar3);
+ if (iVar5 == 0) {
+ SetGlobalFlag(uVar3);
+ } else {
+ ClearGlobalFlag(uVar3);
+ }
+ break;
+ }
+ goto _check;
+ case 4:
+ uVar3 = (int)*(u32*)dia;
+ uVar4 = (s32)uVar3 >> 0xc & 0xf;
+ uVar3 = uVar3 & 0xfff;
+ iVar5 = 0;
+ {
+ u32 local;
+ switch (uVar4) {
+ case 0:
+ local = CheckRoomFlag(uVar3);
+ break;
+ case 1:
+ local = CheckLocalFlag(uVar3);
+ break;
+ case 2:
+ local = CheckGlobalFlag(uVar3);
+ break;
+ case 3:
+ local = CheckKinstoneFused(uVar3);
+ break;
+ case 4:
+ local = GetInventoryValue(uVar3);
+ if (local != 0) {
+ local = 1;
+ }
+ break;
+ default:
+ goto _check;
+ }
+ iVar5 = local;
+ }
+ goto _check;
+ case 5:
+ if (dia->data.func != 0) {
+ dia->data.func(ent);
+ return;
+ }
+ default:
+ case 0:
+ uVar2 = 0;
+ break;
+ case 1:
+ uVar2 = dia->data.indices.b;
+ break;
+ case 6:
+ if ((gPlayerState.flags & 0x80) != 0) {
+ uVar2 = dia->data.indices.b;
+ } else {
+ uVar2 = dia->data.indices.a;
+ }
+ break;
+ }
+
+ if (uVar1 != 0) {
+ MessageNoOverlap(uVar2, ent);
+ } else {
+ MessageFromTarget(uVar2);
+ }
+}
diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c
index a5b344ba..cdc65c3a 100644
--- a/src/object/bakerOven.c
+++ b/src/object/bakerOven.c
@@ -1,7 +1,7 @@
#include "object.h"
+#include "functions.h"
extern void SoundReqClipped(Entity*, u32);
-extern u32 sub_0806FC80(Entity*, Entity*, s32);
extern void sub_0809CDF0(Entity*);
extern void (*const gUnk_08123E20[])(Entity*);
@@ -24,7 +24,7 @@ void sub_0809CC74(Entity* this) {
ent = CreateObject(BAKER_OVEN, 1, i);
if (ent) {
ent->parent = this;
- PositionRelative(this, ent, (((i + 1) / 2) * 0x100000) - 0x80000, -0xe0000);
+ PositionRelative(this, ent, 16 * Q_16_16((i + 1) / 2) - Q_16_16(8.0), Q_16_16(-14.0));
}
}
sub_0809CDF0(this);
@@ -61,7 +61,7 @@ void sub_0809CD0C(Entity* this) {
sub_0806FC80(this, &gPlayerEntity, 4)) {
this->field_0xf++;
ModHealth(-2);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
gPlayerEntity.iframes = 16;
gPlayerEntity.knockbackDirection = 16;
gPlayerEntity.knockbackDuration = 12;
diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c
new file mode 100644
index 00000000..71f10a90
--- /dev/null
+++ b/src/object/bigPushableLever.c
@@ -0,0 +1,155 @@
+/**
+ * @file bigPushableLever.c
+ * @ingroup Objects
+ *
+ * @brief Big Pushable Lever object
+ */
+
+#define NENT_DEPRECATED
+#include "global.h"
+#include "object.h"
+#include "functions.h"
+
+typedef struct {
+ /*0x00*/ Entity base;
+ /*0x68*/ u8 unk_68[8];
+ /*0x70*/ u16 tilePositionUpper;
+ /*0x72*/ u16 tilePositionLower;
+ /*0x74*/ u16 tileIndexUpper;
+ /*0x76*/ u16 tileIndexLower;
+ /*0x78*/ u8 unk_78[12];
+ /*0x84*/ u16 timer;
+ /*0x86*/ u16 pushedFlag;
+} BigPushableLeverEntity;
+
+enum BigPushableLeverAction {
+ INIT,
+ IDLE,
+ PUSHING,
+};
+
+extern void (*const BigPushableLever_Actions[])(BigPushableLeverEntity*);
+extern const u16 gUnk_081236E8[];
+extern const u8 BigPushableLever_InitialOffsets[];
+extern const u8 BigPushableLever_PushedOffsets[];
+
+void BigPushableLever_SetIdle(BigPushableLeverEntity*);
+bool32 BigPushableLever_ShouldStartPushing(BigPushableLeverEntity*);
+void BigPushableLever_SetTiles(BigPushableLeverEntity*);
+void BigPushableLever_CalculateSpriteOffsets(BigPushableLeverEntity*);
+
+#define TILE_INITIAL 0x4058
+#define TILE_PUSHED 0x4056
+
+void BigPushableLever(BigPushableLeverEntity* this) {
+ BigPushableLever_Actions[super->action](this);
+}
+
+void BigPushableLever_Init(BigPushableLeverEntity* this) {
+ super->spritePriority.b0 = 5;
+ BigPushableLever_SetIdle(this);
+}
+
+void BigPushableLever_Idle(BigPushableLeverEntity* this) {
+ if (BigPushableLever_ShouldStartPushing(this)) {
+ super->action = PUSHING;
+ SetTile(this->tileIndexUpper, this->tilePositionUpper, super->collisionLayer);
+ SetTile(this->tileIndexLower, this->tilePositionLower, super->collisionLayer);
+ EnqueueSFX(SFX_132);
+ RequestPriorityDuration(super, 0x1e);
+ if (sub_08079F8C()) {
+ gPlayerState.pushedObject = 0x98;
+ gPlayerState.queued_action = 5;
+ gPlayerState.flags |= 1;
+ gPlayerEntity.x.HALF.LO = 0;
+ gPlayerEntity.y.HALF.LO = 0;
+ gPlayerEntity.direction = gPlayerEntity.animationState << 2;
+ }
+ }
+}
+
+void BigPushableLever_Pushing(BigPushableLeverEntity* this) {
+ GetNextFrame(super);
+ if ((super->frame & 0x80) != 0) {
+ if (super->type2 == 0) {
+ SetFlag(this->pushedFlag);
+ } else {
+ ClearFlag(this->pushedFlag);
+ }
+ BigPushableLever_SetIdle(this);
+ }
+}
+
+void BigPushableLever_SetIdle(BigPushableLeverEntity* this) {
+ super->action = IDLE;
+ this->timer = 0x3c;
+ BigPushableLever_SetTiles(this);
+}
+
+void BigPushableLever_SetTiles(BigPushableLeverEntity* this) {
+ if (!CheckFlags(this->pushedFlag)) {
+ super->type2 = 0;
+ this->tilePositionUpper = COORD_TO_TILE_OFFSET(super, 0, 0x10);
+ this->tilePositionLower = this->tilePositionUpper - 0x40;
+ this->tileIndexUpper = GetTileIndex(this->tilePositionUpper, super->collisionLayer);
+ this->tileIndexLower = GetTileIndex(this->tilePositionLower, super->collisionLayer);
+ SetTile(0x4057, this->tilePositionUpper, super->collisionLayer);
+ SetTile(0x4058, this->tilePositionLower, super->collisionLayer);
+ InitializeAnimation(super, 1);
+ } else {
+ super->type2 = 1;
+ this->tilePositionUpper = COORD_TO_TILE_OFFSET(super, 0x10, 0);
+ this->tilePositionLower = this->tilePositionUpper - 1;
+ this->tileIndexUpper = GetTileIndex(this->tilePositionUpper, super->collisionLayer);
+ this->tileIndexLower = GetTileIndex(this->tilePositionLower, super->collisionLayer);
+ SetTile(0x4055, this->tilePositionUpper, super->collisionLayer);
+ SetTile(0x4056, this->tilePositionLower, super->collisionLayer);
+ InitializeAnimation(super, 0);
+ }
+}
+
+bool32 BigPushableLever_ShouldStartPushing(BigPushableLeverEntity* this) {
+ if (GetTileIndex(this->tilePositionLower, super->collisionLayer) == 0x4059) {
+ if (--this->timer == 0) {
+ return TRUE;
+ }
+ BigPushableLever_CalculateSpriteOffsets(this);
+ SetTile(gUnk_081236E8[super->type2], this->tilePositionLower, super->collisionLayer);
+ } else {
+ this->timer = 0x3c;
+ super->spriteOffsetX = 0;
+ super->spriteOffsetY = 0;
+ }
+ return FALSE;
+}
+
+void BigPushableLever_CalculateSpriteOffsets(BigPushableLeverEntity* this) {
+ const u8* offsets;
+ if (super->type2 == 0) {
+ offsets = BigPushableLever_InitialOffsets;
+ } else {
+ offsets = BigPushableLever_PushedOffsets;
+ }
+ offsets = &offsets[this->timer >> 2 & 6];
+ super->spriteOffsetX = offsets[0];
+ super->spriteOffsetY = offsets[1];
+ if ((this->timer & 3) == 0) {
+ EnqueueSFX(SFX_131);
+ }
+}
+
+void (*const BigPushableLever_Actions[])(BigPushableLeverEntity*) = {
+ BigPushableLever_Init,
+ BigPushableLever_Idle,
+ BigPushableLever_Pushing,
+};
+const u16 gUnk_081236E8[] = {
+ TILE_INITIAL,
+ TILE_PUSHED,
+};
+const u8 BigPushableLever_InitialOffsets[] = {
+ 0, 0, 0, 0, 255, 0, 0, 0,
+};
+const u8 BigPushableLever_PushedOffsets[] = {
+ 0, 0, 0, 0, 0, 255, 0, 0,
+};
diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c
index a26b7aae..1a3d8229 100644
--- a/src/object/bigVortex.c
+++ b/src/object/bigVortex.c
@@ -65,7 +65,7 @@ void sub_08098DC4(Entity* this) {
sub_08004542(this);
sub_08004542(&gPlayerEntity);
gPlayerEntity.collisionLayer = 1;
- ResolveEntityOnTop(this, &gPlayerEntity);
+ SortEntityAbove(this, &gPlayerEntity);
gPlayerState.queued_action = PLAYER_PARACHUTE;
gPlayerState.field_0x34[4] = 1;
gPlayerState.field_0x34[5] = this->type2;
@@ -101,12 +101,12 @@ void sub_08098E88(Entity* this) {
ent1 = CreateObject(BIG_VORTEX, 1, 0);
if (ent1 != NULL) {
- PositionRelative(this, ent1, 0, -0x10000);
+ PositionRelative(this, ent1, 0, Q_16_16(-1.0));
ent1->spriteOffsetY = 8;
}
ent2 = CreateObject(BIG_VORTEX, 2, 0);
if (ent2 != NULL) {
- PositionRelative(this, ent2, 0, -0x20000);
+ PositionRelative(this, ent2, 0, Q_16_16(-2.0));
ent2->spriteOffsetY = 0x10;
}
}
diff --git a/src/object/bird.c b/src/object/bird.c
index 24e2693b..cafe1262 100644
--- a/src/object/bird.c
+++ b/src/object/bird.c
@@ -24,9 +24,9 @@ void sub_0809CF54(Entity* this) {
this->spriteSettings.draw = TRUE;
this->actionDelay = 0x31;
this->field_0xf = 1;
- this->zVelocity = -0x18000;
- this->z.WORD = -0x38C000;
- this->field_0x68.HWORD = -0x800;
+ this->zVelocity = Q_16_16(-1.5);
+ this->z.WORD = Q_16_16(-56.75);
+ this->field_0x68.HWORD = Q_16_16(-0.03125);
this->speed = 0x280;
this->direction = 8;
this->collisionLayer = 2;
@@ -37,8 +37,8 @@ void sub_0809CF54(Entity* this) {
target = CreateObject(BIRD, 1, 0);
if (target != NULL) {
target->parent = this;
- PositionRelative(this, target, 0, 0x80000);
- ResolveEntityOnTop(this, target);
+ PositionRelative(this, target, 0, Q_16_16(8.0));
+ SortEntityAbove(this, target);
}
}
@@ -77,7 +77,7 @@ void sub_0809D084(Entity* this) {
if (this->parent != NULL) {
temp = this->parent->field_0xf;
if (temp != 0) {
- PositionRelative(this->parent, this, 0, 0x80000);
+ PositionRelative(this->parent, this, 0, Q_16_16(8.0));
} else {
this->subAction++;
this->zVelocity = temp;
@@ -97,7 +97,7 @@ void sub_0809D0AC(Entity* this) {
SoundReq(SFX_SECRET);
fx = CreateFx(this, FX_DASH, 0);
if (fx != NULL) {
- ResolveEntityBelow(this, fx);
+ SortEntityBelow(this, fx);
}
}
}
@@ -116,7 +116,7 @@ void sub_0809D10C(Entity* this) {
void sub_0809D130(Entity* this) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
sub_0800445C(this);
- } else if (sub_08017850(this) != 0) {
+ } else if (IsCollidingPlayer(this) != 0) {
CreateItemEntity(0x17, 0, 0);
gSave.windcrests |= 0x10000000;
DeleteThisEntity();
diff --git a/src/object/book.c b/src/object/book.c
index 7c3bf57e..c0003115 100644
--- a/src/object/book.c
+++ b/src/object/book.c
@@ -98,7 +98,7 @@ void sub_0809B4A8(Entity* this) {
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
- EnqueueSFX(0x10f);
+ EnqueueSFX(SFX_10F);
} else {
this->actionDelay = 0x16;
}
@@ -134,14 +134,14 @@ void sub_0809B56C(Entity* this) {
fx = CreateFx(this, FX_DEATH, 0);
if (fx) {
- ResolveEntityOnTop(this, fx);
+ SortEntityAbove(this, fx);
}
}
void sub_0809B5B4(Entity* this) {
if (gPlayerState.flags & PL_MINISH) {
sub_0800445C(this);
- } else if (sub_08017850(this)) {
+ } else if (IsCollidingPlayer(this)) {
CreateItemEntity(this->type + 0x39, 0, 0);
DeleteThisEntity();
}
diff --git a/src/object/button.c b/src/object/button.c
index 1d1c88d9..61f4e704 100644
--- a/src/object/button.c
+++ b/src/object/button.c
@@ -90,7 +90,7 @@ void sub_08081C30(Entity* this) {
this->action = 2;
ClearFlag(this->field_0x86.HWORD);
SetTileType(0x77, this->field_0x74.HWORD, this->collisionLayer);
- SoundReq(SFX_10C);
+ SoundReq(SFX_BUTTON_PRESS);
}
}
@@ -101,7 +101,6 @@ void sub_08081C98(Entity* this) {
}
Entity* sub_08081D74(Entity*);
-u32 sub_080001DA(u32, u32);
u32 sub_08081CB0(Entity* this) {
u16 tmp;
@@ -114,7 +113,7 @@ u32 sub_08081CB0(Entity* this) {
} else {
tmp = GetTileType(this->field_0x74.HWORD, this->collisionLayer);
if (tmp != 0x77 && tmp != 0x79 && tmp != 0x4035) {
- this->field_0x70.HALF.LO = sub_080001DA(this->field_0x74.HWORD, this->collisionLayer);
+ this->field_0x70.HALF.LO = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer);
return 1;
}
}
@@ -129,14 +128,13 @@ u32 sub_08081D28(Entity* this) {
if (this->field_0x70.HALF_U.LO == 0xFFFF) {
return 0;
}
- if (sub_080001DA(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) {
+ if (GetTileIndex(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) {
return 0;
}
}
return 1;
}
-extern u32 sub_080002E0(u32, u32);
extern Entity* gPlayerClones[3];
u32 sub_08081E0C(Entity*);
@@ -252,7 +250,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
SetFlag(this->field_0x86.HWORD);
SetTileType(r7, this->field_0x74.HWORD, this->collisionLayer);
sub_08081F24(this);
- SoundReq(SFX_10C);
+ SoundReq(SFX_BUTTON_PRESS);
if (this->field_0x70.HALF_U.LO != 0xFFFF)
SetTile(this->field_0x70.HALF_U.LO, this->field_0x74.HWORD, this->collisionLayer);
return 0;
@@ -261,8 +259,6 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
return 1;
}
-extern void sub_080044AE(Entity*, u32, u32);
-
void sub_08081FF8(Entity* this) {
u32 direction;
u32 i;
diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c
index 921b0b97..f68a531d 100644
--- a/src/object/fileScreenObjects.c
+++ b/src/object/fileScreenObjects.c
@@ -256,7 +256,7 @@ void sub_0808EB74(Entity* this) {
this->x.WORD = entity->x.WORD;
this->y.WORD = entity->y.WORD;
this->spriteRendering.b3 = entity->spriteRendering.b3;
- ResolveEntityBelow(entity, this);
+ SortEntityBelow(entity, this);
} else {
this->x.HALF.HI = 0xF000;
this->y.HALF.HI = 0xF000;
@@ -306,7 +306,7 @@ void sub_0808EBB8(Entity* this) {
default:
entity = sub_0808EC80(var0);
if (entity) {
- ResolveEntityBelow(entity, this);
+ SortEntityBelow(entity, this);
this->spriteRendering.b3 = entity->spriteRendering.b3;
x = entity->x.HALF.HI;
y = entity->y.HALF.HI;
@@ -322,7 +322,7 @@ static Entity* sub_0808EC80(int form) {
Entity* entityA = (Entity*)&gEntityLists[6];
Entity* entityB = entityA->next;
while (entityB != entityA) {
- if ((entityB->kind == 0x6 && entityB->id == 0x48) && form == entityB->type) {
+ if ((entityB->kind == OBJECT && entityB->id == 0x48) && form == entityB->type) {
return entityB;
}
entityB = entityB->next;
diff --git a/src/object/furniture.c b/src/object/furniture.c
index c625d1fb..5683156c 100644
--- a/src/object/furniture.c
+++ b/src/object/furniture.c
@@ -5,7 +5,6 @@
#include "object.h"
extern void sub_080001D0(u32, u32, u32);
-extern u32 sub_080001DA(u32, u32);
enum {
FURNITURE_INIT,
@@ -220,7 +219,7 @@ static void FurnitureInit(FurnitureEntity* this) {
case SMITH_FORGE:
e = CreateObject(FURNITURE, FORGE_HELPER, 0);
if (e != NULL) {
- PositionRelative(super, e, 0x100000, 0x100000);
+ PositionRelative(super, e, Q_16_16(16.0), Q_16_16(16.0));
e->frameIndex = 1;
e->updatePriority = PRIO_MESSAGE;
}
@@ -374,7 +373,7 @@ static void sub_08090B6C(FurnitureEntity* this) {
}
static void sub_08090CDC(u32 id, u32 pos, u32 layer) {
- u16 cur = sub_080001DA(pos, layer);
+ u16 cur = GetTileIndex(pos, layer);
u32 next = cur;
u32 id2;
@@ -451,7 +450,7 @@ static void sub_08090E4C(FurnitureEntity* this) {
void sub_08090E64(FurnitureEntity* this) {
Entity* e = CreateObject(OBJECT_2A, 0, 0);
if (e != NULL) {
- PositionRelative(super, e, (s16)((u16)-2 + super->type2) * 0x10000, 0);
+ PositionRelative(super, e, Q_16_16((s16)((u16)-2 + super->type2)), 0);
e->z.HALF.HI -= 16;
e->collisionLayer = 2;
UpdateSpriteForCollisionLayer(e);
diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c
index 3a1f9a13..70210ffa 100644
--- a/src/object/greatFairy.c
+++ b/src/object/greatFairy.c
@@ -92,8 +92,8 @@ void GreatFairy_DormantUpdate(Entity* this) {
case 289:
ripple = GreatFairy_CreateForm(this, RIPPLE, 0);
if (ripple) {
- PositionRelative(this, ripple, (s32)GreatFairy_RippleOffsets[this->actionDelay] * 65536,
- (s32)GreatFairy_RippleOffsets[this->actionDelay + 1] * 65536);
+ PositionRelative(this, ripple, Q_16_16(GreatFairy_RippleOffsets[this->actionDelay]),
+ Q_16_16(GreatFairy_RippleOffsets[this->actionDelay + 1]));
this->actionDelay += 2;
break;
}
@@ -105,7 +105,7 @@ void GreatFairy_CreateBigRipple(Entity* this) {
ripple = GreatFairy_CreateForm(this, BIGRIPPLE, 0);
if (ripple != NULL) {
- PositionRelative(this, ripple, 0, 0x80000);
+ PositionRelative(this, ripple, 0, Q_16_16(8.0));
this->action = 3;
}
}
@@ -137,7 +137,7 @@ void GreatFairy_MiniUpdate(Entity* this) {
} else {
target = GreatFairy_CreateForm(this, WINGS, 0);
if (target != NULL) {
- PositionRelative(this, target, 0, -0x140000);
+ PositionRelative(this, target, 0, Q_16_16(-20.0));
this->action = 5;
this->actionDelay = 120;
this->field_0xf = 0;
@@ -153,7 +153,7 @@ void GreatFairy_FinalUpdate(Entity* this) {
--this->actionDelay;
} else {
if ((this->field_0xf == 0) && (target = GreatFairy_CreateForm(this, FORM9, 0), target != NULL)) {
- PositionRelative(this, target, 0, -0x4C0000);
+ PositionRelative(this, target, 0, Q_16_16(-76.0));
target->parent = this;
this->field_0xf = 1;
}
@@ -236,7 +236,7 @@ void GreatFairy_MiniRisingUpdate(Entity* this) {
} else {
if (((this->z.HALF.HI == -10) && (this->field_0xf == 0)) &&
(target = GreatFairy_CreateForm(this, DROPLET, 0), target != NULL)) {
- PositionRelative(this, target, 0, 0x40000);
+ PositionRelative(this, target, 0, Q_16_16(4.0));
this->field_0xf = 1;
}
}
@@ -350,7 +350,7 @@ void GreatFairy_BigRippleUpdate(Entity* this) {
} else {
target = GreatFairy_CreateForm(this, MINI, 0);
if (target != NULL) {
- PositionRelative(this, target, 0, -0x80000);
+ PositionRelative(this, target, 0, Q_16_16(-8.0));
gRoomVars.animFlags |= 2;
DeleteEntity(this);
}
diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c
index ea0dc245..3bef5d5f 100644
--- a/src/object/gyorgBossObject.c
+++ b/src/object/gyorgBossObject.c
@@ -418,7 +418,8 @@ void sub_080A1FF0(GyorgBossObjectEntity* this) {
}
}
if (this->unk_7b) {
- if (sub_0806FCB8(&gPlayerEntity, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, 0x100)) {
+ if (EntityWithinDistance(&gPlayerEntity, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210,
+ 0x100)) {
if (super->actionDelay == 0) {
super->actionDelay = 0x78;
} else {
diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c
index 9e8346b3..a81709c4 100644
--- a/src/object/heartContainer.c
+++ b/src/object/heartContainer.c
@@ -59,7 +59,7 @@ static void sub_0808E714(Entity* this) {
static void sub_0808E764(Entity* this) {
sub_08080CB4(this);
- if (!(gPlayerState.flags & PL_MINISH) && sub_08017850(this)) {
+ if (!(gPlayerState.flags & PL_MINISH) && IsCollidingPlayer(this)) {
SetFlag(this->cutsceneBeh.HWORD);
CreateItemEntity(0x62, 0, 0);
DeleteThisEntity();
diff --git a/src/object/hittableLever.c b/src/object/hittableLever.c
new file mode 100644
index 00000000..401e9671
--- /dev/null
+++ b/src/object/hittableLever.c
@@ -0,0 +1,79 @@
+/**
+ * @file hittableLever.c
+ * @ingroup Objects
+ *
+ * @brief Hittable Lever object
+ */
+
+#define NENT_DEPRECATED
+#include "global.h"
+#include "object.h"
+#include "functions.h"
+
+typedef struct {
+ /*0x00*/ Entity base;
+ /*0x68*/ u8 unk_68[8];
+ /*0x70*/ u16 wasHit; /**< Has this lever been hit before. */
+ /*0x72*/ u8 unk_72[0x14];
+ /*0x86*/ u16 hitFlag;
+} HittableLeverEntity;
+
+extern void (*const HittableLever_Actions[])(HittableLeverEntity*);
+extern const Hitbox HittableLever_Hitbox;
+
+void HittableLever_UpdateTile(HittableLeverEntity*);
+
+void HittableLever(HittableLeverEntity* this) {
+ if (super->iframes == 0) {
+ this->wasHit = 0;
+ }
+ HittableLever_Actions[super->action](this);
+}
+
+void HittableLever_Init(HittableLeverEntity* this) {
+ super->action = 1;
+ super->flags |= ENT_COLLIDE;
+ super->field_0x3c = 7;
+ super->hitType = 0x8f;
+ super->flags2 = 0xa;
+ super->hitbox = (Hitbox*)&HittableLever_Hitbox;
+ if (super->type == 0) {
+ if (CheckFlags(this->hitFlag)) {
+ super->type = 1;
+ } else {
+ super->type = 0;
+ }
+ } else {
+ SetFlag(this->hitFlag);
+ }
+ HittableLever_UpdateTile(this);
+}
+
+void HittableLever_Idle(HittableLeverEntity* this) {
+ if (((super->bitfield & 0x80) != 0) && (this->wasHit == 0)) {
+ this->wasHit = 1;
+ super->type ^= 1;
+ super->iframes = -0x18;
+ HittableLever_UpdateTile(this);
+ if (CheckFlags(this->hitFlag)) {
+ ClearFlag(this->hitFlag);
+ } else {
+ SetFlag(this->hitFlag);
+ }
+ SoundReqClipped(super, SFX_117);
+ }
+}
+
+void HittableLever_UpdateTile(HittableLeverEntity* this) {
+ if (super->type != 0) {
+ sub_0807B7D8(0x378, COORD_TO_TILE(super), super->collisionLayer);
+ } else {
+ sub_0807B7D8(0x377, COORD_TO_TILE(super), super->collisionLayer);
+ }
+}
+
+void (*const HittableLever_Actions[])(HittableLeverEntity*) = {
+ HittableLever_Init,
+ HittableLever_Idle,
+};
+const Hitbox HittableLever_Hitbox = { 0, 1, { 0, 0, 0, 0 }, 4, 3 };
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index a1495848..92ba70b8 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -105,7 +105,7 @@ void sub_0808681C(Entity* this) {
this->action = 2;
this->frameIndex = 1;
}
- if (this->flags & 0x2) {
+ if (this->flags & ENT_SCRIPTED) {
this->action = 2;
}
break;
@@ -119,7 +119,7 @@ void sub_0808681C(Entity* this) {
break;
}
- if (this->flags & 0x2) {
+ if (this->flags & ENT_SCRIPTED) {
ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh);
sub_080868EC(this, *(void**)&this->cutsceneBeh);
}
@@ -158,7 +158,7 @@ static void sub_080868EC(Entity* entity, unk_80868EC* arg1) {
}
void sub_0808692C(Entity* this) {
- this->flags &= 0xFD;
+ this->flags &= ~ENT_SCRIPTED;
this->type2 = 2;
this->action = this->frameIndex == 0 ? 1 : 2;
this->subAction = 0;
diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c
index 35cb741b..2643ade9 100644
--- a/src/object/itemOnGround.c
+++ b/src/object/itemOnGround.c
@@ -18,7 +18,7 @@ void sub_080813BC(Entity*);
void sub_080810FC(Entity*);
bool32 CheckShouldPlayItemGetCutscene(Entity*);
-extern u32 sub_080177A0(Entity*, Entity*);
+extern u32 IsColliding(Entity*, Entity*);
extern void GiveItem(u32, u32);
extern void (*const gUnk_0811E7D4[])(Entity*);
@@ -149,7 +149,7 @@ void sub_080810A8(Entity* this) {
}
if (this->zVelocity == 0) {
- this->zVelocity = 0x1E000;
+ this->zVelocity = Q_16_16(1.875);
}
if (this->collisionLayer == 2) {
@@ -269,10 +269,10 @@ void sub_080812A8(Entity* this) {
void sub_080812E8(Entity* this) {
PlayerState* playerState = &gPlayerState;
#ifdef EU
- if ((playerState->swim_state & 0x80) && sub_080177A0(this, &gPlayerEntity)) {
+ if ((playerState->swim_state & 0x80) && IsColliding(this, &gPlayerEntity)) {
#else
if ((playerState->swim_state & 0x80) && (playerState->flags & PL_MINISH) == 0 &&
- sub_080177A0(this, &gPlayerEntity)) {
+ IsColliding(this, &gPlayerEntity)) {
#endif
sub_080810FC(this);
}
@@ -283,13 +283,13 @@ void nullsub_510(Entity* this) {
void sub_08081328(Entity* this) {
Entity* other = this->child;
- if (!(other->kind == 8 && other->id == 3)) {
+ if (!(other->kind == PLAYER_ITEM && other->id == 3)) {
sub_08081404(this, 0);
} else {
CopyPosition(other, this);
this->z.HALF.HI--;
other = &gPlayerEntity;
- if (sub_080177A0(this, other)) {
+ if (IsColliding(this, other)) {
sub_080810FC(this);
}
}
@@ -412,7 +412,7 @@ void sub_0808153C(Entity* this) {
if (this->field_0x68.HALF.LO == 0) {
if (!GravityUpdate(this, 0x1000) && !sub_0800442E(this)) {
this->field_0x68.HALF.LO = 1;
- this->zVelocity = 0x1E000;
+ this->zVelocity = Q_16_16(1.875);
sub_0808148C(this->type);
UpdateSpriteForCollisionLayer(this);
}
@@ -432,7 +432,7 @@ void sub_08081598(Entity* this) {
COLLISION_OFF(this);
this->action = 4;
this->actionDelay = 14;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->spriteSettings.draw = 1;
this->spritePriority.b1 = 2;
this->spritePriority.b0 = 3;
diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c
index 61ebb19a..a482621d 100644
--- a/src/object/jarPortal.c
+++ b/src/object/jarPortal.c
@@ -60,7 +60,7 @@ void sub_0808BF58(Entity* this) {
GravityUpdate(this, 0x2000);
switch (this->subAction) {
case 0:
- if (this->zVelocity <= 98303) {
+ if (this->zVelocity < Q_16_16(1.5)) {
++this->subAction;
InitAnimationForceUpdate(this, 2);
}
@@ -69,7 +69,7 @@ void sub_0808BF58(Entity* this) {
UpdateAnimationSingleFrame(this);
if (!this->z.HALF.HI) {
++this->subAction;
- this->zVelocity = 0x8000;
+ this->zVelocity = Q_16_16(0.5);
}
break;
case 2:
@@ -128,7 +128,7 @@ void sub_0808C0AC(Entity* this) {
GravityUpdate(this, 0x2000);
switch (this->subAction) {
case 0:
- if (this->zVelocity <= 98303) {
+ if (this->zVelocity < Q_16_16(1.5)) {
this->subAction = 1;
InitAnimationForceUpdate(this, 3);
}
@@ -137,7 +137,7 @@ void sub_0808C0AC(Entity* this) {
UpdateAnimationSingleFrame(this);
if (!this->z.HALF.HI) {
++this->subAction;
- this->zVelocity = 0x8000;
+ this->zVelocity = Q_16_16(0.5);
}
break;
case 2:
@@ -157,7 +157,7 @@ u32 sub_0808C128(Entity* this) {
void sub_0808C13C(Entity* this) {
this->subAction = 0;
- this->zVelocity = 163840;
+ this->zVelocity = Q_16_16(2.5);
}
void sub_0808C148(Entity* this, u32 a2) {
diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c
index 639ffa17..a8d9dffd 100644
--- a/src/object/lightableSwitch.c
+++ b/src/object/lightableSwitch.c
@@ -48,7 +48,7 @@ void sub_0809EA80(Entity* this) {
} else {
SetFlag(this->field_0x86.HWORD);
}
- EnqueueSFX(0x110);
+ EnqueueSFX(SFX_110);
}
sub_0809EABC(this);
}
@@ -121,7 +121,7 @@ void sub_0809EBD8(Entity* this) {
this->actionDelay = 0x10;
this->frameIndex = 2;
SetFlag(this->field_0x86.HWORD);
- EnqueueSFX(0x110);
+ EnqueueSFX(SFX_110);
}
}
@@ -135,7 +135,7 @@ void sub_0809EC08(Entity* this) {
this->action = 1;
this->frameIndex = 3;
ClearFlag(this->field_0x86.HWORD);
- EnqueueSFX(0x110);
+ EnqueueSFX(SFX_110);
}
}
}
diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c
new file mode 100644
index 00000000..9a7fe9d4
--- /dev/null
+++ b/src/object/lilypadLarge.c
@@ -0,0 +1,385 @@
+/**
+ * @file lilypadLarge.c
+ * @ingroup Objects
+ *
+ * @brief Large Lilypad object
+ */
+
+#define NENT_DEPRECATED
+#include "global.h"
+#include "area.h"
+#include "functions.h"
+#include "item.h"
+#include "object.h"
+
+typedef struct {
+ Entity base;
+ u8 unk_68[4];
+ s32 unk_6c;
+ s32 unk_70;
+ s16 unk_74;
+ s16 unk_76;
+ union SplitWord unk_78;
+ union SplitWord unk_7c;
+ u8 unk_80[2];
+ u16 unk_82;
+ u8 unk_84;
+ u8 unk_85;
+} LilypadLargeEntity;
+
+extern void (*const gUnk_08120608[])(LilypadLargeEntity*);
+extern Hitbox gUnk_08120640;
+extern void (*const gUnk_0812062C[])(LilypadLargeEntity*);
+extern u8 gUnk_08120638[];
+extern u8 gUnk_08126EE4[];
+extern u32 gUnk_08120620[];
+
+void sub_080855E8(LilypadLargeEntity*);
+void sub_08085CDC(LilypadLargeEntity*);
+void sub_08085EFC(LilypadLargeEntity*);
+void sub_08085F1C(LilypadLargeEntity*);
+void sub_08085E74(LilypadLargeEntity*);
+void sub_08085F48(LilypadLargeEntity*);
+void sub_08085D28(LilypadLargeEntity*);
+void sub_08085D60(LilypadLargeEntity*);
+
+void LilypadLarge(LilypadLargeEntity* this) {
+ gUnk_08120608[super->action](this);
+}
+
+void sub_08085504(LilypadLargeEntity* this) {
+ if (super->type == 0xff) {
+ if (GetInventoryValue(ITEM_FLIPPERS)) {
+ DeleteThisEntity();
+ }
+ super->type = 0;
+ }
+ if (super->type != 0) {
+ if (gArea.locationIndex == 0x1b) {
+ if (CheckLocalFlag(super->type2) == 0) {
+ DeleteThisEntity();
+ }
+ } else {
+ if (CheckLocalFlag(super->type2) == 0) {
+ super->action = 5;
+ return;
+ }
+ }
+ }
+ if (super->actionDelay != 0) {
+ if (sub_080040A2(super) == 0) {
+ DeleteThisEntity();
+ }
+ super->actionDelay = 0;
+ } else {
+ if (EntityHasDuplicateID(super) != 0) {
+ DeleteThisEntity();
+ }
+ }
+ super->action = 1;
+ super->speed = 0x100;
+ super->spritePriority.b0 = 6;
+ super->hitbox = &gUnk_08120640;
+ super->flags |= ENT_COLLIDE;
+ super->field_0x3c = 7;
+ super->hitType = 1;
+ super->flags2 = 4;
+ this->unk_78.WORD = 0x1000000;
+ this->unk_7c.HALF_U.HI = 0x1000;
+ this->unk_85 = 0;
+ this->unk_84 = 0;
+ InitializeAnimation(super, 9);
+ sub_080855E8(this);
+}
+
+ASM_FUNC("asm/non_matching/lilypadLarge/sub_080855E8.inc", void sub_080855E8(LilypadLargeEntity* this));
+
+void sub_08085A1C(LilypadLargeEntity* this) {
+ gUnk_0812062C[super->subAction](this);
+ gPlayerState.flags |= 2;
+ sub_08078B48();
+}
+
+void sub_08085A44(LilypadLargeEntity* this) {
+ super->speed = 0x200;
+ if (sub_080002B4(super, 0x10, 0x18) != 0x11) {
+ super->direction = 0x18;
+ } else {
+ if (sub_080002B4(super, 0xfffffff0, 0x18) != 0x11) {
+ super->direction = 8;
+ } else {
+ super->direction = 0x10;
+ super->subAction = 1;
+ return;
+ }
+ }
+ sub_08085EFC(this);
+ sub_080AF134(super);
+ sub_08085F1C(this);
+}
+
+void sub_08085A98(LilypadLargeEntity* this) {
+ sub_08085EFC(this);
+ LinearMoveUpdate(super);
+ sub_08085F1C(this);
+ if (0x7fffff < (u32)this->unk_78.WORD) {
+ this->unk_78.WORD -= 0x20000;
+ sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI);
+ }
+ if (sub_080002B4(super, 0, 0x18) != 0x11) {
+ super->subAction = 2;
+ if (gArea.locationIndex == 0x1b) {
+ super->y.HALF.HI += 0xd0;
+ super->z.HALF.HI = 0xff30;
+ this->unk_82 = 0x46;
+ SetLocalFlag(0x73);
+ } else {
+ super->y.HALF.HI += 0x40;
+ super->z.HALF.HI = 0xffc0;
+ this->unk_82 = 0xf;
+ }
+ CreateObjectWithParent(super, OBJECT_2B, 0, 0);
+ SoundReq(SFX_12D);
+ }
+}
+
+void sub_08085B40(LilypadLargeEntity* this) {
+ if (super->z.WORD != 0) {
+ if (GravityUpdate(super, 0x2000) != 0) {
+ if ((u32)this->unk_78.WORD < 0x1200000) {
+ this->unk_78.WORD += 0x100000;
+ sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI);
+ }
+ gPlayerEntity.y.HALF.HI = (super->y.HALF.HI + super->z.HALF.HI) - this->unk_74;
+ if (gArea.locationIndex == 0x1b) {
+ gPlayerEntity.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0xd0 - gPlayerEntity.y.HALF.HI;
+ } else {
+ gPlayerEntity.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0x40 - gPlayerEntity.y.HALF.HI;
+ }
+ }
+ } else {
+ ResetCollisionLayer(super);
+ if (sub_080002B8(super) == 0xd) {
+ ResetCollisionLayer(&gPlayerEntity);
+ sub_08085CDC(this);
+ super->direction = GetFacingDirection(&gPlayerEntity, super);
+ LinearMoveDirection(&gPlayerEntity, 0x100, super->direction);
+ }
+ }
+
+ if (this->unk_82 == 0) {
+ if (GravityUpdate(&gPlayerEntity, 0x2000) == 0) {
+ ResetCollisionLayer(&gPlayerEntity);
+ sub_08085F1C(this);
+ super->action = 1;
+ super->field_0xf = 4;
+ while (super->field_0xf != 0) {
+ sub_080A2AF4(super, 8, 10);
+ super->field_0xf--;
+ }
+ super->field_0xf = 1;
+ super->actionDelay |= 0x80;
+ this->unk_70 = 0;
+ this->unk_6c = 0;
+ if (sub_080002B8(super) == 0xd) {
+ super->action = 4;
+ }
+ }
+ } else {
+ this->unk_82--;
+ }
+}
+
+void sub_08085C5C(LilypadLargeEntity* this) {
+ if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) {
+ LinearMoveUpdate(super);
+ gPlayerEntity.speed = super->speed;
+ gPlayerEntity.direction = super->direction;
+ LinearMoveUpdate(&gPlayerEntity);
+ gPlayerState.flags |= 2;
+ if (super->collisionLayer == 1) {
+ ResetCollisionLayer(&gPlayerEntity);
+ } else {
+ sub_08004542(&gPlayerEntity);
+ }
+ }
+ if (gRoomControls.reload_flags == 0) {
+ super->flags &= ~ENT_PERSIST;
+ super->action = 1;
+ super->updatePriority = super->updatePriorityPrev;
+ gRoomControls.camera_target = &gPlayerEntity;
+ }
+}
+
+void sub_08085CDC(LilypadLargeEntity* this) {
+ this->unk_78.WORD += 0x100000;
+ if (this->unk_78.WORD_U < 0x4000000) {
+ sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI);
+ } else {
+ DeleteThisEntity();
+ }
+}
+
+void sub_08085D10(LilypadLargeEntity* this) {
+ if (EntityHasDuplicateID(super) != 0) {
+ SetLocalFlag(super->type2);
+ DeleteThisEntity();
+ }
+}
+
+void sub_08085D28(LilypadLargeEntity* this) {
+ if (((gPlayerState.framestate != PL_STATE_TALKEZLO) && ((gPlayerState.flags & 2) != 0)) &&
+ (sub_080002B4(super, 0, 0x18) == 0x11)) {
+ super->action = 2;
+ super->subAction = 0;
+ sub_08078B48();
+ }
+}
+
+NONMATCH("asm/non_matching/lilypadLarge/sub_08085D60.inc", void sub_08085D60(LilypadLargeEntity* this)) {
+ u32 r4; // horizontal direction?
+ u32 r6; // vertical direction?
+ if ((gPlayerState.flags & 2) != 0) {
+ if (gPlayerState.framestate != PL_STATE_DIE) {
+ if (gPlayerState.jump_status == 0) {
+ if ((super->direction & 7) == 0) { // North or South
+ r4 = super->direction;
+ r6 = super->direction;
+ } else {
+ if ((super->direction & 0x10) != 0) { // South(already top) or West
+ r4 = DirectionWest;
+ } else {
+ r4 = DirectionEast;
+ }
+ if (super->direction - 8 > 0x10) { // North(already top) or West(?)
+ r6 = DirectionNorth;
+ } else {
+ r6 = DirectionSouth;
+ }
+ }
+ if (r4 == DirectionWest || r4 == DirectionEast) { // Handle horizontal
+ u32 tmp = r4 >> 2;
+ s32 tmpX = gUnk_08120638[tmp];
+ s32 tmpY = gUnk_08120638[tmp + 1];
+ if (sub_080002CC(super, tmpX, tmpY) == 0xff) {
+
+ if (sub_080806BC((super->x.HALF.HI - gRoomControls.origin_x) + tmpX,
+ (super->y.HALF.HI - gRoomControls.origin_y) + tmpY, r4, 5) == 0) {
+ if (sub_0807BD14(&gPlayerEntity, r4 >> 3) != 0) {
+ super->direction = r4;
+ sub_08085E74(this);
+ return;
+ }
+ } else {
+ super->direction = r4;
+ return;
+ }
+ }
+ }
+ if (r6 == DirectionNorth || r6 == DirectionSouth) { // Handle vertical
+ u32 tmp = r6 >> 2;
+ s32 tmpX = (u8)gUnk_08120638[tmp];
+ s32 tmpY = gUnk_08120638[tmp + 1];
+ if (sub_080002CC(super, tmpX, tmpY) == 0xff) {
+ if (sub_0807BD14(&gPlayerEntity, r6 >> 3) != 0) {
+ super->direction = (u8)r6;
+ sub_08085E74(this);
+ }
+ }
+ }
+ return;
+ }
+ }
+ }
+ super->flags &= ~ENT_PERSIST;
+}
+END_NONMATCH
+
+void sub_08085E74(LilypadLargeEntity* this) {
+ super->flags |= ENT_PERSIST;
+ super->updatePriority = 6;
+ super->action = 3;
+ switch (super->direction) {
+ case DirectionNorth:
+ super->speed = 0x120;
+ break;
+ case DirectionSouth:
+ super->speed = 0x138;
+ break;
+ case DirectionEast:
+ case DirectionWest:
+ super->speed = 0x100;
+ break;
+ }
+ this->unk_70 = 0;
+ this->unk_6c = 0;
+ super->x.HALF.LO = 0;
+ super->y.HALF.LO = 0;
+ gPlayerEntity.x.HALF.LO = 0;
+ gPlayerEntity.y.HALF.LO = 0;
+ gPlayerEntity.direction = super->direction;
+ gPlayerState.animation = 0x100;
+ gRoomControls.camera_target = super;
+ if (gPlayerState.item != NULL) {
+ DeleteEntity(gPlayerState.item);
+ }
+ ResetPlayer();
+}
+
+void sub_08085EFC(LilypadLargeEntity* this) {
+ this->unk_76 = super->x.HALF.HI - gPlayerEntity.x.HALF.HI;
+ this->unk_74 = super->y.HALF.HI - gPlayerEntity.y.HALF.HI;
+}
+
+void sub_08085F1C(LilypadLargeEntity* this) {
+ gPlayerEntity.x.HALF.HI = super->x.HALF.HI - this->unk_76;
+ gPlayerEntity.y.HALF.HI = super->y.HALF.HI - this->unk_74;
+ sub_0807A5B8(super->direction);
+}
+
+void sub_08085F48(LilypadLargeEntity* this) {
+ u32 tmp = super->actionDelay & 0x80;
+ if (tmp != 0) {
+ if (gPlayerState.floor_type == 0x17) {
+ ResetPlayerVelocity();
+ gPlayerState.floor_type = 0x19;
+ }
+ SoundReq(SFX_WATER_WALK);
+ if (this->unk_78.WORD_U < 0x1280000) {
+ this->unk_78.WORD_U += 0x80000;
+ } else {
+ super->actionDelay = 0;
+ }
+ } else {
+ if ((gPlayerState.flags & 2) != 0) {
+ if (super->actionDelay != 0) {
+ if (this->unk_78.WORD_U < 0x1200000) {
+ this->unk_78.WORD_U += 0x8000;
+ } else {
+ super->actionDelay = tmp;
+ }
+ } else {
+ if (this->unk_78.WORD_U > 0x1100000) {
+ this->unk_78.WORD_U -= 0x8000;
+ } else {
+ super->actionDelay = 1;
+ }
+ }
+ } else {
+ if (super->actionDelay != 0) {
+ if (this->unk_78.WORD_U < 0x1100000) {
+ this->unk_78.WORD_U += 0x4000;
+ } else {
+ super->actionDelay = 0;
+ }
+ } else {
+ if (this->unk_78.WORD_U > 0x1060000) {
+ this->unk_78.WORD_U -= 0x4000;
+ } else {
+ super->actionDelay = 1;
+ }
+ }
+ }
+ }
+ sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI);
+}
diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c
index 5ebe073f..74cb0e55 100644
--- a/src/object/lockedDoor.c
+++ b/src/object/lockedDoor.c
@@ -37,7 +37,6 @@ void LockedDoor(Entity* this) {
extern Hitbox gHitbox_2;
-extern u32 sub_080001DA(u32, u32);
extern void sub_08078850(Entity*, u32, u32, u32);
typedef struct PACKED {
@@ -102,7 +101,7 @@ void sub_08083338(Entity* this) {
this->spritePriority.b0 = 5;
this->frame = this->type & 0xF;
this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI);
- this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer);
+ this->field_0x74.HWORD = GetTileIndex(this->field_0x76.HWORD, this->collisionLayer);
switch (this->type2) {
case 0:
if (!CheckFlags(this->field_0x86.HWORD)) {
@@ -149,7 +148,7 @@ void sub_080834B4(Entity* this) {
this->action = 2;
this->actionDelay = 7;
SetTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer);
- EnqueueSFX(0x10b);
+ EnqueueSFX(SFX_10B);
}
}
@@ -185,7 +184,7 @@ void sub_08083540(Entity* this) {
}
}
sub_08083814(this, this->field_0x7c.BYTES.byte2);
- EnqueueSFX(0x10b);
+ EnqueueSFX(SFX_10B);
}
}
diff --git a/src/object/mask.c b/src/object/mask.c
index 4e9810c3..00c9e957 100644
--- a/src/object/mask.c
+++ b/src/object/mask.c
@@ -4,8 +4,6 @@
extern void (*MaskActionFuncs[])(Entity*);
extern void sub_08000148(u16, u16, u32);
-extern s16 sub_080001DA(u16, u32);
-extern u16 sub_080002E0(u16, u32);
extern void sub_0805457C(Entity*, s32);
@@ -40,7 +38,7 @@ void sub_080929A4(Entity* this) {
}
this->action = 1;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
this->field_0x78.HWORD = ((Random() & 7) << 10) | 0x2000;
@@ -49,10 +47,10 @@ void sub_080929A4(Entity* this) {
this->frameIndex = this->type2 & 0x3f;
- this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
- this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1);
+ this->field_0x7c.HALF_U.HI = COORD_TO_TILE(this);
+ this->field_0x7c.HALF_U.LO = GetTileIndex(this->field_0x7c.HALF_U.HI, 1);
- this->field_0x7a.HWORD = sub_080002E0(this->field_0x7c.HALF.HI, 1);
+ this->field_0x7a.HWORD = sub_080002E0((u16)this->field_0x7c.HALF.HI, 1);
SetTile(0x4022, this->field_0x7c.HALF_U.HI, 1);
}
@@ -60,7 +58,7 @@ void sub_080929A4(Entity* this) {
// Probably related to knocking it down
void sub_08092A94(Entity* this) {
// Check for the first frame of bonking animation
- if (gPlayerEntity.action != 6) {
+ if (gPlayerEntity.action != PLAYER_BOUNCE) {
return;
}
@@ -99,7 +97,7 @@ void sub_08092B0C(Entity* this) {
this->actionDelay = 0;
switch (this->type2 & 0xC0) {
case 0x80:
- EnqueueSFX(0x72);
+ EnqueueSFX(SFX_SECRET);
case 0x40:
SetFlag(this->field_0x86.HWORD);
break;
diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c
index ed89d276..2146a801 100644
--- a/src/object/metalDoor.c
+++ b/src/object/metalDoor.c
@@ -10,7 +10,6 @@
extern u32 sub_08083734(Entity*, u32);
extern void sub_080A080C(Entity*);
extern void sub_080A0870(Entity*);
-extern u32 sub_080001DA(u32, u32);
extern void (*const gUnk_0812493C[])(Entity*);
@@ -68,7 +67,7 @@ void sub_080A074C(Entity* this) {
ent->x.HALF.HI -= 0xc;
ent->y.HALF.HI -= 0xc;
}
- EnqueueSFX(0x10b);
+ EnqueueSFX(SFX_10B);
}
}
@@ -93,9 +92,9 @@ void sub_080A07F0(Entity* this) {
}
void sub_080A080C(Entity* this) {
- this->field_0x76.HWORD = sub_080001DA(this->field_0x74.HWORD - 1, this->collisionLayer);
- this->field_0x78.HWORD = sub_080001DA(this->field_0x74.HWORD, this->collisionLayer);
- this->field_0x7a.HWORD = sub_080001DA(this->field_0x74.HWORD + 1, this->collisionLayer);
+ this->field_0x76.HWORD = GetTileIndex(this->field_0x74.HWORD - 1, this->collisionLayer);
+ this->field_0x78.HWORD = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer);
+ this->field_0x7a.HWORD = GetTileIndex(this->field_0x74.HWORD + 1, this->collisionLayer);
SetTile(0x4022, this->field_0x74.HWORD - 1, this->collisionLayer);
SetTile(0x4022, this->field_0x74.HWORD, this->collisionLayer);
SetTile(0x4022, this->field_0x74.HWORD + 1, this->collisionLayer);
diff --git a/src/object/minecart.c b/src/object/minecart.c
index fee9da56..0de7e4c3 100644
--- a/src/object/minecart.c
+++ b/src/object/minecart.c
@@ -2,7 +2,6 @@
#include "functions.h"
extern u32 sub_08091DDC(Entity*);
-extern u32 sub_080002B4(Entity*, u32, u32);
extern u32 sub_08007DD6(u32, u32);
extern void sub_08017744(Entity*);
extern void sub_08091C0C(Entity*);
@@ -46,7 +45,7 @@ void sub_080916EC(Entity* this) {
void sub_080917DC(Entity* this) {
if ((this->bitfield & 0x7f) == 0x1d) {
- this->zVelocity = 0x2a000;
+ this->zVelocity = Q_16_16(2.625);
this->action = 7;
InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState);
SoundReq(SFX_13B);
@@ -66,7 +65,7 @@ void sub_080917DC(Entity* this) {
this->action++;
gPlayerState.jump_status = 0x81;
gPlayerState.flags |= PL_ENTER_MINECART;
- gPlayerEntity.zVelocity = 0x20000;
+ gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerEntity.speed = 0x100;
gPlayerEntity.flags &= ~PL_MINISH;
ResetPlayer();
@@ -161,7 +160,7 @@ void sub_080919AC(Entity* this) {
sub_08017744(this);
gPlayerState.jump_status = 0x41;
gPlayerState.flags = (gPlayerState.flags ^ PL_IN_MINECART) | PL_ENTER_MINECART;
- gPlayerEntity.zVelocity = 0x20000;
+ gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerEntity.speed = 0x200;
gPlayerEntity.animationState = this->animationState << 1;
gPlayerEntity.direction = this->direction;
diff --git a/src/object/object2A.c b/src/object/object2A.c
index 5ef7ba3e..743eb305 100644
--- a/src/object/object2A.c
+++ b/src/object/object2A.c
@@ -4,13 +4,15 @@
#include "functions.h"
#include "flags.h"
-extern void (*const gUnk_08120DD0[])(Entity*);
+extern void sub_0807AB44(Entity*, s32, s32);
+
+void (*const gUnk_08120DD0[])(Entity*);
void Object2A(Entity* this) {
gUnk_08120DD0[this->action](this);
}
-void sub_08089B18(Entity* this) {
+void Object2A_Init(Entity* this) {
this->action = 1;
this->spriteSettings.draw = TRUE;
if (this->type2 != 0) {
@@ -36,5 +38,61 @@ void sub_08089B18(Entity* this) {
return;
}
}
- EnqueueSFX(0x124);
+ EnqueueSFX(SFX_124);
}
+
+void sub_08089BA0(Entity* this) {
+ u32 val;
+ GetNextFrame(this);
+
+ switch (this->type) {
+ case 0:
+ default:
+ if (this->type2 == 0)
+ return;
+ case 1:
+ case 2:
+ if (--this->actionDelay != 0xff)
+ return;
+ if (this->type == 2) {
+ sub_0807B7D8(((u16*)this->child)[3], COORD_TO_TILE(this), this->collisionLayer);
+ sub_0807AB44(this, 0, 0x10);
+ sub_0807AB44(this, 0, -0x10);
+ sub_0807AB44(this, 0x10, 0);
+ sub_0807AB44(this, -0x10, 0);
+ }
+ DeleteThisEntity();
+ break;
+ case 3:
+ if (this->parent->next == NULL) {
+ DeleteThisEntity();
+ }
+ if (--this->actionDelay == 0) {
+ DeleteThisEntity();
+ }
+
+ CopyPosition(this->parent, this);
+ break;
+ case 4:
+ val = CheckFlags(this->field_0x86.HWORD);
+ if (this->subAction == 0) {
+ if (val)
+ return;
+ this->subAction = 1;
+ this->spriteSettings.draw = 0;
+ } else {
+ if (!val)
+ return;
+ this->subAction = 0;
+ this->spriteSettings.draw = 1;
+ InitializeAnimation(this, 0);
+ EnqueueSFX(SFX_124);
+ }
+ break;
+ }
+}
+
+void (*const gUnk_08120DD0[])(Entity*) = {
+ Object2A_Init,
+ sub_08089BA0,
+};
diff --git a/src/object/object49.c b/src/object/object49.c
index f1873fc2..c65b41bf 100644
--- a/src/object/object49.c
+++ b/src/object/object49.c
@@ -178,14 +178,14 @@ void sub_0808F3DC(Entity* this) {
// TODO: This block of code might supposed to be a switch statement.
if (this->type != 8) {
if (this->type == 7) {
- ResolveEntityBelow(this->child, this);
+ SortEntityBelow(this->child, this);
return;
}
} else {
this->hitType = this->child->hitType;
this->child->hitType = 0x7E;
}
- ResolveEntityOnTop(this->child, this);
+ SortEntityAbove(this->child, this);
} else {
if (*(u32*)&this->parent->field_0x74 == 0) {
if (this->type == 8) {
diff --git a/src/object/object6A.c b/src/object/object6A.c
index 6813f69c..e3750c43 100644
--- a/src/object/object6A.c
+++ b/src/object/object6A.c
@@ -212,7 +212,7 @@ void sub_08094C30(Object6AEntity* this) {
DeleteThisEntity();
if (super->action == 0) {
super->action++;
- SetDefaultPriority(super, 2);
+ SetDefaultPriority(super, PRIO_MESSAGE);
super->spriteRendering.b3 = gUnk_08114F30[p->spriteRendering.b3];
InitAnimationForceUpdate(super, 1);
}
@@ -231,13 +231,13 @@ void sub_08094C88(Object6AEntity* this) {
} else {
super->action++;
super->spriteSettings.draw = 1;
- SetDefaultPriority(super, 3);
+ SetDefaultPriority(super, PRIO_NO_BLOCK);
switch (super->type2) {
case 0x40:
case 0x41:
case 0x42:
case 0x43:
- ResolveEntityBelow(super, super);
+ SortEntityBelow(super, super);
}
}
@@ -250,8 +250,8 @@ void sub_08094C88(Object6AEntity* this) {
void sub_08094CDC(Object6AEntity* this) {
Entity* e = CreateObject(0x6a, 3, 0x62);
if (e != NULL) {
- e->x.HALF.HI = gRoomControls.origin_x + 224;
- e->y.HALF.HI = gRoomControls.origin_y + 600;
+ e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(7.0 / 8.0);
+ e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345);
SoundReq(324);
}
}
@@ -266,8 +266,8 @@ void sub_08094D10(Object6AEntity* this) {
void sub_08094D34(Object6AEntity* this) {
Entity* e = CreateObject(0x6a, 0x15, 0xd);
if (e != NULL) {
- e->x.HALF.HI = gRoomControls.origin_x + 256;
- e->y.HALF.HI = gRoomControls.origin_y + 600;
+ e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(1.0);
+ e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345);
SoundReq(324);
}
}
@@ -290,7 +290,7 @@ void sub_08094D94(Object6AEntity* this) {
} else {
super->action++;
super->spriteSettings.draw = 1;
- SetDefaultPriority(super, 3);
+ SetDefaultPriority(super, PRIO_NO_BLOCK);
InitAnimationForceUpdate(super, 0);
}
UpdateAnimationSingleFrame(super);
@@ -299,8 +299,8 @@ void sub_08094D94(Object6AEntity* this) {
void sub_08094DD8(Object6AEntity* this) {
Entity* e = CreateObject(0x6a, 0x4, 0);
if (e != NULL) {
- e->x.HALF.HI = gRoomControls.origin_x + 240;
- e->y.HALF.HI = gRoomControls.origin_y + 600;
+ e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(15.0 / 16.0);
+ e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345);
SoundReq(324);
}
}
@@ -330,7 +330,7 @@ void sub_08094E30(Object6AEntity* this) {
super->action++;
super->z.WORD = -0xA00000;
super->zVelocity = 0;
- SetDefaultPriority(super, 6);
+ SetDefaultPriority(super, PRIO_PLAYER_EVENT);
InitializeAnimation(super, 0);
if (sub_080002B8(super) == 13) {
super->action = 3;
@@ -338,13 +338,13 @@ void sub_08094E30(Object6AEntity* this) {
break;
case 1:
super->z.WORD -= super->zVelocity;
- super->zVelocity -= 0x2000;
+ super->zVelocity -= Q_8_8(32.0);
if (super->z.WORD > 0) {
super->action++;
super->z.WORD = 0;
super->zVelocity = 0;
InitializeAnimation(super, 1);
- EnqueueSFX(382);
+ EnqueueSFX(SFX_LAVA_TILE_FLIP);
}
break;
case 2:
@@ -355,7 +355,7 @@ void sub_08094E30(Object6AEntity* this) {
break;
case 3:
super->z.WORD -= super->zVelocity;
- super->zVelocity -= 0x2000;
+ super->zVelocity -= Q_8_8(32.0);
if (!CheckOnScreen(super)) {
DeleteThisEntity();
}
@@ -413,7 +413,7 @@ void sub_08094FA8(Object6AEntity* this) {
}
break;
case 3:
- if (gPlayerEntity.action != 12) {
+ if (gPlayerEntity.action != PLAYER_EMPTYBOTTLE) {
super->action = 4;
#ifndef EU
if (!CheckGlobalFlag(BIN_DOGFOOD)) {
@@ -472,8 +472,8 @@ void sub_08095088(Object6AEntity* this) {
void sub_08095120(Object6AEntity* this) {
if (super->action == 0) {
super->action = 1;
- SetDefaultPriority(super, 3);
- ResolveEntityBelow(super, super);
+ SetDefaultPriority(super, PRIO_NO_BLOCK);
+ SortEntityBelow(super, super);
sub_0807DD64(super);
InitAnimationForceUpdate(super, 2);
}
@@ -492,8 +492,8 @@ void sub_08095164(Object6AEntity* this) {
void sub_08095188(Object6AEntity* this) {
if (super->action == 0) {
super->action = 1;
- SetDefaultPriority(super, 3);
- ResolveEntityBelow(super, super);
+ SetDefaultPriority(super, PRIO_NO_BLOCK);
+ SortEntityBelow(super, super);
sub_0807DD64(super);
InitAnimationForceUpdate(super, 0);
}
@@ -535,7 +535,7 @@ void sub_08095244(Object6AEntity* this) {
Entity* e = CreateObject(OBJECT_6A, 0xA, 0);
if (e != NULL) {
e->parent = super;
- PositionRelative(super, e, 0x100000, -0x100000);
+ PositionRelative(super, e, Q_16_16(16.0), -Q_16_16(16.0));
((Object6AEntity*)e)->ctx = StartCutscene(e, &script_Object6ASwordInChest);
}
}
@@ -547,7 +547,7 @@ void sub_08095288(Object6AEntity* this) {
if (super->action == 0) {
super->action++;
super->subAction = 0;
- SetDefaultPriority(super, 3);
+ SetDefaultPriority(super, PRIO_NO_BLOCK);
InitAnimationForceUpdate(super, 0);
}
if (super->subAction != 0) {
@@ -583,7 +583,7 @@ void sub_08095330(Object6AEntity* this) {
e->parent = super;
CopyPosition(super, e);
e->z.HALF.HI = -16;
- ResolveEntityOnTop(e, e);
+ SortEntityAbove(e, e);
}
}
@@ -597,7 +597,7 @@ void sub_08095364(Object6AEntity* this) {
e->subAction = 1;
e->z.HALF.HI = -16;
e->direction = 7;
- e->zVelocity = 0x30000;
+ e->zVelocity = Q_16_16(3.0);
e->speed = 128;
InitAnimationForceUpdate(e, 1);
}
@@ -607,9 +607,9 @@ void sub_080953A4(Object6AEntity* this) {
if (super->action == 0) {
super->action++;
super->z.HALF.HI = -16;
- SetDefaultPriority(super, 2);
+ SetDefaultPriority(super, PRIO_MESSAGE);
super->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3];
- ResolveEntityOnTop(super, super);
+ SortEntityAbove(super, super);
sub_0807DD64(super);
}
ExecuteScriptForEntity(super, 0);
@@ -625,7 +625,7 @@ void sub_080953A4(Object6AEntity* this) {
void sub_08095420(Object6AEntity* this, ScriptExecutionContext* ctx) {
Entity* e = CreateObject(OBJECT_6A, 0xC, 0);
if (e != NULL) {
- PositionRelative(super, e, 0, -0x100000);
+ PositionRelative(super, e, 0, Q_16_16(-16));
((Object6AEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable);
}
}
@@ -637,7 +637,7 @@ void sub_0809545C(Object6AEntity* this, ScriptExecutionContext* ctx) {
Entity* p = CreateObject(OBJECT_6A, 0xD, 0);
Entity* e;
if (p != NULL) {
- PositionRelative(super, p, 0, -0x100000);
+ PositionRelative(super, p, 0, Q_16_16(-16));
((Object6AEntity*)p)->ctx = StartCutscene(p, (u16*)ctx->intVariable);
e = CreateObject(OBJECT_6A, 2, 0);
if (e != NULL) {
@@ -692,7 +692,7 @@ void sub_080954DC(Object6AEntity* this) {
super->y.HALF.HI += this->py;
break;
case 3:
- sub_0806F62C(super, super->speed, super->direction);
+ LinearMoveAngle(super, super->speed, super->direction);
break;
}
this->off += 4;
@@ -764,7 +764,7 @@ void sub_08095754(Object6AEntity* this) {
if (e != NULL) {
e->parent = super;
CopyPosition(super, e);
- ResolveEntityBelow(super, e);
+ SortEntityBelow(super, e);
}
}
@@ -784,7 +784,7 @@ void sub_080957B4(Object6AEntity* this) {
if (e != NULL) {
e->parent = super;
CopyPosition(super, e);
- ResolveEntityBelow(super, e);
+ SortEntityBelow(super, e);
}
}
@@ -804,7 +804,7 @@ void sub_08095810(Object6AEntity* this) {
if (e != NULL) {
e->parent = super;
CopyPosition(super, e);
- ResolveEntityOnTop(super, e);
+ SortEntityAbove(super, e);
((Object6AEntity*)e)->ctx = StartCutscene(e, &script_ZeldaMagic);
}
}
@@ -847,7 +847,7 @@ void sub_080958D8(Object6AEntity* this) {
void sub_08095918(Object6AEntity* this) {
if (super->action == 0) {
super->action++;
- SetDefaultPriority(super, 6);
+ SetDefaultPriority(super, PRIO_PLAYER_EVENT);
sub_0807DD64(super);
InitializeAnimation(super, 0);
}
@@ -871,7 +871,7 @@ void sub_08095954(Object6AEntity* this) {
PositionRelative(super, e, x, y);
e->z.HALF.HI = -3;
((Object6AEntity*)e)->ctx = StartCutscene(e, &script_08012C48);
- EnqueueSFX(292);
+ EnqueueSFX(SFX_124);
super->frame &= ~1;
} else {
gActiveScriptInfo.syncFlags |= 0x100;
@@ -882,7 +882,7 @@ void sub_080959CC(Object6AEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 0;
- SetDefaultPriority(super, 3);
+ SetDefaultPriority(super, PRIO_NO_BLOCK);
sub_0807DD64(super);
}
ExecuteScriptForEntity(super, 0);
@@ -1038,7 +1038,7 @@ void sub_08095CE0(Object6AEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 0;
- SetDefaultPriority(super, 6);
+ SetDefaultPriority(super, PRIO_PLAYER_EVENT);
sub_0807DD64(super);
}
ExecuteScriptForEntity(super, 0);
@@ -1084,12 +1084,12 @@ void sub_08095DBC(Object6AEntity* this) {
super->spriteSettings.draw = 1;
InitializeAnimation(super, 75);
super->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3];
- ResolveEntityOnTop(super, super);
+ SortEntityAbove(super, super);
}
if ((super->type2 & 0x80) == 0 && gActiveScriptInfo.syncFlags & 0x20000) {
super->type2 = -1;
- super->zVelocity = 0x40000;
- super->speed = 0xC000;
+ super->zVelocity = Q_16_16(4.0);
+ super->speed = Q_8_8(192);
}
GravityUpdate(super, super->speed);
GetNextFrame(super);
@@ -1128,7 +1128,7 @@ NONMATCH("asm/non_matching/object6A/sub_08095EAC.inc",
x = a - (Random() & b);
y = a - (Random() & b);
- PositionRelative(super, e, x << 16, y << 16);
+ PositionRelative(super, e, Q_16_16(x), Q_16_16(y));
super->zVelocity = vel;
super->speed = speed;
}
@@ -1220,7 +1220,7 @@ void sub_080960C4(Object6AEntity* this, ScriptExecutionContext* ctx) {
e->parent = super;
CopyPosition(super, e);
e->spriteRendering.b3 = gUnk_08114F34[super->spriteRendering.b3];
- ResolveEntityBelow(super, e);
+ SortEntityBelow(super, e);
((Object6AEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable);
}
e = CreateObject(OBJECT_6A, 0x24, 0x4A);
@@ -1228,7 +1228,7 @@ void sub_080960C4(Object6AEntity* this, ScriptExecutionContext* ctx) {
e->parent = super;
CopyPosition(super, e);
e->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3];
- ResolveEntityOnTop(super, e);
+ SortEntityAbove(super, e);
e->collisionLayer = 2;
((Object6AEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable);
}
@@ -1241,7 +1241,7 @@ void sub_08096168(Object6AEntity* this) {
InitializeAnimation(super, 75);
}
GetNextFrame(super);
- sub_0806F62C(super, super->speed, super->direction);
+ LinearMoveAngle(super, super->speed, super->direction);
if (!CheckOnScreen(super))
DeleteThisEntity();
}
@@ -1267,21 +1267,21 @@ void sub_08096208(Object6AEntity* this, u32 x) {
s8* p = &gUnk_08122B2E[x * 2];
Entity* e = CreateObject(OBJECT_6A, 0x26, 0);
if (e != NULL) {
- PositionRelative(super, e, p[0] << 16, p[1] << 16);
+ PositionRelative(super, e, Q_16_16(p[0]), Q_16_16(p[1]));
}
}
void sub_0809623C(Object6AEntity* this) {
Entity* e = CreateObject(OBJECT_6A, 0x27, 0);
if (e != NULL) {
- PositionRelative(super, e, 0, -0x100000);
+ PositionRelative(super, e, 0, Q_16_16(-16.0));
}
}
void sub_08096260(Object6AEntity* this) {
Entity* e = CreateObject(OBJECT_6A, 0x28, 0);
if (e != NULL) {
- PositionRelative(super, e, 0, -0x100000);
+ PositionRelative(super, e, 0, Q_16_16(-16.0));
}
}
diff --git a/src/object/object7E.c b/src/object/object7E.c
index 15785d8f..a23b0e5c 100644
--- a/src/object/object7E.c
+++ b/src/object/object7E.c
@@ -17,7 +17,7 @@ void Object7E(Entity* this) {
this->spriteSettings.flipX = TRUE;
}
}
- PositionRelative(this->parent, this, 0, 0x80000);
+ PositionRelative(this->parent, this, 0, Q_16_16(8.0));
this->z.HALF.HI = 0;
if (this->type != 0) {
this->spriteSettings.draw = this->child->spriteSettings.draw;
diff --git a/src/object/objectA2.c b/src/object/objectA2.c
index cc0e350a..e529794c 100644
--- a/src/object/objectA2.c
+++ b/src/object/objectA2.c
@@ -25,14 +25,16 @@ void ObjectA2(Entity* this) {
GetNextFrame(this);
}
+#define fp(n) ((n) << 8)
+
void sub_0809F318(Entity* this) {
InitializeAnimation(this, 0);
if (Random() & 0x10) {
this->spriteSettings.flipX = 1;
}
- this->x.HALF.HI = 0x28;
- this->y.HALF.HI = 0x48;
- this->z.HALF.HI = 0xFFB0;
+ this->x.HALF.HI = Q_8_8(0.16);
+ this->y.HALF.HI = Q_8_8(0.285);
+ this->z.HALF.HI = Q_8_8(-0.315);
this->spriteOrientation.flipY = 2;
this->action = 1;
ChangeObjPalette(this, gUnk_08124704[this->type]);
diff --git a/src/object/objectAF.c b/src/object/objectAF.c
index f34ff4f2..8aa2c9ed 100644
--- a/src/object/objectAF.c
+++ b/src/object/objectAF.c
@@ -47,7 +47,7 @@ void sub_080A0624(Entity* this) {
void sub_080A0640(Entity* this) {
if (this->type == 0) {
- PositionRelative(*(((Entity**)this->parent->myHeap) + 4), this, 0, 0x80000);
+ PositionRelative(*(((Entity**)this->parent->myHeap) + 4), this, 0, Q_16_16(8.0));
} else {
CopyPosition(this->parent, this);
}
diff --git a/src/object/objectB5.c b/src/object/objectB5.c
index a93011ed..e23779b2 100644
--- a/src/object/objectB5.c
+++ b/src/object/objectB5.c
@@ -10,5 +10,5 @@ void ObjectB5(Entity* this) {
#ifndef EU
gRoomControls.camera_target = this;
#endif
- PositionRelative(&gPlayerEntity, this, 0, -0x280000);
+ PositionRelative(&gPlayerEntity, this, 0, Q_16_16(-40.0));
}
diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c
index a6e3a625..cd527a72 100644
--- a/src/object/octorokBossObject.c
+++ b/src/object/octorokBossObject.c
@@ -40,8 +40,6 @@ enum OctorokBossObjectType {
};
#define GET_HELPER(this) (*(HelperStruct**)&(this)->cutsceneBeh)
-extern u32 sub_0806FC80(Entity*, Entity*, s32);
-
void OctorokBossObject(Entity* this) {
OctorokBossObject_Actions[this->action](this);
}
@@ -78,14 +76,14 @@ void OctorokBossObject_Init(Entity* this) {
}
this->speed = 0xf0 - (Random() & 0x3f);
- sub_0806F62C(this, ((s16)this->speed >> 1) << 8, (u32)this->direction);
- sub_0806F62C(this, ((s16)this->speed >> 1) << 8, (u32)this->direction);
+ LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction);
+ LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction);
InitializeAnimation(this, 5);
SoundReq(SFX_14C);
break;
case 3:
this->direction = -(this->parent->field_0x7a.HALF.HI + -0x80);
- sub_0806F62C(this, 0x4800, (u32)this->direction);
+ LinearMoveAngle(this, 0x4800, (u32)this->direction);
if ((Random() & 1) != 0) {
this->direction = (Random() & 0x3f) + this->direction;
} else {
@@ -94,7 +92,7 @@ void OctorokBossObject_Init(Entity* this) {
InitializeAnimation(this, 6);
break;
case 6:
- sub_0806F62C(this, (0x30 - (Random() & 0x2f)) * 0x100, Random() & 0xff);
+ LinearMoveAngle(this, (0x30 - (Random() & 0x2f)) * 0x100, Random() & 0xff);
if ((Random() & 1) != 0) {
this->direction = (Random() & 0x3f) + this->direction;
} else {
@@ -111,10 +109,10 @@ void OctorokBossObject_Init(Entity* this) {
this->field_0x76.HWORD = 0x400;
this->field_0x74.HWORD = 0x400;
this->field_0x7a.HWORD = 0;
- sub_0806F62C(this,
- ((-(u32)this->parent->field_0x7a.HALF.HI << 0x18) >> 0x18) +
- (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1],
- (u32)gUnk_0812388C[(u32)this->type2 * 2]);
+ LinearMoveAngle(this,
+ ((-(u32)this->parent->field_0x7a.HALF.HI << 0x18) >> 0x18) +
+ (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1],
+ (u32)gUnk_0812388C[(u32)this->type2 * 2]);
sub_0805EC9C(this, this->field_0x76.HWORD, this->field_0x74.HWORD, this->field_0x7a.HWORD);
InitializeAnimation(this, 7);
break;
@@ -172,7 +170,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc",
case 1:
this->direction = sub_080045DA(GET_HELPER(this)->tailObjects[this->actionDelay]->x.WORD - this->x.WORD,
GET_HELPER(this)->tailObjects[this->actionDelay]->y.WORD - this->y.WORD);
- sub_0806F62C(this, this->speed, this->direction);
+ LinearMoveAngle(this, this->speed, this->direction);
if (EntityInRectRadius(this, GET_HELPER(this)->tailObjects[this->actionDelay], 2, 2) == 0) {
return;
}
@@ -197,7 +195,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc",
if (this->parent->type2 == 3) {
Entity* object = GET_HELPER(this->parent)->mouthObject;
this->direction = sub_080045DA(object->x.WORD - this->x.WORD, object->y.WORD - this->y.WORD);
- sub_0806F62C(this, 0x280, this->direction);
+ LinearMoveAngle(this, 0x280, this->direction);
if (sub_0806FC80(this, this->parent, 0x48) == 0) {
return;
}
@@ -206,7 +204,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc",
break;
case 3:
case 6:
- sub_0806F62C(this, 0x80, this->direction);
+ LinearMoveAngle(this, 0x80, this->direction);
if (this->frame != 0) {
DeleteThisEntity();
}
@@ -249,8 +247,9 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc",
*(int*)&this->field_0x78 -= 1;
}
CopyPosition(this->parent, this);
- sub_0806F62C(this, (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1],
- ((u8) - this->parent->field_0x7a.HALF.HI & 0xff) + (u32)gUnk_0812388C[(u32)this->type2 * 2]);
+ LinearMoveAngle(this, (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1],
+ ((u8) - this->parent->field_0x7a.HALF.HI & 0xff) +
+ (u32)gUnk_0812388C[(u32)this->type2 * 2]);
return;
case 7:
if (this->actionDelay == 0) {
diff --git a/src/object/pot.c b/src/object/pot.c
index bf94a8be..4e47144f 100644
--- a/src/object/pot.c
+++ b/src/object/pot.c
@@ -18,7 +18,6 @@ extern void (*const gUnk_0811F0C4[])(Entity*);
extern Hitbox gHitbox_18; // TODO: should be const
extern Hitbox gUnk_080FD340; // TODO: should be const
-extern u32 sub_080001DA(u32, u32);
extern void sub_08078930(Entity*);
extern void sub_08016A6C(Entity*);
@@ -47,7 +46,7 @@ void sub_0808222C(Entity* this) {
ResolveCollisionLayer(this);
}
- this->field_0x70.HALF.LO = sub_080001DA(COORD_TO_TILE(this), this->collisionLayer);
+ this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer);
if ((u16)this->field_0x70.HALF.LO == 0x4000) {
DeleteThisEntity();
}
@@ -67,7 +66,7 @@ void sub_08082310(Entity* this) {
case 0x1D:
SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
this->action = 5;
- this->zVelocity = 0x2A000;
+ this->zVelocity = Q_16_16(2.625);
this->spriteOffsetY = 0;
this->spriteSettings.shadow = 1;
this->spritePriority.b1 = 3;
@@ -90,7 +89,7 @@ void sub_08082310(Entity* this) {
this->actionDelay = 64;
}
SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
- EnqueueSFX(0x10F);
+ EnqueueSFX(SFX_10F);
break;
case 0x4067:
SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
@@ -188,7 +187,7 @@ void sub_08082614(Entity* this) {
this->speed <<= 1;
}
- this->field_0x70.HALF.LO = sub_080001DA(COORD_TO_TILE(this), this->collisionLayer);
+ this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer);
tileType = GetTileTypeByEntity(this);
switch (tileType) {
case 0x71:
diff --git a/src/object/pressurePlate.c b/src/object/pressurePlate.c
new file mode 100644
index 00000000..bef003fe
--- /dev/null
+++ b/src/object/pressurePlate.c
@@ -0,0 +1,185 @@
+#define NENT_DEPRECATED
+#include "object.h"
+#include "functions.h"
+
+u32 IsColliding(Entity*, Entity*);
+
+typedef struct {
+ Entity base;
+ /*0x68*/ union SplitHWord field_0x68;
+ /*0x6a*/ union SplitHWord field_0x6a;
+ /*0x6c*/ union SplitHWord field_0x6c;
+ /*0x6e*/ union SplitHWord field_0x6e;
+ /*0x70*/ u16 canToggle;
+ /*0x72*/ u8 dir;
+ /*0x73*/ u8 filler73[0x86 - 0x73];
+ /*0x86*/ u16 flag;
+} PressurePlateEntity;
+
+typedef void(PressurePlateAction)(PressurePlateEntity*);
+
+PressurePlateAction sub_08088840;
+PressurePlateAction sub_0808886C;
+PressurePlateAction sub_080888F4;
+
+extern Hitbox gUnk_080FD1D4;
+
+static u32 sub_08088938(PressurePlateEntity*);
+static u32 get_standing_count(PressurePlateEntity*);
+
+static const u8 sSpriteOffsets[];
+
+void PressurePlate(PressurePlateEntity* this) {
+ static PressurePlateAction* const sActions[] = {
+ sub_08088840,
+ sub_0808886C,
+ sub_080888F4,
+ };
+
+ if (super->field_0xf) {
+ if (--super->field_0xf == 0) {
+ this->dir = super->animationState;
+ InitializeAnimation(super, super->animationState);
+ }
+ }
+
+ sActions[super->action](this);
+}
+
+void sub_08088840(PressurePlateEntity* this) {
+ super->action = 1;
+ super->spriteSettings.draw = 1;
+ super->spritePriority.b0 = 7;
+ super->hitbox = &gUnk_080FD1D4;
+ this->dir = super->animationState;
+}
+
+void sub_0808886C(PressurePlateEntity* this) {
+ u8 weight;
+
+ weight = sub_08088938(this) + get_standing_count(this);
+ if (super->type + 2 <= weight) {
+ super->action = 2;
+ super->field_0xf = 0;
+ super->animationState = 4;
+ super->z.HALF.HI = 0;
+ InitializeAnimation(super, 4);
+ SetFlag(this->flag);
+ EnqueueSFX(SFX_PRESSURE_PLATE);
+ } else {
+ if (weight > super->animationState) {
+ if (super->type + 1 == weight) {
+ super->field_0xf = 4;
+ InitializeAnimation(super, weight + 1);
+ } else {
+ InitializeAnimation(super, weight);
+ }
+ EnqueueSFX(SFX_BUTTON_PRESS);
+ } else if (weight < super->animationState) {
+ InitializeAnimation(super, weight);
+ }
+ super->animationState = weight;
+ }
+}
+
+void sub_080888F4(PressurePlateEntity* this) {
+ u8 weight;
+
+ if (this->canToggle) {
+ weight = sub_08088938(this) + get_standing_count(this);
+ if (super->type + 2 > weight) {
+ super->action = 1;
+ super->animationState = weight;
+ ClearFlag(this->flag);
+ InitializeAnimation(super, weight);
+ }
+ }
+}
+
+static NONMATCH("asm/non_matching/pressurePlate/sub_08088938.inc", u32 sub_08088938(PressurePlateEntity* this)) {
+ u16 x, y;
+ s32 num;
+ u8* tmp;
+ u32 i;
+
+ num = 0;
+ x = super->x.HALF.HI - 8;
+ y = super->y.HALF.HI - 8;
+
+ tmp = &this->dir;
+ for (i = 0; i < 8; ++i) {
+ Entity* e = gRoomVars.field_0x8c[8 + i];
+ if (e != NULL) {
+ if ((u16)(e->x.HALF.HI - x) < 0x11 && ((u16)(e->y.HALF_U.HI - y) < 0x11)) {
+ e->spriteOffsetY = sSpriteOffsets[*tmp];
+ num++;
+ }
+ }
+ }
+ return num;
+}
+END_NONMATCH
+
+static u32 get_standing_count(PressurePlateEntity* this) {
+ u32 num;
+
+ num = 0;
+ if (IsCollidingPlayer(super) != 0) {
+ gPlayerEntity.spriteOffsetY = sSpriteOffsets[this->dir];
+ num = 1;
+ }
+ if ((gPlayerState.flags & PL_CLONING) != 0) {
+ if (IsColliding(super, gPlayerClones[0]) != 0) {
+ gPlayerClones[0]->spriteOffsetY = sSpriteOffsets[this->dir];
+ num++;
+ }
+ if (IsColliding(super, gPlayerClones[1]) != 0) {
+ gPlayerClones[1]->spriteOffsetY = sSpriteOffsets[this->dir];
+ num++;
+ }
+ if (IsColliding(super, gPlayerClones[2]) != 0) {
+ gPlayerClones[2]->spriteOffsetY = sSpriteOffsets[this->dir];
+ num++;
+ }
+ }
+ return num;
+}
+
+static const u8 sSpriteOffsets[] = {
+ -4, -3, -2, -1, 0,
+};
+
+static const Frame gSpriteAnimations_PressurePlate_0 = {
+ .index = 0,
+ .duration = 0xFF,
+ .frameSettings = { .b = { .endOfAnimation = 1 } },
+};
+
+static const Frame gSpriteAnimations_PressurePlate_1 = {
+ .index = 1,
+ .duration = 0xFF,
+ .frameSettings = { .b = { .endOfAnimation = 1 } },
+};
+
+static const Frame gSpriteAnimations_PressurePlate_2 = {
+ .index = 2,
+ .duration = 0xFF,
+ .frameSettings = { .b = { .endOfAnimation = 1 } },
+};
+
+static const Frame gSpriteAnimations_PressurePlate_3 = {
+ .index = 3,
+ .duration = 0xFF,
+ .frameSettings = { .b = { .endOfAnimation = 1 } },
+};
+
+static const Frame gSpriteAnimations_PressurePlate_4 = {
+ .index = 4,
+ .duration = 0xFF,
+ .frameSettings = { .b = { .endOfAnimation = 1 } },
+};
+
+const Frame* const gSpriteAnimations_PressurePlate[] = {
+ &gSpriteAnimations_PressurePlate_0, &gSpriteAnimations_PressurePlate_1, &gSpriteAnimations_PressurePlate_2,
+ &gSpriteAnimations_PressurePlate_3, &gSpriteAnimations_PressurePlate_4,
+};
diff --git a/src/object/pullableLever.c b/src/object/pullableLever.c
new file mode 100644
index 00000000..56acc72d
--- /dev/null
+++ b/src/object/pullableLever.c
@@ -0,0 +1,284 @@
+/**
+ * @file pullableLever.c
+ * @ingroup Objects
+ *
+ * @brief Pullable Lever object
+ */
+
+#define NENT_DEPRECATED
+#include "global.h"
+#include "object.h"
+#include "functions.h"
+#include "sound.h"
+
+typedef struct {
+ /*0x00*/ Entity base;
+ /*0x68*/ u8 unk_68[8];
+ /*0x70*/ u16 pullLength;
+ /*0x72*/ u16 leverPart; // lever part number? [0,1,2]
+ /*0x74*/ u8 actionDelay;
+ /*0x75*/ u8 unk_75;
+ /*0x76*/ u16 necessaryPullLength;
+ /*0x78*/ u8 unk_78[6];
+ /*0x7e*/ u8 unk_7e;
+ /*0x7f*/ u8 unk_7f;
+ /*0x80*/ u16 initialX;
+ /*0x82*/ u16 initialY;
+ /*0x84*/ u8 unk_84[2];
+ /*0x86*/ u16 pulledFlag;
+} PullableLeverEntity;
+
+enum PullableLeverPart { HANDLE, MIDDLE, SOCKET };
+
+extern u16 gUnk_02021F00[];
+extern Hitbox gUnk_080FD270;
+extern Hitbox gUnk_080FD278;
+
+extern void (*const PullableLever_HandleActions[])(PullableLeverEntity*);
+extern void (*const PullableLever_MiddleActions[])(PullableLeverEntity*);
+extern const s8 PullableLever_InitialOffsets[];
+extern void (*const PullableLever_HandleSubActions[])(PullableLeverEntity*);
+extern const s8 gUnk_081222B8[];
+extern const u8 gUnk_081222C0[];
+
+void sub_08091504(PullableLeverEntity*);
+void PullableLever_UpdateLength(PullableLeverEntity*);
+void sub_0809153C(PullableLeverEntity*);
+
+void PullableLever(PullableLeverEntity* this) {
+ switch (this->leverPart) {
+ case HANDLE:
+ PullableLever_HandleActions[super->action](this);
+ sub_0800445C(super);
+ gUnk_02021F00[this->actionDelay] = this->pullLength;
+ break;
+ case MIDDLE:
+ PullableLever_MiddleActions[super->action](this);
+ break;
+ case SOCKET:
+ if (super->action == 0) {
+ sub_08091504(this);
+ }
+ break;
+ }
+}
+
+void PullableLever_HandleInit(PullableLeverEntity* this) {
+ if (gEntCount < 0x46) {
+ PullableLeverEntity* entity1 = (PullableLeverEntity*)CreateObject(PULLABLE_LEVER, super->type, super->type2);
+ PullableLeverEntity* entity2 = (PullableLeverEntity*)CreateObject(PULLABLE_LEVER, super->type, super->type2);
+ (entity1->base).parent = super;
+ (entity2->base).parent = super;
+ entity1->leverPart = 1;
+ entity2->leverPart = 2;
+ CopyPosition(super, &entity2->base);
+ super->action = 1;
+ super->spriteSettings.draw = 1;
+ super->speed = 0x60;
+ if ((super->type2 & 1)) {
+ super->hitbox = &gUnk_080FD278;
+ } else {
+ super->hitbox = &gUnk_080FD270;
+ }
+ super->field_0x16 = 1;
+ super->x.HALF.HI += PullableLever_InitialOffsets[super->type2 * 2];
+ this->initialX = super->x.HALF.HI;
+ super->y.HALF.HI += PullableLever_InitialOffsets[super->type2 * 2 + 1];
+ this->initialY = super->y.HALF.HI;
+ CopyPosition(super, &entity1->base);
+ this->necessaryPullLength = this->unk_7e;
+ this->actionDelay = super->actionDelay;
+ InitializeAnimation(super, super->type2);
+ }
+}
+
+void PullableLever_HandleAction1(PullableLeverEntity* this) {
+ sub_08078930(super);
+ if (this->pullLength != 0) {
+ super->direction = super->type2 << 3;
+ LinearMoveUpdate(super);
+ PullableLever_UpdateLength(this);
+ }
+}
+
+void PullableLever_HandleAction2(PullableLeverEntity* this) {
+ sub_0806FBB4(super);
+ PullableLever_HandleSubActions[super->subAction - 5](this);
+}
+
+void PullableLever_HandleSubAction0(PullableLeverEntity* this) {
+ u16 y;
+ u16 x;
+ Entity* player = &gPlayerEntity;
+
+ if (this->unk_75 == 0) {
+ if (-player->animationState + super->type2 * 2 == 0) {
+ x = gUnk_081222B8[super->type2 * 2] + super->x.HALF_U.HI;
+ y = gUnk_081222B8[super->type2 * 2 + 1] + super->y.HALF_U.HI;
+ if (0x10 < sub_080002D4(x, y, player->collisionLayer) - 0xf) {
+ player->x.HALF.HI = x;
+ player->y.HALF.HI = y;
+ }
+ }
+ this->unk_75 = 1;
+ super->field_0xf = 2;
+ }
+ if (player->animationState >> 1 == super->type2) {
+ if (gPlayerState.framestate == PL_STATE_PULL) {
+ if (gPlayerState.heldObject & 2) {
+ if (gPlayerEntity.frame & 2) {
+ sub_0809153C(this);
+ if (this->unk_75 == 1) {
+ this->unk_75 = 2;
+ EnqueueSFX(SFX_19E);
+ }
+ }
+ }
+ }
+ }
+}
+
+void PullableLever_HandleSubAction1(PullableLeverEntity* this) {
+ super->action = 1;
+ this->unk_75 = 0;
+}
+
+void PullableLever_MiddleInit(PullableLeverEntity* this) {
+ super->action = 1;
+ super->spritePriority.b0 = 5;
+ InitializeAnimation(super, super->parent->type2 + 8);
+ UpdateSpriteForCollisionLayer(super);
+}
+
+void PullableLever_MiddleAction1(PullableLeverEntity* this) {
+ u16 tmp;
+ PullableLeverEntity* parent = ((PullableLeverEntity*)super->parent);
+ if (parent->pullLength < 8) {
+ super->spriteSettings.draw = 0;
+ } else {
+ super->spriteSettings.draw = 1;
+ tmp = (((PullableLeverEntity*)super->parent)->pullLength - 8) & 7;
+ switch (super->type2) {
+ case 0:
+ super->y.HALF.HI = (super->parent->y.HALF.HI - tmp) - 0x11;
+ break;
+ case 1:
+ super->x.HALF.HI = tmp + super->parent->x.HALF.HI + 0x11;
+ break;
+ case 2:
+ super->y.HALF.HI = tmp + super->parent->y.HALF.HI + 0x11;
+ break;
+ case 3:
+ super->x.HALF.HI = (super->parent->x.HALF.HI - tmp) - 0x11;
+ break;
+ }
+ tmp = (parent->pullLength - 8) >> 4;
+ if (tmp != super->animationState) {
+ super->animationState = tmp;
+ InitializeAnimation(super, tmp * 4 + super->type2 + 8);
+ }
+ }
+}
+
+void sub_08091504(PullableLeverEntity* this) {
+ super->action = 1;
+ super->spriteSettings.draw = 1;
+ super->spritePriority.b0 = 6;
+ InitializeAnimation(super, super->type2 + 4);
+ UpdateSpriteForCollisionLayer(super);
+}
+
+void sub_0809153C(PullableLeverEntity* this) {
+ s16 prevX;
+ s16 prevY;
+ u32 dir;
+ s16 diff;
+ s32 radius;
+
+ Entity* player = &gPlayerEntity;
+ dir = gUnk_081222C0[super->type2];
+ if (this->necessaryPullLength <= this->pullLength) {
+ return;
+ }
+ prevX = player->x.HALF.HI;
+ prevY = player->y.HALF.HI;
+ sub_080044AE(&gPlayerEntity, super->speed, dir);
+ if ((prevX == gPlayerEntity.x.HALF.HI) && (prevY == gPlayerEntity.y.HALF.HI)) {
+ return;
+ }
+
+ switch (super->type2) {
+ case 0:
+ diff = player->y.HALF.HI - prevY;
+ break;
+ case 1:
+ diff = prevX - gPlayerEntity.x.HALF.HI;
+ break;
+ case 2:
+ diff = prevY - gPlayerEntity.y.HALF.HI;
+ break;
+ case 3:
+ diff = gPlayerEntity.x.HALF.HI - prevX;
+ break;
+ }
+ radius = (diff << 0x18);
+ super->x.WORD += gSineTable[dir * 8] * (radius >> 0x10);
+ super->y.WORD -= gSineTable[dir * 8 + 0x40] * (radius >> 0x10);
+ PullableLever_UpdateLength(this);
+ if (this->necessaryPullLength <= this->pullLength) {
+ EnqueueSFX(SFX_BUTTON_PRESS);
+ SetFlag(this->pulledFlag);
+ } else {
+ if (--super->field_0xf == 0) {
+ super->field_0xf = 0x10;
+ EnqueueSFX(SFX_10F);
+ }
+ }
+}
+
+void PullableLever_UpdateLength(PullableLeverEntity* this) {
+ switch (super->type2) {
+ case 0:
+ this->pullLength = super->y.HALF.HI - this->initialY;
+ break;
+ case 1:
+ this->pullLength = this->initialX - super->x.HALF.HI;
+ break;
+ case 2:
+ this->pullLength = this->initialY - super->y.HALF.HI;
+ break;
+ case 3:
+ this->pullLength = super->x.HALF.HI - this->initialX;
+ break;
+ }
+
+ if (CheckFlags(this->pulledFlag) && (this->pullLength == 0)) {
+ ClearFlag(this->pulledFlag);
+ }
+}
+
+void (*const PullableLever_HandleActions[])(PullableLeverEntity*) = {
+ PullableLever_HandleInit,
+ PullableLever_HandleAction1,
+ PullableLever_HandleAction2,
+};
+void (*const PullableLever_MiddleActions[])(PullableLeverEntity*) = {
+ PullableLever_MiddleInit,
+ PullableLever_MiddleAction1,
+};
+const s8 PullableLever_InitialOffsets[] = {
+ 0, 9, -9, 0, 0, -9, 9, 0,
+};
+void (*const PullableLever_HandleSubActions[])(PullableLeverEntity*) = {
+ PullableLever_HandleSubAction0,
+ PullableLever_HandleSubAction1,
+};
+const s8 gUnk_081222B8[] = {
+ 0, 10, -8, 0, 0, -10, 8, 0,
+};
+const u8 gUnk_081222C0[] = {
+ 16,
+ 24,
+ 0,
+ 8,
+};
diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c
new file mode 100644
index 00000000..dff5ed9a
--- /dev/null
+++ b/src/object/pushableLever.c
@@ -0,0 +1,148 @@
+/**
+ * @file pushableLever.c
+ * @ingroup Objects
+ *
+ * @brief Pushable Lever object
+ */
+
+#define NENT_DEPRECATED
+#include "global.h"
+#include "object.h"
+#include "functions.h"
+
+typedef struct {
+ /*0x00*/ Entity base;
+ /*0x68*/ u8 unk_68[8];
+ /*0x70*/ u16 tilePosition;
+ /*0x72*/ u16 tileIndex;
+ /*0x74*/ u16 timer;
+ /*0x76*/ u8 unk_76[16];
+ /*0x86*/ u16 pushedFlag;
+} PushableLeverEntity;
+
+enum PushableLeverAction {
+ INIT,
+ IDLE,
+ PUSHING,
+};
+
+extern void (*const PushableLever_Actions[])(PushableLeverEntity*);
+extern const u16 PushableLever_Tiles[];
+extern const u8 PushableLever_InitialOffsets[];
+extern const u8 PushableLever_PushedOffsets[];
+
+void PushableLever_SetIdle(PushableLeverEntity*);
+bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this);
+void PushableLever_SetTiles(PushableLeverEntity*);
+void PushableLever_CalculateSpriteOffsets(PushableLeverEntity*);
+
+#define TILE_INITIAL 0x4053
+#define TILE_PUSHED 0x4052
+
+void PushableLever(PushableLeverEntity* this) {
+ PushableLever_Actions[super->action](this);
+}
+
+void PushableLever_Init(PushableLeverEntity* this) {
+ super->spritePriority.b0 = 5;
+ PushableLever_SetIdle(this);
+}
+
+void PushableLever_Idle(PushableLeverEntity* this) {
+ if (PushableLever_ShouldStartPushing(this)) {
+ super->action = PUSHING;
+ super->spriteOffsetX = 0;
+ super->spriteOffsetY = 0;
+ SetTile(this->tileIndex, this->tilePosition, super->collisionLayer);
+ EnqueueSFX(SFX_16A);
+ RequestPriorityDuration(super, 0x1e);
+ if (sub_08079F8C()) {
+ gPlayerState.pushedObject = 0x90;
+ gPlayerState.queued_action = 5;
+ gPlayerState.flags |= 1;
+ gPlayerEntity.x.HALF.LO = 0;
+ gPlayerEntity.y.HALF.LO = 0;
+ gPlayerEntity.direction = gPlayerEntity.animationState << 2;
+ }
+ }
+}
+
+void PushableLever_Pushing(PushableLeverEntity* this) {
+ GetNextFrame(super);
+ if ((super->frame & 0x80) != 0) {
+ if (super->type2 == 0) {
+ SetFlag(this->pushedFlag);
+ } else {
+ ClearFlag(this->pushedFlag);
+ }
+ PushableLever_SetIdle(this);
+ }
+}
+
+void PushableLever_SetIdle(PushableLeverEntity* this) {
+ super->action = IDLE;
+ this->timer = 0x3c;
+ PushableLever_SetTiles(this);
+}
+
+void PushableLever_SetTiles(PushableLeverEntity* this) {
+ if (CheckFlags(this->pushedFlag) == FALSE) {
+ super->type2 = 0;
+ this->tilePosition = COORD_TO_TILE_OFFSET(super, 0, 0x10);
+ this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer);
+ SetTile(TILE_INITIAL, this->tilePosition, super->collisionLayer);
+ InitializeAnimation(super, 1);
+ } else {
+ super->type2 = 1;
+ this->tilePosition = COORD_TO_TILE_OFFSET(super, 0x10, 0);
+ this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer);
+ SetTile(TILE_PUSHED, this->tilePosition, super->collisionLayer);
+ InitializeAnimation(super, 0);
+ }
+}
+
+bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this) {
+ if (GetTileIndex(this->tilePosition, super->collisionLayer) == 0x4054) {
+ if (--this->timer == 0) {
+ return TRUE;
+ }
+ PushableLever_CalculateSpriteOffsets(this);
+ SetTile(PushableLever_Tiles[super->type2], this->tilePosition, super->collisionLayer);
+ } else {
+ this->timer = 0x3c;
+ super->spriteOffsetX = 0;
+ super->spriteOffsetY = 0;
+ }
+ return FALSE;
+}
+
+void PushableLever_CalculateSpriteOffsets(PushableLeverEntity* this) {
+ const u8* offsets;
+ if (super->type2 == 0) {
+ offsets = PushableLever_InitialOffsets;
+ } else {
+ offsets = PushableLever_PushedOffsets;
+ }
+ offsets = &offsets[(this->timer / 4) & 6];
+ super->spriteOffsetX = offsets[0];
+ super->spriteOffsetY = offsets[1];
+ if ((this->timer & 3) == 0) {
+ EnqueueSFX(SFX_104);
+ }
+}
+
+void (*const PushableLever_Actions[])(PushableLeverEntity*) = {
+ PushableLever_Init,
+ PushableLever_Idle,
+ PushableLever_Pushing,
+};
+const u16 PushableLever_Tiles[] = {
+ TILE_INITIAL,
+ TILE_PUSHED,
+};
+const u8 PushableLever_InitialOffsets[] = {
+ 0, 0, 0, 0, 255, 0, 0, 0,
+};
+const u8 PushableLever_PushedOffsets[] = {
+ 0, 0, 0, 0, 0, 255, 0, 0,
+};
diff --git a/src/object/railtrack.c b/src/object/railtrack.c
index d92a9546..303d279d 100644
--- a/src/object/railtrack.c
+++ b/src/object/railtrack.c
@@ -55,7 +55,7 @@ void sub_08085264(Entity* this) {
this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3;
InitializeAnimation(this, this->animationState);
sub_0808543C(this);
- EnqueueSFX(0x151);
+ EnqueueSFX(SFX_151);
}
}
@@ -67,7 +67,7 @@ void sub_080852B4(Entity* this) {
this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3;
InitializeAnimation(this, this->animationState);
sub_08085394(this);
- EnqueueSFX(0x151);
+ EnqueueSFX(SFX_151);
}
}
@@ -97,7 +97,7 @@ void sub_08085308(Entity* this) {
this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3;
InitializeAnimation(this, this->animationState);
sub_0808543C(this);
- EnqueueSFX(0x151);
+ EnqueueSFX(SFX_151);
}
}
}
diff --git a/src/object/rupee.c b/src/object/rupee.c
index 4c9b8aa0..f4119600 100644
--- a/src/object/rupee.c
+++ b/src/object/rupee.c
@@ -51,7 +51,7 @@ void sub_08086A6C(Entity* ent) {
u32 uVar1;
uVar1 = Random();
- ent->zVelocity = 163840;
+ ent->zVelocity = Q_16_16(2.5);
ent->direction = DirectionNormalize(uVar1 >> 16);
ent->speed = uVar1 & 480;
}
diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c
index 065b9fcc..1098d131 100644
--- a/src/object/warpPoint.c
+++ b/src/object/warpPoint.c
@@ -56,7 +56,7 @@ void sub_0808B474(Entity* this) {
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.animationState = 4;
- EnqueueSFX(0x112);
+ EnqueueSFX(SFX_112);
RequestPriorityDuration(this, this->field_0xf + 0x10);
}
@@ -68,7 +68,7 @@ void sub_0808B530(Entity* this) {
}
this->action = 2;
this->field_0xf = 60;
- EnqueueSFX(0x112);
+ EnqueueSFX(SFX_112);
}
}
@@ -91,7 +91,7 @@ void sub_0808B590(Entity* this) {
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.animationState = 4;
- gPlayerEntity.flags &= ~0x80;
+ gPlayerEntity.flags &= ~ENT_COLLIDE;
RequestPriorityDuration(this, this->field_0xf + 0x10);
SoundReq(SFX_113);
} else {
@@ -152,7 +152,7 @@ void sub_0808B684(Entity* this) {
gRoomTransition.player_status.start_pos_y = ((this->cutsceneBeh.HWORD & 0xfc0) >> 2) + 8;
gRoomTransition.player_status.layer = 0;
gRoomTransition.player_status.start_anim = 4;
- gRoomTransition.player_status.spawn_type = 0;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_DEFAULT;
if (this->type == 2) {
gRoomTransition.type = TRANSITION_FADE_WHITE_SLOW;
}
@@ -192,10 +192,10 @@ void sub_0808B73C(Entity* this) {
this->palette.b.b0 = this->parent->palette.b.b0;
InitializeAnimation(this, 1);
}
- if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) {
+ if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) {
this->spriteSettings.draw = 1;
} else {
- if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) {
+ if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) {
this->spriteSettings.draw ^= 1;
} else {
this->spriteSettings.draw = 0;
diff --git a/src/objectUtils.c b/src/objectUtils.c
index 0b219018..745bd0fd 100644
--- a/src/objectUtils.c
+++ b/src/objectUtils.c
@@ -16,7 +16,7 @@ Entity* sub_080A276C(Entity* parent, u32 type, u32 type2) {
Entity* e = sub_0805E744();
if (e != NULL) {
e->id = 0xC1;
- e->kind = 6;
+ e->kind = OBJECT;
e->type = type;
e->type2 = type2;
e->parent = parent;
@@ -100,7 +100,7 @@ u32 LoadObjectSprite(Entity* this, s32 type, const ObjectDefinition* definition)
Entity* CreateObject(u32 subtype, u32 form, u32 parameter) {
Entity* entity = GetEmptyEntity();
if (entity != NULL) {
- entity->kind = 6;
+ entity->kind = OBJECT;
entity->id = subtype;
entity->type = form;
entity->type2 = parameter;
diff --git a/src/player.c b/src/player.c
index b49d83eb..8209718c 100644
--- a/src/player.c
+++ b/src/player.c
@@ -22,26 +22,26 @@
#include "screen.h"
#include "main.h"
-#define GRAVITY_RATE 0x2000
+#define GRAVITY_RATE Q_8_8(32)
#define SLOPE_SPEED_MODIFIER 0x50
-#define WALK_SPEED 0x140
-#define ROLL_SPEED 0x200
-#define SHIELDING_SPEED 0xC0
-#define GUST_JAR_SPEED 0x80
-#define SWORD_CHARGE_SPEED 0xE0
-#define BURNING_SPEED 0x300
+#define WALK_SPEED Q_8_8(1.25)
+#define ROLL_SPEED Q_8_8(2.0)
+#define GUST_JAR_SPEED Q_8_8(0.5)
+#define SHIELDING_SPEED Q_8_8(0.75)
+#define SWORD_CHARGE_SPEED Q_8_8(0.875)
+#define BURNING_SPEED Q_8_8(3)
-#define JUMP_SPEED_FWD 0x100
+#define JUMP_SPEED_FWD Q_8_8(1)
/* Jumping out of a hole */
-#define JUMP_SPEED_HOLE_FWD 0x78
-#define JUMP_SPEED_HOLE_Z 0x1a000
+#define JUMP_SPEED_HOLE_FWD Q_8_8(0.46875)
+#define JUMP_SPEED_HOLE_Z Q_16_16(1.625)
/* Bouncing off a wall */
-#define BOUNCE_SPEED_FWD 0x100
-#define BOUNCE_SPEED_Z 0x20000
+#define BOUNCE_SPEED_FWD Q_8_8(1.0)
+#define BOUNCE_SPEED_Z Q_16_16(2.0)
-#define PULL_SPEED 0x80
-#define PUSH_SPEED 0x80
+#define PULL_SPEED Q_8_8(0.5)
+#define PUSH_SPEED Q_8_8(0.5)
#define PIT_DAMAGE 0x2
@@ -281,7 +281,6 @@ extern u32 sub_080797C4(void);
extern void sub_0800892E(Entity*);
extern void sub_08078F24(void);
extern void sub_0807B068(Entity*);
-extern u32 sub_080001DA(u32, u32);
extern u32 sub_0807A2F8(u32);
extern u32 sub_0806F730(Entity*);
extern u32 sub_08007DD6(u32, const u16*);
@@ -321,7 +320,6 @@ extern u8 gUnk_080082DC[];
extern u16 script_BedInLinksRoom;
extern u16 script_BedAtSimons;
-extern Entity* gPlayerClones[];
extern ScriptExecutionContext gPlayerScriptExecutionContext;
NONMATCH("asm/non_matching/playerItemPacciCane/CheckPlayerInactive.inc", u32 CheckPlayerInactive(void)) {
@@ -724,7 +722,7 @@ static NONMATCH("asm/non_matching/player/PlayerBounceUpdate.inc", void PlayerBou
}
if (--this->actionDelay != 0xFF) {
- this->zVelocity = 0x10000;
+ this->zVelocity = Q_16_16(1.0);
return;
}
@@ -1118,7 +1116,7 @@ static void PortalStandUpdate(Entity* this) {
if (--this->actionDelay == 0xff) {
this->direction = gPlayerState.field_0xd;
this->animationState = Direction8ToAnimationState(this->direction);
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
this->speed = JUMP_SPEED_FWD;
this->action = PLAYER_MINISH;
this->subAction = 7;
@@ -1531,7 +1529,7 @@ static void sub_08071D04(Entity* this) {
gPlayerState.field_0x3c[0] = 0;
this->direction = 0xff;
this->speed = 0;
- this->zVelocity = 0x18000;
+ this->zVelocity = Q_16_16(1.5);
gPlayerState.jump_status = 1;
gPlayerState.swim_state = 0;
return;
@@ -1849,7 +1847,7 @@ static void PlayerLavaInit(Entity* this) {
COLLISION_OFF(this);
if ((gPlayerState.flags & PL_MINISH) == 0) {
this->subAction = 1;
- this->zVelocity = 0x28000;
+ this->zVelocity = Q_16_16(2.5);
ent = CreateObject(OBJECT_42, 0x80, 0);
if (ent != NULL) {
ent->child = this;
@@ -2156,7 +2154,7 @@ static void PlayerInHoleInit(Entity* this) {
gPlayerState.animation = 0x950;
} else {
gPlayerState.animation = 0x61c;
- if (sub_080001DA(COORD_TO_TILE(this), this->collisionLayer) == 0x4020) {
+ if (GetTileIndex(COORD_TO_TILE(this), this->collisionLayer) == 0x4020) {
this->actionDelay = 1;
}
}
@@ -2224,7 +2222,7 @@ static void sub_08072B5C(Entity* this) {
COLLISION_ON(this);
this->spritePriority.b0 = 4;
this->speed = 0x40;
- this->zVelocity = 0x39000;
+ this->zVelocity = Q_16_16(3.5625);
this->z.WORD--;
gPlayerState.jump_status = 0x41;
sub_0806F854(this, 0, -12);
@@ -2240,7 +2238,7 @@ static void sub_08072B5C(Entity* this) {
temp -= 4;
temp <<= 12;
this->zVelocity = temp;
- this->speed = 0x100;
+ this->speed = Q_8_8(1.0);
gPlayerState.animation = 0x810;
SoundReq(SFX_PLY_JUMP);
}
@@ -2679,7 +2677,7 @@ static void PlayerParachute(Entity* this) {
static void sub_08073468(Entity* this) {
gPlayerState.animation = 1792;
gPlayerState.jump_status = 0;
- this->zVelocity = -0x10000;
+ this->zVelocity = Q_16_16(-1.0);
this->subAction++;
this->field_0x7c.WORD = 480;
this->direction = Direction8FromAnimationState(this->animationState);
@@ -2695,7 +2693,7 @@ static void sub_08073468(Entity* this) {
static void sub_080734D4(Entity* this) {
GravityUpdate(this, -(GRAVITY_RATE / 2));
if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) {
- this->zVelocity = 0x49000;
+ this->zVelocity = Q_16_16(4.5625);
this->subAction++;
}
}
@@ -2872,7 +2870,7 @@ static void sub_0807380C(Entity* this) {
if (--this->actionDelay == 0) {
this->subAction = 7;
this->actionDelay = 60;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
}
}
UpdateAnimationSingleFrame(this);
@@ -2965,7 +2963,7 @@ static void sub_080739EC(Entity* this) {
}
if ((gPlayerState.jump_status & 0xC0) == 0) {
if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) {
- this->zVelocity = 0x28000;
+ this->zVelocity = Q_16_16(2.5);
this->actionDelay = 10;
this->direction = 0xff;
gPlayerState.jump_status += 2;
@@ -3176,7 +3174,7 @@ static void sub_08073F04(Entity* this) {
this->spritePriority.b1 = 2;
this->spriteSettings.draw = 0;
this->subAction++;
- this->zVelocity = 0x28000;
+ this->zVelocity = Q_16_16(2.5);
this->speed = 0x100;
gPlayerState.flags &= ~PL_MINISH;
ResetPlayer();
@@ -3240,7 +3238,7 @@ static void sub_08074060(Entity* this) {
this->spriteSettings.shadow = 1;
this->field_0xf = 0;
this->subAction++;
- this->zVelocity = 0x20000;
+ this->zVelocity = Q_16_16(2.0);
gPlayerState.animation = 2060;
sub_0805EC60(this);
} else {
@@ -3515,7 +3513,7 @@ void SurfaceAction_SlopeGndWater(Entity* this) {
}
}
-ASM_FUNC("asm/non_matching/player/sub_08074678.inc", void SurfaceAction_Swamp(Entity* this));
+ASM_FUNC("asm/non_matching/player/SurfaceAction_Swamp.inc", void SurfaceAction_Swamp(Entity* this));
void SurfaceAction_Water(Entity* this) {
if (!sub_080741C4()) {
diff --git a/src/playerHitbox.c b/src/playerHitbox.c
new file mode 100644
index 00000000..8de4d5c8
--- /dev/null
+++ b/src/playerHitbox.c
@@ -0,0 +1,7 @@
+#include "entity.h"
+
+const Hitbox gPlayerHitbox = {
+ 0, -3, { 5, 3, 3, 5 }, 6, 6,
+};
+
+const u8 gUnk_08114F90[8] = { 0 };
diff --git a/src/playerItem/playerItem13.c b/src/playerItem/playerItem13.c
index 895663d0..80cfc982 100644
--- a/src/playerItem/playerItem13.c
+++ b/src/playerItem/playerItem13.c
@@ -20,7 +20,7 @@ ASM_FUNC("asm/non_matching/playerItem13/sub_080AD27C.inc", void sub_080AD27C(Ent
bool32 sub_080AD32C(Entity* this) {
bool32 result = FALSE;
- if (((this->field_0x16 & 0xf0) == 0x10) || ((this->kind == 6 && ((this->id == 5 || (this->id == 0x7d)))))) {
+ if (((this->field_0x16 & 0xf0) == 0x10) || ((this->kind == OBJECT && ((this->id == 5 || (this->id == 0x7d)))))) {
result = TRUE;
}
return result;
diff --git a/src/playerItem/playerItem3.c b/src/playerItem/playerItem3.c
index beaf69a0..4e668d64 100644
--- a/src/playerItem/playerItem3.c
+++ b/src/playerItem/playerItem3.c
@@ -23,15 +23,11 @@ void PlayerItem3(Entity* this) {
this->field_0xf--;
if ((this->field_0xf & 0xf) == 0) {
- EnqueueSFX(0xfb);
+ EnqueueSFX(SFX_FB);
}
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/sub_0801B4C8.inc", void sub_0801B4C8(Entity* this))
-#else
ASM_FUNC("asm/non_matching/playerItem3/sub_0801B4C8.inc", void sub_0801B4C8(Entity* this))
-#endif
ASM_FUNC("asm/non_matching/playerItem3/sub_0801B584.inc", void sub_0801B584(Entity* this))
diff --git a/src/playerItem/playerItemC.c b/src/playerItem/playerItemC.c
index cc494f79..aa08e1bc 100644
--- a/src/playerItem/playerItemC.c
+++ b/src/playerItem/playerItemC.c
@@ -19,7 +19,7 @@ void PlayerItemC(Entity* this) {
void sub_0801B8B0(Entity* this) {
if (gPlayerState.dash_state != 0) {
gPlayerState.item = this;
- this->flags |= 0x20;
+ this->flags |= ENT_PERSIST;
this->action = 0x01;
this->flags2 = 8;
LoadSwapGFX(this, 1, 3);
@@ -41,7 +41,7 @@ void sub_0801B8FC(Entity* this) {
gPlayerState.item = NULL;
DeleteThisEntity();
} else {
- pbVar1->flags |= 0x80;
+ pbVar1->flags |= ENT_COLLIDE;
pbVar1->field_0x3c = 0x21;
sub_0801B938(pbVar1);
}
diff --git a/src/playerItem/playerItemLantern.c b/src/playerItem/playerItemLantern.c
index 3b7071df..00b2f9c6 100644
--- a/src/playerItem/playerItemLantern.c
+++ b/src/playerItem/playerItemLantern.c
@@ -13,7 +13,7 @@ void PlayerItemLantern(Entity* this) {
}
void sub_08054A60(Entity* this) {
- this->flags |= 0xa0;
+ this->flags |= (ENT_PERSIST | ENT_COLLIDE);
this->action = 0x01;
this->actionDelay = 0x04;
this->frameIndex = -1;
diff --git a/src/projectile/arrowProjectile.c b/src/projectile/arrowProjectile.c
index bdb0a214..7f6079f7 100644
--- a/src/projectile/arrowProjectile.c
+++ b/src/projectile/arrowProjectile.c
@@ -73,7 +73,7 @@ void ArrowProjectile_Action2(Entity* this) {
COLLISION_OFF(this);
this->actionDelay = 0x20;
InitializeAnimation(this, this->animIndex + 2);
- EnqueueSFX(0x18a);
+ EnqueueSFX(SFX_18A);
LinearMoveUpdate(this);
} else if (--this->actionDelay == 0) {
DeleteThisEntity();
diff --git a/src/projectile/ballAndChain.c b/src/projectile/ballAndChain.c
index c01f9a42..2f242f85 100644
--- a/src/projectile/ballAndChain.c
+++ b/src/projectile/ballAndChain.c
@@ -86,9 +86,9 @@ void sub_080AB170(Entity* this) {
ent = parent->parent;
if (this->field_0x7c.BYTES.byte0 != ent->field_0x7c.BYTES.byte0) {
- this->flags |= 0x80;
+ this->flags |= ENT_COLLIDE;
} else {
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
}
this->field_0x7c.BYTES.byte0 = ent->field_0x7c.BYTES.byte0;
diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c
index 20c6e090..33677de2 100644
--- a/src/projectile/boneProjectile.c
+++ b/src/projectile/boneProjectile.c
@@ -75,7 +75,7 @@ void BoneProjectile_Action3(Entity* this) {
void BoneProjectile_Action4(Entity* this) {
GetNextFrame(this);
LinearMoveUpdate(this);
- if (GravityUpdate(this, 0x1800) == 0) {
+ if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
DeleteEntity(this);
}
}
@@ -83,7 +83,7 @@ void BoneProjectile_Action4(Entity* this) {
void sub_080A82D8(Entity* this) {
this->action = 4;
COLLISION_OFF(this);
- this->zVelocity = 0x10000;
+ this->zVelocity = Q_16_16(1.0);
this->direction ^= 0x10;
this->speed = 0x80;
}
diff --git a/src/projectile/cannonballProjectile.c b/src/projectile/cannonballProjectile.c
index 449240e1..5e07dfc4 100644
--- a/src/projectile/cannonballProjectile.c
+++ b/src/projectile/cannonballProjectile.c
@@ -5,7 +5,7 @@ extern void CreateItemOnGround(Entity*);
extern s32 sub_080AF090(Entity*);
extern void sub_080043A8(Entity*);
extern void CreateChestSpawner(Entity*);
-extern u32 sub_080177A0(Entity*, Entity*);
+extern u32 IsColliding(Entity*, Entity*);
extern void (*const CannonballProjectile_Functions[])(Entity*);
extern void (*const CannonballProjectile_Actions[])(Entity*);
@@ -79,7 +79,7 @@ bool32 sub_080AB634(Entity* this) {
Entity** entities = ((Entity**)&this->parent->zVelocity);
u32 i;
for (i = 0; i <= 3; ++i) {
- if (entities[i] != NULL && (sub_080177A0(this, entities[i]) != 0)) {
+ if (entities[i] != NULL && (IsColliding(this, entities[i]) != 0)) {
if (entities[i]->action < 3) {
entities[i]->action = 3;
entities[i]->actionDelay = 0x1e;
diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c
index d84d0409..3afad118 100644
--- a/src/projectile/dekuSeedProjectile.c
+++ b/src/projectile/dekuSeedProjectile.c
@@ -5,7 +5,7 @@
extern s32 sub_080AF090(Entity*);
extern s32 IsProjectileOffScreen(Entity*);
extern void sub_08016AD2(Entity*);
-extern u32 sub_080177A0(Entity*, Entity*);
+extern u32 IsColliding(Entity*, Entity*);
extern void (*const DekuSeedProjectile_Functions[])(Entity*);
extern void (*const DekuSeedProjectile_Actions[])(Entity*);
@@ -70,7 +70,7 @@ void DekuSeedProjectile_Action1(Entity* this) {
}
if (this->field_0xf != 0) {
parent = this->parent;
- if ((parent->next != NULL) && (sub_080177A0(this, parent) != 0)) {
+ if ((parent->next != NULL) && (IsColliding(this, parent) != 0)) {
this->iframes = 0x10;
this->knockbackDirection = -this->direction;
this->bitfield = 0x80;
diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c
index a4a0d8e1..03769bb0 100644
--- a/src/projectile/dirtBallProjectile.c
+++ b/src/projectile/dirtBallProjectile.c
@@ -48,7 +48,7 @@ void DirtBallProjectile_Init(Entity* this) {
this->action = 1;
this->subAction = 0;
this->spriteSettings.shadow = 1;
- this->zVelocity = 0x8000;
+ this->zVelocity = Q_16_16(0.5);
this->hitbox = (Hitbox*)&gUnk_08129764;
this->field_0x3c |= 0x10;
switch (this->type) {
@@ -76,13 +76,13 @@ void DirtBallProjectile_Action1(Entity* this) {
if (parent->next == NULL) {
this->action = 2;
}
- PositionRelative(parent, this, 0, -0x10000);
+ PositionRelative(parent, this, 0, Q_16_16(-1.0));
switch (this->type) {
case 0:
- this->z.HALF.HI += 0x10;
+ this->z.HALF.HI += Q_8_8(1.0 / 16.0);
break;
case 1:
- this->z.HALF.HI += 0xe;
+ this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0);
sub_08078954(this->child);
CopyPosition(this, this->child);
if ((0xf < (u8)(this->actionDelay++ + 1)) && (entity = this->child, entity->actionDelay == 0)) {
@@ -96,7 +96,7 @@ void DirtBallProjectile_Action1(Entity* this) {
}
break;
case 2:
- this->z.HALF.HI += 0xe;
+ this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0);
if (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe) != 0) {
this->action = 2;
parent->field_0x82.HALF.HI = 0xc0;
@@ -145,7 +145,7 @@ void DirtBallProjectile_Action2(Entity* this) {
switch (this->type) {
case 0:
InitializeAnimation(this, 1);
- EnqueueSFX(0x84);
+ EnqueueSFX(SFX_WATER_SPLASH);
this->action = 3;
return;
case 2:
diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c
index 959d3957..128e32f7 100644
--- a/src/projectile/gleerokProjectile.c
+++ b/src/projectile/gleerokProjectile.c
@@ -4,7 +4,6 @@
#include "player.h"
#include "functions.h"
-extern void sub_0806F5BC(Entity*, u32, u32);
extern u32 sub_080041DC(Entity*, u32, u32);
extern void (*const GleerokProjectile_Functions[])(Entity*);
@@ -33,10 +32,10 @@ void GleerokProjectile_Init(Entity* this) {
s32 iVar2;
this->action = 1;
- this->zVelocity = -0x10000;
+ this->zVelocity = Q_16_16(-1.0);
if (this->type != 3) {
CopyPosition(this->parent, this);
- sub_0806F5BC(this, 0x1000, this->direction);
+ LinearMoveDirection(this, 0x1000, this->direction);
this->z.WORD = this->parent->y.WORD - this->child->y.WORD;
this->y.WORD -= this->z.WORD;
InitializeAnimation(this, 0x51);
diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c
index 8e9983cc..f654133e 100644
--- a/src/projectile/gyorgMaleEnergyProjectile.c
+++ b/src/projectile/gyorgMaleEnergyProjectile.c
@@ -33,7 +33,7 @@ void sub_080AC8DC(Entity* this) {
default: {
if (this->action != 3) {
this->action = 3;
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
this->speed >>= 1;
InitializeAnimation(this, 1);
}
@@ -60,8 +60,8 @@ void GyorgMaleEnergyProjectile_Action1(Entity* this) {
DeleteThisEntity();
}
animationState = this->parent->animationState;
- PositionRelative(this->parent, this, gSineTable[animationState] * 0x2800,
- gSineTable[animationState + 0x40] * -0x2800);
+ PositionRelative(this->parent, this, gSineTable[animationState] * Q_16_16(5.0 / 32.0),
+ gSineTable[animationState + 0x40] * Q_16_16(-5.0 / 32.0));
GetNextFrame(this);
if (--this->actionDelay == 0) {
this->action = 2;
diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c
index ce7d2d21..f66dd20e 100644
--- a/src/projectile/lakituCloudProjectile.c
+++ b/src/projectile/lakituCloudProjectile.c
@@ -42,7 +42,7 @@ void LakituCloudProjectile_SubAction2(Entity* this) {
if (sub_0806F3E4(this) != 0) {
if (this->hitType == 0xa6) {
ModHealth(-2);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
sub_08079D84();
}
CreateFx(this, FX_DEATH, 0);
@@ -57,8 +57,8 @@ void LakituCloudProjectile_Init(Entity* this) {
}
void LakituCloudProjectile_Action1(Entity* this) {
- PositionRelative(this->parent, this, 0, -0x10000);
- this->z.HALF.HI = 0xfffe;
+ PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
+ this->z.HALF.HI = -2;
UpdateAnimationSingleFrame(this);
}
diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c
index 0e5599a2..26e2fe24 100644
--- a/src/projectile/mandiblesProjectile.c
+++ b/src/projectile/mandiblesProjectile.c
@@ -4,10 +4,6 @@
#include "functions.h"
#include "game.h"
-extern Entity* sub_08049DF4(u32);
-extern u32 sub_08049F1C(Entity*, Entity*, u32);
-extern s32 sub_080AF090(Entity*);
-extern u32 sub_0806F824(Entity*, Entity*, u32, u32);
extern Hitbox gHitbox_0;
extern void (*const MandiblesProjectile_Functions[])(Entity*);
@@ -81,7 +77,7 @@ void MandiblesProjectile_Init(Entity* this) {
this->animationState = 0xff;
this->field_0x82.HALF.LO = 0;
this->spritePriority.b0 = 4;
- ResolveEntityBelow(this, this->parent);
+ SortEntityBelow(this, this->parent);
sub_080AA270(this);
}
@@ -112,9 +108,6 @@ void MandiblesProjectile_Action2(Entity* this) {
}
}
-#ifdef EU
-ASM_FUNC("asm/non_matching/eu/MandiblesProjectile_Action3.inc", void MandiblesProjectile_Action3(Entity* this))
-#else
void MandiblesProjectile_Action3(Entity* this) {
u32 uVar1;
s8* tmp;
@@ -129,9 +122,9 @@ void MandiblesProjectile_Action3(Entity* this) {
} else {
tmp = GetSpriteSubEntryOffsetDataPointer((u16)entity->spriteIndex, entity->frameIndex);
if ((entity->animationState & 4) != 0) {
- PositionRelative(entity, this, -tmp[0] * 0x10000, tmp[1] << 0x10);
+ PositionRelative(entity, this, Q_16_16(-tmp[0]), Q_16_16(tmp[1]));
} else {
- PositionRelative(entity, this, tmp[0] << 0x10, tmp[1] << 0x10);
+ PositionRelative(entity, this, Q_16_16(tmp[0]), Q_16_16(tmp[1]));
}
}
if (entity->field_0x43 == 0) {
@@ -146,16 +139,20 @@ void MandiblesProjectile_Action3(Entity* this) {
uVar1 = entity->animationState;
this->direction = uVar1 << 2;
this->animationState = uVar1 << 0x1a >> 0x1a;
+#ifdef EU
+ this->spriteOrientation.flipY = 1;
+ this->hitbox = &gHitbox_0;
+#else
this->hitbox = &gHitbox_0;
if (AreaIsDungeon() != 0) {
this->spriteOrientation.flipY = 1;
}
+#endif
sub_080AA3E0(this, 0);
}
}
}
}
-#endif
void MandiblesProjectile_Action4(Entity* this) {
s32 iVar1;
@@ -174,7 +171,7 @@ void MandiblesProjectile_Action4(Entity* this) {
if (entity->health == 0) {
DeleteThisEntity();
}
- EnqueueSFX(0xf2);
+ EnqueueSFX(SFX_F2);
this->action = 1;
this->animationState = 0xff;
this->field_0x82.HALF.LO = 0;
@@ -216,9 +213,9 @@ void sub_080AA1D8(Entity* this) {
if ((parent->frameIndex & 0x20) == 0) {
tmp = GetSpriteSubEntryOffsetDataPointer((u16)parent->spriteIndex, parent->frameIndex);
if ((parent->animationState & 4) != 0) {
- PositionRelative(parent, this, -tmp[0] * 0x10000, tmp[1] << 0x10);
+ PositionRelative(parent, this, Q_16_16(-tmp[0]), Q_16_16(tmp[1]));
} else {
- PositionRelative(parent, this, tmp[0] << 0x10, tmp[1] << 0x10);
+ PositionRelative(parent, this, Q_16_16(tmp[0]), Q_16_16(tmp[1]));
}
if (parent->field_0x43 != 0) {
if ((this->flags & ENT_COLLIDE) != 0) {
@@ -307,8 +304,8 @@ NONMATCH("asm/non_matching/mandiblesProjectile/sub_080AA374.inc", bool32 sub_080
// TODO regalloc
animationState = this->child->animationState;
uVar1 = sub_0806F824(this, this->child, gUnk_08129D14[animationState], gUnk_08129D14[animationState + 1]);
- if (sub_0806FCB8(this, this->child->x.HALF.HI + gUnk_08129D14[animationState],
- this->child->y.HALF.HI + gUnk_08129D14[animationState + 1], 8) != 0) {
+ if (EntityWithinDistance(this, this->child->x.HALF.HI + gUnk_08129D14[animationState],
+ this->child->y.HALF.HI + gUnk_08129D14[animationState + 1], 8) != 0) {
result = TRUE;
} else {
sub_08004596(this, uVar1);
diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c
index b5ed8193..1f5c8ddd 100644
--- a/src/projectile/octorokBossProjectile.c
+++ b/src/projectile/octorokBossProjectile.c
@@ -5,7 +5,6 @@
void OctorokBossProjectile_Action2(Entity*);
extern void sub_080AE58C(Entity*, u32, u32);
-extern u32 sub_0806FC80(Entity*, Entity*, s32);
extern void (*const OctorokBossProjectile_Functions[])(Entity*);
extern void (*const OctorokBossProjectile_Actions[])(Entity*);
@@ -34,7 +33,7 @@ void OctorokBossProjectile_Init(Entity* this) {
switch (this->type) {
case 0:
- sub_0806F62C(this, 0x4800, this->direction);
+ LinearMoveAngle(this, 0x4800, this->direction);
this->speed = 0x200;
this->actionDelay = 0;
this->field_0xf = this->direction;
@@ -45,11 +44,11 @@ void OctorokBossProjectile_Init(Entity* this) {
this->spriteRendering.b3 = 3;
this->spritePriority.b0 = 6;
this->speed = (Random() & 0x1ff) + 0x200;
- this->zVelocity = (Random() & 0x1fff) + 0x18000;
+ this->zVelocity = (Random() & 0x1fff) + Q_16_16(1.5);
uVar1 = (((u8)Random() & 7) - 4);
this->direction -= uVar1;
*(u32*)&this->field_0x78 = 600;
- sub_0806F62C(this, this->speed, this->direction);
+ LinearMoveAngle(this, this->speed, this->direction);
InitializeAnimation(this, 4);
break;
case 2:
@@ -60,7 +59,7 @@ void OctorokBossProjectile_Init(Entity* this) {
}
this->speed = 0x200;
this->actionDelay = 0x30;
- sub_0806F62C(this, 0x5000, this->direction);
+ LinearMoveAngle(this, 0x5000, this->direction);
InitializeAnimation(this, 5);
break;
case 3:
@@ -114,7 +113,7 @@ void OctorokBossProjectile_Action1(Entity* this) {
}
UpdateAnimationSingleFrame(this);
this->field_0x78.HWORD--;
- sub_0806F62C(this, this->speed, this->direction);
+ LinearMoveAngle(this, this->speed, this->direction);
sub_080AE58C(this, this->direction >> 3, 0);
if ((this->collisions & 0xee00) != 0) {
this->direction = -this->direction;
@@ -154,7 +153,7 @@ void OctorokBossProjectile_Action1(Entity* this) {
if (GravityUpdate(this, 0x1800) != 0) {
sub_080AE58C(this, this->direction >> 3, 0);
if (this->collisions == 0) {
- sub_0806F62C(this, (s32)this->speed, (u32)this->direction);
+ LinearMoveAngle(this, (s32)this->speed, (u32)this->direction);
} else {
OctorokBossProjectile_Action2(this);
}
@@ -177,7 +176,7 @@ void OctorokBossProjectile_Action1(Entity* this) {
case 2:
GetNextFrame(this);
if (--this->actionDelay != 0xff) {
- sub_0806F62C(this, this->speed, this->direction);
+ LinearMoveAngle(this, this->speed, this->direction);
return;
}
if (this->child != NULL) {
diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c
index 7254631b..66e8388f 100644
--- a/src/projectile/rockProjectile.c
+++ b/src/projectile/rockProjectile.c
@@ -31,7 +31,7 @@ void sub_080A8064(Entity* this) {
void RockProjectile_Init(Entity* this) {
this->action = 1;
this->actionDelay = 0x30;
- this->zVelocity = 0xa000;
+ this->zVelocity = Q_16_16(0.625);
InitializeAnimation(this, 0);
}
@@ -86,7 +86,7 @@ void sub_080A8178(Entity* this) {
this->action = 2;
COLLISION_OFF(this);
this->speed = 0x40;
- this->zVelocity = 0x14000;
+ this->zVelocity = Q_16_16(1.25);
}
void (*const RockProjectile_Functions[])(Entity*) = {
diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c
index 40bc8007..c6176fa7 100644
--- a/src/projectile/spiderWeb.c
+++ b/src/projectile/spiderWeb.c
@@ -8,10 +8,6 @@ typedef struct {
u8 direction;
} PACKED Struct_0812A074;
-extern void sub_0806FBB4(Entity*);
-extern u32 sub_080002D4(s32, s32, u32);
-extern void sub_08078930(Entity*);
-
extern void (*const SpiderWeb_Functions[])(Entity*);
extern void (*const SpiderWeb_Actions[])(Entity*);
extern const u8 gUnk_0812A03C[];
@@ -153,7 +149,7 @@ void SpiderWeb_SubAction0(Entity* this) {
if ((this->frame & 1) != 0) {
entity->x.HALF.HI = gUnk_0812A06C[entity->animationState] + entity->x.HALF.HI;
entity->y.HALF.HI = gUnk_0812A06C[entity->animationState + 1] + entity->y.HALF.HI;
- EnqueueSFX(0x100);
+ EnqueueSFX(SFX_100);
}
}
}
diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c
index 709907e0..841a68e3 100644
--- a/src/projectile/stalfosProjectile.c
+++ b/src/projectile/stalfosProjectile.c
@@ -32,7 +32,7 @@ void sub_080A9A34(Entity* this) {
if (this->bitfield == 0x9d) {
this->action = 3;
COLLISION_OFF(this);
- this->zVelocity = 0x2a000;
+ this->zVelocity = Q_16_16(2.625);
this->spritePriority.b1 = 1;
}
}
@@ -76,7 +76,7 @@ void StalfosProjectile_Init(Entity* this) {
break;
case 2:
this->action = 3;
- this->zVelocity = 0x2a000;
+ this->zVelocity = Q_16_16(2.625);
this->spritePriority.b1 = 1;
break;
default:
diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c
index c9a3d281..c8320212 100644
--- a/src/projectile/v1DarkMagicProjectile.c
+++ b/src/projectile/v1DarkMagicProjectile.c
@@ -31,9 +31,9 @@ void sub_080AAC44(Entity* this) {
this->action = 2;
COLLISION_OFF(this);
if (this->type == 0) {
- ResolveEntityOnTop(&gPlayerEntity, this);
+ SortEntityAbove(&gPlayerEntity, this);
} else {
- ResolveEntityOnTop(this->parent, this);
+ SortEntityAbove(this->parent, this);
}
ResetPlayer();
gPlayerState.mobility |= 0x80;
@@ -114,7 +114,7 @@ void V1DarkMagicProjectile_Init(Entity* this) {
} else {
this->action = 3;
this->hitType = 0x2c;
- ResolveEntityOnTop(this->parent, this);
+ SortEntityAbove(this->parent, this);
}
if (this->type == 0) {
this->actionDelay = 0;
@@ -136,7 +136,7 @@ void V1DarkMagicProjectile_Init(Entity* this) {
entity->parent = this;
}
} else {
- ResolveEntityOnTop(this->parent, this);
+ SortEntityAbove(this->parent, this);
COLLISION_OFF(this);
CopyPosition(this->parent, this);
}
@@ -203,7 +203,7 @@ void sub_080AAF74(Entity* this) {
this->actionDelay = 0x1e;
gPlayerEntity.iframes = 8;
ModHealth(-4);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
if (gPlayerEntity.health == 0) {
this->health = 0;
}
diff --git a/src/projectile/v1EyeLaser.c b/src/projectile/v1EyeLaser.c
index 8bdb0652..de642d5d 100644
--- a/src/projectile/v1EyeLaser.c
+++ b/src/projectile/v1EyeLaser.c
@@ -99,7 +99,7 @@ void sub_080AB844(Entity* this, s32 param_1, s32 param_2) {
entity->type = 1;
entity->actionDelay = param_1;
entity->parent = this->parent;
- PositionRelative(this, entity, 0, param_2 << 0x10);
+ PositionRelative(this, entity, 0, Q_16_16(param_2));
if (param_1 != 1) {
entity->hitbox = (Hitbox*)&gUnk_0812A61C;
} else {
diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c
index 68cad995..2823d563 100644
--- a/src/projectile/v1FireProjectile.c
+++ b/src/projectile/v1FireProjectile.c
@@ -3,7 +3,6 @@
#include "player.h"
#include "functions.h"
-extern void sub_0806F5BC(Entity*, u32, u32);
extern u32 sub_080041DC(Entity*, u32, u32);
extern void (*const V1FireProjectile_Functions[])(Entity*);
@@ -40,10 +39,10 @@ void V1FireProjectile_Init(Entity* this) {
s8* data;
this->action = 1;
- this->zVelocity = -0x10000;
+ this->zVelocity = Q_16_16(-1.0);
this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI);
CopyPosition(this->parent, this);
- sub_0806F5BC(this, 0x1000, this->direction);
+ LinearMoveDirection(this, 0x1000, this->direction);
this->spritePriority.b0 = 1;
this->z = this->parent->z;
InitializeAnimation(this, 0x51);
diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c
index 5d9f6eb2..fc863d53 100644
--- a/src/projectile/v2Projectile.c
+++ b/src/projectile/v2Projectile.c
@@ -84,7 +84,7 @@ void nullsub_542(Entity* this) {
void sub_080ABC90(Entity* this) {
if (sub_0806F3E4(this) != 0) {
ModHealth(-2);
- SoundReqClipped(&gPlayerEntity, 0x7a);
+ SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
sub_08079D84();
CreateFx(this, FX_DEATH, 0);
DeleteThisEntity();
@@ -138,7 +138,7 @@ void sub_080ABE04(Entity* this) {
u32 rand = Random() & 0xff;
u32 newX;
this->action = 1;
- this->zVelocity = 0xffff0000;
+ this->zVelocity = Q_16_16(-1.0);
this->z.HALF.HI -= 0xa0;
this->x.HALF.HI = (gRoomControls.origin_x & 0x7ff0) | 0x8;
this->y.HALF.HI = (gRoomControls.origin_y & 0x7ff0) | 0x8;
diff --git a/src/projectile/v3ElectricProjectile.c b/src/projectile/v3ElectricProjectile.c
index a3461f03..869d02aa 100644
--- a/src/projectile/v3ElectricProjectile.c
+++ b/src/projectile/v3ElectricProjectile.c
@@ -43,7 +43,7 @@ void sub_080ABFEC(Entity* this) {
}
case 1: {
this->action = 1;
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
this->cutsceneBeh.HALF.HI = 0x18;
CopyPositionAndSpriteOffset(this->parent, this);
this->z.HALF.HI -= 0x14;
diff --git a/src/projectile/v3TennisBallProjectile.c b/src/projectile/v3TennisBallProjectile.c
index 00fc5da7..b25cbf48 100644
--- a/src/projectile/v3TennisBallProjectile.c
+++ b/src/projectile/v3TennisBallProjectile.c
@@ -26,7 +26,7 @@ void sub_080ACA68(Entity* this) {
case 0xc:
case 0x6: {
this->action = 2;
- this->flags &= 0x7f;
+ this->flags &= ~ENT_COLLIDE;
this->speed += 0x80 * 2;
this->child = this->field_0x4c;
if (sub_080ACB40(this)) {
diff --git a/src/projectileUtils.c b/src/projectileUtils.c
index 414f7dc7..31bac370 100644
--- a/src/projectileUtils.c
+++ b/src/projectileUtils.c
@@ -77,7 +77,7 @@ bool32 IsProjectileOffScreen(Entity* this) {
Entity* CreateProjectile(u32 id) {
Entity* entity = GetEmptyEntity();
if (entity != NULL) {
- entity->kind = 4;
+ entity->kind = PROJECTILE;
entity->id = id;
AppendEntityToList(entity, 5);
}
diff --git a/src/respawnPlayer.c b/src/respawnPlayer.c
index 24d23b65..4a201c4e 100644
--- a/src/respawnPlayer.c
+++ b/src/respawnPlayer.c
@@ -31,7 +31,7 @@ void ResetPlayer() {
case 2:
case 3:
case 4: {
- gPlayerState.framestate = 0;
+ gPlayerState.framestate = PL_STATE_IDLE;
break;
}
}
diff --git a/src/room.c b/src/room.c
index 7e5ffa99..cbc94ff1 100644
--- a/src/room.c
+++ b/src/room.c
@@ -194,7 +194,7 @@ void sub_0804B058(EntityData* dat) {
if ((uVar2 < 0x20) && ((dat->kind & 0xF) == 3)) {
if (sub_08049D1C(uVar2) != 0) {
ent = LoadRoomEntity(dat);
- if ((ent != NULL) && (ent->kind == 3)) {
+ if ((ent != NULL) && (ent->kind == ENEMY)) {
ent->field_0x6c.HALF.LO = uVar2 | 0x80;
}
}
diff --git a/src/roomInit.c b/src/roomInit.c
index e4fd06fa..baaadce7 100644
--- a/src/roomInit.c
+++ b/src/roomInit.c
@@ -5313,7 +5313,7 @@ void sub_StateChange_HouseInteriors3_Bakery(void) {
u32 sub_unk3_HouseInteriors3_Simon(void) {
if (CheckGlobalFlag(MAROYA_WAKEUP)) {
- gRoomTransition.player_status.spawn_type = 5;
+ gRoomTransition.player_status.spawn_type = PL_SPAWN_SPECIAL;
}
return 1;
}
@@ -5798,14 +5798,14 @@ void sub_0804F79C(Entity* parent) {
fx = CreateFx(parent, FX_BIG_EXPLOSION, 0);
if (fx != NULL) {
fx->spriteRendering.b3 = 0;
- fx->x.HALF.HI = gRoomControls.origin_x + 0x1b8;
- fx->y.HALF.HI = gRoomControls.origin_y + 0x148;
+ fx->x.HALF.HI = gRoomControls.origin_x + Q_8_8(1.72);
+ fx->y.HALF.HI = gRoomControls.origin_y + Q_8_8(1.285);
}
fx = CreateFx(parent, FX_BIG_EXPLOSION, 0);
if (fx != NULL) {
fx->spriteRendering.b3 = 0;
- fx->x.HALF.HI = gRoomControls.origin_x + 0x238;
- fx->y.HALF.HI = gRoomControls.origin_y + 0x148;
+ fx->x.HALF.HI = gRoomControls.origin_x + Q_8_8(2.22);
+ fx->y.HALF.HI = gRoomControls.origin_y + Q_8_8(1.285);
}
}
diff --git a/src/script.c b/src/script.c
index b7dab735..b59885f2 100644
--- a/src/script.c
+++ b/src/script.c
@@ -258,7 +258,7 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) {
case 1 << 0x02:
break;
case 1 << 0x03:
- entity->zVelocity = 0x18000;
+ entity->zVelocity = Q_16_16(1.5);
break;
case 1 << 0x04:
CreateSpeechBubbleExclamationMark(entity, 8, -0x18);
@@ -1396,7 +1396,7 @@ void ScriptCommand_0807EE30(Entity* entity, ScriptExecutionContext* context) {
}
tmp = entity->x.HALF.HI - context->x.HALF.HI;
tmp2 = entity->y.HALF.HI - context->y.HALF.HI;
- sub_0806F62C(entity, entity->speed, entity->direction);
+ LinearMoveAngle(entity, entity->speed, entity->direction);
tmp *= entity->x.HALF.HI - context->x.HALF.HI;
tmp2 *= entity->y.HALF.HI - context->y.HALF.HI;
if (tmp <= 0 && tmp2 <= 0) {
@@ -1685,7 +1685,7 @@ void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) {
fx = CreateFx(entity, FX_REFLECT4, 0);
if (fx != NULL) {
fx->spritePriority.b0 = 1;
- PositionRelative(entity, fx, 0, -0x80000);
+ PositionRelative(entity, fx, 0, Q_16_16(-8.0));
if (Random() & 1)
fx->spriteSettings.flipX = 1;
if (Random() & 1)
@@ -1749,7 +1749,7 @@ void sub_0807F464(Entity* entity, ScriptExecutionContext* context) {
entity->animationState = (entity->animationState & 0x80) | 6;
}
}
- sub_0806F62C(entity, entity->speed, entity->direction);
+ LinearMoveAngle(entity, entity->speed, entity->direction);
if (((context->x.HALF.HI - entity->x.HALF.HI) ^ ((entity->direction & 0x80) << 24)) < 0)
entity->x.HALF.HI = context->x.HALF.HI;
else
@@ -1773,7 +1773,7 @@ void sub_0807F4F8(Entity* entity, ScriptExecutionContext* context) {
entity->animationState = (entity->animationState & 0x80);
}
}
- sub_0806F62C(entity, entity->speed, entity->direction);
+ LinearMoveAngle(entity, entity->speed, entity->direction);
if (((context->y.HALF.HI - entity->y.HALF.HI) ^ ((entity->direction & 0x80) << 24)) >= 0)
entity->y.HALF.HI = context->y.HALF.HI;
else
@@ -1853,12 +1853,12 @@ void sub_0807F708(Entity* entity, ScriptExecutionContext* context) {
void sub_0807F714(Entity* entity, ScriptExecutionContext* context) {
entity->spriteRendering.b3 = gUnk_08114F30[entity->spriteRendering.b3];
- ResolveEntityOnTop(entity, entity);
+ SortEntityAbove(entity, entity);
}
void sub_0807F738(Entity* entity, ScriptExecutionContext* context) {
entity->spriteRendering.b3 = gUnk_08114F34[entity->spriteRendering.b3];
- ResolveEntityBelow(entity, entity);
+ SortEntityBelow(entity, entity);
}
void SetPlayerPos(Entity* entity, ScriptExecutionContext* context) {
@@ -2121,7 +2121,7 @@ void sub_0807FBCC(Entity* entity, ScriptExecutionContext* context) {
}
void sub_0807FBD4(Entity* entity, ScriptExecutionContext* context) {
- sub_0806F62C(entity, entity->speed, entity->direction);
+ LinearMoveAngle(entity, entity->speed, entity->direction);
if (CheckOnScreen(entity))
gActiveScriptInfo.commandSize = 0;
}
diff --git a/src/scroll.c b/src/scroll.c
index cdae49f4..de61b0ec 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -89,14 +89,12 @@ void sub_08080974(u32 arg0, u32 arg1) {
}
void sub_080809D4(void) {
- register Entity* target asm("r4");
int x, y;
int var1, var0;
RoomControls* roomControls = &gRoomControls;
roomControls->scroll_flags &= ~4;
- target = roomControls->camera_target;
- x = target->x.HALF.HI;
+ x = roomControls->camera_target->x.HALF.HI;
var0 = roomControls->origin_x;
if (x <= var0 + 120) {
roomControls->scroll_x = var0;
@@ -104,13 +102,12 @@ void sub_080809D4(void) {
var0 += roomControls->width;
var1 = var0 - 120;
if (x < var1) {
- var1 = (u16)target->x.HALF.HI;
+ var1 = (u16)roomControls->camera_target->x.HALF.HI;
}
roomControls->scroll_x = var1 - 120;
}
- target = roomControls->camera_target;
- y = target->y.HALF.HI;
+ y = roomControls->camera_target->y.HALF.HI;
var0 = roomControls->origin_y;
if (y <= var0 + 80) {
roomControls->scroll_y = var0;
@@ -118,7 +115,7 @@ void sub_080809D4(void) {
var0 += roomControls->height;
var1 = var0 - 80;
if (y < var1) {
- var1 = (u16)target->y.HALF.HI;
+ var1 = (u16)roomControls->camera_target->y.HALF.HI;
}
roomControls->scroll_y = var1 - 80;
}
diff --git a/src/sineTable.c b/src/sineTable.c
new file mode 100644
index 00000000..aba0e6be
--- /dev/null
+++ b/src/sineTable.c
@@ -0,0 +1,328 @@
+#include "global.h"
+
+// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319
+const s16 gSineTable[64] = {
+ Q_8_8(0), // sin(0*(π/128))
+ Q_8_8(0.0234375), // sin(1*(π/128))
+ Q_8_8(0.046875), // sin(2*(π/128))
+ Q_8_8(0.0703125), // sin(3*(π/128))
+ Q_8_8(0.09765625), // sin(4*(π/128))
+ Q_8_8(0.12109375), // sin(5*(π/128))
+ Q_8_8(0.14453125), // sin(6*(π/128))
+ Q_8_8(0.16796875), // sin(7*(π/128))
+ Q_8_8(0.19140625), // sin(8*(π/128))
+ Q_8_8(0.21875), // sin(9*(π/128))
+ Q_8_8(0.2421875), // sin(10*(π/128))
+ Q_8_8(0.265625), // sin(11*(π/128))
+ Q_8_8(0.2890625), // sin(12*(π/128))
+ Q_8_8(0.3125), // sin(13*(π/128))
+ Q_8_8(0.3359375), // sin(14*(π/128))
+ Q_8_8(0.359375), // sin(15*(π/128))
+ Q_8_8(0.37890625), // sin(16*(π/128))
+ Q_8_8(0.40234375), // sin(17*(π/128))
+ Q_8_8(0.42578125), // sin(18*(π/128))
+ Q_8_8(0.44921875), // sin(19*(π/128))
+ Q_8_8(0.46875), // sin(20*(π/128))
+ Q_8_8(0.4921875), // sin(21*(π/128))
+ Q_8_8(0.51171875), // sin(22*(π/128))
+ Q_8_8(0.53125), // sin(23*(π/128))
+ Q_8_8(0.5546875), // sin(24*(π/128))
+ Q_8_8(0.57421875), // sin(25*(π/128))
+ Q_8_8(0.59375), // sin(26*(π/128))
+ Q_8_8(0.61328125), // sin(27*(π/128))
+ Q_8_8(0.6328125), // sin(28*(π/128))
+ Q_8_8(0.65234375), // sin(29*(π/128))
+ Q_8_8(0.66796875), // sin(30*(π/128))
+ Q_8_8(0.6875), // sin(31*(π/128))
+ Q_8_8(0.70703125), // sin(32*(π/128))
+ Q_8_8(0.72265625), // sin(33*(π/128))
+ Q_8_8(0.73828125), // sin(34*(π/128))
+ Q_8_8(0.75390625), // sin(35*(π/128))
+ Q_8_8(0.76953125), // sin(36*(π/128))
+ Q_8_8(0.78515625), // sin(37*(π/128))
+ Q_8_8(0.80078125), // sin(38*(π/128))
+ Q_8_8(0.81640625), // sin(39*(π/128))
+ Q_8_8(0.828125), // sin(40*(π/128))
+ Q_8_8(0.84375), // sin(41*(π/128))
+ Q_8_8(0.85546875), // sin(42*(π/128))
+ Q_8_8(0.8671875), // sin(43*(π/128))
+ Q_8_8(0.87890625), // sin(44*(π/128))
+ Q_8_8(0.890625), // sin(45*(π/128))
+ Q_8_8(0.90234375), // sin(46*(π/128))
+ Q_8_8(0.9140625), // sin(47*(π/128))
+ Q_8_8(0.921875), // sin(48*(π/128))
+ Q_8_8(0.9296875), // sin(49*(π/128))
+ Q_8_8(0.94140625), // sin(50*(π/128))
+ Q_8_8(0.94921875), // sin(51*(π/128))
+ Q_8_8(0.953125), // sin(52*(π/128))
+ Q_8_8(0.9609375), // sin(53*(π/128))
+ Q_8_8(0.96875), // sin(54*(π/128))
+ Q_8_8(0.97265625), // sin(55*(π/128))
+ Q_8_8(0.98046875), // sin(56*(π/128))
+ Q_8_8(0.984375), // sin(57*(π/128))
+ Q_8_8(0.98828125), // sin(58*(π/128))
+ Q_8_8(0.9921875), // sin(59*(π/128))
+ Q_8_8(0.9921875), // sin(60*(π/128))
+ Q_8_8(0.99609375), // sin(61*(π/128))
+ Q_8_8(0.99609375), // sin(62*(π/128))
+ Q_8_8(0.99609375), // sin(63*(π/128))
+};
+
+const s16 gCosineTable[256] = {
+ Q_8_8(1), // sin(64*(π/128))
+ Q_8_8(0.99609375), // sin(65*(π/128))
+ Q_8_8(0.99609375), // sin(66*(π/128))
+ Q_8_8(0.99609375), // sin(67*(π/128))
+ Q_8_8(0.9921875), // sin(68*(π/128))
+ Q_8_8(0.9921875), // sin(69*(π/128))
+ Q_8_8(0.98828125), // sin(70*(π/128))
+ Q_8_8(0.984375), // sin(71*(π/128))
+ Q_8_8(0.98046875), // sin(72*(π/128))
+ Q_8_8(0.97265625), // sin(73*(π/128))
+ Q_8_8(0.96875), // sin(74*(π/128))
+ Q_8_8(0.9609375), // sin(75*(π/128))
+ Q_8_8(0.953125), // sin(76*(π/128))
+ Q_8_8(0.94921875), // sin(77*(π/128))
+ Q_8_8(0.94140625), // sin(78*(π/128))
+ Q_8_8(0.9296875), // sin(79*(π/128))
+ Q_8_8(0.921875), // sin(80*(π/128))
+ Q_8_8(0.9140625), // sin(81*(π/128))
+ Q_8_8(0.90234375), // sin(82*(π/128))
+ Q_8_8(0.890625), // sin(83*(π/128))
+ Q_8_8(0.87890625), // sin(84*(π/128))
+ Q_8_8(0.8671875), // sin(85*(π/128))
+ Q_8_8(0.85546875), // sin(86*(π/128))
+ Q_8_8(0.84375), // sin(87*(π/128))
+ Q_8_8(0.828125), // sin(88*(π/128))
+ Q_8_8(0.81640625), // sin(89*(π/128))
+ Q_8_8(0.80078125), // sin(90*(π/128))
+ Q_8_8(0.78515625), // sin(91*(π/128))
+ Q_8_8(0.76953125), // sin(92*(π/128))
+ Q_8_8(0.75390625), // sin(93*(π/128))
+ Q_8_8(0.73828125), // sin(94*(π/128))
+ Q_8_8(0.72265625), // sin(95*(π/128))
+ Q_8_8(0.70703125), // sin(96*(π/128))
+ Q_8_8(0.6875), // sin(97*(π/128))
+ Q_8_8(0.66796875), // sin(98*(π/128))
+ Q_8_8(0.65234375), // sin(99*(π/128))
+ Q_8_8(0.6328125), // sin(100*(π/128))
+ Q_8_8(0.61328125), // sin(101*(π/128))
+ Q_8_8(0.59375), // sin(102*(π/128))
+ Q_8_8(0.57421875), // sin(103*(π/128))
+ Q_8_8(0.5546875), // sin(104*(π/128))
+ Q_8_8(0.53125), // sin(105*(π/128))
+ Q_8_8(0.51171875), // sin(106*(π/128))
+ Q_8_8(0.4921875), // sin(107*(π/128))
+ Q_8_8(0.46875), // sin(108*(π/128))
+ Q_8_8(0.44921875), // sin(109*(π/128))
+ Q_8_8(0.42578125), // sin(110*(π/128))
+ Q_8_8(0.40234375), // sin(111*(π/128))
+ Q_8_8(0.37890625), // sin(112*(π/128))
+ Q_8_8(0.359375), // sin(113*(π/128))
+ Q_8_8(0.3359375), // sin(114*(π/128))
+ Q_8_8(0.3125), // sin(115*(π/128))
+ Q_8_8(0.2890625), // sin(116*(π/128))
+ Q_8_8(0.265625), // sin(117*(π/128))
+ Q_8_8(0.2421875), // sin(118*(π/128))
+ Q_8_8(0.21875), // sin(119*(π/128))
+ Q_8_8(0.19140625), // sin(120*(π/128))
+ Q_8_8(0.16796875), // sin(121*(π/128))
+ Q_8_8(0.14453125), // sin(122*(π/128))
+ Q_8_8(0.12109375), // sin(123*(π/128))
+ Q_8_8(0.09765625), // sin(124*(π/128))
+ Q_8_8(0.0703125), // sin(125*(π/128))
+ Q_8_8(0.046875), // sin(126*(π/128))
+ Q_8_8(0.0234375), // sin(127*(π/128))
+ Q_8_8(0), // sin(128*(π/128))
+ Q_8_8(-0.0234375), // sin(129*(π/128))
+ Q_8_8(-0.046875), // sin(130*(π/128))
+ Q_8_8(-0.0703125), // sin(131*(π/128))
+ Q_8_8(-0.09765625), // sin(132*(π/128))
+ Q_8_8(-0.12109375), // sin(133*(π/128))
+ Q_8_8(-0.14453125), // sin(134*(π/128))
+ Q_8_8(-0.16796875), // sin(135*(π/128))
+ Q_8_8(-0.19140625), // sin(136*(π/128))
+ Q_8_8(-0.21875), // sin(137*(π/128))
+ Q_8_8(-0.2421875), // sin(138*(π/128))
+ Q_8_8(-0.265625), // sin(139*(π/128))
+ Q_8_8(-0.2890625), // sin(140*(π/128))
+ Q_8_8(-0.3125), // sin(141*(π/128))
+ Q_8_8(-0.3359375), // sin(142*(π/128))
+ Q_8_8(-0.359375), // sin(143*(π/128))
+ Q_8_8(-0.37890625), // sin(144*(π/128))
+ Q_8_8(-0.40234375), // sin(145*(π/128))
+ Q_8_8(-0.42578125), // sin(146*(π/128))
+ Q_8_8(-0.44921875), // sin(147*(π/128))
+ Q_8_8(-0.46875), // sin(148*(π/128))
+ Q_8_8(-0.4921875), // sin(149*(π/128))
+ Q_8_8(-0.51171875), // sin(150*(π/128))
+ Q_8_8(-0.53125), // sin(151*(π/128))
+ Q_8_8(-0.5546875), // sin(152*(π/128))
+ Q_8_8(-0.57421875), // sin(153*(π/128))
+ Q_8_8(-0.59375), // sin(154*(π/128))
+ Q_8_8(-0.61328125), // sin(155*(π/128))
+ Q_8_8(-0.6328125), // sin(156*(π/128))
+ Q_8_8(-0.65234375), // sin(157*(π/128))
+ Q_8_8(-0.66796875), // sin(158*(π/128))
+ Q_8_8(-0.6875), // sin(159*(π/128))
+ Q_8_8(-0.70703125), // sin(160*(π/128))
+ Q_8_8(-0.72265625), // sin(161*(π/128))
+ Q_8_8(-0.73828125), // sin(162*(π/128))
+ Q_8_8(-0.75390625), // sin(163*(π/128))
+ Q_8_8(-0.76953125), // sin(164*(π/128))
+ Q_8_8(-0.78515625), // sin(165*(π/128))
+ Q_8_8(-0.80078125), // sin(166*(π/128))
+ Q_8_8(-0.81640625), // sin(167*(π/128))
+ Q_8_8(-0.828125), // sin(168*(π/128))
+ Q_8_8(-0.84375), // sin(169*(π/128))
+ Q_8_8(-0.85546875), // sin(170*(π/128))
+ Q_8_8(-0.8671875), // sin(171*(π/128))
+ Q_8_8(-0.87890625), // sin(172*(π/128))
+ Q_8_8(-0.890625), // sin(173*(π/128))
+ Q_8_8(-0.90234375), // sin(174*(π/128))
+ Q_8_8(-0.9140625), // sin(175*(π/128))
+ Q_8_8(-0.921875), // sin(176*(π/128))
+ Q_8_8(-0.9296875), // sin(177*(π/128))
+ Q_8_8(-0.94140625), // sin(178*(π/128))
+ Q_8_8(-0.94921875), // sin(179*(π/128))
+ Q_8_8(-0.953125), // sin(180*(π/128))
+ Q_8_8(-0.9609375), // sin(181*(π/128))
+ Q_8_8(-0.96875), // sin(182*(π/128))
+ Q_8_8(-0.97265625), // sin(183*(π/128))
+ Q_8_8(-0.98046875), // sin(184*(π/128))
+ Q_8_8(-0.984375), // sin(185*(π/128))
+ Q_8_8(-0.98828125), // sin(186*(π/128))
+ Q_8_8(-0.9921875), // sin(187*(π/128))
+ Q_8_8(-0.9921875), // sin(188*(π/128))
+ Q_8_8(-0.99609375), // sin(189*(π/128))
+ Q_8_8(-0.99609375), // sin(190*(π/128))
+ Q_8_8(-0.99609375), // sin(191*(π/128))
+ Q_8_8(-1), // sin(192*(π/128))
+ Q_8_8(-0.99609375), // sin(193*(π/128))
+ Q_8_8(-0.99609375), // sin(194*(π/128))
+ Q_8_8(-0.99609375), // sin(195*(π/128))
+ Q_8_8(-0.9921875), // sin(196*(π/128))
+ Q_8_8(-0.9921875), // sin(197*(π/128))
+ Q_8_8(-0.98828125), // sin(198*(π/128))
+ Q_8_8(-0.984375), // sin(199*(π/128))
+ Q_8_8(-0.98046875), // sin(200*(π/128))
+ Q_8_8(-0.97265625), // sin(201*(π/128))
+ Q_8_8(-0.96875), // sin(202*(π/128))
+ Q_8_8(-0.9609375), // sin(203*(π/128))
+ Q_8_8(-0.953125), // sin(204*(π/128))
+ Q_8_8(-0.94921875), // sin(205*(π/128))
+ Q_8_8(-0.94140625), // sin(206*(π/128))
+ Q_8_8(-0.9296875), // sin(207*(π/128))
+ Q_8_8(-0.921875), // sin(208*(π/128))
+ Q_8_8(-0.9140625), // sin(209*(π/128))
+ Q_8_8(-0.90234375), // sin(210*(π/128))
+ Q_8_8(-0.890625), // sin(211*(π/128))
+ Q_8_8(-0.87890625), // sin(212*(π/128))
+ Q_8_8(-0.8671875), // sin(213*(π/128))
+ Q_8_8(-0.85546875), // sin(214*(π/128))
+ Q_8_8(-0.84375), // sin(215*(π/128))
+ Q_8_8(-0.828125), // sin(216*(π/128))
+ Q_8_8(-0.81640625), // sin(217*(π/128))
+ Q_8_8(-0.80078125), // sin(218*(π/128))
+ Q_8_8(-0.78515625), // sin(219*(π/128))
+ Q_8_8(-0.76953125), // sin(220*(π/128))
+ Q_8_8(-0.75390625), // sin(221*(π/128))
+ Q_8_8(-0.73828125), // sin(222*(π/128))
+ Q_8_8(-0.72265625), // sin(223*(π/128))
+ Q_8_8(-0.70703125), // sin(224*(π/128))
+ Q_8_8(-0.6875), // sin(225*(π/128))
+ Q_8_8(-0.66796875), // sin(226*(π/128))
+ Q_8_8(-0.65234375), // sin(227*(π/128))
+ Q_8_8(-0.6328125), // sin(228*(π/128))
+ Q_8_8(-0.61328125), // sin(229*(π/128))
+ Q_8_8(-0.59375), // sin(230*(π/128))
+ Q_8_8(-0.57421875), // sin(231*(π/128))
+ Q_8_8(-0.5546875), // sin(232*(π/128))
+ Q_8_8(-0.53125), // sin(233*(π/128))
+ Q_8_8(-0.51171875), // sin(234*(π/128))
+ Q_8_8(-0.4921875), // sin(235*(π/128))
+ Q_8_8(-0.46875), // sin(236*(π/128))
+ Q_8_8(-0.44921875), // sin(237*(π/128))
+ Q_8_8(-0.42578125), // sin(238*(π/128))
+ Q_8_8(-0.40234375), // sin(239*(π/128))
+ Q_8_8(-0.37890625), // sin(240*(π/128))
+ Q_8_8(-0.359375), // sin(241*(π/128))
+ Q_8_8(-0.3359375), // sin(242*(π/128))
+ Q_8_8(-0.3125), // sin(243*(π/128))
+ Q_8_8(-0.2890625), // sin(244*(π/128))
+ Q_8_8(-0.265625), // sin(245*(π/128))
+ Q_8_8(-0.2421875), // sin(246*(π/128))
+ Q_8_8(-0.21875), // sin(247*(π/128))
+ Q_8_8(-0.19140625), // sin(248*(π/128))
+ Q_8_8(-0.16796875), // sin(249*(π/128))
+ Q_8_8(-0.14453125), // sin(250*(π/128))
+ Q_8_8(-0.12109375), // sin(251*(π/128))
+ Q_8_8(-0.09765625), // sin(252*(π/128))
+ Q_8_8(-0.0703125), // sin(253*(π/128))
+ Q_8_8(-0.046875), // sin(254*(π/128))
+ Q_8_8(-0.0234375), // sin(255*(π/128))
+ Q_8_8(0), // sin(256*(π/128))
+ Q_8_8(0.0234375), // sin(257*(π/128))
+ Q_8_8(0.046875), // sin(258*(π/128))
+ Q_8_8(0.0703125), // sin(259*(π/128))
+ Q_8_8(0.09765625), // sin(260*(π/128))
+ Q_8_8(0.12109375), // sin(261*(π/128))
+ Q_8_8(0.14453125), // sin(262*(π/128))
+ Q_8_8(0.16796875), // sin(263*(π/128))
+ Q_8_8(0.19140625), // sin(264*(π/128))
+ Q_8_8(0.21875), // sin(265*(π/128))
+ Q_8_8(0.2421875), // sin(266*(π/128))
+ Q_8_8(0.265625), // sin(267*(π/128))
+ Q_8_8(0.2890625), // sin(268*(π/128))
+ Q_8_8(0.3125), // sin(269*(π/128))
+ Q_8_8(0.3359375), // sin(270*(π/128))
+ Q_8_8(0.359375), // sin(271*(π/128))
+ Q_8_8(0.37890625), // sin(272*(π/128))
+ Q_8_8(0.40234375), // sin(273*(π/128))
+ Q_8_8(0.42578125), // sin(274*(π/128))
+ Q_8_8(0.44921875), // sin(275*(π/128))
+ Q_8_8(0.46875), // sin(276*(π/128))
+ Q_8_8(0.4921875), // sin(277*(π/128))
+ Q_8_8(0.51171875), // sin(278*(π/128))
+ Q_8_8(0.53125), // sin(279*(π/128))
+ Q_8_8(0.5546875), // sin(280*(π/128))
+ Q_8_8(0.57421875), // sin(281*(π/128))
+ Q_8_8(0.59375), // sin(282*(π/128))
+ Q_8_8(0.61328125), // sin(283*(π/128))
+ Q_8_8(0.6328125), // sin(284*(π/128))
+ Q_8_8(0.65234375), // sin(285*(π/128))
+ Q_8_8(0.66796875), // sin(286*(π/128))
+ Q_8_8(0.6875), // sin(287*(π/128))
+ Q_8_8(0.70703125), // sin(288*(π/128))
+ Q_8_8(0.72265625), // sin(289*(π/128))
+ Q_8_8(0.73828125), // sin(290*(π/128))
+ Q_8_8(0.75390625), // sin(291*(π/128))
+ Q_8_8(0.76953125), // sin(292*(π/128))
+ Q_8_8(0.78515625), // sin(293*(π/128))
+ Q_8_8(0.80078125), // sin(294*(π/128))
+ Q_8_8(0.81640625), // sin(295*(π/128))
+ Q_8_8(0.828125), // sin(296*(π/128))
+ Q_8_8(0.84375), // sin(297*(π/128))
+ Q_8_8(0.85546875), // sin(298*(π/128))
+ Q_8_8(0.8671875), // sin(299*(π/128))
+ Q_8_8(0.87890625), // sin(300*(π/128))
+ Q_8_8(0.890625), // sin(301*(π/128))
+ Q_8_8(0.90234375), // sin(302*(π/128))
+ Q_8_8(0.9140625), // sin(303*(π/128))
+ Q_8_8(0.921875), // sin(304*(π/128))
+ Q_8_8(0.9296875), // sin(305*(π/128))
+ Q_8_8(0.94140625), // sin(306*(π/128))
+ Q_8_8(0.94921875), // sin(307*(π/128))
+ Q_8_8(0.953125), // sin(308*(π/128))
+ Q_8_8(0.9609375), // sin(309*(π/128))
+ Q_8_8(0.96875), // sin(310*(π/128))
+ Q_8_8(0.97265625), // sin(311*(π/128))
+ Q_8_8(0.98046875), // sin(312*(π/128))
+ Q_8_8(0.984375), // sin(313*(π/128))
+ Q_8_8(0.98828125), // sin(314*(π/128))
+ Q_8_8(0.9921875), // sin(315*(π/128))
+ Q_8_8(0.9921875), // sin(316*(π/128))
+ Q_8_8(0.99609375), // sin(317*(π/128))
+ Q_8_8(0.99609375), // sin(318*(π/128))
+ Q_8_8(0.99609375), // sin(319*(π/128))
+};
diff --git a/src/sound.c b/src/sound.c
index 342ae9c6..b0bb5901 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -462,7 +462,7 @@ extern const SongHeader sfx108;
extern const SongHeader sfx109;
extern const SongHeader sfx10A;
extern const SongHeader sfx10B;
-extern const SongHeader sfx10C;
+extern const SongHeader sfxButtonPress;
extern const SongHeader sfx10D;
extern const SongHeader sfx10E;
extern const SongHeader sfx10F;
@@ -557,7 +557,7 @@ extern const SongHeader sfx167;
extern const SongHeader sfx168;
extern const SongHeader sfx169;
extern const SongHeader sfx16A;
-extern const SongHeader sfx16B;
+extern const SongHeader sfxPressurePlate;
extern const SongHeader sfx16C;
extern const SongHeader sfx16D;
extern const SongHeader sfx16E;
@@ -1094,7 +1094,7 @@ const Song gSongTable[] = {
[SFX_109] = { &sfx109, MUSIC_PLAYER_1E, MUSIC_PLAYER_1E },
[SFX_10A] = { &sfx10A, MUSIC_PLAYER_08, MUSIC_PLAYER_08 },
[SFX_10B] = { &sfx10B, MUSIC_PLAYER_07, MUSIC_PLAYER_07 },
- [SFX_10C] = { &sfx10C, MUSIC_PLAYER_06, MUSIC_PLAYER_06 },
+ [SFX_BUTTON_PRESS] = { &sfxButtonPress, MUSIC_PLAYER_06, MUSIC_PLAYER_06 },
[SFX_10D] = { &sfx10D, MUSIC_PLAYER_05, MUSIC_PLAYER_05 },
[SFX_10E] = { &sfx10E, MUSIC_PLAYER_04, MUSIC_PLAYER_04 },
[SFX_10F] = { &sfx10F, MUSIC_PLAYER_03, MUSIC_PLAYER_03 },
@@ -1189,7 +1189,7 @@ const Song gSongTable[] = {
[SFX_168] = { &sfx168, MUSIC_PLAYER_16, MUSIC_PLAYER_16 },
[SFX_169] = { &sfx169, MUSIC_PLAYER_15, MUSIC_PLAYER_15 },
[SFX_16A] = { &sfx16A, MUSIC_PLAYER_14, MUSIC_PLAYER_14 },
- [SFX_16B] = { &sfx16B, MUSIC_PLAYER_13, MUSIC_PLAYER_13 },
+ [SFX_PRESSURE_PLATE] = { &sfxPressurePlate, MUSIC_PLAYER_13, MUSIC_PLAYER_13 },
[SFX_16C] = { &sfx16C, MUSIC_PLAYER_03, MUSIC_PLAYER_03 },
[SFX_16D] = { &sfx16D, MUSIC_PLAYER_12, MUSIC_PLAYER_12 },
[SFX_16E] = { &sfx16E, MUSIC_PLAYER_11, MUSIC_PLAYER_11 },
diff --git a/src/sub_0807CA18.c b/src/sub_0807CA18.c
index d8e9db7a..675fa831 100644
--- a/src/sub_0807CA18.c
+++ b/src/sub_0807CA18.c
@@ -49,7 +49,7 @@ u32 FinalizeSave(void) {
gSave.saved_status.area_next = 0x22;
gSave.saved_status.room_next = 0x15; // links room
gSave.saved_status.start_anim = 0;
- gSave.saved_status.spawn_type = 0;
+ gSave.saved_status.spawn_type = PL_SPAWN_DEFAULT;
gSave.saved_status.layer = 1;
gSave.saved_status.start_pos_x = 0x90;
gSave.saved_status.start_pos_y = 0x38;