Skip to content

Commit

Permalink
Merge pull request #173 from Hondarer/enable-io-sound
Browse files Browse the repository at this point in the history
Add "Enable io sound" core option
  • Loading branch information
LibretroAdmin authored Aug 8, 2024
2 parents 1f6b5b3 + 4a187c2 commit 824690b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
28 changes: 28 additions & 0 deletions libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static bool msx_ym2413_enable;
static bool use_overscan = true;
int msx2_dif = 0;

static void reevaluate_variables_io_sound(bool setToMixer);

void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; }
Expand Down Expand Up @@ -821,13 +822,39 @@ static void check_variables(void)
else
auto_rewind_cas = true;

if (properties != NULL) // Avoid first run (check_variables() is called before propCreate())
{
reevaluate_variables_io_sound(true);
}

if (geometry_update)
{
retro_get_system_av_info(&av_info);
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &av_info);
}
}

static void reevaluate_variables_io_sound(bool setToMixer)
{
struct retro_variable var;

var.key = "bluemsx_sound_io_enable";
var.value = NULL;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (!strcmp(var.value, "disabled"))
properties->sound.mixerChannel[MIXER_CHANNEL_IO].enable = 0;
else if (!strcmp(var.value, "enabled"))
properties->sound.mixerChannel[MIXER_CHANNEL_IO].enable = 1;
}
else
properties->sound.mixerChannel[MIXER_CHANNEL_IO].enable = 0;

if (setToMixer)
mixerEnableChannelType(mixer, MIXER_CHANNEL_IO, properties->sound.mixerChannel[MIXER_CHANNEL_IO].enable);
}

bool retro_load_game(const struct retro_game_info *info)
{
const char *save_dir = NULL;
Expand Down Expand Up @@ -937,6 +964,7 @@ bool retro_load_game(const struct retro_game_info *info)
#endif

emulatorRestartSound();
reevaluate_variables_io_sound(false);

for (i = 0; i < MIXER_CHANNEL_TYPE_COUNT; i++)
{
Expand Down
11 changes: 11 additions & 0 deletions libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ struct retro_core_option_definition option_defs_us[] = {
},
"ON"
},
{
"bluemsx_sound_io_enable",
"I/O Sound Enable",
"Enable the I/O sound (floppy disk access sound).",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{ NULL, NULL, NULL, {{0}}, NULL },
};

Expand Down

0 comments on commit 824690b

Please sign in to comment.