`z_obj_tokei_tobira` OK undocumented (#1336)

* Fixes

* `z_obj_tokei_tobira` OK undocumented

* Revert "Fixes"

This reverts commit b3358254df.

* Fixes

* Data imported + Code Optimization

* Formatting

* cleaning + fixes

* formatting

* More fixes

* Last fixes

* OK undocumented

* More fixes

* Fixes

* Formatting again

* I hate Jenkins

* Removed a comment

* Review apply

* Formatting

* Applied reviews

* Review Applied

* Update src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

---------

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
AbdooOwd 2023-09-15 04:39:21 +01:00 committed by GitHub
parent 99dd8a41f9
commit 57501ed415
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 159 additions and 18 deletions

3
spec
View File

@ -3098,8 +3098,7 @@ beginseg
name "ovl_Obj_Tokei_Tobira"
compress
include "build/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.o"
include "build/data/ovl_Obj_Tokei_Tobira/ovl_Obj_Tokei_Tobira.data.o"
include "build/data/ovl_Obj_Tokei_Tobira/ovl_Obj_Tokei_Tobira.reloc.o"
include "build/src/overlays/actors/ovl_Obj_Tokei_Tobira/ovl_Obj_Tokei_Tobira_reloc.o"
endseg
beginseg

View File

@ -5,6 +5,7 @@
*/
#include "z_obj_tokei_tobira.h"
#include "objects/object_tokei_tobira/object_tokei_tobira.h"
#define FLAGS 0x00000000
@ -14,8 +15,8 @@ void ObjTokeiTobira_Init(Actor* thisx, PlayState* play);
void ObjTokeiTobira_Destroy(Actor* thisx, PlayState* play);
void ObjTokeiTobira_Update(Actor* thisx, PlayState* play);
void ObjTokeiTobira_Draw(Actor* thisx, PlayState* play);
void ObjTokeiTobira_StartCutscene(ObjTokeiTobira* this);
#if 0
ActorInit Obj_Tokei_Tobira_InitVars = {
ACTOR_OBJ_TOKEI_TOBIRA,
ACTORCAT_BG,
@ -28,24 +29,153 @@ ActorInit Obj_Tokei_Tobira_InitVars = {
(ActorFunc)ObjTokeiTobira_Draw,
};
// static InitChainEntry sInitChain[] = {
static InitChainEntry D_80ABD750[] = {
static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE),
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
#endif
Vec3f D_80ABD760 = { 0.0f, 0.0f, 80.0f };
s16 D_80ABD76C[] = {
-0x4000, // OBJTOKEITOBIRA_TYPE_0
0x4000, // OBJTOKEITOBIRA_TYPE_1
};
CollisionHeader* D_80ABD770[] = {
&object_tokei_tobira_Colheader_0012B0, // OBJTOKEITOBIRA_TYPE_0
&object_tokei_tobira_Colheader_001590, // OBJTOKEITOBIRA_TYPE_1
};
f32 D_80ABD778[] = {
1.0f, // OBJTOKEITOBIRA_TYPE_0
-1.0f, // OBJTOKEITOBIRA_TYPE_1
};
Gfx* D_80ABD780[] = {
object_tokei_tobira_DL_001108, // OBJTOKEITOBIRA_TYPE_0
object_tokei_tobira_DL_0013E8, // OBJTOKEITOBIRA_TYPE_1
};
extern InitChainEntry D_80ABD750[];
void ObjTokeiTobira_Init(Actor* thisx, PlayState* play) {
ObjTokeiTobira* this = THIS;
s32 pad;
s32 type = OBJTOKEITOBIRA_GET_TYPE(&this->dyna.actor);
Vec3f posOffset;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Tobira/ObjTokeiTobira_Init.s")
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y);
DynaPolyActor_LoadMesh(play, &this->dyna, D_80ABD770[type]);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Tobira/ObjTokeiTobira_Destroy.s")
if (type == OBJTOKEITOBIRA_TYPE_0) {
Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_TOKEI_TOBIRA,
this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z,
this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z,
OBJTOKEITOBIRA_PARAMS(OBJTOKEITOBIRA_TYPE_1));
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Tobira/func_80ABD3B0.s")
Matrix_RotateYS(D_80ABD76C[type] + this->dyna.actor.shape.rot.y, MTXMODE_NEW);
Matrix_MultVec3f(&D_80ABD760, &posOffset);
this->dyna.actor.world.pos.x += posOffset.x;
this->dyna.actor.world.pos.y += posOffset.y;
this->dyna.actor.world.pos.z += posOffset.z;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Tobira/ObjTokeiTobira_Update.s")
if ((type == OBJTOKEITOBIRA_TYPE_0) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_04) &&
(play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 0) && (this->dyna.actor.csId > CS_ID_NONE)) {
this->dyna.actor.flags |= ACTOR_FLAG_10;
this->actionFunc = ObjTokeiTobira_StartCutscene;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Tobira/ObjTokeiTobira_Draw.s")
void ObjTokeiTobira_Destroy(Actor* thisx, PlayState* play) {
ObjTokeiTobira* this = THIS;
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
void ObjTokeiTobira_StartCutscene(ObjTokeiTobira* this) {
if (CutsceneManager_IsNext(this->dyna.actor.csId)) {
CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor);
SET_WEEKEVENTREG(WEEKEVENTREG_59_04);
this->actionFunc = NULL;
this->dyna.actor.flags &= ~ACTOR_FLAG_10;
} else {
CutsceneManager_Queue(this->dyna.actor.csId);
}
}
void ObjTokeiTobira_Update(Actor* thisx, PlayState* play) {
s32 pad1;
ObjTokeiTobira* this = THIS;
Player* player = GET_PLAYER(play);
s32 pad2;
s32 type = OBJTOKEITOBIRA_GET_TYPE(&this->dyna.actor);
f32 sp48 = D_80ABD778[type];
s32 pad3;
if (player->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) {
if (DynaPoly_GetActor(&play->colCtx, player->actor.wallBgId) == &this->dyna) {
f32 sp40;
Vec3f sp34;
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp34, &player->actor.world.pos);
sp40 = sp34.x * sp48;
if (sp40 > 20.0f) {
if (sp34.z > 0.0f) {
this->unk160 += (sp40 - 20.0f) * sp48 * (16.0f / 3.0f);
this->unk168 = 1;
if (this->unk16C <= 0) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_OC_WOOD_GATE_OPEN);
this->unk16C = 80;
}
}
if (sp40 > 48.0f) {
ObjTokeiTobira* tobira;
if (type == OBJTOKEITOBIRA_TYPE_0) {
tobira = (ObjTokeiTobira*)this->dyna.actor.child;
} else {
tobira = (ObjTokeiTobira*)this->dyna.actor.parent;
}
if (tobira != NULL) {
tobira->unk168 = 1;
}
}
}
}
} else if (this->unk168 == 1) {
Vec3f sp24;
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp24, &player->actor.world.pos);
if ((sp24.z > 0.0f) && (sp24.z < 30.0f)) {
this->unk168 = 1;
this->unk160 += sp48 * 290.0f;
}
}
if (this->unk16C > 0) {
this->unk16C--;
}
this->unk168 = 0;
this->unk160 *= 0.87f;
this->unk164 += this->unk160;
if ((this->unk164 * sp48) > 14336.0f) {
this->unk160 *= 0.1f;
this->unk164 = 14336.0f * sp48;
} else if ((this->unk164 * sp48) < -1000.0f) {
this->unk160 *= 0.1f;
this->unk164 = -1000.0f * sp48;
}
this->dyna.actor.shape.rot.y = (s32)this->unk164 + this->dyna.actor.home.rot.y;
if (this->actionFunc != NULL) {
this->actionFunc(this);
}
}
void ObjTokeiTobira_Draw(Actor* thisx, PlayState* play) {
Gfx_DrawDListOpa(play, D_80ABD780[OBJTOKEITOBIRA_GET_TYPE(thisx)]);
}

View File

@ -3,15 +3,27 @@
#include "global.h"
#define OBJTOKEITOBIRA_GET_TYPE(thisx) ((thisx)->params & 1)
#define OBJTOKEITOBIRA_PARAMS(type) (type)
struct ObjTokeiTobira;
typedef void (*ObjTokeiTobiraActionFunc)(struct ObjTokeiTobira*, PlayState*);
typedef void (*ObjTokeiTobiraActionFunc)(struct ObjTokeiTobira*);
typedef enum ObjTokeiTobiraType {
/* 0 */ OBJTOKEITOBIRA_TYPE_0,
/* 1 */ OBJTOKEITOBIRA_TYPE_1
} ObjTokeiTobiraType;
typedef struct ObjTokeiTobira {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x18];
/* 0x000 */ DynaPolyActor dyna;
/* 0x15C */ ObjTokeiTobiraActionFunc actionFunc;
/* 0x160 */ char unk_160[0x10];
} ObjTokeiTobira; // size = 0x170
/* 0x160 */ f32 unk160;
/* 0x164 */ f32 unk164;
/* 0x168 */ s32 unk168;
/* 0x16C */ s32 unk16C;
} ObjTokeiTobira; // size = 0x170
#endif // Z_OBJ_TOKEI_TOBIRA_H

View File

@ -11830,7 +11830,7 @@
0x80ABCF0C:("BgHakuginBombwall_Draw",),
0x80ABD1D0:("ObjTokeiTobira_Init",),
0x80ABD37C:("ObjTokeiTobira_Destroy",),
0x80ABD3B0:("func_80ABD3B0",),
0x80ABD3B0:("ObjTokeiTobira_StartCutscene",),
0x80ABD424:("ObjTokeiTobira_Update",),
0x80ABD6F0:("ObjTokeiTobira_Draw",),
0x80ABD830:("BgHakuginElvpole_Init",),