diff options
| author | Tharo <17233964+Thar0@users.noreply.github.com> | 2021-09-12 16:10:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-12 11:10:10 -0400 |
| commit | eccfd2efbf5d76f496dd0e110a2691c687e7d92d (patch) | |
| tree | b9bfe0db620add721e8f11f5d38aabd3dc21f483 /src | |
| parent | e31e35658dd08e9f983eef8aef0e239ecd603333 (diff) | |
Decompile ovl_Door_Warp1 (#949)
* Initial progress on Door_Warp1
* Fix merge
* More work on Door_Warp1
* Decompile most of Door_Warp1
* 2 more functions OK
* All decompiled, 3 nonmatching
* Tiny improvements, fix several warnings
* Remove commented GLOBAL_ASM lines
* Fix
* Fix merge
* Two more matches
* Some docs
* More docs
* Use generated reloc under NON_MATCHING
* Fix accesses in ru1
* Add break and add limbs and dlists for the skeleton to the object xml
* Comment values for enums
Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
* boolean returns for flag checking functions
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
* Named more loop variables i and named DoorWarp1_FloatPlayer
* Last function matched thanks to Roman
* Some further suggestions
* Fix
Co-authored-by: Thar0 <maximilianc64@gmail.com>
Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Diffstat (limited to 'src')
20 files changed, 1091 insertions, 80 deletions
diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index cc8ae1f2e..efb3c2bb0 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -1,5 +1,6 @@ #include "z_boss_dodongo.h" #include "objects/object_kingdodongo/object_kingdodongo.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "scenes/dungeons/ddan_boss/ddan_boss_room_1.h" #define FLAGS 0x00000035 @@ -208,7 +209,7 @@ void BossDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Kill(&this->actor); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, -890.0f, -1523.76f, - -3304.0f, 0, 0, 0, 0); + -3304.0f, 0, 0, 0, WARP_DUNGEON_CHILD); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_BREAKWALL, -890.0f, -1523.76f, -3304.0f, 0, 0, 0, 0x6000); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -690.0f, -1523.76f, -3304.0f, 0, 0, 0, 0); @@ -1616,7 +1617,7 @@ void BossDodongo_DeathCutscene(BossDodongo* this, GlobalContext* globalCtx) { func_80064534(globalCtx, &globalCtx->csCtx); func_8002DF54(globalCtx, &this->actor, 7); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, -890.0f, -1523.76f, - -3304.0f, 0, 0, 0, 0); + -3304.0f, 0, 0, 0, WARP_DUNGEON_CHILD); this->skelAnime.playSpeed = 0.0f; Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); } diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index 7949d80ee..fe2b9f717 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -9,6 +9,7 @@ #include "overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.h" #include "overlays/actors/ovl_Bg_Vb_Sima/z_bg_vb_sima.h" #include "overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000035 @@ -219,7 +220,7 @@ void BossFd_Init(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { Actor_Kill(&this->actor); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 100.0f, 0.0f, 0, 0, 0, - -1); + WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 100.0f, 200.0f, 0, 0, 0, 0); } else { Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_FD2, this->actor.world.pos.x, diff --git a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c index 729527b9a..f56ad1283 100644 --- a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c +++ b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c @@ -7,6 +7,7 @@ #include "z_boss_fd2.h" #include "objects/object_fd2/object_fd2.h" #include "overlays/actors/ovl_Boss_Fd/z_boss_fd.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "vt.h" #define FLAGS 0x00000035 @@ -783,7 +784,7 @@ void BossFd2_Death(BossFd2* this, GlobalContext* globalCtx) { func_80064534(globalCtx, &globalCtx->csCtx); func_8002DF54(globalCtx, &this->actor, 7); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 100.0f, 0.0f, - 0, 0, 0, -1); + 0, 0, 0, WARP_DUNGEON_ADULT); Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); } break; diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c index b76f54634..d766a0ccf 100644 --- a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c +++ b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c @@ -10,6 +10,7 @@ #include "overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.h" #include "overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #define FLAGS 0x00000035 @@ -301,7 +302,7 @@ void BossGanondrof_Init(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { Actor_Kill(&this->actor); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y, - GND_BOSSROOM_CENTER_Z, 0, 0, 0, -1); + GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 200.0f + GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, 0); } else { @@ -1102,7 +1103,7 @@ void BossGanondrof_Death(BossGanondrof* this, GlobalContext* globalCtx) { if (this->timers[0] == 150) { Audio_QueueSeqCmd(0x21); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, - GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, -1); + GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); } Math_ApproachZeroF(&this->cameraEye.y, 0.05f, 1.0f); // GND_BOSSROOM_CENTER_Y + 33.0f diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index dd02ffbe4..d892e3cd8 100644 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -2,6 +2,7 @@ #include "objects/object_goma/object_goma.h" #include "overlays/actors/ovl_En_Goma/z_en_goma.h" #include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #define FLAGS 0x00000035 @@ -361,7 +362,7 @@ void BossGoma_Init(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { Actor_Kill(&this->actor); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, -640.0f, 0.0f, 0, 0, - 0, 0); + 0, WARP_DUNGEON_CHILD); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 141.0f, -640.0f, -84.0f, 0, 0, 0, 0); } } @@ -1151,7 +1152,7 @@ void BossGoma_Defeated(BossGoma* this, GlobalContext* globalCtx) { } Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, childPos.x, - this->actor.world.pos.y, childPos.z, 0, 0, 0, 0); + this->actor.world.pos.y, childPos.z, 0, 0, 0, WARP_DUNGEON_CHILD); Flags_SetClear(globalCtx, globalCtx->roomCtx.curRoom.num); } diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index e8f360a04..ba07ad4db 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -6,6 +6,7 @@ #include "z_boss_mo.h" #include "objects/object_mo/object_mo.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "vt.h" @@ -352,7 +353,7 @@ void BossMo_Init(Actor* thisx, GlobalContext* globalCtx2) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { Actor_Kill(&this->actor); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, -280.0f, 0.0f, 0, - 0, 0, -1); + 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -200.0f, -280.0f, 0.0f, 0, 0, 0, 0); globalCtx->roomCtx.unk_74[0] = 0xFF; MO_WATER_LEVEL(globalCtx) = -500; @@ -1099,7 +1100,7 @@ void BossMo_Tentacle(BossMo* this, GlobalContext* globalCtx) { ((300 - indS1) * .0015f) + 0.13f); } Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, - this->actor.world.pos.x, -280.0f, this->actor.world.pos.z, 0, 0, 0, -1); + this->actor.world.pos.x, -280.0f, this->actor.world.pos.z, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x + 200.0f, -280.0f, this->actor.world.pos.z, 0, 0, 0, 0); Audio_QueueSeqCmd(0x21); diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index c461bbfb0..0fd9e93d8 100644 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -8,6 +8,7 @@ #include "objects/object_sst/object_sst.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #define FLAGS 0x00000435 @@ -289,7 +290,7 @@ void BossSst_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.shape.rot.y = 0; if (Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, ROOM_CENTER_X, ROOM_CENTER_Y, - ROOM_CENTER_Z + 400.0f, 0, 0, 0, -1); + ROOM_CENTER_Z + 400.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, ROOM_CENTER_X, ROOM_CENTER_Y, ROOM_CENTER_Z - 200.0f, 0, 0, 0, 0); Actor_Kill(&this->actor); @@ -1188,7 +1189,7 @@ void BossSst_HeadFinish(BossSst* this, GlobalContext* globalCtx) { } } else if (this->effects[0].alpha == 0) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, ROOM_CENTER_X, ROOM_CENTER_Y, ROOM_CENTER_Z, 0, - 0, 0, -1); + 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, (Math_SinS(this->actor.shape.rot.y) * 200.0f) + ROOM_CENTER_X, ROOM_CENTER_Y, Math_CosS(this->actor.shape.rot.y) * 200.0f + ROOM_CENTER_Z, 0, 0, 0, 0); diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 3afdd7862..d16263860 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -1,6 +1,7 @@ #include "z_boss_tw.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_tw/object_tw.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #define FLAGS 0x00000035 @@ -570,7 +571,7 @@ void BossTw_Init(Actor* thisx, GlobalContext* globalCtx2) { // twinrova has been defeated. Actor_Kill(&this->actor); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 600.0f, 230.0f, 0.0f, 0, - 0, 0, 0xFFFF); + 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -600.0f, 230.0f, 0.0f, 0, 0, 0, 0); } else { sKotakePtr = (BossTw*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_BOSS_TW, @@ -2816,7 +2817,7 @@ void BossTw_TwinrovaDeathCS(BossTw* this, GlobalContext* globalCtx) { func_8002DF54(globalCtx, &this->actor, 7); Audio_QueueSeqCmd(0x21); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 600.0f, 230.0f, - 0.0f, 0, 0, 0, -1); + 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, -600.0f, 230.f, 0.0f, 0, 0, 0, 0); this->actor.world.pos.y = -2000.0f; this->workf[UNK_F18] = 0.0f; diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index 2fec99cb5..43115ab54 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -630,7 +630,7 @@ void BossVa_Init(Actor* thisx, GlobalContext* globalCtx2) { warpId = ACTOR_DOOR_WARP1; } Actor_Spawn(&globalCtx->actorCtx, globalCtx, warpId, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.world.pos.z, 0, 0, 0, 0); //! params could be WARP_DUNGEON_CHILD however this can also spawn Ru1 Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.world.pos.x + 160.0f, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); sDoorState = 100; diff --git a/src/overlays/actors/ovl_Demo_Du/z_demo_du.c b/src/overlays/actors/ovl_Demo_Du/z_demo_du.c index 802dbee62..80c922978 100644 --- a/src/overlays/actors/ovl_Demo_Du/z_demo_du.c +++ b/src/overlays/actors/ovl_Demo_Du/z_demo_du.c @@ -1,6 +1,7 @@ #include "z_demo_du.h" #include "objects/object_du/object_du.h" #include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "vt.h" #define FLAGS 0x00000010 @@ -171,7 +172,7 @@ void DemoDu_CsFireMedallion_SpawnDoorWarp(DemoDu* this, GlobalContext* globalCtx f32 posY = this->actor.world.pos.y; f32 posZ = this->actor.world.pos.z; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 2); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_SAGES); } // Gives the Fire Medallion to Link. diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c index baec20ad9..41f53b858 100644 --- a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c +++ b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c @@ -6,6 +6,7 @@ #include "z_demo_im.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "scenes/indoors/nakaniwa/nakaniwa_scene.h" #include "objects/object_im/object_im.h" #include "vt.h" @@ -304,7 +305,7 @@ void func_80985358(DemoIm* this, GlobalContext* globalCtx) { f32 posY = this->actor.world.pos.y; f32 posZ = this->actor.world.pos.z; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 2); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_SAGES); } void func_809853B4(DemoIm* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c index 22f8e6853..677bcccbf 100644 --- a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c +++ b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c @@ -6,6 +6,7 @@ #include "z_demo_sa.h" #include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "objects/object_sa/object_sa.h" #include "vt.h" @@ -228,7 +229,7 @@ void func_8098E86C(DemoSa* this, GlobalContext* globalCtx) { f32 posY = world->y; f32 posZ = world->z; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 2); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_SAGES); } void func_8098E8C8(DemoSa* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index daa4de2f9..74e4a526f 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -10,7 +10,30 @@ void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx); void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void DoorWarp1_WarpAppear(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_Destination(DoorWarp1* this, GlobalContext* globalCtx); +void func_8099B020(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_AwaitClearFlag(DoorWarp1* this, GlobalContext* globalCtx); +void func_8099A3A4(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_BlueCrystal(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_PurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx); +void func_80999214(DoorWarp1* this, GlobalContext* globalCtx); +void func_80999348(DoorWarp1* this, GlobalContext* globalCtx); +void func_809995D4(DoorWarp1* this, GlobalContext* globalCtx); +void func_809998A4(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_ChildWarpIdle(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_RutoWarpIdle(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_ChildWarpOut(DoorWarp1* this, GlobalContext* globalCtx); +void func_80999EE0(DoorWarp1* this, GlobalContext* globalCtx); +void func_80999FE4(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_RutoWarpOut(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_AdultWarpIdle(DoorWarp1* this, GlobalContext* globalCtx); +void func_8099A508(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_AdultWarpOut(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_DoNothing(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_ChooseInitialAction(DoorWarp1* this, GlobalContext* globalCtx); +void DoorWarp1_FloatPlayer(DoorWarp1* this, GlobalContext* globalCtx); + const ActorInit Door_Warp1_InitVars = { ACTOR_DOOR_WARP1, ACTORCAT_ITEMACTION, @@ -22,77 +45,1005 @@ const ActorInit Door_Warp1_InitVars = { (ActorFunc)DoorWarp1_Update, (ActorFunc)DoorWarp1_Draw, }; -*/ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80998780.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/DoorWarp1_Init.s") +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 4000, ICHAIN_STOP), +}; + +static s16 sWarpTimerTarget; + +void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* this = THIS; + GlobalContext* globalCtx2 = globalCtx; + + this->unk_1B8 = 0; + this->unk_1B4 = 0.0f; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + + if (this->actor.params != WARP_SAGES && this->actor.params != WARP_BLUE_CRYSTAL && + this->actor.params != WARP_YELLOW && this->actor.params != WARP_DESTINATION) { + Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->upperLight = LightContext_InsertLight(globalCtx2, &globalCtx2->lightCtx, &this->upperLightInfo); + + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->lowerLight = LightContext_InsertLight(globalCtx2, &globalCtx2->lightCtx, &this->lowerLightInfo); + } + osSyncPrintf("\nBOSSWARP arg_data=[%d]", this->actor.params); + + DoorWarp1_ChooseInitialAction(this, globalCtx2); +} + +void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { + u8 i; + DoorWarp1* this = THIS; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->upperLight); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lowerLight); + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.unk_8C[0][i] = globalCtx->envCtx.unk_8C[2][i] = globalCtx->envCtx.unk_8C[1][i] = 0; + } + //! @bug SkelAnime_Free is not called for crystal variants +} + +void DoorWarp1_SetupWarp(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->scale = 0; + this->unk_1AE = -140; + this->unk_1B0 = -80; + sWarpTimerTarget = 100; + this->unk_1BC = 1.0f; + this->lightRayAlpha = 0.0f; + this->warpAlpha = 0.0f; + this->crystalAlpha = 0.0f; + + switch (this->actor.params) { + case WARP_YELLOW: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + this->unk_194 = 0.23f; + this->unk_198 = 0.6f; + break; + case WARP_DESTINATION: + this->unk_194 = 0.0f; + this->unk_198 = 0.0f; + break; + case WARP_UNK_7: + this->scale = 100; + this->unk_1AE = 120; + this->unk_1B0 = 230; + this->unk_194 = 0.3f; + this->unk_198 = 0.3f; + break; + case WARP_BLUE_RUTO: + default: + this->unk_194 = 0.3f; + this->unk_198 = 0.3f; + break; + } + + this->unk_19C = 0.0f; + this->actor.shape.yOffset = 1.0f; + this->warpTimer = 0; + + switch (this->actor.params) { + case WARP_PURPLE_CRYSTAL: + case WARP_BLUE_RUTO: + case WARP_UNK_7: + default: + Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 200, 255, 255, 255); + break; + case WARP_CLEAR_FLAG: + case WARP_SAGES: + case WARP_YELLOW: + case WARP_DESTINATION: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + break; + } + + switch (this->actor.params) { + case WARP_CLEAR_FLAG: + DoorWarp1_SetupAction(this, DoorWarp1_AwaitClearFlag); + break; + case WARP_DESTINATION: + if ((!(gSaveContext.entranceIndex == 0x608 || // sacred forest meadow + gSaveContext.entranceIndex == 0x564 || // death mountain crater + gSaveContext.entranceIndex == 0x60C || // lake hylia + gSaveContext.entranceIndex == 0x610 || // desert colossus + gSaveContext.entranceIndex == 0x580) && // graveyard + gSaveContext.sceneSetupIndex < 4) || + (GET_PLAYER(globalCtx)->actor.params & 0xF00) != 0x200) { + Actor_Kill(&this->actor); + } + if (Actor_WorldDistXZToActor(&player->actor, &this->actor) > 100.0f) { + Actor_Kill(&this->actor); + } + DoorWarp1_SetupAction(this, DoorWarp1_Destination); + break; + case WARP_UNK_7: + DoorWarp1_SetupAction(this, func_8099B020); + break; + default: + DoorWarp1_SetupAction(this, DoorWarp1_WarpAppear); + break; + } +} + +void DoorWarp1_SetupAdultDungeonWarp(DoorWarp1* this, GlobalContext* globalCtx) { + SkelAnime_Init(globalCtx, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 40.0f, 1); + + this->scale = 0; + this->unk_1AE = -140; + this->unk_1B0 = -80; + sWarpTimerTarget = 160; + this->actor.shape.yOffset = -400.0f; + this->warpTimer = 0; + this->unk_1BC = 1.0f; + this->unk_194 = 0.3f; + this->unk_198 = 0.3f; + this->lightRayAlpha = 0.0f; + this->warpAlpha = 0.0f; + this->crystalAlpha = 0.0f; + this->unk_19C = 0.0f; + + Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + 200, 255, 255, 255); + + DoorWarp1_SetupAction(this, func_8099A3A4); +} + +void DoorWarp1_SetupBlueCrystal(DoorWarp1* this, GlobalContext* globalCtx) { + s16 i; + + SkelAnime_Init(globalCtx, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 0, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 0.0f, 1); + + this->skelAnime.curFrame = Animation_GetLastFrame(&gWarpCrystalAnim); + this->scale = 10; + this->unk_1AE = 120; + this->unk_1B0 = 230; + this->warpTimer = 0; + this->unk_194 = 0.3f; + this->unk_198 = 0.3f; + this->lightRayAlpha = 0.0f; + this->warpAlpha = 0.0f; + this->crystalAlpha = 0.0f; + this->unk_19C = 0.0f; + this->unk_1BC = 1.0f; + this->actor.shape.yOffset = 800.0f; + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.unk_8C[0][i] = globalCtx->envCtx.unk_8C[2][i] = globalCtx->envCtx.unk_8C[1][i] = -255; + } + + globalCtx->envCtx.unk_9E = -500; + this->warpTimer = 30; + this->unk_1B8 = 4000; + DoorWarp1_SetupAction(this, DoorWarp1_BlueCrystal); +} + +void DoorWarp1_SetupPurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx) { + SkelAnime_Init(globalCtx, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 0, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 0.0f, 1); + + this->skelAnime.curFrame = Animation_GetLastFrame(&gWarpCrystalAnim); + this->unk_1AE = 120; + this->unk_1B0 = 230; + this->warpTimer = 200; + this->unk_1B8 = 4000; + this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 1.0f; + this->unk_194 = 0.3f; + this->unk_198 = 0.3f; + this->lightRayAlpha = 0.0f; + this->warpAlpha = 0.0f; + this->crystalAlpha = 0.0f; + this->unk_19C = 0.0f; + this->unk_1BC = 1.f; + this->actor.shape.yOffset = 800.0f; + + if (gSaveContext.entranceIndex != 0x53) { + this->actor.scale.x = 0.0499f; + this->actor.scale.y = 0.077f; + this->actor.scale.z = 0.09f; + this->crystalAlpha = 255.0f; + } else { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_SHUT_BY_CRYSTAL); + } + DoorWarp1_SetupAction(this, DoorWarp1_PurpleCrystal); +} + +void DoorWarp1_SetPlayerPos(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.velocity.y = 0.0f; + player->actor.world.pos.x = this->actor.world.pos.x; + player->actor.world.pos.y = this->actor.world.pos.y + 55.0f; + player->actor.world.pos.z = this->actor.world.pos.z; +} + +void DoorWarp1_BlueCrystal(DoorWarp1* this, GlobalContext* globalCtx) { + if (this->warpTimer != 0) { + this->warpTimer--; + } else { + DoorWarp1_SetupAction(this, func_80999214); + } + DoorWarp1_SetPlayerPos(this, globalCtx); +} + +void func_80999214(DoorWarp1* this, GlobalContext* globalCtx) { + s32 temp_f4; + f32 phi_f0; + s16 i; + + Math_SmoothStepToF(&this->crystalAlpha, 255.0f, 0.2f, 5.0f, 0.1f); + + phi_f0 = (f32)(40 - this->warpTimer) / 40.0f; + phi_f0 = CLAMP_MIN(phi_f0, 0); + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.unk_8C[0][i] = globalCtx->envCtx.unk_8C[2][i] = + globalCtx->envCtx.unk_8C[1][i] = -255.0f * phi_f0; + } + globalCtx->envCtx.unk_9E = -500.0f * phi_f0; + + this->warpTimer++; + if (phi_f0 <= 0) { + DoorWarp1_SetupAction(this, func_80999348); + } + this->actor.shape.rot.y += 0x320; + DoorWarp1_SetPlayerPos(this, globalCtx); +} + +void func_80999348(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + DoorWarp1_SetPlayerPos(this, globalCtx); + + if (this->warpTimer == 0) { + Math_SmoothStepToF(&this->crystalAlpha, 0.0f, 0.1f, 4.0f, 1.0f); + if (this->crystalAlpha <= 150.0f) { + player->actor.gravity = -0.1f; + } + if (this->crystalAlpha <= 0.0f) { + DoorWarp1_SetupAction(this, DoorWarp1_FloatPlayer); + } + } else { + this->warpTimer--; + } + this->actor.shape.rot.y += 0x320; +} + +void DoorWarp1_FloatPlayer(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.gravity = -0.1f; +} + +void DoorWarp1_PurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx) { + if (this->warpTimer != 0) { + this->warpTimer--; + Math_SmoothStepToF(&this->actor.scale.x, 0.0499f, 0.2f, 0.05f, 0.001f); + Math_SmoothStepToF(&this->actor.scale.y, 0.077f, 0.2f, 0.05f, 0.001f); + Math_SmoothStepToF(&this->actor.scale.z, 0.09f, 0.2f, 0.05f, 0.001f); + Math_SmoothStepToF(&this->crystalAlpha, 255.0f, 0.2f, 5.0f, 0.1f); + } +} + +void DoorWarp1_ChooseInitialAction(DoorWarp1* this, GlobalContext* globalCtx) { + switch (this->actor.params) { + case WARP_DUNGEON_CHILD: + case WARP_CLEAR_FLAG: + case WARP_SAGES: + case WARP_YELLOW: + case WARP_BLUE_RUTO: + case WARP_DESTINATION: + case WARP_UNK_7: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + DoorWarp1_SetupWarp(this, globalCtx); + break; + case WARP_DUNGEON_ADULT: + DoorWarp1_SetupAdultDungeonWarp(this, globalCtx); + break; + case WARP_BLUE_CRYSTAL: + DoorWarp1_SetupBlueCrystal(this, globalCtx); + break; + case WARP_PURPLE_CRYSTAL: + DoorWarp1_SetupPurpleCrystal(this, globalCtx); + break; + } +} + +void DoorWarp1_AwaitClearFlag(DoorWarp1* this, GlobalContext* globalCtx) { + if (Flags_GetTempClear(globalCtx, this->actor.room)) { + this->warpTimer = 200; + Audio_QueueSeqCmd(0x21); + DoorWarp1_SetupAction(this, func_809995D4); + } +} + +void func_809995D4(DoorWarp1* this, GlobalContext* globalCtx) { + if (this->warpTimer == 0) { + if (this->actor.xzDistToPlayer < 100.0f) { + this->actor.world.pos.x = -98.0f; + this->actor.world.pos.y = 827.0f; + this->actor.world.pos.z = -3228.0f; + } + Lights_PointNoGlowSetInfo(&this->upperLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 200, 255, 255, 255); + DoorWarp1_SetupAction(this, DoorWarp1_WarpAppear); + } + this->warpTimer--; +} + +void DoorWarp1_WarpAppear(DoorWarp1* this, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Math_SmoothStepToF(&this->lightRayAlpha, 255.0f, 0.4f, 10.0f, 0.01f); + Math_SmoothStepToF(&this->warpAlpha, 255.0f, 0.4f, 10.0f, 0.01f); + + if (this->actor.params != WARP_YELLOW && this->actor.params != WARP_ORANGE && this->actor.params != WARP_GREEN && + this->actor.params != WARP_RED) { + if (this->scale < 100) { + this->scale += 2; + } + if (this->unk_1AE < 120) { + this->unk_1AE += 4; + } + if (this->unk_1B0 < 230) { + this->unk_1B0 += 4; + } else if (this->actor.params == WARP_BLUE_RUTO) { + DoorWarp1_SetupAction(this, DoorWarp1_RutoWarpIdle); + } else if (this->actor.params != WARP_SAGES && this->actor.params != WARP_YELLOW) { + DoorWarp1_SetupAction(this, DoorWarp1_ChildWarpIdle); + } else { + DoorWarp1_SetupAction(this, func_809998A4); + } + } else { + if (this->unk_1AE < -50) { + this->unk_1AE += 4; + } + if (this->unk_1B0 < 70) { + this->unk_1B0 += 4; + } else { + DoorWarp1_SetupAction(this, func_809998A4); + } + } +} + +void func_809998A4(DoorWarp1* this, GlobalContext* globalCtx) { + if (this->lightRayAlpha != 0.0f) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + } + Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.1f, 2.0f, 0.01f); + Math_SmoothStepToF(&this->warpAlpha, 0.0f, 0.1f, 2.0f, 0.01f); +} + +s32 DoorWarp1_PlayerInRange(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if (fabsf(this->actor.xzDistToPlayer) < 60.0f) { + if ((player->actor.world.pos.y - 20.0f) < this->actor.world.pos.y) { + if (this->actor.world.pos.y < (player->actor.world.pos.y + 20.0f)) { + ret = true; + } + } + } + return ret; +} + +void DoorWarp1_ChildWarpIdle(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player; + + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + + if (DoorWarp1_PlayerInRange(this, globalCtx)) { + player = GET_PLAYER(globalCtx); + + Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + OnePointCutscene_Init(globalCtx, 0x25E7, 999, &this->actor, MAIN_CAM); + func_8002DF54(globalCtx, &this->actor, 10); + + player->unk_450.x = this->actor.world.pos.x; + player->unk_450.z = this->actor.world.pos.z; + this->unk_1B2 = 1; + DoorWarp1_SetupAction(this, DoorWarp1_ChildWarpOut); + } +} + +void DoorWarp1_ChildWarpOut(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1B2 >= 101) { + if (player->actor.velocity.y < 10.0f) { + player->actor.gravity = 0.1f; + } else { + player->actor.gravity = 0.0f; + } + } else { + this->unk_1B2++; + } + + Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.2f, 6.0f, 0.01f); + this->warpTimer++; + + if (sWarpTimerTarget < this->warpTimer && gSaveContext.nextCutsceneIndex == 0xFFEF) { + osSyncPrintf("\n\n\nじかんがきたからおーしまい fade_direction=[%d]", globalCtx->sceneLoadFlag, 0x14); + + if (globalCtx->sceneNum == SCENE_DDAN_BOSS) { + if (!Flags_GetEventChkInf(0x25)) { + Flags_SetEventChkInf(0x25); + Item_Give(globalCtx, ITEM_GORON_RUBY); + globalCtx->nextEntranceIndex = 0x13D; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + globalCtx->nextEntranceIndex = 0x47A; + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_YDAN_BOSS) { + if (!Flags_GetEventChkInf(7)) { + Flags_SetEventChkInf(7); + Flags_SetEventChkInf(9); + Item_Give(globalCtx, ITEM_KOKIRI_EMERALD); + globalCtx->nextEntranceIndex = 0xEE; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + globalCtx->nextEntranceIndex = 0x457; + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_BDAN_BOSS) { + globalCtx->nextEntranceIndex = 0x10E; + gSaveContext.nextCutsceneIndex = 0; + } + osSyncPrintf("\n\n\nおわりおわり"); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 7; + gSaveContext.nextTransition = 3; + } + + Math_StepToF(&this->unk_194, 2.0f, 0.01f); + Math_StepToF(&this->unk_198, 10.0f, 0.02f); + Lights_PointNoGlowSetInfo(&this->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, + (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, + 255, 255); + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, + (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, + 255, 255); + Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); +} + +void DoorWarp1_RutoWarpIdle(DoorWarp1* this, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + + if (this->rutoWarpState != WARP_BLUE_RUTO_STATE_INITIAL && DoorWarp1_PlayerInRange(this, globalCtx)) { + this->rutoWarpState = WARP_BLUE_RUTO_STATE_ENTERED; + func_8002DF54(globalCtx, &this->actor, 10); + this->unk_1B2 = 1; + DoorWarp1_SetupAction(this, func_80999EE0); + } +} + +static s16 sRutoWarpSubCamId; + +void func_80999EE0(DoorWarp1* this, GlobalContext* globalCtx) { + Vec3f at; + Vec3f eye; + Player* player = GET_PLAYER(globalCtx); + + if (this->rutoWarpState == WARP_BLUE_RUTO_STATE_3) { + Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); + sRutoWarpSubCamId = Gameplay_CreateSubCamera(globalCtx); + + Gameplay_ChangeCameraStatus(globalCtx, sRutoWarpSubCamId, CAM_STAT_ACTIVE); + at.x = this->actor.world.pos.x; + at.y = 49.0f; + at.z = this->actor.world.pos.z; + eye.x = player->actor.world.pos.x; + eye.y = 43.0f; + eye.z = player->actor.world.pos.z; + + Gameplay_CameraSetAtEye(globalCtx, sRutoWarpSubCamId, &at, &eye); + Gameplay_CameraSetFov(globalCtx, sRutoWarpSubCamId, 90.0f); + this->rutoWarpState = WARP_BLUE_RUTO_STATE_TALKING; + func_8010B680(globalCtx, 0x4022, NULL); + DoorWarp1_SetupAction(this, func_80999FE4); + } +} + +void func_80999FE4(DoorWarp1* this, GlobalContext* globalCtx) { + if (func_8010BDBC(&globalCtx->msgCtx) == 0) { + Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + OnePointCutscene_Init(globalCtx, 0x25E9, 999, &this->actor, MAIN_CAM); + Gameplay_CopyCamera(globalCtx, -1, sRutoWarpSubCamId); + Gameplay_ChangeCameraStatus(globalCtx, sRutoWarpSubCamId, CAM_STAT_WAIT); + this->rutoWarpState = WARP_BLUE_RUTO_STATE_WARPING; + DoorWarp1_SetupAction(this, DoorWarp1_RutoWarpOut); + } +} + +void DoorWarp1_RutoWarpOut(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1B2 >= 61) { + if (player->actor.velocity.y < 10.f) { + player->actor.gravity = 0.02f; + } else { + player->actor.gravity = 0.0f; + } + } else { + this->unk_1B2++; + } + Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.2f, 6.0f, 0.01f); + this->warpTimer++; + + if (this->warpTimer > sWarpTimerTarget && gSaveContext.nextCutsceneIndex == 0xFFEF) { + gSaveContext.eventChkInf[3] |= 0x80; + Item_Give(globalCtx, ITEM_ZORA_SAPPHIRE); + globalCtx->nextEntranceIndex = 0x10E; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 7; + } + + Math_StepToF(&this->unk_194, 2.0f, 0.01f); + Math_StepToF(&this->unk_198, 10.f, 0.02f); + Lights_PointNoGlowSetInfo(&this->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, + (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, + 255, 255); + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, + (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, + 255, 255); + Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); +} + +void func_8099A3A4(DoorWarp1* this, GlobalContext* globalCtx) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Math_SmoothStepToF(&this->lightRayAlpha, 255.0f, 0.2f, 2.0f, 0.1f); + Math_SmoothStepToF(&this->warpAlpha, 255.0f, 0.2f, 2.0f, 0.1f); + + if (this->scale < 10) { + this->scale += 2; + } + if (this->unk_1AE < 120) { + this->unk_1AE += 4; + } + if (this->unk_1B0 < 230) { + this->unk_1B0 += 4; + } else { + DoorWarp1_SetupAction(this, DoorWarp1_AdultWarpIdle); + } +} + +void DoorWarp1_AdultWarpIdle(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player; + + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + + if (DoorWarp1_PlayerInRange(this, globalCtx)) { + player = GET_PLAYER(globalCtx); + + OnePointCutscene_Init(globalCtx, 0x25E8, 999, &this->actor, MAIN_CAM); + func_8002DF54(globalCtx, &this->actor, 10); + player->unk_450.x = this->actor.world.pos.x; + player->unk_450.z = this->actor.world.pos.z; + this->unk_1B2 = 20; + DoorWarp1_SetupAction(this, func_8099A508); + } +} + +void func_8099A508(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1B2 != 0) { + this->unk_1B2--; + return; + } + Audio_PlaySoundGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), ANIMMODE_ONCE, 40.0f, 1); + + this->unk_1B2 = 0x32; + DoorWarp1_SetupAction(this, DoorWarp1_AdultWarpOut); +} + +void DoorWarp1_AdultWarpOut(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0_2; + + if (this->unk_1B2 != 0) { + this->unk_1B2--; + } + + if (this->unk_1B2 < 31) { + u32 phi_v0 = (LINK_IS_ADULT) ? 35 : 45; + + if ((player->actor.world.pos.y - this->actor.world.pos.y) <= phi_v0) { + player->actor.gravity = 0.0139999995f; + } else { + player->actor.gravity = 0.0f; + player->actor.velocity.y = 0.0f; + } + if (this->unk_1B2 <= 0) { + if (this->unk_1B8 < 4000) { + this->unk_1B8 += 40; + } + player->actor.world.rot.y -= this->unk_1B8; + player->actor.shape.rot.y -= this->unk_1B8; + } + Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 0.5f, 0.1f, 0.01f); + Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 0.5f, 0.1f, 0.01f); + } + this->warpTimer++; + + if (this->warpTimer > sWarpTimerTarget && gSaveContext.nextCutsceneIndex == 0xFFEF) { + if (globalCtx->sceneNum == SCENE_MORIBOSSROOM) { + if (!(gSaveContext.eventChkInf[4] & 0x100)) { + gSaveContext.eventChkInf[4] |= 0x100; + Item_Give(globalCtx, ITEM_MEDALLION_FOREST); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x600; + } else { + globalCtx->nextEntranceIndex = 0x608; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_FIRE_BS) { + if (!(gSaveContext.eventChkInf[4] & 0x200)) { + gSaveContext.eventChkInf[4] |= 0x200; + Item_Give(globalCtx, ITEM_MEDALLION_FIRE); + globalCtx->nextEntranceIndex = 0xDB; + gSaveContext.nextCutsceneIndex = 0xFFF3; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x4F6; + } else { + globalCtx->nextEntranceIndex = 0x564; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_MIZUSIN_BS) { + if (!(gSaveContext.eventChkInf[4] & 0x400)) { + gSaveContext.eventChkInf[4] |= 0x400; + Item_Give(globalCtx, ITEM_MEDALLION_WATER); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_WATER; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x604; + } else { + globalCtx->nextEntranceIndex = 0x60C; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_JYASINBOSS) { + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { + Item_Give(globalCtx, ITEM_MEDALLION_SPIRIT); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_SPIRIT; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x1F1; + } else { + globalCtx->nextEntranceIndex = 0x610; + } + gSaveContext.nextCutsceneIndex = 0; + } + } else if (globalCtx->sceneNum == SCENE_HAKADAN_BS) { + if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { + Item_Give(globalCtx, ITEM_MEDALLION_SHADOW); + globalCtx->nextEntranceIndex = 0x6B; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_SHADOW; + } else { + if (!LINK_IS_ADULT) { + globalCtx->nextEntranceIndex = 0x568; + } else { + globalCtx->nextEntranceIndex = 0x580; + } + gSaveContext.nextCutsceneIndex = 0; + } + } + globalCtx->sceneLoadFlag = 0x14; + globalCtx->fadeTransition = 3; + gSaveContext.nextTransition = 7; + } + if (this->warpTimer >= 141) { + f32 phi_f0; + + globalCtx->envCtx.unk_E1 = 1; + phi_f0 = (f32)(this->warpTimer - 140) / 20.0f; + + if (phi_f0 > 1.0f) { + phi_f0 = 1.0f; + } + globalCtx->envCtx.unk_E2[0] = 160; + globalCtx->envCtx.unk_E2[1] = 160; + globalCtx->envCtx.unk_E2[2] = 160; + globalCtx->envCtx.unk_E2[3] = (u32)(255.0f * phi_f0); + + osSyncPrintf("\nparcent=[%f]", phi_f0); + } + Lights_PointNoGlowSetInfo(&this->upperLightInfo, (s16)player->actor.world.pos.x + 10.0f, + (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 235, 255, + 255, 255); + Lights_PointNoGlowSetInfo(&this->lowerLightInfo, (s16)player->actor.world.pos.x - 10.0f, + (s16)player->actor.world.pos.y - 10.0f, (s16)player->actor.world.pos.z - 10.0f, 235, 255, + 255, 255); + + Math_SmoothStepToF(&this->actor.shape.yOffset, 800.0f, 0.5f, 15.0f, 0.1f); + this->actor.shape.rot.y += 0x320; + + Math_SmoothStepToF(&this->unk_1BC, 1.13f, 0.2f, 0.1f, 0.01f); + Math_StepToF(&this->unk_194, 2.0f, 0.003f); + Math_StepToF(&this->unk_198, 10.0f, 0.006f); + Math_SmoothStepToF(&this->lightRayAlpha, 0.0f, 0.2f, 3.0f, 0.01f); + Math_SmoothStepToF(&this->warpAlpha, 0.0f, 0.2f, 2.0f, 0.01f); + Math_SmoothStepToF(&this->crystalAlpha, 255.0f, 0.1f, 1.0f, 0.01f); + + temp_f0_2 = 1.0f - (f32)(sWarpTimerTarget - this->warpTimer) / (sWarpTimerTarget - (sWarpTimerTarget - 100)); + if (temp_f0_2 > 0.0f) { + s16 i; + + for (i = 0; i < 3; i++) { + globalCtx->envCtx.unk_8C[0][i] = globalCtx->envCtx.unk_8C[2][i] = + globalCtx->envCtx.unk_8C[1][i] = -255.0f * temp_f0_2; + } + + globalCtx->envCtx.unk_9E = -500.0f * temp_f0_2; + if (globalCtx->envCtx.unk_9E < -300) { + globalCtx->roomCtx.curRoom.segment = NULL; + } + } +} + +void DoorWarp1_Destination(DoorWarp1* this, GlobalContext* globalCtx) { + f32 alphaFrac; + + this->warpTimer++; + this->unk_194 = 5.0f; + + alphaFrac = 1.0f; + if (this->warpTimer < 20) { + alphaFrac = this->warpTimer / 20.f; + } else if (this->warpTimer >= 60) { + alphaFrac = 1.0f - ((this->warpTimer - 60.0f) / 20.f); + } + this->warpAlpha = 255.0f * alphaFrac; + this->lightRayAlpha = 0.0f; + + if (this->warpTimer >= 80.0f) { + this->warpAlpha = 0.0f; + DoorWarp1_SetupAction(this, DoorWarp1_DoNothing); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); +} + +void DoorWarp1_DoNothing(DoorWarp1* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/DoorWarp1_Destroy.s") +void func_8099B020(DoorWarp1* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->lightRayAlpha, 128.0f, 0.2f, 2.0f, 0.1f); + Math_SmoothStepToF(&this->warpAlpha, 128.0f, 0.2f, 2.0f, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099898C.s") + if (this->lightRayAlpha >= 128.0f) { + Math_StepToF(&this->unk_194, 2.0f, 0.01f); + Math_StepToF(&this->unk_198, 10.0f, 0.02f); + } + Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80998C90.s") +void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80998E5C.s") + this->actionFunc(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80998FF4.s") + if (this->actor.params != WARP_PURPLE_CRYSTAL) { + Actor_SetScale(&this->actor, this->scale / 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999194.s") +void DoorWarp1_DrawBlueCrystal(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_809991C8.s") + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2078); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999214.s") + func_80093D84(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999348.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (u8)this->crystalAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (u8)this->crystalAlpha); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999410.s") + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, + &this->actor, POLY_XLU_DISP); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999428.s") + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2098); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999508.s") + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999580.s") +void DoorWarp1_DrawPurpleCrystal(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f eye; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_809995D4.s") + eye.x = -(Math_SinS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; + eye.y = (Math_CosS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; + eye.z = (Math_CosS(globalCtx->state.frames * 200) * 120.0f) * 80.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999724.s") + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2122); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_809998A4.s") + func_80093D84(globalCtx->state.gfxCtx); + func_8002EB44(&this->actor.world.pos, &eye, &eye, globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999938.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->crystalAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 0, 100, (u8)this->crystalAlpha); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_809999A0.s") + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, + &this->actor, POLY_XLU_DISP); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999A68.s") + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2152); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999E64.s") + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999EE0.s") +void DoorWarp1_DrawWarp(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad; + u32 pad1; + u32 spEC = globalCtx->state.frames * 10; + f32 spE8 = (this->unk_194 >= 1.0f) ? 0.0f : 1.0f - this->unk_194; + f32 spE4 = (this->unk_198 >= 1.0f) ? 0.0f : 1.0f - this->unk_198; + f32 xzScale; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_80999FE4.s") + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2173); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099A098.s") + temp_f0 = 1.0f - (2.0f - this->unk_194) / 1.7f; + if (this->actor.params != WARP_YELLOW && this->actor.params != WARP_DESTINATION && this->actor.params != WARP_ORANGE && + this->actor.params != WARP_GREEN && this->actor.params != WARP_RED) { + this->unk_19C += (s16)(temp_f0 * 15.0f); + } + if (this->actor.params == WARP_DESTINATION) { + this->unk_19C -= (s16)(temp_f0 * 2.0f); + } + func_80093D84(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099A3A4.s") + switch (this->actor.params) { + case WARP_YELLOW: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 255); + break; + case WARP_ORANGE: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + break; + case WARP_GREEN: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 200, 0, 255); + break; + case WARP_RED: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + break; + default: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255 * temp_f0, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255 * temp_f0, 255, 255); + break; + } + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_AD_NOTPATTERN | G_CD_MAGICSQ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099A46C.s") + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 1.0f, this->actor.world.pos.z, MTXMODE_NEW); + gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2247)); + Matrix_Push(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099A508.s") + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, spEC & 0xFF, -((s16)(this->unk_19C + this->unk_19C) & 511), + 0x100, 0x100, 1, spEC & 0xFF, -((s16)(this->unk_19C + this->unk_19C) & 511), 0x100, + 0x100)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099A5EC.s") + Matrix_Translate(0.0f, this->unk_194 * 230.0f, 0.0f, MTXMODE_APPLY); + xzScale = (((f32)this->unk_1AE * spE8) / 100.0f) + 1.0f; + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2267)); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); + Matrix_Pop(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099AEE4.s") + if (this->lightRayAlpha > 0.0f) { + switch (this->actor.params) { + case WARP_YELLOW: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 255); + break; + case WARP_ORANGE: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + break; + case WARP_GREEN: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 200, 0, 255); + break; + case WARP_RED: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255, 255, 255, (u8)this->warpAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + break; + default: + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 255 * temp_f0, 255, 255, (u8)this->lightRayAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255 * temp_f0, 255, 255); + break; + } + spEC *= 2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099B014.s") + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, spEC & 0xFF, -((s16)this->unk_19C & 511), 0x100, 0x100, + 1, spEC & 0xFF, -((s16)this->unk_19C & 511), 0x100, 0x100)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099B020.s") + Matrix_Translate(0.0f, this->unk_198 * 60.0f, 0.0f, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/DoorWarp1_Update.s") + xzScale = (((f32)this->unk_1B0 * spE4) / 100.0f) + 1.0f; + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099B140.s") + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2336)); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099B33C.s") + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_door_warp1.c", 2340); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/func_8099B5EC.s") +void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Warp1/DoorWarp1_Draw.s") + switch (this->actor.params) { + case WARP_DUNGEON_ADULT: + DoorWarp1_DrawBlueCrystal(this, globalCtx); + DoorWarp1_DrawWarp(this, globalCtx); + break; + case WARP_DUNGEON_CHILD: + case WARP_CLEAR_FLAG: + case WARP_SAGES: + case WARP_YELLOW: + case WARP_BLUE_RUTO: + case WARP_DESTINATION: + case WARP_UNK_7: + case WARP_ORANGE: + case WARP_GREEN: + case WARP_RED: + DoorWarp1_DrawWarp(this, globalCtx); + break; + case WARP_BLUE_CRYSTAL: + DoorWarp1_DrawBlueCrystal(this, globalCtx); + break; + case WARP_PURPLE_CRYSTAL: + DoorWarp1_DrawPurpleCrystal(this, globalCtx); + break; + } +} diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h index 0cd313c6f..e9b75b7e4 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h @@ -6,12 +6,58 @@ struct DoorWarp1; +typedef enum { + /* -2 */ WARP_BLUE_CRYSTAL = -2, + /* -1 */ WARP_DUNGEON_ADULT, + /* 0 */ WARP_DUNGEON_CHILD, + /* 1 */ WARP_CLEAR_FLAG, // Activate on temp clear flag + /* 2 */ WARP_SAGES, // Used by sages warping into chamber of sages during their cutscene + /* 3 */ WARP_PURPLE_CRYSTAL, + /* 4 */ WARP_YELLOW, // The colored variants don't warp, they are cutscene setpieces + /* 5 */ WARP_BLUE_RUTO, + /* 6 */ WARP_DESTINATION, // Spawning in after having taken a warp + /* 7 */ WARP_UNK_7, + /* 8 */ WARP_ORANGE, + /* 9 */ WARP_GREEN, + /* 10 */ WARP_RED +} DoorWarp1Type; + +typedef enum { + /* 0 */ WARP_BLUE_RUTO_STATE_INITIAL, // initial, warp doesn't work yet + /* 1 */ WARP_BLUE_RUTO_STATE_READY, // set by ruto, warp can work now + /* 2 */ WARP_BLUE_RUTO_STATE_ENTERED, // set by warp, player has stepped into the warp + /* 3 */ WARP_BLUE_RUTO_STATE_3, // set by ruto, folding arms + /* 4 */ WARP_BLUE_RUTO_STATE_TALKING, // set by warp, dialog started + /* 5 */ WARP_BLUE_RUTO_STATE_WARPING // set by warp, after closing dialog +} DoorWarp1RutoState; + +typedef void (*DoorWarp1ActionFunc)(struct DoorWarp1*, GlobalContext*); + typedef struct DoorWarp1 { /* 0x0000 */ Actor actor; - /* 0x014C */ char unk_14C[0x5C]; - /* 0x01A8 */ f32 alpha; - /* 0x01AC */ char unk_1AC[0x40]; - /* 0x01EC */ s32 unk_1EC; + /* 0x014C */ SkelAnime skelAnime; + /* 0x0190 */ char unk_190[0x2]; + /* 0x0192 */ u16 warpTimer; + /* 0x0194 */ f32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ f32 lightRayAlpha; + /* 0x01A4 */ f32 warpAlpha; + /* 0x01A8 */ f32 crystalAlpha; + /* 0x01AC */ s16 scale; + /* 0x01AE */ s16 unk_1AE; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s16 unk_1B2; + /* 0x01B4 */ f32 unk_1B4; + /* 0x01B8 */ s16 unk_1B8; + /* 0x01BA */ u16 unk_1BA; + /* 0x01BC */ f32 unk_1BC; + /* 0x01C0 */ DoorWarp1ActionFunc actionFunc; + /* 0x01C4 */ LightNode* upperLight; + /* 0x01C8 */ LightInfo upperLightInfo; + /* 0x01D8 */ LightNode* lowerLight; + /* 0x01DC */ LightInfo lowerLightInfo; + /* 0x01EC */ s32 rutoWarpState; // for state communication with En_Ru1 using DoorWarp1RutoState values } DoorWarp1; // size = 0x01F0 #endif diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index dbdd66225..6686c4a91 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -7,6 +7,7 @@ #include "z_en_nb.h" #include "vt.h" #include "objects/object_nb/object_nb.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #define FLAGS 0x00000010 @@ -312,7 +313,7 @@ void EnNb_SpawnBlueWarp(EnNb* this, GlobalContext* globalCtx) { f32 posY = this->actor.world.pos.y; f32 posZ = this->actor.world.pos.z; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 2); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_SAGES); } void EnNb_GiveMedallion(EnNb* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index 309e80f80..c02257c31 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -999,7 +999,7 @@ void func_80AECCB0(EnRu1* this, GlobalContext* globalCtx) { spawnY = pos->y; spawnZ = ((kREG(1) + 12.0f) * Math_CosS(yawTowardsPlayer)) + pos->z; this->blueWarp = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, - spawnX, spawnY, spawnZ, 0, yawTowardsPlayer, 0, 5); + spawnX, spawnY, spawnZ, 0, yawTowardsPlayer, 0, WARP_BLUE_RUTO); } void func_80AECDA0(EnRu1* this, GlobalContext* globalCtx) { @@ -1068,16 +1068,16 @@ s32 func_80AECF6C(EnRu1* this, GlobalContext* globalCtx) { return false; } -s32 func_80AED084(EnRu1* this, UNK_TYPE arg1) { - if (this->blueWarp != NULL && this->blueWarp->unk_1EC == arg1) { +s32 func_80AED084(EnRu1* this, s32 state) { + if (this->blueWarp != NULL && this->blueWarp->rutoWarpState == state) { return true; } return false; } -void func_80AED0B0(EnRu1* this, UNK_TYPE arg1) { +void func_80AED0B0(EnRu1* this, s32 state) { if (this->blueWarp != NULL) { - this->blueWarp->unk_1EC = arg1; + this->blueWarp->rutoWarpState = state; } } @@ -1097,12 +1097,12 @@ void func_80AED110(EnRu1* this) { if (this->actor.shape.yOffset >= 0.0f) { this->action = 18; this->actor.shape.yOffset = 0.0f; - func_80AED0B0(this, 1); + func_80AED0B0(this, WARP_BLUE_RUTO_STATE_READY); } } void func_80AED154(EnRu1* this, GlobalContext* globalCtx) { - if (func_80AED084(this, 2)) { + if (func_80AED084(this, WARP_BLUE_RUTO_STATE_ENTERED)) { this->action = 0x13; this->unk_26C = 0.0f; func_80AECEB4(this, globalCtx); @@ -1115,17 +1115,17 @@ void func_80AED19C(EnRu1* this, s32 cond) { Animation_GetLastFrame(&gRutoChildTransitionHandsOnHipToCrossArmsAndLegsAnim), ANIMMODE_ONCE, -8.0f); this->action = 20; - func_80AED0B0(this, 3); + func_80AED0B0(this, WARP_BLUE_RUTO_STATE_3); } } void func_80AED218(EnRu1* this, UNK_TYPE arg1) { - if (func_80AED084(this, 4)) { + if (func_80AED084(this, WARP_BLUE_RUTO_STATE_TALKING)) { if (arg1 != 0) { Animation_Change(&this->skelAnime, &gRutoChildWaitSittingAnim, 1.0f, 0, Animation_GetLastFrame(&gRutoChildWaitSittingAnim), ANIMMODE_LOOP, -8.0f); } - } else if (func_80AED084(this, 5)) { + } else if (func_80AED084(this, WARP_BLUE_RUTO_STATE_WARPING)) { Animation_Change(&this->skelAnime, &gRutoChildWaitInBlueWarpAnim, 1.0f, 0, Animation_GetLastFrame(&gRutoChildWaitInBlueWarpAnim), ANIMMODE_ONCE, -8.0f); this->action = 21; diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c index cc9fccb0f..62a1185c9 100644 --- a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c +++ b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c @@ -6,6 +6,7 @@ #include "z_en_ru2.h" #include "objects/object_ru2/object_ru2.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "vt.h" #define FLAGS 0x00000010 @@ -247,7 +248,7 @@ void func_80AF29DC(EnRu2* this, GlobalContext* globalCtx) { f32 posY = thisx->world.pos.y; f32 posZ = thisx->world.pos.z; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 2); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_SAGES); } void func_80AF2A38(EnRu2* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index f2697d65f..fa361556f 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -6,6 +6,7 @@ #include "z_en_xc.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "objects/object_xc/object_xc.h" #include "scenes/overworld/spot05/spot05_scene.h" #include "scenes/overworld/spot17/spot17_scene.h" @@ -1391,7 +1392,7 @@ void func_80B3F534(GlobalContext* globalCtx) { u16 frameCount = csCtx->frames; if (frameCount == 310) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, -1044.0f, -1243.0f, 7458.0f, 0, 0, 0, 6); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, -1044.0f, -1243.0f, 7458.0f, 0, 0, 0, WARP_DESTINATION); } } diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c index 70516fb0b..bb7b11f0a 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -649,7 +649,7 @@ void func_80B4FF84(EnZl2* this, GlobalContext* globalCtx) { posY = this->actor.world.pos.y; posZ = this->actor.world.pos.z; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 4); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_YELLOW); this->unk_250 = 1; } } @@ -665,7 +665,7 @@ void func_80B4FFF0(EnZl2* this, GlobalContext* globalCtx) { posZ = this->actor.world.pos.z; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0x4000, - 0, 3); + 0, WARP_PURPLE_CRYSTAL); this->unk_248 = 1; } } @@ -707,7 +707,7 @@ void func_80B500E0(EnZl2* this, GlobalContext* globalCtx) { void func_80B501C4(EnZl2* this, s32 alpha) { if (this->actor.child != NULL) { - ((DoorWarp1*)this->actor.child)->alpha = alpha; + ((DoorWarp1*)this->actor.child)->crystalAlpha = alpha; } } @@ -1183,7 +1183,7 @@ void func_80B513A8(EnZl2* this, GlobalContext* globalCtx) { posX = player->actor.world.pos.x; posY = player->actor.world.pos.y; posZ = player->actor.world.pos.z; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, 7); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0, 0, WARP_UNK_7); this->unk_250 = 1; } } diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 9f771ec90..6fd915525 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -786,7 +786,7 @@ void func_80B54F18(EnZl3* this, GlobalContext* globalCtx) { f32 posZ = this->actor.world.pos.z; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, posX, posY, posZ, 0, 0x4000, - 0, 3); + 0, WARP_PURPLE_CRYSTAL); this->unk_2F8 = 1; } } @@ -813,7 +813,7 @@ void func_80B55054(EnZl3* this) { f32* temp_v0 = &this->unk_2EC; if (*temp_v0 < 19.0f) { - ((DoorWarp1*)child)->alpha = (20.0f - *temp_v0) * 12.75f; + ((DoorWarp1*)child)->crystalAlpha = (20.0f - *temp_v0) * 12.75f; *temp_v0 += 1.0f; } else { Actor_Kill(child); |
