Libretro: Add core option to mute sound channels

This commit is contained in:
retro-wertz 2018-06-14 18:39:15 +08:00 committed by Rafael Kitover
parent 5a4c788dad
commit 94f1102395
1 changed files with 59 additions and 35 deletions

View File

@ -29,6 +29,9 @@
#define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
#define RETRO_DEVICE_GBA_ALT2 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 2)
#define SAMPLERATE 32768
#define FRAMERATE (16777216.0 / 280896.0)
#define ISHEXDEC ((codeLine[cursor]>='0') && (codeLine[cursor]<='9')) || ((codeLine[cursor]>='a') && (codeLine[cursor]<='f')) || ((codeLine[cursor]>='A') && (codeLine[cursor]<='F'))
static retro_log_printf_t log_cb;
@ -197,6 +200,12 @@ void retro_set_environment(retro_environment_t cb)
{ "vbam_layer_6", "Show window layer 1; enabled|disabled" },
{ "vbam_layer_7", "Show window layer 2; enabled|disabled" },
{ "vbam_layer_8", "Show sprite window layer; enabled|disabled" },
{ "vbam_sound_1", "Sound channel 1; enabled|disabled" },
{ "vbam_sound_2", "Sound channel 2; enabled|disabled" },
{ "vbam_sound_3", "Sound channel 3; enabled|disabled" },
{ "vbam_sound_4", "Sound channel 4; enabled|disabled" },
{ "vbam_sound_5", "Direct Sound A; enabled|disabled" },
{ "vbam_sound_6", "Direct Sound B; enabled|disabled" },
{ NULL, NULL },
};
@ -233,8 +242,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->geometry.max_width = 240;
info->geometry.max_height = 160;
info->geometry.aspect_ratio = 3.0 / 2.0;
info->timing.fps = 16777216.0 / 280896.0;
info->timing.sample_rate = 32000.0;
info->timing.fps = (double)FRAMERATE;
info->timing.sample_rate = (double)SAMPLERATE;
}
void retro_init(void)
@ -560,14 +569,29 @@ static void update_variables(void)
key[strlen("vbam_layer_")] = '1' + i;
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && var.value[0] == 'd')
{
disabled_layers |= 0x100 << i;
}
}
layerSettings = 0xFF00 ^ disabled_layers;
layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false);
unsigned sound_enabled = 0x30F;
strcpy(key, "vbam_sound_x");
for (unsigned i = 0; i < 6; i++)
{
key[strlen("vbam_sound_")] = '1' + i;
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && var.value[0] == 'd')
{
unsigned which = (i < 4) ? (1 << i) : (0x100 << (i - 4));
sound_enabled &= ~(which);
}
}
if (soundGetEnable() != sound_enabled)
soundSetEnable(sound_enabled & 0x30F);
var.key = "vbam_usebios";
var.value = NULL;