Filled in the directions

This commit is contained in:
Reinmmar 2023-09-18 18:56:46 +02:00
parent 561b8da657
commit e689c1b32d
59 changed files with 291 additions and 259 deletions

View File

@ -95,6 +95,12 @@ typedef enum {
CONTROL_DISABLED, CONTROL_DISABLED,
} PlayerControlMode; } PlayerControlMode;
typedef enum {
DIR_DIAGONAL = 0x4,
DIR_NOT_MOVING_CHECK = 0x80,
DIR_NONE = 0xff,
} PlayerDirections;
typedef enum { typedef enum {
PL_BUSY = 0x1, PL_BUSY = 0x1,
PL_FLAGS2 = 0x2, PL_FLAGS2 = 0x2,
@ -306,11 +312,10 @@ typedef enum {
ANIM_PORTAL = 0x2c2, ANIM_PORTAL = 0x2c2,
ANIM_PORTAL_SHRINK = 0x2c3, ANIM_PORTAL_SHRINK = 0x2c3,
ANIM_DROWN_END = 0x2ce, ANIM_DROWN_END = 0x2ce,
// I literally can't tell the difference in the following ANIM_CLIMB1_UP = 0x2cf,
ANIM_CLIMB = 0x2cf, ANIM_CLIMB2_UP = 0x2d0,
ANIM_CLIMB2 = 0x2d0, ANIM_CLIMB1_DOWN = 0x2d1,
ANIM_CLIMB3 = 0x2d1, ANIM_CLIMB2_DOWN = 0x2d2,
ANIM_CLIMB4 = 0x2d2,
ANIM_CLIMB_FROM_TOP = 0x2d3, ANIM_CLIMB_FROM_TOP = 0x2d3,
ANIM_CLIMB_LEFT = 0x2d4, ANIM_CLIMB_LEFT = 0x2d4,
ANIM_CLIMB_RIGHT = 0x2d5, ANIM_CLIMB_RIGHT = 0x2d5,
@ -392,7 +397,7 @@ typedef enum {
ANIM_DROWN_MINISH = 0xc19, ANIM_DROWN_MINISH = 0xc19,
ANIM_DIE1_MINISH = 0xc1a, ANIM_DIE1_MINISH = 0xc1a,
ANIM_DIE2_MINISH = 0xc1b, ANIM_DIE2_MINISH = 0xc1b,
ANIM_C1C = 0xc1c, ANIM_DIVE_MINISH = 0xc1c,
} PlayerAnimation; } PlayerAnimation;
typedef struct { typedef struct {

View File

@ -198,7 +198,7 @@ u32 UpdatePlayerCollision(void) {
} else { } else {
direction = gPlayerState.direction; 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); index = sub_0807BDB8(&gPlayerEntity, direction >> 2);
if (index != 0xff && (gRoomControls.scroll_flags & 4) == 0) { if (index != 0xff && (gRoomControls.scroll_flags & 4) == 0) {
ptr1 = &gUnk_080B4490[index * 2]; ptr1 = &gUnk_080B4490[index * 2];
@ -254,10 +254,10 @@ u32 UpdatePlayerCollision(void) {
if (gPlayerState.field_0xa != 0) { if (gPlayerState.field_0xa != 0) {
return 0; return 0;
} }
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != 0) { if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != DirectionNorth) {
return 0; return 0;
} }
if ((gPlayerEntity.direction & 0x80) != 0) { if ((gPlayerEntity.direction & DIR_NOT_MOVING_CHECK) != 0) {
return 0; return 0;
} }
if (sub_080B1B44(position, gPlayerEntity.collisionLayer) != 0xf) { if (sub_080B1B44(position, gPlayerEntity.collisionLayer) != 0xf) {
@ -356,7 +356,7 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
#endif #endif
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != 0) { if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != DirectionNorth) {
return 0; return 0;
} }
if ((gPlayerEntity.direction & 0x80) != 0) { if ((gPlayerEntity.direction & 0x80) != 0) {
@ -415,7 +415,7 @@ u32 UpdatePlayerCollision(void) {
if ((animationState1 & 0xff) != 0) { if ((animationState1 & 0xff) != 0) {
return 0; return 0;
} }
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0; return 0;
} }
if ((gPlayerEntity.frame & 2) == 0) { if ((gPlayerEntity.frame & 2) == 0) {
@ -555,7 +555,7 @@ u32 UpdatePlayerCollision(void) {
if (animationState3 == 0) { if (animationState3 == 0) {
return 0; return 0;
} }
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0; return 0;
} }
if ((gPlayerEntity.frame & 1) == 0) { if ((gPlayerEntity.frame & 1) == 0) {
@ -574,7 +574,7 @@ u32 UpdatePlayerCollision(void) {
if ((animationState2) != 4) { if ((animationState2) != 4) {
return 0; return 0;
} }
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0; return 0;
} }
if ((gPlayerEntity.frame & 1) == 0) { if ((gPlayerEntity.frame & 1) == 0) {
@ -595,7 +595,7 @@ bool32 sub_0801A2B0(LayerStruct* layer, u32 position, u32 collisionType) {
u16 temp4; u16 temp4;
uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1]; 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 position = (u16)(position - (-uVar1)); // necessary for match
temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer)); temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer));
switch (temp4) { switch (temp4) {
@ -712,18 +712,18 @@ bool32 sub_0801A4F8(void) {
if (GetInventoryValue(ITEM_POWER_BRACELETS) != 1) { if (GetInventoryValue(ITEM_POWER_BRACELETS) != 1) {
return FALSE; return FALSE;
} }
if ((gPlayerState.direction & 0x80) != 0) { if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) {
return FALSE; return FALSE;
} }
if (gPlayerState.direction != gPlayerEntity.direction) { if (gPlayerState.direction != gPlayerEntity.direction) {
return FALSE; return FALSE;
} }
tmp = (((gPlayerEntity.direction + 4) & 0x18) >> 3); tmp = (((gPlayerEntity.direction + 4) & DirectionWest) >> 3);
if ((gUnk_080B44A0[tmp] & gPlayerEntity.collisions) == 0) { if ((gUnk_080B44A0[tmp] & gPlayerEntity.collisions) == 0) {
return FALSE; return FALSE;
} }
} else { } else {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) { if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return FALSE; return FALSE;
} }
if ((gPlayerEntity.frame & 1) == 0) { if ((gPlayerEntity.frame & 1) == 0) {

View File

@ -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); this->spriteSettings.flipX = (this->direction >> 4 ^ 1);
ProcessMovement0(this); ProcessMovement0(this);
@ -486,7 +486,7 @@ void AcroBandit_Type1Action6(Entity* this) {
this->action = 7; this->action = 7;
dir = fallDirections[this->field_0x74.HALF.LO * 5 + this->type2]; dir = fallDirections[this->field_0x74.HALF.LO * 5 + this->type2];
this->direction = dir; this->direction = dir;
if (dir >= 0x10) { if (dir >= DirectionSouth) {
this->spriteSettings.flipX = 1; this->spriteSettings.flipX = 1;
} else { } else {
this->spriteSettings.flipX = 0; this->spriteSettings.flipX = 0;
@ -570,7 +570,7 @@ static void sub_080322E8(Entity* this) {
} }
} else { } else {
u8 tmp = this->direction; u8 tmp = this->direction;
if (tmp & 0xF) { if (tmp & (0x3 | DirectionEast | DIR_DIAGONAL)) {
tmp >>= 4; tmp >>= 4;
tmp ^= 1; tmp ^= 1;
if (tmp != this->spriteSettings.flipX) { if (tmp != this->spriteSettings.flipX) {

View File

@ -105,7 +105,8 @@ void sub_080218CC(Entity* this) {
if (this->subAction == 0) { if (this->subAction == 0) {
this->subAction = 1; this->subAction = 1;
this->spriteSettings.draw = 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->speed = 0x100;
this->zVelocity = Q_16_16(1.125); this->zVelocity = Q_16_16(1.125);
} }
@ -244,9 +245,9 @@ void sub_08021B64(Entity* this) {
this->zVelocity = Q_16_16(1.0); this->zVelocity = Q_16_16(1.0);
((u8*)&this->field_0x86)[1] = 0; ((u8*)&this->field_0x86)[1] = 0;
if (gPlayerEntity.direction != 0xff) { if (gPlayerEntity.direction != 0xff) {
this->direction = 0x10 ^ gPlayerEntity.direction; this->direction = DirectionSouth ^ gPlayerEntity.direction;
} else { } else {
this->direction = (gPlayerEntity.animationState << 2) ^ 0x10; this->direction = (gPlayerEntity.animationState << 2) ^ DirectionSouth;
} }
InitializeAnimation(this, 5); InitializeAnimation(this, 5);
} else { } else {

View File

@ -10,18 +10,20 @@
#include "room.h" #include "room.h"
#include "object.h" #include "object.h"
#define DIR_NOT_MOVING_CHECK 0x80
void BladeTrap(Entity* this) { void BladeTrap(Entity* this) {
if (this->action == 0) { if (this->action == 0) {
this->action = 1; this->action = 1;
this->child = GetCurrentRoomProperty(this->type); this->child = GetCurrentRoomProperty(this->type);
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
} }
if (!(this->direction & 0x80)) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(this); LinearMoveUpdate(this);
} }
if (!(--this->field_0x74.HWORD)) { if (!(--this->field_0x74.HWORD)) {
if (!(this->direction & 0x80)) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
EnqueueSFX(SFX_METAL_CLINK); EnqueueSFX(SFX_METAL_CLINK);
} }
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);

View File

@ -62,7 +62,7 @@ void Bobomb_OnCollision(Entity* this) {
this->zVelocity = Q_16_16(1.5); this->zVelocity = Q_16_16(1.5);
this->speed = 0; this->speed = 0;
this->field_0x80.HALF.HI = 1; this->field_0x80.HALF.HI = 1;
InitializeAnimation(this, this->direction >> 4 | 6); InitializeAnimation(this, this->direction >> 4 | IdleWest);
break; break;
} }
} }
@ -123,7 +123,7 @@ void sub_0802C83C(Entity* this) {
} else { } else {
this->field_0x82.HALF.LO = 2; this->field_0x82.HALF.LO = 2;
this->timer = 120; this->timer = 120;
InitializeAnimation(this, (this->direction >> 4) | 6); InitializeAnimation(this, (this->direction >> 4) | IdleWest);
COLLISION_OFF(this); COLLISION_OFF(this);
this->hitType = 0x6e; this->hitType = 0x6e;
} }
@ -147,7 +147,7 @@ void sub_0802C8D8(Entity* this) {
this->action = 1; this->action = 1;
this->timer = 60; this->timer = 60;
this->subtimer = 0; this->subtimer = 0;
this->direction = (Random() & 0x18) | 4; this->direction = (Random() & 0x18) | DIR_DIAGONAL;
this->carryFlags = 0; this->carryFlags = 0;
this->gustJarFlags = 0x12; this->gustJarFlags = 0x12;
this->field_0x82.HALF.LO = 0; this->field_0x82.HALF.LO = 0;
@ -163,7 +163,7 @@ void sub_0802C91C(Entity* this) {
if (this->field_0x82.HALF.LO) { if (this->field_0x82.HALF.LO) {
if (this->collisions != COL_NONE) { if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions); sub_0800417E(this, this->collisions);
InitializeAnimation(this, (this->direction >> 4) | 2); InitializeAnimation(this, (this->direction >> 4) | IdleEast);
} }
if (--this->timer == 0) { if (--this->timer == 0) {
sub_0802CBC4(this); sub_0802CBC4(this);
@ -180,7 +180,7 @@ void sub_0802C91C(Entity* this) {
} }
if (--this->timer == 0) { if (--this->timer == 0) {
this->timer = 60; this->timer = 60;
this->direction = (this->direction + 8) & 0x1c; this->direction = (this->direction + 8) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(this, this->direction >> 4); InitializeAnimation(this, this->direction >> 4);
} }
} }
@ -196,7 +196,7 @@ void sub_0802C9D0(Entity* this) {
this->spritePriority.b1 = 0; this->spritePriority.b1 = 0;
this->field_0x82.HALF.HI = 1; this->field_0x82.HALF.HI = 1;
sub_0802CC18(this); sub_0802CC18(this);
InitializeAnimation(this, (this->direction >> 4) | 6); InitializeAnimation(this, (this->direction >> 4) | IdleWest);
GetNextFrame(this); GetNextFrame(this);
} }
@ -210,7 +210,7 @@ void sub_0802CA10(Entity* this) {
} }
} else { } else {
this->field_0x82.HALF.HI = 2; 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); sub_0802CC18(this);
GetNextFrame(this); GetNextFrame(this);
} }
@ -234,8 +234,8 @@ void sub_0802CA94(Entity* this) {
this->speed = 0; this->speed = 0;
this->field_0x82.HALF.HI = 0; this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0; this->field_0x80.HALF.HI = 0;
this->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c; this->direction = ((gPlayerEntity.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(this, (this->direction >> 4) | 6); InitializeAnimation(this, (this->direction >> 4) | IdleWest);
} }
void sub_0802CAF8(Entity* this) { void sub_0802CAF8(Entity* this) {
@ -264,7 +264,7 @@ void sub_0802CB68(Entity* this) {
this->action = 1; this->action = 1;
this->subAction = 0; this->subAction = 0;
this->direction = Random() & 0x18; this->direction = Random() & 0x18;
this->direction |= 4; this->direction |= IdleSouth;
COLLISION_ON(this); COLLISION_ON(this);
if (this->field_0x82.HALF.LO) { if (this->field_0x82.HALF.LO) {
this->timer = 200; this->timer = 200;

View File

@ -141,10 +141,10 @@ void sub_0802A9A8(Entity* this) {
this->field_0x82.HWORD = 1; this->field_0x82.HWORD = 1;
if (this->field_0x80.HALF.LO) { if (this->field_0x80.HALF.LO) {
this->x.HALF.HI = gRoomControls.scroll_x - 0x10; this->x.HALF.HI = gRoomControls.scroll_x - 0x10;
this->direction = 8; this->direction = DirectionEast;
} else { } else {
this->x.HALF.HI = gRoomControls.scroll_x + 0x100; this->x.HALF.HI = gRoomControls.scroll_x + 0x100;
this->direction = 0x18; this->direction = DirectionWest;
} }
this->y.HALF.HI = gRoomControls.scroll_y + 0x40; this->y.HALF.HI = gRoomControls.scroll_y + 0x40;
this->timer = 128; this->timer = 128;
@ -221,7 +221,7 @@ void sub_0802AAC0(Entity* this) {
#ifndef EU #ifndef EU
this->field_0x78.HALF.LO = 0; this->field_0x78.HALF.LO = 0;
this->field_0x78.HALF.HI = 4; this->field_0x78.HALF.HI = 4;
this->direction = 0xff; this->direction = DIR_NONE;
#endif #endif
InitializeAnimation(this, 0); InitializeAnimation(this, 0);
} }

View File

@ -79,7 +79,7 @@ void BusinessScrub_Action0(Entity* this) {
this->field_0x78.HWORD = this->x.HALF.HI; this->field_0x78.HWORD = this->x.HALF.HI;
this->field_0x7a.HWORD = this->y.HALF.HI; this->field_0x7a.HWORD = this->y.HALF.HI;
this->animationState = 0; this->animationState = 0;
this->direction = 0x10; this->direction = DirectionSouth;
sub_08028E9C(this); sub_08028E9C(this);
if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) { if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) {
this->action = 4; this->action = 4;
@ -455,8 +455,8 @@ void sub_080290FC(Entity* this) {
if (this->timer != 0) { if (this->timer != 0) {
this->timer--; this->timer--;
if ((this->timer < 16) && ((this->timer & 1) == 0)) { if ((this->timer < 16) && ((this->timer & 1) == 0)) {
s32 sVar3 = ((this->direction & 0x10) != 0) ? -1 : 1; s32 sVar3 = (this->direction & DirectionSouth) ? -1 : 1;
if ((this->direction & 8) != 0) { if (this->direction & DirectionEast) {
this->x.HALF.HI += ((this->timer & 8) != 0) ? -sVar3 : sVar3; this->x.HALF.HI += ((this->timer & 8) != 0) ? -sVar3 : sVar3;
} else { } else {
this->y.HALF.HI += ((this->timer & 8) != 0) ? sVar3 : -sVar3; this->y.HALF.HI += ((this->timer & 8) != 0) ? sVar3 : -sVar3;

View File

@ -34,7 +34,7 @@ void sub_0802B540(Entity* this) {
this->timer--; this->timer--;
} else { } else {
u32 direction = sub_0804A024(this, 1, 0xc); u32 direction = sub_0804A024(this, 1, 0xc);
if (direction != 0xff) { if (direction != DIR_NONE) {
this->action = 2; this->action = 2;
this->speed = 0x40; this->speed = 0x40;
this->direction = direction; this->direction = direction;

View File

@ -119,10 +119,11 @@ void sub_08022AA4(Entity* this) {
if (!sub_08049FA0(this) && (rand >> 8) & 3) { if (!sub_08049FA0(this) && (rand >> 8) & 3) {
this->direction = sub_08049EE4(this); this->direction = sub_08049EE4(this);
} else { } 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; this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
} }
@ -144,7 +145,7 @@ void sub_08022B44(Entity* this) {
this->zVelocity = Q_16_16(0.75); this->zVelocity = Q_16_16(0.75);
this->direction = GetFacingDirection(this, &gPlayerEntity); this->direction = GetFacingDirection(this, &gPlayerEntity);
if (this->direction & 0xf) if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast))
this->spriteSettings.flipX = (this->direction >> 4) ^ 1; this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
EnqueueSFX(SFX_VO_CHEEP); EnqueueSFX(SFX_VO_CHEEP);

View File

@ -117,7 +117,7 @@ void sub_08045524(Entity* this) {
this->zVelocity = Q_16_16(1.75); this->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(this, 1, 8); tmp = sub_0804A024(this, 1, 8);
if (tmp != 0xff && (Random() & 3) == 0) { if (tmp != DIR_NONE && (Random() & 3) == 0) {
this->timer = Random() & 3; this->timer = Random() & 3;
this->direction = DirectionRound(tmp); this->direction = DirectionRound(tmp);
} else { } else {

View File

@ -215,9 +215,9 @@ void sub_0802BE80(Entity* this) {
} }
void sub_0802BEBC(Entity* this) { void sub_0802BEBC(Entity* this) {
this->direction ^= 0x10; this->direction ^= DirectionSouth;
ProcessMovement2(this); ProcessMovement2(this);
this->direction ^= 0x10; this->direction ^= DirectionSouth;
if (!sub_080044EC(this, Q_16_16(0.125))) { if (!sub_080044EC(this, Q_16_16(0.125))) {
sub_0802C1C0(this); sub_0802C1C0(this);
} }

View File

@ -89,7 +89,7 @@ void sub_0803CD6C(Entity* this) {
void sub_0803CDA8(Entity* this) { void sub_0803CDA8(Entity* this) {
UpdateAnimationSingleFrame(this); UpdateAnimationSingleFrame(this);
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(this); LinearMoveUpdate(this);
} }
@ -123,7 +123,7 @@ void sub_0803CE14(Entity* this) {
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
direction = this->direction; direction = this->direction;
if (direction & 0x80) { if (direction & DIR_NOT_MOVING_CHECK) {
return; return;
} }

View File

@ -73,7 +73,7 @@ void Leever_Idle(Entity* this) {
if (Leever_PlayerInRange(this, Random() & 0x1f)) { if (Leever_PlayerInRange(this, Random() & 0x1f)) {
this->action = 2; this->action = 2;
this->spriteSettings.draw = TRUE; 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); InitializeAnimation(this, LeeverAnimation_DigUp);
UpdateSpriteForCollisionLayer(this); UpdateSpriteForCollisionLayer(this);
} else { } else {

View File

@ -369,16 +369,16 @@ void sub_08029EEC(Entity* this) {
void sub_08029F0C(Entity* this) { void sub_08029F0C(Entity* this) {
switch (this->direction >> 3) { switch (this->direction >> 3) {
case 0: case 0: // UP
this->field_0x78.HWORD = this->y.HALF.HI - 0x10; this->field_0x78.HWORD = this->y.HALF.HI - 0x10;
break; break;
case 1: case 1: // RIGHT
this->field_0x78.HWORD = this->x.HALF.HI + 0x10; this->field_0x78.HWORD = this->x.HALF.HI + 0x10;
break; break;
case 2: case 2: // DOWN
this->field_0x78.HWORD = this->y.HALF.HI + 0x10; this->field_0x78.HWORD = this->y.HALF.HI + 0x10;
break; break;
case 3: case 3: // LEFT
this->field_0x78.HWORD = this->x.HALF.HI - 0x10; this->field_0x78.HWORD = this->x.HALF.HI - 0x10;
break; break;
} }
@ -386,25 +386,25 @@ void sub_08029F0C(Entity* this) {
bool32 sub_08029F48(Entity* this) { bool32 sub_08029F48(Entity* this) {
switch (this->direction >> 3) { switch (this->direction >> 3) {
case 0: case 0: // UP
if (this->y.HALF.HI <= this->field_0x78.HWORD) { if (this->y.HALF.HI <= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD; this->y.HALF.HI = this->field_0x78.HWORD;
return TRUE; return TRUE;
} }
break; break;
case 1: case 1: // RIGHT
if (this->x.HALF.HI >= this->field_0x78.HWORD) { if (this->x.HALF.HI >= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD; this->x.HALF.HI = this->field_0x78.HWORD;
return TRUE; return TRUE;
} }
break; break;
case 2: case 2: // DOWN
if (this->y.HALF.HI >= this->field_0x78.HWORD) { if (this->y.HALF.HI >= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD; this->y.HALF.HI = this->field_0x78.HWORD;
return TRUE; return TRUE;
} }
break; break;
case 3: case 3: // LEFT
if (this->x.HALF.HI <= this->field_0x78.HWORD) { if (this->x.HALF.HI <= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD; this->x.HALF.HI = this->field_0x78.HWORD;
return TRUE; return TRUE;

View File

@ -509,7 +509,7 @@ void sub_0803A8B8(Entity* this) {
this->action = 0x10; this->action = 0x10;
this->timer = 30; this->timer = 30;
this->direction = 0; this->direction = DirectionNorth;
this->speed = 0x80; this->speed = 0x80;
ptr = gUnk_080CED6C; ptr = gUnk_080CED6C;
@ -553,7 +553,7 @@ void sub_0803A978(Entity* this) {
sub_08004596(this, 0x10); sub_08004596(this, 0x10);
} }
LinearMoveUpdate(this); LinearMoveUpdate(this);
if (this->direction == 0x10) { if (this->direction == DirectionSouth) {
this->action = 0x12; this->action = 0x12;
this->timer = 3; this->timer = 3;
COLLISION_OFF(this); COLLISION_OFF(this);

View File

@ -561,7 +561,7 @@ void sub_0803473C(Entity* this) {
if (roomX + 0xe0 < this->x.HALF.HI) { if (roomX + 0xe0 < this->x.HALF.HI) {
return; return;
} }
this->direction = 8; this->direction = DirectionEast;
} else { } else {
if (playerX + 4 >= this->x.HALF.HI) { if (playerX + 4 >= this->x.HALF.HI) {
return; return;
@ -569,7 +569,7 @@ void sub_0803473C(Entity* this) {
if (roomX + 0x90 > this->x.HALF.HI) { if (roomX + 0x90 > this->x.HALF.HI) {
return; return;
} }
this->direction = 0x18; this->direction = DirectionWest;
} }
LinearMoveUpdate(this); LinearMoveUpdate(this);
} }
@ -581,7 +581,7 @@ void sub_080347B4(Entity* this) {
if (roomX + 0xe0 < this->x.HALF.HI) { if (roomX + 0xe0 < this->x.HALF.HI) {
return; return;
} }
this->direction = 8; this->direction = DirectionEast;
} else { } else {
if (playerX + 4 >= this->x.HALF.HI) { if (playerX + 4 >= this->x.HALF.HI) {
return; return;
@ -589,7 +589,7 @@ void sub_080347B4(Entity* this) {
if (roomX + 0x90 > this->x.HALF.HI) { if (roomX + 0x90 > this->x.HALF.HI) {
return; return;
} }
this->direction = 0x18; this->direction = DirectionWest;
} }
LinearMoveUpdate(this); LinearMoveUpdate(this);
} }

View File

@ -209,7 +209,7 @@ void sub_08022F14(Entity* this) {
} }
this->direction += this->field_0x78.HALF.LO; this->direction += this->field_0x78.HALF.LO;
this->direction &= 0x1f; this->direction &= DirectionNorthWest | 0x3;
this->animationState = ((this->direction + 2) & 0x1c) >> 2; this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState; this->frameIndex = this->animationState;

View File

@ -182,7 +182,7 @@ void Peahat_ChargeStart(Entity* this) {
this->action = 3; this->action = 3;
this->timer = 120; this->timer = 120;
this->speed = 192; 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 { } else {
sub_080205F8(this); sub_080205F8(this);
@ -226,6 +226,8 @@ void Peahat_ChargeEnd(Entity* this) {
} }
} }
#define DIR_NONE 0xff
void Peahat_Stunned(Entity* this) { void Peahat_Stunned(Entity* this) {
switch (this->animationState) { switch (this->animationState) {
default: default:
@ -236,7 +238,7 @@ void Peahat_Stunned(Entity* this) {
this->hitType = 0x71; this->hitType = 0x71;
} }
if (this->direction == 0xff) if (this->direction == DIR_NONE)
this->direction = this->knockbackDirection; this->direction = this->knockbackDirection;
ProcessMovement0(this); ProcessMovement0(this);
@ -364,7 +366,7 @@ void sub_08020604(Entity* this) {
this->direction = sub_08049EE4(this); this->direction = sub_08049EE4(this);
} else { } else {
this->direction += this->field_0x80.HALF.LO; this->direction += this->field_0x80.HALF.LO;
this->direction &= 0x1f; this->direction &= (0x3 | DirectionNorthWest);
} }
} }

View File

@ -387,7 +387,7 @@ void sub_080244E8(Entity* this) {
if (tmp == 0) { if (tmp == 0) {
this->field_0x80.HALF.LO++; this->field_0x80.HALF.LO++;
this->timer = 12; this->timer = 12;
this->direction = 0x10; this->direction = DirectionSouth;
this->speed = tmp; this->speed = tmp;
this->cutsceneBeh.HALF.LO = 0; this->cutsceneBeh.HALF.LO = 0;
this->flags2 &= 0xfc; this->flags2 &= 0xfc;
@ -554,13 +554,13 @@ void sub_08024940(Entity* this) {
} }
void sub_080249DC(Entity* this) { void sub_080249DC(Entity* this) {
u8 direction = ((this->direction + 2) & 0x1c) >> 2; u8 direction = ((this->direction + 2) & DirectionNorthWest) >> 2;
this->animationState = direction; this->animationState = direction;
InitializeAnimation(this, this->animationState); InitializeAnimation(this, this->animationState);
} }
void sub_080249F4(Entity* this) { void sub_080249F4(Entity* this) {
u32 direction = ((this->direction + 2) & 0x1f); u32 direction = ((this->direction + 2) & (0x3 | DirectionNorthWest));
direction >>= 2; direction >>= 2;
if (direction != this->animationState) { if (direction != this->animationState) {
this->animationState = direction; this->animationState = direction;
@ -770,8 +770,8 @@ void sub_08024D00(Entity* this) {
this->field_0x80.HALF.LO++; this->field_0x80.HALF.LO++;
this->timer = (Random() & 0xf) + 32; this->timer = (Random() & 0xf) + 32;
this->direction += this->field_0x80.HALF.HI ? 4 : 0x1c; this->direction += this->field_0x80.HALF.HI ? DirectionNorthEast : DirectionNorthWest;
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
this->field_0x80.HALF.HI ^= 0x40; this->field_0x80.HALF.HI ^= 0x40;
sub_08024A14(this, 3, 0x10); sub_08024A14(this, 3, 0x10);
@ -783,8 +783,8 @@ void sub_08024D00(Entity* this) {
this->timer = (Random() & 0x1f) + 32; this->timer = (Random() & 0x1f) + 32;
} else { } else {
if (--this->subtimer == 0) { if (--this->subtimer == 0) {
this->direction += this->field_0x80.HALF.HI ? 1 : 0x1f; this->direction += this->field_0x80.HALF.HI ? 1 : (0x3 | DirectionNorthWest);
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
this->subtimer = 16; this->subtimer = 16;
sub_080249DC(this); sub_080249DC(this);

View File

@ -338,7 +338,7 @@ void sub_080255AC(Entity* this) {
} }
tmp -= 7; tmp -= 7;
this->direction = (GetFacingDirection(ent, this) + tmp) & 0x1f; this->direction = (GetFacingDirection(ent, this) + tmp) & (0x3 | DirectionNorthWest);
} }
if (this->field_0x78.HWORD == 0) { if (this->field_0x78.HWORD == 0) {
@ -378,7 +378,7 @@ void sub_080256B4(Entity* this) {
this->action = 1; this->action = 1;
this->timer = (Random() & 3) + 4; this->timer = (Random() & 3) + 4;
this->subtimer = 30; 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_0x78.HWORD = gUnk_080CC000[Random() & 0xf];
this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1; this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1;
this->field_0x7a.HALF.HI = 0; this->field_0x7a.HALF.HI = 0;

View File

@ -39,7 +39,7 @@ void Rollobite_OnCollision(Entity* this) {
if (this->hitType == 34 && this->health != 0xff) { if (this->hitType == 34 && this->health != 0xff) {
this->action = 4; this->action = 4;
this->zVelocity = Q_16_16(2.0); this->zVelocity = Q_16_16(2.0);
this->direction = 0xff; this->direction = DIR_NONE;
this->health = 0xff; this->health = 0xff;
this->hitType = 35; this->hitType = 35;
InitializeAnimation(this, this->animationState + 8); InitializeAnimation(this, this->animationState + 8);
@ -49,7 +49,7 @@ void Rollobite_OnCollision(Entity* this) {
if (this->action == 4 || this->action == 5) { if (this->action == 4 || this->action == 5) {
this->action = 4; this->action = 4;
this->timer = 180; this->timer = 180;
this->direction = 0xff; this->direction = DIR_NONE;
InitializeAnimation(this, this->animationState + 0x10); InitializeAnimation(this, this->animationState + 0x10);
} }
} }
@ -74,7 +74,7 @@ void Rollobite_OnGrabbed(Entity* this) {
if (this->subAction < 3 && !sub_0806F520(this)) { if (this->subAction < 3 && !sub_0806F520(this)) {
this->action = 4; this->action = 4;
COLLISION_ON(this); COLLISION_ON(this);
this->direction = 0xff; this->direction = DIR_NONE;
InitializeAnimation(this, this->animationState + 0x10); InitializeAnimation(this, this->animationState + 0x10);
} else { } else {
gUnk_080CA6A4[this->subAction](this); gUnk_080CA6A4[this->subAction](this);
@ -107,7 +107,7 @@ void sub_080207A8(Entity* this) {
COLLISION_ON(this); COLLISION_ON(this);
this->spritePriority.b0 = 4; this->spritePriority.b0 = 4;
this->gustJarState &= 0xfb; this->gustJarState &= 0xfb;
this->direction ^= 0x10; this->direction ^= DirectionSouth;
this->zVelocity = Q_16_16(1.5); this->zVelocity = Q_16_16(1.5);
this->speed = 0x80; this->speed = 0x80;
InitializeAnimation(this, this->animationState + 0x10); InitializeAnimation(this, this->animationState + 0x10);
@ -193,7 +193,7 @@ void Rollobite_RolledUp(Entity* this) {
if (unk == 1) if (unk == 1)
EnqueueSFX(SFX_PLACE_OBJ); EnqueueSFX(SFX_PLACE_OBJ);
if ((this->direction & 0x80) == 0) if (!(this->direction & DIR_NOT_MOVING_CHECK))
ProcessMovement2(this); ProcessMovement2(this);
} }
} }
@ -248,8 +248,8 @@ void sub_08020A7C(Entity* this) {
if (sub_08049FA0(this) == 0) { if (sub_08049FA0(this) == 0) {
int tmp = DirectionRoundUp(sub_08049EE4(this)); int tmp = DirectionRoundUp(sub_08049EE4(this));
if ((state ^ 0x10) == tmp) if ((state ^ DirectionSouth) == tmp)
state ^= 0x10; state ^= DirectionSouth;
} }
this->direction = state; this->direction = state;

View File

@ -131,7 +131,7 @@ void sub_08038304(Entity* this) {
} }
this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI; this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI;
this->field_0x78.HALF.HI = cVar2; this->field_0x78.HALF.HI = cVar2;
this->direction = (this->direction + cVar2) & 0x18; this->direction = (this->direction + cVar2) & DirectionWest;
} else { } else {
this->direction = this->field_0x78.HALF.LO; this->direction = this->field_0x78.HALF.LO;
} }

View File

@ -218,7 +218,7 @@ void sub_08029688(Entity* this) {
void sub_0802969C(Entity* this) { void sub_0802969C(Entity* this) {
u32 bVar1; u32 bVar1;
if ((this->direction & 0xf) != 0) { if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) {
bVar1 = this->direction >> 4; bVar1 = this->direction >> 4;
if (bVar1 != this->animationState) { if (bVar1 != this->animationState) {

View File

@ -42,16 +42,16 @@ void sub_0802BA18(Entity* this) {
this->direction = direction; this->direction = direction;
switch (direction >> 3) { switch (direction >> 3) {
case 0: case 0: // UP
this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI; this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI;
break; break;
case 1: case 1: // RIGHT
this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO; this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO;
break; break;
case 2: case 2: // DOWN
this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI; this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI;
break; break;
case 3: case 3: // LEFT
this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO; this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO;
break; break;
} }
@ -62,19 +62,19 @@ void sub_0802BA8C(Entity* this) {
sub_0802BB10(this); sub_0802BB10(this);
} else { } else {
switch (this->direction >> 3) { switch (this->direction >> 3) {
case 0: case 0: // UP
if (this->field_0x7a.HWORD >= this->y.HALF.HI) if (this->field_0x7a.HWORD >= this->y.HALF.HI)
sub_0802BB10(this); sub_0802BB10(this);
break; break;
case 1: case 1: // RIGHT
if (this->field_0x7a.HWORD <= this->x.HALF.HI) if (this->field_0x7a.HWORD <= this->x.HALF.HI)
sub_0802BB10(this); sub_0802BB10(this);
break; break;
case 2: case 2: // DOWN
if (this->field_0x7a.HWORD <= this->y.HALF.HI) if (this->field_0x7a.HWORD <= this->y.HALF.HI)
sub_0802BB10(this); sub_0802BB10(this);
break; break;
case 3: case 3: // LEFT
if (this->field_0x7a.HWORD >= this->x.HALF.HI) if (this->field_0x7a.HWORD >= this->x.HALF.HI)
sub_0802BB10(this); sub_0802BB10(this);
break; break;
@ -91,7 +91,7 @@ void sub_0802BAFC(Entity* this) {
void sub_0802BB10(Entity* this) { void sub_0802BB10(Entity* this) {
this->action = 3; this->action = 3;
this->speed = 0xc0; this->speed = 0xc0;
this->direction = this->direction ^ 0x10; this->direction = this->direction ^ DirectionSouth;
EnqueueSFX(SFX_METAL_CLINK); EnqueueSFX(SFX_METAL_CLINK);
} }

View File

@ -91,8 +91,8 @@ void sub_08031714(Entity* this) {
if (sub_08049FA0(this) == 0 && (this->subtimer & 1) != 0) { if (sub_08049FA0(this) == 0 && (this->subtimer & 1) != 0) {
this->direction = sub_08049EE4(this); this->direction = sub_08049EE4(this);
} else { } else {
this->direction += 0x18; this->direction += DirectionWest;
this->direction = ((Random() & 0xe) + this->direction) & 0x1f; this->direction = ((Random() & 0xe) + this->direction) & (0x3 | DirectionNorthWest);
} }
sub_080317E0(this); sub_080317E0(this);
} }

View File

@ -60,7 +60,7 @@ void sub_0802B35C(Entity* this) {
if (--this->subtimer == 0) { if (--this->subtimer == 0) {
this->subtimer = 120; this->subtimer = 120;
this->direction += is_head ? 0x08 : 0x18; this->direction += is_head ? DirectionEast : DirectionWest;
this->direction = DirectionRound(this->direction); this->direction = DirectionRound(this->direction);
} }
} else { } else {

View File

@ -176,7 +176,7 @@ void sub_08028488(Entity* this) {
this->timer = (Random() & 7) * 3 + 64; this->timer = (Random() & 7) * 3 + 64;
break; break;
case 4: case 4:
this->direction = (this->direction + 0x10) & 0x18; this->direction = (this->direction + 0x10) & DirectionWest;
/* fallthrough */ /* fallthrough */
case 1: case 1:
default: default:
@ -265,7 +265,7 @@ void sub_08028604(Entity* this) {
this->timer = this->timer + 0x10; this->timer = this->timer + 0x10;
this->field_0x82.HALF.HI--; this->field_0x82.HALF.HI--;
} }
this->direction = (iVar3 + 4U) & 0x18; this->direction = (iVar3 + 4U) & DirectionWest;
iVar3 = Direction8ToAnimationState(this->direction); iVar3 = Direction8ToAnimationState(this->direction);
} }
} else { } else {

View File

@ -107,7 +107,7 @@ void sub_0802B7A4(Entity* this) {
this->timer = gUnk_080CD314[Random() & 3]; this->timer = gUnk_080CD314[Random() & 3];
this->speed = 0x60; this->speed = 0x60;
sub_0802B960(this); sub_0802B960(this);
if (this->direction != 0xff) { if (this->direction != DIR_NONE) {
u32 animation = this->direction >> 3; u32 animation = this->direction >> 3;
if (animation != this->animationState) { if (animation != this->animationState) {
this->animationState = animation & 3; this->animationState = animation & 3;

View File

@ -159,7 +159,7 @@ void sub_0802F300(Entity* this) {
} else if (this->collisions != COL_NONE) { } else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions); sub_0800417E(this, this->collisions);
} else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) {
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
} }
if (--this->timer == 0) { if (--this->timer == 0) {
@ -214,6 +214,6 @@ static void sub_0802F45C(Entity* this) {
this->direction = sub_08049F84(this, 1); this->direction = sub_08049F84(this, 1);
} else { } else {
temp = (Random() & 0xf) + 0x18; temp = (Random() & 0xf) + 0x18;
this->direction = (temp + this->direction) & 0x1f; this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest);
} }
} }

View File

@ -136,7 +136,7 @@ void sub_08038048(Entity* this) {
} else if (this->collisions != COL_NONE) { } else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions); sub_0800417E(this, this->collisions);
} else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) {
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
} }
if (--this->timer == 0) { if (--this->timer == 0) {
@ -185,6 +185,6 @@ void sub_08038168(Entity* this) {
this->direction = sub_08049F84(this, 1); this->direction = sub_08049F84(this, 1);
} else { } else {
temp = (Random() & 0xf) + 0x18; temp = (Random() & 0xf) + 0x18;
this->direction = (temp + this->direction) & 0x1f; this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest);
} }
} }

View File

@ -74,7 +74,7 @@ void sub_0804468C(Entity* this) {
case 0: case 0:
this->action = 1; this->action = 1;
this->timer = 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_0x78.HALF.LO = 0;
this->field_0x82.HALF.HI = 0; this->field_0x82.HALF.HI = 0;
this->spriteSettings.draw = 0; this->spriteSettings.draw = 0;
@ -123,7 +123,7 @@ void sub_0804474C(Entity* this) {
if (--this->timer == 0) { if (--this->timer == 0) {
this->timer = 2; this->timer = 2;
this->direction++; this->direction++;
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
} }
LinearMoveUpdate(this); LinearMoveUpdate(this);
UpdateAnimationSingleFrame(this); UpdateAnimationSingleFrame(this);
@ -253,7 +253,7 @@ void sub_080449F8(Entity* this) {
this->timer = 4; this->timer = 4;
this->direction++; this->direction++;
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
if (vaati->field_0x80.HALF.LO == 0) if (vaati->field_0x80.HALF.LO == 0)
vaati->field_0x74.HALF.LO = 1; vaati->field_0x74.HALF.LO = 1;
break; break;
@ -266,9 +266,9 @@ void sub_080449F8(Entity* this) {
} }
break; break;
case 1: case 1:
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(this); LinearMoveUpdate(this);
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
this->timer = 2; this->timer = 2;
break; break;
case 3: case 3:
@ -324,7 +324,7 @@ void sub_08044B04(Entity* this) {
if (--this->timer == 0) { if (--this->timer == 0) {
this->timer = this->field_0x78.HALF.LO ? 4 : 2; this->timer = this->field_0x78.HALF.LO ? 4 : 2;
this->direction++; this->direction++;
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
} }
if (--this->subtimer == 0) { if (--this->subtimer == 0) {
if (this->timer != 2) { if (this->timer != 2) {
@ -346,11 +346,11 @@ void sub_08044B04(Entity* this) {
case 1: case 1:
if (--this->timer == 0) { if (--this->timer == 0) {
this->timer = 6; this->timer = 6;
this->direction = (this->direction + 1) & 0x1f; this->direction = (this->direction + 1) & (0x3 | DirectionNorthWest);
if (++this->subtimer == 0x30) { if (++this->subtimer == 0x30) {
u32 direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10); u32 direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
this->speed = 0; this->speed = 0;
this->direction = (direction + 16) & 0x1f; this->direction = (direction + 16) & (0x3 | DirectionNorthWest);
this->timer = 16; this->timer = 16;
this->subtimer = 16; this->subtimer = 16;
this->field_0x74.HALF.LO++; this->field_0x74.HALF.LO++;
@ -485,18 +485,18 @@ void sub_08044E74(Entity* this, u32 state) {
switch (state) { switch (state) {
case 2: case 2:
this->action = 2; this->action = 2;
this->direction += 0x18; this->direction += DirectionWest;
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); PositionRelative(this->parent, this, 0, Q_16_16(-16.0));
this->speed = 12288; this->speed = 12288;
LinearMoveUpdate(this); LinearMoveUpdate(this);
this->direction += 0x8; this->direction += DirectionEast;
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
this->speed = 1280; this->speed = 1280;
LinearMoveUpdate(this); LinearMoveUpdate(this);
break; break;
case 1: case 1:
this->direction = (this->direction + 8) & 0x1f; this->direction = (this->direction + 8) & (0x3 | DirectionNorthWest);
break; break;
case 0: case 0:
if (this->field_0x78.HALF.LO) { if (this->field_0x78.HALF.LO) {
@ -507,9 +507,9 @@ void sub_08044E74(Entity* this, u32 state) {
} while (this->timer-- != 3); } while (this->timer-- != 3);
break; break;
case 1: case 1:
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(this); LinearMoveUpdate(this);
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
break; break;
} }
} else { } else {

View File

@ -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); iVar4 = sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1);
if (iVar4 != 0) { if (iVar4 != 0) {
this->direction = 0xff; this->direction = DIR_NONE;
} else { } else {
this->timer = (rand & 3) + 1; this->timer = (rand & 3) + 1;
this->direction = (uVar1 & 0x18); this->direction = (uVar1 & 0x18);
@ -251,7 +251,7 @@ void sub_0802F04C(Entity* this) {
return; return;
} }
switch (this->direction >> 3) { switch (this->direction >> 3) {
case 0: case 0: // UP
if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) { if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) {
this->timer--; this->timer--;
oldY = (this->y.HALF.HI & 0xfff0) + 8; oldY = (this->y.HALF.HI & 0xfff0) + 8;
@ -263,7 +263,7 @@ void sub_0802F04C(Entity* this) {
return; return;
} }
break; break;
case 1: case 1: // RIGHT
if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) { if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) {
this->timer--; this->timer--;
oldX = (this->x.HALF.HI & 0xfff0) + 8; oldX = (this->x.HALF.HI & 0xfff0) + 8;
@ -275,7 +275,7 @@ void sub_0802F04C(Entity* this) {
return; return;
} }
break; break;
case 2: case 2: // DOWN
if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) { if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) {
this->timer--; this->timer--;
oldY = (this->y.HALF.HI & 0xfff0) + 8; oldY = (this->y.HALF.HI & 0xfff0) + 8;
@ -287,7 +287,7 @@ void sub_0802F04C(Entity* this) {
return; return;
} }
break; break;
default: default: // LEFT
if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) { if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) {
this->timer--; this->timer--;
oldX = (this->x.HALF.HI & 0xfff0) + 8; oldX = (this->x.HALF.HI & 0xfff0) + 8;

View File

@ -187,7 +187,7 @@ void VaatiProjectileFunction0Action5(Entity* this) {
void VaatiProjectileFunction0Action6(Entity* this) { void VaatiProjectileFunction0Action6(Entity* this) {
if (--this->timer == 0) { if (--this->timer == 0) {
this->action = 7; this->action = 7;
this->direction = 0x10; this->direction = DirectionSouth;
this->speed = 0x300; this->speed = 0x300;
} }
sub_0803E444(this); sub_0803E444(this);

View File

@ -103,7 +103,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) {
this->timer = 0; this->timer = 0;
this->field_0x76.HALF.LO = 0; this->field_0x76.HALF.LO = 0;
this->spriteSettings.draw = 1; this->spriteSettings.draw = 1;
this->direction = 0xff; this->direction = DIR_NONE;
this->spritePriority.b0 = 4; this->spritePriority.b0 = 4;
this->z.WORD = 0; this->z.WORD = 0;
this->field_0x80.HALF.LO = 2; this->field_0x80.HALF.LO = 2;
@ -149,12 +149,12 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
this->action = 2; this->action = 2;
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->timer = 16; this->timer = 16;
this->direction = 0xff; this->direction = DIR_NONE;
} else { } else {
if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) { 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 { } else {
this->direction = 0xff; this->direction = DIR_NONE;
} }
} }
} else { } else {
@ -165,7 +165,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
this->field_0x74.HALF.HI = this->field_0x74.HALF.LO & 0x80; this->field_0x74.HALF.HI = this->field_0x74.HALF.LO & 0x80;
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->timer = 192; this->timer = 192;
this->direction = 0xff; this->direction = DIR_NONE;
this->spriteSettings.draw = 1; this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 0); InitAnimationForceUpdate(this, 0);
} }
@ -176,7 +176,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
case 0: case 0:
this->action = 4; this->action = 4;
this->timer = 160; this->timer = 160;
this->direction = 0xff; this->direction = DIR_NONE;
this->cutsceneBeh.HALF.LO = 0xff; this->cutsceneBeh.HALF.LO = 0xff;
InitAnimationForceUpdate(this, 1); InitAnimationForceUpdate(this, 1);
break; break;
@ -184,21 +184,21 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
this->action = 6; this->action = 6;
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->timer = 0; this->timer = 0;
this->direction = 0xff; this->direction = DIR_NONE;
break; break;
case 3: case 3:
this->action = 5; this->action = 5;
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->subtimer = 32; this->subtimer = 32;
this->direction = 0xff; this->direction = DIR_NONE;
break; break;
case 2: case 2:
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->timer = 32; this->timer = 32;
if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) { 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 { } else {
this->direction = 0xff; this->direction = DIR_NONE;
} }
break; break;
} }
@ -340,7 +340,7 @@ void VaatiRebornEnemyType0Action4(Entity* this) {
this->action = 1; this->action = 1;
this->cutsceneBeh.HALF.LO = 0xff; this->cutsceneBeh.HALF.LO = 0xff;
this->timer = 1; this->timer = 1;
this->direction = (this->direction + 0x10) & 0x1f; this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
InitAnimationForceUpdate(this, 0); InitAnimationForceUpdate(this, 0);
} else { } else {
if ((this->frame & 0x10) != 0) { if ((this->frame & 0x10) != 0) {
@ -369,7 +369,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) {
if (this->field_0x80.HALF.LO == 0) { if (this->field_0x80.HALF.LO == 0) {
this->action = 1; this->action = 1;
this->timer = 1; this->timer = 1;
this->direction = 0xff; this->direction = DIR_NONE;
InitAnimationForceUpdate(this, 0); InitAnimationForceUpdate(this, 0);
return; return;
} }
@ -394,7 +394,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) {
this->field_0x86.HALF.HI++; this->field_0x86.HALF.HI++;
this->subtimer = (Random() & 0x3f) + 64; this->subtimer = (Random() & 0x3f) + 64;
uVar3 = GetFacingDirection(this, &gPlayerEntity); uVar3 = GetFacingDirection(this, &gPlayerEntity);
this->direction = (uVar3 & 0x10) | 8; this->direction = (uVar3 & 0x10) | DirectionEast;
} else { } else {
this->field_0x74.HALF.LO++; this->field_0x74.HALF.LO++;
this->field_0x86.HALF.HI = 0; this->field_0x86.HALF.HI = 0;
@ -408,7 +408,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) {
this->action = 1; this->action = 1;
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->timer = 1; this->timer = 1;
this->direction = 0xff; this->direction = DIR_NONE;
} }
break; break;
} }
@ -557,7 +557,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) {
this->field_0x74.HALF.LO = 1; this->field_0x74.HALF.LO = 1;
this->field_0x74.HALF.HI = 0; this->field_0x74.HALF.HI = 0;
this->spriteOffsetY = -2; this->spriteOffsetY = -2;
this->direction = 0xff; this->direction = DIR_NONE;
PositionRelative(source, this, 0, Q_16_16(2.0)); PositionRelative(source, this, 0, Q_16_16(2.0));
InitAnimationForceUpdate(this, 2); InitAnimationForceUpdate(this, 2);
} }
@ -601,7 +601,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) {
void VaatiRebornEnemyType3Action0(Entity* this) { void VaatiRebornEnemyType3Action0(Entity* this) {
this->action = 1; this->action = 1;
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->direction = 0xff; this->direction = DIR_NONE;
this->spriteOffsetY = -1; this->spriteOffsetY = -1;
InitAnimationForceUpdate(this, this->field_0x74.HALF.LO); InitAnimationForceUpdate(this, this->field_0x74.HALF.LO);
sub_0803DC0C(this); sub_0803DC0C(this);
@ -621,7 +621,7 @@ void VaatiRebornEnemyType3Action1(Entity* this) {
} else { } else {
if (this->field_0x74.HALF.LO != 0) { if (this->field_0x74.HALF.LO != 0) {
this->field_0x74.HALF.LO = 0; this->field_0x74.HALF.LO = 0;
this->direction = 0xff; this->direction = DIR_NONE;
InitAnimationForceUpdate(this, 2); InitAnimationForceUpdate(this, 2);
} }
} }
@ -855,7 +855,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) {
this->field_0x7c = this->y; this->field_0x7c = this->y;
} }
if (this->field_0x76.HALF.LO == 0) { 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) { if (this->field_0x80.HALF.LO == 0) {
this->animationState = (this->animationState + 1) & 3; this->animationState = (this->animationState + 1) & 3;
this->spriteOffsetX = gUnk_080D04D3[this->animationState]; this->spriteOffsetX = gUnk_080D04D3[this->animationState];
@ -863,7 +863,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) {
return; return;
} }
bVar1 = sub_08049EE4(this); bVar1 = sub_08049EE4(this);
this->direction = (bVar1 & 0x10) | 8; this->direction = (bVar1 & 0x10) | DirectionEast;
this->field_0x76.HALF.LO = 0x10; this->field_0x76.HALF.LO = 0x10;
} else { } else {
this->field_0x76.HALF.LO--; this->field_0x76.HALF.LO--;

View File

@ -888,7 +888,7 @@ void sub_080406A0(Entity* this) {
this->direction = tmp + 0x1f; this->direction = tmp + 0x1f;
} }
} }
this->direction &= 0x1f; this->direction &= 0x3 | DirectionNorthWest;
this->field_0x86.HALF.LO = uVar5; this->field_0x86.HALF.LO = uVar5;
} }
@ -974,7 +974,7 @@ void sub_08040770(Entity* this) {
this->direction = tmp3 + 0x1F; this->direction = tmp3 + 0x1F;
} }
} }
this->direction &= 0x1F; this->direction &= 0x3 | DirectionNorthWest;
this->field_0x86.HALF.LO = tmp2; this->field_0x86.HALF.LO = tmp2;
} }

View File

@ -383,7 +383,7 @@ void VaatiWrathType0Action7(Entity* this) {
UpdateAnimationSingleFrame(this); UpdateAnimationSingleFrame(this);
if (gRoomControls.origin_y + 0x48 != this->y.HALF.HI) { if (gRoomControls.origin_y + 0x48 != this->y.HALF.HI) {
this->speed = 0x100; 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); LinearMoveUpdate(this);
} else { } else {
if (--this->timer == 0) { if (--this->timer == 0) {
@ -398,7 +398,7 @@ void VaatiWrathType0Action8(Entity* this) {
LinearMoveUpdate(this); LinearMoveUpdate(this);
if (((gRoomControls.origin_x + 0x20) > this->x.HALF.HI) || ((gRoomControls.origin_x + 0x140) < this->x.HALF.HI)) { if (((gRoomControls.origin_x + 0x20) > this->x.HALF.HI) || ((gRoomControls.origin_x + 0x140) < this->x.HALF.HI)) {
if (0x3f < this->speed) { if (0x3f < this->speed) {
this->direction ^= 0x10; this->direction ^= DirectionSouth;
} }
} }
if (--this->timer == 0) { if (--this->timer == 0) {
@ -451,7 +451,7 @@ void VaatiWrathType0ActionA(Entity* this) {
if (this->field_0x7a.HALF.HI == 0xf0) { if (this->field_0x7a.HALF.HI == 0xf0) {
this->action = 0xb; this->action = 0xb;
this->subAction = 0; this->subAction = 0;
this->direction = 0; this->direction = DirectionNorth;
this->speed = 0x100; this->speed = 0x100;
this->zVelocity = Q_16_16(1.125); this->zVelocity = Q_16_16(1.125);
ChangeObjPalette(this, 0x16b); ChangeObjPalette(this, 0x16b);
@ -521,7 +521,7 @@ void VaatiWrathType0ActionC(Entity* this) {
if (this->z.HALF.HI < -4) { if (this->z.HALF.HI < -4) {
this->subAction = 1; this->subAction = 1;
this->timer = 120; this->timer = 120;
this->direction = 0x10; this->direction = DirectionSouth;
this->speed = 0x80; this->speed = 0x80;
} }
break; break;

View File

@ -66,7 +66,7 @@ void sub_08076EC8(ItemBehavior* this, u32 index) {
if (gPlayerEntity.subAction == 0x1b) { if (gPlayerEntity.subAction == 0x1b) {
animIndex = 0x524; animIndex = 0x524;
} else { } else {
if (gPlayerState.direction & 0x80) { if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) {
animIndex = 0x504; animIndex = 0x504;
} else { } else {
animIndex = 0x518; animIndex = 0x518;

View File

@ -15,7 +15,7 @@ extern u16 gUnk_0800275C[];
extern u8 gUnk_0811BE38[]; extern u8 gUnk_0811BE38[];
void ItemPegasusBoots(ItemBehavior* this, u32 index) { 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_080768F8,
sub_08076964, sub_08076964,
sub_08076A88, sub_08076A88,
@ -136,7 +136,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) {
u8* ptr; u8* ptr;
if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) { if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) {
if ((gPlayerState.flags & PL_MINISH) == 0) { if (!(gPlayerState.flags & PL_MINISH)) {
gPlayerEntity.speed = 0x300; gPlayerEntity.speed = 0x300;
} else { } else {
gPlayerEntity.speed = 0x280; gPlayerEntity.speed = 0x280;
@ -148,7 +148,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) {
gPlayerEntity.subAction = 0; gPlayerEntity.subAction = 0;
COLLISION_OFF(&gPlayerEntity); COLLISION_OFF(&gPlayerEntity);
gPlayerState.field_0x38 = 0; gPlayerState.field_0x38 = 0;
gPlayerState.direction = 0xff; gPlayerState.direction = DIR_NONE;
return; return;
} }
this->subtimer = 1; this->subtimer = 1;
@ -157,12 +157,13 @@ void sub_08076A88(ItemBehavior* this, u32 index) {
ptr = gUnk_0811BE38; ptr = gUnk_0811BE38;
if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) { if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) {
this->direction = (this->playerAnimationState & 0xe) * 4; this->direction = (this->playerAnimationState & 0xe) * 4;
if ((gPlayerState.direction != 0xff) && (gPlayerState.direction != this->direction)) { if ((gPlayerState.direction != DIR_NONE) && (gPlayerState.direction != this->direction)) {
if (((gPlayerState.direction - this->direction) & 0x1f) < 0x10) { if (((gPlayerState.direction - this->direction) &
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest)) < DirectionSouth) {
this->direction = this->direction + 2; this->direction = this->direction + 2;
} }
this->direction--; this->direction--;
this->direction &= 0x1f; this->direction &= 0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest;
} }
gPlayerState.direction = this->direction; gPlayerState.direction = this->direction;
UpdateItemAnim(this); UpdateItemAnim(this);

View File

@ -220,7 +220,7 @@ void sub_08075738(ItemBehavior* this, u32 index) {
} }
if ((gPlayerState.sword_state & 0x10) != 0) { if ((gPlayerState.sword_state & 0x10) != 0) {
if ((gPlayerState.direction & 0x80) == 0) { if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) {
this->direction = gPlayerState.direction; this->direction = gPlayerState.direction;
} }
gPlayerEntity.direction = this->direction; gPlayerEntity.direction = this->direction;

View File

@ -2080,7 +2080,7 @@ bool32 MoveNorthWest(Entity* this, s32 radius, s32 angle, u32 collisionType) {
bool32 ProcessMovement0(Entity* this) { bool32 ProcessMovement0(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 0); CalculateEntityTileCollisions(this, this->direction, 0);
result = ProcessMovementInternal(this, this->speed, this->direction, 0); result = ProcessMovementInternal(this, this->speed, this->direction, 0);
} else { } else {
@ -2092,7 +2092,7 @@ bool32 ProcessMovement0(Entity* this) {
bool32 ProcessMovement1(Entity* this) { bool32 ProcessMovement1(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 1); CalculateEntityTileCollisions(this, this->direction, 1);
result = ProcessMovementInternal(this, this->speed, this->direction, 1); result = ProcessMovementInternal(this, this->speed, this->direction, 1);
} else { } else {
@ -2104,7 +2104,7 @@ bool32 ProcessMovement1(Entity* this) {
bool32 ProcessMovement2(Entity* this) { bool32 ProcessMovement2(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 2); CalculateEntityTileCollisions(this, this->direction, 2);
result = ProcessMovementInternal(this, this->speed, this->direction, 2); result = ProcessMovementInternal(this, this->speed, this->direction, 2);
} else { } else {
@ -2116,7 +2116,7 @@ bool32 ProcessMovement2(Entity* this) {
bool32 ProcessMovement10(Entity* this) { bool32 ProcessMovement10(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 10); CalculateEntityTileCollisions(this, this->direction, 10);
result = ProcessMovementInternal(this, this->speed, this->direction, 10); result = ProcessMovementInternal(this, this->speed, this->direction, 10);
} else { } else {
@ -2128,7 +2128,7 @@ bool32 ProcessMovement10(Entity* this) {
bool32 ProcessMovement12(Entity* this) { bool32 ProcessMovement12(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 12); CalculateEntityTileCollisions(this, this->direction, 12);
result = ProcessMovementInternal(this, this->speed, this->direction, 12); result = ProcessMovementInternal(this, this->speed, this->direction, 12);
} else { } else {
@ -2140,7 +2140,7 @@ bool32 ProcessMovement12(Entity* this) {
bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) { bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) {
bool32 result; bool32 result;
if ((direction & 0x80) == 0) { if (!(direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, direction, 0); CalculateEntityTileCollisions(this, direction, 0);
result = ProcessMovementInternal(this, speed, direction, 0); result = ProcessMovementInternal(this, speed, direction, 0);
} else { } else {
@ -2152,7 +2152,7 @@ bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) {
bool32 ProcessMovement3(Entity* this) { bool32 ProcessMovement3(Entity* this) {
bool32 result; 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); CalculateEntityTileCollisions(this, this->direction, 3);
result = ProcessMovementInternal(this, this->speed, this->direction, 3); result = ProcessMovementInternal(this, this->speed, this->direction, 3);
} else { } else {
@ -2165,25 +2165,37 @@ bool32 sub_080AF0C8(Entity* this) {
u32 tileType = GetTileTypeByEntity(this); u32 tileType = GetTileTypeByEntity(this);
switch (tileType) { switch (tileType) {
case 0x87: 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; this->collisions = COL_NORTH_ANY;
return TRUE; return TRUE;
} }
break; break;
case 0x8a: 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; this->collisions = COL_EAST_ANY;
return TRUE; return TRUE;
} }
break; break;
case 0x88: 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; this->collisions = COL_SOUTH_ANY;
return TRUE; return TRUE;
} }
break; break;
case 0x89: 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; this->collisions = COL_WEST_ANY;
return TRUE; return TRUE;
} }
@ -2195,7 +2207,7 @@ bool32 sub_080AF0C8(Entity* this) {
bool32 ProcessMovement4(Entity* this) { bool32 ProcessMovement4(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 4); CalculateEntityTileCollisions(this, this->direction, 4);
result = ProcessMovementInternal(this, this->speed, this->direction, 4); result = ProcessMovementInternal(this, this->speed, this->direction, 4);
} else { } else {
@ -2207,7 +2219,7 @@ bool32 ProcessMovement4(Entity* this) {
bool32 ProcessMovement5(Entity* this) { bool32 ProcessMovement5(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 5); CalculateEntityTileCollisions(this, this->direction, 5);
result = ProcessMovementInternal(this, this->speed, this->direction, 5); result = ProcessMovementInternal(this, this->speed, this->direction, 5);
} else { } else {
@ -2231,7 +2243,7 @@ void Knockback2(Entity* this) {
bool32 ProcessMovement6(Entity* this) { bool32 ProcessMovement6(Entity* this) {
bool32 result; bool32 result;
if ((this->direction & 0x80) == 0) { if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 6); CalculateEntityTileCollisions(this, this->direction, 6);
result = ProcessMovementInternal(this, this->speed, this->direction, 6); result = ProcessMovementInternal(this, this->speed, this->direction, 6);
} else { } else {
@ -2243,7 +2255,7 @@ bool32 ProcessMovement6(Entity* this) {
bool32 ProcessMovement6_custom(Entity* this, u32 direction, u32 speed) { bool32 ProcessMovement6_custom(Entity* this, u32 direction, u32 speed) {
bool32 result; bool32 result;
if ((direction & 0x80) == 0) { if (!(direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, direction, 6); CalculateEntityTileCollisions(this, direction, 6);
result = ProcessMovementInternal(this, speed, direction, 6); result = ProcessMovementInternal(this, speed, direction, 6);
} else { } else {

View File

@ -206,12 +206,12 @@ void sub_08066570(Entity* this) {
direction = GetFacingDirection(this, &gPlayerEntity); direction = GetFacingDirection(this, &gPlayerEntity);
cond = TRUE; cond = TRUE;
dir2 = (direction & 0x18); dir2 = (direction & DirectionWest);
dir1 = (this->direction & 0x18); dir1 = (this->direction & DirectionWest);
tmp = 0x18; tmp = DirectionWest;
if (dir1 == dir2) { if (dir1 == dir2) {
dir1 = (direction + 5) & 7; dir1 = (direction + 5) & (0x3 | DirectionNorthEast);
dir2 = (this->direction + 5) & 7; dir2 = (this->direction + 5) & (0x3 | DirectionNorthEast);
if (dir2 < 3 && dir1 < 3) { if (dir2 < 3 && dir1 < 3) {
cond = FALSE; cond = FALSE;
} }

View File

@ -222,7 +222,7 @@ void Book_Action5(BookEntity* this) {
u32 sub_0809B688(Entity* this) { u32 sub_0809B688(Entity* this) {
u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12); u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
if (ret == 1 && gPlayerState.direction != 16) { if (ret == 1 && gPlayerState.direction != DirectionSouth) {
ret = 0; ret = 0;
} }

View File

@ -53,7 +53,7 @@ void ChuchuBossCutscene_Action3(Entity* this) {
GetNextFrame(this); GetNextFrame(this);
if (--this->timer == 0) { if (--this->timer == 0) {
this->action++; this->action++;
this->direction = 0; this->direction = DirectionNorth;
this->speed = 0x100; this->speed = 0x100;
this->zVelocity = Q_16_16(2.0); this->zVelocity = Q_16_16(2.0);
this->spriteOrientation.flipY = 0; this->spriteOrientation.flipY = 0;

View File

@ -138,7 +138,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
if (super->parent->action == 2) { if (super->parent->action == 2) {
switch (super->parent->subAction) { switch (super->parent->subAction) {
case 1: case 1:
if ((gPlayerState.direction & 0x80) != 0) { if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) {
InitializeAnimation(super, 4); InitializeAnimation(super, 4);
} else { } else {
GetNextFrame(super); GetNextFrame(super);
@ -161,7 +161,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
} else { } else {
gPlayerState.mobility |= 0x80; gPlayerState.mobility |= 0x80;
gPlayerState.heldObject = 5; gPlayerState.heldObject = 5;
if ((gPlayerState.direction & 0x80) != 0) { if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) {
InitializeAnimation(super, (super->type >> 1) + 3); InitializeAnimation(super, (super->type >> 1) + 3);
} else { } else {
GetNextFrame(super); GetNextFrame(super);

View File

@ -90,10 +90,10 @@ void GraveyardKey_Init(Entity* this, const struct_gUnk_08123FB0* param_2) {
this->y.HALF.HI -= param_2->y; this->y.HALF.HI -= param_2->y;
this->z.WORD = 0; this->z.WORD = 0;
this->timer = param_2->timer; this->timer = param_2->timer;
if ((this->direction & 0x80)) { if ((this->direction & DIR_NOT_MOVING_CHECK)) {
dir = this->direction; dir = this->direction;
if (dir == 0x81) { if (dir == (DIR_NOT_MOVING_CHECK | 0x1)) {
this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ 0x10; this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ DirectionSouth;
} }
} }
UpdateSpriteForCollisionLayer(this); UpdateSpriteForCollisionLayer(this);

View File

@ -271,7 +271,7 @@ void sub_080836DC(Entity* this, u32 unk_0, u32 unk_1) {
SetTile(0x4022, unk_1, this->collisionLayer); SetTile(0x4022, unk_1, this->collisionLayer);
this->timer = 7; this->timer = 7;
this->spriteSettings.draw = 1; this->spriteSettings.draw = 1;
this->direction = (unk_0 << 3) ^ 0x10; this->direction = (unk_0 << 3) ^ DirectionSouth;
tmp = &gUnk_0811F688[unk_0]; tmp = &gUnk_0811F688[unk_0];
if (this->type2 != 2) { if (this->type2 != 2) {
this->x.HALF.HI += tmp->x; this->x.HALF.HI += tmp->x;

View File

@ -52,7 +52,7 @@ void sub_0808A484(Entity* this) {
this->action = 1; this->action = 1;
this->spriteSettings.draw = TRUE; this->spriteSettings.draw = TRUE;
this->speed = 0x40; this->speed = 0x40;
this->direction = 6; this->direction = DirectionNorthEast | 0x2;
this->spriteRendering.b3 = 1; this->spriteRendering.b3 = 1;
this->spritePriority.b0 = 0; this->spritePriority.b0 = 0;
this->spriteOrientation.flipY = 1; this->spriteOrientation.flipY = 1;

View File

@ -321,7 +321,7 @@ void UpdateRailMovement(Entity* this, u16** param_2, u16* param_3) {
ptr = ptr + (u32)ptr[1] * -3; ptr = ptr + (u32)ptr[1] * -3;
} }
if (*ptr == 0xff) { if (*ptr == 0xff) {
this->direction = 0xff; this->direction = DIR_NONE;
this->speed = 0; this->speed = 0;
} else { } else {
this->direction = (u8)*ptr; this->direction = (u8)*ptr;

View File

@ -245,17 +245,21 @@ bool32 sub_0806F8DC(Entity* ent) {
return TRUE; return TRUE;
} }
#define CDIR_DIAGONAL 1
#define CDirectionSouth 4
#define CDirectionWest 6
u32 sub_0806F948(Entity* ent) { u32 sub_0806F948(Entity* ent) {
u32 v1; u32 direction;
if (gPlayerState.direction == 0xFF) if (gPlayerState.direction == DIR_NONE)
return ent->animationState; return ent->animationState;
v1 = gPlayerState.direction / 4; direction = gPlayerState.direction / 4;
if ((v1 & 1) && !(((v1 + 1) - ent->animationState) & 4)) { if ((direction & CDIR_DIAGONAL) && !(((direction + 1) - ent->animationState) & CDirectionSouth)) {
return ent->animationState; return ent->animationState;
} else { } else {
ent->spriteSettings.flipX = v1 > 4; ent->spriteSettings.flipX = direction > CDirectionSouth;
ent->animationState = v1 & 6; ent->animationState = direction & CDirectionWest;
} }
return ent->animationState; return ent->animationState;
} }

View File

@ -503,7 +503,7 @@ static void PlayerNormal(Entity* this) {
this->speed = gPlayerState.jump_status & 0x20; this->speed = gPlayerState.jump_status & 0x20;
sub_08008926(this); sub_08008926(this);
} else { } else {
this->direction = 0xff; this->direction = DIR_NONE;
} }
} }
UpdatePlayerMovement(); UpdatePlayerMovement();
@ -535,14 +535,14 @@ static void PlayerNormal(Entity* this) {
this->direction = gPlayerState.direction; this->direction = gPlayerState.direction;
if (gPlayerState.flags & PL_BURNING) { if (gPlayerState.flags & PL_BURNING) {
this->speed = BURNING_SPEED; this->speed = BURNING_SPEED;
if ((gPlayerState.direction & 0x80) != 0) if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0)
this->direction = 4 * (this->animationState & 0xE); this->direction = 4 * (this->animationState & 0xE);
DeleteClones(); DeleteClones();
} }
} }
} }
v13 = 0; 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) { (gPlayerState.field_0x7 & 0x10) == 0) {
v13 = 1; v13 = 1;
if (this->knockbackDuration == 0 && if (this->knockbackDuration == 0 &&
@ -578,7 +578,7 @@ static void PlayerFall(Entity* this) {
PlayerFallUpdate, PlayerFallUpdate,
}; };
gPlayerState.direction = 0xFF; gPlayerState.direction = DIR_NONE;
gPlayerState.pushedObject = 0x80; gPlayerState.pushedObject = 0x80;
gPlayerState.framestate = PL_STATE_FALL; gPlayerState.framestate = PL_STATE_FALL;
@ -1068,7 +1068,7 @@ static void PortalStandUpdate(Entity* this) {
break; break;
} }
if ((gPlayerState.direction & 0x84) == 0) { if ((gPlayerState.direction & (DIR_NOT_MOVING_CHECK | DIR_DIAGONAL)) == 0) {
if (this->direction != gPlayerState.direction) { if (this->direction != gPlayerState.direction) {
this->timer = 8; this->timer = 8;
} }
@ -1557,7 +1557,7 @@ static void sub_08071D04(Entity* this) {
ModHealth(deltaHealth); ModHealth(deltaHealth);
this->subAction = 3; this->subAction = 3;
gPlayerState.field_0x3c = 0; gPlayerState.field_0x3c = 0;
this->direction = 0xff; this->direction = DIR_NONE;
this->speed = 0; this->speed = 0;
this->zVelocity = Q_16_16(1.5); this->zVelocity = Q_16_16(1.5);
gPlayerState.jump_status = 1; gPlayerState.jump_status = 1;
@ -1787,7 +1787,7 @@ static void sub_08072100(Entity* this) {
this->subAction = 1; this->subAction = 1;
COLLISION_OFF(this); COLLISION_OFF(this);
if (gPlayerState.field_0x39) if (gPlayerState.field_0x39)
this->direction = 0xff; this->direction = DIR_NONE;
if (gPlayerState.flags & PL_NO_CAP) { if (gPlayerState.flags & PL_NO_CAP) {
gPlayerState.animation = ANIM_DOOR_NOCAP; gPlayerState.animation = ANIM_DOOR_NOCAP;
@ -2218,7 +2218,7 @@ static void PlayerInHoleUpdate(Entity* this) {
} }
static void sub_08072ACC(Entity* this) { static void sub_08072ACC(Entity* this) {
if (gPlayerState.direction == 0xff) { if (gPlayerState.direction == DIR_NONE) {
this->subtimer = 0; this->subtimer = 0;
} else if (this->subtimer > 7) { } else if (this->subtimer > 7) {
COLLISION_ON(this); COLLISION_ON(this);
@ -2448,14 +2448,14 @@ static void PlayerClimb(Entity* this) {
this->action = PLAYER_CLIMB; this->action = PLAYER_CLIMB;
this->subAction = 0; this->subAction = 0;
this->y.HALF.LO = 0; this->y.HALF.LO = 0;
gPlayerState.animation = ANIM_CLIMB; gPlayerState.animation = ANIM_CLIMB1_UP;
} }
} }
} }
} }
static void sub_08072F94(Entity* this) { static void sub_08072F94(Entity* this) {
u32 bVar1; u32 direction;
switch (gPlayerState.floor_type) { switch (gPlayerState.floor_type) {
default: default:
@ -2466,10 +2466,10 @@ static void sub_08072F94(Entity* this) {
case SURFACE_CLIMB_WALL: case SURFACE_CLIMB_WALL:
case SURFACE_2C: case SURFACE_2C:
this->spritePriority.b1 = 0; this->spritePriority.b1 = 0;
bVar1 = gPlayerState.direction; direction = gPlayerState.direction;
if ((gPlayerState.direction & 0x80) == 0) { if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) {
this->direction = gPlayerState.direction; this->direction = gPlayerState.direction;
if ((gPlayerState.direction == 8) || (gPlayerState.direction == 0x18)) { if ((gPlayerState.direction == DirectionEast) || (gPlayerState.direction == DirectionWest)) {
if (gPlayerState.floor_type == SURFACE_LADDER) { if (gPlayerState.floor_type == SURFACE_LADDER) {
return; return;
} }
@ -2480,20 +2480,20 @@ static void sub_08072F94(Entity* this) {
} }
sub_08073094(this); sub_08073094(this);
} else { } else {
if ((gPlayerState.floor_type == SURFACE_LADDER) && ((bVar1 & 7) != 0)) { if ((gPlayerState.floor_type == SURFACE_LADDER) && ((direction & (DIR_DIAGONAL | 0x3)) != 0)) {
this->direction = (bVar1 + 8) & 0x10; this->direction = (direction + 8) & DirectionSouth;
} }
if (this->direction & 0x10) { if (this->direction & DirectionSouth) {
if (this->frame & 0x10) { if (this->frame & 0x10) {
gPlayerState.animation = ANIM_CLIMB3; gPlayerState.animation = ANIM_CLIMB1_DOWN;
} else { } else {
gPlayerState.animation = ANIM_CLIMB4; gPlayerState.animation = ANIM_CLIMB2_DOWN;
} }
} else { } else {
if (this->frame & 0x10) { if (this->frame & 0x10) {
gPlayerState.animation = ANIM_CLIMB; gPlayerState.animation = ANIM_CLIMB1_UP;
} else { } 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) { if (gPlayerState.field_0x39 == 7) {
this->direction = IdleNorth; this->direction = IdleNorth;
} else { } else {
this->direction = 28; this->direction = DirectionNorthWest;
} }
if ((this->x.HALF.HI & 0xF) != 0xF) { if ((this->x.HALF.HI & 0xF) != 0xF) {
if (gPlayerState.field_0x39 == 7) { if (gPlayerState.field_0x39 == 7) {
this->animationState = IdleEast; this->animationState = IdleEast;
this->direction = 4; this->direction = DIR_DIAGONAL;
} else { } else {
this->animationState = 6; this->animationState = IdleWest;
if (this->direction <= DirectionWest) { if (this->direction <= DirectionWest) {
LinearMoveUpdate(this); LinearMoveUpdate(this);
return; return;
} }
this->direction = (this->direction - 1) & 0x1F; this->direction = (this->direction - 1) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
} }
LinearMoveUpdate(this); LinearMoveUpdate(this);
return; return;
@ -2756,7 +2756,7 @@ static void sub_08073584(Entity* this) {
gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL; gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL;
if (sub_0807A2F8(0)) { if (sub_0807A2F8(0)) {
this->subAction++; this->subAction++;
this->direction = 4 * (this->animationState & 6); this->direction = 4 * (this->animationState & IdleWest);
COLLISION_OFF(this); COLLISION_OFF(this);
return; return;
} }
@ -2766,21 +2766,23 @@ static void sub_08073584(Entity* this) {
else else
this->speed = 0x80; 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) {
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; *(u32*)&this->field_0x80 -= 0x20;
else else
*(u32*)&this->field_0x80 += 0x20; *(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(); UpdatePlayerMovement();
state = 4 * this->animationState; state = 4 * this->animationState;
dir = this->direction; dir = this->direction;
if (this->animationState == 0) { if (this->animationState == 0) {
state = (state + 8) & 0x1F; state = (state + 8) & 0x1F;
dir = (dir + 8) & 0x1F; dir = (dir + 8) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
} }
if (state - 7 > dir) { if (state - 7 > dir) {
@ -2798,7 +2800,8 @@ static void sub_08073584(Entity* this) {
this->animationState = state; this->animationState = state;
idx = 0; idx = 0;
state = gPlayerState.direction >> 2; 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[] = { static const u16 sAnims1[] = {
0x0708, 0x0708,
0x071C, 0x071C,
@ -2806,7 +2809,7 @@ static void sub_08073584(Entity* this) {
0x0714, 0x0714,
}; };
if ((gPlayerState.direction & 0x80) == 0) { if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) {
if (this->animationState != state) { if (this->animationState != state) {
if (this->animationState == (state ^ 4)) { if (this->animationState == (state ^ 4)) {
idx = 2; idx = 2;
@ -2890,7 +2893,7 @@ static void sub_0807380C(Entity* this) {
}; };
if ((gRoomTransition.frameCount & 3) == 0) { if ((gRoomTransition.frameCount & 3) == 0) {
u32 tmp = (this->animationState + 2) & 6; u32 tmp = (this->animationState + 2) & IdleWest;
this->animationState = tmp; this->animationState = tmp;
this->direction = 4 * tmp; this->direction = 4 * tmp;
} }
@ -2916,7 +2919,7 @@ void sub_08073884(Entity* this) {
}; };
if ((gRoomTransition.frameCount & 1) == 0) { if ((gRoomTransition.frameCount & 1) == 0) {
u32 tmp = (this->animationState + 2) & 6; u32 tmp = (this->animationState + 2) & IdleWest;
this->animationState = tmp; this->animationState = tmp;
this->direction = 4 * tmp; this->direction = 4 * tmp;
} }
@ -2940,10 +2943,10 @@ static void DoJump(Entity* this) {
} }
static void sub_08073924(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.jump_status = 0x40;
gPlayerState.direction = 0xff; gPlayerState.direction = DIR_NONE;
this->direction = 0xff; this->direction = DIR_NONE;
PutAwayItems(); PutAwayItems();
sub_08073968(this); sub_08073968(this);
} }
@ -2996,7 +2999,7 @@ static void sub_080739EC(Entity* this) {
if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) { if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) {
this->zVelocity = Q_16_16(2.5); this->zVelocity = Q_16_16(2.5);
this->timer = 10; this->timer = 10;
this->direction = 0xff; this->direction = DIR_NONE;
gPlayerState.jump_status += 2; gPlayerState.jump_status += 2;
gPlayerState.animation = ANIM_DOWN_THRUST; gPlayerState.animation = ANIM_DOWN_THRUST;
ResetPlayerVelocity(); ResetPlayerVelocity();
@ -3171,7 +3174,7 @@ static void sub_08073D20(Entity* this) {
UpdatePlayerMovement(); UpdatePlayerMovement();
} else { } else {
this->direction = gPlayerState.direction; this->direction = gPlayerState.direction;
if ((gPlayerState.direction & 0x80) == 0) { if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) {
gPlayerState.framestate = PL_STATE_WALK; gPlayerState.framestate = PL_STATE_WALK;
UpdatePlayerMovement(); UpdatePlayerMovement();
} }
@ -3427,7 +3430,7 @@ void SurfaceAction_14(Entity* this) {
sub_08074808(this); sub_08074808(this);
spd = this->speed; spd = this->speed;
this->speed = 0x300; this->speed = 0x300;
this->direction = 16; this->direction = DirectionSouth;
gPlayerState.field_0xa |= 0x80; gPlayerState.field_0xa |= 0x80;
LinearMoveUpdate(this); LinearMoveUpdate(this);
this->speed = spd; this->speed = spd;

View File

@ -148,8 +148,9 @@ void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this) {
bool32 uVar6; bool32 uVar6;
sub_0801B804(this); sub_0801B804(this);
if ((this->unk_68 == 12) && (this->unk_80 == 0) && ((gPlayerState.direction & 0x80) == 0)) { if ((this->unk_68 == 12) && (this->unk_80 == 0) && !(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) {
if (((this->unk_82.HALF.HI - gPlayerState.direction) & 0x1f) > 0x10) { if (((this->unk_82.HALF.HI - gPlayerState.direction) &
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest)) > DirectionSouth) {
this->unk_82.HWORD += 0x40; this->unk_82.HWORD += 0x40;
this->unk_82.HALF.HI &= 0x1f; this->unk_82.HALF.HI &= 0x1f;
super->direction = this->unk_82.HALF.HI; super->direction = this->unk_82.HALF.HI;

View File

@ -1490,7 +1490,7 @@ bool32 CheckQueuedAction(void) {
// this doesnt seem to have any real function where its used // this doesnt seem to have any real function where its used
void CheckPlayerVelocity(void) { void CheckPlayerVelocity(void) {
u32 angle = gPlayerState.direction; u32 angle = gPlayerState.direction;
if ((angle & 0x80) != 0) { if ((angle & DIR_NOT_MOVING_CHECK) != 0) {
ResetPlayerVelocity(); ResetPlayerVelocity();
} else { } else {
gPlayerState.vel_x = gSineTable[angle * 8]; gPlayerState.vel_x = gSineTable[angle * 8];
@ -1753,7 +1753,7 @@ code_3:
void sub_08079520(Entity* this) { void sub_08079520(Entity* this) {
s32 tmp = gPlayerState.direction; s32 tmp = gPlayerState.direction;
if (tmp < 0x80) { if (tmp < DIR_NOT_MOVING_CHECK) {
this->direction = gPlayerState.direction; this->direction = gPlayerState.direction;
} else { } else {
this->direction = (this->animationState >> 1) << 3; this->direction = (this->animationState >> 1) << 3;
@ -1774,7 +1774,7 @@ bool32 sub_08079550(void) {
if (gDiggingCaveEntranceTransition.isDiggingCave == 0) { if (gDiggingCaveEntranceTransition.isDiggingCave == 0) {
if ((gPlayerState.dash_state == 0 || (gPlayerState.flags & PL_BURNING)) && if ((gPlayerState.dash_state == 0 || (gPlayerState.flags & PL_BURNING)) &&
(gPlayerState.swim_state != 0 || (gPlayerState.sword_state & 0x40) || (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; gPlayerEntity.subtimer = 0;
return FALSE; return FALSE;
} }
@ -2072,8 +2072,8 @@ bool32 sub_08079B24(void) {
} }
if ((gPlayerState.jump_status & 0x41) == 0) { if ((gPlayerState.jump_status & 0x41) == 0) {
gPlayerState.jump_status = 0x41; gPlayerState.jump_status = 0x41;
gPlayerEntity.direction = 0xff; gPlayerEntity.direction = DIR_NONE;
gPlayerState.direction = 0xff; gPlayerState.direction = DIR_NONE;
return TRUE; return TRUE;
} else { } else {
return TRUE; return TRUE;
@ -2660,7 +2660,7 @@ bool32 sub_0807AC54(Entity* this) {
this->action = 0x1d; this->action = 0x1d;
this->subAction = 0; this->subAction = 0;
this->y.HALF.LO = 0; this->y.HALF.LO = 0;
gPlayerState.animation = ANIM_CLIMB; gPlayerState.animation = ANIM_CLIMB1_UP;
return TRUE; return TRUE;
case SURFACE_AUTO_LADDER: case SURFACE_AUTO_LADDER:
this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8; this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8;
@ -2750,7 +2750,7 @@ void PlayerUpdateSwimming(Entity* this) {
ModHealth(-2); ModHealth(-2);
SoundReq(SFX_PLY_VO6); SoundReq(SFX_PLY_VO6);
} }
if ((this->direction & 0x80) != 0) { if (this->direction & DIR_NOT_MOVING_CHECK) {
if ((gRoomTransition.frameCount & 0xf) == 0) { if ((gRoomTransition.frameCount & 0xf) == 0) {
CreateRandomWaterTrace(this, 4); CreateRandomWaterTrace(this, 4);
} }
@ -2825,15 +2825,15 @@ u32 GetSwordBeam(void) {
} }
void sub_0807B068(Entity* entity) { void sub_0807B068(Entity* entity) {
if ((gPlayerState.dash_state | gPlayerState.attack_status) == 0) { if (!(gPlayerState.dash_state | gPlayerState.attack_status)) {
if (gPlayerState.swim_state != 0) { if (gPlayerState.swim_state) {
if ((gPlayerState.swim_state & 0x80) != 0) { if (gPlayerState.swim_state & 0x80) {
gPlayerState.animation = ANIM_C1C; gPlayerState.animation = ANIM_DIVE_MINISH;
} else { } else {
gPlayerState.animation = ANIM_SWIM_MINISH; gPlayerState.animation = ANIM_SWIM_MINISH;
} }
} else { } else {
if ((gPlayerState.direction & 0x80) != 0) { if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) {
if (gPlayerState.animation != ANIM_BOUNCE_MINISH) { if (gPlayerState.animation != ANIM_BOUNCE_MINISH) {
gPlayerState.animation = ANIM_BOUNCE_MINISH; gPlayerState.animation = ANIM_BOUNCE_MINISH;
} }

View File

@ -88,7 +88,7 @@ void sub_080A82D8(Entity* this) {
this->action = 4; this->action = 4;
COLLISION_OFF(this); COLLISION_OFF(this);
this->zVelocity = Q_16_16(1.0); this->zVelocity = Q_16_16(1.0);
this->direction ^= 0x10; this->direction ^= DirectionSouth;
this->speed = 0x80; this->speed = 0x80;
} }

View File

@ -24,7 +24,7 @@ void FireProjectile_Init(Entity* this) {
InitializeAnimation(this, this->direction >> 3); InitializeAnimation(this, this->direction >> 3);
} else { } else {
this->action = 2; this->action = 2;
InitializeAnimation(this, this->direction >> 3 | 4); InitializeAnimation(this, this->direction >> 3 | IdleSouth);
EnqueueSFX(SFX_15E); EnqueueSFX(SFX_15E);
} }
} }
@ -41,7 +41,7 @@ void FireProjectile_Action1(Entity* this) {
if (this->spriteSettings.draw == 1) { if (this->spriteSettings.draw == 1) {
CopyPosition(parent, this); CopyPosition(parent, this);
if (this->timer != 0) { if (this->timer != 0) {
direction = parent->direction & 0x18; direction = parent->direction & DirectionWest;
this->direction = direction; this->direction = direction;
this->timer = 0; this->timer = 0;
InitializeAnimation(this, direction >> 3); InitializeAnimation(this, direction >> 3);

View File

@ -264,7 +264,7 @@ void sub_080AC6F0(Entity* this) {
u32 uVar4; u32 uVar4;
u32 tmp; u32 tmp;
uVar4 = this->direction & 0x1f; uVar4 = this->direction & (0x3 | DirectionNorthWest);
uVar1 = this->direction >> 5; uVar1 = this->direction >> 5;
iVar3 = uVar1 * 3; iVar3 = uVar1 * 3;
tmp = gUnk_0812A9C0[this->animationState] - uVar1 * 3; tmp = gUnk_0812A9C0[this->animationState] - uVar1 * 3;

View File

@ -24,7 +24,7 @@ void IceProjectile_Init(Entity* this) {
InitializeAnimation(this, this->direction >> 3); InitializeAnimation(this, this->direction >> 3);
} else { } else {
this->action = 2; this->action = 2;
InitializeAnimation(this, this->direction >> 3 | 4); InitializeAnimation(this, this->direction >> 3 | IdleSouth);
EnqueueSFX(SFX_160); EnqueueSFX(SFX_160);
} }
} }
@ -43,7 +43,7 @@ void IceProjectile_Action1(Entity* this) {
if (this->spriteSettings.draw == 1) { if (this->spriteSettings.draw == 1) {
CopyPosition(parent, this); CopyPosition(parent, this);
if (this->timer != 0) { if (this->timer != 0) {
direction = parent->direction & 0x18; direction = parent->direction & DirectionWest;
this->direction = direction; this->direction = direction;
this->timer = 0; this->timer = 0;
InitializeAnimation(this, direction >> 3); InitializeAnimation(this, direction >> 3);

View File

@ -36,7 +36,7 @@ void V3TennisBallProjectile_OnCollision(Entity* this) {
this->speed += 0x80 * 2; this->speed += 0x80 * 2;
this->child = this->contactedEntity; this->child = this->contactedEntity;
if (sub_080ACB40(this)) { if (sub_080ACB40(this)) {
this->direction = 0; this->direction = DirectionNorth;
} else { } else {
this->direction = this->knockbackDirection; this->direction = this->knockbackDirection;
} }
@ -53,7 +53,7 @@ void V3TennisBallProjectile_OnCollision(Entity* this) {
void V3TennisBallProjectile_Init(Entity* this) { void V3TennisBallProjectile_Init(Entity* this) {
this->action = 1; this->action = 1;
this->direction = 0x10; this->direction = DirectionSouth;
this->z.HALF.HI = -4; this->z.HALF.HI = -4;
this->child = NULL; this->child = NULL;
InitializeAnimation(this, 7); InitializeAnimation(this, 7);

View File

@ -24,7 +24,7 @@ void WindProjectile_Init(Entity* this) {
InitializeAnimation(this, this->direction >> 3); InitializeAnimation(this, this->direction >> 3);
} else { } else {
this->action = 2; this->action = 2;
InitializeAnimation(this, this->direction >> 3 | 4); InitializeAnimation(this, this->direction >> 3 | IdleSouth);
EnqueueSFX(SFX_15F); EnqueueSFX(SFX_15F);
} }
} }
@ -40,7 +40,7 @@ void WindProjectile_Action1(Entity* this) {
} else { } else {
if (this->spriteSettings.draw == 1) { if (this->spriteSettings.draw == 1) {
CopyPosition(parent, this); CopyPosition(parent, this);
direction = (parent->direction + 4) & 0x18; direction = (parent->direction + 4) & DirectionWest;
if (this->timer != 0) { if (this->timer != 0) {
this->direction = direction; this->direction = direction;
this->animationState = direction >> 2; this->animationState = direction >> 2;