1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-07 06:40:15 +00:00

Decompiled ovl_Bg_Spot18_Shutter (#395)

* Decompiled ovl_Bg_Spot18_Shutter

* formatting

* PR fix
This commit is contained in:
Ethan Roseman 2020-09-20 12:14:32 -04:00 committed by GitHub
parent d080b4ab17
commit 9018841660
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 123 additions and 377 deletions

View file

@ -1,3 +1,9 @@
/*
* File: z_bg_spot18_shutter.c
* Overlay: Bg_Spot18_Shutter
* Description:
*/
#include "z_bg_spot18_shutter.h"
#define FLAGS 0x00000030
@ -9,7 +15,12 @@ void BgSpot18Shutter_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgSpot18Shutter_Update(Actor* thisx, GlobalContext* globalCtx);
void BgSpot18Shutter_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void func_808B95AC(BgSpot18Shutter* this, GlobalContext* globalCtx);
void func_808B95B8(BgSpot18Shutter* this, GlobalContext* globalCtx);
void func_808B9618(BgSpot18Shutter* this, GlobalContext* globalCtx);
void func_808B9698(BgSpot18Shutter* this, GlobalContext* globalCtx);
void func_808B971C(BgSpot18Shutter* this, GlobalContext* globalCtx);
const ActorInit Bg_Spot18_Shutter_InitVars = {
ACTOR_BG_SPOT18_SHUTTER,
ACTORTYPE_PROP,
@ -21,21 +32,114 @@ const ActorInit Bg_Spot18_Shutter_InitVars = {
(ActorFunc)BgSpot18Shutter_Update,
(ActorFunc)BgSpot18Shutter_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/BgSpot18Shutter_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/BgSpot18Shutter_Destroy.s")
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/func_808B95AC.s")
extern Gfx D_06000420[];
extern UNK_TYPE D_06000534;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/func_808B95B8.s")
void BgSpot18Shutter_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
BgSpot18Shutter* this = THIS;
s32 param = (this->dyna.actor.params >> 8) & 1;
s32 localC = 0;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/func_808B9618.s")
DynaPolyInfo_SetActorMove(&this->dyna, DPM_UNK);
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/func_808B9698.s")
if (param == 0) {
if (LINK_AGE_IN_YEARS == YEARS_ADULT) {
if (gSaveContext.infTable[16] & 0x200) {
this->actionFunc = func_808B95AC;
this->dyna.actor.posRot.pos.y += 180.0f;
} else {
this->actionFunc = func_808B9618;
}
} else {
if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) {
this->actionFunc = func_808B95AC;
this->dyna.actor.posRot.pos.y += 180.0f;
} else {
this->actionFunc = func_808B95B8;
}
}
} else {
if (gSaveContext.infTable[16] & 0x200) {
this->dyna.actor.posRot.pos.x += 125.0f * Math_Coss(this->dyna.actor.posRot.rot.y);
this->dyna.actor.posRot.pos.z -= 125.0f * Math_Sins(this->dyna.actor.posRot.rot.y);
this->actionFunc = func_808B95AC;
} else {
this->actionFunc = func_808B9618;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/func_808B971C.s")
DynaPolyInfo_Alloc(&D_06000534, &localC);
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, localC);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/BgSpot18Shutter_Update.s")
void BgSpot18Shutter_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgSpot18Shutter* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot18_Shutter/BgSpot18Shutter_Draw.s")
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
}
void func_808B95AC(BgSpot18Shutter* this, GlobalContext* globalCtx) {
}
void func_808B95B8(BgSpot18Shutter* this, GlobalContext* globalCtx) {
if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) {
Actor_SetHeight(&this->dyna.actor, 70.0f);
func_80080480(globalCtx, this);
this->actionFunc = func_808B9698;
}
}
void func_808B9618(BgSpot18Shutter* this, GlobalContext* globalCtx) {
if (gSaveContext.infTable[16] & 0x200) {
Actor_SetHeight(&this->dyna.actor, 70.0f);
if (((this->dyna.actor.params >> 8) & 1) == 0) {
this->actionFunc = func_808B9698;
} else {
this->actionFunc = func_808B971C;
func_800800F8(globalCtx, 0x107D, 0x8C, &this->dyna.actor, 0);
}
}
}
void func_808B9698(BgSpot18Shutter* this, GlobalContext* globalCtx) {
if (Math_ApproxF(&this->dyna.actor.posRot.pos.y, this->dyna.actor.initPosRot.pos.y + 180.0f, 1.44f)) {
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP);
this->actionFunc = func_808B95AC;
} else {
func_8002F974(&this->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG);
}
}
void func_808B971C(BgSpot18Shutter* this, GlobalContext* globalCtx) {
f32 sin = Math_Sins(this->dyna.actor.posRot.rot.y);
f32 cos = Math_Coss(this->dyna.actor.posRot.rot.y);
s32 flag =
Math_ApproxF(&this->dyna.actor.posRot.pos.x, this->dyna.actor.initPosRot.pos.x + (125.0f * cos), fabsf(cos)) &
1;
flag &=
Math_ApproxF(&this->dyna.actor.posRot.pos.z, this->dyna.actor.initPosRot.pos.z - (125.0f * sin), fabsf(sin));
if (flag) {
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP);
this->actionFunc = func_808B95AC;
} else {
func_8002F974(&this->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG);
}
}
void BgSpot18Shutter_Update(Actor* thisx, GlobalContext* globalCtx) {
BgSpot18Shutter* this = THIS;
this->actionFunc(this, globalCtx);
}
void BgSpot18Shutter_Draw(Actor* thisx, GlobalContext* globalCtx) {
Gfx_DrawDListOpa(globalCtx, D_06000420);
}

View file

@ -6,9 +6,11 @@
struct BgSpot18Shutter;
typedef void (*BgSpot18ShutterActionFunc)(struct BgSpot18Shutter*, GlobalContext*);
typedef struct BgSpot18Shutter {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x1C];
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ BgSpot18ShutterActionFunc actionFunc;
} BgSpot18Shutter; // size = 0x0168
extern const ActorInit Bg_Spot18_Shutter_InitVars;