diff --git a/data/scripts.s b/data/scripts.s index d05247e1..d2065a5c 100644 --- a/data/scripts.s +++ b/data/scripts.s @@ -9,6 +9,7 @@ .include "player.inc" .include "sound.inc" .include "kinstone.inc" + .include "script.inc" .syntax unified .text diff --git a/data/scripts/hyruleTown/script_Anju.inc b/data/scripts/hyruleTown/script_Anju.inc index 2c67d555..adfccdb4 100644 --- a/data/scripts/hyruleTown/script_Anju.inc +++ b/data/scripts/hyruleTown/script_Anju.inc @@ -46,7 +46,7 @@ script_080101AC: WaitForFadeFinish CallWithArg SetPlayerPos, 0x03400378 Call SetPlayerActionNormal - Call sub_0807FB74 + Call DisablePlayerSwimState _0807E8E4_1 Call SetPlayerCollisionLayer1 Call CuccoMinigame_Cleanup diff --git a/data/scripts/hyruleTown/script_Beedle.inc b/data/scripts/hyruleTown/script_Beedle.inc index 4b58971b..49342981 100644 --- a/data/scripts/hyruleTown/script_Beedle.inc +++ b/data/scripts/hyruleTown/script_Beedle.inc @@ -38,11 +38,11 @@ script_08010564: Jump script_08010570 script_08010570: Call sub_080634EC - CallWithArg sub_0807F78C, 0x00000000 + CallWithArg ScriptCommand_SaleItemConfirmMessage, 0x00000000 WaitUntilTextboxCloses CheckTextboxResult JumpIfNot script_080105E0 - CallWithArg sub_0807F7C4, 0x00000000 + CallWithArg ScriptCommand_CheckShopItemPrice, 0x00000000 JumpIfNot script_080105C4 CheckBottleContaining ITEM_BOTTLE_EMPTY JumpIfNot script_080105CC @@ -50,7 +50,7 @@ script_08010570: JumpIf script_080105D4 MessageNoOverlap TEXT_PICOLYTE, 0x07 WaitUntilTextboxCloses - CallWithArg sub_0807F800, 0x00000000 + CallWithArg ScriptCommand_BuyShopItem, 0x00000000 WaitPlayerGetItem WaitUntilTextboxCloses MessageNoOverlap TEXT_PICOLYTE, 0x0c diff --git a/data/scripts/hyruleTown/script_Emma.inc b/data/scripts/hyruleTown/script_Emma.inc index e3e87ca5..345d8afd 100644 --- a/data/scripts/hyruleTown/script_Emma.inc +++ b/data/scripts/hyruleTown/script_Emma.inc @@ -12,9 +12,9 @@ script_0800E832: SetAnimationState 0x0004 BeginBlock MessageFromTarget TEXT_HAPPY_HEARTH, 0x01 - CallWithArg sub_0807F854, 0x00010032 - CallWithArg sub_0807F854, 0x000200c8 - CallWithArg sub_0807F854, 0x00030190 + CallWithArg ScriptCommand_SetMessageValue, (SMV_RUPEES << 16) | 50 + CallWithArg ScriptCommand_SetMessageValue, (SMV_FIELD_0X14 << 16) | 200 + CallWithArg ScriptCommand_SetMessageValue, (SMV_FIELD_0X18 << 16) | 400 EndBlock WaitUntilTextboxCloses _0807EB38 @@ -22,7 +22,7 @@ script_0800E832: script_0800E872: @ Rent large room BeginBlock MessageFromTarget TEXT_HAPPY_HEARTH, 0x05 - CallWithArg sub_0807F854, 0x00010190 + CallWithArg ScriptCommand_SetMessageValue, (SMV_RUPEES << 16) | 400 EndBlock WaitUntilTextboxCloses HasRupees 400 diff --git a/data/scripts/hyruleTown/script_GoronMerchant.inc b/data/scripts/hyruleTown/script_GoronMerchant.inc index 460e9226..e2aee53a 100644 --- a/data/scripts/hyruleTown/script_GoronMerchant.inc +++ b/data/scripts/hyruleTown/script_GoronMerchant.inc @@ -77,7 +77,7 @@ script_080108AA: MessageNoOverlap TEXT_STOCKWELL, 0x20 script_080108B2: WaitUntilTextboxCloses - Call sub_0807F83C + Call ScriptCommand_PlayerDropHeldObject script_080108BA: WaitUntilTextboxCloses Call EnablePauseMenu diff --git a/data/scripts/hyruleTown/script_MalonHyruleTown.inc b/data/scripts/hyruleTown/script_MalonHyruleTown.inc index 377db839..4128f658 100644 --- a/data/scripts/hyruleTown/script_MalonHyruleTown.inc +++ b/data/scripts/hyruleTown/script_MalonHyruleTown.inc @@ -16,7 +16,7 @@ script_08014F4A: DoPostScriptAction 0x0000 BeginBlock MessageNoOverlap TEXT_MILK, 0x0b - CallWithArg sub_0807F854, 0x00010064 + CallWithArg ScriptCommand_SetMessageValue, (SMV_RUPEES << 16) | 100 EndBlock WaitUntilTextboxCloses CheckTextboxResult diff --git a/data/scripts/hyruleTown/script_Pita.inc b/data/scripts/hyruleTown/script_Pita.inc index c026e4cf..360afd7a 100644 --- a/data/scripts/hyruleTown/script_Pita.inc +++ b/data/scripts/hyruleTown/script_Pita.inc @@ -19,7 +19,7 @@ script_080106BE: Jump script_08010726 script_080106E0: Call RemoveAllBakedGoods - CallWithArg sub_0807F78C, 0x00000000 + CallWithArg ScriptCommand_SaleItemConfirmMessage, 0x00000000 WaitUntilTextboxCloses CheckTextboxResult JumpIfNot script_08010726 diff --git a/data/scripts/hyruleTown/script_RemFallingAsleep.inc b/data/scripts/hyruleTown/script_RemFallingAsleep.inc index 36e0a0de..08b5211f 100644 --- a/data/scripts/hyruleTown/script_RemFallingAsleep.inc +++ b/data/scripts/hyruleTown/script_RemFallingAsleep.inc @@ -43,7 +43,7 @@ script_08013006: WaitPlayerGetItem Wait 0x001e _0807E8E4_0 - Call sub_0806AB9C + Call DeleteNpcRem SetAnimation 0x000b Wait 0x003c DoPostScriptAction 0x0004 diff --git a/data/scripts/hyruleTown/script_RentRegularRoom.inc b/data/scripts/hyruleTown/script_RentRegularRoom.inc index e1b15506..3ae62d24 100644 --- a/data/scripts/hyruleTown/script_RentRegularRoom.inc +++ b/data/scripts/hyruleTown/script_RentRegularRoom.inc @@ -2,7 +2,7 @@ SCRIPT_START script_RentRegularRoom BeginBlock MessageFromTarget TEXT_HAPPY_HEARTH, 0x04 - CallWithArg sub_0807F854, 0x000100c8 + CallWithArg ScriptCommand_SetMessageValue, (SMV_RUPEES << 16) | 200 EndBlock WaitUntilTextboxCloses HasRupees 200 diff --git a/data/scripts/hyruleTown/script_RentSmallRoom.inc b/data/scripts/hyruleTown/script_RentSmallRoom.inc index d214c5c8..2feb3f13 100644 --- a/data/scripts/hyruleTown/script_RentSmallRoom.inc +++ b/data/scripts/hyruleTown/script_RentSmallRoom.inc @@ -2,7 +2,7 @@ SCRIPT_START script_RentSmallRoom BeginBlock MessageFromTarget TEXT_HAPPY_HEARTH, 0x03 - CallWithArg sub_0807F854, 0x00010032 + CallWithArg ScriptCommand_SetMessageValue, (SMV_RUPEES << 16) | 50 EndBlock WaitUntilTextboxCloses HasRupees 50 diff --git a/data/scripts/lonLonRanch/script_TalonInside.inc b/data/scripts/lonLonRanch/script_TalonInside.inc index 75a00919..e5b898fc 100644 --- a/data/scripts/lonLonRanch/script_TalonInside.inc +++ b/data/scripts/lonLonRanch/script_TalonInside.inc @@ -12,15 +12,15 @@ script_08014E64: SetPlayerIdle Call DisablePauseMenuAndPutAwayItems FacePlayer - CallWithArg sub_0807F78C, 0x00000022 + CallWithArg ScriptCommand_SaleItemConfirmMessage, 0x00000022 WaitUntilTextboxCloses CheckTextboxResult JumpIfNot script_08014EBC - CallWithArg sub_0807F7C4, 0x00000022 + CallWithArg ScriptCommand_CheckShopItemPrice, 0x00000022 JumpIfNot script_08014EB0 CheckBottleContaining ITEM_BOTTLE_EMPTY JumpIfNot script_08014EB8 - CallWithArg sub_0807F800, 0x00000022 + CallWithArg ScriptCommand_BuyShopItem, 0x00000022 WaitPlayerGetItem MessageNoOverlap TEXT_EMPTY, 0x04 Jump script_08014EBC diff --git a/data/scripts/unused/script_08012B24.inc b/data/scripts/unused/script_08012B24.inc index 5691eba9..72138857 100644 --- a/data/scripts/unused/script_08012B24.inc +++ b/data/scripts/unused/script_08012B24.inc @@ -7,6 +7,6 @@ SCRIPT_START script_08012B24 DoPostScriptAction 0x0001 WalkSouth 0x0008 SetSyncFlag 0x00000002 - CallWithArg sub_0807FB64, 0xffffffe2 + CallWithArg SetPlayerIFrames, 0xffffffe2 Call SetPlayerActionNormal SCRIPT_END diff --git a/data/scripts/unused/script_08012B50.inc b/data/scripts/unused/script_08012B50.inc index 8fb1d22f..8d48f7f2 100644 --- a/data/scripts/unused/script_08012B50.inc +++ b/data/scripts/unused/script_08012B50.inc @@ -7,6 +7,6 @@ SCRIPT_START script_08012B50 DoPostScriptAction 0x0001 WalkNorth 0x0008 SetSyncFlag 0x00000002 - CallWithArg sub_0807FB64, 0xffffffe2 + CallWithArg SetPlayerIFrames, 0xffffffe2 Call SetPlayerActionNormal SCRIPT_END diff --git a/data/scripts/unused/script_08012B7C.inc b/data/scripts/unused/script_08012B7C.inc index 525c228e..228ba8b9 100644 --- a/data/scripts/unused/script_08012B7C.inc +++ b/data/scripts/unused/script_08012B7C.inc @@ -7,6 +7,6 @@ SCRIPT_START script_08012B7C DoPostScriptAction 0x0001 WalkEast 0x0008 SetSyncFlag 0x00000002 - CallWithArg sub_0807FB64, 0xffffffe2 + CallWithArg SetPlayerIFrames, 0xffffffe2 Call SetPlayerActionNormal SCRIPT_END diff --git a/include/player.h b/include/player.h index 044cb79a..3b117779 100644 --- a/include/player.h +++ b/include/player.h @@ -67,8 +67,9 @@ enum PlayerFrameState { PL_STATE_CLIMB, PL_STATE_PUSH, PL_STATE_PULL, - PL_STATE_1B, + PL_STATE_SINKING, PL_STATE_STAIRS, + PL_STATE_1D, }; enum PlayerSpawnType { @@ -275,7 +276,7 @@ typedef struct { /*0x0e*/ u8 field_0xe; /*0x0f*/ u8 hurtBlinkSpeed; /*0x10*/ u8 field_0x10; - /*0x11*/ u8 field_0x11; + /*0x11*/ u8 surfacePositionSameTimer; /*0x12*/ u8 floor_type; /*0x13*/ u8 floor_type_last; /*0x14*/ u8 field_0x14; @@ -297,7 +298,7 @@ typedef struct { /*0x34*/ u8 field_0x34; /*0x35*/ u8 field_0x35; /*0x36*/ u8 field_0x36; - /*0x37*/ u8 field_0x37; + /*0x37*/ u8 surfaceTimer; /*0x38*/ u8 field_0x38; /*0x39*/ u8 field_0x39; /*0x3a*/ u8 field_0x3a; @@ -356,10 +357,20 @@ typedef struct { /*0x1*/ u8 behaviorID; /*0x2*/ u8 field_0x2[2]; /*0x4*/ u8 stateID; - /*0x5*/ u8 field_0x5[10]; + /*0x5*/ u8 field_0x5; + /*0x6*/ u8 field_0x6; + /*0x7*/ u8 timer; + /*0x8*/ u8 subtimer; + /*0x9*/ u8 field_0x9; + /*0xa*/ u8 playerAnimationState; + /*0xb*/ u8 direction; + /*0xc*/ u8 playerAnimIndex; + /*0xd*/ u8 playerFrameDuration; + /*0xe*/ u8 playerFrame; /*0xf*/ u8 field_0xf; /*0x10*/ u16 field_0x10; - /*0x12*/ u8 field_0x12[6]; + /*0xf*/ u8 playerFrameIndex; + /*0x12*/ u8 field_0x12[5]; /*0x18*/ Entity* field_0x18; } ItemBehavior; diff --git a/include/room.h b/include/room.h index d1becf0b..710aab1f 100644 --- a/include/room.h +++ b/include/room.h @@ -183,7 +183,7 @@ typedef struct { u8 area; u8 room; u8 playerLayer; - u8 field_0xe; + u8 spawn_type; u8 playerState; u16 transitionSFX; } ScreenTransitionData; diff --git a/include/script.h b/include/script.h index 0c1c4ed5..78e29963 100644 --- a/include/script.h +++ b/include/script.h @@ -3,6 +3,14 @@ #include "entity.h" +enum SetMessageValueIndex { + SMV_DEFAULT, + SMV_RUPEES, + SMV_FIELD_0X14, + SMV_FIELD_0X18, + SMV_FIELD_0X1C, +}; + typedef struct ScriptExecutionContext { /*0x00*/ u16* scriptInstructionPointer; /*0x04*/ u32 intVariable; diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 543accd0..c0a82532 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -383,7 +383,7 @@ bool32 sub_0801AA58(Entity* this, u32 param_2, u32 param_3) { object->y.HALF.HI = (((param_2 & 0xfc0) >> 2) + 8) + gRoomControls.origin_y; object->collisionLayer = this->collisionLayer; gPlayerState.pushedObject = 0xa0; - gPlayerState.queued_action = 5; + gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= 1; this->x.HALF.LO = 0; this->y.HALF.LO = 0; diff --git a/src/collision.c b/src/collision.c index cb63f494..7b6f2cb4 100644 --- a/src/collision.c +++ b/src/collision.c @@ -403,7 +403,7 @@ s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_FROZEN | PL_IN_MINECART)) == 0 && - gPlayerState.queued_action == 0) { + gPlayerState.queued_action == PLAYER_INIT) { if (org->action == 1 || org->action == 24) { tgt->damage = 4; org->health = sub_08017874(org, tgt); diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 115a2e08..d86f012c 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -539,7 +539,7 @@ void sub_08026110(ChuchuBossEntity* this) { void sub_0802626C(ChuchuBossEntity* this) { gPauseMenuOptions.disabled = 1; gUnk_080CC20C[this->unk_84->unk_03](this); - if (gPlayerEntity.action != 23 && gPlayerEntity.action != 15) { + if (gPlayerEntity.action != PLAYER_ROOMTRANSITION && gPlayerEntity.action != PLAYER_ROOM_EXIT) { sub_08078B48(); } } @@ -565,7 +565,7 @@ void sub_080262A8(ChuchuBossEntity* this) { } void sub_08026328(ChuchuBossEntity* this) { - if (gPlayerEntity.action != 23) { + if (gPlayerEntity.action != PLAYER_ROOMTRANSITION) { this->unk_7d = 0x78; this->unk_84->unk_03++; sub_08078AC0(10, 0, 0); @@ -575,7 +575,7 @@ void sub_08026328(ChuchuBossEntity* this) { void sub_08026358(ChuchuBossEntity* this) { u32 bVar1; - if (gPlayerEntity.action != 15) { + if (gPlayerEntity.action != PLAYER_ROOM_EXIT) { bVar1 = --this->unk_7d; if (bVar1 == 0) { this->unk_7c = 0; diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 3a3968c3..8704cc41 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -98,7 +98,7 @@ void sub_08040B9C(Enemy50Entity* this) { if (super->confusedTime != 0) { super->animationState = super->knockbackDirection >> 4; InitializeAnimation(super, super->animationState + 7); - Create0x68FX(super, 0x1c); + Create0x68FX(super, FX_STARS); } if (super->health != this->unk_7a) { if (super->type == 0) { diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 848f0d38..c966d468 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -109,7 +109,7 @@ NONMATCH("asm/non_matching/stalfos/sub_0803933C.inc", void sub_0803933C(StalfosE super->flags2 &= 0xfb; } if (super->confusedTime != 0) { - Create0x68FX(super, 0x1c); + Create0x68FX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Stalfos_Functions); } diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 3f91afd9..22df2068 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -1002,8 +1002,9 @@ void VaatiWrathType0PreAction(Entity* this) { gSave.timers[3]--; } else { temp = gPlayerState.framestate_last; - if (temp < 2) { - if (temp >= 0) { + switch (temp) { + case PL_STATE_IDLE: + case PL_STATE_WALK: if (gPlayerState.item == NULL) { if (gPlayerEntity.field_0x7a.HWORD == 0) { if ((gPlayerEntity.z.HALF.HI & 0x8000U) == 0 || (gPlayerState.field_0xa != 0)) { @@ -1012,7 +1013,7 @@ void VaatiWrathType0PreAction(Entity* this) { } } } - } + break; } } } diff --git a/src/enterPortalSubtask.c b/src/enterPortalSubtask.c index 5987267e..ce6dc548 100644 --- a/src/enterPortalSubtask.c +++ b/src/enterPortalSubtask.c @@ -185,7 +185,7 @@ void sub_0804AD6C(RoomControls* controls) { gRoomTransition.player_status.start_pos_y = (area->portal_y + gUnk_080D4140[area->portal_exit_dir * 2 + 1]) - controls->origin_y; gRoomTransition.player_status.start_anim = area->portal_exit_dir << 1; - gRoomTransition.player_status.spawn_type = 1; + gRoomTransition.player_status.spawn_type = PL_SPAWN_MINISH; gRoomTransition.player_status.area_next = controls->area; gRoomTransition.player_status.room_next = controls->room; gRoomTransition.player_status.layer = 0; diff --git a/src/game.c b/src/game.c index 2fc8d04d..cdfebe13 100644 --- a/src/game.c +++ b/src/game.c @@ -1294,19 +1294,19 @@ bool32 CanDispEzloMessage(void) { if (!(gInput.heldKeys & SELECT_BUTTON) || gPlayerState.controlMode != CONTROL_ENABLED || gPauseMenuOptions.disabled || gUnk_0200AF00.unk_1) - return 0; + return FALSE; if ((gPlayerState.flags & (PL_NO_CAP | PL_CAPTURED | PL_DISABLE_ITEMS)) || (gPlayerState.framestate_last > tmp) || gPlayerState.item || gPlayerEntity.field_0x7a.HWORD) - return 0; + return FALSE; if ((gPlayerEntity.z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) - return 0; + return FALSE; GenerateAreaHint(); ForceSetPlayerState(PL_STATE_TALKEZLO); SetPlayerEventPriority(); - return 1; + return TRUE; } void DisplayEzloMessage(void) { diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c index ce290853..ce5358a4 100644 --- a/src/item/itemBomb.c +++ b/src/item/itemBomb.c @@ -64,7 +64,7 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) { sub_08077DF4(this, 0x338); } gPlayerState.heldObject = 3; - gPlayerState.framestate = 4; + gPlayerState.framestate = PL_STATE_HOLD; this->stateID = 2; this->field_0xf = 0xf; if ((gPlayerEntity.field_0x78.HALF.HI & 0x80)) { @@ -92,12 +92,12 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) { param_2->parent = (Entity*)this; this->field_0x18 = param_2; param_2->type2 = this->field_0x2[1]; - param_2->timer = this->field_0x5[2]; - param_2->subtimer = this->field_0x5[3]; + param_2->timer = this->timer; + param_2->subtimer = this->subtimer; if ((this->field_0x18->carryFlags & 0xf0) == 0x10) { - this->field_0x5[2] = 8; + this->timer = 8; } else { - this->field_0x5[2] = 0; + this->timer = 0; } SoundReq(SFX_PLY_LIFT); } diff --git a/src/item/itemBoomerang.c b/src/item/itemBoomerang.c index 55a8e22a..34475d09 100644 --- a/src/item/itemBoomerang.c +++ b/src/item/itemBoomerang.c @@ -14,7 +14,7 @@ void ItemBoomerang(ItemBehavior* this, u32 idx) { void sub_08075D2C(ItemBehavior* this, u32 idx) { if (((gPlayerState.field_0x3[1] & 8) == 0) && (sub_08077C94(this, this->behaviorID) == NULL)) { - this->field_0x5[4] |= 0xf; + this->field_0x9 |= 0xf; sub_0806F948(&gPlayerEntity); sub_08077C0C(this, 0xb); sub_08077D38(this, idx); @@ -26,12 +26,12 @@ void sub_08075D2C(ItemBehavior* this, u32 idx) { void sub_08075D88(ItemBehavior* this, u32 idx) { if ((gPlayerState.field_0x3[1] & 0x80) == 0) { - if (((this->behaviorID == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->field_0x5[9] & 2) != 0)) { + if (((this->behaviorID == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->playerFrame & 2) != 0)) { ResetPlayerVelocity(); return; } UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) == 0) { + if ((this->playerFrame & 0x80) == 0) { return; } } diff --git a/src/item/itemBow.c b/src/item/itemBow.c index d94e4c57..8e916091 100644 --- a/src/item/itemBow.c +++ b/src/item/itemBow.c @@ -18,7 +18,7 @@ void ItemBow(ItemBehavior* this, u32 idx) { void sub_08075DF4(ItemBehavior* this, u32 idx) { if ((gPlayerState.field_0x3[1] & 8) == 0) { - this->field_0x5[4] |= 0x80; + this->field_0x9 |= 0x80; sub_0806F948(&gPlayerEntity); sub_08077BB8(this); sub_08077D38(this, idx); @@ -35,9 +35,9 @@ void sub_08075E40(ItemBehavior* this, u32 idx) { bVar1 = gPlayerState.field_0x3[1] & 0x80; if (bVar1 == 0) { UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { this->stateID = 2; - this->field_0x5[4] &= 0x7f; + this->field_0x9 &= ~0x80; if (gSave.stats.arrowCount != 0) { this->field_0xf = bVar1; gPlayerState.field_0xa &= ~(8 >> idx); @@ -65,7 +65,7 @@ void sub_08075EC0(ItemBehavior* this, u32 idx) { gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa; sub_08077DF4(this, 0x27c); this->field_0xf = 0xf; - this->field_0x5[4] |= 0xf; + this->field_0x9 |= 0xf; this->stateID = 3; } } @@ -73,7 +73,7 @@ void sub_08075EC0(ItemBehavior* this, u32 idx) { void sub_08075F38(ItemBehavior* this, u32 idx) { if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) { UpdateItemAnim(this); - if ((this->field_0x5[9] & 1) != 0) { + if ((this->playerFrame & 1) != 0) { this->stateID = 4; } } else { @@ -89,7 +89,7 @@ void sub_08075F84(ItemBehavior* this, u32 idx) { } else { UpdateItemAnim(this); } - if ((this->field_0x5[9] & 0x80) == 0) { + if ((this->playerFrame & 0x80) == 0) { return; } } diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index 7b1d681e..c26314e1 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -2,6 +2,7 @@ #include "entity.h" #include "item.h" #include "functions.h" +#include "playeritem.h" void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32); @@ -14,10 +15,10 @@ void sub_08076DF4(ItemBehavior* this, u32 idx) { if (sub_0807A894(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.jump_status == 0) { sub_08077D38(this, idx); - this->field_0x5[2] = 0; - this->field_0x5[5] = gPlayerEntity.animationState; - this->field_0x5[4] |= 0x80; - this->field_0x5[4]++; + this->timer = 0; + this->playerAnimationState = gPlayerEntity.animationState; + this->field_0x9 |= 0x80; + this->field_0x9++; gPlayerState.gustJarSpeed = 1; *(u32*)&gPlayerEntity.field_0x74 = 0; gPlayerState.field_0x1c = 1; @@ -33,11 +34,11 @@ void sub_08076E60(ItemBehavior* this, u32 idx) { if ((gPlayerState.field_0x1c & 0xf) == 0) { DeletePlayerItem(this, idx); } - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { this->stateID = 2; sub_08077DF4(this, 0x504); gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx); - playerItem = CreatePlayerItem(0x10, 0, 0, 0); + playerItem = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0); if (playerItem != NULL) { playerItem->parent = &gPlayerEntity; } @@ -54,9 +55,9 @@ void sub_08076EC8(ItemBehavior* this, u32 idx) { if (sub_08077EFC(this)) { u32 val; - if (this->field_0x5[2] > 0xef) { + if (this->timer > 0xef) { gPlayerState.gustJarSpeed = 3; - } else if (++this->field_0x5[2] > 0x77) { + } else if (++this->timer > 0x77) { gPlayerState.gustJarSpeed = 2; } else { gPlayerState.gustJarSpeed = 1; @@ -89,10 +90,10 @@ void sub_08076F64(ItemBehavior* this, u32 idx) { Entity* player; switch (gPlayerState.field_0x1c & 0xf) { case 5: - if (this->field_0x5[9] & 0x80) { - if (this->field_0x5[3]) { - this->field_0x5[3] = 0; - this->field_0x5[2] = 0; + if (this->playerFrame & 0x80) { + if (this->subtimer) { + this->subtimer = 0; + this->timer = 0; gPlayerState.gustJarSpeed = 1; player = &gPlayerEntity; *(u32*)&player->field_0x74 = 0; @@ -100,7 +101,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) { gPlayerState.field_0xa &= ~(8 >> idx); this->stateID = 2; sub_08077DF4(this, 0x504); - item = CreatePlayerItem(0x10, 0, 0, 0); + item = CreatePlayerItem(PLAYER_ITEM_10, 0, 0, 0); if (item) { item->parent = player; } @@ -112,7 +113,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) { } } else { if (sub_08077EFC(this)) { - this->field_0x5[3] = 1; + this->subtimer = 1; } UpdateItemAnim(this); @@ -130,15 +131,15 @@ void sub_08076F64(ItemBehavior* this, u32 idx) { gPlayerState.field_0x1c = 4; case 4: if (sub_08077EFC(this)) { - this->field_0x5[3] = 1; + this->subtimer = 1; } UpdateItemAnim(this); - if (this->field_0x5[9] & 1) { + if (this->playerFrame & 1) { gPlayerState.field_0x1c = 5; gPlayerEntity.field_0x70.WORD = 0; if (gPlayerState.gustJarSpeed) { - CreatePlayerItem(0x11, 0, 0, 0); + CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0); } } @@ -150,7 +151,7 @@ void sub_08076F64(ItemBehavior* this, u32 idx) { return; case 6: UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) == 0) + if ((this->playerFrame & 0x80) == 0) return; break; case 7: diff --git a/src/item/itemJarEmpty.c b/src/item/itemJarEmpty.c index 9912a294..ff2e1c61 100644 --- a/src/item/itemJarEmpty.c +++ b/src/item/itemJarEmpty.c @@ -22,10 +22,10 @@ void sub_08077534(ItemBehavior* this, u32 idx) { sub_08077D38(this, idx); sub_0806F948(&gPlayerEntity); sub_08077BB8(this); - this->field_0x5[4] |= 0xf; + this->field_0x9 |= 0xf; tmp = this->behaviorID; - this->field_0x5[2] = gSave.filler86[tmp + 0x14]; - switch (this->field_0x5[2]) { + this->timer = gSave.filler86[tmp + 0x14]; + switch (this->timer) { case 0x20: sub_08077DF4(this, 0x614); return; @@ -57,7 +57,7 @@ void sub_08077534(ItemBehavior* this, u32 idx) { } void sub_08077618(ItemBehavior* this, u32 idx) { - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { sub_08077DF4(this, 0x618); this->stateID += 1; } else { @@ -67,7 +67,7 @@ void sub_08077618(ItemBehavior* this, u32 idx) { void sub_08077640(ItemBehavior* this, u32 idx) { UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; DeletePlayerItem(this, idx); } @@ -75,7 +75,7 @@ void sub_08077640(ItemBehavior* this, u32 idx) { void sub_0807766C(ItemBehavior* this, u32 idx) { UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; DeletePlayerItem(this, idx); } diff --git a/src/item/itemLantern.c b/src/item/itemLantern.c index bf702e6a..758b6244 100644 --- a/src/item/itemLantern.c +++ b/src/item/itemLantern.c @@ -34,7 +34,7 @@ void sub_08075A0C(ItemBehavior* this, u32 idx) { ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); DeletePlayerItem(this, idx); } else { - this->field_0x5[4] |= 0x80; + this->field_0x9 |= 0x80; sub_08077D38(this, idx); sub_08077BD4(this); sub_0806F948(&gPlayerEntity); @@ -57,7 +57,7 @@ void sub_08075ADC(ItemBehavior* this, u32 idx) { #ifndef EU gPlayerState.item != NULL || #endif - (this->field_0x5[9] & 1) == 0 || (gPlayerState.flags & (PL_DISABLE_ITEMS | PL_CAPTURED)) != 0 || + (this->playerFrame & 1) == 0 || (gPlayerState.flags & (PL_DISABLE_ITEMS | PL_CAPTURED)) != 0 || sub_08079D48() == 0) { this->field_0xf = 0; this->stateID++; @@ -117,11 +117,11 @@ void sub_08075C9C(ItemBehavior* this, u32 idx) { s8* tmp; UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x10) != 0) { + if ((this->playerFrame & 0x10) != 0) { tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6]; sub_0807AB44(&gPlayerEntity, tmp[0], tmp[1]); } - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { this->field_0xf = 0; this->stateID--; gPlayerState.field_0xa = (~(8 >> idx)) & gPlayerState.field_0xa; diff --git a/src/item/itemMoleMitts.c b/src/item/itemMoleMitts.c index 0b8c9dcd..d3a938a6 100644 --- a/src/item/itemMoleMitts.c +++ b/src/item/itemMoleMitts.c @@ -30,10 +30,10 @@ void sub_08077130(ItemBehavior* this, u32 idx) { if (gPlayerState.jump_status == 0) { sub_08077D38(this, idx); gPlayerState.moleMittsState = 1; - this->field_0x5[4] |= 0x80; + this->field_0x9 |= 0x80; iVar1 = sub_080774A0(); if (iVar1 != 0) { - if (this->field_0x5[2] == 0) { + if (this->timer == 0) { sub_08077DF4(this, 0x50c); this->stateID = 2; if (iVar1 == 0x56) { @@ -62,31 +62,31 @@ void sub_080771C8(ItemBehavior* this, u32 idx) { Entity* object; UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { DeletePlayerItem(this, idx); gPlayerState.moleMittsState = 0; } else { - if (((this->field_0x5[9] & 0x20) != 0) && (this->field_0x5[3] == 0xff)) { - CreateObjectWithParent(&gPlayerEntity, 0x1e, this->field_0x5[9], 1); + if (((this->playerFrame & 0x20) != 0) && (this->subtimer == 0xff)) { + CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 1); } - if ((this->field_0x5[9] & 0x10) != 0) { + if ((this->playerFrame & 0x10) != 0) { if (sub_0800875A(&gPlayerEntity, 0xd, this) == 0) { sub_08077DF4(this, 0x520); this->stateID = 3; SoundReq(SFX_107); } else { - if (this->field_0x5[3] != 0xff) { - object = CreateObjectWithParent(&gPlayerEntity, 0x1f, 0, this->field_0x2[1]); + if (this->subtimer != 0xff) { + object = CreateObjectWithParent(&gPlayerEntity, OBJECT_1F, 0, this->field_0x2[1]); if (object != NULL) { - object->timer = this->field_0x5[2]; - object->subtimer = this->field_0x5[3]; + object->timer = this->timer; + object->subtimer = this->subtimer; object->animationState = gPlayerEntity.animationState & 6; gPlayerEntity.frame = 0; - gPlayerEntity.frameDuration = gUnk_0811BE14[this->field_0x5[3]]; + gPlayerEntity.frameDuration = gUnk_0811BE14[this->subtimer]; } } else { - if ((this->field_0x2[1] == 0x0f) && (this->field_0x5[2] == 0x17)) { - this->field_0x5[3] = 0; + if ((this->field_0x2[1] == 0x0f) && (this->timer == 0x17)) { + this->subtimer = 0; } } SoundReq(SFX_108); @@ -104,56 +104,56 @@ void sub_080772A8(ItemBehavior* this, u32 idx) { }; Entity* effect; - if (((this->field_0x5[9] & 8) != 0) && sub_08077F10(this)) { - this->field_0x5[2] = 1; + if (((this->playerFrame & 8) != 0) && sub_08077F10(this)) { + this->timer = 1; } if (GetInventoryValue(ITEM_DIG_BUTTERFLY) == 1) { - if ((this->field_0x5[9] & 7) != 3) { + if ((this->playerFrame & 7) != 3) { sub_08077E3C(this, 2); - gPlayerEntity.speed = gUnk_0811BE16[this->field_0x5[9] & 7] << 1; + gPlayerEntity.speed = gUnk_0811BE16[this->playerFrame & 7] << 1; } else { UpdateItemAnim(this); - gPlayerEntity.speed = gUnk_0811BE16[this->field_0x5[9] & 7]; + gPlayerEntity.speed = gUnk_0811BE16[this->playerFrame & 7]; } } else { UpdateItemAnim(this); - gPlayerEntity.speed = gUnk_0811BE16[this->field_0x5[9] & 7]; + gPlayerEntity.speed = gUnk_0811BE16[this->playerFrame & 7]; } gPlayerEntity.direction = gPlayerEntity.animationState << 2; if (gPlayerEntity.speed != 0) { UpdatePlayerMovement(); } - if ((this->field_0x5[9] & 0x10) != 0) { - if (this->field_0x5[2] != 0) { + if ((this->playerFrame & 0x10) != 0) { + if (this->timer != 0) { gPlayerEntity.frameDuration = 1; if (sub_080774A0()) { - this->field_0x5[2] = 0; + this->timer = 0; return; } } DeletePlayerItem(this, idx); gPlayerState.moleMittsState = 0; } else { - if ((this->field_0x5[9] & 0x60) != 0) { + if ((this->playerFrame & 0x60) != 0) { gPlayerEntity.frameDuration = 1; if (sub_0807B5B0(&gPlayerEntity)) { SoundReq(SFX_108); - CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->field_0x5[9], 0); + CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 0); } else { sub_08077DF4(this, 0x51c); effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0); if (effect != NULL) { - effect->animationState = this->field_0x5[5]; + effect->animationState = this->playerAnimationState; effect->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; } effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0); if (effect != NULL) { - effect->animationState = this->field_0x5[5]; + effect->animationState = this->playerAnimationState; effect->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; effect->subtimer = 1; } this->stateID = 3; - this->field_0x5[0] = 1; + this->field_0x5 = 1; SoundReq(SFX_ITEM_GLOVES_KNOCKBACK); } } @@ -163,11 +163,11 @@ void sub_080772A8(ItemBehavior* this, u32 idx) { void sub_08077448(ItemBehavior* this, u32 idx) { gPlayerEntity.direction = gPlayerEntity.animationState << 2 ^ 0x10; gPlayerEntity.speed = 0x100; - if (((this->field_0x5[9] & 1) != 0) && (this->field_0x5[0] != 0)) { + if (((this->playerFrame & 1) != 0) && (this->field_0x5 != 0)) { UpdatePlayerMovement(); } UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { gPlayerState.moleMittsState = 0; DeletePlayerItem(this, idx); } diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c index 38d323d6..a3310c7b 100644 --- a/src/item/itemOcarina.c +++ b/src/item/itemOcarina.c @@ -20,7 +20,7 @@ void OcarinaUse(ItemBehavior* this, u32 idx) { if (gPlayerState.queued_action == PLAYER_ROLL) { DeletePlayerItem(this, idx); } else { - this->field_0x5[4] |= 0xf; + this->field_0x9 |= 0xf; gPlayerEntity.animationState = 0x04; gPlayerEntity.spriteSettings.flipX = 0; gPlayerEntity.flags &= ~ENT_COLLIDE; @@ -40,7 +40,7 @@ void OcarinaUse(ItemBehavior* this, u32 idx) { void OcarinaUpdate(ItemBehavior* this, u32 idx) { // TODO regalloc UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; gPlayerState.flags &= ~PL_USE_OCARINA; gPlayerState.field_0x27[0] = 0; diff --git a/src/item/itemPacciCane.c b/src/item/itemPacciCane.c index 01615582..42c3f53b 100644 --- a/src/item/itemPacciCane.c +++ b/src/item/itemPacciCane.c @@ -16,17 +16,17 @@ void ItemPacciCane(ItemBehavior* beh, u32 idx) { } void sub_08076C98(ItemBehavior* beh, u32 idx) { - beh->field_0x5[4] |= 0xf; + beh->field_0x9 |= 0xf; sub_08077D38(beh, idx); sub_0806F948(&gPlayerEntity); sub_08077BB8(beh); } void sub_08076CBC(ItemBehavior* beh, u32 idx) { - if ((beh->field_0x5[9] & 0x80) != 0) { + if ((beh->playerFrame & 0x80) != 0) { DeletePlayerItem(beh, idx); } else { - if ((beh->field_0x5[9] & 0x40) != 0) { + if ((beh->playerFrame & 0x40) != 0) { CreatePlayerItemWithParent(beh, PLAYER_ITEM_12); } UpdateItemAnim(beh); diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index a0424387..81cdf137 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -29,12 +29,11 @@ void ItemPegasusBoots(ItemBehavior* this, u32 idx) { gPlayerState.field_0xe = 0; DeletePlayerItem(this, idx); } else { - bVar1 = this->field_0x5[2] - 1; - this->field_0x5[2] = bVar1; - if ((bVar1 & 7) == 0) { + --this->timer; + if ((this->timer & 7) == 0) { SoundReq(SFX_PLY_LAND); } - if (((gPlayerState.flags & PL_MINISH) == 0) && ((this->field_0x5[2] & 7) == 0)) { + if (((gPlayerState.flags & PL_MINISH) == 0) && ((this->timer & 7) == 0)) { if (gPlayerState.floor_type == SURFACE_SWAMP) { if (gPlayerEntity.spriteOffsetY == 0) { CreateFx(&gPlayerEntity, FX_GREEN_SPLASH, 0); @@ -70,7 +69,7 @@ void sub_080768F8(ItemBehavior* this, u32 idx) { gPlayerState.dash_state = 1; gPlayerState.field_0x1f[2] = bVar1; if ((gPlayerState.flags & PL_MINISH) == 0) { - this->field_0x5[2] = 0x10; + this->timer = 0x10; } else { gPlayerState.animation = 0xc14; } @@ -144,7 +143,7 @@ void sub_08076A88(ItemBehavior* this, u32 idx) { } uVar2 = gUnk_0800275C[(gPlayerEntity.animationState & 0xe) * 4]; if (uVar2 == (gPlayerEntity.collisions & uVar2)) { - if (this->field_0x5[3] != 0) { + if (this->subtimer != 0) { gPlayerEntity.action = PLAYER_BOUNCE; gPlayerEntity.subAction = 0; COLLISION_OFF(&gPlayerEntity); @@ -152,20 +151,20 @@ void sub_08076A88(ItemBehavior* this, u32 idx) { gPlayerState.field_0xd = 0xff; return; } - this->field_0x5[3] = 1; + this->subtimer = 1; return; } ptr = gUnk_0811BE38; if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.field_0x90) == 0) { - this->field_0x5[6] = (this->field_0x5[5] & 0xe) * 4; - if ((gPlayerState.field_0xd != 0xff) && (gPlayerState.field_0xd != this->field_0x5[6])) { - if (((gPlayerState.field_0xd - this->field_0x5[6]) & 0x1f) < 0x10) { - this->field_0x5[6] = this->field_0x5[6] + 2; + this->direction = (this->playerAnimationState & 0xe) * 4; + if ((gPlayerState.field_0xd != 0xff) && (gPlayerState.field_0xd != this->direction)) { + if (((gPlayerState.field_0xd - this->direction) & 0x1f) < 0x10) { + this->direction = this->direction + 2; } - this->field_0x5[6]--; - this->field_0x5[6] &= 0x1f; + this->direction--; + this->direction &= 0x1f; } - gPlayerState.field_0xd = this->field_0x5[6]; + gPlayerState.field_0xd = this->direction; UpdateItemAnim(this); return; } diff --git a/src/item/itemShield.c b/src/item/itemShield.c index f9a2abb0..4ab16a4e 100644 --- a/src/item/itemShield.c +++ b/src/item/itemShield.c @@ -19,7 +19,7 @@ void ItemShield(ItemBehavior* beh, u32 idx) { void sub_08076D04(ItemBehavior* beh, u32 idx) { gPlayerState.field_0x3[0] = 0x81; - beh->field_0x5[4] = 2; + beh->field_0x9 = 2; sub_0806F948(&gPlayerEntity); sub_08077D38(beh, idx); sub_08077BB8(beh); @@ -29,7 +29,7 @@ void sub_08076D34(ItemBehavior* beh, u32 idx) { if (sub_08077EFC(beh) != 0) { gPlayerState.field_0x3[0] |= 1; UpdateItemAnim(beh); - if (beh->field_0x5[9] != 0) { + if (beh->playerFrame != 0) { beh->stateID++; beh->field_0xf = 0; gPlayerState.field_0xa &= ~(u8)(8 >> idx); diff --git a/src/item/itemSword.c b/src/item/itemSword.c index 814e1cf9..9dcaba2e 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -28,7 +28,7 @@ void ItemSword(ItemBehavior* this, u32 idx) { void sub_08075338(ItemBehavior* this, u32 idx) { u32 temp, temp2; if (gPlayerState.flags & PL_MINISH) { - this->field_0x5[4] |= 0x80; + this->field_0x9 |= 0x80; sub_08077D38(this, idx); gPlayerState.animation = 0xc00; SoundReq(SFX_PLY_VO1); @@ -74,9 +74,9 @@ void sub_08075338(ItemBehavior* this, u32 idx) { gPlayerState.field_0xa |= temp; gPlayerState.keepFacing |= temp; this->stateID = 8; - this->field_0x5[2] = 0x14; + this->timer = 0x14; this->field_0xf = 6; - this->field_0x5[4] |= 0x80; + this->field_0x9 |= 0x80; gPlayerState.field_0xab = 2; gPlayerState.flags |= PL_SWORD_THRUST; sub_08077DF4(this, 0x130); @@ -107,8 +107,8 @@ void sub_080754B8(ItemBehavior* this, u32 idx) { sub_08075694(this, idx); } else if (gPlayerState.field_0x3[1] != 0) { UpdateItemAnim(this); - if (this->field_0x5[9] != 0) { - this->field_0x5[4] = this->field_0x5[4] & 0x7f; + if (this->playerFrame != 0) { + this->field_0x9 &= ~0x80; } if (gPlayerEntity.frameSpriteSettings & 1) { @@ -123,7 +123,7 @@ void sub_080754B8(ItemBehavior* this, u32 idx) { } } - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) { sub_080759B8(this, idx); } else { @@ -143,9 +143,9 @@ void sub_08075580(ItemBehavior* this, u32 idx) { this->field_0xf = 0; this->stateID = 2; if ((gPlayerState.skills & SKILL_FAST_SPIN) != 0) { - this->field_0x5[2] = 0x28; // TODO spin speed? + this->timer = 0x28; // TODO spin speed? } else { - this->field_0x5[2] = 0x50; + this->timer = 0x50; } sub_08077DF4(this, 0x168); CreateObject(SWORD_PARTICLE, 0, 0); @@ -158,9 +158,9 @@ void sub_080755F0(ItemBehavior* this, u32 idx) { if (sub_08077EFC(this) != 0) { if (sub_08077EC8(this) == 0) { if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) != 0) { - if (--this->field_0x5[2] == 0) { + if (--this->timer == 0) { this->stateID = 3; - this->field_0x5[4] |= 0x80; + this->field_0x9 |= 0x80; gPlayerState.sword_state = gPlayerState.sword_state | 0x20; } } else { @@ -183,7 +183,7 @@ void sub_0807564C(ItemBehavior* this, u32 idx) { } void sub_08075694(ItemBehavior* this, u32 idx) { - this->field_0x5[2] = 1; + this->timer = 1; if (gPlayerState.flags & PL_SWORD_THRUST) { gPlayerState.flags &= ~PL_SWORD_THRUST; gPlayerState.flags &= ~PL_ROLLING; @@ -213,22 +213,22 @@ void sub_08075738(ItemBehavior* this, u32 idx) { } else { UpdateItemAnim(this); if (sub_08077F10(this)) { - this->field_0x5[2] = 2; + this->timer = 2; } if ((gPlayerState.sword_state & 0x10) != 0) { if ((gPlayerState.field_0xd & 0x80) == 0) { - this->field_0x5[6] = gPlayerState.field_0xd; + this->direction = gPlayerState.field_0xd; } - gPlayerEntity.direction = this->field_0x5[6]; + gPlayerEntity.direction = this->direction; gPlayerEntity.speed = 0x180; - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { bVar6 = 10; if ((gPlayerState.skills & SKILL_LONG_SPIN) != 0) { bVar6 = 0xf; } - if ((bVar6 <= ++this->field_0x5[3]) || (--this->field_0x5[2] == 0)) { + if ((bVar6 <= ++this->subtimer) || (--this->timer == 0)) { sub_080759B8(this, idx); } } @@ -242,17 +242,17 @@ void sub_08075738(ItemBehavior* this, u32 idx) { } if ((((gPlayerEntity.frameSpriteSettings & 2) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && - (((gPlayerState.skills & SKILL_GREAT_SPIN) != 0 && (--this->field_0x5[2] != 0)))) { + (((gPlayerState.skills & SKILL_GREAT_SPIN) != 0 && (--this->timer != 0)))) { gPlayerState.sword_state |= 0x10; gPlayerState.field_0xab = 6; - this->field_0x5[6] = gPlayerEntity.animationState << 2; - this->field_0x5[2] = 1; - this->field_0x5[3] = 1; + this->direction = gPlayerEntity.animationState << 2; + this->timer = 1; + this->subtimer = 1; gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx); sub_08077DF4(this, 0x128); } - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { sub_080759B8(this, idx); } } @@ -270,7 +270,7 @@ void sub_080758B0(ItemBehavior* this, u32 idx) { sub_080759B8(this, idx); } else { UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { this->field_0xf = 0; if ((gPlayerState.sword_state & 0x20) != 0) { this->stateID = 3; @@ -293,8 +293,8 @@ void sub_08075900(ItemBehavior* this, u32 idx) { sub_0807564C(this, idx); } else { - if (this->field_0x5[2] != 0) { - if (--this->field_0x5[2] == 0) { + if (this->timer != 0) { + if (--this->timer == 0) { sub_08077DF4(this, 0x134); } gPlayerEntity.direction = (gPlayerEntity.animationState >> 1) << 3; @@ -304,7 +304,7 @@ void sub_08075900(ItemBehavior* this, u32 idx) { CreateFx(&gPlayerEntity, FX_DASH, 0x40); } } else { - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { gPlayerState.flags &= ~PL_ROLLING; sub_080759B8(this, idx); } diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index cae32fd5..6de4eb66 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -37,7 +37,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 idx) { this->field_0x18 = carried; carried->action = 2; carried->subAction = 5; - gPlayerState.framestate = 5; + gPlayerState.framestate = PL_STATE_THROW; sub_080762C4(this, carried, 2, idx); gUnk_0200AF00.unk_2e = 8; SoundReq(SFX_102); @@ -48,7 +48,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 idx) { break; case 0: this->stateID = 5; - this->field_0x5[2] = 0x0f; + this->timer = 0x0f; this->field_0xf = 6; gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa; gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing; @@ -79,13 +79,13 @@ void sub_08076488(ItemBehavior* this, u32 idx) { u32 bVar1; s32 iVar2; - if (this->field_0x5[2] == 0) { + if (this->timer == 0) { if (PlayerTryDropObject(this, idx) != 0) { if ((((this->field_0x18->carryFlags) & 0xf0) == 0x10) && ((gRoomTransition.frameCount & 1U) != 0)) { return; } UpdateItemAnim(this); - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; gPlayerState.heldObject = 4; bVar1 = ~(8 >> idx); @@ -96,14 +96,14 @@ void sub_08076488(ItemBehavior* this, u32 idx) { } } } else { - this->field_0x5[2]--; + this->timer--; } gPlayerState.framestate = PL_STATE_HOLD; } void sub_08076518(ItemBehavior* this, u32 index) { if (PlayerTryDropObject(this, index)) { - gPlayerState.framestate = 4; + gPlayerState.framestate = PL_STATE_HOLD; if ((gPlayerState.jump_status & 0x80) == 0 && gPlayerState.field_0x1f[0] == 0) { if (gPlayerEntity.knockbackDuration != 0) { PlayerCancelHoldItem(this, index); @@ -132,7 +132,7 @@ void sub_08076518(ItemBehavior* this, u32 index) { void sub_080765E0(ItemBehavior* this, u32 idx) { if (PlayerTryDropObject(this, idx) != 0) { - if ((this->field_0x5[9] & 0x80) != 0) { + if ((this->playerFrame & 0x80) != 0) { PlayerCancelHoldItem(this, idx); } else { UpdateItemAnim(this); @@ -142,7 +142,7 @@ void sub_080765E0(ItemBehavior* this, u32 idx) { void sub_0807660C(ItemBehavior* this, u32 idx) { UpdateItemAnim(this); - if ((this->field_0x5[2]-- == 0) || (gPlayerState.field_0x0[1] == 0)) { + if ((this->timer-- == 0) || (gPlayerState.field_0x0[1] == 0)) { gPlayerState.field_0x0[1] = 0; DeletePlayerItem(this, idx); } diff --git a/src/kinstone.c b/src/kinstone.c index 24feb5ab..c019a623 100644 --- a/src/kinstone.c +++ b/src/kinstone.c @@ -119,7 +119,7 @@ void GenerateAreaHint(void) { u16 uVar1; struct_area_28* ptr; - gPlayerState.queued_action = 0x16; + gPlayerState.queued_action = PLAYER_TALKEZLO; #if defined(EU) || defined(JP) // TODO what fields of the room transition are switched in these variants? gRoomTransition.field_0x2c[7] = 0; diff --git a/src/manager/ezloHintManager.c b/src/manager/ezloHintManager.c index bf7e4ad2..c6aa5183 100644 --- a/src/manager/ezloHintManager.c +++ b/src/manager/ezloHintManager.c @@ -103,7 +103,7 @@ static u32 PlayerStateValid(EzloHintManager* this) { case PL_STATE_DROWN: case PL_STATE_HOLE: case PL_STATE_CLIMB: - case PL_STATE_1B: + case PL_STATE_SINKING: case PL_STATE_STAIRS: return 0; case PL_STATE_6: diff --git a/src/manager/minishRaftersBackgroundManager.c b/src/manager/minishRaftersBackgroundManager.c index e55e989b..8bc52447 100644 --- a/src/manager/minishRaftersBackgroundManager.c +++ b/src/manager/minishRaftersBackgroundManager.c @@ -46,9 +46,10 @@ u32 sub_08058244(int i) { s32 tmp2; u32 tmp3; s32 tmp4; - tmp = ((gRoomControls.scroll_y - gRoomControls.origin_y) * 0x20) / (gRoomControls.height - 0xa0); + tmp = ((gRoomControls.scroll_y - gRoomControls.origin_y) * 0x20) / (gRoomControls.height - DISPLAY_HEIGHT); gScreen.bg1.yOffset = gRoomControls.origin_y + tmp; - tmp = (((gRoomControls.scroll_x - gRoomControls.origin_x) * gUnk_081081EC[i]) / (gRoomControls.width - 0xf0)); + tmp = (((gRoomControls.scroll_x - gRoomControls.origin_x) * gUnk_081081EC[i]) / + (gRoomControls.width - DISPLAY_WIDTH)); gScreen.bg1.xOffset = tmp & 0xf; return tmp; } diff --git a/src/manager/staticBackgroundManager.c b/src/manager/staticBackgroundManager.c index 156aa35d..f069196c 100644 --- a/src/manager/staticBackgroundManager.c +++ b/src/manager/staticBackgroundManager.c @@ -57,7 +57,7 @@ void sub_0805B448(StaticBackgroundManager* this) { } void sub_0805B474(StaticBackgroundManager* this) { - s32 tmp = ((gRoomControls.scroll_y - gRoomControls.origin_y) * 0x60) / (gRoomControls.height - 0xa0); + s32 tmp = ((gRoomControls.scroll_y - gRoomControls.origin_y) * 0x60) / (gRoomControls.height - DISPLAY_HEIGHT); gScreen.bg3.yOffset = gRoomControls.origin_y + tmp; gScreen.bg3.xOffset = gRoomControls.scroll_x - ((gRoomControls.width - 0x100) / 2); } diff --git a/src/menu/figurine_menu.c b/src/menu/figurine_menu.c index 5a15d133..284a10c2 100644 --- a/src/menu/figurine_menu.c +++ b/src/menu/figurine_menu.c @@ -103,7 +103,7 @@ void FigurineMenu_080A4608(void) { SetColor(0x15c, gPaletteBuffer[0xd3]); MemClear(&gBG0Buffer, 0x800); MemClear(&gBG3Buffer, 0x1000); - gScreen.controls.window0HorizontalDimensions = 0xf0; + gScreen.controls.window0HorizontalDimensions = DISPLAY_WIDTH; gScreen.controls.window0VerticalDimensions = 0x7898; gScreen.controls.windowInsideControl = 0x1f; gScreen.controls.windowOutsideControl = 0x1d; diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 564e7e2d..e7208579 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -123,14 +123,14 @@ static void sub_0806D02C(Entity* this) { tmp1 = -(s16)gScreen.bg1.xOffset; tmp2 = tmp1 + 0x100; - tmp1 = min(max(0, tmp1), 0xf0); - tmp2 = min(max(0, tmp2), 0xf0); + tmp1 = min(max(0, tmp1), DISPLAY_WIDTH); + tmp2 = min(max(0, tmp2), DISPLAY_WIDTH); gScreen.controls.window1HorizontalDimensions = (tmp1 << 8) | tmp2; tmp1 = -(s16)gScreen.bg1.yOffset; tmp2 = tmp1 + 0x100; - tmp1 = min(max(0, tmp1), 0xa0); - tmp2 = min(max(0, tmp2), 0xa0); + tmp1 = min(max(0, tmp1), DISPLAY_HEIGHT); + tmp2 = min(max(0, tmp2), DISPLAY_HEIGHT); gScreen.controls.window1VerticalDimensions = (tmp1 << 8) | tmp2; } diff --git a/src/npc/guardWithSpear.c b/src/npc/guardWithSpear.c index 1d1e172d..ed298050 100644 --- a/src/npc/guardWithSpear.c +++ b/src/npc/guardWithSpear.c @@ -278,11 +278,11 @@ void sub_080644B4(Entity* this, ScriptExecutionContext* context) { u32 sub_080644C8(GuardWithSpearEntity* this) { if (super->x.HALF.HI - gRoomControls.scroll_x + 8 < 0) return 0; - if (super->x.HALF.HI - gRoomControls.scroll_x - 8 > 0xf0) + if (super->x.HALF.HI - gRoomControls.scroll_x - 8 > DISPLAY_WIDTH) return 0; if (super->y.HALF.HI - gRoomControls.scroll_y < 0) return 0; - if (super->y.HALF.HI - gRoomControls.scroll_y - 0x18 > 0xa0) + if (super->y.HALF.HI - gRoomControls.scroll_y - 0x18 > DISPLAY_HEIGHT) return 0; return 1; } diff --git a/src/npc/kid.c b/src/npc/kid.c index 77b91db9..1371fb9d 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -18,7 +18,10 @@ typedef struct { u16 unk_4; /* u16 */ u8 unk_6; u8 unk_7; -} KidHeap; +} KidHeapItem; + +#define KID_HEAP_COUNT 0x14 +typedef KidHeapItem KidHeap[KID_HEAP_COUNT]; extern u16 gUnk_0810BDE8[][2]; @@ -142,7 +145,7 @@ void sub_080621AC(Entity* this) { ASM_FUNC("asm/non_matching/kid/sub_080622F4.inc", void sub_080622F4(Entity* this)) void sub_08062500(Entity* this) { - this->myHeap = zMalloc(0xa0); + this->myHeap = zMalloc(sizeof(KidHeap)); if (this->myHeap != NULL) { this->field_0x68.HALF.LO = 1; sub_080788E0(this); @@ -160,7 +163,7 @@ NONMATCH("asm/non_matching/kid/sub_0806252C.inc", void sub_0806252C(Entity* this s16 sVar5; s16 sVar6; u8 bVar7; - KidHeap* heapObj; + KidHeapItem* heapObj; s32 loopVar; s32 iVar10; s32 iVar11; @@ -170,13 +173,13 @@ NONMATCH("asm/non_matching/kid/sub_0806252C.inc", void sub_0806252C(Entity* this sVar2 = gPlayerEntity.y.HALF.HI; sVar1 = gPlayerEntity.x.HALF.HI; r0 = gPlayerEntity.y.HALF.HI - this->y.HALF.HI; - sVar5 = FixedDiv(gPlayerEntity.x.HALF.HI - this->x.HALF.HI, 0x14); - sVar6 = FixedDiv(r0, 0x14); - heapObj = (KidHeap*)this->myHeap; + sVar5 = FixedDiv(gPlayerEntity.x.HALF.HI - this->x.HALF.HI, KID_HEAP_COUNT); + sVar6 = FixedDiv(r0, KID_HEAP_COUNT); + heapObj = (KidHeapItem*)this->myHeap; iVar10 = 0; iVar11 = 0; - loopVar = 0x13; - while (loopVar > -1) { + + for (loopVar = KID_HEAP_COUNT - 1; loopVar > -1; loopVar--) { heapObj->unk_0 = sVar1 - (s16)((u32)iVar11 >> 8); heapObj->unk_2 = sVar2 - (s16)((u32)iVar10 >> 8); heapObj->unk_4 = uVar3; @@ -187,8 +190,7 @@ NONMATCH("asm/non_matching/kid/sub_0806252C.inc", void sub_0806252C(Entity* this heapObj = heapObj + 1; iVar10 = iVar10 + sVar6; iVar11 = iVar11 + sVar5; - loopVar = loopVar - 1; - }; + } } END_NONMATCH diff --git a/src/npc/rem.c b/src/npc/rem.c index f59f642c..c8834192 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -6,7 +6,7 @@ extern void sub_0806A8C8(Entity*); extern void script_Rem; -extern void sub_0807F950(Entity* this, ScriptExecutionContext* context); +extern void DeleteThoughtBubble(Entity* this, ScriptExecutionContext* context); void sub_0806A9B0(Entity*, ScriptExecutionContext*); void sub_0806A914(Entity* this); @@ -463,10 +463,10 @@ void sub_0806AB74(Entity* this) { } } -void sub_0806AB9C(Entity* this, ScriptExecutionContext* context) { +void DeleteNpcRem(Entity* this, ScriptExecutionContext* context) { Entity* entity = FindEntity(NPC, REM, NPC, 1, 0); if (entity != NULL) { DeleteEntity(entity); } - sub_0807F950(this, context); + DeleteThoughtBubble(this, context); } diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c index 8f5a3808..1f62e640 100644 --- a/src/object/bigPushableLever.c +++ b/src/object/bigPushableLever.c @@ -59,7 +59,7 @@ void BigPushableLever_Idle(BigPushableLeverEntity* this) { RequestPriorityDuration(super, 30); if (PlayerCanBeMoved()) { gPlayerState.pushedObject = 0x98; - gPlayerState.queued_action = 5; + gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; diff --git a/src/object/bird.c b/src/object/bird.c index 480cc984..55f080ad 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -225,7 +225,7 @@ void Bird_Type8(Entity* this) { PlayerCanBeMoved() && (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe))) { s32 z = gPlayerEntity.z.HALF.HI - this->z.HALF.HI - 8; if ((u16)z < 0x20 && gPlayerEntity.health != 0) { - pEVar5 = CreateObject(0x95, 10, 0); + pEVar5 = CreateObject(BIRD, 10, 0); if (pEVar5 != NULL) { this->child = pEVar5; this->action = 2; diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 731e8042..899b336f 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -123,7 +123,7 @@ void ChestSpawner_Type2Action2(ChestSpawnerEntity* this) { super->subAction = 1; break; case 1: - if ((super->type == 5) || (gPlayerEntity.action == 1)) { + if ((super->type == 5) || (gPlayerEntity.action == PLAYER_NORMAL)) { super->subAction = 2; super->timer = 8; super->subtimer = 0; diff --git a/src/object/chuchuBossStartParticle.c b/src/object/chuchuBossStartParticle.c index 370b8d4b..ae8dfd15 100644 --- a/src/object/chuchuBossStartParticle.c +++ b/src/object/chuchuBossStartParticle.c @@ -221,7 +221,7 @@ void sub_0808F3DC(Entity* this) { } if (this->type == 5 && (this->frame & 1)) { - Entity* entity = CreateObjectWithParent(this->child, 0x49, 8, 0); + Entity* entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 8, 0); if (entity != NULL) { entity->parent = this->parent; entity->child = this->parent->parent; @@ -288,19 +288,19 @@ void sub_0808F554(Entity* this) { } void sub_0808F5EC(Entity* this) { - Entity* entity = CreateObjectWithParent(this->child, 0x49, 5, 0); + Entity* entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 5, 0); if (entity != NULL) { entity->parent = this; entity->child = this->child; } - entity = CreateObjectWithParent(this->child, 0x49, 6, 0); + entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 6, 0); if (entity != NULL) { entity->parent = this; entity->child = this->child; } - entity = CreateObjectWithParent(this->child, 0x49, 7, 0); + entity = CreateObjectWithParent(this->child, CHUCHU_BOSS_START_PARTICLE, 7, 0); if (entity != NULL) { entity->parent = this; entity->child = this->child; diff --git a/src/object/graveyardKey.c b/src/object/graveyardKey.c index 0a0dfc0b..e4c4f2ef 100644 --- a/src/object/graveyardKey.c +++ b/src/object/graveyardKey.c @@ -173,7 +173,7 @@ void sub_0809D91C(Entity* this) { bool32 sub_0809D93C(Entity* this, const struct_gUnk_08123FB0* param_2) { u32 uVar1; - if (gPlayerEntity.action == 6 && ((param_2->unk0c >> gPlayerEntity.animationState & 1) != 0)) { + if (gPlayerEntity.action == PLAYER_BOUNCE && ((param_2->unk0c >> gPlayerEntity.animationState & 1) != 0)) { uVar1 = (gPlayerEntity.x.HALF.HI - this->x.HALF.HI) + param_2->unk08 + param_2->unk0a; if (param_2->unk0a * 2 <= (u16)uVar1) { return 0; diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c index f66fdee7..d9f44c6d 100644 --- a/src/object/gyorgBossObject.c +++ b/src/object/gyorgBossObject.c @@ -421,12 +421,12 @@ void GyorgBossObject_SpawnChildren(u32 unk0, bool32 fromBlue, u32 animationState tmp->attackOffsetY = -p->offsetY; break; case 1: - tmp->attackOffsetX = p->offsetY + 0xF0; + tmp->attackOffsetX = p->offsetY + DISPLAY_WIDTH; tmp->attackOffsetY = p->offsetX; break; case 2: tmp->attackOffsetX = p->offsetX; - tmp->attackOffsetY = p->offsetY + 0xA0; + tmp->attackOffsetY = p->offsetY + DISPLAY_HEIGHT; break; case 3: tmp->attackOffsetX = -p->offsetY; diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 20664a1c..283969f8 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -92,7 +92,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) { super->interactType = 0; super->action = 3; gRoomVars.animFlags = 1; - gPlayerState.queued_action = 7; + gPlayerState.queued_action = PLAYER_08070E9C; } } else { if (super->interactType != 0) { diff --git a/src/object/keyStealingTakkuri.c b/src/object/keyStealingTakkuri.c index bc4c4dd5..68fac5a3 100644 --- a/src/object/keyStealingTakkuri.c +++ b/src/object/keyStealingTakkuri.c @@ -518,7 +518,7 @@ u32 sub_0809E2C4(KeyStealingTakkuriEntity* this, u32 param_2) { uVar1 = roomY - tmp->unk_2 + tmp->unk_5; uVar2 = tmp->unk_5 * 2; if (uVar2 > (u16)uVar1) { - if (tmp->unk_6 == gPlayerEntity.animationState && gPlayerEntity.action == 6) { + if (tmp->unk_6 == gPlayerEntity.animationState && gPlayerEntity.action == PLAYER_BOUNCE) { return 1; } return 2; diff --git a/src/object/lightRay.c b/src/object/lightRay.c index 4aae9aac..c353a862 100644 --- a/src/object/lightRay.c +++ b/src/object/lightRay.c @@ -94,14 +94,14 @@ void sub_0809B97C(LightRayEntity* this, u32 param_2) { if (tmp1 < 0) { tmp1 = 0; } - if (0xf0 < tmp1) { - tmp1 = 0xf0; + if (DISPLAY_WIDTH < tmp1) { + tmp1 = DISPLAY_WIDTH; } if (tmp2 < 0) { tmp2 = 0; } - if (0xf0 < tmp2) { - tmp2 = 0xf0; + if (DISPLAY_WIDTH < tmp2) { + tmp2 = DISPLAY_WIDTH; } gScreen.controls.window0HorizontalDimensions = (tmp1 << 8) | tmp2; } @@ -124,8 +124,8 @@ void LightRay_Type1(LightRayEntity* this) { } gPlayerEntity.animationState = tmp; gScreen.lcd.displayControl = (gScreen.lcd.displayControl & 0xbfff) | 0x2000; - gScreen.controls.window0HorizontalDimensions = 0xf0; - gScreen.controls.window0VerticalDimensions = 0xa0; + gScreen.controls.window0HorizontalDimensions = DISPLAY_WIDTH; + gScreen.controls.window0VerticalDimensions = DISPLAY_HEIGHT; break; case 1: if (super->timer != 0) { diff --git a/src/object/minishEmoticon.c b/src/object/minishEmoticon.c index a42a9ac8..0904b1cb 100644 --- a/src/object/minishEmoticon.c +++ b/src/object/minishEmoticon.c @@ -72,7 +72,7 @@ void MinishEmoticon_Action1(Entity* this) { animIndex = origAnimIndex + 0x19; } } else { - if ((gPlayerState.framestate == 1) || (gPlayerState.framestate == 25)) { + if (gPlayerState.framestate == PL_STATE_WALK || gPlayerState.framestate == PL_STATE_PUSH) { animIndex = origAnimIndex + 4; if (this->animIndex != animIndex) { this->z.WORD = 0; diff --git a/src/object/object70.c b/src/object/object70.c index 7cc2664f..064f6808 100644 --- a/src/object/object70.c +++ b/src/object/object70.c @@ -42,7 +42,8 @@ void Object70_Action1(Entity* this) { if (this->type == 0) { if (gPlayerEntity.z.WORD == 0) { if ((((gPlayerState.dash_state & 0x40) == 0) && (gPlayerState.floor_type == SURFACE_SWAMP)) && - ((gPlayerEntity.action == 1 || ((gPlayerEntity.action == 0x18 || (gPlayerEntity.action == 4)))))) { + ((gPlayerEntity.action == PLAYER_NORMAL || + ((gPlayerEntity.action == PLAYER_ROLL || (gPlayerEntity.action == PLAYER_JUMP)))))) { goto _080974FA; } else { if (gPlayerEntity.z.WORD == 0) { @@ -65,7 +66,7 @@ void Object70_Action1(Entity* this) { } } else { - if (gPlayerEntity.action != 0x1e) { + if (gPlayerEntity.action != PLAYER_USEENTRANCE) { if (this->collisionLayer == 1) { gPlayerEntity.spriteOrientation.flipY = 2; } else { diff --git a/src/object/objectBlockingStairs.c b/src/object/objectBlockingStairs.c index 8664a365..5473531d 100644 --- a/src/object/objectBlockingStairs.c +++ b/src/object/objectBlockingStairs.c @@ -162,7 +162,7 @@ void ObjectBlockingStairs_Action2(ObjectBlockingStairsEntity* this) { } else { if (gPlayerState.heldObject == 0x12) { if ((gPlayerEntity.frame & 2) != 0 && ++super->subtimer > 8) { - gPlayerState.queued_action = 16; + gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x40; gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index 1b82f909..371d8ec2 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -129,7 +129,7 @@ void ObjectOnPillar_SubAction0(ObjectOnPillarEntity* this) { } sub_08097008(this); if (sub_080896B0()) { - gPlayerState.queued_action = 0x10; + gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x20; gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index a1f974de..ad3afd84 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -79,7 +79,7 @@ void OctorokBossObject_Init(Entity* this) { } } - this->speed = 0xf0 - (Random() & 0x3f); + this->speed = DISPLAY_WIDTH - (Random() & 0x3f); LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); InitializeAnimation(this, 5); diff --git a/src/object/playerClone.c b/src/object/playerClone.c index 485975d9..3dd8b990 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -105,8 +105,8 @@ void PlayerClone_Action2(PlayerCloneEntity* this) { super->subtimer--; } - if (gPlayerState.chargeState.action == 5 && gPlayerClones[super->type] != NULL && gPlayerState.framestate != 19 && - super->health != 0) { + if (gPlayerState.chargeState.action == 5 && gPlayerClones[super->type] != NULL && + gPlayerState.framestate != PL_STATE_TALKEZLO && super->health != 0) { if (gPlayerEntity.iframes >= 1) { gPlayerState.chargeState.action = 1; } else { diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index 408cff7d..c03f3444 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -234,8 +234,8 @@ void sub_0808AEB0(PullableMushroomEntity* this) { super->subtimer = 1; } else { - if (((super->subtimer != 0) && (gPlayerEntity.action == 1)) && (gPlayerState.swim_state == 0)) { - gPlayerState.queued_action = 0x1b; + if (((super->subtimer != 0) && (gPlayerEntity.action == PLAYER_NORMAL)) && (gPlayerState.swim_state == 0)) { + gPlayerState.queued_action = PLAYER_08072C9C; gPlayerState.field_0x38 = uVar1; gPlayerState.field_0x39 = super->direction ^ 0x10; gPlayerState.field_0x3a = sub_0808B1F0(this, &gPlayerEntity); @@ -315,9 +315,9 @@ void sub_0808B0BC(PullableMushroomEntity* this) { ent.base.x.HALF.HI = ptr[0] + gPlayerEntity.x.HALF.HI; ent.base.y.HALF.HI = ptr[1] + gPlayerEntity.y.HALF.HI; if (sub_0800419C(&ent.base, super, 7, 7)) { - if ((gPlayerEntity.action != 1) || (gPlayerState.swim_state != 0)) + if ((gPlayerEntity.action != PLAYER_NORMAL) || (gPlayerState.swim_state != 0)) return; - gPlayerState.queued_action = 0x1b; + gPlayerState.queued_action = PLAYER_08072C9C; gPlayerState.field_0x38 = uVar2; gPlayerState.field_0x39 = super->direction ^ 0x10; gPlayerState.field_0x3a = sub_0808B1F0((PullableMushroomEntity*)super->parent, &gPlayerEntity); diff --git a/src/object/pushableFurniture.c b/src/object/pushableFurniture.c index 22efed6f..42f3b333 100644 --- a/src/object/pushableFurniture.c +++ b/src/object/pushableFurniture.c @@ -352,9 +352,9 @@ void sub_0808FDE8(PushableFurnitureEntity* this) { bool32 sub_0808FECC(PushableFurnitureEntity* this) { bool32 result = TRUE; - if (!((gPlayerState.flags & PL_MINISH) == 0 && (gPlayerEntity.action == 6) && (gPlayerEntity.animationState == 0) && - (gPlayerEntity.y.HALF.HI - super->y.HALF.HI < 0x14) && (super->x.HALF.HI + 0xc > gPlayerEntity.x.HALF.HI) && - (super->x.HALF.HI - 12 < gPlayerEntity.x.HALF.HI))) { + if (!((gPlayerState.flags & PL_MINISH) == 0 && (gPlayerEntity.action == PLAYER_BOUNCE) && + (gPlayerEntity.animationState == 0) && (gPlayerEntity.y.HALF.HI - super->y.HALF.HI < 0x14) && + (super->x.HALF.HI + 0xc > gPlayerEntity.x.HALF.HI) && (super->x.HALF.HI - 12 < gPlayerEntity.x.HALF.HI))) { result = FALSE; } return result; diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c index 3c8ee887..dec3fcb7 100644 --- a/src/object/pushableLever.c +++ b/src/object/pushableLever.c @@ -58,7 +58,7 @@ void PushableLever_Idle(PushableLeverEntity* this) { RequestPriorityDuration(super, 30); if (PlayerCanBeMoved()) { gPlayerState.pushedObject = 0x90; - gPlayerState.queued_action = 5; + gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index 099d96e5..d24e44c7 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -130,7 +130,7 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) { } } if (sub_080896B0()) { - gPlayerState.queued_action = 0x10; + gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x20; gPlayerState.flags |= 1; gPlayerEntity.x.HALF.LO = 0; diff --git a/src/object/vaati1Portal.c b/src/object/vaati1Portal.c index dd60a587..dfbc8487 100644 --- a/src/object/vaati1Portal.c +++ b/src/object/vaati1Portal.c @@ -59,7 +59,7 @@ void Vaati1Portal_Action2(Entity* this) { void sub_080A0190(Entity* this) { this->subAction = 1; CopyPosition(this, &gPlayerEntity); - gPlayerState.queued_action = 3; + gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x38 = 0; gPlayerState.flags |= PL_PIT_IS_EXIT; } diff --git a/src/object/whirlwind.c b/src/object/whirlwind.c index 8dbd8959..b7933500 100644 --- a/src/object/whirlwind.c +++ b/src/object/whirlwind.c @@ -62,9 +62,9 @@ void Whirlwind_Action1(Entity* this) { if (this->spriteSettings.draw != 0) { GetNextFrame(this); if ((((((gPlayerState.flags & PL_MINISH) == 0)) && (gPlayerState.field_0x3c == 0)) && - ((gPlayerEntity.action == 4 || ((gPlayerEntity.flags & ENT_COLLIDE) != 0)))) && - ((gPlayerEntity.action != 6 && (sub_0800419C(this, &gPlayerEntity, 0xc, 0xc) != 0)))) { - if (((gPlayerState.flags & PL_PARACHUTE) == 0) && (gPlayerEntity.action != 4)) { + ((gPlayerEntity.action == PLAYER_JUMP || ((gPlayerEntity.flags & ENT_COLLIDE) != 0)))) && + ((gPlayerEntity.action != PLAYER_BOUNCE && (sub_0800419C(this, &gPlayerEntity, 0xc, 0xc) != 0)))) { + if (((gPlayerState.flags & PL_PARACHUTE) == 0) && (gPlayerEntity.action != PLAYER_JUMP)) { if ((this->type2 != 1) && (-0x10 < gPlayerEntity.z.HALF.HI)) { return; } @@ -76,7 +76,7 @@ void Whirlwind_Action1(Entity* this) { sub_08004542(&gPlayerEntity); gPlayerEntity.collisionLayer = 1; gPlayerEntity.flags |= ENT_COLLIDE; - gPlayerState.queued_action = 0x1f; + gPlayerState.queued_action = PLAYER_PARACHUTE; gPlayerState.field_0x38 = this->type2; gPlayerState.field_0x39 = 0xff; this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; diff --git a/src/physics.c b/src/physics.c index fbe503c1..617b5c81 100644 --- a/src/physics.c +++ b/src/physics.c @@ -9,6 +9,7 @@ #include "room.h" #include "functions.h" #include "color.h" +#include "playeritem.h" const u8 gSpriteSortAboveTable[]; const u8 gSpriteSortBelowTable[]; @@ -82,7 +83,7 @@ bool32 sub_0806F3E4(Entity* ent) { ent->subAction = 3; gNewPlayerEntity.unk_70 = ent; gPlayerState.field_0x1c = 7; - item = CreatePlayerItem(0x11, 0, 0, 0); + item = CreatePlayerItem(PLAYER_ITEM_11, 0, 0, 0); if (item != NULL) { item->child = ent; ent->parent = item; diff --git a/src/player.c b/src/player.c index af48dcf4..0d3687fd 100644 --- a/src/player.c +++ b/src/player.c @@ -288,7 +288,7 @@ bool32 CheckInitPauseMenu(void) { return FALSE; } - framestate = gPlayerState.framestate == 0 ? gPlayerState.framestate_last : gPlayerState.framestate; + framestate = gPlayerState.framestate == PL_STATE_IDLE ? gPlayerState.framestate_last : gPlayerState.framestate; switch (framestate) { case PL_STATE_DIE: case PL_STATE_TALKEZLO: @@ -692,7 +692,7 @@ static void PlayerBounceUpdate(Entity* this) { COLLISION_ON(this); if ((gPlayerState.field_0x14 == 0) && PlayerCheckNEastTile()) { - gPlayerState.field_0x11 = 7; + gPlayerState.surfacePositionSameTimer = 7; ResolvePlayerAnimation(); SetPlayerActionNormal(); return; @@ -845,7 +845,7 @@ static void PlayerJumpInit(Entity* this) { gPlayerState.flags |= PL_BUSY; gPlayerState.flags &= ~(PL_BURNING | PL_FROZEN); - gPlayerState.queued_action = 0; + gPlayerState.queued_action = PLAYER_INIT; if ((gPlayerState.heldObject | gPlayerState.sword_state) == 0) { if ((gPlayerState.flags & PL_MINISH) == 0) { @@ -1499,7 +1499,7 @@ static void PlayerMinishDieInit(Entity* this) { return; } - gPlayerState.queued_action = 0; + gPlayerState.queued_action = PLAYER_INIT; if (gPlayerState.flags & PL_MINISH) { if (gPlayerState.floor_type == SURFACE_MINISH_DOOR_FRONT || gPlayerState.floor_type == SURFACE_MINISH_DOOR_BACK || gPlayerState.floor_type == SURFACE_A) { @@ -1611,7 +1611,7 @@ static void sub_08071E04(Entity* this) { if ((this->z.WORD != 0) && (gPlayerState.field_0x14 == 0)) { UpdateFloorType(); if (gPlayerState.floor_type == SURFACE_PIT) { - gPlayerState.field_0x11 = 7; + gPlayerState.surfacePositionSameTimer = 7; gPlayerState.flags |= PL_FALLING; SetPlayerActionNormal(); return; @@ -2288,7 +2288,7 @@ static void sub_08072C48(Entity* this) { sub_08008790(this, 7); if (gPlayerState.field_0x14) { if (PlayerCheckNEastTile()) { - gPlayerState.field_0x11 = 7; + gPlayerState.surfacePositionSameTimer = 7; if (!(gPlayerState.flags & PL_MINISH)) { SetPlayerActionNormal(); } @@ -2305,7 +2305,7 @@ static void sub_08072C9C(Entity* this) { sub_08072D54, sub_08072F14, }; - gPlayerState.framestate = 0x11; + gPlayerState.framestate = PL_STATE_11; gUnk_0811BBAC[this->subAction](this); } @@ -2410,7 +2410,7 @@ static void sub_08072D54(Entity* this) { sub_08008790(this, 7); if (gPlayerState.field_0x14 != 0) { if (PlayerCheckNEastTile()) { - gPlayerState.field_0x11 = 7; + gPlayerState.surfacePositionSameTimer = 7; if (!(gPlayerState.flags & PL_MINISH)) { SetPlayerActionNormal(); } @@ -3034,7 +3034,7 @@ static void sub_08073AD4(Entity* this) { sub_0807A2B8(); gPlayerState.jump_status = 0; UpdateFloorType(); - if (gPlayerState.queued_action != 0 || gPlayerState.swim_state != 0) { + if (gPlayerState.queued_action != PLAYER_INIT || gPlayerState.swim_state != 0) { return; } if (gPlayerState.field_0x3[1]) @@ -3319,8 +3319,8 @@ void sub_080740D8(Entity* this) { u32 sub_080741C4(void) { if ((gPlayerState.jump_status && (gPlayerState.jump_status & 7) != 3) || gPlayerEntity.z.WORD != 0) { - gPlayerState.field_0x11 = 0; - gPlayerState.field_0x37 = 0; + gPlayerState.surfacePositionSameTimer = 0; + gPlayerState.surfaceTimer = 0; return 1; } return 0; @@ -3374,7 +3374,7 @@ void SurfaceAction_6(Entity* this) { } void SurfaceAction_7(Entity* this) { - if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0 && gPlayerState.field_0x11 == 15) { + if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0 && gPlayerState.surfacePositionSameTimer == 15) { CreateObjectWithParent(this, CRACKING_GROUND, 0, 0); } } @@ -3519,7 +3519,8 @@ void SurfaceAction_ShallowWater(Entity* this) { this->spritePriority.b0 = 4; gPlayerState.swim_state = 0; } - if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) || gPlayerState.field_0x11 == 1) + if ((gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) || + gPlayerState.surfacePositionSameTimer == 1) SoundReq(SFX_WATER_WALK); } } @@ -3536,29 +3537,29 @@ void SurfaceAction_SlopeGndWater(Entity* this) { void SurfaceAction_Swamp(Entity* this) { if (sub_080741C4()) { - gPlayerState.field_0x11 = 0; - gPlayerState.field_0x37 = 0; + gPlayerState.surfacePositionSameTimer = 0; + gPlayerState.surfaceTimer = 0; return; } if (this->health) { if (sub_08079C30(this) == 0) { - gPlayerState.field_0x11 = 0; - gPlayerState.field_0x37 = 0; + gPlayerState.surfacePositionSameTimer = 0; + gPlayerState.surfaceTimer = 0; return; } - if ((gPlayerState.flags & 0x80) == 0) { + if ((gPlayerState.flags & PL_MINISH) == 0) { if (gPlayerState.dash_state) { if ((gPlayerState.dash_state & 0x40) != 0) { - gPlayerState.field_0x11 = 0; - gPlayerState.field_0x37 = 0; + gPlayerState.surfacePositionSameTimer = 0; + gPlayerState.surfaceTimer = 0; return; } } else { PutAwayItems(); } - if (gPlayerState.field_0x37 == 1) { + if (gPlayerState.surfaceTimer == 1) { CreateObjectWithParent(this, OBJECT_70, 0, 0); CreateFx(this, FX_GREEN_SPLASH, 0); SoundReq(SFX_161); @@ -3568,9 +3569,9 @@ void SurfaceAction_Swamp(Entity* this) { SoundReq(SFX_161); } gPlayerState.speed_modifier -= 0xf0; - gPlayerState.framestate = 0x1b; - if (gPlayerState.field_0x37 < 0xf0) { - gPlayerState.spriteOffsetY = gPlayerState.spriteOffsetY + 4 + (gPlayerState.field_0x37 >> 5); + gPlayerState.framestate = PL_STATE_SINKING; + if (gPlayerState.surfaceTimer < 0xf0) { + gPlayerState.spriteOffsetY = gPlayerState.spriteOffsetY + 4 + (gPlayerState.surfaceTimer >> 5); return; } } @@ -3717,7 +3718,8 @@ void SurfaceAction_22(Entity* this) { void SurfaceAction_Dust(Entity* this) { if (!sub_080741C4()) { gPlayerState.speed_modifier -= 128; - if (gPlayerState.field_0x11 == 1 || (gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) != 0) { + if (gPlayerState.surfacePositionSameTimer == 1 || + (gPlayerState.playerInput.field_0x92 & PLAYER_INPUT_ANY_DIRECTION) != 0) { if (gPlayerState.floor_type == SURFACE_DUST) CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0); else diff --git a/src/playerItem/playerItemBomb.c b/src/playerItem/playerItemBomb.c index 25c0f67c..f6ed0c1c 100644 --- a/src/playerItem/playerItemBomb.c +++ b/src/playerItem/playerItemBomb.c @@ -4,6 +4,7 @@ #include "functions.h" #include "asm.h" #include "item.h" +#include "object.h" typedef struct { Entity base; @@ -65,7 +66,7 @@ void PlayerItemBomb(PlayerItemBombEntity* this) { super->spriteSettings.draw = 0; sub_0805EC60(super); FreeCarryEntity(super); - CreateObjectWithParent(super, 0x20, 0, 0); + CreateObjectWithParent(super, SMOKE_PARTICLE, 0, 0); sub_0801B418(super); } else { sub_0801B3A4(this); diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index 9b40a557..4dc62bca 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -90,7 +90,7 @@ void sub_0801B584(Entity* this) { sub_0801B804(this); if ((gPlayerState.field_0x3[1] == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != this || - (gPlayerState.item == this && gPlayerEntity.action != 1)) { + (gPlayerState.item == this && gPlayerEntity.action != PLAYER_NORMAL)) { if (gPlayerState.item == this) { gPlayerState.item = NULL; } diff --git a/src/playerItem/playerItemFireRodProjectile.c b/src/playerItem/playerItemFireRodProjectile.c index 072bedf1..57e26a75 100644 --- a/src/playerItem/playerItemFireRodProjectile.c +++ b/src/playerItem/playerItemFireRodProjectile.c @@ -5,6 +5,7 @@ #include "physics.h" #include "functions.h" #include "effects.h" +#include "playeritem.h" typedef struct { Entity base; @@ -76,7 +77,7 @@ void sub_080A310C(FireRodProjectileEntity* this) { if (sub_08008790(super, 0xc)) { DeleteThisEntity(); } - super->child = CreatePlayerItem(0x15, 1, 0, this->unk68); + super->child = CreatePlayerItem(PLAYER_ITEM_15, 1, 0, this->unk68); if (super->child != NULL) { super->child->parent = super; } diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c index 217e3db5..e3bb729a 100644 --- a/src/playerItem/playerItemGust.c +++ b/src/playerItem/playerItemGust.c @@ -4,6 +4,7 @@ #include "functions.h" #include "asm.h" #include "object.h" +#include "playeritem.h" enum { GUST_INIT, @@ -220,7 +221,7 @@ static void sub_080ACECC(GustEntity* this) { Entity* entity; if (super->type < 3 && super->child == NULL && (s32)this->unk78 >= 0 && gUnk_0812AAE8[super->type] <= this->unk78) { - entity = CreatePlayerItem(0x10, super->type + 1, 0, 0); + entity = CreatePlayerItem(PLAYER_ITEM_10, super->type + 1, 0, 0); if (entity != NULL) { entity->parent = super; super->child = entity; diff --git a/src/playerItem/playerItemShield.c b/src/playerItem/playerItemShield.c index 1b1d67b0..afe8feb1 100644 --- a/src/playerItem/playerItemShield.c +++ b/src/playerItem/playerItemShield.c @@ -4,6 +4,7 @@ #include "functions.h" #include "sound.h" #include "collision.h" +#include "playeritem.h" extern void (*const gUnk_081271D4[])(Entity*); extern u8 gUnk_081271DC[]; @@ -66,7 +67,7 @@ NONMATCH("asm/non_matching/playerItemShield/sub_080A2E00.inc", void sub_080A2E00 if ((this->contactFlags & 0x80) != 0) { if ((((this->contactFlags & 0x7f) == 0x42) && (*(char*)&this->field_0x68 == 0xe)) && ((uVar4 & 0x40) == 0)) { - pEVar1 = CreatePlayerItem(0x15, 0, 0, *(char*)&this->field_0x68); + pEVar1 = CreatePlayerItem(PLAYER_ITEM_15, 0, 0, *(char*)&this->field_0x68); this->child = pEVar1; if (pEVar1 != NULL) { pEVar1->subtimer = 1; diff --git a/src/playerUtils.c b/src/playerUtils.c index 31dbb3fc..8db4be76 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -191,7 +191,7 @@ void sub_08077698(PlayerEntity* this) { idx = 0; puVar2 = gUnk_03000B80; do { - if (puVar2->field_0x5[4] != 0) { + if (puVar2->field_0x9 != 0) { sub_080752E8(puVar2, idx); } puVar2++; @@ -248,7 +248,7 @@ bool32 sub_080777A0(void) { ((((gPlayerState.playerInput.field_0x90 & PLAYER_INPUT_ANY_DIRECTION) != 0 && ((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) && ((gPlayerState.jump_status == 0 && (gPlayerState.field_0x3[1] == 0)))))) { - gPlayerState.queued_action = 0x18; + gPlayerState.queued_action = PLAYER_ROLL; } return FALSE; } @@ -276,7 +276,7 @@ void sub_08077880(Item itemId, u32 param_2, u32 param_3) { if (((*puVar2 & param_2) != 0) || (param_3 != 0)) { item = sub_0807794C(itemId); if (item != NULL) { - item->field_0x5[4] = gUnk_0811BE48[itemId].unk0[1]; + item->field_0x9 = gUnk_0811BE48[itemId].unk0[1]; item->behaviorID = itemId; item->field_0x2[1] = param_2; } @@ -297,7 +297,7 @@ bool32 sub_080778CC(void) { item = sub_0807794C(ITEM_TRAP); if (item != NULL) { item->behaviorID = ITEM_TRAP; - item->field_0x5[4] = gUnk_0811BE48[0].unk0[0x145]; + item->field_0x9 = gUnk_0811BE48[0].unk0[0x145]; return TRUE; } else { return FALSE; @@ -309,7 +309,7 @@ ItemBehavior* sub_0807794C(Item itemId) { (((gPlayerState.flags & (PL_ROLLING | PL_CLONING)) != 0 && (ITEM_FOURSWORD < itemId)))) || ((((gPlayerState.jump_status != 0 || (gPlayerEntity.z.WORD != 0)) && (ITEM_FOURSWORD < itemId)) || (((gPlayerState.flags & PL_MINISH) != 0 && (gUnk_0811BE48[itemId].unk6[2] == 0)))))) || - ((gPlayerState.floor_type == SURFACE_SWAMP && ((gPlayerState.field_0x37 != 0 && (1 < itemId - 0x14)))))) { + ((gPlayerState.floor_type == SURFACE_SWAMP && ((gPlayerState.surfaceTimer != 0 && (1 < itemId - 0x14)))))) { return NULL; } else { u32 tmp = gUnk_0811BE48[itemId].unk0[2]; @@ -322,9 +322,9 @@ u32 sub_080779E8(void) { } ItemBehavior* sub_080779EC(u32 param_1) { - if (gUnk_03000B80[1].field_0x5[4] == 0) { + if (gUnk_03000B80[1].field_0x9 == 0) { return gUnk_03000B80 + 1; - } else if (gUnk_03000B80[2].field_0x5[4] == 0) { + } else if (gUnk_03000B80[2].field_0x9 == 0) { return gUnk_03000B80 + 2; } else { return NULL; @@ -346,7 +346,7 @@ ItemBehavior* sub_08077A48(s32 param_1) { if (gPlayerState.heldObject == 0) { u32 tmp = gPlayerState.jump_status & 0x20; if ((((gPlayerState.jump_status & 0x20) == 0)) && - (gUnk_0811BE48[param_1].unk0[1] >= gUnk_03000B80[0].field_0x5[4])) { + (gUnk_0811BE48[param_1].unk0[1] >= gUnk_03000B80[0].field_0x9)) { DeletePlayerItem(gUnk_03000B80, 0); gPlayerState.field_0x0[1] = tmp; gPlayerState.field_0x1c = tmp; @@ -358,7 +358,7 @@ ItemBehavior* sub_08077A48(s32 param_1) { } ItemBehavior* sub_08077A98(void) { - if (!(((gSave.stats.bombCount == 0) || (gPlayerState.heldObject != 0)) || (gUnk_03000B80[0].field_0x5[4] != 0))) { + if (!(((gSave.stats.bombCount == 0) || (gPlayerState.heldObject != 0)) || (gUnk_03000B80[0].field_0x9 != 0))) { return gUnk_03000B80; } else { return NULL; @@ -372,7 +372,7 @@ ItemBehavior* sub_08077AC8(void) { index = 0; pIVar1 = gUnk_03000B80; while (index < 4) { - if (pIVar1->field_0x5[4] != 0) { + if (pIVar1->field_0x9 != 0) { return NULL; } pIVar1++; @@ -424,9 +424,9 @@ void ResetPlayerItem() { } switch (gPlayerState.framestate) { - case 2: - case 3: - case 4: + case PL_STATE_SWORD: + case PL_STATE_GUSTJAR: + case PL_STATE_HOLD: gPlayerState.framestate = PL_STATE_IDLE; break; } @@ -540,7 +540,7 @@ void sub_08077D38(ItemBehavior* beh, u32 idx) { gPlayerState.field_0xa |= 8 >> idx; gPlayerState.keepFacing |= 8 >> idx; - beh->field_0x5[5] = gPlayerEntity.animationState; + beh->playerAnimationState = gPlayerEntity.animationState; if (beh->stateID == 0) { beh->stateID++; } @@ -583,7 +583,7 @@ typedef struct { void sub_08077DF4(ItemBehavior* beh, u32 animation) { beh->field_0x10 = animation; if ((animation & 0xff) > 0xb8) { - animation += beh->field_0x5[5] >> 1; + animation += beh->playerAnimationState >> 1; } gPlayerEntity.spriteIndex = (short)(animation >> 8); InitAnimationForceUpdate(&gPlayerEntity, (u8)animation); @@ -601,10 +601,10 @@ void sub_08077E3C(ItemBehavior* ent, u32 idx) { } static void sub_08077E54(ItemBehavior* beh) { - beh->field_0x5[7] = gPlayerEntity.animIndex; - beh->field_0x12[0] = gPlayerEntity.frameIndex; - beh->field_0x5[8] = gPlayerEntity.frameDuration; - beh->field_0x5[9] = gPlayerEntity.frame; + beh->playerAnimIndex = gPlayerEntity.animIndex; + beh->playerFrameIndex = gPlayerEntity.frameIndex; + beh->playerFrameDuration = gPlayerEntity.frameDuration; + beh->playerFrame = gPlayerEntity.frame; } void DeletePlayerItem(ItemBehavior* arg0, u32 idx) { @@ -630,7 +630,7 @@ void DeletePlayerItem(ItemBehavior* arg0, u32 idx) { bool32 sub_08077EC8(ItemBehavior* beh) { if ((gPlayerState.sword_state & 8) != 0) { sub_08077DF4(beh, 0x170); - beh->field_0x5[2] = 0x28; + beh->timer = 0x28; beh->stateID = 7; beh->field_0xf = 6; return TRUE; @@ -845,7 +845,7 @@ void sub_08078180(void) { } } else { if (sub_080789A8()) { - if (((gPlayerState.framestate != 0x0e))) { + if (((gPlayerState.framestate != PL_STATE_USEPORTAL))) { if ((gCarriedEntity.unk_1 == 2) && ((gCarriedEntity.unk_8)->carryFlags == 1)) { uVar1 = 8; @@ -856,7 +856,7 @@ void sub_08078180(void) { return; } } else { - if ((gPlayerState.framestate == 1) && (gPlayerState.mobility == 0)) { + if ((gPlayerState.framestate == PL_STATE_WALK) && (gPlayerState.mobility == 0)) { uVar1 = 0xc; } else { uVar1 = 0; @@ -873,18 +873,18 @@ bool32 sub_080782C0(void) { u8 tmp; Entity* entity; - if (gPlayerState.framestate == 0) { + if (gPlayerState.framestate == PL_STATE_IDLE) { tmp = gPlayerState.framestate_last; } else { tmp = gPlayerState.framestate; } switch (tmp) { - case 2: - case 3: - case 0xc: - case 0x12: - case 0x15: - case 0x16: + case PL_STATE_SWORD: + case PL_STATE_GUSTJAR: + case PL_STATE_C: + case PL_STATE_DIE: + case PL_STATE_ITEMGET: + case PL_STATE_DROWN: return FALSE; } if ((gPlayerState.field_0x27[0] | gPlayerState.swim_state) != 0) { @@ -922,11 +922,11 @@ bool32 sub_080782C0(void) { if (gSave.unk12B[0] != 0) { gUnk_03003DF0.unk_2 = gUnk_03003DF0.unk_4[3]; *(u8*)(*(int*)(gUnk_03003DF0.unk_4 + 8) + 0x39) = 2; - gPlayerState.queued_action = 7; + gPlayerState.queued_action = PLAYER_08070E9C; } else { CreateEzloHint(TEXT_INDEX(TEXT_EZLO, 0x65), 0); } - ForceSetPlayerState(0x13); + ForceSetPlayerState(PL_STATE_TALKEZLO); return TRUE; } if ((gPlayerState.playerInput.field_0x92 & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { @@ -940,8 +940,8 @@ bool32 sub_080782C0(void) { case 6: case 9: case 0xa: - gPlayerState.queued_action = 7; - ForceSetPlayerState(0x13); + gPlayerState.queued_action = PLAYER_08070E9C; + ForceSetPlayerState(PL_STATE_TALKEZLO); case 3: case 5: case 7: @@ -1132,7 +1132,7 @@ void SetPlayerItemGetState(Entity* item, u8 param_2, u8 param_3) { gPlayerState.field_0x39 = param_3; gPlayerState.field_0x3a = 0; gPlayerState.queued_action = PLAYER_ITEMGET; - gPlayerState.framestate = 0x15; + gPlayerState.framestate = PL_STATE_ITEMGET; gPlayerState.swim_state = 0; gPlayerState.field_0x14 = 1; gPlayerEntity.child = item; @@ -1147,13 +1147,13 @@ void sub_08078B48(void) { gPlayerState.field_0xa |= 0x80; gPlayerState.field_0x27[0] = 2; switch (gPlayerState.framestate) { - case 4: - case 5: - case 0x19: - case 0x1a: - case 0x1d: + case PL_STATE_HOLD: + case PL_STATE_THROW: + case PL_STATE_PUSH: + case PL_STATE_PULL: + case PL_STATE_1D: break; - case 9: + case PL_STATE_ROLL: gPlayerState.flags &= ~PL_ROLLING; // fallthrough default: @@ -1183,7 +1183,7 @@ void ClearPlayerState(void) { gPlayerState.queued_action = PLAYER_INIT; gPlayerState.field_0xd = 0; gPlayerState.field_0xe = 0; - gPlayerState.field_0x11 = 0; + gPlayerState.surfacePositionSameTimer = 0; gPlayerState.floor_type = SURFACE_NORMAL; gPlayerState.floor_type_last = SURFACE_NORMAL; gPlayerState.field_0x14 = 0; @@ -1260,12 +1260,12 @@ void ResetPlayerPosition(void) { } bool32 CheckQueuedAction(void) { - if (gPlayerState.queued_action == 0) { + if (gPlayerState.queued_action == PLAYER_INIT) { return FALSE; } else { gPlayerEntity.action = gPlayerState.queued_action; gPlayerEntity.subAction = 0; - gPlayerState.queued_action = 0; + gPlayerState.queued_action = PLAYER_INIT; DoPlayerAction(&gPlayerEntity); return TRUE; } @@ -1402,7 +1402,7 @@ void sub_080790E4(Entity* this) { gPlayerState.pushedObject--; } gPlayerState.field_0x35 = this->animationState; - gPlayerState.framestate = 0x19; + gPlayerState.framestate = PL_STATE_PUSH; if ((gPlayerState.flags & PL_NO_CAP) != 0) { gPlayerState.animation = 0x93c; } else { @@ -1464,7 +1464,7 @@ void PlayerMinishSetNormalAndCollide(void) { gPlayerState.flags &= ~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE); gPlayerState.swim_state = 0; - gPlayerState.queued_action = 0; + gPlayerState.queued_action = PLAYER_INIT; SetDefaultPriorityForKind(&gPlayerEntity); } @@ -1515,7 +1515,7 @@ u32 sub_0807953C(void) { ASM_FUNC("asm/non_matching/playerUtils/sub_08079550.inc", u32 sub_08079550(void)) void sub_08079708(Entity* this) { - gPlayerState.framestate = 0x12; + gPlayerState.framestate = PL_STATE_DIE; gPlayerState.field_0x3c = 0xff; this->flags &= ~ENT_COLLIDE; this->action = 0xa; @@ -1776,7 +1776,7 @@ void sub_08079D84(void) { } void sub_08079DCC(void) { - if (gPlayerEntity.action == 1) { + if (gPlayerEntity.action == PLAYER_NORMAL) { gPlayerState.field_0x38 = 0xa0; gPlayerState.field_0x39 = 3; gPlayerState.field_0x3a = 0; @@ -1948,7 +1948,7 @@ void DeleteClones(void) { gPlayerClones[1] = NULL; gPlayerClones[2] = NULL; gPlayerState.flags &= ~PL_CLONING; - if (((gPlayerEntity.action != 0x17) || (gPlayerState.chargeState.action != 4)) && + if (((gPlayerEntity.action != PLAYER_ROOMTRANSITION) || (gPlayerState.chargeState.action != 4)) && (gPlayerState.chargeState.action == 4 || gPlayerState.chargeState.action == 5)) { gPlayerState.chargeState.action = 1; } @@ -1978,19 +1978,19 @@ SurfaceType GetSurfaceCalcType(Entity* param_1, s32 x, s32 y) { u32 position = TILE(param_1->x.HALF.HI + (u32)x, param_1->y.HALF.HI + y); u32 tileType = GetTileTypeByPos(param_1->x.HALF.HI + x, param_1->y.HALF.HI + y, gPlayerEntity.collisionLayer); if (tileType != gPlayerState.tileType) { - gPlayerState.field_0x37 = 0; + gPlayerState.surfaceTimer = 0; } if ((tileType != gPlayerState.tileType) || (position != gPlayerState.tilePosition)) { gPlayerState.tilePosition = position; gPlayerState.tileType = tileType; - gPlayerState.field_0x11 = 0; + gPlayerState.surfacePositionSameTimer = 0; } - if (gPlayerState.field_0x11 != 0xff) { - gPlayerState.field_0x11++; + if (gPlayerState.surfacePositionSameTimer != 0xff) { + gPlayerState.surfacePositionSameTimer++; } - if (gPlayerState.field_0x37 != 0xff) { - gPlayerState.field_0x37++; + if (gPlayerState.surfaceTimer != 0xff) { + gPlayerState.surfaceTimer++; } gPlayerState.floor_type_last = gPlayerState.floor_type; tileType = GetRelativeCollisionTile(param_1, x, y); @@ -2154,7 +2154,7 @@ void sub_0807AB44(Entity* this, s32 xOffset, s32 yOffset) { } bool32 sub_0807AC54(Entity* this) { - if (gPlayerState.field_0x11 == 0) { + if (gPlayerState.surfacePositionSameTimer == 0) { return FALSE; } diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index 36d91e19..59ecd7dc 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -78,7 +78,7 @@ void sub_080AA78C(Entity* this) { if (this->subAction == 0) { animationState = (gPlayerEntity.animationState >> 1); if (animationState != this->type) { - this->gustJarState &= 0xfb; + this->gustJarState &= ~4; if (AnimationStateFlip90(animationState) != this->type) { return; } diff --git a/src/script.c b/src/script.c index a8725c7d..b59c8ef2 100644 --- a/src/script.c +++ b/src/script.c @@ -1845,7 +1845,7 @@ void ResetPlayerFlag(Entity* entity, ScriptExecutionContext* context) { gPlayerState.flags &= ~context->intVariable; } -void sub_0807F708(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_ShowNPCDialogue(Entity* entity, ScriptExecutionContext* context) { ShowNPCDialogue(entity, (Dialog*)context->intVariable); } @@ -1872,7 +1872,7 @@ void GetConditionSet(Entity* entity, ScriptExecutionContext* context) { context->intVariable = 0; } -void sub_0807F78C(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_SaleItemConfirmMessage(Entity* entity, ScriptExecutionContext* context) { u32 item = context->intVariable; u32 msg; u32 price; @@ -1886,7 +1886,7 @@ void sub_0807F78C(Entity* entity, ScriptExecutionContext* context) { gMessage.rupees = (u16)price; } -void sub_0807F7C4(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_CheckShopItemPrice(Entity* entity, ScriptExecutionContext* context) { u32 item = context->intVariable; if (context->intVariable == 0) @@ -1896,7 +1896,7 @@ void sub_0807F7C4(Entity* entity, ScriptExecutionContext* context) { gActiveScriptInfo.flags |= 1; } -void sub_0807F800(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_BuyShopItem(Entity* entity, ScriptExecutionContext* context) { u32 item = context->intVariable; u32 price; @@ -1910,7 +1910,7 @@ void sub_0807F800(Entity* entity, ScriptExecutionContext* context) { gActiveScriptInfo.flags |= 1; } -void sub_0807F83C(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_PlayerDropHeldObject(Entity* entity, ScriptExecutionContext* context) { PlayerDropHeldObject(); } @@ -1919,24 +1919,24 @@ void sub_0807F844(Entity* entity, ScriptExecutionContext* context) { sub_080809D4(); } -void sub_0807F854(Entity* entity, ScriptExecutionContext* context) { +void ScriptCommand_SetMessageValue(Entity* entity, ScriptExecutionContext* context) { u32 value; u32 idx; idx = (context->intVariable >> 0x10) & 3; value = context->intVariable & 0xffff; switch (idx) { - case 0: - case 1: + case SMV_DEFAULT: + case SMV_RUPEES: gMessage.rupees = value; break; - case 2: + case SMV_FIELD_0X14: gMessage.field_0x14 = value; break; - case 3: + case SMV_FIELD_0X18: gMessage.field_0x18 = value; break; - case 4: + case SMV_FIELD_0X1C: gMessage.field_0x1c = value; break; } @@ -1955,7 +1955,7 @@ void DoGravity(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F8E8(Entity* entity, ScriptExecutionContext* context) { - Entity* c = CreateObjectWithParent(entity, 0xA6, 0, 0); + Entity* c = CreateObjectWithParent(entity, SANCTUARY_STONE_TABLET, 0, 0); if (c != NULL) { c->parent = entity; c->field_0x86.HWORD = (context->intVariable & 0x3ff) | 0x8000; @@ -1982,8 +1982,8 @@ void sub_0807F93C(Entity* entity, ScriptExecutionContext* context) { CreateSpeechBubbleSleep(entity, (context->intVariable >> 8) & 0xff, context->intVariable & 0xff); } -void sub_0807F950(Entity* entity, ScriptExecutionContext* context) { - Entity* c = FindEntity(6, 0x56, 6, 0, 2); +void DeleteThoughtBubble(Entity* entity, ScriptExecutionContext* context) { + Entity* c = FindEntity(OBJECT, THOUGHT_BUBBLE, 6, 0, 2); if (c != NULL) DeleteEntity(c); } @@ -2021,7 +2021,7 @@ void WaitForPlayerNormal(Entity* entity, ScriptExecutionContext* context) { case PL_STATE_DROWN: case PL_STATE_HOLE: case PL_STATE_CLIMB: - case PL_STATE_1B: + case PL_STATE_SINKING: case PL_STATE_STAIRS: gActiveScriptInfo.commandSize = 0; break; @@ -2050,7 +2050,7 @@ void WaitForPlayerNormalOrTalkEzlo(Entity* entity, ScriptExecutionContext* conte case PL_STATE_DROWN: case PL_STATE_HOLE: case PL_STATE_CLIMB: - case PL_STATE_1B: + case PL_STATE_SINKING: case PL_STATE_STAIRS: gActiveScriptInfo.commandSize = 0; break; @@ -2088,11 +2088,11 @@ void sub_0807FB28(Entity* entity, ScriptExecutionContext* context) { gActiveScriptInfo.commandSize = 0; } -void sub_0807FB64(Entity* entity, ScriptExecutionContext* context) { +void SetPlayerIFrames(Entity* entity, ScriptExecutionContext* context) { gPlayerEntity.iframes = context->intVariable; } -void sub_0807FB74(Entity* entity, ScriptExecutionContext* context) { +void DisablePlayerSwimState(Entity* entity, ScriptExecutionContext* context) { gPlayerState.swim_state = 0; gPlayerEntity.collisionFlags &= ~4; } diff --git a/src/scroll.c b/src/scroll.c index f13f7cfc..41ea9204 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -157,7 +157,7 @@ NONMATCH("asm/non_matching/scroll/sub_0807FC7C.inc", void sub_0807FC7C(RoomContr } } } else { - uVar2 = (controls->origin_y + controls->height) - 0xa0; + uVar2 = (controls->origin_y + controls->height) - DISPLAY_HEIGHT; if (iVar4 < (int)uVar2) { if ((int)-controls->unk5 >= (int)uVar3) { uVar3 = -controls->unk5; @@ -333,8 +333,8 @@ void sub_08080040(RoomControls* controls) { uVar6 = 0; } iVar7 = iVar2 + controls->filler2[0] - 8; - if (0xf0 < iVar7) { - iVar7 = 0xf0; + if (DISPLAY_WIDTH < iVar7) { + iVar7 = DISPLAY_WIDTH; } temp = controls->camera_target->y.HALF.HI - controls->scroll_y; uVar5 = (temp - controls->filler2[1]) + 8; @@ -342,8 +342,8 @@ void sub_08080040(RoomControls* controls) { uVar5 = 0; } iVar3 = temp + controls->filler2[1] - 8; - if (0xa0 < iVar3) { - iVar3 = 0xa0; + if (DISPLAY_HEIGHT < iVar3) { + iVar3 = DISPLAY_HEIGHT; } gScreen.controls.window1HorizontalDimensions = ((uVar6 & 0xff) << 8) | (iVar7 & 0xff); gScreen.controls.window1VerticalDimensions = ((uVar5 & 0xff) << 8) | (iVar3 & 0xff); @@ -400,8 +400,8 @@ void sub_080801BC(RoomControls* controls) { uVar6 = 0; } iVar7 = iVar2 + controls->filler2[0]; - if (0xf0 < iVar7) { - iVar7 = 0xf0; + if (DISPLAY_WIDTH < iVar7) { + iVar7 = DISPLAY_WIDTH; } temp = controls->camera_target->y.HALF.HI - controls->scroll_y; uVar5 = (temp - controls->filler2[1]); @@ -409,8 +409,8 @@ void sub_080801BC(RoomControls* controls) { uVar5 = 0; } iVar3 = temp + controls->filler2[1]; - if (0xa0 < iVar3) { - iVar3 = 0xa0; + if (DISPLAY_HEIGHT < iVar3) { + iVar3 = DISPLAY_HEIGHT; } gScreen.controls.window1HorizontalDimensions = ((uVar6 & 0xff) << 8) | (iVar7 & 0xff); gScreen.controls.window1VerticalDimensions = ((uVar5 & 0xff) << 8) | (iVar3 & 0xff); @@ -607,7 +607,7 @@ void DoExitTransition(const ScreenTransitionData* data) { status->area_next = data->area; status->room_next = data->room; status->layer = data->playerLayer; - status->spawn_type = data->field_0xe; + status->spawn_type = data->spawn_type; status->start_anim = data->playerState; if (data->transitionSFX != SFX_NONE) { SoundReq(data->transitionSFX);