mirror of https://github.com/zeldaret/mm.git
Ovl Bg_Ctower_Gear OK (#123)
* BgCtowerGear OK * Added description header * Updated functions.txt * Added MACRO to get type * Renamed init chains to match tyype * Added one more use of Macro, and addressed PR comment * Fixed data copy error and better naming
This commit is contained in:
parent
86bdadf4da
commit
4279f12414
|
|
@ -5873,9 +5873,9 @@ SECTIONS
|
|||
ovl_Bg_Ctower_Gear : AT(RomLocation)
|
||||
{
|
||||
build/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.o(.text)
|
||||
build/asm/overlays/ovl_Bg_Ctower_Gear_data.o(.data)
|
||||
build/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.o(.data)
|
||||
build/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.o(.rodata)
|
||||
build/asm/overlays/ovl_Bg_Ctower_Gear_rodata.o(.rodata)
|
||||
build/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear_overlay.o(.ovl)
|
||||
}
|
||||
SegmentEnd = .;
|
||||
SegmentSize = SegmentEnd - SegmentStart;
|
||||
|
|
|
|||
|
|
@ -211,6 +211,15 @@ D_06000140 = 0x06000140;
|
|||
D_06000A20 = 0x06000A20;
|
||||
D_06000040 = 0x06000040;
|
||||
|
||||
/* z_bg_ctower_gear */
|
||||
D_06010828 = 0x06010828;
|
||||
D_06015F30 = 0x06015F30;
|
||||
D_060160A0 = 0x060160A0;
|
||||
D_06016E70 = 0x06016E70;
|
||||
D_06017018 = 0x06017018;
|
||||
D_06018118 = 0x06018118;
|
||||
D_06018588 = 0x06018588;
|
||||
|
||||
/* z_en_warp_uzu */
|
||||
D_06000EC0 = 0x06000EC0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,33 @@
|
|||
/*
|
||||
* File: z_bg_ctower_gear.c
|
||||
* Overlay: Bg_Ctower_Gear
|
||||
* Description: Different Cogs/Organ inside Clock Tower
|
||||
*/
|
||||
|
||||
#include "z_bg_ctower_gear.h"
|
||||
|
||||
#define FLAGS 0x00000010
|
||||
|
||||
#define THIS ((BgCtowerGear*)thisx)
|
||||
|
||||
#define BGCTOWERGEAR_GET_TYPE(this) (((BgCtowerGear*)this)->dyna.actor.params & 3)
|
||||
|
||||
typedef enum {
|
||||
/* 0x00 */ CEILING_COG,
|
||||
/* 0x01 */ CENTER_COG,
|
||||
/* 0x02 */ WATER_WHEEL,
|
||||
/* 0x03 */ ORGAN
|
||||
} BgCtowerGearType;
|
||||
|
||||
void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgCtowerGear_DrawOrgan(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
|
||||
const ActorInit Bg_Ctower_Gear_InitVars = {
|
||||
ACTOR_BG_CTOWER_GEAR,
|
||||
ACTORCAT_PROP,
|
||||
|
|
@ -21,18 +39,189 @@ const ActorInit Bg_Ctower_Gear_InitVars = {
|
|||
(ActorFunc)BgCtowerGear_Update,
|
||||
(ActorFunc)BgCtowerGear_Draw
|
||||
};
|
||||
*/
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/func_80AD2B70.asm")
|
||||
extern Gfx D_06010828[];
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/BgCtowerGear_Init.asm")
|
||||
extern Gfx D_06015F30[];
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/BgCtowerGear_Destroy.asm")
|
||||
extern Gfx D_060160A0[];
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/BgCtowerGear_Update.asm")
|
||||
extern CollisionHeader D_06016E70;
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/func_80AD3054.asm")
|
||||
extern Gfx D_06017018[];
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/BgCtowerGear_Draw.asm")
|
||||
extern Gfx D_06018118[];
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Bg_Ctower_Gear_0x80AD2B70/func_80AD3164.asm")
|
||||
extern CollisionHeader D_06018588;
|
||||
|
||||
static Vec3f D_80AD3270[] = {
|
||||
{-70.0f, -60.0f, 8.0f},
|
||||
{-60.0f, -60.0f, -9.1f},
|
||||
{-75.0f, -60.0f, -9.1f},
|
||||
{-70.0f, -60.0f, -26.2f}
|
||||
};
|
||||
|
||||
static Vec3f D_80AD32A0[] = {
|
||||
{85.0f, -60.0f, 8.0f},
|
||||
{80.0f, -60.0f, -9.1f},
|
||||
{85.0f, -60.0f, -26.2f},
|
||||
};
|
||||
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
static InitChainEntry sInitChainCenterCog[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 2000, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
static InitChainEntry sInitChainOrgan[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 420, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 570, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
static Gfx* D_80AD32E8[] = {D_06010828, D_06017018, D_06018118};
|
||||
|
||||
void BgCtowerGear_Splash(BgCtowerGear *this, GlobalContext *GlobalContext) {
|
||||
int i;
|
||||
s32 flags;
|
||||
Vec3f splashSpawnPos;
|
||||
Vec3f splashOffset;
|
||||
s32 pad;
|
||||
int j;
|
||||
s16 rotZ;
|
||||
|
||||
flags = this->dyna.actor.flags & 0x40;
|
||||
rotZ = this->dyna.actor.shape.rot.z & 0x1FFF;
|
||||
if ((flags != 0) && (rotZ < 0x1B58) && (rotZ >= 0x1388)) {
|
||||
Matrix_RotateY(this->dyna.actor.home.rot.y, 0);
|
||||
SysMatrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1);
|
||||
SysMatrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1);
|
||||
for(i=0; i<4; i++) {
|
||||
if ((u32) Rand_Next() >= 0x40000000) {
|
||||
splashOffset.x = D_80AD3270[i].x - (Rand_ZeroOne() * 30.0f);
|
||||
splashOffset.y = D_80AD3270[i].y;
|
||||
splashOffset.z = D_80AD3270[i].z;
|
||||
SysMatrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos);
|
||||
splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f);
|
||||
splashSpawnPos.y += this->dyna.actor.world.pos.y;
|
||||
splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f);
|
||||
EffectSsGSplash_Spawn(GlobalContext, &splashSpawnPos, NULL, NULL, 0, ((u32) Rand_Next() >> 25) + 340);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((rotZ < 0x1F4) && (rotZ >= 0)) {
|
||||
if (flags != 0) {
|
||||
Matrix_RotateY(this->dyna.actor.home.rot.y, 0);
|
||||
SysMatrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1);
|
||||
SysMatrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1);
|
||||
for(i=0; i<3; i++) {
|
||||
for(j=0; j<2; j++) {
|
||||
splashOffset.x = D_80AD32A0[i].x + (Rand_ZeroOne() * 10.0f);
|
||||
splashOffset.y = D_80AD32A0[i].y;
|
||||
splashOffset.z = D_80AD32A0[i].z;
|
||||
SysMatrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos);
|
||||
splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f);
|
||||
splashSpawnPos.y += this->dyna.actor.world.pos.y;
|
||||
splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f);
|
||||
EffectSsGSplash_Spawn(GlobalContext, &splashSpawnPos, NULL, NULL, 0, ((u32) Rand_Next() >> 25) + 280);
|
||||
}
|
||||
}
|
||||
}
|
||||
Audio_PlayActorSound2(this, 0x291B);
|
||||
}
|
||||
}
|
||||
|
||||
void BgCtowerGear_Init(Actor *thisx, GlobalContext *globalCtx) {
|
||||
BgCtowerGear *this = THIS;
|
||||
s32 type;
|
||||
|
||||
type = BGCTOWERGEAR_GET_TYPE(this);
|
||||
Actor_SetScale(&this->dyna.actor, 0.1f);
|
||||
if (type == CENTER_COG) {
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChainCenterCog);
|
||||
} else if (type == ORGAN) {
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChainOrgan);
|
||||
this->dyna.actor.draw = NULL;
|
||||
this->dyna.actor.update = BgCtowerGear_UpdateOrgan;
|
||||
} else {
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
}
|
||||
if (type == WATER_WHEEL) {
|
||||
BcCheck3_BgActorInit(&this->dyna, 3);
|
||||
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06018588);
|
||||
} else if (type == ORGAN) {
|
||||
BcCheck3_BgActorInit(&this->dyna, 0);
|
||||
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06016E70);
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
}
|
||||
|
||||
void BgCtowerGear_Destroy(Actor *thisx, GlobalContext *globalCtx) {
|
||||
BgCtowerGear *this = THIS;
|
||||
s32 type;
|
||||
|
||||
type = BGCTOWERGEAR_GET_TYPE(this);
|
||||
if ((type == WATER_WHEEL) || (type == ORGAN)) {
|
||||
BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
}
|
||||
|
||||
void BgCtowerGear_Update(Actor *thisx, GlobalContext *globalCtx) {
|
||||
BgCtowerGear *this = THIS;
|
||||
s32 type;
|
||||
|
||||
type = BGCTOWERGEAR_GET_TYPE(this);
|
||||
if (type == CEILING_COG) {
|
||||
this->dyna.actor.shape.rot.x -= 0x1F4;
|
||||
}
|
||||
else if (type == CENTER_COG) {
|
||||
this->dyna.actor.shape.rot.y += 0x1F4;
|
||||
func_800B9010(&this->dyna.actor, 0x2085);
|
||||
}
|
||||
else if (type == WATER_WHEEL) {
|
||||
this->dyna.actor.shape.rot.z -= 0x1F4;
|
||||
BgCtowerGear_Splash(this, globalCtx);
|
||||
}
|
||||
}
|
||||
|
||||
void BgCtowerGear_UpdateOrgan(Actor *thisx, GlobalContext *globalCtx) {
|
||||
BgCtowerGear *this = THIS;
|
||||
|
||||
if (func_800EE29C(globalCtx, 0x68)) {
|
||||
switch (globalCtx->csCtx.actorActions[func_800EE200(globalCtx, 0x68)]->unk0) {
|
||||
case 1:
|
||||
this->dyna.actor.draw = NULL;
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
break;
|
||||
case 2:
|
||||
this->dyna.actor.draw = BgCtowerGear_DrawOrgan;
|
||||
func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
break;
|
||||
case 3:
|
||||
Actor_MarkForDeath(&this->dyna.actor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Using BgCtowerGear *this = THIS causes regalloc issues
|
||||
void BgCtowerGear_Draw(Actor *thisx, GlobalContext *globalCtx) {
|
||||
func_800BDFC0(globalCtx, D_80AD32E8[BGCTOWERGEAR_GET_TYPE(thisx)]);
|
||||
}
|
||||
|
||||
void BgCtowerGear_DrawOrgan(Actor *thisx, GlobalContext *globalCtx) {
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
func_8012C28C(globalCtx->state.gfxCtx);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_OPA_DISP++, D_060160A0);
|
||||
func_8012C2DC(globalCtx->state.gfxCtx);
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_XLU_DISP++, D_06015F30);
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
struct BgCtowerGear;
|
||||
|
||||
typedef struct BgCtowerGear {
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ char unk_144[0x18];
|
||||
/* 0x000 */ DynaPolyActor dyna;
|
||||
} BgCtowerGear; // size = 0x15C
|
||||
|
||||
extern const ActorInit Bg_Ctower_Gear_InitVars;
|
||||
|
|
|
|||
|
|
@ -12169,13 +12169,13 @@
|
|||
0x80AD1DA8:("func_80AD1DA8",),
|
||||
0x80AD1E28:("func_80AD1E28",),
|
||||
0x80AD1F88:("EnOsn_Draw",),
|
||||
0x80AD2B70:("func_80AD2B70",),
|
||||
0x80AD2B70:("BgCtowerGear_Splash",),
|
||||
0x80AD2E84:("BgCtowerGear_Init",),
|
||||
0x80AD2F8C:("BgCtowerGear_Destroy",),
|
||||
0x80AD2FD8:("BgCtowerGear_Update",),
|
||||
0x80AD3054:("func_80AD3054",),
|
||||
0x80AD3054:("BgCtowerGear_UpdateOrgan",),
|
||||
0x80AD3124:("BgCtowerGear_Draw",),
|
||||
0x80AD3164:("func_80AD3164",),
|
||||
0x80AD3164:("BgCtowerGear_DrawOrgan",),
|
||||
0x80AD3380:("func_80AD3380",),
|
||||
0x80AD341C:("func_80AD341C",),
|
||||
0x80AD349C:("func_80AD349C",),
|
||||
|
|
|
|||
Loading…
Reference in New Issue