summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfig02 <fig02srl@gmail.com>2020-03-23 17:39:32 -0400
committerGitHub <noreply@github.com>2020-03-23 17:39:32 -0400
commit8e316933d596204aa42fcfc2587fee480b4e114e (patch)
tree9763c68b8511f23f7801939cac736bf96a502d54 /src
parent2f3f556bfb7e31dac0864a056372ba83abfebd15 (diff)
parent7bc9d3863c9800a699a9ec84c21e33bd5d3936d3 (diff)
Merge pull request #25 from shawlucas/ovl_Bg_Zg
ovl_Bg_Zg OK
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c133
-rw-r--r--src/overlays/actors/ovl_Bg_Zg/z_bg_zg.h6
2 files changed, 119 insertions, 20 deletions
diff --git a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c
index a4547686c..b1a828e3c 100644
--- a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c
+++ b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.c
@@ -1,16 +1,32 @@
+/*
+ * File: z_bg_zg.c
+ * Overlay: ovl_Bg_Zg
+ * Description: Metal bars (Ganon's Castle)
+ */
+
#include "z_bg_zg.h"
#define ROOM 0x00
#define FLAGS 0x00000010
-void BgZg_Init(BgZg* this, GlobalContext* globalCtx);
-void BgZg_Destroy(BgZg* this, GlobalContext* globalCtx);
-void BgZg_Update(BgZg* this, GlobalContext* globalCtx);
-void BgZg_Draw(BgZg* this, GlobalContext* globalCtx);
+static void BgZg_Init(BgZg* this, GlobalContext* globalCtx);
+static void BgZg_Destroy(BgZg* this, GlobalContext* globalCtx);
+static void BgZg_Update(BgZg* this, GlobalContext* globalCtx);
+static void BgZg_Draw(BgZg* this, GlobalContext* globalCtx);
+static void func_808C0C50(BgZg* this);
+static s32 func_808C0C98(BgZg* this, GlobalContext* globalCtx);
+static s32 func_808C0CC8(BgZg* this);
+static void func_808C0CD4(BgZg* this, GlobalContext* globalCtx);
+static void func_808C0D08(BgZg* this, GlobalContext* globalCtx);
+static void func_808C0EEC(BgZg* this, GlobalContext* globalCtx);
-/*
-const ActorInit Bg_Zg_InitVars =
-{
+static const ActorFunc actionFuncs[] = { (ActorFunc)func_808C0CD4, (ActorFunc)func_808C0D08, };
+
+static InitChainEntry initChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), };
+
+static const ActorFunc drawFuncs[] = { (ActorFunc)func_808C0EEC, };
+
+const ActorInit Bg_Zg_InitVars = {
ACTOR_BG_ZG,
ACTORTYPE_NPC,
ROOM,
@@ -22,23 +38,104 @@ const ActorInit Bg_Zg_InitVars =
(ActorFunc)BgZg_Update,
(ActorFunc)BgZg_Draw,
};
-*/
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/BgZg_Destroy.s")
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/func_808C0C50.s")
+extern u32 D_06001080;
+extern u32 D_060011D4;
+
+static void BgZg_Destroy(BgZg* this, GlobalContext* globalCtx) {
+ DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
+}
+
+static void func_808C0C50(BgZg* this) {
+ Audio_PlaySoundGeneral(NA_SE_EV_METALDOOR_OPEN, &this->dyna.actor.unk_E4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
+}
+
+static s32 func_808C0C98(BgZg* this, GlobalContext* globalCtx) {
+ Actor* thisx = &this->dyna.actor;
+ s32 flag = (thisx->params >> 8) & 0xFF;
+ return Flags_GetSwitch(globalCtx, flag);
+}
+
+static s32 func_808C0CC8(BgZg* this) {
+ s32 flag = this->dyna.actor.params & 0xFF;
+ return flag;
+}
+
+static void func_808C0CD4(BgZg* this, GlobalContext* globalCtx) {
+ if (func_808C0C98(this, globalCtx) != 0) {
+ this->action = 1;
+ func_808C0C50(this);
+ }
+}
+
+static void func_808C0D08(BgZg* this, GlobalContext* globalCtx) {
+ Actor* thisx = &this->dyna.actor;
+
+ thisx->posRot.pos.y += (kREG(16) + 20.0f) * 1.2f;
+ if ((((kREG(17) + 200.0f) * 1.2f) + thisx->initPosRot.pos.y) <= thisx->posRot.pos.y) {
+ Actor_Kill(thisx);
+ }
+}
+
+static void BgZg_Update(BgZg* this, GlobalContext* globalCtx) {
+ s32 action = this->action;
+
+ if (((action < 0) || (1 < action)) || (actionFuncs[action] == NULL)) {
+ // Translates to: "Main Mode is wrong!!!!!!!!!!!!!!!!!!!!!!!!!"
+ osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST);
+ } else {
+ actionFuncs[action](&this->dyna.actor, globalCtx);
+ }
+}
+
+static void BgZg_Init(BgZg* this, GlobalContext* globalCtx) {
+ s32 sp20[2];
+ Actor* thisx = &this->dyna.actor;
+ u32 local_c;
+
+ Actor_ProcessInitChain(thisx, initChain);
+ DynaPolyInfo_SetActorMove(thisx, DPM_UNK);
+ local_c = 0;
+ DynaPolyInfo_Alloc(&D_060011D4, &local_c);
+ this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, local_c);
+ if ((func_808C0CC8(this) == 8) || (func_808C0CC8(this) == 9)) {
+ thisx->scale.x = thisx->scale.x * 1.3f;
+ thisx->scale.z = thisx->scale.z * 1.3f;
+ thisx->scale.y = thisx->scale.y * 1.2f;
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/func_808C0C98.s")
+ this->action = 0;
+ this->drawConfig = 0;
+ if (func_808C0C98(this, globalCtx) != 0) {
+ Actor_Kill(thisx);
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/func_808C0CC8.s")
+static void func_808C0EEC(BgZg* this, GlobalContext* globalCtx) {
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/func_808C0CD4.s")
+ GraphicsContext* gfxCtx;
+ GraphicsContext* tempgfxCtx; // oddly needs this to match
+ Gfx* gfxArr[4];
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/func_808C0D08.s")
+ tempgfxCtx = globalCtx->state.gfxCtx;
+ gfxCtx = tempgfxCtx;
+ func_800C6AC4(gfxArr, gfxCtx, "../z_bg_zg.c", 311);
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/BgZg_Update.s")
+ func_80093D18(gfxCtx);
+ gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(gfxCtx, "../z_bg_zg.c", 315),
+ G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/BgZg_Init.s")
+ gSPDisplayList(gfxCtx->polyOpa.p++, &D_06001080);
+ func_800C6B54(gfxArr, gfxCtx, "../z_bg_zg.c", 320);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/func_808C0EEC.s")
+static void BgZg_Draw(BgZg* this, GlobalContext* globalCtx) {
+ s32 action = this->drawConfig;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Zg/BgZg_Draw.s")
+ if (((action < 0) || (action > 0)) || drawFuncs[action] == NULL) {
+ // Translates to: "Drawing mode is wrong !!!!!!!!!!!!!!!!!!!!!!!!!"
+ osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST);
+ } else {
+ drawFuncs[action](this, globalCtx);
+ }
+}
diff --git a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.h b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.h
index ac05e9b1c..ab959e101 100644
--- a/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.h
+++ b/src/overlays/actors/ovl_Bg_Zg/z_bg_zg.h
@@ -3,10 +3,12 @@
#include <ultra64.h>
#include <global.h>
+#include <vt.h>
typedef struct {
- /* 0x0000 */ Actor actor;
- /* 0x014C */ char unk_14C[0x20];
+ /* 0x0000 */ DynaPolyActor dyna;
+ /* 0x0164 */ s32 action;
+ /* 0x0168 */ s32 drawConfig;
} BgZg; // size = 0x016C
extern const ActorInit Bg_Zg_InitVars;