From 7780c76eac79febc6ad31a77e25637e2372522da Mon Sep 17 00:00:00 2001 From: Elliptic Ellipsis Date: Fri, 18 Mar 2022 23:16:15 +0000 Subject: [PATCH 1/3] Correct type of sub_0806F520 and use it as a bool --- include/functions.h | 2 +- src/enemy/chuchu.c | 2 +- src/enemy/enemy50.c | 2 +- src/enemy/ghini.c | 2 +- src/enemy/gyorgChild.c | 2 +- src/enemy/lakituCloud.c | 2 +- src/enemy/rope.c | 2 +- src/enemy/stalfos.c | 2 +- src/enemy/takkuri.c | 2 +- src/enemy/wisp.c | 2 +- src/projectile/lakituCloudProjectile.c | 2 +- src/projectile/spiderWeb.c | 2 +- src/projectile/stalfosProjectile.c | 2 +- src/projectile/v1DarkMagicProjectile.c | 2 +- src/projectile/v2Projectile.c | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/functions.h b/include/functions.h index daa1e0f7..ea3d6ce3 100644 --- a/include/functions.h +++ b/include/functions.h @@ -163,7 +163,7 @@ extern void sub_08060158(Entity*); extern void sub_0806D02C(Entity*); extern void sub_0806D0B0(Entity*); extern void sub_0806F4E8(Entity*); -extern u32 sub_0806F520(); +extern bool32 sub_0806F520(Entity*); extern u32 sub_0806F5B0(u32); extern u32 sub_0806F824(Entity*, Entity*, s32, s32); extern u32 sub_0806F948(Entity*); diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 9f23dd3b..34094ef5 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -123,7 +123,7 @@ void Chuchu_OnCollision(Entity* this) { } void Chuchu_OnGrabbed(Entity* this) { - if (sub_0806F520(this) == 0 && this->confusedTime) { + if (!sub_0806F520(this) && this->confusedTime) { Create0x68FX(this, FX_STARS); InitializeAnimation(this, 6); } else { diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 2811e901..40bd1fde 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -154,7 +154,7 @@ void sub_08040D30(Enemy50Entity* this) { } void sub_08040D90(Enemy50Entity* this) { - if (sub_0806F520()) { + if (sub_0806F520(super)) { Enemy50_SubActions[super->subAction](this); } else { sub_08041128(this); diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index 7bd4179b..ab807ba0 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -113,7 +113,7 @@ void Ghini_OnConfused(GhiniEntity* this) { } void Ghini_OnGrabbed(GhiniEntity* this) { - if (sub_0806F520()) { + if (sub_0806F520(super)) { Ghini_SubActions[super->subAction](this); } else { sub_0803F51C(this); diff --git a/src/enemy/gyorgChild.c b/src/enemy/gyorgChild.c index 698ad03a..84bd4e6e 100644 --- a/src/enemy/gyorgChild.c +++ b/src/enemy/gyorgChild.c @@ -56,7 +56,7 @@ void GyorgChild_OnGrabbed(GyorgChildEntity* this) { GyorgChild_OnGrabbed_Action1, GyorgChild_OnGrabbed_Action3, }; - if (sub_0806F520()) { + if (sub_0806F520(super)) { GyorgChild_OnGrabbed_Actions[super->subAction](this); } } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index 25616556..1c311f6c 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -34,7 +34,7 @@ void LakituCloud_OnKnockback(Entity* this) { } void LakituCloud_OnGrabbed(Entity* this) { - if (sub_0806F520(this) == 0) { + if (!sub_0806F520(this)) { if (this->subAction == 2) { sub_0803CE3C(this); } diff --git a/src/enemy/rope.c b/src/enemy/rope.c index 8d728a03..61f36bc5 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -39,7 +39,7 @@ void Rope_OnCollision(Entity* this) { } void Rope_OnGrabbed(Entity* this) { - if (sub_0806F520()) { + if (sub_0806F520(this)) { gUnk_080CE470[this->subAction](this); } } diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 67f6b6e1..61512e7e 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -123,7 +123,7 @@ void sub_08039418(StalfosEntity* this) { } void sub_08039438(StalfosEntity* this) { - if (sub_0806F520()) { + if (sub_0806F520(super)) { Stalfos_SubActions[super->subAction](this); } } diff --git a/src/enemy/takkuri.c b/src/enemy/takkuri.c index dc28b862..a07b8330 100644 --- a/src/enemy/takkuri.c +++ b/src/enemy/takkuri.c @@ -74,7 +74,7 @@ void Takkuri_OnCollision(TakkuriEntity* this) { void Takkuri_OnGrabbed(TakkuriEntity* this) { gUnk_080CFF6C[super->subAction](this); GetNextFrame(super); - if (sub_0806F520(super) == 0) { + if (!sub_0806F520(super)) { super->action = 2; super->subAction = 0; this->unk_0x84 = 2; diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 94943d52..213453c2 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -69,7 +69,7 @@ void Wisp_OnCollision(Entity* this) { } void Wisp_OnGrabbed(Entity* this) { - if (sub_0806F520() != 0) { + if (sub_0806F520(this)) { gUnk_080CEB98[this->subAction](this); } } diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index f66dd20e..a766f97b 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -24,7 +24,7 @@ void nullsub_539(Entity* this) { } void sub_080A9CF0(Entity* this) { - if (sub_0806F520() == 0) { + if (!sub_0806F520(this)) { CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index 93951fad..8f24dae1 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -79,7 +79,7 @@ void sub_080AA78C(Entity* this) { this->subAction = 1; InitAnimationForceUpdate(this, animationState + 8); } - if (sub_0806F520(this) != 0) { + if (sub_0806F520(this)) { UpdateAnimationSingleFrame(this); if ((this->frame & 0x10) != 0) { this->frame &= 0xef; diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index 841a68e3..3f8f679d 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -38,7 +38,7 @@ void sub_080A9A34(Entity* this) { } void sub_080A9A64(Entity* this) { - if ((this->subAction < 3) && (sub_0806F520(this) == 0)) { + if ((this->subAction < 3) && !sub_0806F520(this)) { sub_080A9BA8(this); } StalfosProjectile_SubActions[this->subAction](this); diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index aeca2aa3..8131c3d7 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -87,7 +87,7 @@ void sub_080AACE0(Entity* this) { } void sub_080AAD70(Entity* this) { - if (sub_0806F520() == 0) { + if (!sub_0806F520(this)) { this->health = 0; } V1DarkMagicProjectile_SubActions[this->subAction](this); diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index 3733945d..e2c86b53 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -62,7 +62,7 @@ void sub_080ABBF4(Entity* this) { } void sub_080ABC54(Entity* this) { - if (sub_0806F520() == 0) { + if (!sub_0806F520(this)) { CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } From 673b8d2e69cd86d9df1340762a7ad6eb4b3b0472 Mon Sep 17 00:00:00 2001 From: Elliptic Ellipsis Date: Fri, 18 Mar 2022 23:17:22 +0000 Subject: [PATCH 2/3] New entity struct in coord.c --- src/coord.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/coord.c b/src/coord.c index 629f700a..d093498a 100644 --- a/src/coord.c +++ b/src/coord.c @@ -1,6 +1,8 @@ +#define NENT_DEPRECATED #include "asm.h" #include "area.h" #include "player.h" +#include "new_player.h" #include "coord.h" #include "common.h" #include "sound.h" @@ -38,7 +40,7 @@ void sub_0806F38C(void) { u32 sub_0806F39C(Entity* ent) { s32 dist; - if (gPlayerEntity.animationState & 2) { + if (gNewPlayerEntity.base.animationState & 2) { dist = ent->x.HALF.HI - gPlayerEntity.x.HALF.HI; } else { dist = ent->y.HALF.HI - gPlayerEntity.y.HALF.HI; @@ -55,10 +57,10 @@ u32 sub_0806F39C(Entity* ent) { } bool32 sub_0806F3E4(Entity* ent) { - Entity tmp_ent; + GenericEntity tmp_ent; s8* p; - if ((gPlayerState.field_0x1c & 0x7F) != 1) + if ((gPlayerState.field_0x1c & ~0x80) != 1) return 0; switch (gPlayerState.gustJarSpeed) { case 1: @@ -74,15 +76,15 @@ bool32 sub_0806F3E4(Entity* ent) { if (ent->knockbackSpeed > 0x500) ent->knockbackSpeed = 0x500; p = &gUnk_08126EE4[gPlayerEntity.animationState & 0xE]; - tmp_ent.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI; - tmp_ent.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI; - LinearMoveDirection(ent, ent->knockbackSpeed, GetFacingDirection(ent, &tmp_ent)); - if (sub_0800419C(&tmp_ent, ent, 4, 4)) { + tmp_ent.base.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI; + tmp_ent.base.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI; + LinearMoveDirection(ent, ent->knockbackSpeed, GetFacingDirection(ent, &tmp_ent.base)); + if (sub_0800419C(&tmp_ent.base, ent, 4, 4)) { u32 state = ent->field_0x1c & 0xF; if (state == 2) { Entity* item; ent->subAction = 3; - (Entity*)gPlayerEntity.field_0x70.WORD = ent; + gNewPlayerEntity.unk_70 = ent; gPlayerState.field_0x1c = 7; item = CreatePlayerItem(0x11, 0, 0, 0); if (item != NULL) { @@ -116,7 +118,7 @@ void sub_0806F4E8(Entity* ent) { } } -u32 sub_0806F520(Entity* ent) { +bool32 sub_0806F520(Entity* ent) { if (ent->bitfield == 0x93) return 1; ent->field_0x3a &= ~4; @@ -336,38 +338,38 @@ void SortEntityBelow(Entity* above_ent, Entity* below_ent) { below_ent->spritePriority.b0 = gSpriteSortBelowTable[above_ent->spritePriority.b0]; } -void sub_0806FB00(Entity* ent, u32 param_1, u32 param_2, u32 param_3) { +void sub_0806FB00(GenericEntity* 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->field_0x80.HWORD = ent->base.x.HALF.HI; + ent->field_0x82.HWORD = ent->base.y.HALF.HI; ent->cutsceneBeh.HWORD = param_1; ent->field_0x86.HWORD = param_2; } -bool32 sub_0806FB38(Entity* ent) { +bool32 sub_0806FB38(GenericEntity* ent) { s32 val; u32 rv; if (ent->field_0x7c.BYTES.byte2 < ent->field_0x7c.BYTES.byte3) { ent->field_0x7c.BYTES.byte2++; - ent->x.HALF.HI = + ent->base.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 = + ent->base.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; + ent->base.x.HALF.HI = ent->cutsceneBeh.HWORD; + ent->base.y.HALF.HI = ent->field_0x86.HWORD; rv = 1; } return rv; From defe055ff49e2007f1911bb2c467d55d44f8768d Mon Sep 17 00:00:00 2001 From: Elliptic Ellipsis Date: Fri, 18 Mar 2022 23:26:49 +0000 Subject: [PATCH 3/3] Fix fix --- src/coord.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coord.c b/src/coord.c index d093498a..98f3f65e 100644 --- a/src/coord.c +++ b/src/coord.c @@ -60,7 +60,7 @@ bool32 sub_0806F3E4(Entity* ent) { GenericEntity tmp_ent; s8* p; - if ((gPlayerState.field_0x1c & ~0x80) != 1) + if ((gPlayerState.field_0x1c & 0x7F) != 1) return 0; switch (gPlayerState.gustJarSpeed) { case 1: