1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-12 10:54:44 +00:00

BgSpot03Taki (#414)

* Migrate data, fix header, add undefined symbol, decompile Init function

* Decompiled Destroy function

* Decompiled func_808ADEF0 and adjusted struct some

* Decompiled Update function

* Fixed sInitChain stuff

* Preliminary Draw function decompilation

* Replaced code with OPEN_DISPS and CLOSE_DISPS and some hex with decimal

* Working on Draw function still

* More permuter test stuff

* Got Draw matching except for one little TwoTex issue

* Added NON_MATCHING

* Removed false alarm

* Got most of the functions decompiled; 1 non-matching, 1 not started

* Ran format.sh on file

* These two symbols should be arrays

* Got func_808ADAE0 mostly decompiled

* Got func_808ADAE0 fully decompiled!

* Removed necessary files (except _Draw)

* Successfully decompiled Draw function

* Decompiled Draw function
+ Added proper includes to spec

* Removed Draw function assembly

* Moved func_800F46E0 prototype to functions.h

* Renamed unk_174 to bufferIndex

* Replaced state constants with enum

* Renamed func_808ADAE0 to BgSpot03Taki_ApplyOpeningAlpha

* Renamed func_808ADAE0 to BgSpot03Taki_ApplyOpeningAlpha

* Made changes as per pull request comments

Co-authored-by: fig02 <fig02srl@gmail.com>
This commit is contained in:
Electrk 2020-10-04 07:14:28 -07:00 committed by GitHub
parent 85cf70bcd3
commit 4dfc9d3c3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 163 additions and 655 deletions

View file

@ -15,7 +15,8 @@ void BgSpot03Taki_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgSpot03Taki_Update(Actor* thisx, GlobalContext* globalCtx);
void BgSpot03Taki_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void func_808ADEF0(BgSpot03Taki* this, GlobalContext* globalCtx);
const ActorInit Bg_Spot03_Taki_InitVars = {
ACTOR_BG_SPOT03_TAKI,
ACTORTYPE_BG,
@ -27,15 +28,142 @@ const ActorInit Bg_Spot03_Taki_InitVars = {
(ActorFunc)BgSpot03Taki_Update,
(ActorFunc)BgSpot03Taki_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot03_Taki/func_808ADAE0.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot03_Taki/BgSpot03Taki_Init.s")
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot03_Taki/BgSpot03Taki_Destroy.s")
extern UNK_TYPE D_06000C98;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot03_Taki/func_808ADEF0.s")
// These are identical vertex data for the waterfall.
extern Vtx* D_06000800[]; // Vertex buffer 0
extern Vtx* D_06000990[]; // Vertex buffer 1
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot03_Taki/BgSpot03Taki_Update.s")
extern Gfx* D_06000B20[];
extern Gfx* D_06000BC0[];
extern Gfx* D_06001580[];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot03_Taki/BgSpot03Taki_Draw.s")
void BgSpot03Taki_ApplyOpeningAlpha(BgSpot03Taki* this, s32 bufferIndex) {
s32 i;
Vtx* vtx = (bufferIndex == 0) ? SEGMENTED_TO_VIRTUAL(D_06000800) : SEGMENTED_TO_VIRTUAL(D_06000990);
for (i = 0; i < 5; i++) {
vtx[i + 10].v.cn[3] = this->openingAlpha;
}
}
void BgSpot03Taki_Init(Actor* thisx, GlobalContext* globalCtx) {
BgSpot03Taki* this = THIS;
s16 pad;
s32 sp24 = 0;
this->switchFlag = (this->dyna.actor.params & 0x3F);
DynaPolyInfo_SetActorMove(&this->dyna, 0);
DynaPolyInfo_Alloc(&D_06000C98, &sp24);
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp24);
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
this->bufferIndex = 0;
this->openingAlpha = 255.0f;
BgSpot03Taki_ApplyOpeningAlpha(this, 0);
BgSpot03Taki_ApplyOpeningAlpha(this, 1);
this->actionFunc = func_808ADEF0;
}
void BgSpot03Taki_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgSpot03Taki* this = THIS;
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
}
void func_808ADEF0(BgSpot03Taki* this, GlobalContext* globalCtx) {
if (this->state == WATERFALL_CLOSED) {
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
this->state = WATERFALL_OPENING_ANIMATED;
this->timer = 40;
func_800800F8(globalCtx, 0x1004, -0x63, NULL, 0);
}
} else if (this->state == WATERFALL_OPENING_IDLE) {
this->timer--;
if (this->timer < 0) {
this->state = WATERFALL_OPENING_ANIMATED;
}
} else if (this->state == WATERFALL_OPENING_ANIMATED) {
if (this->openingAlpha > 0) {
this->openingAlpha -= 5;
if (this->openingAlpha <= 0.0f) {
func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
this->timer = 400;
this->state = WATERFALL_OPENED;
this->openingAlpha = 0;
}
}
} else if (this->state == WATERFALL_OPENED) {
this->timer--;
if (this->timer < 0) {
this->state = WATERFALL_CLOSING;
}
} else if (this->state == WATERFALL_CLOSING) {
if (this->openingAlpha < 255.0f) {
this->openingAlpha += 5.0f;
if (this->openingAlpha >= 255.0f) {
func_8003EC50(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
this->state = WATERFALL_CLOSED;
this->openingAlpha = 255.0f;
Flags_UnsetSwitch(globalCtx, this->switchFlag);
}
}
}
BgSpot03Taki_ApplyOpeningAlpha(this, this->bufferIndex);
}
void BgSpot03Taki_Update(Actor* thisx, GlobalContext* globalCtx) {
BgSpot03Taki* this = THIS;
this->actionFunc(this, globalCtx);
}
void BgSpot03Taki_Draw(Actor* thisx, GlobalContext* globalCtx) {
BgSpot03Taki* this = THIS;
s32 pad;
u32 gameplayFrames;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot03_taki.c", 321);
gameplayFrames = globalCtx->gameplayFrames;
gSPMatrix(oGfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_spot03_taki.c", 325),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
func_80093D84(globalCtx->state.gfxCtx);
gSPSegment(
oGfxCtx->polyXlu.p++, 0x08,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames * 5, 64, 64, 1, 0, gameplayFrames * 5, 64, 64));
gSPDisplayList(oGfxCtx->polyXlu.p++, D_06000B20);
if (this->bufferIndex == 0) {
gSPVertex(oGfxCtx->polyXlu.p++, D_06000800, 25, 0);
} else {
gSPVertex(oGfxCtx->polyXlu.p++, D_06000990, 25, 0);
}
gSPDisplayList(oGfxCtx->polyXlu.p++, D_06000BC0);
gSPSegment(oGfxCtx->polyXlu.p++, 0x08,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, gameplayFrames * 3, 64, 64, 1,
-gameplayFrames, gameplayFrames * 3, 64, 64));
gSPDisplayList(oGfxCtx->polyXlu.p++, D_06001580);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_spot03_taki.c", 358);
this->bufferIndex = this->bufferIndex == 0;
if (this->state > WATERFALL_CLOSED && this->state < WATERFALL_CLOSING) {
func_800F46E0(&this->dyna.actor.projectedPos, 0.5f);
} else {
func_800F46E0(&this->dyna.actor.projectedPos, 1.0f);
}
}

View file

@ -4,11 +4,26 @@
#include "ultra64.h"
#include "global.h"
typedef enum {
WATERFALL_CLOSED,
WATERFALL_OPENING_IDLE,
WATERFALL_OPENING_ANIMATED,
WATERFALL_OPENED,
WATERFALL_CLOSING,
} BgSpot03TakiState;
struct BgSpot03Taki;
typedef void (*BgSpot03TakiActionFunc)(struct BgSpot03Taki*, GlobalContext*);
typedef struct BgSpot03Taki {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x2C];
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ BgSpot03TakiActionFunc actionFunc;
/* 0x0168 */ s16 timer;
/* 0x016A */ u8 state;
/* 0x016C */ u16 switchFlag;
/* 0x0170 */ f32 openingAlpha;
/* 0x0174 */ u8 bufferIndex;
} BgSpot03Taki; // size = 0x0178
extern const ActorInit Bg_Spot03_Taki_InitVars;