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

Darkmeiro decompilation (#320)

* Darkmeiro decompilation

Bg_Gnd_Darkmeiro decompiled, matched, and documented.

* forgot to remove ASM

* Now with better formatting

* removed some stray thisx

* Update src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c

Co-authored-by: Random <28494085+Random06457@users.noreply.github.com>

* Update src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c

Co-authored-by: Random <28494085+Random06457@users.noreply.github.com>

* Update src/overlays/actors/ovl_Bg_Gnd_Darkmeiro/z_bg_gnd_darkmeiro.c

Co-authored-by: Random <28494085+Random06457@users.noreply.github.com>

* one more cleanup

* cleanup as per discussion

* fancy new names

* sfx

* ZAP

* more cleanup

* more cleanup

* and a little more

* renaming some stuff

* a little more tidying up

* bug comment

Co-authored-by: Random <28494085+Random06457@users.noreply.github.com>
This commit is contained in:
petrie911 2020-09-14 15:53:57 -05:00 committed by GitHub
parent 9891ac04c3
commit 203cd19f8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 208 additions and 631 deletions

View file

@ -1,7 +1,7 @@
/*
* File: z_bg_gnd_darkmeiro.c
* Overlay: ovl_Bg_Gnd_Darkmeiro
* Description: Clear block
* Description: Shadow trial actors (invisible path, clear block, and timer)
*/
#include "z_bg_gnd_darkmeiro.h"
@ -13,17 +13,15 @@
void BgGndDarkmeiro_Init(Actor* thisx, GlobalContext* globalCtx);
void BgGndDarkmeiro_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgGndDarkmeiro_Update(Actor* thisx, GlobalContext* globalCtx);
void BgGndDarkmeiro_DrawInvisiblePath(Actor* thisx, GlobalContext* globalCtx);
void BgGndDarkmeiro_DrawSwitchBlock(Actor* thisx, GlobalContext* globalCtx);
void BgGndDarkmeiro_DrawStaticBlock(Actor* thisx, GlobalContext* globalCtx);
void func_80878C30(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_80878F28(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_80878F34(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_80879128(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_80879134(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_808791BC(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_808791E8(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void func_80879334(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void BgGndDarkmeiro_Noop(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void BgGndDarkmeiro_UpdateBlockTimer(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void BgGndDarkmeiro_UpdateStaticBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx);
void BgGndDarkmeiro_UpdateSwitchBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx);
/*
const ActorInit Bg_Gnd_Darkmeiro_InitVars = {
ACTOR_BG_GND_DARKMEIRO,
ACTORTYPE_PROP,
@ -35,25 +33,189 @@ const ActorInit Bg_Gnd_Darkmeiro_InitVars = {
(ActorFunc)BgGndDarkmeiro_Update,
NULL,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_80878C30.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/BgGndDarkmeiro_Init.s")
extern Gfx D_060088B0[];
extern Gfx D_0600BEC0[];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/BgGndDarkmeiro_Destroy.s")
extern UNK_TYPE D_0600C080;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_80878F28.s")
void BgGndDarkmeiro_ToggleBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx) {
if (this->actionFlags & 2) {
if (this->timer1 == 0) {
func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
this->actionFlags &= ~2;
}
} else if (this->timer1 != 0) {
func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
this->actionFlags |= 2;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_80878F34.s")
void BgGndDarkmeiro_Init(Actor* thisx, GlobalContext* globalCtx) {
GlobalContext* globalCtx2 = globalCtx;
s32 local_c = 0;
BgGndDarkmeiro* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_80879128.s")
this->updateFunc = BgGndDarkmeiro_Noop;
Actor_SetScale(&this->dyna.actor, 0.1f);
switch (this->dyna.actor.params & 0xFF) {
case DARKMEIRO_INVISIBLE_PATH:
this->dyna.actor.draw = BgGndDarkmeiro_DrawInvisiblePath;
this->dyna.actor.flags |= 0x80;
break;
case DARKMEIRO_CLEAR_BLOCK:
DynaPolyInfo_Alloc(&D_0600C080, &local_c);
this->dyna.dynaPolyId =
DynaPolyInfo_RegisterActor(globalCtx2, &globalCtx2->colCtx.dyna, &this->dyna.actor, local_c);
if (((this->dyna.actor.params >> 8) & 0x3F) == 0x3F) {
this->updateFunc = BgGndDarkmeiro_UpdateStaticBlock;
this->dyna.actor.draw = BgGndDarkmeiro_DrawStaticBlock;
} else {
this->actionFlags = this->timer1 = this->timer2 = 0;
thisx->draw = BgGndDarkmeiro_DrawSwitchBlock;
this->updateFunc = BgGndDarkmeiro_UpdateSwitchBlock;
if (!Flags_GetSwitch(globalCtx2, (this->dyna.actor.params >> 8) & 0x3F)) {
func_8003EBF8(globalCtx2, &globalCtx2->colCtx.dyna, this->dyna.dynaPolyId);
} else {
this->timer1 = 64;
this->actionFlags |= 2;
}
}
break;
case DARKMEIRO_BLOCK_TIMER:
this->actionFlags = this->timer1 = this->timer2 = 0;
this->updateFunc = BgGndDarkmeiro_UpdateBlockTimer;
thisx->draw = NULL;
if (Flags_GetSwitch(globalCtx2, ((this->dyna.actor.params >> 8) & 0x3F) + 1)) {
this->timer1 = 64;
this->actionFlags |= 4;
}
if (Flags_GetSwitch(globalCtx2, ((this->dyna.actor.params >> 8) & 0x3F) + 2)) {
this->timer2 = 64;
this->actionFlags |= 8;
}
if ((this->timer1 != 0) || (this->timer2 != 0)) {
Flags_SetSwitch(globalCtx2, (this->dyna.actor.params >> 8) & 0x3F);
} else {
Flags_UnsetSwitch(globalCtx2, (this->dyna.actor.params >> 8) & 0x3F);
}
break;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_80879134.s")
void BgGndDarkmeiro_Destroy(Actor* thisx, GlobalContext* globalCtx) {
GlobalContext* globalCtx2 = globalCtx;
BgGndDarkmeiro* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/BgGndDarkmeiro_Update.s")
if ((this->dyna.actor.params & 0xFF) == 1) {
if (1) {}
DynaPolyInfo_Free(globalCtx2, &globalCtx2->colCtx.dyna, this->dyna.dynaPolyId);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_808791BC.s")
void BgGndDarkmeiro_Noop(BgGndDarkmeiro* this, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_808791E8.s")
void BgGndDarkmeiro_UpdateBlockTimer(BgGndDarkmeiro* this, GlobalContext* globalCtx) {
s16 timeLeft;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Gnd_Darkmeiro/func_80879334.s")
if (Flags_GetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 1)) {
if (this->actionFlags & 4) {
if (this->timer1 > 0) {
this->timer1--;
} else {
Flags_UnsetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 1);
this->actionFlags &= ~4;
}
} else {
this->actionFlags |= 4;
this->timer1 = 304;
Audio_PlaySoundGeneral(NA_SE_EV_RED_EYE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
}
if (Flags_GetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 2)) {
if (this->actionFlags & 8) {
if (this->timer2 > 0) {
this->timer2--;
} else {
Flags_UnsetSwitch(globalCtx, ((this->dyna.actor.params >> 8) & 0x3F) + 2);
this->actionFlags &= ~8;
}
} else {
this->actionFlags |= 8;
this->timer2 = 304;
Audio_PlaySoundGeneral(NA_SE_EV_RED_EYE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
}
timeLeft = CLAMP_MIN(this->timer1, this->timer2);
if (timeLeft > 0) {
func_8002F994(&this->dyna.actor, timeLeft);
}
if ((this->timer1 >= 64) || (this->timer2 >= 64)) {
Flags_SetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F);
} else {
Flags_UnsetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F);
}
}
void BgGndDarkmeiro_UpdateStaticBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx) {
}
void BgGndDarkmeiro_UpdateSwitchBlock(BgGndDarkmeiro* this, GlobalContext* globalCtx) {
if (this->timer1 > 0) {
this->timer1--;
}
if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params >> 8) & 0x3F)) {
this->timer1 = 64;
}
BgGndDarkmeiro_ToggleBlock(this, globalCtx);
}
void BgGndDarkmeiro_Update(Actor* thisx, GlobalContext* globalCtx) {
BgGndDarkmeiro* this = THIS;
GlobalContext* globalCtx2 = globalCtx;
this->updateFunc(this, globalCtx2);
}
void BgGndDarkmeiro_DrawInvisiblePath(Actor* thisx, GlobalContext* globalCtx) {
Gfx_DrawDListXlu(globalCtx, D_060088B0);
}
void BgGndDarkmeiro_DrawSwitchBlock(Actor* thisx, GlobalContext* globalCtx) {
BgGndDarkmeiro* this = THIS;
s16 vanishTimer;
vanishTimer = this->timer1;
if (vanishTimer != 0) {
if (vanishTimer > 64) {
this->timer2 = (this->timer2 < 120) ? this->timer2 + 8 : 127;
} else if (vanishTimer > 16) {
this->timer2 = (Math_Coss((u16)this->timer1 * 0x1000) * 64.0f) + 127.0f;
if (this->timer2 > 127) {
this->timer2 = 127;
}
} else {
this->timer2 = vanishTimer * 8;
}
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 378);
//@bug Due to a bug in the display list, the transparency data is not used.
gDPSetPrimColor(oGfxCtx->polyXlu.p++, 0, 0, 198, 202, 208, this->timer2);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 380);
Gfx_DrawDListXlu(globalCtx, D_0600BEC0);
}
}
void BgGndDarkmeiro_DrawStaticBlock(Actor* thisx, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 391);
gDPSetPrimColor(oGfxCtx->polyXlu.p++, 0, 0, 198, 202, 208, 255);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_gnd_darkmeiro.c", 393);
Gfx_DrawDListXlu(globalCtx, D_0600BEC0);
}

View file

@ -6,14 +6,29 @@
struct BgGndDarkmeiro;
typedef void (*BgGndDarkmeiroActionFunc)(struct BgGndDarkmeiro*, GlobalContext*);
typedef void (*BgGndDarkmeiroUpdateFunc)(struct BgGndDarkmeiro*, GlobalContext*);
typedef struct BgGndDarkmeiro {
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ char unk_164[0x8];
/* 0x016C */ BgGndDarkmeiroActionFunc actionFunc;
/* 0x0164 */ u16 actionFlags; // 0x8 for timer 2, 0x4 for timer 1, 0x2 for blocks.
/* 0x0166 */ s16 timer1; // Vanish countdown for clear blocks
/* 0x0168 */ s16 timer2; // Transparency flicker for clear blocks. Does not work.
/* 0x016C */ BgGndDarkmeiroUpdateFunc updateFunc;
} BgGndDarkmeiro; // size = 0x0170
typedef enum {
/* 0 */ DARKMEIRO_INVISIBLE_PATH, // Textures for the invisible path in shadow trial.
/* 1 */ DARKMEIRO_CLEAR_BLOCK, /* Clear blocks appear when their switch flag is set and
disappear 64 frames after their switch flag is cleared.
Clear blocks with flag 0x3F are always on. */
/* 2 */ DARKMEIRO_BLOCK_TIMER /* A block timer with switch flag N reacts to switch flags N+1
and N+2 being set, setting its own switch flag and a timer
for 304 frames. There are separate timers for N+1 and N+2,
and the timer sets flag N if either timer is above 64 frames. */
} DarkmeiroType;
extern const ActorInit Bg_Gnd_Darkmeiro_InitVars;
#endif