Compare commits

..

2 Commits

Author SHA1 Message Date
danielryb
a6e69066b2 add toggle for double SoT 2024-06-19 23:58:43 +02:00
danielryb
2d0ce9f68d add better double SoT 2024-06-19 21:00:58 +02:00
12 changed files with 279 additions and 328 deletions

View File

@ -92,7 +92,7 @@
/> />
</div> </div>
</div> </div>
<!-- joystick deadzone --> <!-- joystick deadzone -->
<div class="config-option" data-event-mouseover="set_cur_config_index(4)"> <div class="config-option" data-event-mouseover="set_cur_config_index(4)">
<label class="config-option__title">Joystick Deadzone</label> <label class="config-option__title">Joystick Deadzone</label>
@ -171,7 +171,7 @@
<label class="config-option__tab-label" for="autosave_disabled">Off</label> <label class="config-option__tab-label" for="autosave_disabled">Off</label>
</div> </div>
</div> </div>
<!-- camera inversion --> <!-- camera inversion -->
<div class="config-option" data-event-mouseover="set_cur_config_index(7)"> <div class="config-option" data-event-mouseover="set_cur_config_index(7)">
<label class="config-option__title">Aiming Camera Mode</label> <label class="config-option__title">Aiming Camera Mode</label>
@ -225,7 +225,7 @@
<label class="config-option__tab-label" for="camera_inversion_both">Invert Both</label> <label class="config-option__tab-label" for="camera_inversion_both">Invert Both</label>
</div> </div>
</div> </div>
<!-- analog camera --> <!-- analog camera -->
<div class="config-option" data-event-mouseover="set_cur_config_index(8)"> <div class="config-option" data-event-mouseover="set_cur_config_index(8)">
<label class="config-option__title">Analog Camera</label> <label class="config-option__title">Analog Camera</label>
@ -255,7 +255,7 @@
<label class="config-option__tab-label" for="analog_cam_disabled">Off</label> <label class="config-option__tab-label" for="analog_cam_disabled">Off</label>
</div> </div>
</div> </div>
<!-- analog camera inversion --> <!-- analog camera inversion -->
<div class="config-option" data-event-mouseover="set_cur_config_index(9)"> <div class="config-option" data-event-mouseover="set_cur_config_index(9)">
<label class="config-option__title">Analog Camera Mode</label> <label class="config-option__title">Analog Camera Mode</label>
@ -268,7 +268,7 @@
data-checked="analog_camera_invert_mode" data-checked="analog_camera_invert_mode"
value="InvertNone" value="InvertNone"
id="analog_camera_inversion_none" id="analog_camera_inversion_none"
style="nav-up: #analog_cam_enabled;" style="nav-up: #analog_cam_enabled; nav-down: #dsot_enabled"
/> />
<label class="config-option__tab-label" for="analog_camera_inversion_none">None</label> <label class="config-option__tab-label" for="analog_camera_inversion_none">None</label>
@ -280,7 +280,7 @@
data-checked="analog_camera_invert_mode" data-checked="analog_camera_invert_mode"
value="InvertX" value="InvertX"
id="analog_camera_inversion_x" id="analog_camera_inversion_x"
style="nav-up: #analog_cam_disabled;" style="nav-up: #analog_cam_disabled; nav-down: #dsot_disabled"
/> />
<label class="config-option__tab-label" for="analog_camera_inversion_x">Invert X</label> <label class="config-option__tab-label" for="analog_camera_inversion_x">Invert X</label>
@ -292,7 +292,7 @@
data-checked="analog_camera_invert_mode" data-checked="analog_camera_invert_mode"
value="InvertY" value="InvertY"
id="analog_camera_inversion_y" id="analog_camera_inversion_y"
style="nav-up: #analog_cam_disabled;" style="nav-up: #analog_cam_disabled; nav-down: #dsot_disabled"
/> />
<label class="config-option__tab-label" for="analog_camera_inversion_y">Invert Y</label> <label class="config-option__tab-label" for="analog_camera_inversion_y">Invert Y</label>
@ -304,16 +304,45 @@
data-checked="analog_camera_invert_mode" data-checked="analog_camera_invert_mode"
value="InvertBoth" value="InvertBoth"
id="analog_camera_inversion_both" id="analog_camera_inversion_both"
style="nav-up: #analog_cam_disabled;" style="nav-up: #analog_cam_disabled; nav-down: #dsot_disabled"
/> />
<label class="config-option__tab-label" for="analog_camera_inversion_both">Invert Both</label> <label class="config-option__tab-label" for="analog_camera_inversion_both">Invert Both</label>
</div> </div>
</div> </div>
<!-- better double song of time -->
<div class="config-option" data-event-mouseover="set_cur_config_index(10)">
<label class="config-option__title">Better Double Song of Time</label>
<div class="config-option__list">
<input
type="radio"
data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(10)"
name="dsot_mode"
data-checked="dsot_mode"
value="On"
id="dsot_enabled"
style="nav-up: #analog_camera_inversion_none"
/>
<label class="config-option__tab-label" for="dsot_enabled">On</label>
<input
type="radio"
data-event-blur="set_cur_config_index(-1)"
data-event-focus="set_cur_config_index(10)"
name="dsot_mode"
data-checked="dsot_mode"
value="Off"
id="dsot_disabled"
style="nav-up: #analog_camera_inversion_x"
/>
<label class="config-option__tab-label" for="dsot_disabled">Off</label>
</div>
</div>
</div> </div>
<!-- Descriptions --> <!-- Descriptions -->
<div class="config__wrapper"> <div class="config__wrapper">
<p data-if="cur_config_index == 0"> <p data-if="cur_config_index == 0">
Controls how targeting enemies and objects works. <b>Switch</b> will start or stop targeting each time the target button is pressed. <b>Hold</b> will start when the target button is pressed and stop when the button is released. Controls how targeting enemies and objects works. <b>Switch</b> will start or stop targeting each time the target button is pressed. <b>Hold</b> will start when the target button is pressed and stop when the button is released.
</p> </p>
<p data-if="cur_config_index == 1"> <p data-if="cur_config_index == 1">
Controls the strength of rumble when using a controller that supports it. <b>Setting this to zero will disable rumble.</b> Controls the strength of rumble when using a controller that supports it. <b>Setting this to zero will disable rumble.</b>
@ -362,6 +391,12 @@
<p data-if="cur_config_index == 9"> <p data-if="cur_config_index == 9">
Inverts the camera controls for the analog camera if it's enabled. <b>None</b> is the default. Inverts the camera controls for the analog camera if it's enabled. <b>None</b> is the default.
</p> </p>
<p data-if="cur_config_index == 10">
Enables hour selection for Double Song of Time.
<br/>
<br/>
To select an hour move the left analog stick in horizontal axis.
</p>
</div> </div>
</div> </div>
</form> </form>

View File

@ -12,16 +12,16 @@ namespace zelda64 {
// TODO: Move loading configs to the runtime once we have a way to allow per-project customization. // TODO: Move loading configs to the runtime once we have a way to allow per-project customization.
void load_config(); void load_config();
void save_config(); void save_config();
void reset_input_bindings(); void reset_input_bindings();
void reset_cont_input_bindings(); void reset_cont_input_bindings();
void reset_kb_input_bindings(); void reset_kb_input_bindings();
std::filesystem::path get_app_folder_path(); std::filesystem::path get_app_folder_path();
bool get_debug_mode_enabled(); bool get_debug_mode_enabled();
void set_debug_mode_enabled(bool enabled); void set_debug_mode_enabled(bool enabled);
enum class AutosaveMode { enum class AutosaveMode {
On, On,
Off, Off,
@ -79,6 +79,17 @@ namespace zelda64 {
{zelda64::AnalogCamMode::Off, "Off"} {zelda64::AnalogCamMode::Off, "Off"}
}); });
enum class DsotMode {
On,
Off,
OptionCount
};
NLOHMANN_JSON_SERIALIZE_ENUM(zelda64::DsotMode, {
{zelda64::DsotMode::On, "On"},
{zelda64::DsotMode::Off, "Off"}
});
AutosaveMode get_autosave_mode(); AutosaveMode get_autosave_mode();
void set_autosave_mode(AutosaveMode mode); void set_autosave_mode(AutosaveMode mode);
@ -86,6 +97,9 @@ namespace zelda64 {
void set_analog_cam_mode(AnalogCamMode mode); void set_analog_cam_mode(AnalogCamMode mode);
void open_quit_game_prompt(); void open_quit_game_prompt();
DsotMode get_dsot_mode();
void set_dsot_mode(DsotMode mode);
}; };
#endif #endif

View File

@ -3,7 +3,16 @@
void dsot_load_day_number_texture(PlayState* play, s32 day); void dsot_load_day_number_texture(PlayState* play, s32 day);
void dsot_actor_fixes(PlayState* play); void dsot_actor_fixes(PlayState* play);
bool dsot_used = false; bool dsot_on;
void dsot_determine_enabled(void) {
dsot_on = recomp_dsot_enabled();
}
bool dsot_enabled(void) {
return dsot_on;
}
u8 choiceHour; u8 choiceHour;
void dsot_init_hour_selection(PlayState* play) { void dsot_init_hour_selection(PlayState* play) {
@ -99,7 +108,6 @@ void dsot_cancel_hour_selection(PlayState* play) {
void dsot_advance_hour(PlayState* play) { void dsot_advance_hour(PlayState* play) {
gSaveContext.save.time = CLOCK_TIME(choiceHour, 0); gSaveContext.save.time = CLOCK_TIME(choiceHour, 0);
gSaveContext.skyboxTime = CURRENT_TIME; gSaveContext.skyboxTime = CURRENT_TIME;
dsot_used = true;
// Instantly enable/disable rain on day 2. // Instantly enable/disable rain on day 2.
if ((CURRENT_DAY == 2) && (Environment_GetStormState(play) != STORM_STATE_OFF)) { if ((CURRENT_DAY == 2) && (Environment_GetStormState(play) != STORM_STATE_OFF)) {
@ -119,14 +127,16 @@ void dsot_advance_hour(PlayState* play) {
} }
// Play music/ambience. // Play music/ambience.
play->envCtx.timeSeqState = TIMESEQ_FADE_DAY_BGM;
if ((CURRENT_TIME >= CLOCK_TIME(18, 0)) || (CURRENT_TIME <= CLOCK_TIME(6,0))) { if ((CURRENT_TIME >= CLOCK_TIME(18, 0)) || (CURRENT_TIME <= CLOCK_TIME(6,0))) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0);
play->envCtx.timeSeqState = TIMESEQ_NIGHT_BEGIN_SFX;
} else if (CURRENT_TIME > CLOCK_TIME(17, 10)) { } else if (CURRENT_TIME > CLOCK_TIME(17, 10)) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 240); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 240);
play->envCtx.timeSeqState = TIMESEQ_NIGHT_BEGIN_SFX;
} }
play->envCtx.timeSeqState = TIMESEQ_NIGHT_BEGIN_SFX;
if ((CURRENT_TIME >= CLOCK_TIME(18, 0)) || (CURRENT_TIME <= CLOCK_TIME(6, 0))) { if ((CURRENT_TIME >= CLOCK_TIME(18, 0)) || (CURRENT_TIME <= CLOCK_TIME(6, 0))) {
Audio_PlayAmbience(play->sequenceCtx.ambienceId); Audio_PlayAmbience(play->sequenceCtx.ambienceId);
Audio_SetAmbienceChannelIO(AMBIENCE_CHANNEL_CRITTER_0, 1, 1); Audio_SetAmbienceChannelIO(AMBIENCE_CHANNEL_CRITTER_0, 1, 1);
@ -148,7 +158,7 @@ void dsot_advance_hour(PlayState* play) {
dsot_actor_fixes(play); dsot_actor_fixes(play);
} }
// Loads day number texture from week_static for the three-day clock // Loads day number texture from week_static for the three-day clock.
void dsot_load_day_number_texture(PlayState* play, s32 day) { void dsot_load_day_number_texture(PlayState* play, s32 day) {
s16 i = day - 1; s16 i = day - 1;
@ -164,7 +174,7 @@ void dsot_load_day_number_texture(PlayState* play, s32 day) {
void Interface_DrawClock(PlayState* play); void Interface_DrawClock(PlayState* play);
// Wrapper for Interface_DrawClock to display selected hour // Wrapper for Interface_DrawClock to display selected hour.
void dsot_draw_clock(PlayState* play) { void dsot_draw_clock(PlayState* play) {
MessageContext *msgCtx = &play->msgCtx; MessageContext *msgCtx = &play->msgCtx;
@ -205,13 +215,15 @@ void dsot_draw_clock(PlayState* play) {
} }
#include "overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h" #include "overlays/actors/ovl_En_Test4/z_en_test4.h"
#include "overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h" #include "overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h"
#include "overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h"
void dsot_ObjTokeidai_fix(ObjTokeidai* this, PlayState* play); void dsot_ObjEnTest4_fix(EnTest4* this, PlayState* play);
void dsot_ObjTokeiStep_fix(ObjTokeiStep* this, PlayState* play); void dsot_ObjTokeiStep_fix(ObjTokeiStep* this, PlayState* play);
void dsot_ObjTokeidai_fix(ObjTokeidai* this, PlayState* play);
// Calls actor specific fixes // Calls actor specific fixes.
void dsot_actor_fixes(PlayState* play) { void dsot_actor_fixes(PlayState* play) {
s32 category; s32 category;
Actor* actor; Actor* actor;
@ -226,35 +238,70 @@ void dsot_actor_fixes(PlayState* play) {
actor = entry->first; actor = entry->first;
for (actor = entry->first; actor != NULL; actor = actor->next) { for (actor = entry->first; actor != NULL; actor = actor->next) {
switch(actor->id) { switch(actor->id) {
case ACTOR_OBJ_TOKEIDAI: case ACTOR_EN_TEST4:
dsot_ObjTokeidai_fix(actor, play); dsot_ObjEnTest4_fix(actor, play);
break; break;
case ACTOR_OBJ_TOKEI_STEP: case ACTOR_OBJ_TOKEI_STEP:
dsot_ObjTokeiStep_fix(actor, play); dsot_ObjTokeiStep_fix(actor, play);
break; break;
case ACTOR_OBJ_TOKEIDAI:
dsot_ObjTokeidai_fix(actor, play);
break;
} }
} }
} }
} }
#define PAST_MIDNIGHT ((CURRENT_DAY == 3) && (CURRENT_TIME < CLOCK_TIME(6, 0)) && (CURRENT_TIME > CLOCK_TIME(0, 0)))
// z_obj_en_test_4
void func_80A42198(EnTest4* this); // EnTest4_GetBellTimeOnDay3
void dsot_ObjEnTest4_fix(EnTest4* this, PlayState* play) {
this->prevTime = CURRENT_TIME;
this->prevBellTime = CURRENT_TIME;
// Change daytime to night manually if necessary.
if ((this->daytimeIndex = THREEDAY_DAYTIME_DAY) && (CURRENT_TIME > CLOCK_TIME(18, 0)) || (CURRENT_TIME <= CLOCK_TIME(6, 0))) {
this->daytimeIndex = THREEDAY_DAYTIME_NIGHT;
// Re-spawn the setup actors.
play->numSetupActors = -play->numSetupActors;
}
// Setup next bell time.
if (CURRENT_DAY == 3) {
gSaveContext.save.time--;
func_80A42198(this);
gSaveContext.save.time++;
}
}
// z_obj_tokei_step
void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this);
void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this);
void ObjTokeiStep_DrawOpen(Actor* thisx, PlayState* play);
void dsot_ObjTokeiStep_fix(ObjTokeiStep* this, PlayState* play) {
if (PAST_MIDNIGHT) {
// @recomp Manual relocation, TODO remove when the recompiler handles this automatically.
this->dyna.actor.draw = actor_relocate(this, ObjTokeiStep_DrawOpen);
ObjTokeiStep_InitStepsOpen(this);
ObjTokeiStep_SetupDoNothingOpen(this);
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
}
}
// z_obj_tokeidai // z_obj_tokeidai
#define GET_CURRENT_CLOCK_HOUR(this) ((s32)TIME_TO_HOURS_F((this)->clockTime))
#define GET_CLOCK_FACE_ROTATION(currentClockHour) (TRUNCF_BINANG(currentClockHour * (0x10000 / 24.0f))) #define GET_CLOCK_FACE_ROTATION(currentClockHour) (TRUNCF_BINANG(currentClockHour * (0x10000 / 24.0f)))
#define GET_MINUTE_RING_OR_EXTERIOR_GEAR_ROTATION(currentClockMinute) \ #define GET_MINUTE_RING_OR_EXTERIOR_GEAR_ROTATION(currentClockMinute) \
(TRUNCF_BINANG(currentClockMinute * (0x10000 * 12.0f / 360))) (TRUNCF_BINANG(currentClockMinute * (0x10000 * 12.0f / 360)))
s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void); s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void);
void ObjTokeidai_SetupClockOrExteriorGear(ObjTokeidai* this);
void ObjTokeidai_Init(Actor* thisx, PlayState* play); void ObjTokeidai_Init(Actor* thisx, PlayState* play);
void ObjTokeidai_Draw(Actor* thisx, PlayState* play); void ObjTokeidai_Draw(Actor* thisx, PlayState* play);
void ObjTokeidai_Clock_Init(ObjTokeidai* this);
void ObjTokeidai_SetupTowerOpening(ObjTokeidai* this);
void ObjTokeidai_DoNothing(ObjTokeidai* this, PlayState* play);
void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx);
void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, PlayState* play);
void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, PlayState* play); void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, PlayState* play);
void ObjTokeidai_Clock_Draw(Actor* thisx, PlayState* play); void ObjTokeidai_Clock_Draw(Actor* thisx, PlayState* play);
@ -273,7 +320,7 @@ void dsot_ObjTokeidai_update_clock(ObjTokeidai* this, u16 currentHour, u16 curre
// @recomp Manual relocation, TODO remove when the recompiler handles this automatically. // @recomp Manual relocation, TODO remove when the recompiler handles this automatically.
this->clockTime = CURRENT_TIME; this->clockTime = CURRENT_TIME;
// Instantly switch to desired hour // Instantly switch to desired hour.
u16 clockHour = currentHour; u16 clockHour = currentHour;
if (currentMinute == 0) { if (currentMinute == 0) {
clockHour--; clockHour--;
@ -287,7 +334,7 @@ void dsot_ObjTokeidai_update_clock(ObjTokeidai* this, u16 currentHour, u16 curre
this->clockFaceAngularVelocity = 0; this->clockFaceAngularVelocity = 0;
this->clockFaceRotationTimer = 0; this->clockFaceRotationTimer = 0;
// Instantly switch to desired minute // Instantly switch to desired minute.
u16 clockMinute = currentMinute - 1; u16 clockMinute = currentMinute - 1;
if (clockMinute > 59) { if (clockMinute > 59) {
clockMinute = 59; clockMinute = 59;
@ -305,8 +352,6 @@ void dsot_ObjTokeidai_update_clock(ObjTokeidai* this, u16 currentHour, u16 curre
} }
} }
#define PAST_MIDNIGHT ((CURRENT_DAY == 3) && (CURRENT_TIME < CLOCK_TIME(6, 0)) && (CURRENT_TIME > CLOCK_TIME(0, 0)))
void dsot_ObjTokeidai_fix(ObjTokeidai* this, PlayState* play) { void dsot_ObjTokeidai_fix(ObjTokeidai* this, PlayState* play) {
s32 type = OBJ_TOKEIDAI_TYPE(&this->actor); s32 type = OBJ_TOKEIDAI_TYPE(&this->actor);
u16 currentHour = TIME_TO_HOURS_F(CURRENT_TIME); u16 currentHour = TIME_TO_HOURS_F(CURRENT_TIME);
@ -355,20 +400,4 @@ void dsot_ObjTokeidai_fix(ObjTokeidai* this, PlayState* play) {
dsot_ObjTokeidai_update_clock(this, currentHour, currentMinute); dsot_ObjTokeidai_update_clock(this, currentHour, currentMinute);
break; break;
} }
}
// z_obj_tokei_step
void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this);
void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this);
void ObjTokeiStep_DrawOpen(Actor* thisx, PlayState* play);
void dsot_ObjTokeiStep_fix(ObjTokeiStep* this, PlayState* play) {
if (PAST_MIDNIGHT) {
// @recomp Manual relocation, TODO remove when the recompiler handles this automatically.
this->dyna.actor.draw = actor_relocate(this, ObjTokeiStep_DrawOpen);
ObjTokeiStep_InitStepsOpen(this);
ObjTokeiStep_SetupDoNothingOpen(this);
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
}
} }

View File

@ -1,201 +1,5 @@
#include "patches.h" #include "patches.h"
#define PAST_MIDNIGHT CLOCK_TIME(0, 1)
#include "overlays/actors/ovl_En_Test4/z_en_test4.h"
#include "z64horse.h"
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
#define THIS ((EnTest4*)thisx)
static s16 sCsIdList[THREEDAY_DAYTIME_MAX];
void func_80A42AB8(EnTest4* this, PlayState* play); // EnTest4_HandleEvents
void func_80A42F20(EnTest4* this, PlayState* play); // EnTest4_HandleCutscene
static s16 sCurCsId;
void func_800FEAF4(EnvironmentContext* envCtx); // Environment_NewDay
void func_80A41FA4(EnTest4* this, PlayState* play); // EnTest4_HandleDayNightSwap
void func_80A42198(EnTest4* this); // EnTest4_GetBellTimeOnDay3
void func_80A425E4(EnTest4* this, PlayState* play); // EnTest4_GetBellTimeAndShrinkScreenBeforeDay3
// @recomp Patched to perform transitions when Double SoT is used.
/**
* 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 func_80A42AB8(EnTest4* this, PlayState* play) { // EnTest4_HandleEvents
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()) {
u16 transitionTime = sDayNightTransitionTimes[this->daytimeIndex];
s16 curTimeUntilTransition;
s16 prevTimeUntilTransition;
s16 prevTimeUntilBell;
s16 curTimeUntilBell;
curTimeUntilTransition = CURRENT_TIME - transitionTime;
prevTimeUntilTransition = this->prevTime - transitionTime;
prevTimeUntilBell = this->prevBellTime - this->nextBellTime;
curTimeUntilBell = CURRENT_TIME - this->nextBellTime;
extern bool dsot_used;
u8 current_hour = TIME_TO_HOURS_F(CURRENT_TIME);
// @recomp Check for unusual Double SoT time skips.
if (dsot_used) {
if ((this->daytimeIndex == THREEDAY_DAYTIME_DAY) && (CURRENT_TIME < this->prevTime)) {
if (CURRENT_TIME >= CLOCK_TIME(6, 0)) {
transitionTime = sDayNightTransitionTimes[0];
}
curTimeUntilTransition = 0;
}
if ((CURRENT_DAY == 3) && (current_hour == 0)) {
curTimeUntilBell = 0;
this->nextBellTime = CLOCK_TIME(0, 0);
}
}
// 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;
}
// @recomp Manual relocation, TODO remove when the recompiler handles this automatically.
s16* sCsIdList_reloc = (s16*)actor_relocate(&this->actor, &sCsIdList);
if (transitionTime != CLOCK_TIME(6, 0)) {
// previously day, turning night
// @recomp Skip night transition cutscene if Double SoT is used.
if ((!dsot_used) || (current_hour == 18)) {
func_80A41FA4(this, play);
} else {
this->daytimeIndex = THREEDAY_DAYTIME_NIGHT;
this->prevTime = CURRENT_TIME;
// Re-spawn the setup actors.
play->numSetupActors = -play->numSetupActors;
}
} 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_reloc[this->daytimeIndex] <= CS_ID_NONE) ||
(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) &&
(CURRENT_DAY != 3)) {
// Turn day without cutscene
func_80A41FA4(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);
func_80169EFC(&play->state);
if (player->stateFlags1 & PLAYER_STATE1_800000) {
EnHorse* rideActor = (EnHorse*)player->rideActor;
if ((rideActor->type == HORSE_TYPE_EPONA) || (rideActor->type == HORSE_TYPE_2)) {
if (CURRENT_DAY < 3) {
gHorseIsMounted = true;
} else {
gHorseIsMounted = false;
}
}
}
gSaveContext.respawnFlag = -4;
SET_EVENTINF(EVENTINF_TRIGGER_DAYTELOP);
Actor_Kill(&this->actor);
}
}
// @recomp Skip night transition cutscene if Double SoT is used.
if ((!dsot_used) || (transitionTime == CLOCK_TIME(6, 0))) {
if ((sCsIdList_reloc[this->daytimeIndex] > CS_ID_NONE) && !(play->actorCtx.flags & ACTORCTX_FLAG_TELESCOPE_ON)) {
player->stateFlags1 |= PLAYER_STATE1_200;
this->prevTime = CURRENT_TIME;
} else {
if (this->daytimeIndex == THREEDAY_DAYTIME_NIGHT) {
this->daytimeIndex = THREEDAY_DAYTIME_DAY;
} else {
this->daytimeIndex = THREEDAY_DAYTIME_NIGHT;
}
gSaveContext.save.time += CLOCK_TIME_MINUTE;
this->prevTime = CURRENT_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) {
// @recomp Don't initate cutscene if it's past midnight.
if ((this->nextBellTime == CLOCK_TIME(0, 0)) &&
(CURRENT_TIME < PAST_MIDNIGHT) &&
((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_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);
if ((play->sceneId == SCENE_TENMON_DAI) || (play->sceneId == SCENE_00KEIKOKU)) {
play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0);
} else {
play->nextEntrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0);
}
gSaveContext.nextCutsceneIndex = 0xFFF1;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_FADE_BLACK;
player->stateFlags1 |= PLAYER_STATE1_200;
Actor_Kill(&this->actor);
}
func_80A42198(this);
} else {
func_80A425E4(this, play);
}
}
dsot_used = false;
}
}
u8 func_800FE5D0(struct PlayState* play); u8 func_800FE5D0(struct PlayState* play);
void Environment_UpdateTimeBasedSequence(PlayState* play) { void Environment_UpdateTimeBasedSequence(PlayState* play) {
@ -262,19 +66,17 @@ void Environment_UpdateTimeBasedSequence(PlayState* play) {
} }
} }
// @recomp Don't play final hours until it's actually past midnight
if ((play->envCtx.timeSeqState != TIMESEQ_REQUEST) && (((void)0, gSaveContext.save.day) == 3) && if ((play->envCtx.timeSeqState != TIMESEQ_REQUEST) && (((void)0, gSaveContext.save.day) == 3) &&
(CURRENT_TIME < CLOCK_TIME(6, 0)) && !func_800FE5D0(play) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (CURRENT_TIME < CLOCK_TIME(6, 0)) && !func_800FE5D0(play) && (play->transitionTrigger == TRANS_TRIGGER_OFF) &&
(play->transitionMode == TRANS_MODE_OFF) && (play->csCtx.state == CS_STATE_IDLE) && (play->transitionMode == TRANS_MODE_OFF) && (play->csCtx.state == CS_STATE_IDLE) &&
((play->sceneId != SCENE_00KEIKOKU) || (((void)0, gSaveContext.sceneLayer) != 1)) && ((play->sceneId != SCENE_00KEIKOKU) || (((void)0, gSaveContext.sceneLayer) != 1)) &&
(CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS) && (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_SONG_OF_SOARING)) { (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_SONG_OF_SOARING) &&
// @recomp Don't play final hours until Double SoT finishes. (CURRENT_TIME > CLOCK_TIME(0, 0))) {
extern bool dsot_used; SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0);
if (!dsot_used) { Audio_PlaySceneSequence(NA_BGM_FINAL_HOURS, 3 - 1);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0);
Audio_PlaySceneSequence(NA_BGM_FINAL_HOURS, 3 - 1);
}
} }
} }
@ -536,8 +338,8 @@ void EnTest6_DoubleSoTCutscene(EnTest6* this, PlayState* play) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 20); SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 20);
} }
// @recomp Advance hour as Double SoT ends. // @recomp Replace DSoT functionality if the option for it is enabled.
if (this->timer == 15) { if (dsot_enabled() && this->timer == 15) {
dsot_advance_hour(play); dsot_advance_hour(play);
} }
@ -784,7 +586,18 @@ void EnTest6_SharedSoTCutscene(EnTest6* this, PlayState* play) {
return; return;
case SOTCS_CUEID_DOUBLE_END: case SOTCS_CUEID_DOUBLE_END:
// @recomp Disable scene reset after Double SoT ends. // @recomp Replace DSoT functionality if the option for it is enabled.
if (!dsot_enabled() && (CURRENT_TIME > CLOCK_TIME(12, 0))) {
Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, ((void)0, gSaveContext.save.entrance),
player->unk_3CE, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0,
player->unk_3CC);
this->drawType = SOTCS_DRAW_TYPE_NONE;
play->transitionTrigger = TRANS_TRIGGER_START;
play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance;
play->transitionType = TRANS_TYPE_FADE_BLACK;
gSaveContext.respawnFlag = 2;
play->msgCtx.ocarinaMode = OCARINA_MODE_END;
}
return; return;
} }
} }

View File

@ -452,23 +452,43 @@ void Message_Update(PlayState* play) {
} }
} else if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) && } else if ((msgCtx->textboxEndType == TEXTBOX_ENDTYPE_10) &&
(play->msgCtx.ocarinaMode == OCARINA_MODE_PROCESS_DOUBLE_TIME)) { (play->msgCtx.ocarinaMode == OCARINA_MODE_PROCESS_DOUBLE_TIME)) {
// @recomp // @recomp Replace DSoT functionality if the option for it is enabled.
dsot_handle_hour_selection(play); if (dsot_enabled()) {
// @recomp
dsot_handle_hour_selection(play);
if (Message_ShouldAdvance(play)) { if (Message_ShouldAdvance(play)) {
if (msgCtx->choiceIndex == 0) { if (msgCtx->choiceIndex == 0) {
Audio_PlaySfx_MessageDecide(); Audio_PlaySfx_MessageDecide();
play->msgCtx.ocarinaMode = OCARINA_MODE_APPLY_DOUBLE_SOT; play->msgCtx.ocarinaMode = OCARINA_MODE_APPLY_DOUBLE_SOT;
gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF;
} else { } else {
Audio_PlaySfx_MessageCancel(); Audio_PlaySfx_MessageCancel();
play->msgCtx.ocarinaMode = OCARINA_MODE_END; play->msgCtx.ocarinaMode = OCARINA_MODE_END;
// @recomp // @recomp
dsot_cancel_hour_selection(play); dsot_cancel_hour_selection(play);
}
Message_CloseTextbox(play);
}
} else {
if (Message_ShouldAdvance(play)) {
if (msgCtx->choiceIndex == 0) {
Audio_PlaySfx_MessageDecide();
if (gSaveContext.save.isNight != 0) {
gSaveContext.save.time = CLOCK_TIME(6, 0);
} else {
gSaveContext.save.time = CLOCK_TIME(18, 0);
}
play->msgCtx.ocarinaMode = OCARINA_MODE_APPLY_DOUBLE_SOT;
gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF;
} else {
Audio_PlaySfx_MessageCancel();
play->msgCtx.ocarinaMode = OCARINA_MODE_END;
}
Message_CloseTextbox(play);
} }
Message_CloseTextbox(play);
} }
} else if ((msgCtx->textboxEndType != TEXTBOX_ENDTYPE_10) || } else if ((msgCtx->textboxEndType != TEXTBOX_ENDTYPE_10) ||
(pauseCtx->state != PAUSE_STATE_OWL_WARP_CONFIRM)) { (pauseCtx->state != PAUSE_STATE_OWL_WARP_CONFIRM)) {
@ -659,49 +679,66 @@ void Message_Update(PlayState* play) {
play->msgCtx.ocarinaMode = OCARINA_MODE_PROCESS_RESTRICTED_SONG; play->msgCtx.ocarinaMode = OCARINA_MODE_PROCESS_RESTRICTED_SONG;
} }
} else if (sLastPlayedSong == OCARINA_SONG_DOUBLE_TIME) { } else if (sLastPlayedSong == OCARINA_SONG_DOUBLE_TIME) {
// @recomp Patch Song of Double Time.
if (interfaceCtx->restrictions.songOfDoubleTime == 0) { if (interfaceCtx->restrictions.songOfDoubleTime == 0) {
if ((CURRENT_DAY != 3) || (CURRENT_TIME < CLOCK_TIME(5, 0)) || (CURRENT_TIME >= CLOCK_TIME(6, 0))) { // @recomp
Message_StartTextbox(play, D_801D0464[0], NULL); dsot_determine_enabled();
// @recomp Replace message text. // @recomp Replace DSoT functionality if the option for it is enabled.
char *buf = play->msgCtx.font.msgBuf.schar; if (dsot_enabled()) {
buf[25] = ' '; if ((CURRENT_DAY != 3) || (CURRENT_TIME < CLOCK_TIME(5, 0)) || (CURRENT_TIME >= CLOCK_TIME(6, 0))) {
buf[26] = 1; Message_StartTextbox(play, D_801D0464[0], NULL);
buf[27] = 'S';
buf[28] = 'e';
buf[29] = 'l';
buf[30] = 'e';
buf[31] = 'c';
buf[32] = 't';
buf[33] = 'e';
buf[34] = 'd';
buf[35] = ' ';
buf[36] = 'H';
buf[37] = 'o';
buf[38] = 'u';
buf[39] = 'r';
buf[40] = 0;
buf[41] = '?';
buf[42] = 17;
buf[43] = 17;
buf[44] = 2;
buf[45] = -62;
buf[46] = 'Y';
buf[47] = 'e';
buf[48] = 's';
buf[49] = 17;
buf[50] = 'N';
buf[51] = 'o';
buf[52] = -65;
play->msgCtx.ocarinaMode = OCARINA_MODE_PROCESS_DOUBLE_TIME; // @recomp Replace message text.
char *buf = play->msgCtx.font.msgBuf.schar;
buf[25] = ' ';
buf[26] = 1;
buf[27] = 'S';
buf[28] = 'e';
buf[29] = 'l';
buf[30] = 'e';
buf[31] = 'c';
buf[32] = 't';
buf[33] = 'e';
buf[34] = 'd';
buf[35] = ' ';
buf[36] = 'H';
buf[37] = 'o';
buf[38] = 'u';
buf[39] = 'r';
buf[40] = 0;
buf[41] = '?';
buf[42] = 17;
buf[43] = 17;
buf[44] = 2;
buf[45] = -62;
buf[46] = 'Y';
buf[47] = 'e';
buf[48] = 's';
buf[49] = 17;
buf[50] = 'N';
buf[51] = 'o';
buf[52] = -65;
// @recomp play->msgCtx.ocarinaMode = OCARINA_MODE_PROCESS_DOUBLE_TIME;
dsot_init_hour_selection(play);
// @recomp
dsot_init_hour_selection(play);
} else {
Message_StartTextbox(play, 0x1B94, NULL);
play->msgCtx.ocarinaMode = OCARINA_MODE_END;
}
} else { } else {
Message_StartTextbox(play, 0x1B94, NULL); if ((CURRENT_DAY != 3) || (gSaveContext.save.isNight == 0)) {
play->msgCtx.ocarinaMode = OCARINA_MODE_END; if (gSaveContext.save.isNight) {
Message_StartTextbox(play, D_801D0464[CURRENT_DAY - 1], NULL);
} else {
Message_StartTextbox(play, D_801D045C[CURRENT_DAY - 1], NULL);
}
play->msgCtx.ocarinaMode = OCARINA_MODE_PROCESS_DOUBLE_TIME;
} else {
Message_StartTextbox(play, 0x1B94, NULL);
play->msgCtx.ocarinaMode = OCARINA_MODE_END;
}
} }
} else { } else {
sLastPlayedSong = 0xFF; sLastPlayedSong = 0xFF;

View File

@ -11,5 +11,6 @@ DECLARE_FUNC(void, recomp_handle_quicksave_actions_main, OSMesgQueue* enter_mq,
DECLARE_FUNC(u16, recomp_get_pending_warp); DECLARE_FUNC(u16, recomp_get_pending_warp);
DECLARE_FUNC(u32, recomp_get_pending_set_time); DECLARE_FUNC(u32, recomp_get_pending_set_time);
DECLARE_FUNC(s32, recomp_autosave_enabled); DECLARE_FUNC(s32, recomp_autosave_enabled);
DECLARE_FUNC(s32, recomp_dsot_enabled);
#endif #endif

View File

@ -108,6 +108,8 @@ void draw_autosave_icon(PlayState* play);
void recomp_crash(const char* err); void recomp_crash(const char* err);
void dsot_determine_enabled(void);
bool dsot_enabled(void);
void dsot_init_hour_selection(PlayState* play); void dsot_init_hour_selection(PlayState* play);
void dsot_handle_hour_selection(PlayState* play); void dsot_handle_hour_selection(PlayState* play);
void dsot_cancel_hour_selection(PlayState* play); void dsot_cancel_hour_selection(PlayState* play);

View File

@ -47,7 +47,7 @@ osContStartReadData_recomp = 0x8F000070;
osContGetReadData_recomp = 0x8F000074; osContGetReadData_recomp = 0x8F000074;
osContStartQuery_recomp = 0x8F000078; osContStartQuery_recomp = 0x8F000078;
osContGetQuery_recomp = 0x8F00007C; osContGetQuery_recomp = 0x8F00007C;
recomp_get_mouse_deltas = 0x8F000080; recomp_get_mouse_deltas = 0x8F000080;
bcmp_recomp = 0x8F000084; bcmp_recomp = 0x8F000084;
osGetTime_recomp = 0x8F000088; osGetTime_recomp = 0x8F000088;
recomp_autosave_enabled = 0x8F00008C; recomp_autosave_enabled = 0x8F00008C;
@ -60,3 +60,4 @@ recomp_get_inverted_axes = 0x8F0000A4;
recomp_high_precision_fb_enabled = 0x8F0000A8; recomp_high_precision_fb_enabled = 0x8F0000A8;
recomp_get_resolution_scale = 0x8F0000AC; recomp_get_resolution_scale = 0x8F0000AC;
recomp_get_analog_inverted_axes = 0x8F0000B0; recomp_get_analog_inverted_axes = 0x8F0000B0;
recomp_dsot_enabled = 0x8F0000B4;

View File

@ -990,8 +990,8 @@ void Message_DrawTextBox(PlayState* play, Gfx** gfxP) {
gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPPopMatrix(gfx++, G_MTX_MODELVIEW);
} }
// @recomp Draw clock for Double SoT. // @recomp Replace DSoT functionality if the option for it is enabled.
if (play->msgCtx.ocarinaMode == OCARINA_MODE_PROCESS_DOUBLE_TIME) { if (dsot_enabled() && (play->msgCtx.ocarinaMode == OCARINA_MODE_PROCESS_DOUBLE_TIME)) {
dsot_draw_clock(play); dsot_draw_clock(play);
} }

View File

@ -72,7 +72,7 @@ T from_or_default(const json& j, const std::string& key, T default_value) {
else { else {
ret = default_value; ret = default_value;
} }
return ret; return ret;
} }
@ -130,7 +130,7 @@ namespace recomp {
} }
std::filesystem::path zelda64::get_app_folder_path() { std::filesystem::path zelda64::get_app_folder_path() {
// directly check for portable.txt (windows and native linux binary) // directly check for portable.txt (windows and native linux binary)
if (std::filesystem::exists("portable.txt")) { if (std::filesystem::exists("portable.txt")) {
return std::filesystem::current_path(); return std::filesystem::current_path();
} }
@ -207,7 +207,7 @@ bool save_json_with_backups(const std::filesystem::path& path, const nlohmann::j
return recomp::finalize_output_file_with_backup(path); return recomp::finalize_output_file_with_backup(path);
} }
bool save_general_config(const std::filesystem::path& path) { bool save_general_config(const std::filesystem::path& path) {
nlohmann::json config_json{}; nlohmann::json config_json{};
zelda64::to_json(config_json["targeting_mode"], zelda64::get_targeting_mode()); zelda64::to_json(config_json["targeting_mode"], zelda64::get_targeting_mode());
@ -221,7 +221,8 @@ bool save_general_config(const std::filesystem::path& path) {
config_json["analog_cam_mode"] = zelda64::get_analog_cam_mode(); config_json["analog_cam_mode"] = zelda64::get_analog_cam_mode();
config_json["analog_camera_invert_mode"] = zelda64::get_analog_camera_invert_mode(); config_json["analog_camera_invert_mode"] = zelda64::get_analog_camera_invert_mode();
config_json["debug_mode"] = zelda64::get_debug_mode_enabled(); config_json["debug_mode"] = zelda64::get_debug_mode_enabled();
config_json["dsot_mode"] = zelda64::get_dsot_mode();
return save_json_with_backups(path, config_json); return save_json_with_backups(path, config_json);
} }
@ -237,6 +238,7 @@ void set_general_settings_from_json(const nlohmann::json& config_json) {
zelda64::set_analog_cam_mode(from_or_default(config_json, "analog_cam_mode", zelda64::AnalogCamMode::Off)); zelda64::set_analog_cam_mode(from_or_default(config_json, "analog_cam_mode", zelda64::AnalogCamMode::Off));
zelda64::set_analog_camera_invert_mode(from_or_default(config_json, "analog_camera_invert_mode", zelda64::CameraInvertMode::InvertNone)); zelda64::set_analog_camera_invert_mode(from_or_default(config_json, "analog_camera_invert_mode", zelda64::CameraInvertMode::InvertNone));
zelda64::set_debug_mode_enabled(from_or_default(config_json, "debug_mode", false)); zelda64::set_debug_mode_enabled(from_or_default(config_json, "debug_mode", false));
zelda64::set_dsot_mode(from_or_default(config_json, "dsot_mode", zelda64::DsotMode::On));
} }
bool load_general_config(const std::filesystem::path& path) { bool load_general_config(const std::filesystem::path& path) {
@ -423,7 +425,7 @@ bool save_sound_config(const std::filesystem::path& path) {
config_json["main_volume"] = zelda64::get_main_volume(); config_json["main_volume"] = zelda64::get_main_volume();
config_json["bgm_volume"] = zelda64::get_bgm_volume(); config_json["bgm_volume"] = zelda64::get_bgm_volume();
config_json["low_health_beeps"] = zelda64::get_low_health_beeps_enabled(); config_json["low_health_beeps"] = zelda64::get_low_health_beeps_enabled();
return save_json_with_backups(path, config_json); return save_json_with_backups(path, config_json);
} }
@ -485,7 +487,7 @@ void zelda64::save_config() {
} }
std::filesystem::create_directories(recomp_dir); std::filesystem::create_directories(recomp_dir);
// TODO error handling for failing to save config files. // TODO error handling for failing to save config files.
save_general_config(recomp_dir / general_filename); save_general_config(recomp_dir / general_filename);

View File

@ -95,6 +95,10 @@ extern "C" void recomp_autosave_enabled(uint8_t* rdram, recomp_context* ctx) {
_return(ctx, static_cast<s32>(zelda64::get_autosave_mode() == zelda64::AutosaveMode::On)); _return(ctx, static_cast<s32>(zelda64::get_autosave_mode() == zelda64::AutosaveMode::On));
} }
extern "C" void recomp_dsot_enabled(uint8_t* rdram, recomp_context* ctx) {
_return(ctx, static_cast<s32>(zelda64::get_dsot_mode() == zelda64::DsotMode::On));
}
extern "C" void recomp_load_overlays(uint8_t * rdram, recomp_context * ctx) { extern "C" void recomp_load_overlays(uint8_t * rdram, recomp_context * ctx) {
u32 rom = _arg<0, u32>(rdram, ctx); u32 rom = _arg<0, u32>(rdram, ctx);
PTR(void) ram = _arg<1, PTR(void)>(rdram, ctx); PTR(void) ram = _arg<1, PTR(void)>(rdram, ctx);

View File

@ -281,6 +281,7 @@ struct ControlOptionsContext {
zelda64::CameraInvertMode camera_invert_mode; zelda64::CameraInvertMode camera_invert_mode;
zelda64::AnalogCamMode analog_cam_mode; zelda64::AnalogCamMode analog_cam_mode;
zelda64::CameraInvertMode analog_camera_invert_mode; zelda64::CameraInvertMode analog_camera_invert_mode;
zelda64::DsotMode dsot_mode;
}; };
ControlOptionsContext control_options_context; ControlOptionsContext control_options_context;
@ -401,6 +402,17 @@ void zelda64::set_analog_camera_invert_mode(zelda64::CameraInvertMode mode) {
} }
} }
zelda64::DsotMode zelda64::get_dsot_mode() {
return control_options_context.dsot_mode;
}
void zelda64::set_dsot_mode(zelda64::DsotMode mode) {
control_options_context.dsot_mode = mode;
if (general_model_handle) {
general_model_handle.DirtyVariable("dsot_mode");
}
}
struct SoundOptionsContext { struct SoundOptionsContext {
std::atomic<int> main_volume; // Option to control the volume of all sound std::atomic<int> main_volume; // Option to control the volume of all sound
std::atomic<int> bgm_volume; std::atomic<int> bgm_volume;
@ -461,7 +473,7 @@ struct DebugContext {
Rml::DataModelHandle model_handle; Rml::DataModelHandle model_handle;
std::vector<std::string> area_names; std::vector<std::string> area_names;
std::vector<std::string> scene_names; std::vector<std::string> scene_names;
std::vector<std::string> entrance_names; std::vector<std::string> entrance_names;
int area_index = 0; int area_index = 0;
int scene_index = 0; int scene_index = 0;
int entrance_index = 0; int entrance_index = 0;
@ -482,7 +494,7 @@ struct DebugContext {
for (const auto& scene : zelda64::game_warps[area_index].scenes) { for (const auto& scene : zelda64::game_warps[area_index].scenes) {
scene_names.emplace_back(scene.name); scene_names.emplace_back(scene.name);
} }
entrance_names = zelda64::game_warps[area_index].scenes[scene_index].entrances; entrance_names = zelda64::game_warps[area_index].scenes[scene_index].entrances;
} }
}; };
@ -557,7 +569,7 @@ public:
controls_model_handle.DirtyVariable("input_device_is_keyboard"); controls_model_handle.DirtyVariable("input_device_is_keyboard");
controls_model_handle.DirtyVariable("inputs"); controls_model_handle.DirtyVariable("inputs");
}); });
recompui::register_event(listener, "area_index_changed", recompui::register_event(listener, "area_index_changed",
[](const std::string& param, Rml::Event& event) { [](const std::string& param, Rml::Event& event) {
debug_context.area_index = event.GetParameter<int>("value", 0); debug_context.area_index = event.GetParameter<int>("value", 0);
@ -569,7 +581,7 @@ public:
debug_context.model_handle.DirtyVariable("scene_names"); debug_context.model_handle.DirtyVariable("scene_names");
debug_context.model_handle.DirtyVariable("entrance_names"); debug_context.model_handle.DirtyVariable("entrance_names");
}); });
recompui::register_event(listener, "scene_index_changed", recompui::register_event(listener, "scene_index_changed",
[](const std::string& param, Rml::Event& event) { [](const std::string& param, Rml::Event& event) {
debug_context.scene_index = event.GetParameter<int>("value", 0); debug_context.scene_index = event.GetParameter<int>("value", 0);
@ -684,7 +696,7 @@ public:
} }
out = ""; out = "";
}); });
constructor.BindFunc("gfx_help__apply", [](Rml::Variant& out) { constructor.BindFunc("gfx_help__apply", [](Rml::Variant& out) {
if (cont_active) { if (cont_active) {
out = PF_GAMEPAD_X " " PF_GAMEPAD_START; out = PF_GAMEPAD_X " " PF_GAMEPAD_START;
@ -892,7 +904,7 @@ public:
} }
bind_config_list_events(constructor); bind_config_list_events(constructor);
constructor.Bind("rumble_strength", &control_options_context.rumble_strength); constructor.Bind("rumble_strength", &control_options_context.rumble_strength);
constructor.Bind("gyro_sensitivity", &control_options_context.gyro_sensitivity); constructor.Bind("gyro_sensitivity", &control_options_context.gyro_sensitivity);
constructor.Bind("mouse_sensitivity", &control_options_context.mouse_sensitivity); constructor.Bind("mouse_sensitivity", &control_options_context.mouse_sensitivity);
@ -903,10 +915,11 @@ public:
bind_option(constructor, "camera_invert_mode", &control_options_context.camera_invert_mode); bind_option(constructor, "camera_invert_mode", &control_options_context.camera_invert_mode);
bind_option(constructor, "analog_cam_mode", &control_options_context.analog_cam_mode); bind_option(constructor, "analog_cam_mode", &control_options_context.analog_cam_mode);
bind_option(constructor, "analog_camera_invert_mode", &control_options_context.analog_camera_invert_mode); bind_option(constructor, "analog_camera_invert_mode", &control_options_context.analog_camera_invert_mode);
bind_option(constructor, "dsot_mode", &control_options_context.dsot_mode);
general_model_handle = constructor.GetModelHandle(); general_model_handle = constructor.GetModelHandle();
} }
void make_sound_options_bindings(Rml::Context* context) { void make_sound_options_bindings(Rml::Context* context) {
Rml::DataModelConstructor constructor = context->CreateDataModel("sound_options_model"); Rml::DataModelConstructor constructor = context->CreateDataModel("sound_options_model");
if (!constructor) { if (!constructor) {
@ -914,7 +927,7 @@ public:
} }
bind_config_list_events(constructor); bind_config_list_events(constructor);
sound_options_model_handle = constructor.GetModelHandle(); sound_options_model_handle = constructor.GetModelHandle();
bind_atomic(constructor, sound_options_model_handle, "main_volume", &sound_options_context.main_volume); bind_atomic(constructor, sound_options_model_handle, "main_volume", &sound_options_context.main_volume);
@ -932,10 +945,10 @@ public:
// Bind the debug mode enabled flag. // Bind the debug mode enabled flag.
constructor.Bind("debug_enabled", &debug_context.debug_enabled); constructor.Bind("debug_enabled", &debug_context.debug_enabled);
// Register the array type for string vectors. // Register the array type for string vectors.
constructor.RegisterArray<std::vector<std::string>>(); constructor.RegisterArray<std::vector<std::string>>();
// Bind the warp parameter indices // Bind the warp parameter indices
constructor.Bind("area_index", &debug_context.area_index); constructor.Bind("area_index", &debug_context.area_index);
constructor.Bind("scene_index", &debug_context.scene_index); constructor.Bind("scene_index", &debug_context.scene_index);
@ -1004,7 +1017,7 @@ void recompui::update_supported_options() {
msaa4x_supported = zelda64::renderer::RT64MaxMSAA() >= RT64::UserConfiguration::Antialiasing::MSAA4X; msaa4x_supported = zelda64::renderer::RT64MaxMSAA() >= RT64::UserConfiguration::Antialiasing::MSAA4X;
msaa8x_supported = zelda64::renderer::RT64MaxMSAA() >= RT64::UserConfiguration::Antialiasing::MSAA8X; msaa8x_supported = zelda64::renderer::RT64MaxMSAA() >= RT64::UserConfiguration::Antialiasing::MSAA8X;
sample_positions_supported = zelda64::renderer::RT64SamplePositionsSupported(); sample_positions_supported = zelda64::renderer::RT64SamplePositionsSupported();
new_options = ultramodern::renderer::get_graphics_config(); new_options = ultramodern::renderer::get_graphics_config();
graphics_model_handle.DirtyAllVariables(); graphics_model_handle.DirtyAllVariables();