1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-12 19:04:38 +00:00

BgHakaWater OK (#302)

* BgHakaWater OK

* minor style fixups

* made requested changes

* use true/false for isLowered
This commit is contained in:
gamestabled 2020-09-08 22:48:35 -04:00 committed by GitHub
parent 507edd134e
commit 43a3ee9a93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 124 additions and 597 deletions

View file

@ -15,11 +15,13 @@ void BgHakaWater_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgHakaWater_Update(Actor* thisx, GlobalContext* globalCtx);
void BgHakaWater_Draw(Actor* thisx, GlobalContext* globalCtx);
// ? func_80881D94(BgHakaWater* this, GlobalContext* globalCtx) // not entirely sure on this one
void func_80881EDC(BgHakaWater* this, GlobalContext* globalCtx);
void func_80881F98(BgHakaWater* this, GlobalContext* globalCtx);
void func_80881D94(BgHakaWater* this, GlobalContext* globalCtx);
void BgHakaWater_Wait(BgHakaWater* this, GlobalContext* globalCtx);
void BgHakaWater_ChangeWaterLevel(BgHakaWater* this, GlobalContext* globalCtx);
extern Gfx D_06001E50[];
extern Gfx D_06002010[];
/*
const ActorInit Bg_Haka_Water_InitVars = {
ACTOR_BG_HAKA_WATER,
ACTORTYPE_PROP,
@ -31,18 +33,122 @@ const ActorInit Bg_Haka_Water_InitVars = {
(ActorFunc)BgHakaWater_Update,
(ActorFunc)BgHakaWater_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/BgHakaWater_Init.s")
InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/BgHakaWater_Destroy.s")
void BgHakaWater_Init(Actor* thisx, GlobalContext* globalCtx) {
BgHakaWater* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/func_80881D94.s")
Actor_ProcessInitChain(&this->actor, sInitChain);
if (Flags_GetSwitch(globalCtx, this->actor.params)) {
this->isLowered = true;
this->actor.initPosRot.pos.y -= 200.0f;
this->actor.posRot.pos.y = this->actor.initPosRot.pos.y;
} else {
this->isLowered = false;
}
func_80881D94(this, globalCtx);
this->actionFunc = BgHakaWater_Wait;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/func_80881EDC.s")
void BgHakaWater_Destroy(Actor* thisx, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/func_80881F98.s")
void func_80881D94(BgHakaWater* this, GlobalContext* globalCtx) {
s32 i;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/BgHakaWater_Update.s")
for (i = 0; i < 9; i++) {
globalCtx->colCtx.stat.colHeader->waterBoxes[i].unk_02 = (s16)this->actor.posRot.pos.y - 8;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Water/BgHakaWater_Draw.s")
void BgHakaWater_Wait(BgHakaWater* this, GlobalContext* globalCtx) {
if ((!this->isLowered && Flags_GetSwitch(globalCtx, this->actor.params)) ||
(this->isLowered && !Flags_GetSwitch(globalCtx, this->actor.params))) {
if (this->isLowered) {
this->isLowered = false;
this->actor.draw = BgHakaWater_Draw;
this->actor.initPosRot.pos.y += 200.0f;
} else {
this->isLowered = true;
this->actor.initPosRot.pos.y -= 200.0f;
}
this->actionFunc = BgHakaWater_ChangeWaterLevel;
}
}
void BgHakaWater_ChangeWaterLevel(BgHakaWater* this, GlobalContext* globalCtx) {
if (!this->isLowered && Flags_GetSwitch(globalCtx, this->actor.params)) {
this->isLowered = true;
this->actor.initPosRot.pos.y -= 200.0f;
} else if (this->isLowered && !Flags_GetSwitch(globalCtx, this->actor.params)) {
this->isLowered = false;
this->actor.initPosRot.pos.y += 200.0f;
}
if (this->actor.initPosRot.pos.y < this->actor.posRot.pos.y) {
func_8002F948(&this->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG);
} else {
func_8002F948(&this->actor, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG);
}
if (Math_ApproxF(&this->actor.posRot.pos.y, this->actor.initPosRot.pos.y, 0.5f) != 0) {
this->actionFunc = BgHakaWater_Wait;
if (this->isLowered) {
this->actor.draw = NULL;
}
}
func_80881D94(this, globalCtx);
}
void BgHakaWater_Update(Actor* thisx, GlobalContext* globalCtx) {
BgHakaWater* this = THIS;
this->actionFunc(this, globalCtx);
}
void BgHakaWater_Draw(Actor* thisx, GlobalContext* globalCtx) {
BgHakaWater* this = THIS;
s32 pad;
f32 temp;
s32 pad2;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_haka_water.c", 287);
func_80093D84(globalCtx->state.gfxCtx);
if (this->isLowered) {
temp = this->actor.posRot.pos.y - this->actor.initPosRot.pos.y;
} else {
temp = this->actor.posRot.pos.y - (this->actor.initPosRot.pos.y - 200.0f);
}
gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, 255, 255, 255, (u8)(0.765f * temp));
gSPSegment(gfxCtx->polyXlu.p++, 0x08,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128,
globalCtx->gameplayFrames % 128, 32, 32, 1, 0, (0 - globalCtx->gameplayFrames) % 128,
32, 32));
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_water.c", 312),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfxCtx->polyXlu.p++, D_06001E50);
Matrix_Translate(0.0f, 92.0f, -1680.0f, MTXMODE_NEW);
Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY);
temp -= 170.0f;
if (temp < 0.0f) {
temp = 0.0f;
}
gDPPipeSync(gfxCtx->polyXlu.p++);
gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, 255, 255, 255, (u8)(5.1f * temp));
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_water.c", 328),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfxCtx->polyXlu.p++, D_06002010);
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_haka_water.c", 332);
}

View file

@ -11,7 +11,7 @@ typedef void (*BgHakaWaterActionFunc)(struct BgHakaWater*, GlobalContext*);
typedef struct BgHakaWater {
/* 0x0000 */ Actor actor;
/* 0x014C */ BgHakaWaterActionFunc actionFunc;
/* 0x0150 */ char unk_150[0x4];
/* 0x0150 */ u8 isLowered;
} BgHakaWater; // size = 0x0154
extern const ActorInit Bg_Haka_Water_InitVars;