mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-07 06:40:15 +00:00
Bg_Mori_Idomizu (#401)
* Darkmeiro decompilation Bg_Gnd_Darkmeiro decompiled, matched, and documented. * give this a shot * fix conflict * one more try * matching * merge and cleanup * wait for mori tex * name
This commit is contained in:
parent
00fb26a441
commit
a506801cd7
16 changed files with 168 additions and 493 deletions
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
* File: z_bg_mori_idomizu.c
|
||||
* Overlay: ovl_Bg_Mori_Idomizu
|
||||
* Description: Square of water in Forest Temple well
|
||||
*/
|
||||
|
||||
#include "z_bg_mori_idomizu.h"
|
||||
|
||||
#define FLAGS 0x00000030
|
||||
|
@ -7,8 +13,17 @@
|
|||
void BgMoriIdomizu_Init(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgMoriIdomizu_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgMoriIdomizu_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgMoriIdomizu_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* this);
|
||||
void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, GlobalContext* globalCtx);
|
||||
void BgMoriIdomizu_SetupMain(BgMoriIdomizu* this);
|
||||
void BgMoriIdomizu_Main(BgMoriIdomizu* this, GlobalContext* globalCtx);
|
||||
|
||||
extern Gfx D_060049D0[];
|
||||
|
||||
static s16 sAlreadyLoaded = false;
|
||||
|
||||
/*
|
||||
const ActorInit Bg_Mori_Idomizu_InitVars = {
|
||||
ACTOR_BG_MORI_IDOMIZU,
|
||||
ACTORTYPE_BG,
|
||||
|
@ -20,23 +35,152 @@ const ActorInit Bg_Mori_Idomizu_InitVars = {
|
|||
(ActorFunc)BgMoriIdomizu_Update,
|
||||
NULL,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A4640.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A4648.s")
|
||||
void BgMoriIdomizu_SetupAction(BgMoriIdomizu* this, BgMoriIdomizuActionFunc actionFunc) {
|
||||
this->actionFunc = actionFunc;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/BgMoriIdomizu_Init.s")
|
||||
void BgMoriIdomizu_SetWaterLevel(GlobalContext* globalCtx, s16 waterLevel) {
|
||||
WaterBox* waterBox = globalCtx->colCtx.stat.colHeader->waterBoxes;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/BgMoriIdomizu_Destroy.s")
|
||||
waterBox[2].unk_02 = waterLevel;
|
||||
waterBox[3].unk_02 = waterLevel;
|
||||
waterBox[4].unk_02 = waterLevel;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A47D8.s")
|
||||
void BgMoriIdomizu_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
BgMoriIdomizu* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A47FC.s")
|
||||
if (sAlreadyLoaded) {
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
}
|
||||
this->actor.scale.x = 1.1f;
|
||||
this->actor.scale.y = 1.0f;
|
||||
this->actor.scale.z = 1.0f;
|
||||
this->actor.posRot.pos.x = 119.0f;
|
||||
this->actor.posRot.pos.z = -1820.0f;
|
||||
this->prevSwitchFlagSet = Flags_GetSwitch(globalCtx, this->actor.params & 0x3F);
|
||||
if (this->prevSwitchFlagSet != 0) {
|
||||
this->actor.posRot.pos.y = -282.0f;
|
||||
BgMoriIdomizu_SetWaterLevel(globalCtx, -282);
|
||||
} else {
|
||||
this->actor.posRot.pos.y = 184.0f;
|
||||
BgMoriIdomizu_SetWaterLevel(globalCtx, 184);
|
||||
}
|
||||
this->moriTexObjIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MORI_TEX);
|
||||
if (this->moriTexObjIndex < 0) {
|
||||
Actor_Kill(&this->actor);
|
||||
// Bank danger!
|
||||
osSyncPrintf("Error : バンク危険!(arg_data 0x%04x)(%s %d)\n", this->actor.params, "../z_bg_mori_idomizu.c",
|
||||
202);
|
||||
return;
|
||||
}
|
||||
BgMoriIdomizu_SetupWaitForMoriTex(this);
|
||||
sAlreadyLoaded = true;
|
||||
this->isLoaded = true;
|
||||
this->actor.room = -1;
|
||||
// Forest Temple well water
|
||||
osSyncPrintf("(森の神殿 井戸水)(arg_data 0x%04x)\n", this->actor.params);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A4850.s")
|
||||
void BgMoriIdomizu_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
BgMoriIdomizu* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A4874.s")
|
||||
if (this->isLoaded) {
|
||||
sAlreadyLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/BgMoriIdomizu_Update.s")
|
||||
void BgMoriIdomizu_SetupWaitForMoriTex(BgMoriIdomizu* this) {
|
||||
BgMoriIdomizu_SetupAction(this, BgMoriIdomizu_WaitForMoriTex);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Mori_Idomizu/func_808A4A64.s")
|
||||
void BgMoriIdomizu_WaitForMoriTex(BgMoriIdomizu* this, GlobalContext* globalCtx) {
|
||||
if (Object_IsLoaded(&globalCtx->objectCtx, this->moriTexObjIndex)) {
|
||||
BgMoriIdomizu_SetupMain(this);
|
||||
this->actor.draw = BgMoriIdomizu_Draw;
|
||||
}
|
||||
}
|
||||
|
||||
void BgMoriIdomizu_SetupMain(BgMoriIdomizu* this) {
|
||||
BgMoriIdomizu_SetupAction(this, BgMoriIdomizu_Main);
|
||||
}
|
||||
|
||||
void BgMoriIdomizu_Main(BgMoriIdomizu* this, GlobalContext* globalCtx) {
|
||||
s8 roomNum;
|
||||
Actor* thisx = &this->actor;
|
||||
s32 switchFlagSet;
|
||||
|
||||
roomNum = globalCtx->roomCtx.curRoom.num;
|
||||
switchFlagSet = Flags_GetSwitch(globalCtx, thisx->params & 0x3F);
|
||||
if (switchFlagSet) {
|
||||
this->targetWaterLevel = -282.0f;
|
||||
} else {
|
||||
this->targetWaterLevel = 184.0f;
|
||||
}
|
||||
if (switchFlagSet && !this->prevSwitchFlagSet) {
|
||||
func_800800F8(globalCtx, 0xCA8, 0x46, thisx, 0);
|
||||
this->drainTimer = 90;
|
||||
} else if (!switchFlagSet && this->prevSwitchFlagSet) {
|
||||
func_800800F8(globalCtx, 0xCA8, 0x46, thisx, 0);
|
||||
this->drainTimer = 90;
|
||||
thisx->posRot.pos.y = 0.0f;
|
||||
}
|
||||
this->drainTimer--;
|
||||
if ((roomNum == 7) || (roomNum == 8) || (roomNum == 9)) {
|
||||
if (this->drainTimer < 70) {
|
||||
Math_ApproxF(&thisx->posRot.pos.y, this->targetWaterLevel, 3.5f);
|
||||
BgMoriIdomizu_SetWaterLevel(globalCtx, thisx->posRot.pos.y);
|
||||
if (this->drainTimer > 0) {
|
||||
if (switchFlagSet) {
|
||||
func_800788CC(NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG);
|
||||
} else {
|
||||
func_800788CC(NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
thisx->posRot.pos.y = this->targetWaterLevel;
|
||||
BgMoriIdomizu_SetWaterLevel(globalCtx, thisx->posRot.pos.y);
|
||||
Actor_Kill(thisx);
|
||||
return;
|
||||
}
|
||||
this->prevSwitchFlagSet = switchFlagSet;
|
||||
}
|
||||
|
||||
void BgMoriIdomizu_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
BgMoriIdomizu* this = THIS;
|
||||
|
||||
if (this->actionFunc != NULL) {
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
}
|
||||
|
||||
void BgMoriIdomizu_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
BgMoriIdomizu* this = THIS;
|
||||
u32 gameplayFrames = globalCtx->gameplayFrames;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_idomizu.c", 356);
|
||||
|
||||
func_80093D84(globalCtx->state.gfxCtx);
|
||||
|
||||
gSPMatrix(oGfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_mori_idomizu.c", 360),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
gSPSegment(oGfxCtx->polyXlu.p++, 0x08, globalCtx->objectCtx.status[this->moriTexObjIndex].segment);
|
||||
|
||||
gDPSetEnvColor(oGfxCtx->polyXlu.p++, 0, 0, 0, 128);
|
||||
|
||||
gSPSegment(oGfxCtx->polyXlu.p++, 0x09,
|
||||
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0x7F - (gameplayFrames & 0x7F), gameplayFrames % 0x80, 0x20,
|
||||
0x20, 1, gameplayFrames & 0x7F, gameplayFrames % 0x80, 0x20, 0x20));
|
||||
|
||||
gSPDisplayList(oGfxCtx->polyXlu.p++, D_060049D0);
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_mori_idomizu.c", 382);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,16 @@
|
|||
|
||||
struct BgMoriIdomizu;
|
||||
|
||||
typedef void (*BgMoriIdomizuActionFunc)(struct BgMoriIdomizu*, GlobalContext*);
|
||||
|
||||
typedef struct BgMoriIdomizu {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ char unk_14C[0x14];
|
||||
/* 0x014C */ BgMoriIdomizuActionFunc actionFunc;
|
||||
/* 0x0150 */ f32 targetWaterLevel;
|
||||
/* 0x0154 */ s32 prevSwitchFlagSet;
|
||||
/* 0x0158 */ s16 isLoaded;
|
||||
/* 0x015A */ s16 drainTimer;
|
||||
/* 0x015C */ s8 moriTexObjIndex;
|
||||
} BgMoriIdomizu; // size = 0x0160
|
||||
|
||||
extern const ActorInit Bg_Mori_Idomizu_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue