Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding fix for lvl1 intro music crouch delay when quicksave/load #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ extern custom_options_type custom_defaults INIT(= {
.demo_hitp = 4,
.demo_end_room = 24,
.intro_music_level = 1,
.intro_music_time_initial = 33,
.intro_music_time_restart = 4,
.have_sword_from_level = 2,
.checkpoint_level = 3,
.checkpoint_respawn_dir = dir_FF_left,
Expand Down
5 changes: 5 additions & 0 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ enum setting_ids {
SETTING_FIX_HANG_ON_TELEPORT,
SETTING_FIX_EXIT_DOOR,
SETTING_FIX_QUICKSAVE_DURING_FEATHER,
SETTING_FIX_QUICKSAVE_DURING_LVL1_MUSIC,
SETTING_USE_CUSTOM_OPTIONS,
SETTING_START_MINUTES_LEFT,
SETTING_START_TICKS_LEFT,
Expand Down Expand Up @@ -552,6 +553,10 @@ setting_type gameplay_settings[] = {
.linked = &fixes_saved.fix_quicksave_during_feather, .required = &use_fixes_and_enhancements,
.text = "Fix quick save in feather mode",
.explanation = "You cannot save game while floating in feather mode."},
{.id = SETTING_FIX_QUICKSAVE_DURING_LVL1_MUSIC, .style = SETTING_STYLE_TOGGLE,
.linked = &fixes_saved.fix_quicksave_during_lvl1_music, .required = &use_fixes_and_enhancements,
.text = "Fix quick save during level 1 initial music",
.explanation = "If you save during the level 1 initial music and reload, you stand up faster than otherwise."},
};

NAMES_LIST(tile_type_setting_names, {
Expand Down
1 change: 1 addition & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ static int global_ini_callback(const char *section, const char *name, const char
process_boolean("fix_hang_on_teleport", &fixes_saved.fix_hang_on_teleport);
process_boolean("fix_exit_door", &fixes_saved.fix_exit_door);
process_boolean("fix_quicksave_during_feather", &fixes_saved.fix_quicksave_during_feather);
process_boolean("fix_quicksave_during_lvl1_music", &fixes_saved.fix_quicksave_during_lvl1_music);
}

if (check_ini_section("CustomGameplay")) {
Expand Down
1 change: 1 addition & 0 deletions src/replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ void options_process_fixes(SDL_RWops* rw, rw_process_func_type process_func) {
process(fixes_options_replay.fix_hang_on_teleport);
process(fixes_options_replay.fix_exit_door);
process(fixes_options_replay.fix_quicksave_during_feather);
process(fixes_options_replay.fix_quicksave_during_lvl1_music);
}

void options_process_custom_general(SDL_RWops* rw, rw_process_func_type process_func) {
Expand Down
11 changes: 10 additions & 1 deletion src/seg003.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ void __pascal far init_game(int level) {
rem_tick = custom->start_ticks_left; // 719
hitp_beg_lev = custom->start_hitp; // 3
}
need_level1_music = (level == /*1*/ custom->intro_music_level);

if (fixes->fix_quicksave_during_lvl1_music)
if (level == /*1*/ custom->intro_music_level) need_level1_music = custom->intro_music_time_initial;
else
need_level1_music = (level == /*1*/ custom->intro_music_level);

play_level(level);
}

Expand Down Expand Up @@ -368,6 +373,10 @@ int __pascal far play_level_2() {
timers();
play_frame();

if (need_level1_music != 0 && current_level == /*1*/ custom->intro_music_level)
if (fixes->fix_quicksave_during_lvl1_music)
need_level1_music = custom->intro_music_time_restart;

#ifdef USE_REPLAY
// At the exact "end of level" frame, preserve the seed to ensure reproducibility,
// regardless of how long the sound is still playing *after* this frame (torch animation modifies the seed!)
Expand Down
34 changes: 21 additions & 13 deletions src/seg005.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,27 @@ void __pascal far control() {
// seg005:02EB
void __pascal far control_crouched() {
if (need_level1_music != 0 && current_level == /*1*/ custom->intro_music_level) {
// Special event: music when crouching
if (! check_sound_playing()) {
if (need_level1_music == 1) {
play_sound(sound_25_presentation); // presentation (level 1 start)
need_level1_music = 2;
} else {
#ifdef USE_REPLAY
if (recording) special_move = MOVE_EFFECT_END;
if (!replaying) // during replays, crouch immobilization gets cancelled in do_replay_move()
#endif
need_level1_music = 0;
}
}

if (fixes->fix_quicksave_during_lvl1_music)
{
need_level1_music--;
}
else
{
// Special event: music when crouching
if (! check_sound_playing()) {
if (need_level1_music == 1) {
play_sound(sound_25_presentation); // presentation (level 1 start)
need_level1_music = 2;
} else {
#ifdef USE_REPLAY
if (recording) special_move = MOVE_EFFECT_END;
if (!replaying) // during replays, crouch immobilization gets cancelled in do_replay_move()
#endif
need_level1_music = 0;
}
}
}
} else {
need_level1_music = 0;
if (control_shift2 < 0 && check_get_item()) return;
Expand Down
3 changes: 3 additions & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ typedef struct fixes_options_type {
byte fix_hang_on_teleport;
byte fix_exit_door;
byte fix_quicksave_during_feather;
byte fix_quicksave_during_lvl1_music;
} fixes_options_type;

#define NUM_GUARD_SKILLS 12
Expand Down Expand Up @@ -1244,6 +1245,8 @@ typedef struct custom_options_type {
word demo_hitp;
word demo_end_room;
word intro_music_level;
word intro_music_time_initial;
word intro_music_time_restart;
word have_sword_from_level;
word checkpoint_level;
sbyte checkpoint_respawn_dir;
Expand Down