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

replaced sound channel toggle with volume percent core options #289

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
10 changes: 9 additions & 1 deletion apu/bapu/dsp/SPC_DSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,15 @@ inline void SPC_DSP::voice_output( voice_t const* v, int ch )
// Apply left/right volume
int amp = (m.t_output * (int8_t) VREG(v->regs,voll + ch)) >> 7;
amp *= ((stereo_switch & (1 << (v->voice_number + ch * voice_count))) ? 1 : 0);


#ifdef __LIBRETRO__
// Apply user-set volume (if set)
if (Settings.ChannelsVolumePercent[v->voice_number] < 100)
{
amp = amp * Settings.ChannelsVolumePercent[v->voice_number] / 100;
}
#endif

// Add to output total
m.t_main_out [ch] += amp;
CLAMP16( m.t_main_out [ch] );
Expand Down
31 changes: 17 additions & 14 deletions libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,19 @@ static void update_variables(void)
}
else
Settings.UpAndDown = false;

strcpy(key, "snes9x_sndchan_x");
strcpy(key, "snes9x_sndchan_volume_x");
var.key=key;
for (int i=0;i<8;i++)
{
key[strlen("snes9x_sndchan_")]='1'+i;
key[strlen("snes9x_sndchan_volume_")]='1'+i;
var.value=NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && !strcmp("disabled", var.value))
disabled_channels|=1<<i;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
{
Settings.ChannelsVolumePercent[i] = atoi(var.value);
}
}
S9xSetSoundControl(disabled_channels^0xFF);



int disabled_layers=0;
strcpy(key, "snes9x_layer_x");
for (int i=0;i<5;i++)
Expand Down Expand Up @@ -1235,12 +1235,6 @@ bool retro_load_game(const struct retro_game_info *game)
for(int lcv = 0; lcv < 0x20000; lcv++)
Memory.RAM[lcv] = rand() % 256;
}

// restore disabled sound channels
if (disabled_channels)
{
S9xSetSoundControl(disabled_channels^0xFF);
}
}

if (!rom_loaded && log_cb)
Expand Down Expand Up @@ -1440,6 +1434,15 @@ void retro_init(void)
Settings.CartBName[0] = 0;
Settings.AutoSaveDelay = 1;
Settings.DontSaveOopsSnapshot = TRUE;
Settings.ChannelsVolumePercent[0] = 100;
Settings.ChannelsVolumePercent[1] = 100;
Settings.ChannelsVolumePercent[2] = 100;
Settings.ChannelsVolumePercent[3] = 100;
Settings.ChannelsVolumePercent[4] = 100;
Settings.ChannelsVolumePercent[5] = 100;
Settings.ChannelsVolumePercent[6] = 100;
Settings.ChannelsVolumePercent[7] = 100;
Settings.ChannelsVolumePercent[8] = 100;

CPU.Flags = 0;

Expand Down
152 changes: 112 additions & 40 deletions libretro/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,116 +725,188 @@ struct retro_core_option_v2_definition option_defs_us[] = {
"enabled"
},
{
"snes9x_sndchan_1",
"Enable Sound Channel 1",
"snes9x_sndchan_volume_1",
"Volume % for Sound Channel 1",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_2",
"Enable Sound Channel 2",
"snes9x_sndchan_volume_2",
"Volume % for Sound Channel 2",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_3",
"Enable Sound Channel 3",
"snes9x_sndchan_volume_3",
"Volume % for Sound Channel 3",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_4",
"Enable Sound Channel 4",
"snes9x_sndchan_volume_4",
"Volume % for Sound Channel 4",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_5",
"Enable Sound Channel 5",
"snes9x_sndchan_volume_5",
"Volume % for Sound Channel 5",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_6",
"Enable Sound Channel 6",
"snes9x_sndchan_volume_6",
"Volume % for Sound Channel 6",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_7",
"Enable Sound Channel 7",
"snes9x_sndchan_volume_7",
"Volume % for Sound Channel 7",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{
"snes9x_sndchan_8",
"Enable Sound Channel 8",
"snes9x_sndchan_volume_8",
"Volume % for Sound Channel 8",
NULL,
NULL,
NULL,
"advanced_av",
{
{ "enabled", NULL },
{ "disabled", NULL },
{ "0", NULL },
{ "10", NULL },
{ "20", NULL },
{ "30", NULL },
{ "40", NULL },
{ "50", NULL },
{ "60", NULL },
{ "70", NULL },
{ "80", NULL },
{ "90", NULL },
{ "100", NULL },
{ NULL, NULL },
},
"enabled"
"100"
},
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
Expand Down
1 change: 1 addition & 0 deletions snes9x.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ struct SSettings
int OneSlowClockCycle;
int TwoClockCycles;
int MaxSpriteTilesPerLine;
int ChannelsVolumePercent[9];
};

struct SSNESGameFixes
Expand Down