From c9e0cd0a75f9f4106151843cf5572ddda9e570f6 Mon Sep 17 00:00:00 2001 From: "a.mantoni" <925171+eadmaster@users.noreply.github.com> Date: Wed, 28 Dec 2022 07:03:21 +0100 Subject: [PATCH] replaced sound channel toggle with volume percent core options --- apu/bapu/dsp/SPC_DSP.cpp | 10 +- libretro/libretro.cpp | 31 ++++--- libretro/libretro_core_options.h | 152 +++++++++++++++++++++++-------- snes9x.h | 1 + 4 files changed, 139 insertions(+), 55 deletions(-) diff --git a/apu/bapu/dsp/SPC_DSP.cpp b/apu/bapu/dsp/SPC_DSP.cpp index 6213b08b7..66b764958 100644 --- a/apu/bapu/dsp/SPC_DSP.cpp +++ b/apu/bapu/dsp/SPC_DSP.cpp @@ -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] ); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 0136b601b..3a62f27bc 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -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<