summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authori82orbom <mariottf2@gmail.com>2020-08-04 20:30:46 +0200
committerGitHub <noreply@github.com>2020-08-04 14:30:46 -0400
commit34c73dda62f973aaa940ffc7c8165cc645324c28 (patch)
tree4a23de1f4b746b951026b99dfc266b4e465e3c8a /src
parent91299ed21f844a297312b87788ba35aa88108be9 (diff)
Decompiles z_bg_ingate (#301)
* Decompiles z_bg_ingate * BgIngate_SetupAction * BgIngate_Init * BgIngate_Destroy * BgIngate_Update * func_80892990 * func_80892890 * BgIngate_Draw Removes unused asm's Formats z_bg_ingate.c * Addresses PR comments * Fixes usage of cutscene id instead of regular scene * Addresses PR comments
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c95
1 files changed, 85 insertions, 10 deletions
diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c
index 629249aff..2f0cca4f5 100644
--- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c
+++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c
@@ -16,9 +16,8 @@ void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx);
void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx);
void func_80892890(BgIngate* this, GlobalContext* globalCtx);
-void func_80892990(BgIngate* this, GlobalContext* globalCtx);
+void BgIngate_DoNothing(BgIngate* this, GlobalContext* globalCtx);
-/*
const ActorInit Bg_Ingate_InitVars = {
ACTOR_BG_INGATE,
ACTORTYPE_PROP,
@@ -30,17 +29,93 @@ const ActorInit Bg_Ingate_InitVars = {
(ActorFunc)BgIngate_Update,
(ActorFunc)BgIngate_Draw,
};
-*/
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/BgIngate_SetupAction.s")
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/BgIngate_Init.s")
+extern UNK_TYPE D_060011B8;
+extern Gfx D_06001040[];
+
+void BgIngate_SetupAction(BgIngate* this, BgIngateActionFunc actionFunc) {
+ this->actionFunc = actionFunc;
+}
+
+void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx) {
+ BgIngate* this = THIS;
+
+ s32 pad;
+ s32 sp32 = 0;
+
+ DynaPolyInfo_SetActorMove(&this->dyna, 0);
+ DynaPolyInfo_Alloc(&D_060011B8, &sp32);
+
+ this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp32);
+
+ if ((globalCtx->sceneNum != SCENE_SPOT20 || LINK_IS_CHILD) ||
+ (((gSaveContext.eventChkInf[1] & 0x100)) && (gSaveContext.cutsceneIndex != 0xFFF0))) {
+ Actor_Kill(&this->dyna.actor);
+ return;
+ }
+
+ Actor_SetScale(&this->dyna.actor, 0.1f);
+ if (((this->dyna.actor.params & 1) != 0) && ((gSaveContext.eventInf[0] & 0xF) == 6)) {
+ globalCtx->csCtx.frames = 0;
+ BgIngate_SetupAction(this, func_80892890);
+ } else {
+ BgIngate_SetupAction(this, BgIngate_DoNothing);
+ }
+}
+
+void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx) {
+ BgIngate* this = THIS;
+
+ DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
+}
+
+void func_80892890(BgIngate* this, GlobalContext* globalCtx) {
+ s32 phi0;
+ s16 phi1;
+ s16 csFrames;
+
+ if (globalCtx->csCtx.frames >= 50) {
+ phi0 = 0x4000;
+ if ((this->dyna.actor.params & 2) == 0) {
+ phi0 = -0x4000;
+ }
+ this->dyna.actor.shape.rot.y = this->dyna.actor.posRot.rot.y + phi0;
+ BgIngate_SetupAction(this, &BgIngate_DoNothing);
+ } else if (globalCtx->csCtx.frames >= 10) {
+ csFrames = globalCtx->csCtx.frames - 10;
+ csFrames *= 400;
+ phi1 = csFrames;
+ if (csFrames > 0x4000) {
+ csFrames = 0x4000;
+ }
+ csFrames = (Math_Sins(csFrames) * 16384.0f);
+ phi1 = csFrames;
+ if ((this->dyna.actor.params & 2) == 0) {
+ phi1 = -phi1;
+ }
+ this->dyna.actor.shape.rot.y = this->dyna.actor.posRot.rot.y + phi1;
+ }
+}
+
+void BgIngate_DoNothing(BgIngate* this, GlobalContext* globalCtx) {}
+
+void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx) {
+ BgIngate* this = THIS;
+
+ this->actionFunc(this, globalCtx);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/BgIngate_Destroy.s")
+void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx) {
+ GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
+ Gfx* dispRefs[4];
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/func_80892890.s")
+ Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_ingate.c", 240);
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/func_80892990.s")
+ func_80093D18(globalCtx->state.gfxCtx);
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/BgIngate_Update.s")
+ gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_ingate.c", 245),
+ G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ingate/BgIngate_Draw.s")
+ gSPDisplayList(gfxCtx->polyOpa.p++, D_06001040);
+ Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_ingate.c", 250);
+}