From e689c1b32dca15796580f780e9a57161615686c5 Mon Sep 17 00:00:00 2001 From: Reinmmar Date: Mon, 18 Sep 2023 18:56:46 +0200 Subject: [PATCH] Filled in the directions --- include/player.h | 17 ++++-- src/beanstalkSubtask.c | 22 +++---- src/enemy/acroBandits.c | 6 +- src/enemy/beetle.c | 7 ++- src/enemy/bladeTrap.c | 6 +- src/enemy/bobomb.c | 20 +++--- src/enemy/bombPeahat.c | 6 +- src/enemy/businessScrub.c | 6 +- src/enemy/chaser.c | 2 +- src/enemy/cuccoChickAggr.c | 7 ++- src/enemy/fireballGuy.c | 2 +- src/enemy/helmasaur.c | 4 +- src/enemy/lakituCloud.c | 4 +- src/enemy/leever.c | 2 +- src/enemy/madderpillar.c | 16 ++--- src/enemy/mazaalBracelet.c | 4 +- src/enemy/mazaalHead.c | 8 +-- src/enemy/moldorm.c | 2 +- src/enemy/peahat.c | 8 ++- src/enemy/pesto.c | 14 ++--- src/enemy/puffstool.c | 4 +- src/enemy/rollobite.c | 14 ++--- src/enemy/ropeGolden.c | 2 +- src/enemy/rupeeLike.c | 2 +- src/enemy/sensorBladeTrap.c | 18 +++--- src/enemy/smallPesto.c | 4 +- src/enemy/spark.c | 2 +- src/enemy/spearMoblin.c | 4 +- src/enemy/spikedBeetle.c | 2 +- src/enemy/tektite.c | 4 +- src/enemy/tektiteGolden.c | 4 +- src/enemy/vaatiBall.c | 30 ++++----- src/enemy/vaatiEyesMacro.c | 10 +-- src/enemy/vaatiProjectile.c | 2 +- src/enemy/vaatiRebornEnemy.c | 38 ++++++------ src/enemy/vaatiTransfigured.c | 4 +- src/enemy/vaatiWrath.c | 8 +-- src/item/itemGustJar.c | 2 +- src/item/itemPegasusBoots.c | 13 ++-- src/item/itemSword.c | 2 +- src/movement.c | 42 ++++++++----- src/npc/npc23.c | 10 +-- src/object/book.c | 2 +- src/object/chuchuBossCutscene.c | 2 +- src/object/crenelBeanSprout.c | 4 +- src/object/graveyardKey.c | 6 +- src/object/lockedDoor.c | 2 +- src/object/smoke.c | 2 +- src/objectUtils.c | 2 +- src/physics.c | 16 +++-- src/player.c | 81 +++++++++++++------------ src/playerItem/playerItemBoomerang.c | 5 +- src/playerUtils.c | 24 ++++---- src/projectile/boneProjectile.c | 2 +- src/projectile/fireProjectile.c | 4 +- src/projectile/gyorgTail.c | 2 +- src/projectile/iceProjectile.c | 4 +- src/projectile/v3TennisBallProjectile.c | 4 +- src/projectile/windProjectile.c | 4 +- 59 files changed, 291 insertions(+), 259 deletions(-) diff --git a/include/player.h b/include/player.h index cd7f57cd..d0108cd7 100644 --- a/include/player.h +++ b/include/player.h @@ -95,6 +95,12 @@ typedef enum { CONTROL_DISABLED, } PlayerControlMode; +typedef enum { + DIR_DIAGONAL = 0x4, + DIR_NOT_MOVING_CHECK = 0x80, + DIR_NONE = 0xff, +} PlayerDirections; + typedef enum { PL_BUSY = 0x1, PL_FLAGS2 = 0x2, @@ -306,11 +312,10 @@ typedef enum { ANIM_PORTAL = 0x2c2, ANIM_PORTAL_SHRINK = 0x2c3, ANIM_DROWN_END = 0x2ce, - // I literally can't tell the difference in the following - ANIM_CLIMB = 0x2cf, - ANIM_CLIMB2 = 0x2d0, - ANIM_CLIMB3 = 0x2d1, - ANIM_CLIMB4 = 0x2d2, + ANIM_CLIMB1_UP = 0x2cf, + ANIM_CLIMB2_UP = 0x2d0, + ANIM_CLIMB1_DOWN = 0x2d1, + ANIM_CLIMB2_DOWN = 0x2d2, ANIM_CLIMB_FROM_TOP = 0x2d3, ANIM_CLIMB_LEFT = 0x2d4, ANIM_CLIMB_RIGHT = 0x2d5, @@ -392,7 +397,7 @@ typedef enum { ANIM_DROWN_MINISH = 0xc19, ANIM_DIE1_MINISH = 0xc1a, ANIM_DIE2_MINISH = 0xc1b, - ANIM_C1C = 0xc1c, + ANIM_DIVE_MINISH = 0xc1c, } PlayerAnimation; typedef struct { diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 5271ab5a..15e9dbdf 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -198,7 +198,7 @@ u32 UpdatePlayerCollision(void) { } else { direction = gPlayerState.direction; } - if (((direction & 0x83) == 0) && (gPlayerState.field_0xa == 0)) { + if (((direction & (DIR_NOT_MOVING_CHECK | 0x3)) == 0) && (gPlayerState.field_0xa == 0)) { index = sub_0807BDB8(&gPlayerEntity, direction >> 2); if (index != 0xff && (gRoomControls.scroll_flags & 4) == 0) { ptr1 = &gUnk_080B4490[index * 2]; @@ -254,10 +254,10 @@ u32 UpdatePlayerCollision(void) { if (gPlayerState.field_0xa != 0) { return 0; } - if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != 0) { + if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != DirectionNorth) { return 0; } - if ((gPlayerEntity.direction & 0x80) != 0) { + if ((gPlayerEntity.direction & DIR_NOT_MOVING_CHECK) != 0) { return 0; } if (sub_080B1B44(position, gPlayerEntity.collisionLayer) != 0xf) { @@ -356,7 +356,7 @@ u32 UpdatePlayerCollision(void) { return 0; } #endif - if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != 0) { + if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != DirectionNorth) { return 0; } if ((gPlayerEntity.direction & 0x80) != 0) { @@ -415,7 +415,7 @@ u32 UpdatePlayerCollision(void) { if ((animationState1 & 0xff) != 0) { return 0; } - if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { + if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) { return 0; } if ((gPlayerEntity.frame & 2) == 0) { @@ -555,7 +555,7 @@ u32 UpdatePlayerCollision(void) { if (animationState3 == 0) { return 0; } - if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { + if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) { return 0; } if ((gPlayerEntity.frame & 1) == 0) { @@ -574,7 +574,7 @@ u32 UpdatePlayerCollision(void) { if ((animationState2) != 4) { return 0; } - if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { + if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) { return 0; } if ((gPlayerEntity.frame & 1) == 0) { @@ -595,7 +595,7 @@ bool32 sub_0801A2B0(LayerStruct* layer, u32 position, u32 collisionType) { u16 temp4; uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1]; - if ((((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) == 0) && ((gPlayerEntity.frame & 1) != 0)) { + if ((((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) == 0) && ((gPlayerEntity.frame & 1) != 0)) { position = (u16)(position - (-uVar1)); // necessary for match temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer)); switch (temp4) { @@ -712,18 +712,18 @@ bool32 sub_0801A4F8(void) { if (GetInventoryValue(ITEM_POWER_BRACELETS) != 1) { return FALSE; } - if ((gPlayerState.direction & 0x80) != 0) { + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) { return FALSE; } if (gPlayerState.direction != gPlayerEntity.direction) { return FALSE; } - tmp = (((gPlayerEntity.direction + 4) & 0x18) >> 3); + tmp = (((gPlayerEntity.direction + 4) & DirectionWest) >> 3); if ((gUnk_080B44A0[tmp] & gPlayerEntity.collisions) == 0) { return FALSE; } } else { - if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { + if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) { return FALSE; } if ((gPlayerEntity.frame & 1) == 0) { diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 86d5d1db..aeeed7f6 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -445,7 +445,7 @@ void AcroBandit_Type1Action4(Entity* this) { } } - if (this->direction & 0xf) + if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL)) this->spriteSettings.flipX = (this->direction >> 4 ^ 1); ProcessMovement0(this); @@ -486,7 +486,7 @@ void AcroBandit_Type1Action6(Entity* this) { this->action = 7; dir = fallDirections[this->field_0x74.HALF.LO * 5 + this->type2]; this->direction = dir; - if (dir >= 0x10) { + if (dir >= DirectionSouth) { this->spriteSettings.flipX = 1; } else { this->spriteSettings.flipX = 0; @@ -570,7 +570,7 @@ static void sub_080322E8(Entity* this) { } } else { u8 tmp = this->direction; - if (tmp & 0xF) { + if (tmp & (0x3 | DirectionEast | DIR_DIAGONAL)) { tmp >>= 4; tmp ^= 1; if (tmp != this->spriteSettings.flipX) { diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index ace73b7f..451d9aea 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -105,7 +105,8 @@ void sub_080218CC(Entity* this) { if (this->subAction == 0) { this->subAction = 1; this->spriteSettings.draw = 1; - this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f; + this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); this->speed = 0x100; this->zVelocity = Q_16_16(1.125); } @@ -244,9 +245,9 @@ void sub_08021B64(Entity* this) { this->zVelocity = Q_16_16(1.0); ((u8*)&this->field_0x86)[1] = 0; if (gPlayerEntity.direction != 0xff) { - this->direction = 0x10 ^ gPlayerEntity.direction; + this->direction = DirectionSouth ^ gPlayerEntity.direction; } else { - this->direction = (gPlayerEntity.animationState << 2) ^ 0x10; + this->direction = (gPlayerEntity.animationState << 2) ^ DirectionSouth; } InitializeAnimation(this, 5); } else { diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c index 86fe70d0..5f8306bd 100644 --- a/src/enemy/bladeTrap.c +++ b/src/enemy/bladeTrap.c @@ -10,18 +10,20 @@ #include "room.h" #include "object.h" +#define DIR_NOT_MOVING_CHECK 0x80 + void BladeTrap(Entity* this) { if (this->action == 0) { this->action = 1; this->child = GetCurrentRoomProperty(this->type); UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); } - if (!(this->direction & 0x80)) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { LinearMoveUpdate(this); } if (!(--this->field_0x74.HWORD)) { - if (!(this->direction & 0x80)) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { EnqueueSFX(SFX_METAL_CLINK); } UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index bfc8f092..ad7ceff0 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -62,7 +62,7 @@ void Bobomb_OnCollision(Entity* this) { this->zVelocity = Q_16_16(1.5); this->speed = 0; this->field_0x80.HALF.HI = 1; - InitializeAnimation(this, this->direction >> 4 | 6); + InitializeAnimation(this, this->direction >> 4 | IdleWest); break; } } @@ -123,7 +123,7 @@ void sub_0802C83C(Entity* this) { } else { this->field_0x82.HALF.LO = 2; this->timer = 120; - InitializeAnimation(this, (this->direction >> 4) | 6); + InitializeAnimation(this, (this->direction >> 4) | IdleWest); COLLISION_OFF(this); this->hitType = 0x6e; } @@ -147,7 +147,7 @@ void sub_0802C8D8(Entity* this) { this->action = 1; this->timer = 60; this->subtimer = 0; - this->direction = (Random() & 0x18) | 4; + this->direction = (Random() & 0x18) | DIR_DIAGONAL; this->carryFlags = 0; this->gustJarFlags = 0x12; this->field_0x82.HALF.LO = 0; @@ -163,7 +163,7 @@ void sub_0802C91C(Entity* this) { if (this->field_0x82.HALF.LO) { if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); - InitializeAnimation(this, (this->direction >> 4) | 2); + InitializeAnimation(this, (this->direction >> 4) | IdleEast); } if (--this->timer == 0) { sub_0802CBC4(this); @@ -180,7 +180,7 @@ void sub_0802C91C(Entity* this) { } if (--this->timer == 0) { this->timer = 60; - this->direction = (this->direction + 8) & 0x1c; + this->direction = (this->direction + 8) & (DirectionWest | DIR_DIAGONAL); InitializeAnimation(this, this->direction >> 4); } } @@ -196,7 +196,7 @@ void sub_0802C9D0(Entity* this) { this->spritePriority.b1 = 0; this->field_0x82.HALF.HI = 1; sub_0802CC18(this); - InitializeAnimation(this, (this->direction >> 4) | 6); + InitializeAnimation(this, (this->direction >> 4) | IdleWest); GetNextFrame(this); } @@ -210,7 +210,7 @@ void sub_0802CA10(Entity* this) { } } else { this->field_0x82.HALF.HI = 2; - this->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c; + this->direction = (((gPlayerEntity.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest); sub_0802CC18(this); GetNextFrame(this); } @@ -234,8 +234,8 @@ void sub_0802CA94(Entity* this) { this->speed = 0; this->field_0x82.HALF.HI = 0; this->field_0x80.HALF.HI = 0; - this->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c; - InitializeAnimation(this, (this->direction >> 4) | 6); + this->direction = ((gPlayerEntity.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL); + InitializeAnimation(this, (this->direction >> 4) | IdleWest); } void sub_0802CAF8(Entity* this) { @@ -264,7 +264,7 @@ void sub_0802CB68(Entity* this) { this->action = 1; this->subAction = 0; this->direction = Random() & 0x18; - this->direction |= 4; + this->direction |= IdleSouth; COLLISION_ON(this); if (this->field_0x82.HALF.LO) { this->timer = 200; diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 96dbcba4..ab856221 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -141,10 +141,10 @@ void sub_0802A9A8(Entity* this) { this->field_0x82.HWORD = 1; if (this->field_0x80.HALF.LO) { this->x.HALF.HI = gRoomControls.scroll_x - 0x10; - this->direction = 8; + this->direction = DirectionEast; } else { this->x.HALF.HI = gRoomControls.scroll_x + 0x100; - this->direction = 0x18; + this->direction = DirectionWest; } this->y.HALF.HI = gRoomControls.scroll_y + 0x40; this->timer = 128; @@ -221,7 +221,7 @@ void sub_0802AAC0(Entity* this) { #ifndef EU this->field_0x78.HALF.LO = 0; this->field_0x78.HALF.HI = 4; - this->direction = 0xff; + this->direction = DIR_NONE; #endif InitializeAnimation(this, 0); } diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 70467401..a1704040 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -79,7 +79,7 @@ void BusinessScrub_Action0(Entity* this) { this->field_0x78.HWORD = this->x.HALF.HI; this->field_0x7a.HWORD = this->y.HALF.HI; this->animationState = 0; - this->direction = 0x10; + this->direction = DirectionSouth; sub_08028E9C(this); if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) { this->action = 4; @@ -455,8 +455,8 @@ void sub_080290FC(Entity* this) { if (this->timer != 0) { this->timer--; if ((this->timer < 16) && ((this->timer & 1) == 0)) { - s32 sVar3 = ((this->direction & 0x10) != 0) ? -1 : 1; - if ((this->direction & 8) != 0) { + s32 sVar3 = (this->direction & DirectionSouth) ? -1 : 1; + if (this->direction & DirectionEast) { this->x.HALF.HI += ((this->timer & 8) != 0) ? -sVar3 : sVar3; } else { this->y.HALF.HI += ((this->timer & 8) != 0) ? sVar3 : -sVar3; diff --git a/src/enemy/chaser.c b/src/enemy/chaser.c index 895c13f1..40f365c2 100644 --- a/src/enemy/chaser.c +++ b/src/enemy/chaser.c @@ -34,7 +34,7 @@ void sub_0802B540(Entity* this) { this->timer--; } else { u32 direction = sub_0804A024(this, 1, 0xc); - if (direction != 0xff) { + if (direction != DIR_NONE) { this->action = 2; this->speed = 0x40; this->direction = direction; diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index ca4f3585..6611126b 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -119,10 +119,11 @@ void sub_08022AA4(Entity* this) { if (!sub_08049FA0(this) && (rand >> 8) & 3) { this->direction = sub_08049EE4(this); } else { - this->direction = (rand >> 0x10) & 0x1f; + this->direction = + (rand >> 0x10) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); } - if (this->direction & 0xf) + if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL)) this->spriteSettings.flipX = (this->direction >> 4) ^ 1; } @@ -144,7 +145,7 @@ void sub_08022B44(Entity* this) { this->zVelocity = Q_16_16(0.75); this->direction = GetFacingDirection(this, &gPlayerEntity); - if (this->direction & 0xf) + if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) this->spriteSettings.flipX = (this->direction >> 4) ^ 1; EnqueueSFX(SFX_VO_CHEEP); diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index db1bf3da..3eb404a1 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -117,7 +117,7 @@ void sub_08045524(Entity* this) { this->zVelocity = Q_16_16(1.75); tmp = sub_0804A024(this, 1, 8); - if (tmp != 0xff && (Random() & 3) == 0) { + if (tmp != DIR_NONE && (Random() & 3) == 0) { this->timer = Random() & 3; this->direction = DirectionRound(tmp); } else { diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 18976674..122ac212 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -215,9 +215,9 @@ void sub_0802BE80(Entity* this) { } void sub_0802BEBC(Entity* this) { - this->direction ^= 0x10; + this->direction ^= DirectionSouth; ProcessMovement2(this); - this->direction ^= 0x10; + this->direction ^= DirectionSouth; if (!sub_080044EC(this, Q_16_16(0.125))) { sub_0802C1C0(this); } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index 6e2c7091..23ff2274 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -89,7 +89,7 @@ void sub_0803CD6C(Entity* this) { void sub_0803CDA8(Entity* this) { UpdateAnimationSingleFrame(this); - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { LinearMoveUpdate(this); } @@ -123,7 +123,7 @@ void sub_0803CE14(Entity* this) { UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); direction = this->direction; - if (direction & 0x80) { + if (direction & DIR_NOT_MOVING_CHECK) { return; } diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 87f8dc9a..e687ab19 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -73,7 +73,7 @@ void Leever_Idle(Entity* this) { if (Leever_PlayerInRange(this, Random() & 0x1f)) { this->action = 2; this->spriteSettings.draw = TRUE; - this->direction = (GetFacingDirection(this, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & 0x1f; + this->direction = (GetFacingDirection(this, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & (0x3 | DirectionNorthWest); InitializeAnimation(this, LeeverAnimation_DigUp); UpdateSpriteForCollisionLayer(this); } else { diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index ad81c2d4..9a443e8e 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -369,16 +369,16 @@ void sub_08029EEC(Entity* this) { void sub_08029F0C(Entity* this) { switch (this->direction >> 3) { - case 0: + case 0: // UP this->field_0x78.HWORD = this->y.HALF.HI - 0x10; break; - case 1: + case 1: // RIGHT this->field_0x78.HWORD = this->x.HALF.HI + 0x10; break; - case 2: + case 2: // DOWN this->field_0x78.HWORD = this->y.HALF.HI + 0x10; break; - case 3: + case 3: // LEFT this->field_0x78.HWORD = this->x.HALF.HI - 0x10; break; } @@ -386,25 +386,25 @@ void sub_08029F0C(Entity* this) { bool32 sub_08029F48(Entity* this) { switch (this->direction >> 3) { - case 0: + case 0: // UP if (this->y.HALF.HI <= this->field_0x78.HWORD) { this->y.HALF.HI = this->field_0x78.HWORD; return TRUE; } break; - case 1: + case 1: // RIGHT if (this->x.HALF.HI >= this->field_0x78.HWORD) { this->x.HALF.HI = this->field_0x78.HWORD; return TRUE; } break; - case 2: + case 2: // DOWN if (this->y.HALF.HI >= this->field_0x78.HWORD) { this->y.HALF.HI = this->field_0x78.HWORD; return TRUE; } break; - case 3: + case 3: // LEFT if (this->x.HALF.HI <= this->field_0x78.HWORD) { this->x.HALF.HI = this->field_0x78.HWORD; return TRUE; diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index 28c7cfc2..9180ae73 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -509,7 +509,7 @@ void sub_0803A8B8(Entity* this) { this->action = 0x10; this->timer = 30; - this->direction = 0; + this->direction = DirectionNorth; this->speed = 0x80; ptr = gUnk_080CED6C; @@ -553,7 +553,7 @@ void sub_0803A978(Entity* this) { sub_08004596(this, 0x10); } LinearMoveUpdate(this); - if (this->direction == 0x10) { + if (this->direction == DirectionSouth) { this->action = 0x12; this->timer = 3; COLLISION_OFF(this); diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index a6a9ad92..1a027a87 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -561,7 +561,7 @@ void sub_0803473C(Entity* this) { if (roomX + 0xe0 < this->x.HALF.HI) { return; } - this->direction = 8; + this->direction = DirectionEast; } else { if (playerX + 4 >= this->x.HALF.HI) { return; @@ -569,7 +569,7 @@ void sub_0803473C(Entity* this) { if (roomX + 0x90 > this->x.HALF.HI) { return; } - this->direction = 0x18; + this->direction = DirectionWest; } LinearMoveUpdate(this); } @@ -581,7 +581,7 @@ void sub_080347B4(Entity* this) { if (roomX + 0xe0 < this->x.HALF.HI) { return; } - this->direction = 8; + this->direction = DirectionEast; } else { if (playerX + 4 >= this->x.HALF.HI) { return; @@ -589,7 +589,7 @@ void sub_080347B4(Entity* this) { if (roomX + 0x90 > this->x.HALF.HI) { return; } - this->direction = 0x18; + this->direction = DirectionWest; } LinearMoveUpdate(this); } diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index facad891..3d0daa83 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -209,7 +209,7 @@ void sub_08022F14(Entity* this) { } this->direction += this->field_0x78.HALF.LO; - this->direction &= 0x1f; + this->direction &= DirectionNorthWest | 0x3; this->animationState = ((this->direction + 2) & 0x1c) >> 2; this->frameIndex = this->animationState; diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 7b5ead2a..9f0ea969 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -182,7 +182,7 @@ void Peahat_ChargeStart(Entity* this) { this->action = 3; this->timer = 120; this->speed = 192; - this->direction = (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & 0x1f; + this->direction = (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & (0x3 | DirectionNorthWest); } } else { sub_080205F8(this); @@ -226,6 +226,8 @@ void Peahat_ChargeEnd(Entity* this) { } } +#define DIR_NONE 0xff + void Peahat_Stunned(Entity* this) { switch (this->animationState) { default: @@ -236,7 +238,7 @@ void Peahat_Stunned(Entity* this) { this->hitType = 0x71; } - if (this->direction == 0xff) + if (this->direction == DIR_NONE) this->direction = this->knockbackDirection; ProcessMovement0(this); @@ -364,7 +366,7 @@ void sub_08020604(Entity* this) { this->direction = sub_08049EE4(this); } else { this->direction += this->field_0x80.HALF.LO; - this->direction &= 0x1f; + this->direction &= (0x3 | DirectionNorthWest); } } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index b395ba9e..d0299a3e 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -387,7 +387,7 @@ void sub_080244E8(Entity* this) { if (tmp == 0) { this->field_0x80.HALF.LO++; this->timer = 12; - this->direction = 0x10; + this->direction = DirectionSouth; this->speed = tmp; this->cutsceneBeh.HALF.LO = 0; this->flags2 &= 0xfc; @@ -554,13 +554,13 @@ void sub_08024940(Entity* this) { } void sub_080249DC(Entity* this) { - u8 direction = ((this->direction + 2) & 0x1c) >> 2; + u8 direction = ((this->direction + 2) & DirectionNorthWest) >> 2; this->animationState = direction; InitializeAnimation(this, this->animationState); } void sub_080249F4(Entity* this) { - u32 direction = ((this->direction + 2) & 0x1f); + u32 direction = ((this->direction + 2) & (0x3 | DirectionNorthWest)); direction >>= 2; if (direction != this->animationState) { this->animationState = direction; @@ -770,8 +770,8 @@ void sub_08024D00(Entity* this) { this->field_0x80.HALF.LO++; this->timer = (Random() & 0xf) + 32; - this->direction += this->field_0x80.HALF.HI ? 4 : 0x1c; - this->direction &= 0x1f; + this->direction += this->field_0x80.HALF.HI ? DirectionNorthEast : DirectionNorthWest; + this->direction &= 0x3 | DirectionNorthWest; this->field_0x80.HALF.HI ^= 0x40; sub_08024A14(this, 3, 0x10); @@ -783,8 +783,8 @@ void sub_08024D00(Entity* this) { this->timer = (Random() & 0x1f) + 32; } else { if (--this->subtimer == 0) { - this->direction += this->field_0x80.HALF.HI ? 1 : 0x1f; - this->direction &= 0x1f; + this->direction += this->field_0x80.HALF.HI ? 1 : (0x3 | DirectionNorthWest); + this->direction &= 0x3 | DirectionNorthWest; this->subtimer = 16; sub_080249DC(this); diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 63ef70b4..c7bfafce 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -338,7 +338,7 @@ void sub_080255AC(Entity* this) { } tmp -= 7; - this->direction = (GetFacingDirection(ent, this) + tmp) & 0x1f; + this->direction = (GetFacingDirection(ent, this) + tmp) & (0x3 | DirectionNorthWest); } if (this->field_0x78.HWORD == 0) { @@ -378,7 +378,7 @@ void sub_080256B4(Entity* this) { this->action = 1; this->timer = (Random() & 3) + 4; this->subtimer = 30; - this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & 0x1c; + this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & DirectionNorthWest; this->field_0x78.HWORD = gUnk_080CC000[Random() & 0xf]; this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1; this->field_0x7a.HALF.HI = 0; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index f55a3c34..e064cfeb 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -39,7 +39,7 @@ void Rollobite_OnCollision(Entity* this) { if (this->hitType == 34 && this->health != 0xff) { this->action = 4; this->zVelocity = Q_16_16(2.0); - this->direction = 0xff; + this->direction = DIR_NONE; this->health = 0xff; this->hitType = 35; InitializeAnimation(this, this->animationState + 8); @@ -49,7 +49,7 @@ void Rollobite_OnCollision(Entity* this) { if (this->action == 4 || this->action == 5) { this->action = 4; this->timer = 180; - this->direction = 0xff; + this->direction = DIR_NONE; InitializeAnimation(this, this->animationState + 0x10); } } @@ -74,7 +74,7 @@ void Rollobite_OnGrabbed(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 4; COLLISION_ON(this); - this->direction = 0xff; + this->direction = DIR_NONE; InitializeAnimation(this, this->animationState + 0x10); } else { gUnk_080CA6A4[this->subAction](this); @@ -107,7 +107,7 @@ void sub_080207A8(Entity* this) { COLLISION_ON(this); this->spritePriority.b0 = 4; this->gustJarState &= 0xfb; - this->direction ^= 0x10; + this->direction ^= DirectionSouth; this->zVelocity = Q_16_16(1.5); this->speed = 0x80; InitializeAnimation(this, this->animationState + 0x10); @@ -193,7 +193,7 @@ void Rollobite_RolledUp(Entity* this) { if (unk == 1) EnqueueSFX(SFX_PLACE_OBJ); - if ((this->direction & 0x80) == 0) + if (!(this->direction & DIR_NOT_MOVING_CHECK)) ProcessMovement2(this); } } @@ -248,8 +248,8 @@ void sub_08020A7C(Entity* this) { if (sub_08049FA0(this) == 0) { int tmp = DirectionRoundUp(sub_08049EE4(this)); - if ((state ^ 0x10) == tmp) - state ^= 0x10; + if ((state ^ DirectionSouth) == tmp) + state ^= DirectionSouth; } this->direction = state; diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c index b5d0f886..32535b12 100644 --- a/src/enemy/ropeGolden.c +++ b/src/enemy/ropeGolden.c @@ -131,7 +131,7 @@ void sub_08038304(Entity* this) { } this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI; this->field_0x78.HALF.HI = cVar2; - this->direction = (this->direction + cVar2) & 0x18; + this->direction = (this->direction + cVar2) & DirectionWest; } else { this->direction = this->field_0x78.HALF.LO; } diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 39a8e586..ab1b3c0f 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -218,7 +218,7 @@ void sub_08029688(Entity* this) { void sub_0802969C(Entity* this) { u32 bVar1; - if ((this->direction & 0xf) != 0) { + if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) { bVar1 = this->direction >> 4; if (bVar1 != this->animationState) { diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c index 627a75bb..87fea681 100644 --- a/src/enemy/sensorBladeTrap.c +++ b/src/enemy/sensorBladeTrap.c @@ -42,16 +42,16 @@ void sub_0802BA18(Entity* this) { this->direction = direction; switch (direction >> 3) { - case 0: + case 0: // UP this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI; break; - case 1: + case 1: // RIGHT this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO; break; - case 2: + case 2: // DOWN this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI; break; - case 3: + case 3: // LEFT this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO; break; } @@ -62,19 +62,19 @@ void sub_0802BA8C(Entity* this) { sub_0802BB10(this); } else { switch (this->direction >> 3) { - case 0: + case 0: // UP if (this->field_0x7a.HWORD >= this->y.HALF.HI) sub_0802BB10(this); break; - case 1: + case 1: // RIGHT if (this->field_0x7a.HWORD <= this->x.HALF.HI) sub_0802BB10(this); break; - case 2: + case 2: // DOWN if (this->field_0x7a.HWORD <= this->y.HALF.HI) sub_0802BB10(this); break; - case 3: + case 3: // LEFT if (this->field_0x7a.HWORD >= this->x.HALF.HI) sub_0802BB10(this); break; @@ -91,7 +91,7 @@ void sub_0802BAFC(Entity* this) { void sub_0802BB10(Entity* this) { this->action = 3; this->speed = 0xc0; - this->direction = this->direction ^ 0x10; + this->direction = this->direction ^ DirectionSouth; EnqueueSFX(SFX_METAL_CLINK); } diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c index 490da140..1997c4df 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -91,8 +91,8 @@ void sub_08031714(Entity* this) { if (sub_08049FA0(this) == 0 && (this->subtimer & 1) != 0) { this->direction = sub_08049EE4(this); } else { - this->direction += 0x18; - this->direction = ((Random() & 0xe) + this->direction) & 0x1f; + this->direction += DirectionWest; + this->direction = ((Random() & 0xe) + this->direction) & (0x3 | DirectionNorthWest); } sub_080317E0(this); } diff --git a/src/enemy/spark.c b/src/enemy/spark.c index 26ea7c79..91efe2ff 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -60,7 +60,7 @@ void sub_0802B35C(Entity* this) { if (--this->subtimer == 0) { this->subtimer = 120; - this->direction += is_head ? 0x08 : 0x18; + this->direction += is_head ? DirectionEast : DirectionWest; this->direction = DirectionRound(this->direction); } } else { diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index 29c2584f..0a6765b5 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -176,7 +176,7 @@ void sub_08028488(Entity* this) { this->timer = (Random() & 7) * 3 + 64; break; case 4: - this->direction = (this->direction + 0x10) & 0x18; + this->direction = (this->direction + 0x10) & DirectionWest; /* fallthrough */ case 1: default: @@ -265,7 +265,7 @@ void sub_08028604(Entity* this) { this->timer = this->timer + 0x10; this->field_0x82.HALF.HI--; } - this->direction = (iVar3 + 4U) & 0x18; + this->direction = (iVar3 + 4U) & DirectionWest; iVar3 = Direction8ToAnimationState(this->direction); } } else { diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 36deab65..6cb42502 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -107,7 +107,7 @@ void sub_0802B7A4(Entity* this) { this->timer = gUnk_080CD314[Random() & 3]; this->speed = 0x60; sub_0802B960(this); - if (this->direction != 0xff) { + if (this->direction != DIR_NONE) { u32 animation = this->direction >> 3; if (animation != this->animationState) { this->animationState = animation & 3; diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 04b9769c..02a1c4ba 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -159,7 +159,7 @@ void sub_0802F300(Entity* this) { } else if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); } if (--this->timer == 0) { @@ -214,6 +214,6 @@ static void sub_0802F45C(Entity* this) { this->direction = sub_08049F84(this, 1); } else { temp = (Random() & 0xf) + 0x18; - this->direction = (temp + this->direction) & 0x1f; + this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest); } } diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index b6ffdca9..fa967d18 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -136,7 +136,7 @@ void sub_08038048(Entity* this) { } else if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); } if (--this->timer == 0) { @@ -185,6 +185,6 @@ void sub_08038168(Entity* this) { this->direction = sub_08049F84(this, 1); } else { temp = (Random() & 0xf) + 0x18; - this->direction = (temp + this->direction) & 0x1f; + this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest); } } diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 7095b875..e1075076 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -74,7 +74,7 @@ void sub_0804468C(Entity* this) { case 0: this->action = 1; this->timer = 1; - this->direction = (this->field_0x78.HALF.HI * 8) & 0x1f; + this->direction = (this->field_0x78.HALF.HI * 8) & (0x3 | DirectionNorthWest); this->field_0x78.HALF.LO = 0; this->field_0x82.HALF.HI = 0; this->spriteSettings.draw = 0; @@ -123,7 +123,7 @@ void sub_0804474C(Entity* this) { if (--this->timer == 0) { this->timer = 2; this->direction++; - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; } LinearMoveUpdate(this); UpdateAnimationSingleFrame(this); @@ -253,7 +253,7 @@ void sub_080449F8(Entity* this) { this->timer = 4; this->direction++; - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; if (vaati->field_0x80.HALF.LO == 0) vaati->field_0x74.HALF.LO = 1; break; @@ -266,9 +266,9 @@ void sub_080449F8(Entity* this) { } break; case 1: - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); LinearMoveUpdate(this); - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); this->timer = 2; break; case 3: @@ -324,7 +324,7 @@ void sub_08044B04(Entity* this) { if (--this->timer == 0) { this->timer = this->field_0x78.HALF.LO ? 4 : 2; this->direction++; - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; } if (--this->subtimer == 0) { if (this->timer != 2) { @@ -346,11 +346,11 @@ void sub_08044B04(Entity* this) { case 1: if (--this->timer == 0) { this->timer = 6; - this->direction = (this->direction + 1) & 0x1f; + this->direction = (this->direction + 1) & (0x3 | DirectionNorthWest); if (++this->subtimer == 0x30) { u32 direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10); this->speed = 0; - this->direction = (direction + 16) & 0x1f; + this->direction = (direction + 16) & (0x3 | DirectionNorthWest); this->timer = 16; this->subtimer = 16; this->field_0x74.HALF.LO++; @@ -485,18 +485,18 @@ void sub_08044E74(Entity* this, u32 state) { switch (state) { case 2: this->action = 2; - this->direction += 0x18; - this->direction &= 0x1f; + this->direction += DirectionWest; + this->direction &= 0x3 | DirectionNorthWest; PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); this->speed = 12288; LinearMoveUpdate(this); - this->direction += 0x8; - this->direction &= 0x1f; + this->direction += DirectionEast; + this->direction &= 0x3 | DirectionNorthWest; this->speed = 1280; LinearMoveUpdate(this); break; case 1: - this->direction = (this->direction + 8) & 0x1f; + this->direction = (this->direction + 8) & (0x3 | DirectionNorthWest); break; case 0: if (this->field_0x78.HALF.LO) { @@ -507,9 +507,9 @@ void sub_08044E74(Entity* this, u32 state) { } while (this->timer-- != 3); break; case 1: - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); LinearMoveUpdate(this); - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); break; } } else { diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index 3a99ae35..bcc53034 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -232,7 +232,7 @@ void sub_0802EFB8(Entity* this) { } iVar4 = sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1); if (iVar4 != 0) { - this->direction = 0xff; + this->direction = DIR_NONE; } else { this->timer = (rand & 3) + 1; this->direction = (uVar1 & 0x18); @@ -251,7 +251,7 @@ void sub_0802F04C(Entity* this) { return; } switch (this->direction >> 3) { - case 0: + case 0: // UP if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) { this->timer--; oldY = (this->y.HALF.HI & 0xfff0) + 8; @@ -263,7 +263,7 @@ void sub_0802F04C(Entity* this) { return; } break; - case 1: + case 1: // RIGHT if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) { this->timer--; oldX = (this->x.HALF.HI & 0xfff0) + 8; @@ -275,7 +275,7 @@ void sub_0802F04C(Entity* this) { return; } break; - case 2: + case 2: // DOWN if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) { this->timer--; oldY = (this->y.HALF.HI & 0xfff0) + 8; @@ -287,7 +287,7 @@ void sub_0802F04C(Entity* this) { return; } break; - default: + default: // LEFT if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) { this->timer--; oldX = (this->x.HALF.HI & 0xfff0) + 8; diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index 98aff7a5..6cdc7ef8 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -187,7 +187,7 @@ void VaatiProjectileFunction0Action5(Entity* this) { void VaatiProjectileFunction0Action6(Entity* this) { if (--this->timer == 0) { this->action = 7; - this->direction = 0x10; + this->direction = DirectionSouth; this->speed = 0x300; } sub_0803E444(this); diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index b6a257eb..50144071 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -103,7 +103,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) { this->timer = 0; this->field_0x76.HALF.LO = 0; this->spriteSettings.draw = 1; - this->direction = 0xff; + this->direction = DIR_NONE; this->spritePriority.b0 = 4; this->z.WORD = 0; this->field_0x80.HALF.LO = 2; @@ -149,12 +149,12 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->action = 2; this->field_0x74.HALF.LO = 0; this->timer = 16; - this->direction = 0xff; + this->direction = DIR_NONE; } else { if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) { - this->direction = ((Random() & 0x80) >> 3) | 8; + this->direction = ((Random() & 0x80) >> 3) | DirectionEast; } else { - this->direction = 0xff; + this->direction = DIR_NONE; } } } else { @@ -165,7 +165,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->field_0x74.HALF.HI = this->field_0x74.HALF.LO & 0x80; this->field_0x74.HALF.LO = 0; this->timer = 192; - this->direction = 0xff; + this->direction = DIR_NONE; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 0); } @@ -176,7 +176,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) { case 0: this->action = 4; this->timer = 160; - this->direction = 0xff; + this->direction = DIR_NONE; this->cutsceneBeh.HALF.LO = 0xff; InitAnimationForceUpdate(this, 1); break; @@ -184,21 +184,21 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->action = 6; this->field_0x74.HALF.LO = 0; this->timer = 0; - this->direction = 0xff; + this->direction = DIR_NONE; break; case 3: this->action = 5; this->field_0x74.HALF.LO = 0; this->subtimer = 32; - this->direction = 0xff; + this->direction = DIR_NONE; break; case 2: this->field_0x74.HALF.LO = 0; this->timer = 32; if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) { - this->direction = ((Random() & 0x80) >> 3) | 8; + this->direction = ((Random() & 0x80) >> 3) | DirectionEast; } else { - this->direction = 0xff; + this->direction = DIR_NONE; } break; } @@ -340,7 +340,7 @@ void VaatiRebornEnemyType0Action4(Entity* this) { this->action = 1; this->cutsceneBeh.HALF.LO = 0xff; this->timer = 1; - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); InitAnimationForceUpdate(this, 0); } else { if ((this->frame & 0x10) != 0) { @@ -369,7 +369,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { if (this->field_0x80.HALF.LO == 0) { this->action = 1; this->timer = 1; - this->direction = 0xff; + this->direction = DIR_NONE; InitAnimationForceUpdate(this, 0); return; } @@ -394,7 +394,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { this->field_0x86.HALF.HI++; this->subtimer = (Random() & 0x3f) + 64; uVar3 = GetFacingDirection(this, &gPlayerEntity); - this->direction = (uVar3 & 0x10) | 8; + this->direction = (uVar3 & 0x10) | DirectionEast; } else { this->field_0x74.HALF.LO++; this->field_0x86.HALF.HI = 0; @@ -408,7 +408,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { this->action = 1; this->field_0x74.HALF.LO = 0; this->timer = 1; - this->direction = 0xff; + this->direction = DIR_NONE; } break; } @@ -557,7 +557,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) { this->field_0x74.HALF.LO = 1; this->field_0x74.HALF.HI = 0; this->spriteOffsetY = -2; - this->direction = 0xff; + this->direction = DIR_NONE; PositionRelative(source, this, 0, Q_16_16(2.0)); InitAnimationForceUpdate(this, 2); } @@ -601,7 +601,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) { void VaatiRebornEnemyType3Action0(Entity* this) { this->action = 1; this->field_0x74.HALF.LO = 0; - this->direction = 0xff; + this->direction = DIR_NONE; this->spriteOffsetY = -1; InitAnimationForceUpdate(this, this->field_0x74.HALF.LO); sub_0803DC0C(this); @@ -621,7 +621,7 @@ void VaatiRebornEnemyType3Action1(Entity* this) { } else { if (this->field_0x74.HALF.LO != 0) { this->field_0x74.HALF.LO = 0; - this->direction = 0xff; + this->direction = DIR_NONE; InitAnimationForceUpdate(this, 2); } } @@ -855,7 +855,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) { this->field_0x7c = this->y; } if (this->field_0x76.HALF.LO == 0) { - if ((this->direction == 0xff) || sub_08049FA0(this)) { + if ((this->direction == DIR_NONE) || sub_08049FA0(this)) { if (this->field_0x80.HALF.LO == 0) { this->animationState = (this->animationState + 1) & 3; this->spriteOffsetX = gUnk_080D04D3[this->animationState]; @@ -863,7 +863,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) { return; } bVar1 = sub_08049EE4(this); - this->direction = (bVar1 & 0x10) | 8; + this->direction = (bVar1 & 0x10) | DirectionEast; this->field_0x76.HALF.LO = 0x10; } else { this->field_0x76.HALF.LO--; diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 5e3ccd6b..6b58c2af 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -888,7 +888,7 @@ void sub_080406A0(Entity* this) { this->direction = tmp + 0x1f; } } - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; this->field_0x86.HALF.LO = uVar5; } @@ -974,7 +974,7 @@ void sub_08040770(Entity* this) { this->direction = tmp3 + 0x1F; } } - this->direction &= 0x1F; + this->direction &= 0x3 | DirectionNorthWest; this->field_0x86.HALF.LO = tmp2; } diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 7a0af279..1c4e74ac 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -383,7 +383,7 @@ void VaatiWrathType0Action7(Entity* this) { UpdateAnimationSingleFrame(this); if (gRoomControls.origin_y + 0x48 != this->y.HALF.HI) { this->speed = 0x100; - this->direction = ((gRoomControls.origin_y + 0x48) >= this->y.HALF.HI) ? 0x10 : 0; + this->direction = ((gRoomControls.origin_y + 0x48) >= this->y.HALF.HI) ? DirectionSouth : DirectionNorth; LinearMoveUpdate(this); } else { if (--this->timer == 0) { @@ -398,7 +398,7 @@ void VaatiWrathType0Action8(Entity* this) { LinearMoveUpdate(this); if (((gRoomControls.origin_x + 0x20) > this->x.HALF.HI) || ((gRoomControls.origin_x + 0x140) < this->x.HALF.HI)) { if (0x3f < this->speed) { - this->direction ^= 0x10; + this->direction ^= DirectionSouth; } } if (--this->timer == 0) { @@ -451,7 +451,7 @@ void VaatiWrathType0ActionA(Entity* this) { if (this->field_0x7a.HALF.HI == 0xf0) { this->action = 0xb; this->subAction = 0; - this->direction = 0; + this->direction = DirectionNorth; this->speed = 0x100; this->zVelocity = Q_16_16(1.125); ChangeObjPalette(this, 0x16b); @@ -521,7 +521,7 @@ void VaatiWrathType0ActionC(Entity* this) { if (this->z.HALF.HI < -4) { this->subAction = 1; this->timer = 120; - this->direction = 0x10; + this->direction = DirectionSouth; this->speed = 0x80; } break; diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index c567f197..3b7221fe 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -66,7 +66,7 @@ void sub_08076EC8(ItemBehavior* this, u32 index) { if (gPlayerEntity.subAction == 0x1b) { animIndex = 0x524; } else { - if (gPlayerState.direction & 0x80) { + if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) { animIndex = 0x504; } else { animIndex = 0x518; diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index fc076799..8449ee50 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -15,7 +15,7 @@ extern u16 gUnk_0800275C[]; extern u8 gUnk_0811BE38[]; void ItemPegasusBoots(ItemBehavior* this, u32 index) { - static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior * beh, u32) = { + static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior* beh, u32) = { sub_080768F8, sub_08076964, sub_08076A88, @@ -136,7 +136,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) { u8* ptr; if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) { - if ((gPlayerState.flags & PL_MINISH) == 0) { + if (!(gPlayerState.flags & PL_MINISH)) { gPlayerEntity.speed = 0x300; } else { gPlayerEntity.speed = 0x280; @@ -148,7 +148,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) { gPlayerEntity.subAction = 0; COLLISION_OFF(&gPlayerEntity); gPlayerState.field_0x38 = 0; - gPlayerState.direction = 0xff; + gPlayerState.direction = DIR_NONE; return; } this->subtimer = 1; @@ -157,12 +157,13 @@ void sub_08076A88(ItemBehavior* this, u32 index) { ptr = gUnk_0811BE38; if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) { this->direction = (this->playerAnimationState & 0xe) * 4; - if ((gPlayerState.direction != 0xff) && (gPlayerState.direction != this->direction)) { - if (((gPlayerState.direction - this->direction) & 0x1f) < 0x10) { + if ((gPlayerState.direction != DIR_NONE) && (gPlayerState.direction != this->direction)) { + if (((gPlayerState.direction - this->direction) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest)) < DirectionSouth) { this->direction = this->direction + 2; } this->direction--; - this->direction &= 0x1f; + this->direction &= 0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest; } gPlayerState.direction = this->direction; UpdateItemAnim(this); diff --git a/src/item/itemSword.c b/src/item/itemSword.c index f34718f0..e08b6576 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -220,7 +220,7 @@ void sub_08075738(ItemBehavior* this, u32 index) { } if ((gPlayerState.sword_state & 0x10) != 0) { - if ((gPlayerState.direction & 0x80) == 0) { + if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { this->direction = gPlayerState.direction; } gPlayerEntity.direction = this->direction; diff --git a/src/movement.c b/src/movement.c index 6e87133b..f4e2eea6 100644 --- a/src/movement.c +++ b/src/movement.c @@ -2080,7 +2080,7 @@ bool32 MoveNorthWest(Entity* this, s32 radius, s32 angle, u32 collisionType) { bool32 ProcessMovement0(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 0); result = ProcessMovementInternal(this, this->speed, this->direction, 0); } else { @@ -2092,7 +2092,7 @@ bool32 ProcessMovement0(Entity* this) { bool32 ProcessMovement1(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 1); result = ProcessMovementInternal(this, this->speed, this->direction, 1); } else { @@ -2104,7 +2104,7 @@ bool32 ProcessMovement1(Entity* this) { bool32 ProcessMovement2(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 2); result = ProcessMovementInternal(this, this->speed, this->direction, 2); } else { @@ -2116,7 +2116,7 @@ bool32 ProcessMovement2(Entity* this) { bool32 ProcessMovement10(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 10); result = ProcessMovementInternal(this, this->speed, this->direction, 10); } else { @@ -2128,7 +2128,7 @@ bool32 ProcessMovement10(Entity* this) { bool32 ProcessMovement12(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 12); result = ProcessMovementInternal(this, this->speed, this->direction, 12); } else { @@ -2140,7 +2140,7 @@ bool32 ProcessMovement12(Entity* this) { bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) { bool32 result; - if ((direction & 0x80) == 0) { + if (!(direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, direction, 0); result = ProcessMovementInternal(this, speed, direction, 0); } else { @@ -2152,7 +2152,7 @@ bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) { bool32 ProcessMovement3(Entity* this) { bool32 result; - if (((this->direction & 0x80) == 0) && (sub_080AF0C8(this) == 0)) { + if (!(this->direction & DIR_NOT_MOVING_CHECK) && !sub_080AF0C8(this)) { CalculateEntityTileCollisions(this, this->direction, 3); result = ProcessMovementInternal(this, this->speed, this->direction, 3); } else { @@ -2165,25 +2165,37 @@ bool32 sub_080AF0C8(Entity* this) { u32 tileType = GetTileTypeByEntity(this); switch (tileType) { case 0x87: - if (((this->direction + 7) & 0x1f) < 0x10) { + if (( + (this->direction + 7) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest) + ) < DirectionSouth) { this->collisions = COL_NORTH_ANY; return TRUE; } break; case 0x8a: - if (((this->direction - 1) & 0x1f) < 0x10) { + if (( + (this->direction - 1) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest) + ) < DirectionSouth) { this->collisions = COL_EAST_ANY; return TRUE; } break; case 0x88: - if (((this->direction - 9) & 0x1f) < 0x10) { + if (( + (this->direction - 9) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest) + ) < DirectionSouth) { this->collisions = COL_SOUTH_ANY; return TRUE; } break; case 0x89: - if (((this->direction - 0x11) & 0x1f) < 0x10) { + if (( + (this->direction - 0x11) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest) + ) < DirectionSouth) { this->collisions = COL_WEST_ANY; return TRUE; } @@ -2195,7 +2207,7 @@ bool32 sub_080AF0C8(Entity* this) { bool32 ProcessMovement4(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 4); result = ProcessMovementInternal(this, this->speed, this->direction, 4); } else { @@ -2207,7 +2219,7 @@ bool32 ProcessMovement4(Entity* this) { bool32 ProcessMovement5(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 5); result = ProcessMovementInternal(this, this->speed, this->direction, 5); } else { @@ -2231,7 +2243,7 @@ void Knockback2(Entity* this) { bool32 ProcessMovement6(Entity* this) { bool32 result; - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, this->direction, 6); result = ProcessMovementInternal(this, this->speed, this->direction, 6); } else { @@ -2243,7 +2255,7 @@ bool32 ProcessMovement6(Entity* this) { bool32 ProcessMovement6_custom(Entity* this, u32 direction, u32 speed) { bool32 result; - if ((direction & 0x80) == 0) { + if (!(direction & DIR_NOT_MOVING_CHECK)) { CalculateEntityTileCollisions(this, direction, 6); result = ProcessMovementInternal(this, speed, direction, 6); } else { diff --git a/src/npc/npc23.c b/src/npc/npc23.c index 846c1bde..2a64ef15 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -206,12 +206,12 @@ void sub_08066570(Entity* this) { direction = GetFacingDirection(this, &gPlayerEntity); cond = TRUE; - dir2 = (direction & 0x18); - dir1 = (this->direction & 0x18); - tmp = 0x18; + dir2 = (direction & DirectionWest); + dir1 = (this->direction & DirectionWest); + tmp = DirectionWest; if (dir1 == dir2) { - dir1 = (direction + 5) & 7; - dir2 = (this->direction + 5) & 7; + dir1 = (direction + 5) & (0x3 | DirectionNorthEast); + dir2 = (this->direction + 5) & (0x3 | DirectionNorthEast); if (dir2 < 3 && dir1 < 3) { cond = FALSE; } diff --git a/src/object/book.c b/src/object/book.c index 31d07e34..36f76c6a 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -222,7 +222,7 @@ void Book_Action5(BookEntity* this) { u32 sub_0809B688(Entity* this) { u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12); - if (ret == 1 && gPlayerState.direction != 16) { + if (ret == 1 && gPlayerState.direction != DirectionSouth) { ret = 0; } diff --git a/src/object/chuchuBossCutscene.c b/src/object/chuchuBossCutscene.c index 564c420b..235a1f91 100644 --- a/src/object/chuchuBossCutscene.c +++ b/src/object/chuchuBossCutscene.c @@ -53,7 +53,7 @@ void ChuchuBossCutscene_Action3(Entity* this) { GetNextFrame(this); if (--this->timer == 0) { this->action++; - this->direction = 0; + this->direction = DirectionNorth; this->speed = 0x100; this->zVelocity = Q_16_16(2.0); this->spriteOrientation.flipY = 0; diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index f40e7de2..a9d500cd 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -138,7 +138,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { if (super->parent->action == 2) { switch (super->parent->subAction) { case 1: - if ((gPlayerState.direction & 0x80) != 0) { + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) { InitializeAnimation(super, 4); } else { GetNextFrame(super); @@ -161,7 +161,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { } else { gPlayerState.mobility |= 0x80; gPlayerState.heldObject = 5; - if ((gPlayerState.direction & 0x80) != 0) { + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) { InitializeAnimation(super, (super->type >> 1) + 3); } else { GetNextFrame(super); diff --git a/src/object/graveyardKey.c b/src/object/graveyardKey.c index 3a4d664c..bef307ed 100644 --- a/src/object/graveyardKey.c +++ b/src/object/graveyardKey.c @@ -90,10 +90,10 @@ void GraveyardKey_Init(Entity* this, const struct_gUnk_08123FB0* param_2) { this->y.HALF.HI -= param_2->y; this->z.WORD = 0; this->timer = param_2->timer; - if ((this->direction & 0x80)) { + if ((this->direction & DIR_NOT_MOVING_CHECK)) { dir = this->direction; - if (dir == 0x81) { - this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ 0x10; + if (dir == (DIR_NOT_MOVING_CHECK | 0x1)) { + this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ DirectionSouth; } } UpdateSpriteForCollisionLayer(this); diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index 6f1812ac..43d04047 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -271,7 +271,7 @@ void sub_080836DC(Entity* this, u32 unk_0, u32 unk_1) { SetTile(0x4022, unk_1, this->collisionLayer); this->timer = 7; this->spriteSettings.draw = 1; - this->direction = (unk_0 << 3) ^ 0x10; + this->direction = (unk_0 << 3) ^ DirectionSouth; tmp = &gUnk_0811F688[unk_0]; if (this->type2 != 2) { this->x.HALF.HI += tmp->x; diff --git a/src/object/smoke.c b/src/object/smoke.c index 06de5ca1..bffaa8b8 100644 --- a/src/object/smoke.c +++ b/src/object/smoke.c @@ -52,7 +52,7 @@ void sub_0808A484(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; this->speed = 0x40; - this->direction = 6; + this->direction = DirectionNorthEast | 0x2; this->spriteRendering.b3 = 1; this->spritePriority.b0 = 0; this->spriteOrientation.flipY = 1; diff --git a/src/objectUtils.c b/src/objectUtils.c index 172e2afc..f891b1b6 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -321,7 +321,7 @@ void UpdateRailMovement(Entity* this, u16** param_2, u16* param_3) { ptr = ptr + (u32)ptr[1] * -3; } if (*ptr == 0xff) { - this->direction = 0xff; + this->direction = DIR_NONE; this->speed = 0; } else { this->direction = (u8)*ptr; diff --git a/src/physics.c b/src/physics.c index 63f29f14..f3f554fd 100644 --- a/src/physics.c +++ b/src/physics.c @@ -245,17 +245,21 @@ bool32 sub_0806F8DC(Entity* ent) { return TRUE; } +#define CDIR_DIAGONAL 1 +#define CDirectionSouth 4 +#define CDirectionWest 6 + u32 sub_0806F948(Entity* ent) { - u32 v1; - if (gPlayerState.direction == 0xFF) + u32 direction; + if (gPlayerState.direction == DIR_NONE) return ent->animationState; - v1 = gPlayerState.direction / 4; - if ((v1 & 1) && !(((v1 + 1) - ent->animationState) & 4)) { + direction = gPlayerState.direction / 4; + if ((direction & CDIR_DIAGONAL) && !(((direction + 1) - ent->animationState) & CDirectionSouth)) { return ent->animationState; } else { - ent->spriteSettings.flipX = v1 > 4; - ent->animationState = v1 & 6; + ent->spriteSettings.flipX = direction > CDirectionSouth; + ent->animationState = direction & CDirectionWest; } return ent->animationState; } diff --git a/src/player.c b/src/player.c index 420b0429..0cd9847d 100644 --- a/src/player.c +++ b/src/player.c @@ -503,7 +503,7 @@ static void PlayerNormal(Entity* this) { this->speed = gPlayerState.jump_status & 0x20; sub_08008926(this); } else { - this->direction = 0xff; + this->direction = DIR_NONE; } } UpdatePlayerMovement(); @@ -535,14 +535,14 @@ static void PlayerNormal(Entity* this) { this->direction = gPlayerState.direction; if (gPlayerState.flags & PL_BURNING) { this->speed = BURNING_SPEED; - if ((gPlayerState.direction & 0x80) != 0) + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) this->direction = 4 * (this->animationState & 0xE); DeleteClones(); } } } v13 = 0; - if ((((gPlayerState.field_0x7 | this->direction) & 0x80) | gPlayerState.field_0xa) == 0 && + if ((((gPlayerState.field_0x7 | this->direction) & DIR_NOT_MOVING_CHECK) | gPlayerState.field_0xa) == 0 && (gPlayerState.field_0x7 & 0x10) == 0) { v13 = 1; if (this->knockbackDuration == 0 && @@ -578,7 +578,7 @@ static void PlayerFall(Entity* this) { PlayerFallUpdate, }; - gPlayerState.direction = 0xFF; + gPlayerState.direction = DIR_NONE; gPlayerState.pushedObject = 0x80; gPlayerState.framestate = PL_STATE_FALL; @@ -1068,7 +1068,7 @@ static void PortalStandUpdate(Entity* this) { break; } - if ((gPlayerState.direction & 0x84) == 0) { + if ((gPlayerState.direction & (DIR_NOT_MOVING_CHECK | DIR_DIAGONAL)) == 0) { if (this->direction != gPlayerState.direction) { this->timer = 8; } @@ -1557,7 +1557,7 @@ static void sub_08071D04(Entity* this) { ModHealth(deltaHealth); this->subAction = 3; gPlayerState.field_0x3c = 0; - this->direction = 0xff; + this->direction = DIR_NONE; this->speed = 0; this->zVelocity = Q_16_16(1.5); gPlayerState.jump_status = 1; @@ -1787,7 +1787,7 @@ static void sub_08072100(Entity* this) { this->subAction = 1; COLLISION_OFF(this); if (gPlayerState.field_0x39) - this->direction = 0xff; + this->direction = DIR_NONE; if (gPlayerState.flags & PL_NO_CAP) { gPlayerState.animation = ANIM_DOOR_NOCAP; @@ -2218,7 +2218,7 @@ static void PlayerInHoleUpdate(Entity* this) { } static void sub_08072ACC(Entity* this) { - if (gPlayerState.direction == 0xff) { + if (gPlayerState.direction == DIR_NONE) { this->subtimer = 0; } else if (this->subtimer > 7) { COLLISION_ON(this); @@ -2448,14 +2448,14 @@ static void PlayerClimb(Entity* this) { this->action = PLAYER_CLIMB; this->subAction = 0; this->y.HALF.LO = 0; - gPlayerState.animation = ANIM_CLIMB; + gPlayerState.animation = ANIM_CLIMB1_UP; } } } } static void sub_08072F94(Entity* this) { - u32 bVar1; + u32 direction; switch (gPlayerState.floor_type) { default: @@ -2466,10 +2466,10 @@ static void sub_08072F94(Entity* this) { case SURFACE_CLIMB_WALL: case SURFACE_2C: this->spritePriority.b1 = 0; - bVar1 = gPlayerState.direction; - if ((gPlayerState.direction & 0x80) == 0) { + direction = gPlayerState.direction; + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) { this->direction = gPlayerState.direction; - if ((gPlayerState.direction == 8) || (gPlayerState.direction == 0x18)) { + if ((gPlayerState.direction == DirectionEast) || (gPlayerState.direction == DirectionWest)) { if (gPlayerState.floor_type == SURFACE_LADDER) { return; } @@ -2480,20 +2480,20 @@ static void sub_08072F94(Entity* this) { } sub_08073094(this); } else { - if ((gPlayerState.floor_type == SURFACE_LADDER) && ((bVar1 & 7) != 0)) { - this->direction = (bVar1 + 8) & 0x10; + if ((gPlayerState.floor_type == SURFACE_LADDER) && ((direction & (DIR_DIAGONAL | 0x3)) != 0)) { + this->direction = (direction + 8) & DirectionSouth; } - if (this->direction & 0x10) { + if (this->direction & DirectionSouth) { if (this->frame & 0x10) { - gPlayerState.animation = ANIM_CLIMB3; + gPlayerState.animation = ANIM_CLIMB1_DOWN; } else { - gPlayerState.animation = ANIM_CLIMB4; + gPlayerState.animation = ANIM_CLIMB2_DOWN; } } else { if (this->frame & 0x10) { - gPlayerState.animation = ANIM_CLIMB; + gPlayerState.animation = ANIM_CLIMB1_UP; } else { - gPlayerState.animation = ANIM_CLIMB2; + gPlayerState.animation = ANIM_CLIMB2_UP; } } } @@ -2633,19 +2633,19 @@ static void sub_0807332C(Entity* this) { if (gPlayerState.field_0x39 == 7) { this->direction = IdleNorth; } else { - this->direction = 28; + this->direction = DirectionNorthWest; } if ((this->x.HALF.HI & 0xF) != 0xF) { if (gPlayerState.field_0x39 == 7) { this->animationState = IdleEast; - this->direction = 4; + this->direction = DIR_DIAGONAL; } else { - this->animationState = 6; + this->animationState = IdleWest; if (this->direction <= DirectionWest) { LinearMoveUpdate(this); return; } - this->direction = (this->direction - 1) & 0x1F; + this->direction = (this->direction - 1) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); } LinearMoveUpdate(this); return; @@ -2756,7 +2756,7 @@ static void sub_08073584(Entity* this) { gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL; if (sub_0807A2F8(0)) { this->subAction++; - this->direction = 4 * (this->animationState & 6); + this->direction = 4 * (this->animationState & IdleWest); COLLISION_OFF(this); return; } @@ -2766,21 +2766,23 @@ static void sub_08073584(Entity* this) { else this->speed = 0x80; - if ((gPlayerState.direction & 0x80) == 0) { + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) { if (this->direction != gPlayerState.direction) { - if (((this->direction - gPlayerState.direction) & 0x1F) < 0x10) + if (((this->direction - gPlayerState.direction) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | + DirectionSouth | DirectionWest)) < DirectionSouth) *(u32*)&this->field_0x80 -= 0x20; else *(u32*)&this->field_0x80 += 0x20; } } - this->direction = (*(u32*)&this->field_0x80 >> 8) & 0x1F; + this->direction = (*(u32*)&this->field_0x80 >> 8) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); UpdatePlayerMovement(); state = 4 * this->animationState; dir = this->direction; if (this->animationState == 0) { state = (state + 8) & 0x1F; - dir = (dir + 8) & 0x1F; + dir = (dir + 8) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); } if (state - 7 > dir) { @@ -2798,7 +2800,8 @@ static void sub_08073584(Entity* this) { this->animationState = state; idx = 0; state = gPlayerState.direction >> 2; - if (!this->field_0x86.HALF.HI || ((gPlayerState.direction & 0x80) == 0 && this->animationState != state)) { + if (!this->field_0x86.HALF.HI || + ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0 && this->animationState != state)) { static const u16 sAnims1[] = { 0x0708, 0x071C, @@ -2806,7 +2809,7 @@ static void sub_08073584(Entity* this) { 0x0714, }; - if ((gPlayerState.direction & 0x80) == 0) { + if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) { if (this->animationState != state) { if (this->animationState == (state ^ 4)) { idx = 2; @@ -2890,7 +2893,7 @@ static void sub_0807380C(Entity* this) { }; if ((gRoomTransition.frameCount & 3) == 0) { - u32 tmp = (this->animationState + 2) & 6; + u32 tmp = (this->animationState + 2) & IdleWest; this->animationState = tmp; this->direction = 4 * tmp; } @@ -2916,7 +2919,7 @@ void sub_08073884(Entity* this) { }; if ((gRoomTransition.frameCount & 1) == 0) { - u32 tmp = (this->animationState + 2) & 6; + u32 tmp = (this->animationState + 2) & IdleWest; this->animationState = tmp; this->direction = 4 * tmp; } @@ -2940,10 +2943,10 @@ static void DoJump(Entity* this) { } static void sub_08073924(Entity* this) { - if ((gPlayerState.flags & PL_ROLLING) == 0 && (this->z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) { + if (!(gPlayerState.flags & PL_ROLLING) && (this->z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) { gPlayerState.jump_status = 0x40; - gPlayerState.direction = 0xff; - this->direction = 0xff; + gPlayerState.direction = DIR_NONE; + this->direction = DIR_NONE; PutAwayItems(); sub_08073968(this); } @@ -2996,7 +2999,7 @@ static void sub_080739EC(Entity* this) { if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) { this->zVelocity = Q_16_16(2.5); this->timer = 10; - this->direction = 0xff; + this->direction = DIR_NONE; gPlayerState.jump_status += 2; gPlayerState.animation = ANIM_DOWN_THRUST; ResetPlayerVelocity(); @@ -3171,7 +3174,7 @@ static void sub_08073D20(Entity* this) { UpdatePlayerMovement(); } else { this->direction = gPlayerState.direction; - if ((gPlayerState.direction & 0x80) == 0) { + if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { gPlayerState.framestate = PL_STATE_WALK; UpdatePlayerMovement(); } @@ -3427,7 +3430,7 @@ void SurfaceAction_14(Entity* this) { sub_08074808(this); spd = this->speed; this->speed = 0x300; - this->direction = 16; + this->direction = DirectionSouth; gPlayerState.field_0xa |= 0x80; LinearMoveUpdate(this); this->speed = spd; diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index be166131..b8b9229d 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -148,8 +148,9 @@ void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this) { bool32 uVar6; sub_0801B804(this); - if ((this->unk_68 == 12) && (this->unk_80 == 0) && ((gPlayerState.direction & 0x80) == 0)) { - if (((this->unk_82.HALF.HI - gPlayerState.direction) & 0x1f) > 0x10) { + if ((this->unk_68 == 12) && (this->unk_80 == 0) && !(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { + if (((this->unk_82.HALF.HI - gPlayerState.direction) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest)) > DirectionSouth) { this->unk_82.HWORD += 0x40; this->unk_82.HALF.HI &= 0x1f; super->direction = this->unk_82.HALF.HI; diff --git a/src/playerUtils.c b/src/playerUtils.c index c2b7c8d8..f30c14bf 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1490,7 +1490,7 @@ bool32 CheckQueuedAction(void) { // this doesnt seem to have any real function where its used void CheckPlayerVelocity(void) { u32 angle = gPlayerState.direction; - if ((angle & 0x80) != 0) { + if ((angle & DIR_NOT_MOVING_CHECK) != 0) { ResetPlayerVelocity(); } else { gPlayerState.vel_x = gSineTable[angle * 8]; @@ -1753,7 +1753,7 @@ code_3: void sub_08079520(Entity* this) { s32 tmp = gPlayerState.direction; - if (tmp < 0x80) { + if (tmp < DIR_NOT_MOVING_CHECK) { this->direction = gPlayerState.direction; } else { this->direction = (this->animationState >> 1) << 3; @@ -1774,7 +1774,7 @@ bool32 sub_08079550(void) { if (gDiggingCaveEntranceTransition.isDiggingCave == 0) { if ((gPlayerState.dash_state == 0 || (gPlayerState.flags & PL_BURNING)) && (gPlayerState.swim_state != 0 || (gPlayerState.sword_state & 0x40) || - gPlayerEntity.direction != gPlayerState.direction || (gPlayerEntity.direction & 0x80))) { + gPlayerEntity.direction != gPlayerState.direction || (gPlayerEntity.direction & DIR_NOT_MOVING_CHECK))) { gPlayerEntity.subtimer = 0; return FALSE; } @@ -2072,8 +2072,8 @@ bool32 sub_08079B24(void) { } if ((gPlayerState.jump_status & 0x41) == 0) { gPlayerState.jump_status = 0x41; - gPlayerEntity.direction = 0xff; - gPlayerState.direction = 0xff; + gPlayerEntity.direction = DIR_NONE; + gPlayerState.direction = DIR_NONE; return TRUE; } else { return TRUE; @@ -2660,7 +2660,7 @@ bool32 sub_0807AC54(Entity* this) { this->action = 0x1d; this->subAction = 0; this->y.HALF.LO = 0; - gPlayerState.animation = ANIM_CLIMB; + gPlayerState.animation = ANIM_CLIMB1_UP; return TRUE; case SURFACE_AUTO_LADDER: this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8; @@ -2750,7 +2750,7 @@ void PlayerUpdateSwimming(Entity* this) { ModHealth(-2); SoundReq(SFX_PLY_VO6); } - if ((this->direction & 0x80) != 0) { + if (this->direction & DIR_NOT_MOVING_CHECK) { if ((gRoomTransition.frameCount & 0xf) == 0) { CreateRandomWaterTrace(this, 4); } @@ -2825,15 +2825,15 @@ u32 GetSwordBeam(void) { } void sub_0807B068(Entity* entity) { - if ((gPlayerState.dash_state | gPlayerState.attack_status) == 0) { - if (gPlayerState.swim_state != 0) { - if ((gPlayerState.swim_state & 0x80) != 0) { - gPlayerState.animation = ANIM_C1C; + if (!(gPlayerState.dash_state | gPlayerState.attack_status)) { + if (gPlayerState.swim_state) { + if (gPlayerState.swim_state & 0x80) { + gPlayerState.animation = ANIM_DIVE_MINISH; } else { gPlayerState.animation = ANIM_SWIM_MINISH; } } else { - if ((gPlayerState.direction & 0x80) != 0) { + if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) { if (gPlayerState.animation != ANIM_BOUNCE_MINISH) { gPlayerState.animation = ANIM_BOUNCE_MINISH; } diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 069249ab..5593b602 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -88,7 +88,7 @@ void sub_080A82D8(Entity* this) { this->action = 4; COLLISION_OFF(this); this->zVelocity = Q_16_16(1.0); - this->direction ^= 0x10; + this->direction ^= DirectionSouth; this->speed = 0x80; } diff --git a/src/projectile/fireProjectile.c b/src/projectile/fireProjectile.c index 2d5cddc7..833930f0 100644 --- a/src/projectile/fireProjectile.c +++ b/src/projectile/fireProjectile.c @@ -24,7 +24,7 @@ void FireProjectile_Init(Entity* this) { InitializeAnimation(this, this->direction >> 3); } else { this->action = 2; - InitializeAnimation(this, this->direction >> 3 | 4); + InitializeAnimation(this, this->direction >> 3 | IdleSouth); EnqueueSFX(SFX_15E); } } @@ -41,7 +41,7 @@ void FireProjectile_Action1(Entity* this) { if (this->spriteSettings.draw == 1) { CopyPosition(parent, this); if (this->timer != 0) { - direction = parent->direction & 0x18; + direction = parent->direction & DirectionWest; this->direction = direction; this->timer = 0; InitializeAnimation(this, direction >> 3); diff --git a/src/projectile/gyorgTail.c b/src/projectile/gyorgTail.c index 56cc8372..0ed9e396 100644 --- a/src/projectile/gyorgTail.c +++ b/src/projectile/gyorgTail.c @@ -264,7 +264,7 @@ void sub_080AC6F0(Entity* this) { u32 uVar4; u32 tmp; - uVar4 = this->direction & 0x1f; + uVar4 = this->direction & (0x3 | DirectionNorthWest); uVar1 = this->direction >> 5; iVar3 = uVar1 * 3; tmp = gUnk_0812A9C0[this->animationState] - uVar1 * 3; diff --git a/src/projectile/iceProjectile.c b/src/projectile/iceProjectile.c index fb429e49..1ad42525 100644 --- a/src/projectile/iceProjectile.c +++ b/src/projectile/iceProjectile.c @@ -24,7 +24,7 @@ void IceProjectile_Init(Entity* this) { InitializeAnimation(this, this->direction >> 3); } else { this->action = 2; - InitializeAnimation(this, this->direction >> 3 | 4); + InitializeAnimation(this, this->direction >> 3 | IdleSouth); EnqueueSFX(SFX_160); } } @@ -43,7 +43,7 @@ void IceProjectile_Action1(Entity* this) { if (this->spriteSettings.draw == 1) { CopyPosition(parent, this); if (this->timer != 0) { - direction = parent->direction & 0x18; + direction = parent->direction & DirectionWest; this->direction = direction; this->timer = 0; InitializeAnimation(this, direction >> 3); diff --git a/src/projectile/v3TennisBallProjectile.c b/src/projectile/v3TennisBallProjectile.c index c703592e..f731832b 100644 --- a/src/projectile/v3TennisBallProjectile.c +++ b/src/projectile/v3TennisBallProjectile.c @@ -36,7 +36,7 @@ void V3TennisBallProjectile_OnCollision(Entity* this) { this->speed += 0x80 * 2; this->child = this->contactedEntity; if (sub_080ACB40(this)) { - this->direction = 0; + this->direction = DirectionNorth; } else { this->direction = this->knockbackDirection; } @@ -53,7 +53,7 @@ void V3TennisBallProjectile_OnCollision(Entity* this) { void V3TennisBallProjectile_Init(Entity* this) { this->action = 1; - this->direction = 0x10; + this->direction = DirectionSouth; this->z.HALF.HI = -4; this->child = NULL; InitializeAnimation(this, 7); diff --git a/src/projectile/windProjectile.c b/src/projectile/windProjectile.c index d07eeb6e..e3ce3d57 100644 --- a/src/projectile/windProjectile.c +++ b/src/projectile/windProjectile.c @@ -24,7 +24,7 @@ void WindProjectile_Init(Entity* this) { InitializeAnimation(this, this->direction >> 3); } else { this->action = 2; - InitializeAnimation(this, this->direction >> 3 | 4); + InitializeAnimation(this, this->direction >> 3 | IdleSouth); EnqueueSFX(SFX_15F); } } @@ -40,7 +40,7 @@ void WindProjectile_Action1(Entity* this) { } else { if (this->spriteSettings.draw == 1) { CopyPosition(parent, this); - direction = (parent->direction + 4) & 0x18; + direction = (parent->direction + 4) & DirectionWest; if (this->timer != 0) { this->direction = direction; this->animationState = direction >> 2;