z_dm_opstage decompiled (#845)

* z_dm_opstage progress

* z_dm_opstage decompiled

* pr review fixes

* pr review fixes

* pr review fixes

* params var removal

* macro tunning + params removal

* final (hopefully)

* prototype was unnecessary

* pr review  changes

* pr review fixes

Co-authored-by: SonicDcer <noreply@github.com>
This commit is contained in:
Alejandro Asenjo
2022-06-19 20:07:13 -03:00
committed by GitHub
parent 9e6bc5db8b
commit 1ce5d13677
4 changed files with 105 additions and 35 deletions
+1 -2
View File
@@ -3133,8 +3133,7 @@ beginseg
name "ovl_Dm_Opstage"
compress
include "build/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.o"
include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.data.o"
include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.reloc.o"
include "build/src/overlays/actors/ovl_Dm_Opstage/ovl_Dm_Opstage_reloc.o"
endseg
beginseg
@@ -5,6 +5,7 @@
*/
#include "z_dm_opstage.h"
#include "objects/object_keikoku_demo/object_keikoku_demo.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)
@@ -15,11 +16,8 @@ void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx);
void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx);
void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx);
void func_80A9FA58(DmOpstage* this, GlobalContext* globalCtx);
void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx);
void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc);
#if 0
const ActorInit Dm_Opstage_InitVars = {
ACTOR_DM_OPSTAGE,
ACTORCAT_ITEMACTION,
@@ -32,26 +30,102 @@ const ActorInit Dm_Opstage_InitVars = {
(ActorFunc)DmOpstage_Draw,
};
// static InitChainEntry sInitChain[] = {
static InitChainEntry D_80A9FD30[] = {
static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP),
};
#endif
void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
extern InitChainEntry D_80A9FD30[];
void DmOpstage_Init(Actor* thisx, GlobalContext* globalCtx) {
DmOpstage* this = THIS;
extern UNK_TYPE D_06000978;
extern UNK_TYPE D_06001C98;
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DmOpstage_SetupAction(this, DmOpstage_FollowCutsceneScript);
Actor_SetScale(&this->dyna.actor, 0.1f);
if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) {
DynaPolyActor_Init(&this->dyna, 0);
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_keikoku_demo_Colheader_001C98);
}
if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) {
this->pos.x = this->dyna.actor.world.pos.x;
this->pos.y = this->dyna.actor.world.pos.y;
this->pos.z = this->dyna.actor.world.pos.z;
this->dyna.actor.world.pos.x = 0.0f;
this->dyna.actor.world.pos.y = 0.0f;
this->dyna.actor.world.pos.z = 0.0f;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_SetupAction.s")
void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx) {
DmOpstage* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Init.s")
if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) {
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Destroy.s")
void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx) {
s32 actionIndex;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/func_80A9FA58.s")
if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) {
if (Cutscene_CheckActorAction(globalCtx, 0x73)) {
actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x73);
if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) {
this->dyna.actor.scale.x = 0.075f;
this->dyna.actor.scale.z = 0.3f;
} else {
this->dyna.actor.scale.x = 0.1f;
this->dyna.actor.scale.z = 0.1f;
}
Cutscene_ActorTranslateAndYaw(&this->dyna.actor, globalCtx, actionIndex);
}
} else if (Cutscene_CheckActorAction(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)) {
Cutscene_ActorTranslateAndYaw(
&this->dyna.actor, globalCtx,
Cutscene_GetActorActionIndex(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74));
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Update.s")
void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx) {
DmOpstage* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Draw.s")
this->actionFunc(this, globalCtx);
if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) &&
(globalCtx->csCtx.frames == 480)) {
func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH);
}
}
void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx) {
DmOpstage* this = THIS;
if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) {
Matrix_Translate(this->dyna.actor.world.pos.x + this->pos.x, this->dyna.actor.world.pos.y + this->pos.y,
this->dyna.actor.world.pos.z + this->pos.z, MTXMODE_NEW);
Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY);
Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY);
}
switch (DMOPSTAGE_GET_TYPE(&this->dyna.actor)) {
case DM_OPSTAGE_TYPE_FLOOR:
Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_000978);
Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_000970);
break;
case DM_OPSTAGE_TYPE_TREE1:
Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_002878);
Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_002870);
break;
case DM_OPSTAGE_TYPE_TREE2:
Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003068);
Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003060);
break;
case DM_OPSTAGE_TYPE_TREE3:
Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003728);
Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003720);
break;
}
}
@@ -3,17 +3,26 @@
#include "global.h"
#define DMOPSTAGE_GET_TYPE(thisx) (((thisx)->params & 0xFF))
#define DMOPSTAGE_GET_08(thisx) (((thisx)->params >> 8) & 0xFF)
struct DmOpstage;
typedef void (*DmOpstageActionFunc)(struct DmOpstage*, GlobalContext*);
typedef struct DmOpstage {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x5C];
/* 0x01A0 */ DmOpstageActionFunc actionFunc;
/* 0x01A4 */ char unk_1A4[0xC];
/* 0x000 */ DynaPolyActor dyna;
/* 0x15C */ UNK_TYPE1 pad_15C[0x44];
/* 0x1A0 */ DmOpstageActionFunc actionFunc;
/* 0x1A4 */ Vec3f pos;
} DmOpstage; // size = 0x1B0
typedef enum {
/* 0 */ DM_OPSTAGE_TYPE_FLOOR,
/* 1 */ DM_OPSTAGE_TYPE_TREE1,
/* 2 */ DM_OPSTAGE_TYPE_TREE2,
/* 3 */ DM_OPSTAGE_TYPE_TREE3,
} DmOpStageTypes;
extern const ActorInit Dm_Opstage_InitVars;
#endif // Z_DM_OPSTAGE_H
-12
View File
@@ -881,18 +881,6 @@ D_0600E748 = 0x0600E748;
D_0600005C = 0x0600005C;
D_06001398 = 0x06001398;
// ovl_Dm_Opstage
D_06000970 = 0x06000970;
D_06000978 = 0x06000978;
D_06001C98 = 0x06001C98;
D_06002870 = 0x06002870;
D_06002878 = 0x06002878;
D_06003060 = 0x06003060;
D_06003068 = 0x06003068;
D_06003720 = 0x06003720;
D_06003728 = 0x06003728;
// ovl_Dm_Tsg
D_06002D30 = 0x06002D30;