mirror of
https://github.com/zeldaret/mm.git
synced 2025-02-17 03:57:46 +00:00
ovl_Bg_Ladder: OK (Wooden Ladder) (#135)
* ovl_Bg_Ladder: OK (Wooden Ladder) * Change sLadderDLists type; add comment about thisx * Add macros for BgLadder params; rename object symbols
This commit is contained in:
parent
cb89346c28
commit
458dd13141
@ -4775,9 +4775,9 @@ SECTIONS
|
||||
ovl_Bg_Ladder : AT(RomLocation)
|
||||
{
|
||||
build/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.o(.text)
|
||||
build/asm/overlays/ovl_Bg_Ladder_data.o(.data)
|
||||
build/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.o(.data)
|
||||
build/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.o(.rodata)
|
||||
build/asm/overlays/ovl_Bg_Ladder_rodata.o(.rodata)
|
||||
build/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder_overlay.o(.ovl)
|
||||
}
|
||||
SegmentEnd = .;
|
||||
SegmentSize = SegmentEnd - SegmentStart;
|
||||
|
@ -246,6 +246,16 @@ D_06000958 = 0x06000958;
|
||||
/* z_en_jc_mato */
|
||||
D_06000390 = 0x06000390;
|
||||
|
||||
/* z_bg_ladder */
|
||||
D_060000A0 = 0x060000A0;
|
||||
D_060001D8 = 0x060001D8;
|
||||
D_060002D0 = 0x060002D0;
|
||||
D_06000408 = 0x06000408;
|
||||
D_06000500 = 0x06000500;
|
||||
D_06000638 = 0x06000638;
|
||||
D_06000730 = 0x06000730;
|
||||
D_06000868 = 0x06000868;
|
||||
|
||||
/* z_en_torch2 */
|
||||
D_0401C430 = 0x0401C430;
|
||||
D_04048DF0 = 0x04048DF0;
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* File: z_bg_ladder.c
|
||||
* Overlay: ovl_Bg_Ladder
|
||||
* Description: Wooden Ladder
|
||||
*/
|
||||
#include "z_bg_ladder.h"
|
||||
|
||||
#define FLAGS 0x00000010
|
||||
@ -8,8 +13,21 @@ void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgLadder_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgLadder_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgLadder_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgLadder_ActionWait(BgLadder* this, GlobalContext* globalCtx);
|
||||
void BgLadder_ActionStartCutscene(BgLadder* this, GlobalContext* globalCtx);
|
||||
void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx);
|
||||
void BgLadder_ActionIdle(BgLadder* this, GlobalContext* globalCtx);
|
||||
|
||||
extern Gfx D_060000A0[];
|
||||
extern Gfx D_060002D0[];
|
||||
extern Gfx D_06000500[];
|
||||
extern Gfx D_06000730[];
|
||||
|
||||
extern CollisionHeader D_060001D8;
|
||||
extern CollisionHeader D_06000408;
|
||||
extern CollisionHeader D_06000638;
|
||||
extern CollisionHeader D_06000868;
|
||||
|
||||
/*
|
||||
const ActorInit Bg_Ladder_InitVars = {
|
||||
ACTOR_BG_LADDER,
|
||||
ACTORCAT_PROP,
|
||||
@ -21,20 +39,129 @@ const ActorInit Bg_Ladder_InitVars = {
|
||||
(ActorFunc)BgLadder_Update,
|
||||
(ActorFunc)BgLadder_Draw,
|
||||
};
|
||||
*/
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/BgLadder_Init.asm")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/BgLadder_Destroy.asm")
|
||||
static Gfx* sLadderDLists[] = {
|
||||
D_060000A0, // 12 Rung
|
||||
D_060002D0, // 16 Rung
|
||||
D_06000500, // 20 Rung
|
||||
D_06000730, // 24 Rung
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/func_80A4DB88.asm")
|
||||
void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgLadder* this = THIS;
|
||||
BgLadderSize size;
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/func_80A4DBD8.asm")
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/func_80A4DC48.asm")
|
||||
// Has to be `thisx` instead of `&this->actor` to match
|
||||
this->switchFlag = GET_BGLADDER_SWITCHFLAG(thisx);
|
||||
thisx->params = GET_BGLADDER_SIZE(thisx);
|
||||
BcCheck3_BgActorInit(&this->dyna, 0);
|
||||
size = thisx->params;
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/func_80A4DCCC.asm")
|
||||
if (size == LADDER_SIZE_12RUNG) {
|
||||
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_060001D8);
|
||||
} else if (size == LADDER_SIZE_16RUNG) {
|
||||
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000408);
|
||||
} else if (size == LADDER_SIZE_20RUNG) {
|
||||
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000638);
|
||||
} else if (size == LADDER_SIZE_24RUNG) {
|
||||
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000868);
|
||||
} else {
|
||||
Actor_MarkForDeath(&this->dyna.actor);
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/BgLadder_Update.asm")
|
||||
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
|
||||
// If the flag is set, then the ladder draws immediately
|
||||
this->alpha = 255;
|
||||
this->dyna.actor.flags &= ~0x10; // always update = off
|
||||
this->action = BgLadder_ActionIdle;
|
||||
} else {
|
||||
// Otherwise, the ladder doesn't draw; wait for the flag to be set
|
||||
this->alpha = 5;
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
this->dyna.actor.draw = NULL;
|
||||
this->action = BgLadder_ActionWait;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ladder_0x80A4D9F0/BgLadder_Draw.asm")
|
||||
void BgLadder_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgLadder* this = THIS;
|
||||
|
||||
BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
|
||||
void BgLadder_ActionWait(BgLadder* this, GlobalContext* globalCtx) {
|
||||
// Wait for the flag to be set, then trigger the cutscene
|
||||
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
|
||||
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
|
||||
this->action = BgLadder_ActionStartCutscene;
|
||||
}
|
||||
}
|
||||
|
||||
void BgLadder_ActionStartCutscene(BgLadder* this, GlobalContext* globalCtx) {
|
||||
// Trigger the cutscene, then make the ladder fade in
|
||||
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
|
||||
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
|
||||
this->dyna.actor.draw = BgLadder_Draw;
|
||||
Audio_PlayActorSound2(this, 0x2997);
|
||||
this->action = BgLadder_ActionFadeIn;
|
||||
} else {
|
||||
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
|
||||
}
|
||||
}
|
||||
|
||||
void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx) {
|
||||
// Fade in the ladder, then stop the cutscene & go idle
|
||||
this->alpha += 5;
|
||||
if (this->alpha >= 255) {
|
||||
this->alpha = 255;
|
||||
ActorCutscene_Stop(this->dyna.actor.cutscene);
|
||||
func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
this->dyna.actor.flags &= ~0x10; // always update = off
|
||||
this->action = BgLadder_ActionIdle;
|
||||
}
|
||||
}
|
||||
|
||||
void BgLadder_ActionIdle(BgLadder* this, GlobalContext* globalCtx) {
|
||||
}
|
||||
|
||||
void BgLadder_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgLadder* this = THIS;
|
||||
|
||||
this->action(this, globalCtx);
|
||||
}
|
||||
|
||||
void BgLadder_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgLadder* this = THIS;
|
||||
s32 pad;
|
||||
Gfx* gfx;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
if (this->alpha == 255) {
|
||||
Scene_SetRenderModeXlu(globalCtx, 0, 0x01);
|
||||
gfx = POLY_OPA_DISP;
|
||||
} else {
|
||||
Scene_SetRenderModeXlu(globalCtx, 1, 0x02);
|
||||
gfx = POLY_XLU_DISP;
|
||||
}
|
||||
|
||||
gSPDisplayList(&gfx[0], &sSetupDL[6 * 0x19]);
|
||||
gDPSetEnvColor(&gfx[1], 255, 255, 255, this->alpha);
|
||||
gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
|
||||
gSPDisplayList(&gfx[3], sLadderDLists[this->dyna.actor.params]);
|
||||
|
||||
if (this->alpha == 255) {
|
||||
POLY_OPA_DISP = gfx + 4;
|
||||
} else {
|
||||
POLY_XLU_DISP = gfx + 4;
|
||||
}
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
@ -3,13 +3,27 @@
|
||||
|
||||
#include <global.h>
|
||||
|
||||
#define GET_BGLADDER_SIZE(actor) ((actor)->params & 0xFF)
|
||||
#define GET_BGLADDER_SWITCHFLAG(actor) (((actor)->params >> 8) & 0xFF)
|
||||
|
||||
struct BgLadder;
|
||||
|
||||
typedef void (*BgLadderActionFn)(struct BgLadder*, GlobalContext*);
|
||||
|
||||
typedef struct BgLadder {
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ char unk_144[0x20];
|
||||
/* 0x000 */ DynaPolyActor dyna;
|
||||
/* 0x15C */ BgLadderActionFn action;
|
||||
/* 0x160 */ s16 alpha;
|
||||
/* 0x162 */ s16 switchFlag;
|
||||
} BgLadder; // size = 0x164
|
||||
|
||||
typedef enum {
|
||||
LADDER_SIZE_12RUNG,
|
||||
LADDER_SIZE_16RUNG,
|
||||
LADDER_SIZE_20RUNG,
|
||||
LADDER_SIZE_24RUNG,
|
||||
} BgLadderSize;
|
||||
|
||||
extern const ActorInit Bg_Ladder_InitVars;
|
||||
|
||||
#endif // Z_BG_LADDER_H
|
||||
|
@ -10528,10 +10528,10 @@
|
||||
0x80A4D6A4:("ObjFireshield_Draw",),
|
||||
0x80A4D9F0:("BgLadder_Init",),
|
||||
0x80A4DB54:("BgLadder_Destroy",),
|
||||
0x80A4DB88:("func_80A4DB88",),
|
||||
0x80A4DBD8:("func_80A4DBD8",),
|
||||
0x80A4DC48:("func_80A4DC48",),
|
||||
0x80A4DCCC:("func_80A4DCCC",),
|
||||
0x80A4DB88:("BgLadder_ActionWait",),
|
||||
0x80A4DBD8:("BgLadder_ActionStartCutscene",),
|
||||
0x80A4DC48:("BgLadder_ActionFadeIn",),
|
||||
0x80A4DCCC:("BgLadder_ActionIdle",),
|
||||
0x80A4DCDC:("BgLadder_Update",),
|
||||
0x80A4DD00:("BgLadder_Draw",),
|
||||
0x80A4DED0:("EnMkk_Init",),
|
||||
|
Loading…
x
Reference in New Issue
Block a user