diff options
| author | theo3 <arisstephenson2@gmail.com> | 2021-12-27 17:14:52 -0800 |
|---|---|---|
| committer | theo3 <arisstephenson2@gmail.com> | 2021-12-27 17:14:52 -0800 |
| commit | 24750a6bb59eebab95a9ef0a020ba612cac908e1 (patch) | |
| tree | b242f49ec7f5eb4b0e8478cdf7e64565586d7ec9 /src | |
| parent | 079260dbd64b6d090e05b409ded30a95bf33a9e9 (diff) | |
finish player.c
Diffstat (limited to 'src')
51 files changed, 1790 insertions, 218 deletions
diff --git a/src/code_0808091C.c b/src/code_0808091C.c index ab3ceb11..2b4dceb0 100644 --- a/src/code_0808091C.c +++ b/src/code_0808091C.c @@ -55,7 +55,7 @@ u32* GetLayerByIndex(u32 param_1) { } } -void sub_08080964(u32 time, u32 magnitude) { +void InitScreenShake(u32 time, u32 magnitude) { gRoomControls.screenShakeTime = time; gRoomControls.screenShakeMagnitude = magnitude & 7; } diff --git a/src/collision.c b/src/collision.c index 3dac2783..1c22f7d6 100644 --- a/src/collision.c +++ b/src/collision.c @@ -7,6 +7,7 @@ #include "functions.h" #include "enemy.h" #include "effects.h" +#include "object.h" extern u8 gCollidableCount; extern u8 gUnk_080B3740[]; @@ -30,7 +31,7 @@ extern ColSettings gCollisionMtx[173 * 34]; extern void gDoCollision(void); u32 sub_08081420(Entity*); -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); s32 sub_08018308(Entity*, Entity*, u32, ColSettings*); void sub_08079D84(void); void sub_080180BC(Entity*, Entity*); @@ -232,7 +233,7 @@ s32 sub_08017874(Entity* a, Entity* b) { if (newDmg <= 0) newDmg = 1; v5 = ModHealth(-newDmg); - sub_0800449C(a, 122); + SoundReqClipped(a, 122); } else { v6 = b->damage; if (b->kind == 8) { @@ -248,9 +249,9 @@ s32 sub_08017874(Entity* a, Entity* b) { v5 = a->health - v6; if (a->kind == 3) { if ((a->field_0x6c.HALF.HI & 1) != 0) - sub_0800449C(a, 295); + SoundReqClipped(a, 295); else - sub_0800449C(a, 254); + SoundReqClipped(a, 254); } } if (v5 <= 0) { @@ -389,11 +390,11 @@ s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { - if ((gPlayerState.flags & (0x1 | 0x80 | 0x400 | 0x1000)) == 0) { - Entity* e = CreateObject(66, 1, 0); + if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_BURNING | 0x1000)) == 0) { + Entity* e = CreateObject(OBJECT_42, 1, 0); if (e != NULL) { e->child = org; - gPlayerState.flags |= 0x400; + gPlayerState.flags |= PL_BURNING; org->animationState = (direction ^ 0x10) >> 2; } } @@ -408,12 +409,12 @@ 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 & (0x1 | 0x80 | 0x800 | 0x1000)) == 0 && gPlayerState.playerAction == 0) { + if ((gPlayerState.flags & (PL_BUSY | PL_MINISH | PL_FROZEN | 0x1000)) == 0 && gPlayerState.queued_action == 0) { if (org->action == 1 || org->action == 24) { tgt->damage = 4; org->health = sub_08017874(org, tgt); - gPlayerState.flags = 0x800; - gPlayerState.playerAction = 13; + gPlayerState.flags = PL_FROZEN; + gPlayerState.queued_action = PLAYER_FROZEN; } } org->knockbackDuration = 12; @@ -533,7 +534,7 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) if (org == &gPlayerEntity) { if (sub_08079F8C() && #ifdef EU - (gPlayerState.flags & 0x81) == 0 && + (gPlayerState.flags & (PL_MINISH | PL_BUSY)) == 0 && #else (gPlayerState.flags & PL_MINISH) == 0 && #endif @@ -622,18 +623,18 @@ s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { if (tgt->field_0x43 == 0) { if (org == &gPlayerEntity) { - if (((sub_08079F8C() != 0) && + if (sub_08079F8C() && #ifdef EU - ((gPlayerState.flags & 0x81) == 0)) && + (gPlayerState.flags & (PL_MINISH | PL_BUSY)) == 0 && #else - ((gPlayerState.flags & 0x40080) == 0)) && + (gPlayerState.flags & (PL_MINISH | PL_ROLLING)) == 0 && #endif - (gPlayerState.swimState == 0)) { + gPlayerState.swimState == 0) { gPlayerState.field_0x1a[0] |= 0x80; gPlayerState.field_0xa |= 0x80; gPlayerState.flags |= 0x100; gPlayerState.jumpStatus = 0; - gPlayerEntity.flags &= ~0x80; + COLLISION_OFF(&gPlayerEntity); gPlayerEntity.spriteRendering.b3 = tgt->spriteRendering.b3; gPlayerEntity.spriteOrientation.flipY = tgt->spriteOrientation.flipY; gPlayerEntity.iframes = 0xff; @@ -749,7 +750,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } } else if (org->id == 3) { if (settings->_9) { - sub_0800449C(tgt, 254); + SoundReqClipped(tgt, 254); } } else if (org->id == 5) { gPlayerEntity.iframes = 0x80; diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index b6988f6c..de27657c 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -213,7 +213,7 @@ void sub_08021AD8(Entity* this) { } void sub_08021B64(Entity* this) { - if (gPlayerState.flags & 4) { + if (gPlayerState.flags & PL_DROWNING) { this->action = 3; this->z.WORD = 0; InitializeAnimation(this, 2); diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 912f0f61..7102f85d 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -21,7 +21,7 @@ void sub_08037A14(); extern void sub_0804A4E4(Entity*, Entity*); extern Entity* sub_08049DF4(u32); u32 sub_0804A044(Entity*, Entity*, u32); -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern void (*const gGibdo[6])(Entity*); extern void (*const gUnk_080CF2AC[9])(Entity*); @@ -347,8 +347,8 @@ void sub_08037A58(Entity* this) { } void sub_08037ACC(Entity* this) { - gPlayerState.flags &= 0xFFFFFEFF; - gPlayerEntity.flags |= 0x80; + gPlayerState.flags &= ~0x100; + COLLISION_ON(&gPlayerEntity); gPlayerEntity.iframes = 0x1e; gPlayerEntity.knockbackDirection = DirectionFromAnimationState(this->animationState); gPlayerEntity.knockbackDuration = 4; @@ -359,7 +359,7 @@ void sub_08037B10(Entity* this) { u32 h; gPlayerEntity.iframes = 0xc; h = ModHealth(-8); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); if (h == 0) { sub_08037A58(this); this->field_0x76.HALF.LO = 0xf0; diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 494b577b..9539b36d 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -186,7 +186,7 @@ void sub_0802BE18(Entity* this) { void sub_0802BE48(Entity* this) { if (!sub_080AEFE0(this)) { sub_0802C218(this); - sub_08080964(8, 0); + InitScreenShake(8, 0); } else { GetNextFrame(this); sub_0802C1CC(this); diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index f391c5ee..bb9e6b76 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -11,7 +11,7 @@ extern void (*const gUnk_080D0418[6])(Entity*); extern void (*const gUnk_080D0430[3])(Entity*); extern void (*const gUnk_080D043C[3])(Entity*); -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern void sub_0803CE14(Entity*); extern void sub_0803CE3C(Entity*); extern void sub_08079D84(void); @@ -56,7 +56,7 @@ void sub_0803CD40(Entity* this) { ModHealth(-2); - sub_0800449C(&gPlayerEntity, 122); + SoundReqClipped(&gPlayerEntity, 122); sub_08079D84(); sub_0803CE3C(this); diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index 2adfed33..584dd185 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -20,7 +20,7 @@ void sub_0803B798(void); void sub_0803BA8C(Entity*, u32); void sub_0803B724(Entity*); -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); void sub_0803A170(Entity*); void sub_0803A188(Entity*); @@ -434,7 +434,7 @@ void sub_0803A740(Entity* this) { this->actionDelay = 10; this->parent->field_0x7c.BYTES.byte1 |= 0x40; sub_0803B8E8(this, 0x13); - sub_08080964(10, 0); + InitScreenShake(10, 0); SoundReq(SFX_158); } } @@ -713,7 +713,7 @@ void sub_0803ACC0(Entity* this) { this->z.HALF.HI = 0; this->actionDelay = 0xc; this->subAction = 3; - sub_08080964(8, 0); + InitScreenShake(8, 0); SoundReq(SFX_158); sub_0803B804(this); } @@ -735,7 +735,7 @@ void sub_0803ACC0(Entity* this) { this->z.HALF.HI = 0; this->action = 0x1a; this->actionDelay = 0x3c; - sub_08080964(0x1e, 0); + InitScreenShake(0x1e, 0); SoundReq(SFX_158); sub_0803B804(this); return; @@ -859,7 +859,7 @@ void sub_0803AFE0(Entity* this) { this->actionDelay = 0xf0; *(u8*)&this->cutsceneBeh = 3; this->z.HALF.HI = 0; - sub_08080964(0xa0, 0); + InitScreenShake(0xa0, 0); SoundReq(SFX_158); } } @@ -931,7 +931,7 @@ void sub_0803B144(Entity* this) { this->action = 0x2a; InitializeAnimation(this, 0x16); sub_0803B8E8(this, 0x14); - sub_08080964(8, 0); + InitScreenShake(8, 0); } } @@ -1238,7 +1238,7 @@ void sub_0803B798(void) { void sub_0803B804(Entity* this) { gPlayerEntity.iframes = 30; ModHealth(-4); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); } void sub_0803B824(Entity* this) { diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index 553d5053..2b59e960 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -320,7 +320,7 @@ void sub_080342C8(Entity* this) { this->field_0x7c.HALF.HI = 0x708; this->field_0x7c.BYTES.byte1 = 0; this->field_0x80.HALF.HI = 0; - sub_08080964(0x1e, 0); + InitScreenShake(0x1e, 0); SoundReq(SFX_1A1); } } diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index ed28d6c8..64a25711 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -195,7 +195,7 @@ void sub_08034F70(Entity* this) { void sub_08034FA0(Entity* this) { if (0 < this->iframes) { this->child->iframes = this->iframes; - sub_08080964(0xc, 1); + InitScreenShake(0xc, 1); } switch (this->type2) { case 0: diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index 9ffd49fa..3a0425ef 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -1,7 +1,7 @@ #include "enemy.h" #include "functions.h" -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern bool32 sub_08023A38(u32); extern void sub_08023990(Entity*, u32, u32); extern void sub_08023A88(Entity*, u32); @@ -263,7 +263,7 @@ void sub_0802351C(Entity* this) { if (this->field_0x7c.BYTES.byte3 == 0) { if (this->type2 == 0) { gPlayerEntity.animationState = this->animationState & 7; - gPlayerState.flags |= 0x80000; + gPlayerState.flags |= PL_TRAPPED; PositionRelative(this, &gPlayerEntity, 0, gUnk_080CBC90[this->animationState & 7] << 0x10); gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7]; } @@ -398,14 +398,14 @@ void sub_08023894(Entity* this) { this->parent->field_0x7c.BYTES.byte3 = 1; InitializeAnimation(this, this->animationState); if (this->parent->type2 == 0) { - gPlayerState.flags |= 0x200000; + gPlayerState.flags |= PL_RELEASED; gPlayerEntity.x.HALF.HI = this->x.HALF.HI; gPlayerEntity.y.HALF.HI = this->y.HALF.HI; gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(*(Entity**)&this->field_0x74, this)); gPlayerEntity.animationState = gPlayerEntity.direction >> 2; gPlayerEntity.iframes = 12; ModHealth(-0x10); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); } } } diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 23dca6d4..fb16b706 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -811,7 +811,7 @@ void OctorokBoss_Action1_ChargeAttack(Entity* this) { this->knockbackDirection = this->direction ^ 0x10; GET_HELPER(this)->fallingStonesTimer += 0x3c; OctorokBoss_SetAttackTimer(this); - sub_08080964(0x3c, 0); + InitScreenShake(0x3c, 0); SoundReq(SFX_158); SoundReq(SFX_14C); } @@ -946,7 +946,7 @@ void OctorokBoss_ExecuteAttackVacuum(Entity* this) { } } } else { - gPlayerState.flags &= 0xfffff7ff; + gPlayerState.flags &= ~PL_FROZEN; } } } @@ -1077,7 +1077,7 @@ void OctorokBoss_Burning_SubAction1(Entity* this) { this->field_0x46 = 0x200; this->knockbackDirection = this->direction ^ 0x10; GET_HELPER(this)->fallingStonesTimer += 0x1e; - sub_08080964(0x1e, 0); + InitScreenShake(0x1e, 0); SoundReq(SFX_158); SoundReq(SFX_14C); } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 54f43381..fc987dd7 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -5,7 +5,7 @@ #include "save.h" extern u32 sub_080002E0(u16, u32); -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern u32 sub_08049F1C(Entity*, Entity*, u32); extern u32 PlayerInRange(Entity*, u32, u32); extern void sub_080AEFB4(Entity*); @@ -809,7 +809,7 @@ NONMATCH("asm/non_matching/pesto/sub_08024E4C.inc", void sub_08024E4C(Entity* th ResetPlayer(); gPlayerState.flags |= 0x100; gPlayerState.field_0xa |= 0x80; - gPlayerState.playerAction = 0xe; + gPlayerState.queued_action = PLAYER_0807204C; gPlayerState.field_0x38 = 0x14; gPlayerState.field_0x39 = 1; *(u8*)&gPlayerState.field_0x3a = 0; @@ -821,7 +821,7 @@ NONMATCH("asm/non_matching/pesto/sub_08024E4C.inc", void sub_08024E4C(Entity* th this->field_0x86.HALF.HI++; player->iframes = 8; ModHealth(-2); - sub_0800449C(player, 0x7a); + SoundReqClipped(player, 0x7a); } } } @@ -830,10 +830,10 @@ END_NONMATCH void sub_08024F50(Entity* this) { gPlayerState.field_0xa = 0; - gPlayerState.flags &= 0xfffffeff; + gPlayerState.flags &= ~0x100; CopyPosition(this, &gPlayerEntity); gPlayerEntity.action = 1; - gPlayerEntity.flags |= 0x80; + COLLISION_ON(&gPlayerEntity); gPlayerEntity.iframes = -0x3c; gPlayerEntity.direction = gPlayerEntity.animationState << 2; gPlayerEntity.speed = 0; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 926648bf..ee274ac7 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -233,7 +233,7 @@ void sub_080296C8(Entity* this) { void sub_080296D8(Entity* this) { gPlayerState.jumpStatus = 0x41; - gPlayerState.flags &= 0xffffffef; + gPlayerState.flags &= ~0x10; gPlayerEntity.flags |= 0x80; gPlayerEntity.zVelocity = 0x18000; gPlayerEntity.iframes = 0xa6; diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index c8f97752..f3ccf3bb 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -662,7 +662,7 @@ void VaatiRebornEnemyType1PreAction(Entity* this) { } if (0 < this->iframes) { SoundReq(0x127); - sub_08080964(0xc, 1); + InitScreenShake(0xc, 1); if (this->actionDelay == 0) this->actionDelay = 0x48; } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index c9198d08..8c80bbbd 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -266,7 +266,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { this->actionDelay = 0xc0; COLLISION_ON(this); SoundReq(SFX_14C); - sub_08080964(0x14, 4); + InitScreenShake(0x14, 4); break; case 1: if (--this->actionDelay == 0) { @@ -321,7 +321,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { this->field_0x86.HALF.LO = 0; sub_080408EC(this); SoundReq(SFX_14C); - sub_08080964(0x1e, 4); + InitScreenShake(0x1e, 4); } else { if (this->field_0xf != 0) { if (--this->field_0xf == 0) { @@ -399,7 +399,7 @@ void VaatiTransfiguredType0Action4(Entity* this) { this->field_0xf = 1; } SoundReq(SFX_14C); - sub_08080964(0x1e, 4); + InitScreenShake(0x1e, 4); break; case 2: if (--this->actionDelay == 0) { @@ -1069,7 +1069,7 @@ void sub_080409B0(Entity* this) { } } else { if (((this->bitfield & 0x80) != 0) && (0 < this->iframes)) { - sub_08080964(0xc, 1); + InitScreenShake(0xc, 1); SoundReq(SFX_BOSS_HIT); } if ((this->bitfield == 0x8a) && (gPlayerState.field_0xa0[0] == 5)) { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index d216ba7f..eef8e73e 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -475,7 +475,7 @@ void VaatiWrathType0ActionB(Entity* this) { this->actionDelay = 0xf0; this->health = 8; this->hitType = 0x38; - sub_08080964(0x14, 0); + InitScreenShake(0x14, 0); InitAnimationForceUpdate(this, 6); InitializeAnimation(((VaatiWrathHeapStruct*)this->myHeap)->type2, 0x16); } @@ -709,7 +709,7 @@ void sub_08041E78(Entity* this) { fx->x.HALF.HI += *temp++; fx->y.HALF.HI += *temp; fx->spritePriority.b0 = 3; - sub_08080964(4, 0); + InitScreenShake(4, 0); } } } diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 111e4f04..6b399d2d 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -32,7 +32,7 @@ void sub_08033564(Entity* this) { this->spriteSettings.draw = FALSE; COLLISION_OFF(this); this->field_0x7c.HALF.LO = 0x27c; - gPlayerState.flags |= 0x4000; + gPlayerState.flags |= PL_DRUGGED; gSave.stats.effect = this->type + 1; gSave.stats.effectTimer = 600; if (this->type == 0) { diff --git a/src/enemyUtils.c b/src/enemyUtils.c index 6d8acd97..956ba639 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -1,6 +1,7 @@ #include "entity.h" #include "definitions.h" #include "functions.h" +#include "object.h" extern EnemyDefinition gEnemyDefinitions[]; @@ -46,7 +47,7 @@ bool32 EnemyInit(Entity* this) { if ((this->field_0x6c.HALF.HI & 0x20) != 0) { u32 uVar4 = gUnk_080D3E74[this->id >> 3] >> ((this->id & 7) << 1) & 3; if (uVar4 != 0) { - Entity* object = CreateObject(0xa9, uVar4 - 1, 0); + Entity* object = CreateObject(OBJECT_A9, uVar4 - 1, 0); if (object != NULL) { object->actionDelay = this->flags; object->field_0xf = this->spriteSettings.draw; diff --git a/src/interrupts.c b/src/interrupts.c index 0e42d94d..c2855c46 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -21,7 +21,7 @@ extern u16* gUnk_0200B650; extern u8 gUpdateVisibleTiles; extern u8 gUnk_03003DF0[]; extern u8 gUnk_03003BE0; -extern Entity* gUnk_03004040[3]; +extern Entity* gPlayerClones[3]; extern u16 gUnk_080B2CD8[]; extern u32 gUnk_03000FBC; @@ -181,16 +181,16 @@ void WaitForNextFrame(void) { void PlayerUpdate(Entity* this) { if (gSave.stats.effect != 0) - gPlayerState.flags |= 0x4000; + gPlayerState.flags |= PL_DRUGGED; else - gPlayerState.flags &= ~0x4000; + gPlayerState.flags &= ~PL_DRUGGED; if (CheckDontUpdate(this) == 0) { - if ((gPlayerState.flags & 0x80000) != 0) { + if (gPlayerState.flags & PL_TRAPPED) { sub_08077B20(); - if ((gPlayerState.flags & 0x200000) != 0) { - gPlayerState.playerAction = PLAYER_ROLL; - gPlayerState.flags &= ~0x80000; + if (gPlayerState.flags & PL_RELEASED) { + gPlayerState.queued_action = PLAYER_ROLL; + gPlayerState.flags &= ~PL_TRAPPED; gPlayerState.hurtBlinkSpeed = 240; COLLISION_ON(this); } else { @@ -223,10 +223,10 @@ void HandlePlayerLife(Entity* this) { if ((gPlayerEntity.bitfield & 0x80) && (gPlayerEntity.iframes > 0)) SoundReq(SFX_86); - gPlayerState.flags &= ~(0x2000000 | 0x200); + gPlayerState.flags &= ~(0x2000000 | PL_FALLING); if (gPlayerState.flags & PL_BURNING) ResetPlayer(); - if ((gPlayerState.flags & 0x400000) && !gPlayerState.field_0xa0[0]) + if ((gPlayerState.flags & PL_CLONING) && !gPlayerState.field_0xa0[0]) sub_0807A108(); if (sub_08079B24() == 0) sub_08079708(this); @@ -300,7 +300,7 @@ void sub_080171F0(void) { gPlayerState.flags &= ~2; sub_080028E0(&gPlayerEntity); - if (gPlayerState.flags & 0x400000) + if (gPlayerState.flags & PL_CLONING) gUnk_0200AF00.filler25[10] = 1; sub_08078180(); @@ -315,13 +315,13 @@ void sub_080171F0(void) { gPlayerState.field_0x3f = 0; sub_0807B0C8(); - if (gPlayerState.flags & 0x400000) - gUnk_03004040[0]->spriteOffsetY = gUnk_03004040[1]->spriteOffsetY = gUnk_03004040[2]->spriteOffsetY = 0; + if (gPlayerState.flags & PL_CLONING) + gPlayerClones[0]->spriteOffsetY = gPlayerClones[1]->spriteOffsetY = gPlayerClones[2]->spriteOffsetY = 0; - if (gPlayerEntity.action == PLAYER_08072F34) - gPlayerState.flags |= 0x20000000; + if (gPlayerEntity.action == PLAYER_CLIMB) + gPlayerState.flags |= PL_CLIMBING; else - gPlayerState.flags &= ~0x20000000; + gPlayerState.flags &= ~PL_CLIMBING; sub_0807A8D8(&gPlayerEntity); if (gPlayerState.jumpStatus & 0xc0) @@ -10,3 +10,7 @@ void (*const gItemFunctions[])(ItemBehavior*, u32) = { ItemPegasusBoots, ItemDebug, ItemOcarina, ItemDebug, ItemDebug, ItemDebug, ItemTryPickupObject, ItemJarEmpty, ItemJarEmpty, ItemJarEmpty, ItemJarEmpty, }; + +void sub_080752E8(ItemBehavior* behavior, u32 arg1) { + gItemFunctions[behavior->behaviorID](behavior, arg1); +} diff --git a/src/item/itemBoomerang.c b/src/item/itemBoomerang.c index b443d6fb..a5505136 100644 --- a/src/item/itemBoomerang.c +++ b/src/item/itemBoomerang.c @@ -3,7 +3,7 @@ extern void (*const gUnk_0811BD78[])(ItemBehavior*, u32); -extern void sub_08078F60(void); +extern void ResetPlayerVelocity(void); void ItemBoomerang(ItemBehavior* this, u32 arg1) { gUnk_0811BD78[this->stateID](this, arg1); @@ -24,7 +24,7 @@ void sub_08075D2C(ItemBehavior* this, u32 arg1) { void sub_08075D88(ItemBehavior* this, u32 arg1) { if ((gPlayerState.field_0x3[1] & 0x80) == 0) { if (((this->behaviorID == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->field_0x5[9] & 2) != 0)) { - sub_08078F60(); + ResetPlayerVelocity(); return; } UpdateItemAnim(this); diff --git a/src/item/itemLantern.c b/src/item/itemLantern.c index 2903b2de..88245ad8 100644 --- a/src/item/itemLantern.c +++ b/src/item/itemLantern.c @@ -1,6 +1,7 @@ #include "item.h" #include "functions.h" #include "audio.h" +#include "object.h" extern void (*const gUnk_0811BD68[])(ItemBehavior*, u32); @@ -20,22 +21,21 @@ void sub_08075A0C(ItemBehavior* this, u32 arg1) { u32 itemSlot; s8* tmp; itemSlot = IsItemEquipped(this->behaviorID); - if (gPlayerState.heldObject != 0 || gPlayerState.playerAction == 0x18 || gPlayerState.jumpStatus != 0 || + if (gPlayerState.heldObject != 0 || gPlayerState.queued_action == PLAYER_ROLL || gPlayerState.jumpStatus != 0 || gPlayerState.item != NULL || (gPlayerState.flags & PL_MINISH) != 0) { ForceEquipItem(0xf, itemSlot); - gPlayerState.flags &= 0xff7fffff; + gPlayerState.flags &= ~PL_USE_LANTERN; ForceEquipItem(0xf, itemSlot); sub_08077E78(this, arg1); } else { - this->field_0x5[4] |= 0x80; sub_08077D38(this, arg1); sub_08077BD4(this); sub_0806F948(&gPlayerEntity); this->behaviorID = 0x10; - ForceEquipItem(0x10, itemSlot); + ForceEquipItem(ITEM_LANTERN_ON, itemSlot); tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6]; - object = CreateObjectWithParent(&gPlayerEntity, 0x45, 1, 0); + object = CreateObjectWithParent(&gPlayerEntity, OBJECT_45, 1, 0); if (object != NULL) { object->spriteVramOffset = gPlayerEntity.spriteVramOffset; object->x.HALF.HI = tmp[0] + object->x.HALF.HI; @@ -54,7 +54,7 @@ void sub_08075ADC(ItemBehavior* this, u32 arg1) { sub_08079D48() == 0) { this->field_0xf = 0; this->stateID += 1; - gPlayerState.flags |= 0x800000; + gPlayerState.flags |= PL_USE_LANTERN; bVar1 = 8 >> arg1; gPlayerState.field_0x3[1] = gPlayerState.field_0x3[1] & ~((bVar1 << 4) | bVar1); bVar1 = ~bVar1; @@ -77,11 +77,11 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { itemSlot = IsItemEquipped(this->behaviorID); if (!(((sub_08077F10(this) == 0) && (itemSlot < 2)) || (gPlayerState.jumpStatus != 0))) { ForceEquipItem(0xf, itemSlot); - gPlayerState.flags &= 0xff7fffff; + gPlayerState.flags &= ~PL_USE_LANTERN; sub_08077E78(this, arg1); SoundReq(SFX_ITEM_LANTERN_OFF); } else { - if (((gPlayerState.playerAction != 0x18) && (gPlayerEntity.frameIndex < 0x37)) && + if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.frameIndex < 0x37)) && ((u16)gPlayerEntity.spriteIndex == 6)) { tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6]; @@ -91,7 +91,7 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { this->field_0xf = 0xf; this->stateID += 1; gPlayerEntity.field_0x7a.HWORD = 2; - object = CreateObjectWithParent(&gPlayerEntity, 0x45, 1, 0); + object = CreateObjectWithParent(&gPlayerEntity, OBJECT_45, 1, 0); if (object != NULL) { object->spriteVramOffset = gPlayerEntity.spriteVramOffset; object->x.HALF.HI = tmp[0] + object->x.HALF.HI; diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c index 7b705446..1f418627 100644 --- a/src/item/itemOcarina.c +++ b/src/item/itemOcarina.c @@ -4,7 +4,7 @@ extern void (*const gOcarinaStates[4])(ItemBehavior*, u32); -extern void sub_08078F60(void); +extern void ResetPlayerVelocity(void); extern void SetPlayerEventPriority(void); extern void CreateBird(void); @@ -16,7 +16,7 @@ void ItemOcarina(ItemBehavior* this, u32 arg1) { } void OcarinaUse(ItemBehavior* this, u32 arg1) { - if (gPlayerState.playerAction == 0x18) { + if (gPlayerState.queued_action == PLAYER_ROLL) { sub_08077E78(this, arg1); } else { this->field_0x5[4] |= 0xf; @@ -24,12 +24,12 @@ void OcarinaUse(ItemBehavior* this, u32 arg1) { gPlayerEntity.spriteSettings.flipX = 0; gPlayerEntity.flags &= 0x7f; gPlayerEntity.field_0x7a.HWORD = 2; - gPlayerState.flags |= 0x10000000; + gPlayerState.flags |= PL_USE_OCARINA; gPlayerState.field_0x27[0] = -1; gUnk_02034490[0] = 1; gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa; gPlayerState.keepFacing = (8 >> arg1) | gPlayerState.keepFacing; - sub_08078F60(); + ResetPlayerVelocity(); sub_08077D38(this, arg1); SoundReq(SFX_216); SetPlayerEventPriority(); @@ -41,7 +41,7 @@ NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBe UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerEntity.flags |= 0x80; - gPlayerState.flags &= 0xefffffff; + gPlayerState.flags &= ~PL_USE_OCARINA; gPlayerState.field_0x27[0] = 0; gUnk_02034490[0] = 0; CreateBird(); diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index a12e31f3..e60d820c 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -24,7 +24,7 @@ void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { SoundReq(SFX_PLY_LAND); } if (((gPlayerState.flags & PL_MINISH) == 0) && ((this->field_0x5[2] & 7) == 0)) { - if (gPlayerState.floor_type == SURFACE_11) { + if (gPlayerState.floor_type == SURFACE_SWAMP) { if (gPlayerEntity.spriteOffsetY == 0) { CreateFx(&gPlayerEntity, FX_GREEN_SPLASH, 0); } diff --git a/src/item/itemSword.c b/src/item/itemSword.c index 45441f72..37a91ef4 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -72,9 +72,9 @@ void sub_0807564C(ItemBehavior* this, u32 arg1) { void sub_08075694(ItemBehavior* this, u32 arg1) { this->field_0x5[2] = 1; - if ((gPlayerState.flags & 0x8000000) != 0) { - gPlayerState.flags &= 0xf7ffffff; - gPlayerState.flags &= 0xfffbffff; + if (gPlayerState.flags & PL_SWORD_THRUST) { + gPlayerState.flags &= ~PL_SWORD_THRUST; + gPlayerState.flags &= ~PL_ROLLING; sub_08077DF4(this, 300); } else { gPlayerState.field_0xab = 1; @@ -86,7 +86,7 @@ void sub_08075694(ItemBehavior* this, u32 arg1) { gPlayerEntity.hurtType = 0x1e; gPlayerState.field_0x1a[1] |= 0x40; gPlayerState.field_0x1a[1] &= 0xdf; - if ((gPlayerState.field_0xa0[0] == 0x04) && ((gPlayerState.flags & 0x400000) == 0)) { + if ((gPlayerState.field_0xa0[0] == 0x04) && ((gPlayerState.flags & PL_CLONING) == 0)) { gPlayerState.field_0xa0[0] = 0x01; sub_0807A108(); } @@ -124,7 +124,7 @@ void sub_080759B8(ItemBehavior* this, u32 arg1) { if ((gPlayerState.flags & PL_MINISH) == 0) { gPlayerEntity.hurtType = 0; } - gPlayerState.flags &= 0xf7ffffff; + gPlayerState.flags &= ~PL_SWORD_THRUST; gPlayerState.field_0x1a[1] = 0; gPlayerState.item = NULL; sub_08077E78(this, arg1); diff --git a/src/manager/manager15.c b/src/manager/manager15.c index b73beba0..8dc10a8f 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -315,8 +315,8 @@ void sub_0805A76C(Manager15* this) { } void sub_0805A7E4(Manager15* this) { - if (gPlayerState.playerAction != PLAYER_WARP) { - gPlayerState.playerAction = PLAYER_WARP; + if (gPlayerState.queued_action != PLAYER_WARP) { + gPlayerState.queued_action = PLAYER_WARP; gPlayerState.field_0x38 = 0; gPlayerState.field_0x39 = 0; } diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c index dc09ea5f..b188ef08 100644 --- a/src/manager/manager1A.c +++ b/src/manager/manager1A.c @@ -137,7 +137,7 @@ void sub_0805B168(Manager1A* this) { u32 sub_0805B1CC(Manager1A* this) { u32 re = 0; if (CheckPlayerProximity(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) { - if ((gPlayerState.flags & 0x4) && (gPlayerState.flags & 0x1)) { + if ((gPlayerState.flags & PL_DROWNING) && (gPlayerState.flags & PL_BUSY)) { gPlayerState.flags |= 0x8000; } else if (gPlayerState.flags & 0x8000) { re = 1; diff --git a/src/manager/manager34.c b/src/manager/manager34.c index 6ca4773c..a3f83418 100644 --- a/src/manager/manager34.c +++ b/src/manager/manager34.c @@ -39,11 +39,11 @@ void sub_0805DBF0(Manager34* this) { sub_0805DC70(); } else { if (this->field_0x20 == 0x78) { - sub_08080964(0x78, 2); + InitScreenShake(0x78, 2); } else if (this->field_0x20 == 0xd2) { - sub_08080964(0x5a, 1); + InitScreenShake(0x5a, 1); } else if (this->field_0x20 == 0x12c) { - sub_08080964(0x5a, 0); + InitScreenShake(0x5a, 0); } if (this->field_0x20 < 0x78) { diff --git a/src/manager/managerA.c b/src/manager/managerA.c index fbaf30ff..1d68eadc 100644 --- a/src/manager/managerA.c +++ b/src/manager/managerA.c @@ -117,7 +117,7 @@ static u32 PlayerStateValid(ManagerA* this) { static void sub_08058514(ManagerA* this) { switch (this->manager.unk_0d) { case 1: - if (gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_USE_PORTAL | 0x1210)) + if (gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_USE_PORTAL | PL_FALLING | 0x1010)) return; if (gPlayerEntity.z.HALF.HI != 0) return; diff --git a/src/manager/managerC.c b/src/manager/managerC.c index 2583ce98..1dae3225 100644 --- a/src/manager/managerC.c +++ b/src/manager/managerC.c @@ -156,7 +156,7 @@ void sub_08058A04(ManagerC* this) { s32 tmp2 = gPlayerEntity.y.HALF.HI - gRoomControls.roomOriginY; if ((this->unk_20 - 0x118 < 0xDu) && CheckGlobalFlag(LV1TARU_OPEN) && (tmp - 0x6d < 0x17u) && (tmp2 - 0x45 < 0x17u) && (gPlayerEntity.z.HALF.HI == 0)) { - gPlayerState.playerAction = 3; + gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x38 = 0; gPlayerEntity.x.HALF.HI = gRoomControls.roomOriginX + 0x78; gPlayerEntity.y.HALF.HI = gRoomControls.roomOriginY + 0x50; diff --git a/src/npc/carlov.c b/src/npc/carlov.c index dd25013a..83402406 100644 --- a/src/npc/carlov.c +++ b/src/npc/carlov.c @@ -15,7 +15,7 @@ void Carlov(Entity* this) { if ((this->frame & 0x10) != 0) { this->frame = this->frame & 0xef; EnqueueSFX(0x104); - sub_08080964(0x10, 0); + InitScreenShake(0x10, 0); } if ((this->frame & 0x20) != 0) { this->frame = this->frame & 0xdf; diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index 884a4289..b621b86f 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -97,7 +97,7 @@ void sub_08067534(Entity* this) { } } EnqueueSFX(0x14c); - sub_08080964(0x28, 4); + InitScreenShake(0x28, 4); } void sub_0806757C(Entity* this) { diff --git a/src/npc/rem.c b/src/npc/rem.c index d3ab32d0..cef24033 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -131,7 +131,7 @@ void sub_0806A550(Entity* this) { } else { if (this->frame == 1) { this->frame = 0; - sub_08080964(8, 2); + InitScreenShake(8, 2); gActiveScriptInfo.unk_00 |= 0x100; SoundReq(SFX_CHEST_OPEN); } diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 4cb5a1ae..4631a31e 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -85,7 +85,7 @@ void sub_08066D94(Entity* this) { DeleteThisEntity(); } -void sub_08066DE4(Entity* this) { +void SetZeldaFollowTarget(Entity* this) { Entity* pEVar1; pEVar1 = DeepFindEntityByID(7, 0x2E); diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index ffe11cd9..c7f21f7c 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -1,6 +1,6 @@ #include "object.h" -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern u32 sub_0806FC80(Entity*, Entity*, s32); extern void sub_0809CDF0(Entity*); @@ -61,7 +61,7 @@ void sub_0809CD0C(Entity* this) { sub_0806FC80(this, &gPlayerEntity, 4)) { this->field_0xf++; ModHealth(-2); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); gPlayerEntity.iframes = 16; gPlayerEntity.knockbackDirection = 16; gPlayerEntity.knockbackDuration = 12; diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index 5e7f87eb..9118cb67 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -67,7 +67,7 @@ void sub_08098DC4(Entity* this) { sub_08004542(&gPlayerEntity); gPlayerEntity.collisionLayer = 1; ResolveEntityOnTop(this, &gPlayerEntity); - gPlayerState.playerAction = 0x1f; + gPlayerState.queued_action = PLAYER_PARACHUTE; gPlayerState.field_0x34[4] = 1; gPlayerState.field_0x34[5] = this->type2; this->action = 4; diff --git a/src/object/book.c b/src/object/book.c index 9a99b928..25faf3ab 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -92,8 +92,8 @@ void sub_0809B4A8(Entity* this) { this->direction = 16; gPlayerState.pushedObject = 0x9e; - gPlayerState.playerAction = 5; - gPlayerState.flags |= 1; + gPlayerState.queued_action = PLAYER_PUSH; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; diff --git a/src/object/button.c b/src/object/button.c index 76b48da8..1db2cafb 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -138,7 +138,7 @@ u32 sub_08081D28(Entity* this) { } extern u32 sub_080002E0(u32, u32); -extern Entity* gUnk_03004040[3]; +extern Entity* gPlayerClones[3]; u32 sub_08081E0C(Entity*); Entity* sub_08081D74(Entity* this) { @@ -152,13 +152,13 @@ Entity* sub_08081D74(Entity* this) { ent = &gPlayerEntity; } } else { - if (gPlayerState.flags & 0x400000) { - if (EntityInRectRadius(this, gUnk_03004040[0], 5, 6)) { - ent = gUnk_03004040[0]; - } else if (EntityInRectRadius(this, gUnk_03004040[1], 5, 6)) { - ent = gUnk_03004040[1]; - } else if (EntityInRectRadius(this, gUnk_03004040[2], 5, 6)) { - ent = gUnk_03004040[2]; + if (gPlayerState.flags & PL_CLONING) { + if (EntityInRectRadius(this, gPlayerClones[0], 5, 6)) { + ent = gPlayerClones[0]; + } else if (EntityInRectRadius(this, gPlayerClones[1], 5, 6)) { + ent = gPlayerClones[1]; + } else if (EntityInRectRadius(this, gPlayerClones[2], 5, 6)) { + ent = gPlayerClones[2]; } } } @@ -272,8 +272,8 @@ void sub_08081FF8(Entity* this) { direction = GetFacingDirection(this->child, this); sub_080044AE(this->child, 0x200, direction); for (i = 0; i < 3; i++) { - if (gUnk_03004040[i]) { - sub_080044AE(gUnk_03004040[i], 0x200, direction); + if (gPlayerClones[i]) { + sub_080044AE(gPlayerClones[i], 0x200, direction); } } } diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 78d8c881..c062d75b 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -17,7 +17,6 @@ void sub_080813BC(Entity*); void sub_080810FC(Entity*); bool32 CheckShouldPlayItemGetCutscene(Entity*); -extern u32 sub_080002D0(Entity*); extern u32 sub_080177A0(Entity*, Entity*); extern void GiveItem(u32, u32); diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index 8adb45e7..89142cbc 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -108,7 +108,7 @@ void sub_0808C01C(Entity* this, u32 r1) { type = 2; gArea.curPortalType = type; if (r1 == 1) { - if (((gPlayerState.flags & 0x20) != 0) && (gPlayerState.jumpStatus == 0)) { + if ((gPlayerState.flags & PL_USE_PORTAL) && (gPlayerState.jumpStatus == 0)) { gArea.field_0x18 = 2; } else { if (sub_08057810() != 0) { diff --git a/src/object/minecart.c b/src/object/minecart.c index 8f5e9360..619e1a7b 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -55,7 +55,6 @@ void sub_080916EC(Entity* this) { } void sub_080917DC(Entity* this) { - if ((this->bitfield & 0x7f) == 0x1d) { this->zVelocity = 0x2a000; this->action = 7; @@ -63,8 +62,8 @@ void sub_080917DC(Entity* this) { SoundReq(SFX_13B); } else { if (sub_0800445C(this) != 0) { - if (((gPlayerState.flags & 0x40080) == 0) && (gPlayerState.field_0x1c == 0) && - (gPlayerState.heldObject == 0) && (gPlayerState.jumpStatus == 0)) { + if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.field_0x1c || + gPlayerState.heldObject || gPlayerState.jumpStatus)) { this->actionDelay++; } else { this->actionDelay = 0; @@ -73,13 +72,13 @@ void sub_080917DC(Entity* this) { this->actionDelay = 0; } if (this->type2 == 0) { - if (8 < this->actionDelay) { - this->action = this->action + 1; + if (this->actionDelay > 8) { + this->action++; gPlayerState.jumpStatus = 0x81; - gPlayerState.flags |= 0x4000000; + gPlayerState.flags |= PL_MINECART; gPlayerEntity.zVelocity = 0x20000; gPlayerEntity.speed = 0x100; - gPlayerEntity.flags &= 0x7f; + gPlayerEntity.flags &= ~PL_MINISH; ResetPlayer(); sub_0807A108(); SoundReq(SFX_PLY_JUMP); @@ -95,11 +94,11 @@ void sub_080918A4(Entity* this) { gPlayerEntity.x.HALF.HI = this->x.HALF.HI; gPlayerEntity.y.HALF.HI = this->y.HALF.HI; if (gPlayerEntity.z.HALF.HI > -0x10) { - if ((s32)gPlayerEntity.zVelocity > -1) { + if (gPlayerEntity.zVelocity >= 0) { return; } gPlayerEntity.animationState = this->animationState << 1; - gPlayerState.flags = (gPlayerState.flags ^ 0x4000000) | 0x1000; + gPlayerState.flags = (gPlayerState.flags ^ PL_MINECART) | 0x1000; this->action++; this->field_0xf = 1; this->flags |= ENT_20; @@ -158,7 +157,7 @@ void sub_080919AC(Entity* this) { gUnk_081223C8[this->animationState * 2 + 1]); iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[this->animationState]); if (iVar2 == 0) { - this->direction = this->direction ^ 0x10; + this->direction = DirectionTurnAround(this->direction); this->animationState = this->animationState ^ 2; } else { switch (uVar3) { @@ -171,12 +170,12 @@ void sub_080919AC(Entity* this) { this->action = 6; sub_08017744(this); gPlayerState.jumpStatus = 0x41; - gPlayerState.flags = (gPlayerState.flags ^ 0x1000) | 0x4000000; + gPlayerState.flags = (gPlayerState.flags ^ 0x1000) | PL_MINECART; gPlayerEntity.zVelocity = 0x20000; gPlayerEntity.speed = 0x200; gPlayerEntity.animationState = this->animationState << 1; gPlayerEntity.direction = this->direction; - gPlayerEntity.flags |= 0x80; + gPlayerEntity.flags |= PL_MINISH; sub_08004168(this); InitAnimationForceUpdate(this, this->animationState + 0xc); SoundReq(SFX_PLY_VO4); diff --git a/src/object/object6A.c b/src/object/object6A.c index d0063f60..11dcfc48 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -398,7 +398,7 @@ void sub_08094FA8(Object6AEntity* this) { super->interactType = 0; super->action = 2; sub_080788E0(super); - gPlayerState.playerAction = 12; + gPlayerState.queued_action = PLAYER_EMPTYBOTTLE; gPlayerState.field_0x38 = 54; #ifndef EU SetPlayerControl(2); diff --git a/src/object/object86.c b/src/object/object86.c index b5c9e60b..62d30b6b 100644 --- a/src/object/object86.c +++ b/src/object/object86.c @@ -69,7 +69,7 @@ void nullsub_534(Entity* this) { void sub_08099ECC(Entity* this) { this->subAction = 1; CopyPosition(this, &gPlayerEntity); - gPlayerState.playerAction = 3; + gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x34[4] = 0; gPlayerState.flags |= 0x8000; } diff --git a/src/overworld.c b/src/overworld.c index 997ce29d..ff90afc8 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -351,7 +351,7 @@ void InitializePlayer(void) { pl = &gPlayerEntity; gRoomControls.cameraTarget = pl; - gPlayerState.playerAction = sPlayerSpawnStates[gScreenTransition.player_status.spawn_type]; + gPlayerState.queued_action = sPlayerSpawnStates[gScreenTransition.player_status.spawn_type]; if (!CheckGlobalFlag(EZERO_1ST)) { gPlayerState.flags |= PL_NO_CAP; } @@ -607,7 +607,7 @@ static u32 StairsAreValid(void) { for (i = sStairTypes; i[0] != 0; i += 2) { if (tgt == i[0]) { - gPlayerState.playerAction = 30; + gPlayerState.queued_action = PLAYER_USEENTRANCE; gPlayerState.field_0x38 = 0; gPlayerState.field_0x39 = i[1]; if (!gScreenTransition.player_status.spawn_type) @@ -666,7 +666,7 @@ u32 sub_08052B24(void) { gUnk_0200AF00.filler0[1]) return 0; - if ((gPlayerState.flags & 0x118) || (gPlayerState.framestate_last > tmp) || gPlayerState.item || + if ((gPlayerState.flags & (PL_NO_CAP | 0x110)) || (gPlayerState.framestate_last > tmp) || gPlayerState.item || gPlayerEntity.field_0x7a.HWORD) return 0; diff --git a/src/player.c b/src/player.c index ead93d25..0ead68bc 100644 --- a/src/player.c +++ b/src/player.c @@ -15,11 +15,10 @@ #include "hitbox.h" #include "overworld.h" #include "screen.h" +#include "main.h" typedef void(EntityAction)(Entity*); -static EntityAction* const sPlayerActions[]; - static EntityAction PlayerInit; static EntityAction PlayerNormal; static EntityAction PlayerInit; @@ -29,7 +28,7 @@ static EntityAction PlayerPush; static EntityAction PlayerBounce; static EntityAction sub_08070E9C; static EntityAction PlayerItemGet; -EntityAction PlayerMinish; +static EntityAction PlayerMinish; static EntityAction PlayerMinishDie; static EntityAction sub_08071DB8; static EntityAction PlayerEmptyBottle; @@ -48,10 +47,10 @@ static EntityAction PlayerRoll; static EntityAction sub_080728AC; static EntityAction PlayerInHole; static EntityAction sub_08072C9C; -EntityAction sub_08074C44; -static EntityAction sub_08072F34; +static EntityAction sub_08074C44; +static EntityAction PlayerClimb; static EntityAction PlayerUseEntrance; -EntityAction PlayerParachute; +static EntityAction PlayerParachute; // PLAYER_FALL static EntityAction PlayerFallInit; @@ -163,28 +162,86 @@ static EntityAction sub_08072CFC; static EntityAction sub_08072D54; static EntityAction sub_08072F14; -// PLAYER_08072F34 +// PLAYER_CLIMB static EntityAction sub_08072F94; static EntityAction sub_08073094; // PLAYER_USEENTRANCE -EntityAction sub_080731D8; -EntityAction sub_080732D0; -EntityAction sub_0807332C; -EntityAction sub_080733BC; +static EntityAction sub_080731D8; +static EntityAction sub_080732D0; +static EntityAction sub_0807332C; +static EntityAction sub_080733BC; + +// PLAYER_PARACHUTE +static EntityAction sub_08073468; +static EntityAction sub_080734D4; +static EntityAction sub_08073504; +static EntityAction sub_08073584; +static EntityAction sub_0807379C; +static EntityAction sub_080737BC; +static EntityAction sub_0807380C; +static EntityAction sub_08073884; + +// sub_08073904... ? +static EntityAction sub_08073924; +static EntityAction sub_08073968; +static EntityAction sub_080739EC; +static EntityAction sub_08073A94; +static EntityAction sub_08073B8C; +static EntityAction sub_08073C30; + +// PLAYER_MINISH +static EntityAction sub_08073C80; +static EntityAction sub_08073D20; +static EntityAction sub_08073F04; +static EntityAction sub_08073F4C; +static EntityAction sub_08073FD0; +static EntityAction sub_08074018; +static EntityAction sub_08074060; +static EntityAction sub_080740D8; + +// PLAYER_08074C44 +static EntityAction sub_08074C68; +static EntityAction sub_08074CF8; +static EntityAction sub_08074F00; +static EntityAction sub_080750F4; +// ... +static EntityAction sub_08074F1C; +static EntityAction sub_08074F2C; +static EntityAction sub_08074F44; +static EntityAction sub_08074F8C; +static EntityAction sub_08074FEC; +static EntityAction sub_0807501C; +static EntityAction sub_0807508C; +// ... +static EntityAction sub_08075110; +static EntityAction sub_0807513C; +static EntityAction sub_0807518C; +static EntityAction sub_080751B4; static void sub_080717F8(Entity*); static void ResetPlayerPriority(); static void sub_080728AC(Entity*); static void BreakOut(); +static void sub_08073AD4(); +static void sub_08073B60(Entity*); +static void sub_08074244(Entity*, u32, u32); +static void hide(Entity*); +static void sub_08074BF8(Entity*); +static void sub_08074D34(Entity*, ScriptExecutionContext*); + +// exports +void SurfaceAction_Water(Entity*); +void SurfaceAction_Ladder(Entity*); +void SurfaceAction_AutoLadder(Entity*); extern void RespawnPlayer(); extern void sub_080797EC(); extern void sub_08079E08(); -extern void sub_08078F60(); +extern void ResetPlayerVelocity(); extern void sub_08077698(); extern void sub_08079258(); -extern void sub_0807A298(); +extern void EnablePlayerDraw(); extern u32 sub_08079B24(); extern void sub_08079708(); extern void sub_080792D8(); @@ -208,8 +265,25 @@ extern u32 sub_08007DD6(); extern u32 GetSurfaceCalcType(); extern void sub_08074808(); extern void sub_08073904(Entity*); +extern void SetZeldaFollowTarget(Entity*); +extern u32 ItemIsSword(u32); +extern u32 sub_0807A2B8(); +extern u32 sub_08079550(u32); +extern u32 sub_080782C0(); +extern u32 sub_080793E4(u32); +extern void sub_08008AC6(Entity*); +extern u32 sub_08079C30(Entity*); +extern void sub_08077AEC(); extern ScreenTransitionData gUnk_0813AB58; +extern ScreenTransitionData gUnk_0813AD88[]; +extern u8 gUnk_080082DC[]; + +extern u16 script_08009ECC; +extern u16 script_08009EF0; + +extern Entity* gPlayerClones[]; +extern ScriptExecutionContext gPlayerScriptExecutionContext; void DoPlayerAction(Entity* this) { static void (*const sPlayerActions[])(Entity*) = { @@ -242,7 +316,7 @@ void DoPlayerAction(Entity* this) { [PLAYER_INHOLE] = PlayerInHole, [PLAYER_08072C9C] = sub_08072C9C, [PLAYER_08074C44] = sub_08074C44, - [PLAYER_08072F34] = sub_08072F34, + [PLAYER_CLIMB] = PlayerClimb, [PLAYER_USEENTRANCE] = PlayerUseEntrance, [PLAYER_PARACHUTE] = PlayerParachute, }; @@ -278,7 +352,7 @@ static void PlayerInit(Entity* this) { sub_0807A108(); sub_0807AEE4(); - if (sub_08078EFC() == 0) { + if (RunQueuedAction() == 0) { sub_0807921C(); UpdateFloorType(); if (gPlayerState.swimState != 0) { @@ -329,9 +403,9 @@ static void PlayerFallInit(Entity* this) { gPlayerState.jumpStatus = 0; - if ((gPlayerState.flags & PL_MINISH) != 0) + if (gPlayerState.flags & PL_MINISH) gPlayerState.animation = 0x1ba; - else if ((gPlayerState.flags & 8) != 0) + else if (gPlayerState.flags & PL_NO_CAP) gPlayerState.animation = 0x458; else gPlayerState.animation = 0x1b8; @@ -382,7 +456,7 @@ static void PlayerBounceInit(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) { this->zVelocity = 0x20000; gPlayerState.animation = 0x114; - sub_08080964(16, 0); + InitScreenShake(16, 0); } else { gPlayerState.animation = 0xc18; this->zVelocity = 0x18000; @@ -391,7 +465,7 @@ static void PlayerBounceInit(Entity* this) { gPlayerState.jumpStatus = 0x80; SoundReq(SFX_14C); ResetPlayer(); - sub_08078F60(); + ResetPlayerVelocity(); } // minor regalloc @@ -401,12 +475,12 @@ static NONMATCH("asm/non_matching/player/sub_08070DC4.inc", void PlayerBounceUpd sub_08079E08(); UpdateFloorType(); - if (sub_08078EFC() || GravityUpdate(this, 0x2000)) + if (RunQueuedAction() || GravityUpdate(this, 0x2000)) return; gPlayerState.jumpStatus = 0; - if (sub_08078EFC() || sub_08079D48()) + if (RunQueuedAction() || sub_08079D48()) return; if (gPlayerState.swimState != 0) { @@ -451,7 +525,7 @@ static void sub_08070E9C(Entity* this) { sub_08070f24, }; - if (sub_08078EFC() != 0) { + if (RunQueuedAction() != 0) { MessageClose(); } else { gPlayerState.field_0x27[0] = 4; @@ -531,7 +605,7 @@ static void PlayerItemGetInit(Entity* this) { this->subAction = 1; ResetPlayer(); - sub_08078F60(); + ResetPlayerVelocity(); } static void PlayerItemGetUpdate(Entity* this) { @@ -543,7 +617,7 @@ static void PlayerItemGetUpdate(Entity* this) { static void sub_08071038(Entity* this) { UpdateAnimationSingleFrame(this); - if (sub_08078EFC() || (gMessage.doTextBox & 0x7f)) + if (RunQueuedAction() || (gMessage.doTextBox & 0x7f)) return; if (this->frame & 0x80) { @@ -572,9 +646,9 @@ static void PlayerJumpInit(Entity* this) { this->subAction++; gPlayerState.flags |= PL_BUSY; - gPlayerState.flags &= ~(PL_BURNING | 0x800); + gPlayerState.flags &= ~(PL_BURNING | PL_FROZEN); - gPlayerState.playerAction = 0; + gPlayerState.queued_action = 0; if ((gPlayerState.heldObject | gPlayerState.field_0x1a[1]) == 0) { if ((gPlayerState.flags & PL_MINISH) == 0) { @@ -602,8 +676,7 @@ static void PlayerJumpInit(Entity* this) { } static void sub_08071130(Entity* this) { - - if (sub_08078EFC(this)) + if (RunQueuedAction(this)) return; if (gPlayerState.field_0x1a[1] == 0) { @@ -631,7 +704,7 @@ static void sub_08071130(Entity* this) { UpdateFloorType(); - if (sub_08078EFC()) + if (RunQueuedAction()) return; if ((sub_08079D48() == 0) || (gPlayerState.swimState != 0)) { @@ -652,7 +725,7 @@ static void sub_08071130(Entity* this) { } this->subAction++; - sub_08078F60(); + ResetPlayerVelocity(); this->knockbackDuration = 0; SoundReq(SFX_PLY_LAND); } @@ -940,7 +1013,7 @@ static void PlayerTalkEzlo(Entity* this) { sub_08071A4C, }; - if (sub_08078EFC()) { + if (RunQueuedAction()) { MessageClose(); ResetPlayerPriority(); } else { @@ -1111,7 +1184,7 @@ static void PlayerPushUpdate(Entity* this) { static void sub_08071B60(Entity* this) { gPlayerState.pushedObject = 2; - gPlayerState.flags &= ~0x1; + gPlayerState.flags &= ~PL_BUSY; this->type = 0; this->knockbackDuration = 0; sub_080728AC(this); @@ -1150,11 +1223,11 @@ static void PlayerMinishDieInit(Entity* this) { return; } - gPlayerState.playerAction = 0; + gPlayerState.queued_action = 0; 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) { - sub_0807A298(this); + EnablePlayerDraw(this); RespawnPlayer(); this->action = 10; } @@ -1164,7 +1237,7 @@ static void PlayerMinishDieInit(Entity* this) { } gPlayerState.animation = temp; - gPlayerState.flags &= ~(0x1000000 | 0x200000 | 0x40000 | 0x800 | 0x400 | 0x100 | PL_BUSY); + gPlayerState.flags &= ~(PL_PARACHUTE | PL_RELEASED | PL_ROLLING | PL_FROZEN | PL_BURNING | 0x100 | PL_BUSY); this->subAction = 1; this->animationState = IdleSouth; this->spritePriority.b1 = 1; @@ -1181,7 +1254,7 @@ static void sub_08071CAC(Entity* this) { if (this->frame & 0x80) { u32 temp; if ((gPlayerState.flags & PL_MINISH) == 0) - temp = (gPlayerState.flags & 8) ? 0x45a : 0x2bd; + temp = (gPlayerState.flags & PL_NO_CAP) ? 0x45a : 0x2bd; else temp = 0xc1b; gPlayerState.animation = temp; @@ -1262,7 +1335,7 @@ static void sub_08071E04(Entity* this) { UpdateFloorType(); if (gPlayerState.floor_type == SURFACE_PIT) { gPlayerState.field_0x11 = 7; - gPlayerState.flags |= 0x200; + gPlayerState.flags |= PL_FALLING; sub_080791BC(); return; } @@ -1366,7 +1439,7 @@ static void PlayerFrozenUpdate(Entity* this) { if (sub_08079B24() == 0) { sub_08079708(this); } else { - if (gPlayerState.flags & 0x800) { + if (gPlayerState.flags & PL_FROZEN) { if (sub_0807953C() != 0) { this->actionDelay -= 3; this->spriteOffsetX = 2; @@ -1386,7 +1459,7 @@ static void BreakOut(Entity* this) { this->knockbackDuration = 0; COLLISION_ON(this); this->spriteOffsetX = 0; - gPlayerState.flags &= ~(0x800 | PL_BUSY); + gPlayerState.flags &= ~(PL_FROZEN | PL_BUSY); CreateFx(this, FX_ICE, 0); sub_080791BC(); } @@ -1429,7 +1502,7 @@ static void sub_080720DC(Entity* this) { sub_08072168, }; - if (sub_08078EFC() == 0) + if (RunQueuedAction() == 0) gUnk_0811BB60[this->subAction](this); } @@ -1686,7 +1759,7 @@ static void PlayerRoll(Entity* this) { static void PlayerRollInit(Entity* this) { u32 temp; - if ((gPlayerState.flags & 0x200000) == 0) { + if ((gPlayerState.flags & PL_RELEASED) == 0) { sub_0806F948(&gPlayerEntity); this->direction = Direction8FromAnimationState(this->animationState); } @@ -1715,11 +1788,13 @@ static void PlayerRollInit(Entity* this) { } static void PlayerRollUpdate(Entity* this) { - if (((gPlayerState.flags & (PL_ROLLING | 0x80000)) != PL_ROLLING) || - (!(gPlayerState.flags & 0x200000) && (this->iframes != 0) && (this->bitfield & 0x80))) { + if (((gPlayerState.flags & (PL_ROLLING | PL_TRAPPED)) != PL_ROLLING) || + ((gPlayerState.flags & PL_RELEASED) == 0 && (this->iframes != 0) && (this->bitfield & 0x80))) { gPlayerState.flags &= ~PL_ROLLING; - if (!sub_08078EFC()) - sub_080728AC(this); + if (RunQueuedAction()) + return; + + sub_080728AC(this); return; } @@ -1731,12 +1806,12 @@ static void PlayerRollUpdate(Entity* this) { if ((gPlayerState.flags & 2) == 0) { UpdateFloorType(); } - if (sub_08078EFC()) { + if (RunQueuedAction()) { gPlayerState.flags &= ~PL_ROLLING; return; } - if ((gPlayerState.flags & 0x80000) != 0) { + if (gPlayerState.flags & PL_TRAPPED) { gPlayerState.flags &= ~PL_ROLLING; return; } @@ -1745,7 +1820,7 @@ static void PlayerRollUpdate(Entity* this) { return; } - if (gPlayerState.flags & (0x200 | 0x40 | 0x10)) { + if (gPlayerState.flags & (PL_FALLING | PL_HIDDEN | 0x10)) { gPlayerState.flags &= ~PL_ROLLING; sub_080728AC(this); return; @@ -1778,14 +1853,14 @@ static void PlayerRollUpdate(Entity* this) { // dont take damage this->hurtType = 0; } - if ((this->frame & 0x40) != 0) { + if (this->frame & 0x40) { sub_08077698(this); } - if (((this->frame & 0x80) != 0) || (gPlayerState.field_0x3[1] != 0)) { + if ((this->frame & 0x80) || (gPlayerState.field_0x3[1] != 0)) { sub_080791D0(); } - if ((this->frame & 0x80) != 0) { - gPlayerState.flags &= ~(0x200000 | PL_ROLLING); + if (this->frame & 0x80) { + gPlayerState.flags &= ~(PL_RELEASED | PL_ROLLING); } UpdateAnimationSingleFrame(this); } @@ -1795,17 +1870,17 @@ static void sub_080728AC(Entity* this) { if (gPlayerState.flags & PL_MINISH) sub_0807B068(this); else - sub_08078F60(); + ResetPlayerVelocity(); if (gPlayerState.swimState != 0) this->speed = 0; - if ((gPlayerState.flags & 0x40) == 0) + if ((gPlayerState.flags & PL_HIDDEN) == 0) gPlayerEntity.spriteSettings.draw = 3; if ((gPlayerState.flags & PL_MINISH) == 0) gPlayerEntity.spritePriority.b1 = 1; if ((gRoomControls.unk6 & 4) == 0) { - if (gPlayerState.flags & 0x40) + if (gPlayerState.flags & PL_HIDDEN) COLLISION_ON(this); sub_080791D0(); } @@ -2092,20 +2167,20 @@ static void sub_08072F14(Entity* this) { } } -static void sub_08072F34(Entity* this) { - static EntityAction* const gUnk_0811BBE4[] = { +static void PlayerClimb(Entity* this) { + static EntityAction* const sPlayerClimbStates[] = { sub_08072F94, sub_08073094, }; - if (!sub_08078EFC()) { + if (!RunQueuedAction()) { gPlayerState.framestate = PL_STATE_CLIMB; gPlayerState.floor_type = GetSurfaceCalcType(this, 0, 0); - gUnk_0811BBE4[this->subAction](this); + sPlayerClimbStates[this->subAction](this); if (this->knockbackDuration != 0) { sub_080792D8(); if (this->knockbackDuration == 0) { - this->action = 0x1d; + this->action = PLAYER_CLIMB; this->subAction = 0; this->y.HALF.LO = 0; gPlayerState.animation = 0x2cf; @@ -2183,16 +2258,16 @@ static void sub_08073094(Entity* this) { UpdateFloorType(); } - if (sub_08078EFC() == 0) { + if (RunQueuedAction() == 0) { switch (gPlayerState.floor_type) { case SURFACE_AUTO_LADDER: case SURFACE_2C: this->knockbackDuration = 0; - gPlayerState.flags |= 0x20000000; + gPlayerState.flags |= PL_CLIMBING; UpdateAnimationSingleFrame(this); - if ((this->frame & 0x40) != 0) { + if (this->frame & 0x40) { UpdateFloorType(); - if (!sub_08078EFC()) { + if (!RunQueuedAction()) { this->subAction--; } } @@ -2207,9 +2282,9 @@ static void sub_08073094(Entity* this) { case SURFACE_LADDER: case SURFACE_CLIMB_WALL: UpdateAnimationSingleFrame(this); - if ((this->frame & 0x40) != 0) { + if (this->frame & 0x40) { UpdateFloorType(); - if (!sub_08078EFC()) { + if (!RunQueuedAction()) { this->subAction--; } } @@ -2231,3 +2306,1496 @@ static void PlayerUseEntrance(Entity* this) { RequestPriorityDuration(NULL, 8); sPlayerUseEntranceStates[this->subAction](this); } + +static void sub_080731D8(Entity* this) { + COLLISION_OFF(this); + this->speed = 0x40; + this->animationState = IdleNorth; + this->x.HALF.HI = (this->x.HALF.HI & ~0xF) | 8; + this->x.HALF.LO = 0; + if (gPlayerState.field_0x38 == 0) { + this->subAction = 1; + } else { + this->spriteSettings.draw = 3; + this->subAction = 3; + this->field_0x7c.HALF.HI = this->y.HALF.HI; + this->y.HALF.HI -= 16; + this->child = CreateObjectWithParent(this, OBJECT_70, 1, 0); + if (gPlayerState.field_0x39 == 7) { + this->y.HALF.HI = (this->y.HALF.HI & ~0xF) + 8; + this->x.HALF.HI &= ~0xF; + this->direction = DirectionEast; + this->animationState = IdleEast; + SoundReq(SFX_STAIRS_ASCEND); + } else { + this->y.HALF.HI = (this->y.HALF.HI & ~0xF) + 2; + this->x.HALF.HI = (this->x.HALF.HI & ~0xF) + 15; + this->direction = DirectionWest; + this->animationState = IdleWest; + SoundReq(SFX_STAIRS_DESCEND); + } + SetZeldaFollowTarget(this); + } + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 1028; + } else { + gPlayerState.animation = 260; + } + gRoomControls.cameraTarget = NULL; + sub_0807A108(); + ResetPlayer(); +} + +static void sub_080732D0(Entity* this) { + UpdateAnimationSingleFrame(this); + if (sub_080002B8(this) != 40) { + this->direction = DirectionNorth; + sub_0806F69C(this); + } else { + this->subAction++; + this->y.HALF.LO = 0; + CreateObjectWithParent(this, OBJECT_70, 1, 0); + if (gPlayerState.field_0x39 == 7) { + SoundReq(SFX_STAIRS_ASCEND); + } else { + SoundReq(SFX_STAIRS_DESCEND); + } + } +} + +static void sub_0807332C(Entity* this) { + UpdateAnimationSingleFrame(this); + if (gPlayerState.field_0x39 == 7) { + this->direction = IdleNorth; + } else { + this->direction = 28; + } + if ((this->x.HALF.HI & 0xF) != 0xF) { + if (gPlayerState.field_0x39 == 7) { + this->animationState = IdleEast; + this->direction = 4; + } else { + this->animationState = 6; + if (this->direction <= DirectionWest) { + sub_0806F69C(this); + return; + } + this->direction = (this->direction - 1) & 0x1F; + } + sub_0806F69C(this); + return; + } + if (gPlayerState.field_0x38 != 0) { + gRoomControls.cameraTarget = this; + sub_080791BC(); + } else { + gMain.transition = 3; + *(&gMain.pauseInterval + 1) = 1; + DoFade(5, 8); + } +} + +static void sub_080733BC(Entity* this) { + UpdateAnimationSingleFrame(this); + if ((this->x.HALF.HI & 0xF) == 8) { + Entity* c; + this->direction = DirectionSouth; + this->animationState = IdleSouth; + c = this->child; + if (c != NULL) { + DeleteEntity(c); + this->child = NULL; + if (this->collisionLayer == 1) { + sub_0807AABC(this); + } else { + sub_0807AA80(this); + } + } + } + sub_0806F69C(this); + if (this->field_0x7c.HALF_U.HI == this->y.HALF.HI) { + gRoomControls.cameraTarget = this; + sub_0807921C(); + } +} + +static void PlayerParachute(Entity* this) { + static EntityAction* const sPlayerParachuteStates[] = { + sub_08073468, sub_080734D4, sub_08073504, sub_08073584, sub_0807379C, sub_080737BC, sub_0807380C, sub_08073884, + }; + + if (!RunQueuedAction()) { + UpdateFloorType(); + this->spriteOrientation.flipY = 1; + this->spriteRendering.b3 = 1; + gPlayerState.framestate = PL_STATE_PARACHUTE; + sPlayerParachuteStates[this->subAction](this); + } +} + +static void sub_08073468(Entity* this) { + gPlayerState.animation = 1792; + gPlayerState.jumpStatus = 0; + this->zVelocity = -0x10000; + this->subAction++; + this->field_0x7c.WORD = 480; + this->direction = Direction8FromAnimationState(this->animationState); + if ((gPlayerState.flags & PL_PARACHUTE) == 0) { + gPlayerState.flags |= PL_PARACHUTE; + CreateObjectWithParent(this, OBJECT_61, 0, 0); + } + ResetPlayer(); + if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) + COLLISION_OFF(this); +} + +static void sub_080734D4(Entity* this) { + GravityUpdate(this, -0x1000); + if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) { + this->zVelocity = 0x49000; + this->subAction++; + } +} + +static void sub_08073504(Entity* this) { + GravityUpdate(this, this->zVelocity < 0 ? 0x800 : 0x4000); + if (this->zVelocity < 0 && this->z.HALF.HI > -32) { + this->subAction++; + *((u32*)&this->field_0x80.HWORD) = this->direction << 8; + this->field_0x86.HALF.HI = 0; + this->field_0x86.HALF.LO = 0; + gPlayerState.animation = 1800; + if (gPlayerState.field_0x38 == 1) { + COLLISION_OFF(this); + this->subAction = 6; + this->speed = 16; + this->actionDelay = 30; + SoundReq(SFX_NEAR_PORTAL); + } + } + UpdateAnimationSingleFrame(this); +} + +static const u16 gUnk_0811BC28[] = { + 0x0708, + 0x071C, + 0x0718, + 0x0714, +}; + +static const u16 gUnk_0811BC30[] = { + 0x0708, + 0x0728, + 0x0724, + 0x0720, +}; + +static NONMATCH("asm/non_matching/player/sub_08073584.inc", void sub_08073584(Entity* this)) { + u32 state, dir, tmp, tmp2, idx; + + if ((gPlayerState.field_0x90.HALF.HI & 0x80) || this->iframes > 0 || gPlayerState.field_0x3c[0] || + (gPlayerState.flags & PL_PARACHUTE) == 0) { + gPlayerState.jumpStatus |= 0x40; + sub_0807921C(); + sub_08073904(this); + gPlayerState.animation = 1840; + return; + } + gUnk_0200AF00.filler25[10] = 1; + if (sub_0807A2F8(0)) { + this->subAction++; + this->direction = 4 * (this->animationState & 6); + COLLISION_OFF(this); + return; + } + if (gArea.locationIndex == 16) + this->speed = 256; + else + this->speed = 128; + if ((gPlayerState.field_0xd & 0x80) == 0) { + if (this->direction != gPlayerState.field_0xd) { + if (((this->direction - gPlayerState.field_0xd) & 0x1F) <= 0xF) + *(u32*)&this->field_0x80 -= 32; + else + *(u32*)&this->field_0x80 += 32; + } + } + this->direction = (*(u32*)&this->field_0x80 >> 8) & 0x1F; + sub_08079E08(); + state = 4 * this->animationState; + dir = this->direction; + if (this->animationState == 0) { + state = (state + 8) & 0x1F; + dir = (dir + 8) & 0x1F; + } + if (state - 7 > dir) { + tmp = (this->animationState - 2) & 7; + } else if (state + 7 < dir) { + tmp = (this->animationState + 2) & 7; + } else { + tmp = this->animationState; + } + if (tmp != this->animationState) { + this->field_0x86.HALF.HI = 20; + } + this->animationState = tmp; + idx = 0; + tmp2 = gPlayerState.field_0xd >> 2; + if (!this->field_0x86.HALF.HI || ((gPlayerState.field_0xd & 0x80) == 0 && this->animationState != tmp2)) { + if ((gPlayerState.field_0xd & 0x80) == 0) { + if (this->animationState != tmp2) { + if (this->animationState == (tmp2 ^ 4)) { + idx = 2; + } else { + if (this->animationState == (((tmp2 & 6) + 2) & 7)) { + idx = 1; + } else { + idx = 3; + } + } + } + } + if (gUnk_0811BC28[idx] == gPlayerState.animation) { + if (gArea.locationIndex == 16) + sub_080042BA(this, 2); + else + UpdateAnimationSingleFrame(this); + } else { + gPlayerState.animation = gUnk_0811BC28[idx]; + } + this->field_0x86.HALF.LO = idx; + } else { + + this->field_0x86.HALF.HI--; + if (gUnk_0811BC30[this->field_0x86.HALF.LO] == gPlayerState.animation) + UpdateAnimationSingleFrame(this); + else + gPlayerState.animation = gUnk_0811BC30[this->field_0x86.HALF.LO]; + } + if (--this->field_0x7c.WORD == -1) { + gPlayerState.jumpStatus |= 0x40; + sub_0807921C(); + } else { + u32 di = (this->field_0x7c.WORD / 20); + this->z.HALF.HI = -8 - di; + } +} +END_NONMATCH + +static void sub_0807379C(Entity* this) { + if (this->z.HALF.HI > -32) { + this->z.HALF.HI--; + } else { + this->subAction++; + } +} + +static void sub_080737BC(Entity* this) { + u16 pos; + u32 tmp; + + UpdateAnimationSingleFrame(this); + sub_0806F69C(this); + this->z.WORD += 0x4C00; + if (DirectionIsHorizontal(this->direction)) + pos = this->x.HALF.HI; + else + pos = this->y.HALF.HI; + tmp = 0xf; + tmp &= pos; + if (tmp == 8 && !sub_080002D0(this)) { + gPlayerState.jumpStatus |= 0x40; + sub_0807921C(); + } +} + +static void sub_0807380C(Entity* this) { + static const u16 sAnims[] = { + 0x0708, + 0x071C, + 0x0718, + 0x0714, + }; + + if ((gScreenTransition.frameCount & 3) == 0) { + u32 tmp = (this->animationState + 2) & 6; + this->animationState = tmp; + this->direction = 4 * tmp; + } + gPlayerState.animation = sAnims[this->animationState >> 1]; + if (this->z.HALF.HI < -16) { + GravityUpdate(this, 0x200); + } else { + if (--this->actionDelay == 0) { + this->subAction = 7; + this->actionDelay = 60; + this->zVelocity = 0x20000; + } + } + UpdateAnimationSingleFrame(this); +} + +void sub_08073884(Entity* this) { + static const u16 sAnims[] = { + 0x0708, + 0x071C, + 0x0718, + 0x0714, + }; + + if ((gScreenTransition.frameCount & 1) == 0) { + u32 tmp = (this->animationState + 2) & 6; + this->animationState = tmp; + this->direction = 4 * tmp; + } + gPlayerState.animation = sAnims[this->animationState >> 1]; + if (--this->actionDelay == 0) { + if (gPlayerState.field_0x39 != 0xff) + DoExitTransition(&gUnk_0813AD88[gPlayerState.field_0x39]); + else + InitParachuteRoom(); + } + GravityUpdate(this, -0x1800); + UpdateAnimationSingleFrame(this); +} + +void sub_08073904(Entity* this) { + static EntityAction* const sStates[] = { + sub_08073924, sub_08073968, sub_080739EC, sub_08073A94, sub_08073B8C, sub_08073C30, + }; + + sStates[gPlayerState.jumpStatus & 7](this); +} + +void sub_08073924(Entity* this) { + if ((gPlayerState.flags & PL_ROLLING) == 0 && (this->z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) { + gPlayerState.jumpStatus = 0x40; + gPlayerState.field_0xd = 0xff; + this->direction = 0xff; + sub_08077B20(); + sub_08073968(this); + } +} + +static void sub_08073968(Entity* this) { + if ((gPlayerState.jumpStatus & 0xC0) == 0) { + this->direction = gPlayerState.field_0xd; + } + sub_08078F24(); + if ((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) { + if (gPlayerState.flags & PL_NO_CAP) { + gPlayerState.animation = 1052; + } else { + if ((gPlayerState.flags & PL_MINISH) == 0) { + if (gPlayerState.flags & PL_MINECART) { + gPlayerState.animation = 2064; + } else { + gPlayerState.animation = 2060; + } + } + } + if ((gPlayerState.jumpStatus & 0xC0) == 0) { + sub_0806F948(this); + } + SoundReq(SFX_PLY_JUMP); + } + gPlayerState.jumpStatus = (gPlayerState.jumpStatus & ~7) | 2; +} + +static void sub_080739EC(Entity* this) { + u32 v; + + if ((gPlayerState.jumpStatus & 0xC0) != 0) { + gPlayerState.field_0xd = this->direction; + if (gPlayerState.jumpStatus & 0x80) + this->collisions = 0; + v = 0x2000; + } else { + if ((u16)sub_0806F854(this, 0, -12)) { + gPlayerState.jumpStatus |= 8; + v = 0x4000; + } else { + v = 0x2000; + if (gPlayerState.jumpStatus & 0x10) + v /= 2; + } + } + if ((gPlayerState.jumpStatus & 0xC0) == 0) { + if ((gPlayerState.jumpStatus & 0x20) && this->zVelocity == 0) { + this->zVelocity = 0x28000; + this->actionDelay = 10; + this->direction = 0xff; + gPlayerState.jumpStatus += 2; + gPlayerState.animation = 372; + ResetPlayerVelocity(); + return; + } + } + if (!GravityUpdate(this, v)) + sub_08073AD4(this); +} + +void sub_08073A94(Entity* this) { + if ((this->frame & 0x80) || this->knockbackDuration != 0) { + sub_08073B60(this); + } + if (gPlayerEntity.z.WORD != 0) { + gPlayerState.jumpStatus = 0; + sub_08073924(this); + } +} + +static void sub_08073AD4(Entity* this) { + u32 tmp; + + if ((this->collisionLayer & 2) == 0) { + this->spriteOrientation.flipY = 2; + this->spriteRendering.b3 = 2; + } + tmp = (gPlayerState.jumpStatus & ~0xC0); + if (this->action != PLAYER_MINISHDIE) { + sub_0807A2B8(); + gPlayerState.jumpStatus = 0; + UpdateFloorType(); + if (gPlayerState.queued_action != 0 || gPlayerState.swimState != 0) { + return; + } + if (gPlayerState.field_0x3[1]) + sub_08073B60(this); + } + gPlayerState.jumpStatus = tmp + 1; + if (gPlayerState.flags & PL_NO_CAP) + gPlayerState.animation = 1060; + else + gPlayerState.animation = 2080; + SoundReq(SFX_PLY_LAND); +} + +static void sub_08073B60(Entity* this) { + gPlayerState.field_0x1a[1] = 0; + gPlayerState.field_0x3[1] = 0; + gPlayerState.jumpStatus = 0; + sub_08079938(); + sub_080085B0(this); + if ((gPlayerState.flags & PL_USE_PORTAL) == 0) { + sub_080791BC(); + } +} + +void sub_08073B8C(Entity* this) { + if (!gPlayerState.field_0x3[1]) { + sub_08073B60(this); + return; + } + sub_0806F854(this, 0, -12); + if ((this->frame & 1) == 0) + UpdateAnimationSingleFrame(this); + COLLISION_OFF(this); + if (this->actionDelay != 0) { + --this->actionDelay; + return; + } + GravityUpdate(this, 0x4000); + if (this->z.HALF.HI >= -8) { + if (!gPlayerState.field_0x14 && (sub_0807A2B8() || !sub_08079D48())) { + COLLISION_ON(this); + sub_08073B60(this); + return; + } + gPlayerState.jumpStatus++; + this->actionDelay = 15; + InitScreenShake(0x10, 0); + SoundReq(SFX_14C); + } +} + +void sub_08073C30(Entity* this) { + if (!gPlayerState.field_0x3[1] || --this->actionDelay == 0xFF) { + sub_08073B60(this); + } else { + COLLISION_ON(this); + UpdateAnimationSingleFrame(this); + } +} + +static void PlayerMinish(Entity* this) { + static EntityAction* const sPlayerMinishStates[] = { + sub_08073C80, sub_08073D20, sub_08073F04, sub_08073F4C, sub_08073FD0, sub_08074018, sub_08074060, sub_080740D8, + }; + sPlayerMinishStates[this->subAction](this); +} + +extern Hitbox gUnk_0811BC80; + +static void sub_08073C80(Entity* this) { + static const Hitbox sMinishHitbox = { 0, -1, { 3, 2, 2, 3 }, 2, 2 }; + + gPlayerState.flags |= PL_MINISH; + gPlayerState.animation = 3096; + this->spriteSettings.draw = 3; + this->spritePriority.b1 = 3; + this->spriteSettings.shadow = 0; + this->spriteRendering.b0 = 0; + this->hitbox = (Hitbox*)&sMinishHitbox; + this->actionDelay = 0; + this->field_0xf = 2; + this->knockbackDuration = 0; + this->subAction = 1; + LoadSwapGFX(this, 1, 2); + gRoomControls.cameraTarget = this; + sub_080809D4(); + if (gScreenTransition.player_status.spawn_type == PL_SPAWN_9) { + gScreenTransition.player_status.spawn_type = PL_SPAWN_DEFAULT; + this->spriteSettings.draw = 0; + this->subAction = 2; + } else { + CreateObject(MINISH_EMOTICON, 0, 0); + } +} + +static void sub_08073D20(Entity* this) { + gPlayerState.framestate = PL_STATE_IDLE; + this->spritePriority.b1 = 3; + this->hurtType = 1; + ResetPlayerVelocity(); + if (!gPlayerState.swimState) + this->speed = 0xC0; + if (!sub_08079B24()) { + sub_08079708(this); + return; + } + if (!RunQueuedAction()) { + sub_08073904(this); + UpdateFloorType(); + if (gPlayerState.jumpStatus) + gPlayerState.framestate = PL_STATE_CAPE; + if (gPlayerState.floor_type != SURFACE_SHALLOW_WATER && gPlayerState.floor_type != SURFACE_WATER) { + gPlayerState.swimState = 0; + this->field_0x3c &= 0xFBu; + } + if (!RunQueuedAction() && this->subAction != 2) { + if ((gPlayerState.flags & PL_HIDDEN) == 0) { + sub_080085B0(this); + sub_080792D8(); + if (!gPlayerState.field_0xa && sub_08079550(gPlayerState.field_0xa)) + return; + if (this->knockbackDuration) { + this->direction = this->knockbackDirection; + return; + } + if (sub_080782C0()) { + RunQueuedAction(); + return; + } + COLLISION_ON(this); + } + if (!sub_08019840()) { + sub_08077698(this); + if (!GravityUpdate(this, 0x2000)) + gPlayerState.jumpStatus = 0; + if ((gPlayerState.field_0x7 & 0x80) == 0 && !gPlayerState.field_0xa) { + if (this->iframes <= 8) { + if (gPlayerState.swimState) { + gPlayerState.framestate = PL_STATE_SWIM; + sub_0807ACCC(this); + sub_08079E08(); + } else { + this->direction = gPlayerState.field_0xd; + if ((gPlayerState.field_0xd & 0x80) == 0) { + gPlayerState.framestate = PL_STATE_WALK; + sub_08079E08(1); + } + } + } + if (!gPlayerState.keepFacing) + sub_0806F948(this); + UpdateAnimationSingleFrame(this); + sub_0807B068(this); + if (sub_080793E4(16)) { + this->iframes = 20; + this->knockbackDuration = 4; + this->knockbackDirection = + DirectionTurnAround(Direction8FromAnimationState(this->animationState)); + ModHealth(-2); + SoundReq(SFX_PLY_VO6); + } + if ((gPlayerState.flags & PL_HIDDEN) == 0) + sub_08008AC6(this); + else + gPlayerState.framestate = PL_STATE_D; + } + } + } + } +} + +static void sub_08073F04(Entity* this) { + this->spritePriority.b1 = 2; + this->spriteSettings.draw = 0; + this->subAction++; + this->zVelocity = 0x28000; + this->speed = 0x100; + gPlayerState.flags &= ~PL_MINISH; + ResetPlayer(); +} + +static void sub_08073F4C(Entity* this) { + u32 x = gArea.curPortalX; + u32 y = gArea.curPortalY; + if (this->x.HALF.HI != x || this->y.HALF.HI != y) { + this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY); + this->speed = 0x100; + sub_0806F69C(this); + } else { + COLLISION_OFF(this); + this->actionDelay = 30; + this->subAction++; + this->spriteSettings.flipX = 0; + *(u32*)&this->field_0x80.HWORD = 1152; + *(u32*)&this->cutsceneBeh.HWORD = 1152; + this->spriteRendering.b0 = 3; + sub_08074018(this); + gPlayerState.animation = 1852; + } +} + +static void sub_08073FD0(Entity* this) { + if (this->actionDelay != 0) { + if (--this->actionDelay != 0) { + return; + } + if (this->spriteSettings.draw == 0) { + this->spriteSettings.draw = 3; + SoundReq(SFX_PLY_JUMP); + } + } + GravityUpdate(this, 0x2000); + if (this->zVelocity == 0) { + this->subAction++; + SoundReq(SFX_PLY_GROW); + } +} + +static void sub_08074018(Entity* this) { + if (*(u32*)&this->field_0x80 > 0x100) + *(u32*)&this->field_0x80 -= 32; + if (*(u32*)&this->cutsceneBeh > 0x100) + *(u32*)&this->cutsceneBeh -= 32; + else + this->subAction++; + sub_0805EC9C(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); + UpdateAnimationSingleFrame(this); +} + +static void sub_08074060(Entity* this) { + if (!GravityUpdate(this, 0x2000)) { + this->hitbox = (Hitbox*)&gPlayerHitbox; + this->direction = DirectionSouth; + this->animationState = IdleSouth; + this->speed = 0x100; + this->spritePriority.b1 = 1; + this->spriteSettings.shadow = 1; + this->field_0xf = 0; + this->subAction++; + this->zVelocity = 0x20000; + gPlayerState.animation = 2060; + sub_0805EC60(this); + } else { + UpdateAnimationSingleFrame(this); + } +} + +static NONMATCH("asm/non_matching/player/sub_080740D8.inc", void sub_080740D8(Entity* this)) { + int v1; // r5 + int v2; // r6 + unsigned int v4; // r0 + Hitbox* v5; // r2 + int v6; // r0 + + UpdateAnimationSingleFrame(this); + if (!this->field_0xf) + v4 = this->direction; + else + v4 = this->direction ^ 0x10; + switch (v4) { + case 24: + v5 = this->hitbox; + v2 = this->x.HALF.HI - v5->unk2[0] + v5->offset_x - gRoomControls.roomOriginX; + v6 = this->y.HALF.HI; + v1 = v6 + v5->offset_y - gRoomControls.roomOriginY; + break; + case 8: + v5 = this->hitbox; + v2 = this->x.HALF.HI + v5->unk2[0] + v5->offset_x - gRoomControls.roomOriginX; + v6 = this->y.HALF.HI; + v1 = v6 + v5->offset_y - gRoomControls.roomOriginY; + break; + case 16: + v5 = this->hitbox; + v2 = this->x.HALF.HI + v5->offset_x - gRoomControls.roomOriginX; + v6 = this->y.HALF.HI + v5->unk2[3]; + v1 = v6 + v5->offset_y - gRoomControls.roomOriginY; + break; + case 0: + v5 = this->hitbox; + v2 = this->x.HALF.HI + v5->unk2[0] + v5->offset_x - gRoomControls.roomOriginX; + v6 = this->y.HALF.HI; + v1 = v6 + v5->offset_y - gRoomControls.roomOriginY; + break; + } + + if (sub_080086B4(v2, v1, gUnk_080082DC)) + sub_0806F69C(this); + else + this->field_0xf = 1; + if (!GravityUpdate(this, 0x2000)) + sub_0807921C(); +} +END_NONMATCH + +u32 sub_080741C4() { + if ((gPlayerState.jumpStatus && (gPlayerState.jumpStatus & 7) != 3) || gPlayerEntity.z.WORD != 0) { + gPlayerState.field_0x11 = 0; + gPlayerState.field_0x37 = 0; + return 1; + } + return 0; +} + +void SurfaceAction_DoNothing(Entity* this) { +} + +void SurfaceAction_Pit(Entity* this) { + if (!sub_080741C4() && sub_08079C30(this)) { + if (this->action != PLAYER_FALL) { + ResetPlayer(); + gPlayerState.queued_action = PLAYER_FALL; + } + } +} + +void SurfaceAction_SlopeGndGndVertical(Entity* this) { + sub_08074244(this, 8, 0x18); +} + +void SurfaceAction_SlopeGndGndHorizontal(Entity* this) { + sub_08074244(this, 0, 0x10); +} + +static void sub_08074244(Entity* this, u32 a1, u32 a2) { + if (gPlayerState.floor_type != SURFACE_LIGHT_GRADE && gPlayerState.floor_type != SURFACE_29) { + this->collisionLayer = 3; + this->spriteOrientation.flipY = 1; + this->spriteRendering.b3 = 1; + } + if (!sub_080741C4()) { + u32 tmp; + if (gPlayerState.dash_state == 0) { + tmp = gPlayerState.field_0xd; + } else { + tmp = 4 * this->animationState; + } + if (a1 != tmp || a2 != tmp) { + gPlayerState.field_0x80 -= 80; + } + } +} + +void SurfaceAction_6(Entity* this) { + if (gPlayerState.swimState != 0) { + gPlayerState.swimState = 0; + } + this->spritePriority.b0 = 4; + this->field_0x3c &= ~4; +} + +void SurfaceAction_7(Entity* this) { + if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0 && gPlayerState.field_0x11 == 15) { + CreateObjectWithParent(this, OBJECT_E, 0, 0); + } +} + +void SurfaceAction_MinishDoorFront(Entity* this) { + if ((this->y.HALF.HI & 0xF) <= 0xD) { + this->collisions = 0x6600; + hide(this); + } else { + EnablePlayerDraw(this); + } +} + +void SurfaceAction_MinishDoorBack(Entity* this) { + if ((this->y.HALF.HI & 0xF) > 1) { + this->collisions = 0x6600; + hide(this); + } else { + EnablePlayerDraw(this); + } +} + +void SurfaceAction_A(Entity* this) { + if ((this->x.HALF.HI & 0xF) < 12) { + this->collisions = 0x66; + hide(this); + } else { + EnablePlayerDraw(this); + } +} + +void SurfaceAction_B(Entity* this) { + if ((this->x.HALF.HI & 0xF) > 4) { + this->collisions = 0x66; + hide(this); + } else { + EnablePlayerDraw(this); + } +} + +static void hide(Entity* this) { + gPlayerState.flags |= PL_HIDDEN; + this->type2 = 0x80; + this->spriteSettings.draw = 0; + COLLISION_OFF(this); + this->knockbackDuration = 0; + ResetPlayer(); +} + +void SurfaceAction_14(Entity* this) { + if (!sub_080741C4()) { + if (sub_08079C30(this)) { + u32 spd; + sub_0807AABC(this); + sub_08074808(this); + spd = this->speed; + this->speed = 0x300; + this->direction = 16; + gPlayerState.field_0xa |= 0x80; + sub_0806F69C(this); + this->speed = spd; + } + } +} + +void SurfaceAction_CloneTile(Entity* this) { + if (gPlayerState.field_0xa0[0] == 4) { + u32 item, n, i; + if (ItemIsSword(gSave.stats.itemOnA)) { + item = gSave.stats.itemOnA; + } else { + item = gSave.stats.itemOnB; + } + switch (item) { + case 1: + case 2: + n = 0; + break; + case 3: + n = 1; + break; + case 4: + n = 2; + break; + case 6: + n = 3; + break; + default: + break; + } + for (i = 0; i < n; ++i) { + if (gPlayerClones[i] == 0) + break; + } + if (n > i) { + Entity* e = CreateObjectWithParent(this, 0x10, i, 0); + gPlayerClones[i] = e; + if (e != NULL) { + CopyPosition(this, e); + } + } else { + gPlayerState.field_0x1a[1] |= 0x80; + gPlayerState.flags |= PL_CLONING; + this->x.WORD = (this->x.WORD & ~0xFFFFF) | 0x80000; + this->y.WORD = (this->y.WORD & ~0xFFFFF) | 0x80000; + sub_08077AEC(); + } + } +} + +void SurfaceAction_16(Entity* this) { + if (!sub_080741C4() && !gPlayerState.field_0x14) { + if (this->iframes == 0) { + ModHealth(-2); + SoundReq(SFX_PLY_VO6); + this->iframes = 24; + this->knockbackDuration = 4; + this->knockbackDirection = sub_080045D4((this->x.HALF.HI & 0xFFF0) | 8, (this->y.HALF.HI & 0xFFF0) | 8, + this->x.HALF.HI, this->y.HALF.HI); + } + if ((gPlayerState.flags & PL_MINISH) == 0) + sub_08008790(this, 7); + } +} + +void SurfaceAction_Ice(Entity* this) { + if (!sub_080741C4() && ((gPlayerState.field_0x34[1] & 0x80) == 0 || this->knockbackDuration != 0)) { + ResetPlayerVelocity(); + } +} + +void SurfaceAction_ShallowWater(Entity* this) { + if (!sub_080741C4()) { + if (gPlayerState.flags & PL_MINISH) { + this->spritePriority.b1 = 0; + SurfaceAction_Water(this); + } else { + if (gPlayerState.swimState) { + COLLISION_ON(this); + this->field_0x3c &= ~4; + this->spritePriority.b0 = 4; + gPlayerState.swimState = 0; + } + if ((gPlayerState.field_0x90.HALF.HI & 0xF00) || gPlayerState.field_0x11 == 1) + SoundReq(SFX_WATER_WALK); + } + } +} + +void SurfaceAction_SlopeGndWater(Entity* this) { + if (gPlayerState.swimState) { + COLLISION_ON(this); + this->field_0x3c &= ~4; + this->spritePriority.b0 = 4; + gPlayerState.swimState = 0; + } +} + +ASM_FUNC("asm/non_matching/player/sub_08074678.inc", void SurfaceAction_Swamp(Entity* this)); + +void SurfaceAction_Water(Entity* this) { + if (!sub_080741C4()) { + if (gPlayerState.field_0x14 == 0) { + gPlayerState.field_0x3f += 2; + } else { + gPlayerState.swimState = 0; + this->spritePriority.b0 = 4; + this->field_0x3c &= ~4; + } + if ((gPlayerState.swimState & 0xF) || sub_08079C30(this)) { + sub_08074808(this); + } + } +} + +void sub_08074808(Entity* this) { + sub_08077AEC(this); + if (GetInventoryValue(ITEM_FLIPPERS) == 1) { + if (!gPlayerState.swimState) { + if ((gPlayerState.flags & 0x10000) != 0) + gPlayerState.swimState = 1; + else + gPlayerState.swimState = 8; + this->speed = 0; + gPlayerState.field_0x82[7] = 0; + if ((gPlayerState.flags & PL_MINISH) == 0) + CreateFx(this, FX_WATER_SPLASH, 0); + SoundReq(SFX_1A5); + ResetPlayer(); + } + if ((gPlayerState.swimState & 0xF) != 1) { + sub_08079744(this); + --gPlayerState.swimState; + } + gPlayerState.flags &= ~(PL_BURNING | PL_FROZEN); + if ((gPlayerState.flags & PL_DRUGGED) != 0 && this->field_0x7a.HWORD <= 0xEu) + this->field_0x7a.HWORD = 15; + } else { + gPlayerState.queued_action = PLAYER_DROWN; + } +} + +void SurfaceAction_Button(Entity* this) { + gPlayerState.field_0x3f -= 2; +} + +void sub_080748D4() { + sub_080741C4(); +} + +void SurfaceAction_1B(Entity* this) { + if (!sub_080741C4()) { + if (this->collisionLayer != 1) { + this->y.HALF.HI += 12; + if ((gPlayerState.flags & PL_MINISH) == 0) + this->z.HALF.HI -= 12; + } + sub_0807AABC(this); + } +} + +void SurfaceAction_1C(Entity* this) { + if (!sub_080741C4()) { + if (sub_08079C30(this)) { + gPlayerState.queued_action = PLAYER_LAVA; + } + } +} + +void SurfaceAction_ClimbWall(Entity* this) { + if (GetInventoryValue(ITEM_GRIP_RING) == 1) { + SurfaceAction_Ladder(this); + } else { + this->y.HALF.HI = (this->y.HALF.HI & 0xFFF0) | 0xF; + gPlayerState.floor_type = SURFACE_NORMAL; + } +} + +void SurfaceAction_Ladder(Entity* this) { + if (!sub_080741C4()) { + gPlayerState.jumpStatus = 0; + this->spriteRendering.b3 = 1; + this->spriteOrientation.flipY = 1; + this->animationState = IdleNorth; + this->collisionLayer = 3; + ResetPlayer(); + } +} + +void SurfaceAction_2C(Entity* this) { + if (GetInventoryValue(68) == 1) { + SurfaceAction_AutoLadder(this); + } else { + this->y.HALF.HI &= 0xFFF0; + gPlayerState.floor_type = SURFACE_NORMAL; + } +} + +void SurfaceAction_AutoLadder(Entity* this) { + if (!sub_080741C4()) { + this->spriteRendering.b3 = 1; + this->spriteOrientation.flipY = 1; + this->animationState = IdleNorth; + this->collisionLayer = 3; + gPlayerState.swimState = 0; + this->field_0x3c &= ~4; + if ((this->y.HALF.HI & 0xF) <= 7) { + gPlayerState.animation = 723; + this->direction = DirectionSouth; + } else { + gPlayerState.animation = 726; + this->direction = DirectionNorth; + } + ResetPlayer(); + } +} + +void SurfaceAction_20(Entity* this) { + if (gPlayerState.swimState & 0x80) { + Entity* e = CreateObjectWithParent(&gPlayerEntity, GROUND_ITEM, ITEM_RUPEE1, 0); + if (e != NULL) { + e->actionDelay = 1; + UpdateSpriteForCollisionLayer(e); + sub_08000152(57, gPlayerState.field_0x22[0], this->collisionLayer); + } + } + SurfaceAction_Water(this); +} + +void SurfaceAction_22(Entity* this) { +} + +void SurfaceAction_Dust(Entity* this) { + if (!sub_080741C4()) { + gPlayerState.field_0x80 -= 128; + if (gPlayerState.field_0x11 == 1 || (gPlayerState.field_0x90.HALF.HI & 0xF00) != 0) { + if (gPlayerState.floor_type == SURFACE_DUST) + CreateObjectWithParent(this, OBJECT_21, 1, 0); + else + CreateObjectWithParent(this, OBJECT_21, 1, 1); + } + } +} + +void SurfaceAction_26(Entity* this) { + u32 v1; + + if (gPlayerState.dash_state == 0) + v1 = gPlayerState.field_0xd; + else + v1 = 4 * this->animationState; + sub_08074244(this, v1, v1); +} + +void SurfaceAction_Hole(Entity* this) { + if (!gPlayerState.field_0x14 && !sub_080741C4()) { + if (gPlayerState.flags & PL_MINISH) + SurfaceAction_Pit(this); + else + gPlayerState.queued_action = PLAYER_INHOLE; + } +} + +void SurfaceAction_D(Entity* this) { + if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { + this->animationState = IdleNorth; + this->direction = DirectionNorth; + sub_08074BF8(this); + } +} + +void SurfaceAction_E(Entity* this) { + if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { + this->animationState = IdleSouth; + this->direction = DirectionSouth; + sub_08074BF8(this); + } +} + +void SurfaceAction_F(Entity* this) { + if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { + this->animationState = IdleWest; + this->direction = DirectionWest; + sub_08074BF8(this); + } +} + +void SurfaceAction_10(Entity* this) { + if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { + this->animationState = IdleEast; + this->direction = DirectionEast; + sub_08074BF8(this); + } +} + +static void sub_08074BF8(Entity* this) { + ResetPlayer(); + this->spritePriority.b1 = 0; + this->speed = 320; + gPlayerState.flags |= 0x2000000; + gPlayerState.field_0xa |= 0x80; + gPlayerState.field_0x1a[0] |= 0x80; + gPlayerState.field_0x27[0]++; + sub_0806F69C(this); +} + +static void sub_08074C44(Entity* this) { + static EntityAction* const gUnk_0811BC88[] = { + sub_08074C68, + sub_08074CF8, + sub_08074F00, + sub_080750F4, + }; + + if (!RunQueuedAction()) + gUnk_0811BC88[this->subAction](this); +} + +static void sub_08074C68(Entity* this) { + this->field_0x68.HALF.LO = 0; + if (gPlayerState.field_0x38 != 1) { + if (*(ScriptExecutionContext**)&this->cutsceneBeh.HWORD == &gPlayerScriptExecutionContext) { + this->subAction = 1; + sub_0807DD64(this); + sub_08074CF8(this); + } + } else { + this->spriteSettings.draw = 1; + this->animationState = 0; + this->spritePriority.b1 = 0; + this->subAction = 2; + this->field_0x68.HALF.LO = 1; + sub_0807DD64(this); + if (!gPlayerState.field_0x39) + gPlayerState.animation = 1850; + else + gPlayerState.animation = 1846; + DoFade(5, 0x100); + } +} + +static void sub_08074CF8(Entity* this) { + u32 v3; + + v3 = this->animationState; + ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); + sub_08074D34(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); + if ((this->field_0x82.HWORD & 1) != 0) + this->animationState = v3; + GravityUpdate(this, 0x2000); + UpdateAnimationSingleFrame(this); +} + +void sub_08074D34(Entity* this, ScriptExecutionContext* ctx) { + while (ctx->postScriptActions) { + u32 bit = (~ctx->postScriptActions + 1) & ctx->postScriptActions; + ctx->postScriptActions ^= bit; + switch (bit) { + case 0x1: + if (gPlayerState.flags & PL_NO_CAP) + gPlayerState.animation = 0x400; + else + gPlayerState.animation = 0x100; + break; + case 0x2: + if (gPlayerState.flags & PL_NO_CAP) + gPlayerState.animation = 1028; + else + gPlayerState.animation = 260; + break; + case 0x4: + break; + case 0x8: + if (gPlayerState.flags & PL_NO_CAP) + gPlayerState.animation = 1052; + else + gPlayerState.animation = 2060; + this->zVelocity = 0x18000; + break; + case 0x10: + CreateSpeechBubbleExclamationMark(this, 8, -24); + break; + case 0x20: + CreateSpeechBubbleQuestionMark(this, 8, -24); + break; + case 0x80: + this->spriteSettings.draw = 1; + break; + case 0x100: + this->spriteSettings.draw = 0; + break; + case 0x200: + this->field_0x82.HWORD = 0; + break; + case 0x1000: + this->field_0x82.HWORD &= ~1; + break; + case 0x2000: + this->field_0x82.HWORD |= 1; + break; + case 0x4000: + this->field_0x82.HWORD |= 8; + break; + case 0x8000: + this->field_0x82.HWORD |= 4; + break; + case 0x20000: + this->spriteSettings.flipX ^= 1; + break; + case 0x100000: + this->subAction = 2; + this->field_0x68.HALF.LO = 2; + break; + case 0x200000: + this->subAction = 3; + this->field_0x68.HALF.LO = 0; + break; + } + } +} + +static void sub_08074F00(Entity* this) { + static EntityAction* const gUnk_0811BC98[] = { + sub_08074F1C, sub_08074F2C, sub_08074F44, sub_08074F8C, sub_08074FEC, sub_0807501C, sub_0807508C, + }; + + gUnk_0811BC98[this->field_0x68.HALF.LO](this); +} + +void sub_08074F1C(Entity* this) { + this->field_0x68.HALF.LO = 1; + this->animationState = IdleNorth; +} + +void sub_08074F2C(Entity* this) { + ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); + sub_08074D34(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); +} + +void sub_08074F44(Entity* this) { + typedef struct { + u8 fill[0x6c]; + Entity* e; + } fixme; + + this->field_0x68.HALF.LO++; + if (((fixme*)&gPlayerEntity)->e) + DeleteEntity(((fixme*)&gPlayerEntity)->e); + if (!gPlayerState.field_0x39) { + gPlayerState.animation = 1851; + gPlayerState.flags |= PL_NO_CAP; + } else { + gPlayerState.animation = 1847; + } +} + +void sub_08074F8C(Entity* this) { + UpdateAnimationSingleFrame(this); + if (this->frame == 1) { + this->frame = 0; + gActiveScriptInfo.unk_00 |= 4; + } + if (this->frame & 0x80) { + this->field_0x68.HALF.LO++; + this->actionDelay = 8; + this->animationState = IdleSouth; + if (!gPlayerState.field_0x39) { + gPlayerState.animation = 1024; + } else { + gPlayerState.animation = 256; + } + } +} + +void sub_08074FEC(Entity* this) { + UpdateAnimationSingleFrame(this); + if (--this->actionDelay == 0) { + this->field_0x68.HALF.LO++; + this->actionDelay = 4; + this->animationState = gPlayerState.field_0x3a; + } +} + +void sub_0807501C(Entity* this) { + if (--this->actionDelay == 0) { + this->animationState = gPlayerState.field_0x3a; + if (!gPlayerState.field_0x39) { + gPlayerState.animation = 1052; + } else { + gPlayerState.animation = 2060; + } + this->spritePriority.b1 = 1; + this->direction = Direction8FromAnimationState(this->animationState); + this->speed = 200; + this->zVelocity = 0x20000; + this->actionDelay = 8; + this->field_0x68.HALF.LO++; + SoundReq(SFX_PLY_JUMP); + } +} + +void sub_0807508C(Entity* this) { + UpdateAnimationSingleFrame(this); + if (GravityUpdate(this, 0x2000)) { + sub_0806F69C(this); + } else { + if (!gPlayerState.field_0x39) { + gPlayerState.animation = 1024; + } else { + gPlayerState.flags &= ~PL_NO_CAP; + gPlayerState.animation = 256; + } + if (--this->actionDelay == 0) { + this->animationState = IdleSouth; + this->subAction = 1; + this->field_0x68.HALF.LO = 0; + SoundReq(SFX_PLY_LAND); + } + } +} + +void sub_080750F4(Entity* this) { + static EntityAction* const gUnk_0811BCB4[] = { + sub_08075110, + sub_0807513C, + sub_0807518C, + sub_080751B4, + }; + gUnk_0811BCB4[this->field_0x68.HALF.LO](this); +} + +void sub_08075110(Entity* this) { + this->field_0x68.HALF.LO++; + this->field_0xf = this->animationState; + this->animationState = 0; + gPlayerState.animation = 1844; + gPlayerState.flags &= ~PL_NO_CAP; +} + +void sub_0807513C(Entity* this) { + UpdateAnimationSingleFrame(this); + if (this->frame == 1) { + this->frame = 0; + SoundReq(SFX_PLY_JUMP); + } + if (this->frame == 2) { + this->frame = 0; + SoundReq(SFX_14B); + SoundReq(SFX_PLY_VO6); + } + if (this->frame & 0x80) { + this->field_0x68.HALF.LO++; + this->actionDelay = 60; + } +} + +void sub_0807518C(Entity* this) { + if (--this->actionDelay == 0) { + this->field_0x68.HALF.LO++; + gPlayerState.animation = 969; + } +} + +void sub_080751B4(Entity* this) { + UpdateAnimationSingleFrame(this); + if (this->frame & 0x80) { + this->animationState = IdleSouth; + this->subAction = 1; + this->field_0x68.HALF.LO = 0; + gPlayerState.animation = 256; + } +} + +// regalloc +NONMATCH("asm/non_matching/player/sub_080751E8.inc", void sub_080751E8(u32 a1, u32 a2, void* script)) { + void* tmp; + Entity* e; + Entity* e2; + + typedef struct { + u8 filler[0x84]; + ScriptExecutionContext* ctx; + } fixme; + + MemClear(&gPlayerScriptExecutionContext, sizeof(ScriptExecutionContext)); + gPlayerScriptExecutionContext.scriptInstructionPointer = script; + ((fixme*)&gPlayerEntity)->ctx = &gPlayerScriptExecutionContext; + gPlayerState.queued_action = PLAYER_08074C44; + gPlayerState.field_0x38 = 1; + gPlayerState.field_0x39 = 0; + gPlayerState.field_0x3a = a2; + gPlayerState.flags |= 8; + if (!a1) { + gPlayerState.field_0x39 = 0; + tmp = &script_08009ECC; + } else { + gPlayerState.field_0x39 = 1; + tmp = &script_08009EF0; + } + e = CreateObject(0x5B, !gPlayerState.field_0x39 ? 2 : 0, 0); + if (e != NULL) { + CopyPosition(&gPlayerEntity, e); + StartCutscene(e, tmp); + } + e2 = CreateSpeechBubbleSleep(&gPlayerEntity, -14, -28); + *(Entity**)&gPlayerEntity.field_0x6c.HWORD = e2; + if (e2 != NULL) { + SetDefaultPriority(e2, 3); + } +} +END_NONMATCH + +void sub_0807529C(Entity* this) { + CreateSpeechBubbleQuestionMark(this, 8, -32); +} + +void sub_080752AC(Entity* this, ScriptExecutionContext* ctx) { + sub_0806F69C(this); + if (!ctx->unk_18) { + if (sub_080002B8(this) != 41) { + ctx->unk_18 = 1; + ctx->unk_19 = 6; + } + } else if (--ctx->unk_19 == 0) { + return; + } + gActiveScriptInfo.commandSize = 0; +} diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index 39c6f65f..9fff58bd 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -4,7 +4,7 @@ #include "player.h" #include "effects.h" -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern void sub_08079D84(void); extern void (*const LakituCloudProjectile_Functions[])(Entity*); @@ -44,7 +44,7 @@ void LakituCloudProjectile_SubAction2(Entity* this) { if (sub_0806F3E4(this) != 0) { if (this->hitType == 0xa6) { ModHealth(-2); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); sub_08079D84(); } CreateFx(this, FX_DEATH, 0); diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index 76097b4d..2cbc6dd2 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -6,7 +6,7 @@ #include "functions.h" #include "asm.h" -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern void (*const V1DarkMagicProjectile_Functions[])(Entity*); extern void (*const V1DarkMagicProjectile_Actions[])(Entity*); @@ -173,7 +173,7 @@ void sub_080AAF74(Entity* this) { this->actionDelay = 0x1e; gPlayerEntity.iframes = 8; ModHealth(-4); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); if (gPlayerEntity.health == 0) { this->health = 0; } diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index b3574211..0ed8e9cf 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -12,7 +12,7 @@ extern void (*const gUnk_0812A7F8[])(Entity*); extern void (*const gUnk_0812A800[])(Entity*); extern void (*const gUnk_0812A808[])(Entity*); -extern void sub_0800449C(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); extern void sub_08079D84(void); extern s32 sub_080AF090(Entity*); @@ -43,7 +43,7 @@ void nullsub_542(Entity* this) { void sub_080ABC90(Entity* this) { if (sub_0806F3E4(this) != 0) { ModHealth(-2); - sub_0800449C(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, 0x7a); sub_08079D84(); CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); diff --git a/src/roomInit.c b/src/roomInit.c index e553a20f..fc0a2ff2 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -1010,7 +1010,7 @@ void sub_0804BF38(u32 arg0, struct_0804BF38* arg1) } } - sub_08080964(gUnk_080D8E50[iVar3].shakeTime, gUnk_080D8E50[iVar3].shakeMag); + InitScreenShake(gUnk_080D8E50[iVar3].shakeTime, gUnk_080D8E50[iVar3].shakeMag); SoundReq(gUnk_080D8E50[iVar2].sfx); } #else @@ -4819,7 +4819,7 @@ void sub_StateChange_HouseInteriors2_LinksHouseBedroom(void) { gArea.musicIndex = gArea.pMusicIndex; SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP); } - if ((gPlayerState.flags & 8) == 0) { + if ((gPlayerState.flags & PL_NO_CAP) == 0) { LoadRoomEntityList(&gUnk_080F31D8); } } diff --git a/src/script.c b/src/script.c index 2a28188e..c771df3e 100644 --- a/src/script.c +++ b/src/script.c @@ -223,7 +223,7 @@ void StartPlayerScript(u16* script) { gPlayerScriptExecutionContext.scriptInstructionPointer = script; player = &gPlayerEntity; *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; - gPlayerState.playerAction = 0x1c; + gPlayerState.queued_action = PLAYER_08074C44; gPlayerState.field_0x3a = 0; gPlayerState.field_0x39 = 0; gPlayerState.field_0x38 = 0; @@ -1072,7 +1072,7 @@ void ScriptCommand_0807E888(Entity* entity, ScriptExecutionContext* context) { void ScriptCommand_SetPlayerAction(Entity* entity, ScriptExecutionContext* context) { u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); - gPlayerState.playerAction = tmp; + gPlayerState.queued_action = tmp; gPlayerState.field_0x38 = tmp >> 8; gPlayerState.field_0x39 = tmp >> 0x10; gPlayerState.field_0x3a = tmp >> 0x18; @@ -1527,7 +1527,7 @@ void ScriptCommand_0807F0B4(Entity* entity, ScriptExecutionContext* context) { } void ScriptCommand_0807F0C8(Entity* entity, ScriptExecutionContext* context) { - sub_08080964(context->scriptInstructionPointer[1], context->scriptInstructionPointer[2]); + InitScreenShake(context->scriptInstructionPointer[1], context->scriptInstructionPointer[2]); } extern u8 gUnk_0811E750[]; diff --git a/src/sub_0807B820.c b/src/sub_0807B820.c index 7d2441c3..6d3f516b 100644 --- a/src/sub_0807B820.c +++ b/src/sub_0807B820.c @@ -5,7 +5,7 @@ extern void sub_0807B778(u32, u32); void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) { if (param_1 == 53) { - sub_08000152(53); + sub_08000152(53, param_2, param_3); sub_0807B778(param_2, param_3); sub_0807B778(param_2 + 1, param_3); sub_0807B778(param_2 - 1, param_3); |
