From 2412e2723e5f72120c9be99b60c331a340de3df8 Mon Sep 17 00:00:00 2001 From: tom-overton Date: Tue, 9 Nov 2021 14:12:52 -0800 Subject: [PATCH] Respond to Anghelo's feedback --- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 33 +++---------------- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h | 27 ++++++++++++--- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 2dc93275b5..b6f40602d4 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -30,31 +30,6 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx); void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx); void ObjTokeidai_TowerGear_Draw(Actor* thisx, GlobalContext* globalCtx); -// Used for regular clock functions -#define clockFaceRotationalVelocity actionVar1 -#define clockFaceRotationTimer actionVar2 -#define sunMoonDiskRotationalVelocity actionVar3 -#define clockHour actionVar4 - -// Used for regular counterweight functions -#define spotlightIntensity actionVar4 - -// Used in ObjTokeidai_TowerTransformation_FinishRaise -#define settleTimer actionVar1 -#define settleAmount actionVar2 - -// Used in ObjTokeidai_TowerTransformation_DropCounterweight -#define transformationRotationalVelocity actionVar1 -#define transformationRotationalAcceleration actionVar2 - -// Used in ObjTokeidai_TowerTransformation_Wait -#define transformationWaitTimer actionVar1 - -// Used in ObjTokeidai_TowerClock_SlideOff and ObjTokeidai_TowerClock_Fall -#define slidingClockFaceAngle actionVar1 -#define aerialClockFaceSpeed actionVar2 -#define fallingClockFaceRotationalVelocity actionVar3 - const ActorInit Obj_Tokeidai_InitVars = { ACTOR_OBJ_TOKEIDAI, ACTORCAT_PROP, @@ -610,7 +585,7 @@ s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* glo if (gSaveContext.inventory.items[0] == 0xFF) { return false; } - if (gSaveContext.day % 5 == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) { ObjTokeidai_SetupTowerTransformation(this); return true; } @@ -671,7 +646,7 @@ void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) } void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (gSaveContext.day % 5 == 3 && this->clockHour < 6 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.time < CLOCK_TIME(6, 0)) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_SetupTowerTransformation(this); gSaveContext.weekEventReg[8] |= 0x40; @@ -683,7 +658,7 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { this->currentTime += 3; this->actor.draw = ObjTokeidai_Clock_Draw; } else { - if ((globalCtx->actorCtx.unk5 & 2) == 0 && + if (!(globalCtx->actorCtx.unk5 & 2) && OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD && ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; @@ -695,7 +670,7 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { } } - if (gSaveContext.day % 5 != 3 || gSaveContext.time >= CLOCK_TIME(6, 0)) { + if (CURRENT_DAY != 3 || gSaveContext.time >= CLOCK_TIME(6, 0)) { ObjTokeidai_RotateOnMinuteChange(this, true); } ObjTokeidai_RotateOnHourChange(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h index f91eca531a..52ca9707e4 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h @@ -8,7 +8,7 @@ #define OBJ_TOKEIDAI_GET_CURRENT_MINUTE(this) ((s32)(this->currentTime * (360 * 2.0f / 0x10000)) % 30) #define OBJ_TOKEIDAI_GET_CLOCK_FACE_ROTATION(currentHour) ((s16)(currentHour * (0x10000 / 24.0f))) #define OBJ_TOKEIDAI_GET_OUTER_RING_OR_GEAR_ROTATION(currentMinute) ((s16)(currentMinute * (0x10000 * 12.0f / 360))) -#define OBJ_TOKEIDAI_IS_TRANSFORMED() ((gSaveContext.day % 5 == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || gSaveContext.day % 5 >= 4) +#define OBJ_TOKEIDAI_IS_TRANSFORMED() ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) typedef enum { /* 0 */ OBJ_TOKEIDAI_TYPE_TOWER_GEAR_CLOCK_TOWN, @@ -36,16 +36,33 @@ typedef struct ObjTokeidai { /* 0x14E */ s16 outerRingOrGearRotationalVelocity; /* 0x150 */ s16 outerRingOrGearRotationTimer; /* 0x152 */ s16 clockFaceRotation; - /* 0x154 */ s16 actionVar1; - /* 0x156 */ s16 actionVar2; + /* 0x154 */ union { + s16 clockFaceRotationalVelocity; + s16 settleTimer; + s16 transformationRotationalVelocity; + s16 transformationWaitTimer; + s16 slidingClockFaceAngle; + }; + /* 0x156 */ union { + s16 clockFaceRotationTimer; + s16 settleAmount; + s16 transformationRotationalAcceleration; + s16 aerialClockFaceSpeed; + }; /* 0x158 */ s32 sunMoonDiskRotation; - /* 0x15C */ s16 actionVar3; + /* 0x15C */ union { + s16 sunMoonDiskRotationalVelocity; + s16 fallingClockFaceRotationalVelocity; + }; /* 0x15E */ s16 yTranslation; /* 0x160 */ s16 xRotation; /* 0x162 */ s16 clockFaceZTranslation; // amount the clock face recesses inwards once it transforms /* 0x164 */ s16 boundCount; /* 0x168 */ s32 clockMinute; // only 30 minutes in an hour - /* 0x16C */ s32 actionVar4; + /* 0x16C */ union { + s32 clockHour; + s32 spotlightIntensity; + }; /* 0x170 */ u16 currentTime; /* 0x174 */ ObjTokeidaiActionFunc actionFunc; } ObjTokeidai; // size = 0x178