added sound channel disable options (#160)

This commit is contained in:
eadmaster 2020-09-18 13:33:45 +02:00
parent b3cfd52c6e
commit ad7cb55fce
4 changed files with 125 additions and 2 deletions

View File

@ -1199,6 +1199,7 @@ static int turbo_counter[MAX_PLAYERS][MAX_BUTTONS] = {};
static int Turbo_Delay;
static int Turbo_Toggling = 1;
static bool turbo_toggle_alt = false;
static bool disabled_channels[6] = { false };
static int turbo_toggle_down[MAX_PLAYERS][MAX_BUTTONS] = {};
static void check_variables(void)
@ -1320,7 +1321,20 @@ static void check_variables(void)
if (PCECD_SetSettings(&settings) && log_cb)
log_cb(RETRO_LOG_INFO, "PCE CD Audio settings changed.\n");
}
char pce_disable_sound_channel_base_str[] = "pce_disable_sound_channel_0";
var.key = pce_disable_sound_channel_base_str;
for (unsigned c = 0; c < 6; c++) {;
pce_disable_sound_channel_base_str[26] = c+'0';
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
disabled_channels[c] = true;
else
disabled_channels[c] = false;
}
}
// Set Turbo_Toggling
var.key = "pce_turbo_toggling";
@ -1470,6 +1484,13 @@ bool retro_load_game(const struct retro_game_info *info)
descs[i].select = 0xFFFF0000;
i++;
}
for (unsigned c = 0; c < 6; c++) {
if(disabled_channels[c])
psg->DisableChannel(c);
else
psg->EnableChannel(c);
}
mmaps.descriptors = descs;
mmaps.num_descriptors = i;
@ -1697,9 +1718,17 @@ void retro_run(void)
if(PCE_IsCD){
psg->SetVolume(0.678 * setting_pce_fast_cdpsgvolume / 100);
}
for (unsigned c = 0; c < 6; c++) {
if(disabled_channels[c])
psg->DisableChannel(c);
else
psg->EnableChannel(c);
}
update_geometry(width, height);
}
if (resolution_changed)
update_geometry(width, height);
video_frames++;

View File

@ -318,6 +318,72 @@ struct retro_core_option_definition option_defs_us[] = {
},
"100"
},
{
"pce_disable_sound_channel_0",
"Disable Sound Channel 0",
"",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"pce_disable_sound_channel_1",
"Disable Sound Channel 1",
"",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"pce_disable_sound_channel_2",
"Disable Sound Channel 2",
"",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"pce_disable_sound_channel_3",
"Disable Sound Channel 3",
"",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"pce_disable_sound_channel_4",
"Disable Sound Channel 4",
"",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"pce_disable_sound_channel_5",
"Disable Sound Channel 5",
"",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{
"pce_cdspeed",
"(CD) CD Speed",

View File

@ -30,6 +30,25 @@ void PCEFast_PSG::SetVolume(double new_volume)
Blip_Synth_set_volume(&Synth, OutputVolume / 6, 8192);
}
void PCEFast_PSG::DisableChannel(int chnum)
{
psg_channel *ch = &channel[chnum];
if(! ch ) return;
//printf("Disabled channel: %d\n", chnum);
if(chnum < 6)
ch->disabled = 1;
}
void PCEFast_PSG::EnableChannel(int chnum)
{
//printf("Enabled channel: %d\n", chnum);
psg_channel *ch = &channel[chnum];
if(! ch ) return;
if(chnum < 6)
ch->disabled = 0;
}
void PCEFast_PSG::UpdateOutput_Norm(const int32 timestamp, psg_channel *ch)
{
int32 samp[2];
@ -226,6 +245,8 @@ void PCEFast_PSG::Write(int32 timestamp, uint8 A, uint8 V)
Update(timestamp);
psg_channel *ch = &channel[select];
//if(ch->disabled) return;
//if(A == 0x01 || select == 5)
// printf("Write Ch: %d %04x %02x, %d\n", select, A, V, timestamp);
@ -353,6 +374,8 @@ void PCEFast_PSG::RunChannel(int chc, int32 timestamp)
ch->lastts = timestamp;
if(ch->disabled) return;
if(!run_time)
return;
@ -555,6 +578,7 @@ void PCEFast_PSG::Power(const int32 timestamp)
channel[ch].frequency = 0;
channel[ch].control = 0x00;
channel[ch].balance = 0;
channel[ch].disabled = 0;
memset(channel[ch].waveform, 0, 32);
channel[ch].samp_accum = 0;

View File

@ -30,6 +30,8 @@ struct psg_channel
uint16 frequency; /* Channel frequency */
uint8 balance; /* Channel balance */
bool disabled;
};
class PCEFast_PSG
@ -45,6 +47,8 @@ class PCEFast_PSG
void Write(int32 timestamp, uint8 A, uint8 V);
void SetVolume(double new_volume) MDFN_COLD;
void EnableChannel(int chnum) MDFN_COLD;
void DisableChannel(int chnum) MDFN_COLD;
void EndFrame(int32 timestamp);