From c19e313df4758a6be19384b1b728283b55ffa92b Mon Sep 17 00:00:00 2001 From: Reinmmar Date: Sun, 24 Sep 2023 18:03:34 +0200 Subject: [PATCH] found more anims, also removing != 0 sometimes --- include/player.h | 6 ++ src/beanstalkSubtask.c | 4 +- src/player.c | 34 +++++------ src/playerUtils.c | 127 ++++++++++++++++++++--------------------- src/script.c | 5 +- 5 files changed, 91 insertions(+), 85 deletions(-) diff --git a/include/player.h b/include/player.h index eec1fc9e..6cfd1383 100644 --- a/include/player.h +++ b/include/player.h @@ -396,6 +396,12 @@ typedef enum { ANIM_PARACHUTE = 0x708, ANIM_MINECART_PAUSE = 0x70c, ANIM_MINECART = 0x710, + ANIM_PARACHUTE_TURN_RIGHT = 0x714, + ANIM_PARACHUTE_TURN_OPPOSITE = 0x718, + ANIM_PARACHUTE_TURN_LEFT = 0x71c, + ANIM_PARACHUTE_TURN2_RIGHT = 0x720, + ANIM_PARACHUTE_TURN2_OPPOSITE = 0x724, + ANIM_PARACHUTE_TURN2_LEFT = 0x728, ANIM_DROWN = 0x72c, ANIM_PARACHUTE_FALL = 0x730, ANIM_PUT_ON_EZLO = 0x734, diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index a183d3bd..58efa6f8 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -306,10 +306,10 @@ u32 UpdatePlayerCollision(void) { case 0x3a: case 0x5b: case 0x4051: - if ((gPlayerState.flags & PL_MINISH) != 0) { + if (gPlayerState.flags & PL_MINISH) { return 0; } - if (gPlayerEntity.animationState != 0) { + if (gPlayerEntity.animationState != IdleNorth) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_READ; diff --git a/src/player.c b/src/player.c index e7c5f0d1..c2ceae5a 100644 --- a/src/player.c +++ b/src/player.c @@ -2804,13 +2804,13 @@ static void sub_08073584(Entity* this) { if (!this->field_0x86.HALF.HI || ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0 && this->animationState != state)) { static const u16 sAnims1[] = { - 0x0708, - 0x071C, - 0x0718, - 0x0714, + ANIM_PARACHUTE, + ANIM_PARACHUTE_TURN_LEFT, + ANIM_PARACHUTE_TURN_OPPOSITE, + ANIM_PARACHUTE_TURN_RIGHT, }; - if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) { + if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { if (this->animationState != state) { if (this->animationState == (state ^ 4)) { idx = 2; @@ -2836,10 +2836,10 @@ static void sub_08073584(Entity* this) { this->field_0x86.HALF.LO = idx; } else { static const u16 sAnims2[] = { - 0x0708, - 0x0728, - 0x0724, - 0x0720, + ANIM_PARACHUTE, + ANIM_PARACHUTE_TURN2_LEFT, + ANIM_PARACHUTE_TURN2_OPPOSITE, + ANIM_PARACHUTE_TURN2_RIGHT, }; this->field_0x86.HALF.HI--; @@ -2887,10 +2887,10 @@ static void sub_080737BC(Entity* this) { static void sub_0807380C(Entity* this) { static const u16 sAnims[] = { - 0x0708, - 0x071C, - 0x0718, - 0x0714, + ANIM_PARACHUTE, + ANIM_PARACHUTE_TURN_LEFT, + ANIM_PARACHUTE_TURN_OPPOSITE, + ANIM_PARACHUTE_TURN_RIGHT, }; if ((gRoomTransition.frameCount & 3) == 0) { @@ -2913,10 +2913,10 @@ static void sub_0807380C(Entity* this) { void sub_08073884(Entity* this) { static const u16 sAnims[] = { - 0x0708, - 0x071C, - 0x0718, - 0x0714, + ANIM_PARACHUTE, + ANIM_PARACHUTE_TURN_LEFT, + ANIM_PARACHUTE_TURN_OPPOSITE, + ANIM_PARACHUTE_TURN_RIGHT, }; if ((gRoomTransition.frameCount & 1) == 0) { diff --git a/src/playerUtils.c b/src/playerUtils.c index e707618f..7678ab5a 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 & DIR_NOT_MOVING_CHECK) != 0) { + if (angle & DIR_NOT_MOVING_CHECK) { ResetPlayerVelocity(); } else { gPlayerState.vel_x = gSineTable[angle * 8]; @@ -1518,14 +1518,14 @@ bool32 sub_08078F74(Entity* this) { void sub_08078FB0(Entity* this) { u32 animIndex; - if ((gPlayerState.pushedObject & 0x80) == 0) { + if (!(gPlayerState.pushedObject & 0x80)) { gPlayerState.field_0x35 = 0xff; } sub_08079064(this); - if ((gPlayerState.flags & PL_NO_CAP) != 0) { + if (gPlayerState.flags & PL_NO_CAP) { animIndex = 0x58; } else { - if ((gPlayerState.flags & PL_MINISH) != 0) { + if (gPlayerState.flags & PL_MINISH) { animIndex = 0x18; } else { if (gPlayerState.animation >> 8 == 7) { @@ -1543,7 +1543,7 @@ void sub_08078FB0(Entity* this) { this->spriteSettings.flipX = 0; } - if ((gPlayerState.flags & PL_MOLDWORM_CAPTURED) != 0) { + if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) { animIndex = gPlayerState.animation + this->animationState; } else { animIndex = (this->animationState >> 1) + gPlayerState.animation; @@ -1564,7 +1564,7 @@ void sub_08079064(Entity* this) { u32 maxAnimPriority; u32 animIndex; - if ((gPlayerState.flags & (PL_IN_HOLE | PL_MINISH)) == 0) { + if (!(gPlayerState.flags & (PL_IN_HOLE | PL_MINISH))) { maxAnimPriority = 0; for (i = 0; i < 4; i++) { if (gActiveItems[i].animPriority > maxAnimPriority) { @@ -1601,7 +1601,7 @@ void sub_080790E4(Entity* this) { if ((gPlayerState.pushedObject & 0x80) != 0) { return; } - if (gPlayerState.pushedObject == 0) { + if (!gPlayerState.pushedObject) { if (sub_080793E4(1)) { if (this->subtimer <= 5) { this->subtimer++; @@ -1616,7 +1616,7 @@ void sub_080790E4(Entity* this) { } gPlayerState.field_0x35 = this->animationState; gPlayerState.framestate = PL_STATE_PUSH; - if ((gPlayerState.flags & PL_NO_CAP) != 0) { + if (gPlayerState.flags & PL_NO_CAP) { gPlayerState.animation = ANIM_PUSH_NOCAP; } else { gPlayerState.animation = ANIM_PUSH; @@ -1644,10 +1644,10 @@ void SetPlayerActionNormal(void) { } void ResetPlayerAnimationAndAction(void) { - if ((gPlayerState.flags & PL_HIDDEN) == 0) { + if (!(gPlayerState.flags & PL_HIDDEN)) { gPlayerEntity.spriteSettings.draw = 3; } - if ((gPlayerState.flags & PL_MINISH) == 0) { + if (!(gPlayerState.flags & PL_MINISH)) { gPlayerEntity.spritePriority.b1 = 1; PlayerSetNormalAndCollide(); } else { @@ -1666,7 +1666,7 @@ void PlayerSetNormalAndCollide(void) { } void PlayerMinishSetNormalAndCollide(void) { - if ((gPlayerState.flags & PL_HIDDEN) == 0) { + if (!(gPlayerState.flags & PL_HIDDEN)) { gPlayerEntity.flags |= ENT_COLLIDE; gPlayerEntity.spriteSettings.draw = 3; } @@ -1692,12 +1692,12 @@ ASM_FUNC("asm/non_matching/playerUtils/sub_080792D8.inc", void sub_080792D8()) bool32 sub_080793E4(u32 param_1) { u32 tmp; - if (gPlayerState.swim_state == 0) { + if (!gPlayerState.swim_state) { tmp = gUnk_0811C0F8[gPlayerEntity.animationState >> 1]; } else { tmp = gUnk_0811C0F8[gPlayerEntity.direction >> 2]; } - if (sub_08079778() && ((gPlayerState.playerInput.heldInput & tmp) != 0)) { + if (sub_08079778() && (gPlayerState.playerInput.heldInput & tmp)) { if (param_1 != 0) { if (!sub_080B1BA4(GetPlayerTilePos(), gPlayerEntity.collisionLayer, param_1)) { return FALSE; @@ -1719,8 +1719,8 @@ void RespawnPlayer(void) { player->zVelocity = 0; player->knockbackDuration = 0; ResetPlayerPosition(); - if ((gPlayerState.flags & PL_GYORG_FIGHT) == 0) { - if ((gPlayerState.flags & PL_FLAGS10000) != 0) { + if (!(gPlayerState.flags & PL_GYORG_FIGHT)) { + if (gPlayerState.flags & PL_FLAGS10000) { player->x.HALF.HI = gPlayerState.lilypad->x.HALF.HI; player->y.HALF.HI = gPlayerState.lilypad->y.HALF.HI; } else { @@ -1771,9 +1771,9 @@ bool32 sub_08079550(void) { u32 tilePos2; u32 tilePos1; - if (gDiggingCaveEntranceTransition.isDiggingCave == 0) { - if ((gPlayerState.dash_state == 0 || (gPlayerState.flags & PL_BURNING)) && - (gPlayerState.swim_state != 0 || (gPlayerState.sword_state & 0x40) || + if (!gDiggingCaveEntranceTransition.isDiggingCave) { + if ((!gPlayerState.dash_state || (gPlayerState.flags & PL_BURNING)) && + (gPlayerState.swim_state || (gPlayerState.sword_state & 0x40) || gPlayerEntity.direction != gPlayerState.direction || (gPlayerEntity.direction & DIR_NOT_MOVING_CHECK))) { gPlayerEntity.subtimer = 0; return FALSE; @@ -1821,7 +1821,7 @@ void sub_08079708(Entity* this) { this->action = 0xa; this->subAction = 0; sub_080085B0(this); - if ((gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS)) == 0) { + if (!(gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS))) { SetPlayerEventPriority(); } } @@ -1848,7 +1848,7 @@ void sub_08079744(Entity* this) { bool32 sub_08079778(void) { u32 tmp; - if (gPlayerState.swim_state == 0) { + if (!gPlayerState.swim_state) { tmp = gUnk_0811C108[gPlayerEntity.animationState >> 1]; } else { tmp = gUnk_0811C108[gPlayerEntity.direction >> 2]; @@ -1864,20 +1864,20 @@ u32 sub_080797C4(void) { void sub_080797EC(void) { u32 animation; - if ((gPlayerState.flags & PL_NO_CAP) != 0) { - if (gPlayerState.heldObject != 0) { + if (gPlayerState.flags & PL_NO_CAP) { + if (gPlayerState.heldObject) { animation = ANIM_CARRY_NOCAP; - } else if (gPlayerState.shield_status != 0) { + } else if (gPlayerState.shield_status) { animation = ANIM_SHIELD_WALK_NOCAP; - } else if (gPlayerState.bow_state == 0) { - if (gPlayerState.swim_state != 0) { + } else if (!gPlayerState.bow_state) { + if (gPlayerState.swim_state) { animation = ANIM_SWIM_MOVE; } else { animation = ANIM_SWORD_CHARGE_WALK; - if ((gPlayerState.sword_state & 0x48) != 0) { + if (gPlayerState.sword_state & 0x48) { gPlayerState.prevAnim = 0x6c; return; - } else if (gPlayerState.sword_state == 0) { + } else if (!gPlayerState.sword_state) { if (gPlayerState.framestate == PL_STATE_IDLE) { gPlayerState.framestate = PL_STATE_WALK; } @@ -1896,27 +1896,27 @@ void sub_080797EC(void) { animation = ANIM_BOW_WALK; } } else { - if (gPlayerState.field_0x1c != 0) { + if (gPlayerState.field_0x1c) { return; - } else if (gPlayerState.heldObject != 0) { + } else if (gPlayerState.heldObject) { animation = ANIM_CARRY; - } else if (gPlayerState.dash_state != 0) { + } else if (gPlayerState.dash_state) { animation = ANIM_DASH; - } else if ((gPlayerState.flags & PL_IN_MINECART) != 0) { + } else if (gPlayerState.flags & PL_IN_MINECART) { animation = ANIM_MINECART; - } else if (gPlayerState.shield_status != 0) { + } else if (gPlayerState.shield_status) { animation = ANIM_SHIELD_WALK; - } else if (gPlayerState.bow_state != 0) { + } else if (gPlayerState.bow_state) { animation = ANIM_BOW_WALK; } else { - if (gPlayerState.swim_state != 0) { + if (gPlayerState.swim_state) { animation = ANIM_SWIM_MOVE; } else { animation = ANIM_SWORD_CHARGE_WALK; - if ((gPlayerState.sword_state & 0x48) != 0) { + if (gPlayerState.sword_state & 0x48) { gPlayerState.prevAnim = 0x6c; return; - } else if (gPlayerState.sword_state != 0) { + } else if (gPlayerState.sword_state) { animation = ANIM_SWORD_CHARGE_WALK; if (sub_080793E4(0)) { if (sub_080B1B44(GetPlayerTilePos(), (u32)gPlayerEntity.collisionLayer) != 0xff) { @@ -1933,7 +1933,6 @@ void sub_080797EC(void) { } else { // Change to test animations I guess animation = ANIM_WALK; - // animation = 12; } } } @@ -1941,7 +1940,7 @@ void sub_080797EC(void) { } gPlayerState.animation = animation; - if (gPlayerState.shield_status == 0) { + if (!gPlayerState.shield_status) { UpdateAnimationSingleFrame(&gPlayerEntity); } } @@ -1950,30 +1949,30 @@ void ResolvePlayerAnimation(void) { u32 index; u32 maxAnimPriority; u32 anim; - if ((gPlayerState.flags & PL_NO_CAP) != 0) { - if (gPlayerState.heldObject != 0) { + if (gPlayerState.flags & PL_NO_CAP) { + if (gPlayerState.heldObject) { anim = ANIM_CARRY_STAND_NOCAP; } else { - if ((gPlayerState.field_0x1c | gPlayerState.moleMittsState) != 0) { + if (gPlayerState.field_0x1c | gPlayerState.moleMittsState) { return; } - if ((gPlayerState.flags & PL_CONVEYOR_PUSHED) != 0) { + if (gPlayerState.flags & PL_CONVEYOR_PUSHED) { anim = ANIM_JUMP; - } else if (gPlayerState.shield_status != 0) { + } else if (gPlayerState.shield_status) { anim = ANIM_SHIELD_NOCAP; - } else if (gPlayerState.bow_state != 0) { + } else if (gPlayerState.bow_state) { anim = ANIM_BOW_CHARGE; - } else if (gPlayerState.swim_state != 0) { + } else if (gPlayerState.swim_state) { anim = ANIM_SWIM_STILL; } else { - if ((gPlayerState.sword_state & 0x48) != 0) { + if (gPlayerState.sword_state & 0x48) { return; } - if (gPlayerState.sword_state == 0) { - if (gPlayerState.attack_status != 0) { + if (!gPlayerState.sword_state) { + if (gPlayerState.attack_status) { return; } - if ((gPlayerState.flags & PL_USE_PORTAL) != 0) { + if (gPlayerState.flags & PL_USE_PORTAL) { switch (gArea.portal_type) { case PT_5: anim = ANIM_DEFAULT_NOCAP; @@ -1994,41 +1993,41 @@ void ResolvePlayerAnimation(void) { } } } else { - if (gPlayerState.heldObject != 0) { + if (gPlayerState.heldObject) { anim = ANIM_CARRY_STAND; } else { - if ((gPlayerState.field_0x1c | gPlayerState.moleMittsState) != 0) { + if (gPlayerState.field_0x1c | gPlayerState.moleMittsState) { return; } - if ((gPlayerState.flags & PL_MOLDWORM_CAPTURED) != 0) { + if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) { anim = ANIM_MOLDWORM_CAPTURED; - } else if ((gPlayerState.flags & PL_CONVEYOR_PUSHED) != 0) { + } else if (gPlayerState.flags & PL_CONVEYOR_PUSHED) { anim = ANIM_JUMP; - } else if (gPlayerState.dash_state != 0) { + } else if (gPlayerState.dash_state) { anim = ANIM_DASH; - } else if ((gPlayerState.flags & PL_IN_MINECART) != 0) { + } else if (gPlayerState.flags & PL_IN_MINECART) { anim = ANIM_MINECART_PAUSE; - } else if (gPlayerState.shield_status != 0) { + } else if (gPlayerState.shield_status) { anim = ANIM_SHIELD; - } else if (gPlayerState.bow_state != 0) { + } else if (gPlayerState.bow_state) { anim = ANIM_BOW_CHARGE; - } else if (gPlayerState.swim_state != 0) { + } else if (gPlayerState.swim_state) { anim = ANIM_SWIM_STILL; } else { - if ((gPlayerState.sword_state & 0x48) != 0) { + if (gPlayerState.sword_state & 0x48) { return; } - if ((gPlayerState.flags & PL_USE_PORTAL) != 0) { + if (gPlayerState.flags & PL_USE_PORTAL) { anim = (gArea.portal_type == PT_JAR) ? ANIM_IN_POT : ANIM_PORTAL; } else { - if (gPlayerState.sword_state != 0) { + if (gPlayerState.sword_state) { anim = ANIM_SWORD_CHARGE; } else { - if (gPlayerState.attack_status != 0) { + if (gPlayerState.attack_status) { return; } if (gPlayerState.flags & PL_USE_LANTERN) { - if (gActiveItems[ACTIVE_ITEM_LANTERN].animPriority != 0) { + if (gActiveItems[ACTIVE_ITEM_LANTERN].animPriority) { return; } anim = ANIM_LANTERN_ON; @@ -2042,7 +2041,7 @@ void ResolvePlayerAnimation(void) { } gPlayerState.animation = anim; - if (gPlayerState.heldObject == 0) { + if (!gPlayerState.heldObject) { maxAnimPriority = 0; for (index = 0; index < 4; index++) { if (gActiveItems[index].animPriority > maxAnimPriority) { diff --git a/src/script.c b/src/script.c index 2306dd85..29579d77 100644 --- a/src/script.c +++ b/src/script.c @@ -1548,11 +1548,12 @@ void sub_0807F100(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F128(Entity* entity, ScriptExecutionContext* context) { - static const u8 sAnimations[] = { 6, 2, 6, 2, 4, 6, 4, 2 }; + static const u8 sAnimationStates[] = { IdleWest, IdleEast, IdleWest, IdleEast, + IdleSouth, IdleWest, IdleSouth, IdleEast }; static const u8 sValues[] = { 0xa, 0x14, 0x1e, 0x12, 0x1c, 0x26, 0xc, 0x18 }; u32 rand = Random(); - entity->animationState = sAnimations[rand & 7]; + entity->animationState = sAnimationStates[rand & 7]; context->unk_1A = sValues[(rand >> 8) % 8]; }