diff --git a/include/z64actor.h b/include/z64actor.h index 6790bc2224..19bf3b8706 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -289,7 +289,7 @@ typedef enum { } ActorType; #define ACTORCTX_FLAG_0 (1 << 0) -#define ACTORCTX_FLAG_1 (1 << 1) +#define ACTORCTX_FLAG_TELESCOPE_ON (1 << 1) #define ACTORCTX_FLAG_PICTO_BOX_ON (1 << 2) #define ACTORCTX_FLAG_3 (1 << 3) #define ACTORCTX_FLAG_4 (1 << 4) diff --git a/include/z64environment.h b/include/z64environment.h index 0988355f4d..45f8463f05 100644 --- a/include/z64environment.h +++ b/include/z64environment.h @@ -63,7 +63,7 @@ typedef enum { typedef enum { /* 0 */ WEATHER_MODE_CLEAR, - /* 1 */ WEATHER_MODE_1, // rain? + /* 1 */ WEATHER_MODE_RAIN, /* 2 */ WEATHER_MODE_2, /* 3 */ WEATHER_MODE_SNOW } WeatherMode; @@ -81,6 +81,38 @@ typedef enum { /* 11 */ SKYBOX_DMA_TEXTURE2_START = 11 } SkyboxDmaState; +typedef enum SkyboxConfig { + /* 0x00 */ SKYBOX_CONFIG_0, + /* 0x01 */ SKYBOX_CONFIG_1, + /* 0x02 */ SKYBOX_CONFIG_2, + /* 0x03 */ SKYBOX_CONFIG_3, + /* 0x04 */ SKYBOX_CONFIG_4, + /* 0x05 */ SKYBOX_CONFIG_5, + /* 0x06 */ SKYBOX_CONFIG_6, + /* 0x07 */ SKYBOX_CONFIG_7, + /* 0x08 */ SKYBOX_CONFIG_8, + /* 0x09 */ SKYBOX_CONFIG_9, + /* 0x0A */ SKYBOX_CONFIG_10, + /* 0x0B */ SKYBOX_CONFIG_11, + /* 0x0C */ SKYBOX_CONFIG_12, + /* 0x0D */ SKYBOX_CONFIG_13, + /* 0x0E */ SKYBOX_CONFIG_14, + /* 0x0F */ SKYBOX_CONFIG_15, + /* 0x10 */ SKYBOX_CONFIG_16, + /* 0x11 */ SKYBOX_CONFIG_17, + /* 0x12 */ SKYBOX_CONFIG_18, + /* 0x13 */ SKYBOX_CONFIG_19, + /* 0x14 */ SKYBOX_CONFIG_20, + /* 0x15 */ SKYBOX_CONFIG_21, + /* 0x16 */ SKYBOX_CONFIG_22, + /* 0x17 */ SKYBOX_CONFIG_23, + /* 0x18 */ SKYBOX_CONFIG_24, + /* 0x19 */ SKYBOX_CONFIG_25, + /* 0x1A */ SKYBOX_CONFIG_26, + /* 0x1B */ SKYBOX_CONFIG_27, + /* 0x1C */ SKYBOX_CONFIG_MAX +} SkyboxConfig; + //! @TODO: Verify from OoT (may not be the same) typedef enum { /* 0 */ PRECIP_RAIN_MAX, // max number of raindrops that can draw; uses this or SOS_MAX, whichever is larger @@ -145,15 +177,6 @@ typedef struct LightningStrike { /* 0x08 */ f32 delayTimer; } LightningStrike; // size = 0xC -typedef struct { - /* 0x0 */ u16 startTime; - /* 0x2 */ u16 endTime; - /* 0x4 */ u8 skybox1Index; - /* 0x5 */ u8 skybox2Index; - /* 0x6 */ u8 color1Index; - /* 0x7 */ u8 color2Index; -} TimeBasedSkyboxEntry; // size = 0x8 - #define ENV_FOGNEAR_MAX 996 #define ENV_ZFAR_MAX 15000 @@ -298,7 +321,7 @@ void Environment_LerpSandstormColors(Color_RGBA8* colorSrc, Color_RGBA8* colorDs u8 func_800FE9B4(struct PlayState* play); void func_800FEA50(struct PlayState* play); void func_800FEAB0(void); -void func_800FEAF4(EnvironmentContext* envCtx); +void Environment_NewDay(EnvironmentContext* envCtx); // Data extern u8 gWeatherMode; diff --git a/include/z64save.h b/include/z64save.h index 67449a1781..c063fbd370 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -451,11 +451,12 @@ typedef enum { #define LINK_AGE_IN_YEARS (!LINK_IS_ADULT ? YEARS_CHILD : YEARS_ADULT) #define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) +#define CURRENT_TIME ((void)0, gSaveContext.save.time) // The day begins at CLOCK_TIME(6, 0) so it must be offset. #define TIME_UNTIL_MOON_CRASH \ - ((4 - CURRENT_DAY) * DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0))) -#define TIME_UNTIL_NEW_DAY (DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0))) + ((4 - CURRENT_DAY) * DAY_LENGTH - (u16)(CURRENT_TIME - CLOCK_TIME(6, 0))) +#define TIME_UNTIL_NEW_DAY (DAY_LENGTH - (u16)(CURRENT_TIME - CLOCK_TIME(6, 0))) #define GET_PLAYER_FORM ((void)0, gSaveContext.save.playerForm) @@ -1581,7 +1582,7 @@ typedef enum { #define EVENTINF_47 0x47 #define EVENTINF_50 0x50 #define EVENTINF_51 0x51 -#define EVENTINF_52 0x52 +#define EVENTINF_HAS_DAYTIME_TRANSITION_CS 0x52 #define EVENTINF_53 0x53 #define EVENTINF_54 0x54 #define EVENTINF_55 0x55 diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 26221708c6..0ef8fed953 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -176,8 +176,8 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { case CS_MISC_CLOUDY_SKY: if (isFirstFrame) { play->envCtx.changeSkyboxState = CHANGE_SKYBOX_REQUESTED; - play->envCtx.skyboxConfig = 1; - play->envCtx.changeSkyboxNextConfig = 0; + play->envCtx.skyboxConfig = SKYBOX_CONFIG_1; + play->envCtx.changeSkyboxNextConfig = SKYBOX_CONFIG_0; play->envCtx.changeSkyboxTimer = 60; play->envCtx.changeLightEnabled = true; play->envCtx.lightConfig = 0; @@ -331,7 +331,7 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { case CS_MISC_MOON_CRASH_SKYBOX: if (isFirstFrame) { - play->envCtx.skyboxConfig = 0xD; + play->envCtx.skyboxConfig = SKYBOX_CONFIG_13; } break; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 32a8d5d748..3b1ff5cfca 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -97,7 +97,7 @@ void KaleidoSetup_Update(PlayState* play) { if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { if (!CHECK_EVENTINF(EVENTINF_17) && !(player->stateFlags1 & PLAYER_STATE1_20)) { - if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + if (!(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) && !(play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON)) { if (!play->actorCtx.isOverrideInputOn && CHECK_BTN_ALL(input->press.button, BTN_START)) { diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 933d9f3b74..84acb9c646 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -23,7 +23,7 @@ typedef struct { struct LightningStrike; u8 D_801F4E30; -u8 D_801F4E31; +u8 sInitSkyboxConfig; u8 gCustomLensFlare1On; Vec3f gCustomLensFlare1Pos; f32 D_801F4E44; @@ -156,7 +156,17 @@ TimeBasedLightEntry sTimeBasedLightConfigs[][7] = { }, }; -TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { +typedef struct { + /* 0x0 */ u16 startTime; + /* 0x2 */ u16 endTime; + /* 0x4 */ u8 skybox1Index; + /* 0x5 */ u8 skybox2Index; + /* 0x6 */ u8 color1Index; + /* 0x7 */ u8 color2Index; +} TimeBasedSkyboxEntry; // size = 0x8 + +TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[SKYBOX_CONFIG_MAX][9] = { + // SKYBOX_CONFIG_0 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 3, 3 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 3, 4 }, @@ -168,6 +178,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 2, 3 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 3, 3 }, }, + // SKYBOX_CONFIG_1 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 7, 7 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 7, 8 }, @@ -179,6 +190,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 6, 7 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 7, 7 }, }, + // SKYBOX_CONFIG_2 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 11, 11 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 11, 52 }, @@ -190,6 +202,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 10, 11 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 11, 11 }, }, + // SKYBOX_CONFIG_3 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 15, 15 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 15, 16 }, @@ -201,6 +214,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 14, 15 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 15, 15 }, }, + // SKYBOX_CONFIG_4 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 19, 19 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 19, 20 }, @@ -212,6 +226,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 0, 18, 19 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 19, 19 }, }, + // SKYBOX_CONFIG_5 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 23, 23 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 23, 52 }, @@ -223,6 +238,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 22, 23 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 23, 23 }, }, + // SKYBOX_CONFIG_6 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 27, 27 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 27, 28 }, @@ -234,6 +250,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 26, 27 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 27, 27 }, }, + // SKYBOX_CONFIG_7 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 31, 31 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 31, 32 }, @@ -245,6 +262,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 0, 30, 31 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 31, 31 }, }, + // SKYBOX_CONFIG_8 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 35, 35 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 35, 52 }, @@ -256,6 +274,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 34, 35 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 35, 35 }, }, + // SKYBOX_CONFIG_9 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 39, 39 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 39, 40 }, @@ -267,6 +286,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 38, 39 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 39, 39 }, }, + // SKYBOX_CONFIG_10 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 43, 43 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 43, 44 }, @@ -278,6 +298,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 0, 42, 43 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 43, 43 }, }, + // SKYBOX_CONFIG_11 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 47, 47 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 47, 52 }, @@ -289,6 +310,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 46, 47 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 47, 47 }, }, + // SKYBOX_CONFIG_12 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 51, 51 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 51, 48 }, @@ -300,6 +322,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 50, 51 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 51, 51 }, }, + // SKYBOX_CONFIG_13 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 55, 55 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 55, 52 }, @@ -311,6 +334,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 54, 54 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 55, 55 }, }, + // SKYBOX_CONFIG_14 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 59, 59 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 59, 56 }, @@ -322,6 +346,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 58, 58 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 59, 59 }, }, + // SKYBOX_CONFIG_15 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 63, 63 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 63, 60 }, @@ -333,6 +358,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 62, 62 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 63, 63 }, }, + // SKYBOX_CONFIG_16 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 67, 67 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 67, 64 }, @@ -344,6 +370,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 66, 66 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 67, 67 }, }, + // SKYBOX_CONFIG_17 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 1, 1 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 0, 1, 1 }, @@ -355,6 +382,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 1, 1 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 1, 1 }, }, + // SKYBOX_CONFIG_18 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 71, 71 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 71, 72 }, @@ -366,6 +394,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 70, 71 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 71, 71 }, }, + // SKYBOX_CONFIG_19 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 75, 75 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 75, 76 }, @@ -377,6 +406,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 74, 75 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 75, 75 }, }, + // SKYBOX_CONFIG_20 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 79, 79 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 79, 52 }, @@ -388,6 +418,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 78, 79 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 79, 79 }, }, + // SKYBOX_CONFIG_21 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 83, 83 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 83, 84 }, @@ -399,6 +430,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 82, 83 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 83, 83 }, }, + // SKYBOX_CONFIG_22 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 87, 87 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 87, 88 }, @@ -410,6 +442,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 86, 87 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 87, 87 }, }, + // SKYBOX_CONFIG_23 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 91, 91 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 91, 52 }, @@ -421,6 +454,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 90, 91 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 91, 91 }, }, + // SKYBOX_CONFIG_24 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 11, 11 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 0, 11, 11 }, @@ -432,6 +466,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 11, 11 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 11, 11 }, }, + // SKYBOX_CONFIG_25 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 95, 95 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 95, 96 }, @@ -443,6 +478,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 0, 0, 94, 95 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 0, 0, 95, 95 }, }, + // SKYBOX_CONFIG_26 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 1, 1, 99, 99 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 1, 1, 99, 100 }, @@ -454,6 +490,7 @@ TimeBasedSkyboxEntry sTimeBasedSkyboxConfigs[][9] = { { CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), 1, 1, 98, 99 }, { CLOCK_TIME(19, 0), CLOCK_TIME(24, 0) - 1, 1, 1, 99, 99 }, }, + // SKYBOX_CONFIG_27 { { CLOCK_TIME(0, 0), CLOCK_TIME(4, 0), 0, 0, 103, 103 }, { CLOCK_TIME(4, 0), CLOCK_TIME(5, 0), 0, 1, 103, 52 }, @@ -528,7 +565,7 @@ s32 Environment_ZBufValToFixedPoint(s32 zBufferVal) { void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2) { PlayState* play = play2; f32 temp_ft4; - u8 var_a0; + u8 dayOffset; s16 i; CREG(1) = 0; @@ -664,46 +701,46 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2) { play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; play->envCtx.precipitation[PRECIP_SOS_MAX] = 0; - D_801F4E31 = envCtx->skyboxConfig; + sInitSkyboxConfig = envCtx->skyboxConfig; - var_a0 = 0; + dayOffset = 0; if (((void)0, gSaveContext.save.day) != 0) { - var_a0 = ((void)0, gSaveContext.save.day) - 1; + dayOffset = ((void)0, gSaveContext.save.day) - 1; } - envCtx->skyboxConfig = var_a0 + (D_801F4E31 * 3); + envCtx->skyboxConfig = dayOffset + (sInitSkyboxConfig * 3); envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - if (D_801F4E31 == 4) { - envCtx->skyboxConfig = 0xE; + if (sInitSkyboxConfig == SKYBOX_CONFIG_4) { + envCtx->skyboxConfig = SKYBOX_CONFIG_14; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 5) { - envCtx->skyboxConfig = 0x10; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_5) { + envCtx->skyboxConfig = SKYBOX_CONFIG_16; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 6) { - envCtx->skyboxConfig = 0x11; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_6) { + envCtx->skyboxConfig = SKYBOX_CONFIG_17; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 7) { - envCtx->skyboxConfig = var_a0 + 0x12; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_7) { + envCtx->skyboxConfig = SKYBOX_CONFIG_18 + dayOffset; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 8) { - envCtx->skyboxConfig = var_a0 + 0x15; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_8) { + envCtx->skyboxConfig = SKYBOX_CONFIG_21 + dayOffset; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 9) { - envCtx->skyboxConfig = 0x18; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_9) { + envCtx->skyboxConfig = SKYBOX_CONFIG_24; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 0xA) { - envCtx->skyboxConfig = var_a0 + 0x19; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_10) { + envCtx->skyboxConfig = SKYBOX_CONFIG_25 + dayOffset; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; } - if (var_a0 >= 3) { - envCtx->skyboxConfig = 0xD; - envCtx->changeSkyboxNextConfig = 0xD; + if (dayOffset >= 3) { + envCtx->skyboxConfig = SKYBOX_CONFIG_13; + envCtx->changeSkyboxNextConfig = SKYBOX_CONFIG_13; } - if (envCtx->skyboxConfig >= 0x1C) { - envCtx->skyboxConfig = 0; - envCtx->changeSkyboxNextConfig = 0; + if (envCtx->skyboxConfig >= SKYBOX_CONFIG_MAX) { + envCtx->skyboxConfig = SKYBOX_CONFIG_0; + envCtx->changeSkyboxNextConfig = SKYBOX_CONFIG_0; } D_801F4E74 = 0.0f; @@ -737,7 +774,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2) { play->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; - if (gWeatherMode == WEATHER_MODE_1) { + if (gWeatherMode == WEATHER_MODE_RAIN) { if (((u32)CURRENT_DAY == 2) && (((void)0, gSaveContext.save.time) >= CLOCK_TIME(7, 0)) && (((void)0, gSaveContext.save.time) < CLOCK_TIME(17, 30))) { if (Environment_GetStormState(play) != STORM_STATE_OFF) { @@ -970,8 +1007,8 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon u8 skyboxBlend = 0; f32 colorWeight = 0.0f; - if (envCtx->skyboxConfig >= 0x1C) { - envCtx->skyboxConfig = 0; + if (envCtx->skyboxConfig >= SKYBOX_CONFIG_MAX) { + envCtx->skyboxConfig = SKYBOX_CONFIG_0; } if ((skyboxId == SKYBOX_NORMAL_SKY) || ((skyboxId == SKYBOX_3) && (D_801F4E74 < 1.0f))) { @@ -1219,7 +1256,7 @@ void func_800F6CEC(PlayState* play, u8 arg1, AdjLightSettings* adjLightSettings, lightSettings[temp_v1_2 + temp_v1].blendRateAndFogNear - lightSettings[temp_v1].blendRateAndFogNear; } - if ((arg1 >= 4) && (arg1 < 8) && (gWeatherMode == WEATHER_MODE_1)) { + if ((arg1 >= 4) && (arg1 < 8) && (gWeatherMode == WEATHER_MODE_RAIN)) { adjLightSettings->ambientColor[0] = -50; adjLightSettings->ambientColor[1] = -100; adjLightSettings->ambientColor[2] = -100; @@ -2448,7 +2485,7 @@ void Environment_UpdateTimeBasedSequence(PlayState* play) { //! FAKE: if (!gSaveContext.sceneLayer) {} - if ((play->csCtx.state == 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((play->csCtx.state == 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { switch (play->envCtx.timeSeqState) { case TIMESEQ_DAY_BGM: break; @@ -3074,7 +3111,7 @@ void Environment_SetupSkyboxStars(PlayState* play) { phi_f0 = 0.0f; } - phi_f0 = (play->envCtx.skyboxConfig == 0x18) ? 1.0f : phi_f0; + phi_f0 = (play->envCtx.skyboxConfig == SKYBOX_CONFIG_24) ? 1.0f : phi_f0; D_801F4F28 = phi_f0; sEnvSkyboxNumStars = gSkyboxNumStars; @@ -3486,47 +3523,47 @@ void Environment_JumpForwardInTime(void) { } } -void func_800FEAF4(EnvironmentContext* envCtx) { - u8 phi_v1 = 0; +void Environment_NewDay(EnvironmentContext* envCtx) { + u8 dayOffset = 0; if (((void)0, gSaveContext.save.day) != 0) { - phi_v1 = ((void)0, gSaveContext.save.day) - 1; + dayOffset = ((void)0, gSaveContext.save.day) - 1; } - envCtx->skyboxConfig = phi_v1 + (D_801F4E31 * 3); + envCtx->skyboxConfig = dayOffset + (sInitSkyboxConfig * 3); envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - if (D_801F4E31 == 4) { - envCtx->skyboxConfig = 0xE; + if (sInitSkyboxConfig == SKYBOX_CONFIG_4) { + envCtx->skyboxConfig = SKYBOX_CONFIG_14; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 5) { - envCtx->skyboxConfig = 0x10; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_5) { + envCtx->skyboxConfig = SKYBOX_CONFIG_16; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 6) { - envCtx->skyboxConfig = 0x11; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_6) { + envCtx->skyboxConfig = SKYBOX_CONFIG_17; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 7) { - envCtx->skyboxConfig = phi_v1 + 0x12; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_7) { + envCtx->skyboxConfig = SKYBOX_CONFIG_18 + dayOffset; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 8) { - envCtx->skyboxConfig = phi_v1 + 0x15; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_8) { + envCtx->skyboxConfig = SKYBOX_CONFIG_21 + dayOffset; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 9) { - envCtx->skyboxConfig = 0x18; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_9) { + envCtx->skyboxConfig = SKYBOX_CONFIG_24; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; - } else if (D_801F4E31 == 0xA) { - envCtx->skyboxConfig = phi_v1 + 0x19; + } else if (sInitSkyboxConfig == SKYBOX_CONFIG_10) { + envCtx->skyboxConfig = SKYBOX_CONFIG_25 + dayOffset; envCtx->changeSkyboxNextConfig = envCtx->skyboxConfig; } - if (phi_v1 >= 3) { - envCtx->skyboxConfig = 0xD; - envCtx->changeSkyboxNextConfig = 0xD; + if (dayOffset >= 3) { + envCtx->skyboxConfig = SKYBOX_CONFIG_13; + envCtx->changeSkyboxNextConfig = SKYBOX_CONFIG_13; } - if (envCtx->skyboxConfig >= 0x1C) { - envCtx->skyboxConfig = 0; - envCtx->changeSkyboxNextConfig = 0; + if (envCtx->skyboxConfig >= SKYBOX_CONFIG_MAX) { + envCtx->skyboxConfig = SKYBOX_CONFIG_0; + envCtx->changeSkyboxNextConfig = SKYBOX_CONFIG_0; } switch (((void)0, gSaveContext.save.day)) { diff --git a/src/code/z_message.c b/src/code/z_message.c index 63330e5076..ca02888171 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -5725,7 +5725,7 @@ void Message_Update(PlayState* play) { } if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6) && - (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { Message_StartTextbox(play, 0x5E6, NULL); break; } @@ -5888,7 +5888,7 @@ void Message_Update(PlayState* play) { msgCtx->textboxColorAlphaCurrent -= XREG(70); if (msgCtx->textboxColorAlphaCurrent <= 0) { if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6) && - (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { Message_StartTextbox(play, 0x5E6, NULL); Interface_SetHudVisibility(HUD_VISIBILITY_NONE_ALT); } else { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index db101efb58..9bf52c4e47 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -4405,7 +4405,8 @@ void Interface_DrawClock(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); if ((R_TIME_SPEED != 0) && - ((msgCtx->msgMode == MSGMODE_NONE) || ((play->actorCtx.flags & ACTORCTX_FLAG_1) && !Play_InCsMode(play)) || + ((msgCtx->msgMode == MSGMODE_NONE) || + ((play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) && !Play_InCsMode(play)) || (msgCtx->msgMode == MSGMODE_NONE) || ((msgCtx->currentTextId >= 0x100) && (msgCtx->currentTextId <= 0x200)) || (gSaveContext.gameMode == GAMEMODE_END_CREDITS)) && !FrameAdvance_IsEnabled(&play->state) && !Environment_IsTimeStopped() && (gSaveContext.save.day <= 3)) { @@ -4428,7 +4429,7 @@ void Interface_DrawClock(PlayState* play) { sClockAlphaTimer1 = 0; } } else { - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { sThreeDayClockAlpha = 255; } else { sThreeDayClockAlpha = interfaceCtx->bAlpha; @@ -4437,7 +4438,7 @@ void Interface_DrawClock(PlayState* play) { sClockAlphaTimer1 = 0; } } else { - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { sThreeDayClockAlpha = 255; } else { sThreeDayClockAlpha = interfaceCtx->bAlpha; @@ -5432,7 +5433,7 @@ void Interface_DrawPerfectLetters(PlayState* play) { } void Interface_StartMoonCrash(PlayState* play) { - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { SEQCMD_DISABLE_PLAY_SEQUENCES(false); } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 4d725be755..46fb96daee 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1138,7 +1138,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0)) { - if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { Actor_Kill(&this->actor); } @@ -1177,8 +1177,8 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.scriptIndex > 0)) { - play->envCtx.skyboxConfig = 15; - play->envCtx.changeSkyboxNextConfig = 15; + play->envCtx.skyboxConfig = SKYBOX_CONFIG_15; + play->envCtx.changeSkyboxNextConfig = SKYBOX_CONFIG_15; } } @@ -1680,7 +1680,7 @@ void DmStk_HandleCutscene(DmStk* this, PlayState* play) { this->alpha = 0; this->fadeOutState = SK_FADE_OUT_STATE_NONE; SET_WEEKEVENTREG(WEEKEVENTREG_12_04); - if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { Actor_Kill(&this->actor); } else { this->shouldDraw = false; @@ -1867,7 +1867,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { // This code is responsible for making in-game time pass while using the telescope in the Astral Observatory. // Skull Kid is always loaded in the scene, even if he isn't visible, hence why time always passes. - if ((play->actorCtx.flags & ACTORCTX_FLAG_1) && (play->msgCtx.msgMode != MSGMODE_NONE) && + if ((play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) && (play->msgCtx.msgMode != MSGMODE_NONE) && (play->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&play->state) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (play->csCtx.state == CS_STATE_IDLE)) { @@ -1880,8 +1880,8 @@ void DmStk_Update(Actor* thisx, PlayState* play) { } if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.scriptIndex > 0)) { - play->envCtx.skyboxConfig = 15; - play->envCtx.changeSkyboxNextConfig = 15; + play->envCtx.skyboxConfig = SKYBOX_CONFIG_15; + play->envCtx.changeSkyboxNextConfig = SKYBOX_CONFIG_15; } } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index 1d78c27ef0..581fe6408a 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -283,7 +283,7 @@ void EnFall_Setup(EnFall* this, PlayState* play) { this->actor.draw = NULL; this->actionFunc = EnFall_MoonsTear_Fall; Actor_SetScale(&this->actor, 0.02f); - if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { Actor_Kill(&this->actor); } moon = EnFall_MoonsTear_GetTerminaFieldMoon(play); diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index a6f201813f..8a2abaff86 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -112,7 +112,7 @@ void EnGe2_Init(Actor* thisx, PlayState* play) { EnGe2_SetupPath(this, play); this->picto.actor.flags |= ACTOR_FLAG_10; - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { this->picto.actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); } diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index 4f9220ec2b..d0282d4887 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -50,7 +50,7 @@ void EnScopecoin_Init(Actor* thisx, PlayState* play) { this->rupeeIndex = 0; } - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { if ((this->rupeeIndex == 2) || (this->rupeeIndex == 6)) { if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { Actor_Kill(&this->actor); diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index a49c08b77b..2117c48781 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -306,7 +306,7 @@ void EnScopecrow_Init(Actor* thisx, PlayState* play) { return; } - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { SkelAnime_InitFlex(play, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, OBJECT_CROW_LIMB_MAX); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 99a0a7932d..0373571805 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -707,7 +707,7 @@ void EnScopenuts_Init(Actor* thisx, PlayState* play) { if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_40)) { Actor_Kill(&this->actor); - } else if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + } else if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { this->path = SubS_GetPathByIndex(play, ENSCOPENUTS_GET_PATH_INDEX(&this->actor), ENSCOPENUTS_PATH_INDEX_NONE); this->actor.draw = NULL; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index a2759f3bd2..57d9b96d83 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -131,7 +131,7 @@ void EnSth_Init(Actor* thisx, PlayState* play) { switch (STH_GET_TYPE(&this->actor)) { case STH_TYPE_UNUSED_1: - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = EnSth_DefaultIdle; } else { diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index cf902578c4..9859a3054d 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -40,7 +40,7 @@ void EnSth2_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); this->unused = 0; - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); } else { Actor_Kill(&this->actor); diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 0e2e81bbd8..c4e1aa7c18 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -1,7 +1,9 @@ /* * File: z_en_test4.c * Overlay: ovl_En_Test4 - * Description: Three-Day Events + * Description: Three-Day Events: day-night transitions, shrink screen before next day, + * play bell sounds, triggers clocktown midnight cutscene, controls weather events, + * sets skybox star count */ #include "z_en_test4.h" @@ -17,8 +19,8 @@ void EnTest4_Init(Actor* thisx, PlayState* play); void EnTest4_Destroy(Actor* thisx, PlayState* play); void EnTest4_Update(Actor* thisx, PlayState* play); -void func_80A42AB8(EnTest4* this, PlayState* play); -void func_80A42F20(EnTest4* this, PlayState* play); +void EnTest4_HandleEvents(EnTest4* this, PlayState* play); +void EnTest4_HandleCutscene(EnTest4* this, PlayState* play); ActorInit En_Test4_InitVars = { /**/ ACTOR_EN_TEST4, @@ -33,253 +35,284 @@ ActorInit En_Test4_InitVars = { }; static s32 sIsLoaded = false; -// "Night of ..." -static s16 sNightMessages1[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; -// "Dawn of ..." (Note: first two message are the same) -static s16 sDayMessages1[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; -// "Night of ..." -static s16 sNightMessages2[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; -// "Dawn of ..." (Note: first two message are the same) -static s16 sDayMessages2[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; -static u16 D_80A43364[] = { CLOCK_TIME(6, 0), CLOCK_TIME(18, 0) }; -static s16 sCsIdList[2]; +static s16 sCsIdList[THREEDAY_DAYTIME_MAX]; static s16 sCurCsId; -void func_80A41D70(EnTest4* this, PlayState* play) { - if (this->csIdIndex != 0) { - Message_DisplaySceneTitleCard(play, sNightMessages1[CURRENT_DAY - 1]); - } else if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { - if (play->actorCtx.flags & ACTORCTX_FLAG_1) { +/** + * Handles the transition from day-night and night-day. + * This does not handle DayTelop transitions. + * Only differs from `EnTest4_HandleDayNightSwap` with an extra telescope check when turning day without a cutscene. + */ +void EnTest4_HandleDayNightSwapFromInit(EnTest4* this, PlayState* play) { + // "Night of ..." + static s16 sNightOfTextIds[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; + // "Dawn of ..." (Note: first two message are the same) + static s16 sDawnOfTextIds[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; + + if (this->daytimeIndex != THREEDAY_DAYTIME_NIGHT) { + // Previously day, turning night + Message_DisplaySceneTitleCard(play, sNightOfTextIds[CURRENT_DAY - 1]); + } else if ((sCsIdList[this->daytimeIndex] <= CS_ID_NONE) || (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { + // Previously night, turning day, without a cutscene + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); - Message_DisplaySceneTitleCard(play, sDayMessages1[CURRENT_DAY - 1]); + Message_DisplaySceneTitleCard(play, sDawnOfTextIds[CURRENT_DAY - 1]); } else { - this->csIdIndex = 0; - this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->prevTime = CURRENT_TIME; } Interface_NewDay(play, CURRENT_DAY); gSceneSeqState = SCENESEQ_MORNING; Environment_PlaySceneSequence(play); - func_800FEAF4(&play->envCtx); - this->actionFunc = func_80A42AB8; + Environment_NewDay(&play->envCtx); + this->actionFunc = EnTest4_HandleEvents; } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { - this->actionFunc = func_80A42F20; - sCurCsId = sCsIdList[this->csIdIndex]; + // No scripted cutscene + if ((sCsIdList[this->daytimeIndex] > CS_ID_NONE) && !(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { + // Day-Night transition cutscene + this->actionFunc = EnTest4_HandleCutscene; + sCurCsId = sCsIdList[this->daytimeIndex]; this->transitionCsTimer = 0; SET_EVENTINF(EVENTINF_17); - } else if (this->csIdIndex == 0) { + } else if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { + // Previously night, turning day, without cutscene Audio_PlaySfx(NA_SE_EV_CHICKEN_CRY_M); } else { + // Previously day, turning night, without cutscene Audio_PlaySfx_2(NA_SE_EV_DOG_CRY_EVENING); } } else { - this->actionFunc = func_80A42AB8; - if (this->csIdIndex == 0) { - this->csIdIndex = 1; + // In a scripted cutscene + this->actionFunc = EnTest4_HandleEvents; + if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { + this->daytimeIndex = THREEDAY_DAYTIME_DAY; } else { - this->csIdIndex = 0; + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; } - this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->prevTime = CURRENT_TIME; } } -void func_80A41FA4(EnTest4* this, PlayState* play) { - if (this->csIdIndex != 0) { - Message_DisplaySceneTitleCard(play, sNightMessages2[CURRENT_DAY - 1]); - } else if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { +/** + * Handles the transition from day-night and night-day. + * This does not handle DayTelop transitions. + */ +void EnTest4_HandleDayNightSwap(EnTest4* this, PlayState* play) { + // "Night of ..." + static s16 sNightOfTextIds[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; + // "Dawn of ..." (Note: first two message are the same) + static s16 sDawnOfTextIds[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; + + if (this->daytimeIndex != THREEDAY_DAYTIME_NIGHT) { + // Previously day, turning night + Message_DisplaySceneTitleCard(play, sNightOfTextIds[CURRENT_DAY - 1]); + } else if ((sCsIdList[this->daytimeIndex] <= CS_ID_NONE) || (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { + // Previously night, turning day, without a cutscene Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); Interface_NewDay(play, CURRENT_DAY); - Message_DisplaySceneTitleCard(play, sDayMessages2[CURRENT_DAY - 1]); + Message_DisplaySceneTitleCard(play, sDawnOfTextIds[CURRENT_DAY - 1]); gSceneSeqState = SCENESEQ_MORNING; Environment_PlaySceneSequence(play); - func_800FEAF4(&play->envCtx); - this->actionFunc = func_80A42AB8; + Environment_NewDay(&play->envCtx); + this->actionFunc = EnTest4_HandleEvents; } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { - this->actionFunc = func_80A42F20; - sCurCsId = sCsIdList[this->csIdIndex]; + // No scripted cutscene + if ((sCsIdList[this->daytimeIndex] > CS_ID_NONE) && !(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { + // Day-Night transition cutscene + this->actionFunc = EnTest4_HandleCutscene; + sCurCsId = sCsIdList[this->daytimeIndex]; this->transitionCsTimer = 0; SET_EVENTINF(EVENTINF_17); - } else if (this->csIdIndex == 0) { + } else if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { + // Previously night, turning day, without cutscene Audio_PlaySfx(NA_SE_EV_CHICKEN_CRY_M); } else { + // Previously day, turning night, without cutscene Audio_PlaySfx_2(NA_SE_EV_DOG_CRY_EVENING); } } else { - this->actionFunc = func_80A42AB8; - if (this->csIdIndex == 0) { - this->csIdIndex = 1; + // In a scripted cutscene + this->actionFunc = EnTest4_HandleEvents; + if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { + this->daytimeIndex = THREEDAY_DAYTIME_DAY; } else { - this->csIdIndex = 0; + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; } - this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->prevTime = CURRENT_TIME; } } -// Bells on last day -void func_80A42198(EnTest4* this) { - if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { - if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { +/** + * Get the next bell time on Day 3 + */ +void EnTest4_GetBellTimeOnDay3(EnTest4* this) { + if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME <= CLOCK_TIME(18, 0))) { + if (CURRENT_TIME < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(0, 0); } - } else if (gSaveContext.save.time > CLOCK_TIME(6, 0)) { + } else if (CURRENT_TIME > CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(0, 0); - } else if (gSaveContext.save.time < CLOCK_TIME(0, 10)) { + } else if (CURRENT_TIME < CLOCK_TIME(0, 10)) { this->nextBellTime = CLOCK_TIME(0, 10); - } else if (gSaveContext.save.time < CLOCK_TIME(0, 20)) { + } else if (CURRENT_TIME < CLOCK_TIME(0, 20)) { this->nextBellTime = CLOCK_TIME(0, 20); - } else if (gSaveContext.save.time < CLOCK_TIME(0, 30)) { + } else if (CURRENT_TIME < CLOCK_TIME(0, 30)) { this->nextBellTime = CLOCK_TIME(0, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(0, 40)) { + } else if (CURRENT_TIME < CLOCK_TIME(0, 40)) { this->nextBellTime = CLOCK_TIME(0, 40); - } else if (gSaveContext.save.time < CLOCK_TIME(0, 50)) { + } else if (CURRENT_TIME < CLOCK_TIME(0, 50)) { this->nextBellTime = CLOCK_TIME(0, 50); - } else if (gSaveContext.save.time < CLOCK_TIME(1, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(1, 0)) { this->nextBellTime = CLOCK_TIME(1, 0); - } else if (gSaveContext.save.time < CLOCK_TIME(1, 10)) { + } else if (CURRENT_TIME < CLOCK_TIME(1, 10)) { this->nextBellTime = CLOCK_TIME(1, 10); - } else if (gSaveContext.save.time < CLOCK_TIME(1, 20)) { + } else if (CURRENT_TIME < CLOCK_TIME(1, 20)) { this->nextBellTime = CLOCK_TIME(1, 20); - } else if (gSaveContext.save.time < CLOCK_TIME(1, 30) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(1, 30) - 1) { this->nextBellTime = CLOCK_TIME(1, 30) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(1, 40) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(1, 40) - 1) { this->nextBellTime = CLOCK_TIME(1, 40) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(1, 50) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(1, 50) - 1) { this->nextBellTime = CLOCK_TIME(1, 50) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(2, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(2, 0)) { this->nextBellTime = CLOCK_TIME(2, 0); - } else if (gSaveContext.save.time < CLOCK_TIME(2, 10)) { + } else if (CURRENT_TIME < CLOCK_TIME(2, 10)) { this->nextBellTime = CLOCK_TIME(2, 10); - } else if (gSaveContext.save.time < CLOCK_TIME(2, 20)) { + } else if (CURRENT_TIME < CLOCK_TIME(2, 20)) { this->nextBellTime = CLOCK_TIME(2, 20); - } else if (gSaveContext.save.time < CLOCK_TIME(2, 30)) { + } else if (CURRENT_TIME < CLOCK_TIME(2, 30)) { this->nextBellTime = CLOCK_TIME(2, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(2, 40)) { + } else if (CURRENT_TIME < CLOCK_TIME(2, 40)) { this->nextBellTime = CLOCK_TIME(2, 40); - } else if (gSaveContext.save.time < CLOCK_TIME(2, 50)) { + } else if (CURRENT_TIME < CLOCK_TIME(2, 50)) { this->nextBellTime = CLOCK_TIME(2, 50); - } else if (gSaveContext.save.time < CLOCK_TIME(3, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(3, 0)) { this->nextBellTime = CLOCK_TIME(3, 0); - } else if (gSaveContext.save.time < CLOCK_TIME(3, 10)) { + } else if (CURRENT_TIME < CLOCK_TIME(3, 10)) { this->nextBellTime = CLOCK_TIME(3, 10); - } else if (gSaveContext.save.time < CLOCK_TIME(3, 20)) { + } else if (CURRENT_TIME < CLOCK_TIME(3, 20)) { this->nextBellTime = CLOCK_TIME(3, 20); - } else if (gSaveContext.save.time < CLOCK_TIME(3, 30)) { + } else if (CURRENT_TIME < CLOCK_TIME(3, 30)) { this->nextBellTime = CLOCK_TIME(3, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(3, 40)) { + } else if (CURRENT_TIME < CLOCK_TIME(3, 40)) { this->nextBellTime = CLOCK_TIME(3, 40); - } else if (gSaveContext.save.time < CLOCK_TIME(3, 50)) { + } else if (CURRENT_TIME < CLOCK_TIME(3, 50)) { this->nextBellTime = CLOCK_TIME(3, 50); - } else if (gSaveContext.save.time < CLOCK_TIME(4, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(4, 0)) { this->nextBellTime = CLOCK_TIME(4, 0); - } else if (gSaveContext.save.time < CLOCK_TIME(4, 10)) { + } else if (CURRENT_TIME < CLOCK_TIME(4, 10)) { this->nextBellTime = CLOCK_TIME(4, 10); - } else if (gSaveContext.save.time < CLOCK_TIME(4, 20)) { + } else if (CURRENT_TIME < CLOCK_TIME(4, 20)) { this->nextBellTime = CLOCK_TIME(4, 20); - } else if (gSaveContext.save.time < CLOCK_TIME(4, 30) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(4, 30) - 1) { this->nextBellTime = CLOCK_TIME(4, 30) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(4, 40) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(4, 40) - 1) { this->nextBellTime = CLOCK_TIME(4, 40) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(4, 50) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(4, 50) - 1) { this->nextBellTime = CLOCK_TIME(4, 50) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 0)) { this->nextBellTime = CLOCK_TIME(5, 0); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 5)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 5)) { this->nextBellTime = CLOCK_TIME(5, 5); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 10)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 10)) { this->nextBellTime = CLOCK_TIME(5, 10); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 15) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 15) - 1) { this->nextBellTime = CLOCK_TIME(5, 15) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 20)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 20)) { this->nextBellTime = CLOCK_TIME(5, 20); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 25) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 25) - 1) { this->nextBellTime = CLOCK_TIME(5, 25) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 33) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 33) - 1) { this->nextBellTime = CLOCK_TIME(5, 33) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 39) - 1) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 39) - 1) { this->nextBellTime = CLOCK_TIME(5, 39) - 1; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 45)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 45)) { this->nextBellTime = CLOCK_TIME(5, 45); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 51)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 51)) { this->nextBellTime = CLOCK_TIME(5, 51); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 57)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 57)) { this->nextBellTime = CLOCK_TIME(5, 57); - } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(6, 0); } } -// Bells on first and second day -void func_80A425E4(EnTest4* this, PlayState* play) { +/** + * Get the next bell time and shrinks screen near the end of the day on days 1 and 2 + */ +void EnTest4_GetBellTimeAndShrinkScreenBeforeDay3(EnTest4* this, PlayState* play) { gSaveContext.screenScale = 1000.0f; - if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { - if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { + if ((CURRENT_TIME >= CLOCK_TIME(6, 0)) && (CURRENT_TIME < CLOCK_TIME(18, 0))) { + if (CURRENT_TIME < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { + } else if (CURRENT_TIME < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(5, 30); } } else { - if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { + if (CURRENT_TIME < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); gSaveContext.screenScale -= 50.0f; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); gSaveContext.screenScale -= 100.0f; - } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { + } else if (CURRENT_TIME < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); gSaveContext.screenScale -= 150.0f; - } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { + } else if (CURRENT_TIME < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(17, 30); gSaveContext.screenScale -= 200.0f; } else { this->nextBellTime = CLOCK_TIME(17, 30); } - if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1) || (CURRENT_DAY == 3) || - (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { + if ((sCsIdList[this->daytimeIndex] <= CS_ID_NONE) || (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) || + (CURRENT_DAY == 3) || (CURRENT_TIME >= CLOCK_TIME(17, 0))) { gSaveContext.screenScale = 1000.0f; } if (gSaveContext.screenScale != 1000.0f) { @@ -289,20 +322,20 @@ void func_80A425E4(EnTest4* this, PlayState* play) { } void EnTest4_Init(Actor* thisx, PlayState* play) { - s32 dayTemp; + s32 eventDayCount; EnTest4* this = THIS; Player* player = GET_PLAYER(play); s8 csId = this->actor.csId; - sCsIdList[0] = csId; - if (csId >= 0) { - ActorCutscene* csEntry = CutsceneManager_GetCutsceneEntry(sCsIdList[0]); + sCsIdList[THREEDAY_DAYTIME_NIGHT] = csId; + if (csId > CS_ID_NONE) { + ActorCutscene* csEntry = CutsceneManager_GetCutsceneEntry(sCsIdList[THREEDAY_DAYTIME_NIGHT]); - SET_EVENTINF(EVENTINF_52); - sCsIdList[1] = csEntry->additionalCsId; + SET_EVENTINF(EVENTINF_HAS_DAYTIME_TRANSITION_CS); + sCsIdList[THREEDAY_DAYTIME_DAY] = csEntry->additionalCsId; } else { - CLEAR_EVENTINF(EVENTINF_52); - sCsIdList[1] = sCsIdList[0]; + CLEAR_EVENTINF(EVENTINF_HAS_DAYTIME_TRANSITION_CS); + sCsIdList[THREEDAY_DAYTIME_DAY] = sCsIdList[THREEDAY_DAYTIME_NIGHT]; } if (sIsLoaded || CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) { @@ -312,49 +345,51 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { this->actor.room = -1; gSaveContext.screenScaleFlag = false; gSaveContext.screenScale = 1000.0f; + if (CURRENT_DAY == 0) { - if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { + if (CURRENT_TIME < CLOCK_TIME(6, 1)) { gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = GAMEMODE_NORMAL; STOP_GAMESTATE(&play->state); SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); - this->csIdIndex = 1; + this->daytimeIndex = THREEDAY_DAYTIME_DAY; gSaveContext.save.time = CLOCK_TIME(6, 0); Actor_Kill(&this->actor); } else { gSaveContext.save.day = 1; - dayTemp = gSaveContext.save.day; - gSaveContext.save.eventDayCount = dayTemp; - this->csIdIndex = 1; - this->unk_146 = gSaveContext.save.time; - this->actionFunc = func_80A42AB8; + eventDayCount = gSaveContext.save.day; + gSaveContext.save.eventDayCount = eventDayCount; + this->daytimeIndex = THREEDAY_DAYTIME_DAY; + this->prevTime = CURRENT_TIME; + this->actionFunc = EnTest4_HandleEvents; } - } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { - this->csIdIndex = 0; - func_80A41D70(this, play); - if ((gSaveContext.cutsceneTrigger == 0) && (sCsIdList[this->csIdIndex] >= 0) && - !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + } else if (CURRENT_TIME == CLOCK_TIME(6, 0)) { + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; + EnTest4_HandleDayNightSwapFromInit(this, play); + if ((gSaveContext.cutsceneTrigger == 0) && (sCsIdList[this->daytimeIndex] > CS_ID_NONE) && + !(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { player->stateFlags1 |= PLAYER_STATE1_200; } } else { - if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { - this->csIdIndex = 0; + if ((CURRENT_TIME > CLOCK_TIME(18, 0)) || (CURRENT_TIME < CLOCK_TIME(6, 0))) { + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; } else { - this->csIdIndex = 1; + this->daytimeIndex = THREEDAY_DAYTIME_DAY; } - this->unk_146 = gSaveContext.save.time; - this->actionFunc = func_80A42AB8; + this->prevTime = CURRENT_TIME; + this->actionFunc = EnTest4_HandleEvents; } } if (CURRENT_DAY == 3) { - func_80A42198(this); + EnTest4_GetBellTimeOnDay3(this); } else { - func_80A425E4(this, play); + EnTest4_GetBellTimeAndShrinkScreenBeforeDay3(this, play); } - this->lastBellTime = gSaveContext.save.time; - if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + this->prevBellTime = CURRENT_TIME; + + if ((sCsIdList[this->daytimeIndex] <= CS_ID_NONE) || (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { gSaveContext.screenScaleFlag = false; gSaveContext.screenScale = 1000.0f; } @@ -363,39 +398,60 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { void EnTest4_Destroy(Actor* thisx, PlayState* play) { } -void func_80A42AB8(EnTest4* this, PlayState* play) { +/** + * This function checks for two-specific time-based events: + * 1) The day-night transitions + * 2) The play bells sfx event, which contains screen shrinking and the clocktown day 3 midnight cutscene trigger + */ +void EnTest4_HandleEvents(EnTest4* this, PlayState* play) { + static u16 sDayNightTransitionTimes[THREEDAY_DAYTIME_MAX] = { + CLOCK_TIME(6, 0), // THREEDAY_DAYTIME_NIGHT + CLOCK_TIME(18, 0), // THREEDAY_DAYTIME_DAY + }; Player* player = GET_PLAYER(play); if ((play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (play->numSetupActors <= 0) && (play->roomCtx.status == 0) && !Play_IsDebugCamEnabled()) { - s16 temp_a2; - u16 temp_a0 = D_80A43364[this->csIdIndex]; - s16 temp_a3; - s16 bellDiff; - s16 new_var; + u16 transitionTime = sDayNightTransitionTimes[this->daytimeIndex]; + s16 curTimeUntilTransition; + s16 prevTimeUntilTransition; + s16 prevTimeUntilBell; + s16 curTimeUntilBell; - temp_a3 = gSaveContext.save.time - temp_a0; - temp_a2 = this->unk_146 - temp_a0; - bellDiff = this->lastBellTime - this->nextBellTime; - new_var = gSaveContext.save.time - this->nextBellTime; + curTimeUntilTransition = CURRENT_TIME - transitionTime; + prevTimeUntilTransition = this->prevTime - transitionTime; - if ((temp_a3 * temp_a2) <= 0) { + prevTimeUntilBell = this->prevBellTime - this->nextBellTime; + curTimeUntilBell = CURRENT_TIME - this->nextBellTime; + + // When the day-night transition time is passed: + // `curTimeUntilTransition` will be slightly positive (ahead transition time) + // `prevTimeUntilTransition` will be slightly negative (behind transition time) + // Only when the signs are different will this condition pass + if ((curTimeUntilTransition * prevTimeUntilTransition) <= 0) { + // day-night transition is occuring gSaveContext.unk_3CA7 = 1; if (play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON) { play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; } - if (temp_a0 != CLOCK_TIME(6, 0)) { - func_80A41FA4(this, play); - } else if (temp_a0 == CLOCK_TIME(6, 0)) { + if (transitionTime != CLOCK_TIME(6, 0)) { + // previously day, turning night + EnTest4_HandleDayNightSwap(this, play); + } else if (transitionTime == CLOCK_TIME(6, 0)) { + // previously night, turning day if (CURRENT_DAY == 3) { + // Turn day with mooncrash Interface_StartMoonCrash(play); Actor_Kill(&this->actor); SET_EVENTINF(EVENTINF_17); - } else if (((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) && + } else if (((sCsIdList[this->daytimeIndex] <= CS_ID_NONE) || + (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) && (CURRENT_DAY != 3)) { - func_80A41FA4(this, play); + // Turn day without cutscene + EnTest4_HandleDayNightSwap(this, play); } else { + // Turn day with DayTelop cutscene gSaveContext.screenScale = 0.0f; Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, Entrance_CreateFromSpawn(0), player->unk_3CE, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0, player->unk_3CC); @@ -418,34 +474,44 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { } } - if ((sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((sCsIdList[this->daytimeIndex] > CS_ID_NONE) && !(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { player->stateFlags1 |= PLAYER_STATE1_200; - this->unk_146 = gSaveContext.save.time; + this->prevTime = CURRENT_TIME; } else { - if (this->csIdIndex == 0) { - this->csIdIndex = 1; + if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { + this->daytimeIndex = THREEDAY_DAYTIME_DAY; } else { - this->csIdIndex = 0; + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; } - this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->prevTime = CURRENT_TIME; } - } else if ((new_var * bellDiff) <= 0) { - Audio_PlaySfx_BigBells(&this->actor.projectedPos, TEST4_GET_BIG_BELLS_SFX_VOLUME_INDEX(&this->actor)); - this->lastBellTime = gSaveContext.save.time; + return; + } + + // When the bell sfx time is passed: + // `curTimeUntilBell` will be slightly positive (ahead bell time) + // `prevTimeUntilBell` will be slightly negative (behind bell time) + // Only when the signs are different will this condition pass + if ((curTimeUntilBell * prevTimeUntilBell) <= 0) { + Audio_PlaySfx_BigBells(&this->actor.projectedPos, THREEDAY_GET_BIG_BELLS_SFX_VOLUME_INDEX(&this->actor)); + this->prevBellTime = CURRENT_TIME; if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (play->sceneId == SCENE_CLOCKTOWER))) { + // Initiate Clocktown day 3 midnight festival cutscene s32 playerParams; u32 entrance = gSaveContext.save.entrance; - if ((play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) { playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE); } else { playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B); } + Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, entrance, player->unk_3CE, playerParams, &player->unk_3C0, player->unk_3CC); @@ -460,17 +526,17 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_200; Actor_Kill(&this->actor); } - func_80A42198(this); + EnTest4_GetBellTimeOnDay3(this); } else { - func_80A425E4(this, play); + EnTest4_GetBellTimeAndShrinkScreenBeforeDay3(this, play); } } } } -void func_80A42F20(EnTest4* this, PlayState* play) { +void EnTest4_HandleCutscene(EnTest4* this, PlayState* play) { if (!this->transitionCsTimer) { - if (sCurCsId >= 0) { + if (sCurCsId > CS_ID_NONE) { if (!CutsceneManager_IsNext(sCurCsId)) { CutsceneManager_Queue(sCurCsId); } else { @@ -483,7 +549,7 @@ void func_80A42F20(EnTest4* this, PlayState* play) { } else if (this->transitionCsTimer < 60) { this->transitionCsTimer++; if (this->transitionCsTimer == 10) { - if (this->csIdIndex == 0) { + if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { Audio_PlaySfx(NA_SE_EV_CHICKEN_CRY_M); } else { Audio_PlaySfx_2(NA_SE_EV_DOG_CRY_EVENING); @@ -493,19 +559,19 @@ void func_80A42F20(EnTest4* this, PlayState* play) { Player* player = GET_PLAYER(play); gSaveContext.save.time += CLOCK_TIME_MINUTE; - this->unk_146 = gSaveContext.save.time; + this->prevTime = CURRENT_TIME; play->numSetupActors = -play->numSetupActors; player->stateFlags1 &= ~PLAYER_STATE1_200; } } else { - this->actionFunc = func_80A42AB8; - if (this->csIdIndex == 0) { - this->csIdIndex = 1; + this->actionFunc = EnTest4_HandleEvents; + if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) { + this->daytimeIndex = THREEDAY_DAYTIME_DAY; } else { - this->csIdIndex = 0; + this->daytimeIndex = THREEDAY_DAYTIME_NIGHT; } - if (sCurCsId >= 0) { + if (sCurCsId > CS_ID_NONE) { CutsceneManager_Stop(sCurCsId); } @@ -515,33 +581,27 @@ void func_80A42F20(EnTest4* this, PlayState* play) { } } -void func_80A430C8(EnTest4* this, PlayState* play) { - if ((CURRENT_DAY == 2) && (gSaveContext.save.time >= CLOCK_TIME(7, 0)) && - (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (play->envCtx.precipitation[PRECIP_SNOW_CUR] == 0)) { - // rain? - - gWeatherMode = WEATHER_MODE_1; +void EnTest4_UpdateWeatherClear(EnTest4* this, PlayState* play) { + if ((CURRENT_DAY == 2) && (CURRENT_TIME >= CLOCK_TIME(7, 0)) && (CURRENT_TIME < CLOCK_TIME(17, 30)) && + (play->envCtx.precipitation[PRECIP_SNOW_CUR] == 0)) { + gWeatherMode = WEATHER_MODE_RAIN; Environment_PlayStormNatureAmbience(play); play->envCtx.lightningState = LIGHTNING_ON; play->envCtx.precipitation[PRECIP_RAIN_MAX] = 60; - } else { - if (play->envCtx.precipitation[PRECIP_RAIN_MAX] != 0) { - if ((play->state.frames % 4) == 0) { - play->envCtx.precipitation[PRECIP_RAIN_MAX]--; - if ((play->envCtx.precipitation[PRECIP_RAIN_MAX]) == 8) { - Environment_StopStormNatureAmbience(play); - } - } + } else if ((play->envCtx.precipitation[PRECIP_RAIN_MAX] != 0) && ((play->state.frames % 4) == 0)) { + play->envCtx.precipitation[PRECIP_RAIN_MAX]--; + if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 8) { + Environment_StopStormNatureAmbience(play); } } - if (gWeatherMode == WEATHER_MODE_1) { - this->state = TEST4_STATE_1; + if (gWeatherMode == WEATHER_MODE_RAIN) { + this->weather = THREEDAY_WEATHER_RAIN; } } -void func_80A431C8(EnTest4* this, PlayState* play) { - if (((gSaveContext.save.time >= CLOCK_TIME(17, 30)) && (gSaveContext.save.time < CLOCK_TIME(23, 0)) && +void EnTest4_UpdateWeatherRainy(EnTest4* this, PlayState* play) { + if (((CURRENT_TIME >= CLOCK_TIME(17, 30)) && (CURRENT_TIME < CLOCK_TIME(23, 0)) && (play->envCtx.precipitation[PRECIP_RAIN_MAX] != 0)) || (play->envCtx.precipitation[PRECIP_SNOW_CUR] != 0)) { gWeatherMode = WEATHER_MODE_CLEAR; @@ -549,12 +609,12 @@ void func_80A431C8(EnTest4* this, PlayState* play) { } if (gWeatherMode == WEATHER_MODE_CLEAR) { - this->state = TEST4_STATE_0; + this->weather = THREEDAY_WEATHER_CLEAR; } } void EnTest4_SetSkyboxNumStars(EnTest4* this, PlayState* play) { - s32 numStars = TEST4_GET_SKYBOX_NUM_STARS(&this->actor); + s32 numStars = THREEDAY_GET_SKYBOX_NUM_STARS(&this->actor); if (numStars > 0) { gSkyboxNumStars = numStars; @@ -565,19 +625,26 @@ void EnTest4_Update(Actor* thisx, PlayState* play) { EnTest4* this = THIS; Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & PLAYER_STATE1_2)) { - this->actionFunc(this, play); - - if (Environment_GetStormState(play) != STORM_STATE_OFF) { - switch (this->state) { - case TEST4_STATE_0: - func_80A430C8(this, play); - break; - case TEST4_STATE_1: - func_80A431C8(this, play); - break; - } - } - EnTest4_SetSkyboxNumStars(this, play); + if (player->stateFlags1 & PLAYER_STATE1_2) { + return; } + + this->actionFunc(this, play); + + if (Environment_GetStormState(play) != STORM_STATE_OFF) { + switch (this->weather) { + case THREEDAY_WEATHER_CLEAR: + EnTest4_UpdateWeatherClear(this, play); + break; + + case THREEDAY_WEATHER_RAIN: + EnTest4_UpdateWeatherRainy(this, play); + break; + + default: + break; + } + } + + EnTest4_SetSkyboxNumStars(this, play); } diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.h b/src/overlays/actors/ovl_En_Test4/z_en_test4.h index 2d6e5a6ff7..d83c7634f2 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.h +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.h @@ -5,25 +5,31 @@ struct EnTest4; -#define TEST4_GET_SKYBOX_NUM_STARS(thisx) (((thisx)->params >> 10) * 100) -#define TEST4_GET_BIG_BELLS_SFX_VOLUME_INDEX(thisx) (((thisx)->params >> 5) & 0xF) +#define THREEDAY_GET_SKYBOX_NUM_STARS(thisx) (((thisx)->params >> 10) * 100) +#define THREEDAY_GET_BIG_BELLS_SFX_VOLUME_INDEX(thisx) (((thisx)->params >> 5) & 0xF) typedef void (*EnTest4ActionFunc)(struct EnTest4*, PlayState*); +typedef enum ThreeDayDaytime { + /* 0 */ THREEDAY_DAYTIME_NIGHT, + /* 1 */ THREEDAY_DAYTIME_DAY, + /* 2 */ THREEDAY_DAYTIME_MAX +} ThreeDayDaytime; + typedef struct EnTest4 { /* 0x000 */ Actor actor; - /* 0x144 */ s8 csIdIndex; // 0 on night, 1 on day + /* 0x144 */ s8 daytimeIndex; // See `ThreeDayDaytime` /* 0x145 */ u8 transitionCsTimer; - /* 0x146 */ u16 unk_146; + /* 0x146 */ u16 prevTime; /* 0x148 */ u16 nextBellTime; // Next time the bell will sound - /* 0x14A */ u16 lastBellTime; // Last time the bell sounded - /* 0x14C */ u8 state; + /* 0x14A */ u16 prevBellTime; // Last time the bell sounded + /* 0x14C */ u8 weather; // See `ThreeDayWeather` /* 0x150 */ EnTest4ActionFunc actionFunc; } EnTest4; // size = 0x154 -typedef enum { - /* 0 */ TEST4_STATE_0, - /* 1 */ TEST4_STATE_1 -} EnTest4State; +typedef enum ThreeDayWeather { + /* 0 */ THREEDAY_WEATHER_CLEAR, + /* 1 */ THREEDAY_WEATHER_RAIN +} ThreeDayWeather; #endif // Z_EN_TEST4_H diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 3601bb9e02..dc6e837d04 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -822,7 +822,7 @@ void EnTest6_DoubleSoTCutscene(EnTest6* this, PlayState* play) { case 1: EnTest6_DisableMotionBlur(); - if (CHECK_EVENTINF(EVENTINF_52)) { + if (CHECK_EVENTINF(EVENTINF_HAS_DAYTIME_TRANSITION_CS)) { this->cueId = SOTCS_CUEID_DOUBLE_END; } break; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 37f80d372c..513a57d2ea 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -359,7 +359,7 @@ void func_80966FEC(EnWeatherTag* this, PlayState* play) { gSkyboxNumStars = numStars; } - if ((play->sceneId == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((play->sceneId == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) { EnWeatherTag_SetupAction(this, func_80967060); } } @@ -459,7 +459,7 @@ void func_809674C8(EnWeatherTag* this, PlayState* play) { if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (play->envCtx.precipitation[PRECIP_SNOW_CUR] == 0)) { - gWeatherMode = WEATHER_MODE_1; + gWeatherMode = WEATHER_MODE_RAIN; Environment_PlayStormNatureAmbience(play); play->envCtx.precipitation[PRECIP_SOS_MAX] = 32; EnWeatherTag_SetupAction(this, func_80967608); @@ -488,7 +488,7 @@ void EnWeatherTag_Update(Actor* thisx, PlayState* play) { EnWeatherTag* this = THIS; this->actionFunc(this, play); - if ((play->actorCtx.flags & ACTORCTX_FLAG_1) && (play->msgCtx.msgMode != MSGMODE_NONE) && + if ((play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) && (play->msgCtx.msgMode != MSGMODE_NONE) && (play->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&play->state) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (play->csCtx.state == CS_STATE_IDLE)) { 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 07a75650b2..4681bd07a7 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -700,7 +700,7 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, PlayState* play) { this->clockTime += 3; this->actor.draw = ObjTokeidai_Clock_Draw; } else { - if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + if (!(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) && (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE)) { this->actor.draw = NULL; @@ -733,7 +733,7 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, PlayState* play) { this->clockTime += 3; this->actor.draw = ObjTokeidai_ExteriorGear_Draw; } else { - if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + if (!(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON) && (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE)) { this->actor.draw = NULL; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 40790fe654..1a1983b864 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -8291,7 +8291,7 @@ void Player_InitMode_Telescope(PlayState* play, Player* this) { this->actor.focus.rot.y = 0x2102; this->av2.actionVar2 = 20; } - play->actorCtx.flags |= ACTORCTX_FLAG_1; + play->actorCtx.flags |= ACTORCTX_FLAG_TELESCOPE_ON; } void Player_InitMode_B(PlayState* play, Player* this) { diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index fa1edaf6bc..4f736a3178 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -2489,7 +2489,7 @@ void FileSelect_InitContext(GameState* thisx) { envCtx->lightConfig = 0; envCtx->changeLightNextConfig = 0; envCtx->lightSetting = 0; - envCtx->skyboxConfig = 2; + envCtx->skyboxConfig = SKYBOX_CONFIG_2; envCtx->skyboxDisabled = 0; envCtx->skyboxBlend = 0; envCtx->glareAlpha = 0.0f; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 96f0784a01..36f6b0a598 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1786,7 +1786,7 @@ 0x800FEA50:("func_800FEA50",), 0x800FEAB0:("func_800FEAB0",), 0x800FEAC0:("Environment_JumpForwardInTime",), - 0x800FEAF4:("func_800FEAF4",), + 0x800FEAF4:("Environment_NewDay",), 0x800FEC90:("Lib_MemCpy",), 0x800FECC0:("Lib_MemSet",), 0x800FED44:("Math_CosS",), @@ -10402,16 +10402,16 @@ 0x80A40CF0:("func_80A40CF0",), 0x80A40F34:("func_80A40F34",), 0x80A4129C:("func_80A4129C",), - 0x80A41D70:("func_80A41D70",), - 0x80A41FA4:("func_80A41FA4",), - 0x80A42198:("func_80A42198",), - 0x80A425E4:("func_80A425E4",), + 0x80A41D70:("EnTest4_HandleDayNightSwapFromInit",), + 0x80A41FA4:("EnTest4_HandleDayNightSwap",), + 0x80A42198:("EnTest4_GetBellTimeOnDay3",), + 0x80A425E4:("EnTest4_GetBellTimeAndShrinkScreenBeforeDay3",), 0x80A427E8:("EnTest4_Init",), 0x80A42AA8:("EnTest4_Destroy",), - 0x80A42AB8:("func_80A42AB8",), - 0x80A42F20:("func_80A42F20",), - 0x80A430C8:("func_80A430C8",), - 0x80A431C8:("func_80A431C8",), + 0x80A42AB8:("EnTest4_HandleEvents",), + 0x80A42F20:("EnTest4_HandleCutscene",), + 0x80A430C8:("EnTest4_UpdateWeatherClear",), + 0x80A431C8:("EnTest4_UpdateWeatherRainy",), 0x80A4323C:("EnTest4_SetSkyboxNumStars",), 0x80A43274:("EnTest4_Update",), 0x80A434E0:("EnBat_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index e9cffb7360..961b7c3fbf 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -3866,7 +3866,7 @@ 0x801F4E10:("sNextCutsceneList","u8","[16]",0x10), 0x801F4E20:("D_801F4E20","UNK_TYPE1","",0x1), 0x801F4E30:("D_801F4E30","UNK_TYPE1","",0x1), - 0x801F4E31:("D_801F4E31","UNK_TYPE1","",0x1), + 0x801F4E31:("sInitSkyboxConfig","UNK_TYPE1","",0x1), 0x801F4E32:("gCustomLensFlare1On","UNK_TYPE1","",0x1), 0x801F4E38:("gCustomLensFlare1Pos","UNK_TYPE1","",0x1), 0x801F4E3C:("D_801F4E3C","UNK_TYPE1","",0x1), @@ -11305,11 +11305,11 @@ 0x80A41D6C:("sKafeiCurBodyPartPos","UNK_TYPE1","",0x1), 0x80A43320:("En_Test4_InitVars","ActorInit","",0x20), 0x80A43340:("sIsLoaded","s32","[3]",0x6), - 0x80A43342:("sNightMessages1","s16","[3]",0x6), - 0x80A4334A:("sDayMessages1","s16","[3]",0x6), - 0x80A43352:("sNightMessages2","s16","[3]",0x6), - 0x80A4335A:("sDayMessages2","s16","[3]",0x6), - 0x80A43364:("D_80A43364","u16","[2]",0x4), + 0x80A43342:("sNightOfTextIds2","s16","[3]",0x6), + 0x80A4334A:("sDawnOfTextIds2","s16","[3]",0x6), + 0x80A43352:("sNightOfTextIds","s16","[3]",0x6), + 0x80A4335A:("sDawnOfTextIds","s16","[3]",0x6), + 0x80A43364:("sDayNightTransitionTimes","u16","[2]",0x4), 0x80A434D0:("sCsIdList","s16","[2]",0x4), 0x80A434D4:("sCurCsId","s16","",0x2), 0x80A449E0:("En_Bat_InitVars","ActorInit","",0x1), diff --git a/tools/namefixer.py b/tools/namefixer.py index a5e7c755c1..8384a8af38 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -1291,6 +1291,7 @@ wordReplace = { "RADF_TO_DEGF": "RAD_TO_DEG", "DEGF_TO_RADF": "DEG_TO_RAD", + "ACTORCTX_FLAG_1": "ACTORCTX_FLAG_TELESCOPE_ON", "ACTORCTX_FLAG_2": "ACTORCTX_FLAG_PICTO_BOX_ON", "ACTOR_FLAG_1": "ACTOR_FLAG_TARGETABLE", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 88e9931a60..b441b2f4c0 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1300,7 +1300,7 @@ asm/non_matchings/code/z_kankyo/func_800FE9B4.s,func_800FE9B4,0x800FE9B4,0x27 asm/non_matchings/code/z_kankyo/func_800FEA50.s,func_800FEA50,0x800FEA50,0x18 asm/non_matchings/code/z_kankyo/func_800FEAB0.s,func_800FEAB0,0x800FEAB0,0x4 asm/non_matchings/code/z_kankyo/Environment_JumpForwardInTime.s,Environment_JumpForwardInTime,0x800FEAC0,0xD -asm/non_matchings/code/z_kankyo/func_800FEAF4.s,func_800FEAF4,0x800FEAF4,0x67 +asm/non_matchings/code/z_kankyo/Environment_NewDay.s,Environment_NewDay,0x800FEAF4,0x67 asm/non_matchings/code/z_lib/Lib_MemCpy.s,Lib_MemCpy,0x800FEC90,0xC asm/non_matchings/code/z_lib/Lib_MemSet.s,Lib_MemSet,0x800FECC0,0x21 asm/non_matchings/code/z_lib/Math_CosS.s,Math_CosS,0x800FED44,0x10