1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-07 06:40:15 +00:00

Decomp BgYdanMaruta (#338)

* Fix

* fix

* Fixed upstream

* PR fixes

* PR fixes

* Fix ZAP2.  Hopefully
This commit is contained in:
louist103 2020-08-23 06:44:22 -04:00 committed by GitHub
parent 6f54edd365
commit dea5f4aae5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 189 additions and 221 deletions

View file

@ -69,7 +69,7 @@ void func_80897970(BgJyaGoroiwa* this) {
void func_808979C0(BgJyaGoroiwa* this, GlobalContext* globalCtx) {
s32 pad;
Collider_InitJntSph(globalCtx, &this->collider);
Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderItem);
func_80897970(this);

View file

@ -107,7 +107,8 @@ void BgMoriElevator_Init(Actor* thisx, GlobalContext* globalCtx) {
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyInfo_SetActorMove(&this->dyna, DPM_PLAYER);
DynaPolyInfo_Alloc(&D_060035F8, &localConst);
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, localConst);
this->dyna.dynaPolyId =
DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, localConst);
BgMoriElevator_SetupWaitAfterInit(this);
break;
case 1:

View file

@ -1,3 +1,9 @@
/*
* File: z_bg_ydan_maruta.c
* Overlay: ovl_Bg_Ydan_Maruta
* Description: Rotating spike log in Deku Tree
*/
#include "z_bg_ydan_maruta.h"
#define FLAGS 0x00000000
@ -9,7 +15,11 @@ void BgYdanMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgYdanMaruta_Update(Actor* thisx, GlobalContext* globalCtx);
void BgYdanMaruta_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void func_808BEFF4(BgYdanMaruta* this, GlobalContext* globalCtx);
void BgYdanMaruta_DoNothing(BgYdanMaruta* this, GlobalContext* globalCtx);
void func_808BF078(BgYdanMaruta* this, GlobalContext* globalCtx);
void func_808BF108(BgYdanMaruta* this, GlobalContext* globalCtx);
const ActorInit Bg_Ydan_Maruta_InitVars = {
ACTOR_BG_YDAN_MARUTA,
ACTORTYPE_PROP,
@ -21,21 +31,164 @@ const ActorInit Bg_Ydan_Maruta_InitVars = {
(ActorFunc)BgYdanMaruta_Update,
(ActorFunc)BgYdanMaruta_Draw,
};
*/
ColliderTrisItemInit D_808BF300[2] = {
{
{ 0x00, { 0x20000000, 0x00, 0x04 }, { 0x00000004, 0x00, 0x00 }, 0x11, 0x01, 0x00 },
{ { { 220.0f, -10.0f, 0.0f }, { 220.0f, 10.0f, 0.0f }, { -220.0f, 10.0f, 0.0f } } },
},
{
{ 0x00, { 0x20000000, 0x00, 0x04 }, { 0x00000004, 0x00, 0x00 }, 0x11, 0x01, 0x00 },
{ { { 16.0f, 0.0f, 0.0f }, { 16.0f, 135.0f, 0.0f }, { -16.0f, 135.0f, 0.0f } } },
},
};
ColliderTrisInit D_808BF378 = {
{ COLTYPE_UNK10, 0x11, 0x09, 0x00, 0x20, COLSHAPE_TRIS },
2,
D_808BF300,
};
InitChainEntry D_808BF388[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
extern UNK_TYPE D_060066A8;
extern Gfx D_06008D88[];
extern Gfx D_06006570[];
#ifdef NON_MATCHING
// Register issues
void BgYdanMaruta_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 i;
BgYdanMaruta* this = THIS;
Vec3f sp4C[3];
s32 pad;
f32 sinRotY;
f32 cosRotY;
s32 localConst = 0;
ColliderTrisItemInit* items;
Actor_ProcessInitChain(thisx, D_808BF388);
Collider_InitTris(globalCtx, &this->collider);
Collider_SetTris(globalCtx, &this->collider, thisx, &D_808BF378, &this->colliderItems);
this->unk_168 = thisx->params;
thisx->params = ((thisx->params >> 8) & 0xFF) & 0xFF;
items = &D_808BF300[1];
if (thisx->params == 0) {
items = &D_808BF300[0];
this->actionFunc = func_808BEFF4;
} else {
DynaPolyInfo_SetActorMove(&this->dyna, 0);
DynaPolyInfo_Alloc(&D_060066A8, &localConst);
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, localConst);
thisx->initPosRot.pos.y += -280.0f;
if (Flags_GetSwitch(globalCtx, this->unk_168)) {
thisx->posRot.pos.y = thisx->initPosRot.pos.y;
this->actionFunc = BgYdanMaruta_DoNothing;
} else {
this->actionFunc = func_808BF078;
}
}
sinRotY = Math_Sins(thisx->shape.rot.y);
cosRotY = Math_Coss(thisx->shape.rot.y);
for (i = 0; i < 3; i++) {
sp4C[i].x = (items->dim.vtx[i].x * cosRotY) + thisx->posRot.pos.x;
sp4C[i].y = items->dim.vtx[i].y + thisx->posRot.pos.y;
sp4C[i].z = thisx->posRot.pos.z - (items->dim.vtx[i].x * sinRotY);
}
func_800627A0(&this->collider, 0, &sp4C[0], &sp4C[1], &sp4C[2]);
sp4C[1].x = (items->dim.vtx[2].x * cosRotY) + thisx->posRot.pos.x;
sp4C[1].y = items->dim.vtx[0].y + thisx->posRot.pos.y;
sp4C[1].z = thisx->posRot.pos.z - (items->dim.vtx[2].x * sinRotY);
func_800627A0(&this->collider, 1, &sp4C[0], &sp4C[2], &sp4C[1]);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/BgYdanMaruta_Init.s")
#endif
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/BgYdanMaruta_Destroy.s")
void BgYdanMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgYdanMaruta* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/func_808BEFF4.s")
Collider_DestroyTris(globalCtx, &this->collider);
if (thisx->params == 1) {
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/func_808BF078.s")
void func_808BEFF4(BgYdanMaruta* this, GlobalContext* globalCtx) {
if (this->collider.base.atFlags & 2) {
func_8002F71C(globalCtx, &this->dyna.actor, 7.0f, this->dyna.actor.shape.rot.y, 6.0f);
}
this->dyna.actor.shape.rot.x += 0x360;
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider);
func_8002F974(&this->dyna.actor, NA_SE_EV_TOGE_STICK_ROLLING - SFX_FLAG);
}
void func_808BF078(BgYdanMaruta* this, GlobalContext* globalCtx) {
if (this->collider.base.acFlags & 2) {
this->unk_16A = 20;
Flags_SetSwitch(globalCtx, this->unk_168);
func_80078884(NA_SE_SY_CORRECT_CHIME);
this->actionFunc = func_808BF108;
func_800800F8(globalCtx, 0xBC2, 0x32, &this->dyna.actor, 0);
} else {
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider);
}
}
#ifdef NON_EQUIVALENT
// Casting issues and a branch issue
void func_808BF108(BgYdanMaruta* this, GlobalContext* globalCtx) {
s16 phi_v0;
if (this->unk_16A != 0) {
this->unk_16A--;
}
if (this->unk_16A == 0) {
this->actionFunc = func_808BF1EC;
}
phi_v0 = this->unk_16A;
if ((phi_v0 < 0) && ((phi_v0 % 4) != 0)) {
phi_v0 -= 4;
}
phi_v0 -= 2;
if (phi_v0 == -2) {
phi_v0 = 0;
} else {
phi_v0 *= 2;
}
this->dyna.actor.posRot.pos.x =
(Math_Coss(this->dyna.actor.shape.rot.y) * phi_v0) + this->dyna.actor.initPosRot.pos.x;
this->dyna.actor.posRot.pos.z =
(Math_Sins(this->dyna.actor.shape.rot.y) * phi_v0) + this->dyna.actor.initPosRot.pos.z;
func_8002F974(&this->dyna.actor, NA_SE_EV_TRAP_OBJ_SLIDE - SFX_FLAG);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/func_808BF108.s")
#endif
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/func_808BF1EC.s")
void func_808BF1EC(BgYdanMaruta* this, GlobalContext* globalCtx) {
this->dyna.actor.velocity.y += 1.0f;
if (Math_ApproxF(&this->dyna.actor.posRot.pos.y, this->dyna.actor.initPosRot.pos.y, this->dyna.actor.velocity.y)) {
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_LADDER_DOUND);
this->actionFunc = BgYdanMaruta_DoNothing;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/func_808BF25C.s")
void BgYdanMaruta_DoNothing(BgYdanMaruta* this, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/BgYdanMaruta_Update.s")
void BgYdanMaruta_Update(Actor* thisx, GlobalContext* globalCtx) {
BgYdanMaruta* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ydan_Maruta/BgYdanMaruta_Draw.s")
this->actionFunc(this, globalCtx);
}
void BgYdanMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) {
if (thisx->params == 0) {
Gfx_DrawDListOpa(globalCtx, D_06008D88);
} else {
Gfx_DrawDListOpa(globalCtx, D_06006570);
}
}

View file

@ -6,9 +6,15 @@
struct BgYdanMaruta;
typedef void (*BgYdanMarutaActionFunc)(struct BgYdanMaruta*, GlobalContext*);
typedef struct BgYdanMaruta {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0xF8];
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ BgYdanMarutaActionFunc actionFunc;
/* 0x0168 */ u8 unk_168;
/* 0x016A */ s16 unk_16A;
/* 0x016C */ ColliderTris collider;
/* 0x018C */ ColliderTrisItem colliderItems[2];
} BgYdanMaruta; // size = 0x0244
extern const ActorInit Bg_Ydan_Maruta_InitVars;

View file

@ -47,7 +47,8 @@ void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) {
Actor_ProcessInitChain(&this->actor, sInitChain);
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 25.0f);
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06002530, &D_060000E8, this->limbDrawTable, this->transitionDrawTable, 16);
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06002530, &D_060000E8, this->limbDrawTable,
this->transitionDrawTable, 16);
if (this->actor.params < 0) {
this->actor.params = 0;
}
@ -218,8 +219,7 @@ void func_809B5670(EnAttackNiw* this, GlobalContext* globalCtx) {
this->unk_2E0 = 5.0f;
this->unk_288 = 0.0f;
this->actionFunc = func_809B59B0;
} else if (((this->actor.projectedPos.z > 0.0f) &&
(fabsf(sp34.x - this->actor.posRot.pos.x) < 50.0f) &&
} else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.posRot.pos.x) < 50.0f) &&
(fabsf(sp34.y - this->actor.posRot.pos.y) < 50.0f) &&
(fabsf(sp34.z - this->actor.posRot.pos.z) < 50.0f)) ||
(this->actor.bgCheckFlags & 1)) {