mirror of
https://github.com/zeldaret/mm.git
synced 2026-08-02 08:22:17 -04:00
Document Object Ctower Rot (#530)
* Clean up actors * Start documenting object * Finish object and some other cleanup * Review comments * palette -> tlut * File header * DL as prefix for empties
This commit is contained in:
@@ -11,15 +11,6 @@
|
||||
|
||||
#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);
|
||||
@@ -40,11 +31,14 @@ const ActorInit Bg_Ctower_Gear_InitVars = {
|
||||
(ActorFunc)BgCtowerGear_Draw,
|
||||
};
|
||||
|
||||
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 sExitSplashOffsets[] = {
|
||||
{ -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[] = {
|
||||
static Vec3f sEnterSplashOffsets[] = {
|
||||
{ 85.0f, -60.0f, 8.0f },
|
||||
{ 80.0f, -60.0f, -9.1f },
|
||||
{ 85.0f, -60.0f, -26.2f },
|
||||
@@ -68,28 +62,26 @@ static InitChainEntry sInitChainOrgan[] = {
|
||||
ICHAIN_F32(uncullZoneDownward, 570, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
static Gfx* D_80AD32E8[] = { object_ctower_rot_DL_010828, object_ctower_rot_DL_017018, object_ctower_rot_DL_018118 };
|
||||
static Gfx* sDLists[] = { gClockTowerCeilingCogDL, gClockTowerCenterCogDL, gClockTowerWaterWheelDL };
|
||||
|
||||
void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
|
||||
int i;
|
||||
s32 flags;
|
||||
s32 i;
|
||||
s32 flag40 = this->dyna.actor.flags & 0x40;
|
||||
Vec3f splashSpawnPos;
|
||||
Vec3f splashOffset;
|
||||
s32 pad;
|
||||
int j;
|
||||
s16 rotZ;
|
||||
s32 j;
|
||||
s16 rotZ = this->dyna.actor.shape.rot.z & 0x1FFF;
|
||||
|
||||
flags = this->dyna.actor.flags & 0x40;
|
||||
rotZ = this->dyna.actor.shape.rot.z & 0x1FFF;
|
||||
if ((flags != 0) && (rotZ < 0x1B58) && (rotZ >= 0x1388)) {
|
||||
if (flag40 && (rotZ < 0x1B58) && (rotZ >= 0x1388)) {
|
||||
Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW);
|
||||
Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY);
|
||||
Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY);
|
||||
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;
|
||||
splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f);
|
||||
splashOffset.y = sExitSplashOffsets[i].y;
|
||||
splashOffset.z = sExitSplashOffsets[i].z;
|
||||
Matrix_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;
|
||||
@@ -99,15 +91,15 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
|
||||
}
|
||||
}
|
||||
if ((rotZ < 0x1F4) && (rotZ >= 0)) {
|
||||
if (flags != 0) {
|
||||
if (flag40) {
|
||||
Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW);
|
||||
Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY);
|
||||
Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY);
|
||||
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;
|
||||
splashOffset.x = sEnterSplashOffsets[i].x + (Rand_ZeroOne() * 10.0f);
|
||||
splashOffset.y = sEnterSplashOffsets[i].y;
|
||||
splashOffset.z = sEnterSplashOffsets[i].z;
|
||||
Matrix_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;
|
||||
@@ -122,50 +114,47 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
|
||||
|
||||
void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgCtowerGear* this = THIS;
|
||||
s32 type;
|
||||
s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor);
|
||||
|
||||
type = BGCTOWERGEAR_GET_TYPE(this);
|
||||
Actor_SetScale(&this->dyna.actor, 0.1f);
|
||||
if (type == CENTER_COG) {
|
||||
if (type == BGCTOWERGEAR_CENTER_COG) {
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChainCenterCog);
|
||||
} else if (type == ORGAN) {
|
||||
} else if (type == BGCTOWERGEAR_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) {
|
||||
if (type == BGCTOWERGEAR_WATER_WHEEL) {
|
||||
DynaPolyActor_Init(&this->dyna, 3);
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ctower_rot_Colheader_018588);
|
||||
} else if (type == ORGAN) {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerWaterWheelCol);
|
||||
} else if (type == BGCTOWERGEAR_ORGAN) {
|
||||
DynaPolyActor_Init(&this->dyna, 0);
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ctower_rot_Colheader_016E70);
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerOrganCol);
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
}
|
||||
|
||||
void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgCtowerGear* this = THIS;
|
||||
s32 type;
|
||||
s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor);
|
||||
|
||||
type = BGCTOWERGEAR_GET_TYPE(this);
|
||||
if ((type == WATER_WHEEL) || (type == ORGAN)) {
|
||||
if ((type == BGCTOWERGEAR_WATER_WHEEL) || (type == BGCTOWERGEAR_ORGAN)) {
|
||||
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
}
|
||||
|
||||
void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgCtowerGear* this = THIS;
|
||||
s32 type;
|
||||
s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor);
|
||||
|
||||
type = BGCTOWERGEAR_GET_TYPE(this);
|
||||
if (type == CEILING_COG) {
|
||||
if (type == BGCTOWERGEAR_CEILING_COG) {
|
||||
this->dyna.actor.shape.rot.x -= 0x1F4;
|
||||
} else if (type == CENTER_COG) {
|
||||
} else if (type == BGCTOWERGEAR_CENTER_COG) {
|
||||
this->dyna.actor.shape.rot.y += 0x1F4;
|
||||
func_800B9010(&this->dyna.actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG);
|
||||
} else if (type == WATER_WHEEL) {
|
||||
} else if (type == BGCTOWERGEAR_WATER_WHEEL) {
|
||||
this->dyna.actor.shape.rot.z -= 0x1F4;
|
||||
BgCtowerGear_Splash(this, globalCtx);
|
||||
}
|
||||
@@ -191,18 +180,17 @@ void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
// Using BgCtowerGear *this = THIS causes regalloc issues
|
||||
void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
Gfx_DrawDListOpa(globalCtx, D_80AD32E8[BGCTOWERGEAR_GET_TYPE(thisx)]);
|
||||
Gfx_DrawDListOpa(globalCtx, sDLists[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++, object_ctower_rot_DL_0160A0);
|
||||
gSPDisplayList(POLY_OPA_DISP++, gClockTowerOrganDL);
|
||||
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++, object_ctower_rot_DL_015F30);
|
||||
gSPDisplayList(POLY_XLU_DISP++, gClockTowerOrganPipesDL);
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,16 @@
|
||||
|
||||
struct BgCtowerGear;
|
||||
|
||||
|
||||
#define BGCTOWERGEAR_GET_TYPE(thisx) ((thisx)->params & 3)
|
||||
|
||||
typedef enum {
|
||||
/* 0x00 */ BGCTOWERGEAR_CEILING_COG,
|
||||
/* 0x01 */ BGCTOWERGEAR_CENTER_COG,
|
||||
/* 0x02 */ BGCTOWERGEAR_WATER_WHEEL,
|
||||
/* 0x03 */ BGCTOWERGEAR_ORGAN
|
||||
} BgCtowerGearType;
|
||||
|
||||
typedef struct BgCtowerGear {
|
||||
/* 0x000 */ DynaPolyActor dyna;
|
||||
} BgCtowerGear; // size = 0x15C
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File: z_bg_ctower_rot.c
|
||||
* Overlay: ovl_Bg_CtowerRot
|
||||
* Description: Twisting path along with the Doors to Clock Tower
|
||||
* Description: Twisting path along with the Stone Doors to Clock Tower
|
||||
*/
|
||||
|
||||
#include "z_bg_ctower_rot.h"
|
||||
@@ -37,28 +37,28 @@ static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
static Gfx* bgCtowerRotDlists[] = { object_ctower_rot_DL_012DA0, object_ctower_rot_DL_017220,
|
||||
object_ctower_rot_DL_0174E0 };
|
||||
static Gfx* sDLists[] = { gClockTowerCorridorDL, gClockTowerStoneDoorMainDL, gClockTowerStoneDoorDL };
|
||||
|
||||
void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgCtowerRot* this = THIS;
|
||||
s32 pad;
|
||||
BgCtowerRot* this = THIS;
|
||||
Player* player;
|
||||
Vec3f offset;
|
||||
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
DynaPolyActor_Init(&this->dyna, 1);
|
||||
if (this->dyna.actor.params == CORRIDOR) {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ctower_rot_Colheader_0142E8);
|
||||
if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerCorridorCol);
|
||||
this->actionFunc = BgCtowerRot_CorridorRotate;
|
||||
return;
|
||||
}
|
||||
|
||||
player = GET_PLAYER(globalCtx);
|
||||
if (this->dyna.actor.params == MAIN_DOOR) {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ctower_rot_Colheader_017410);
|
||||
if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerStoneDoorMainCol);
|
||||
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x4000;
|
||||
} else {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ctower_rot_Colheader_017650);
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerStoneDoorCol);
|
||||
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000;
|
||||
}
|
||||
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos);
|
||||
@@ -82,22 +82,18 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) {
|
||||
Player* player = GET_PLAYER(globalCtx);
|
||||
Vec3f offset;
|
||||
f32 rotZ;
|
||||
f32 offsetDiffZ;
|
||||
f32 rotZtmp;
|
||||
|
||||
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos);
|
||||
if (offset.z > 1100.0f) {
|
||||
rotZ = 0.0f;
|
||||
} else {
|
||||
offsetDiffZ = 1100.0f - offset.z;
|
||||
rotZtmp = (offsetDiffZ > 1000.0f)
|
||||
? 1000.0f
|
||||
: offsetDiffZ; // Removing rotZtmp just causes regalloc issues and a missing instruction
|
||||
rotZtmp = CLAMP_MAX(1100.0f - offset.z, 1000.0f);
|
||||
rotZ = rotZtmp;
|
||||
}
|
||||
func_800DFAC8(globalCtx->cameraPtrs[0], 0x11);
|
||||
func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 17);
|
||||
this->dyna.actor.shape.rot.z = rotZ * 16.384f;
|
||||
if (globalCtx->csCtx.frames == 0x84) {
|
||||
if (globalCtx->csCtx.frames == 132) {
|
||||
play_sound(NA_SE_SY_SPIRAL_DASH);
|
||||
}
|
||||
}
|
||||
@@ -107,12 +103,12 @@ void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx) {
|
||||
|
||||
void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) {
|
||||
if (!Math_SmoothStepToF(&this->timer, 0.0f, 0.1f, 15.0f, 0.1f)) {
|
||||
if (this->dyna.actor.params == MAIN_DOOR) {
|
||||
if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
|
||||
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP);
|
||||
ActorCutscene_Stop(this->dyna.actor.cutscene);
|
||||
}
|
||||
this->actionFunc = BgCtowerRot_DoorDoNothing;
|
||||
} else if (this->dyna.actor.params == 1) {
|
||||
} else if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
|
||||
func_800B9010(&this->dyna.actor, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG);
|
||||
}
|
||||
this->dyna.actor.world.pos.x =
|
||||
@@ -135,7 +131,7 @@ void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) {
|
||||
|
||||
void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx) {
|
||||
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
|
||||
if (this->dyna.actor.params == MAIN_DOOR) {
|
||||
if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
|
||||
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
|
||||
}
|
||||
this->actionFunc = BgCtowerRot_DoorClose;
|
||||
@@ -153,8 +149,8 @@ void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgCtowerRot* this = THIS;
|
||||
|
||||
Gfx_DrawDListOpa(globalCtx, bgCtowerRotDlists[this->dyna.actor.params]);
|
||||
if (this->dyna.actor.params == CORRIDOR) {
|
||||
Gfx_DrawDListXlu(globalCtx, object_ctower_rot_DL_0129D0);
|
||||
Gfx_DrawDListOpa(globalCtx, sDLists[this->dyna.actor.params]);
|
||||
if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) {
|
||||
Gfx_DrawDListXlu(globalCtx, gClockTowerCorridorFoliageDL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ struct BgCtowerRot;
|
||||
typedef void (*BgCtowerRotActionFunc)(struct BgCtowerRot*, GlobalContext*);
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ CORRIDOR,
|
||||
/* 1 */ MAIN_DOOR, // Main door controls cutscene flow (updating Link fields and playing sounds). It is the one on
|
||||
// the left when entering from the Lost Woods
|
||||
/* 2 */ DOOR,
|
||||
/* 0 */ BGCTOWERROT_CORRIDOR,
|
||||
/* 1 */ BGCTOWERROT_STONE_DOOR_MAIN, // Main door controls cutscene flow (updating Link fields and playing sounds).
|
||||
// It is the one on the left when entering from the Lost Woods
|
||||
/* 2 */ BGCTOWERROT_STONE_DOOR,
|
||||
} BgCtowerRotType;
|
||||
|
||||
typedef struct BgCtowerRot {
|
||||
|
||||
Reference in New Issue
Block a user