diff --git a/src/engine/platform/sound/vic20sound.c b/src/engine/platform/sound/vic20sound.c index a3c90f204..7bc5880ff 100644 --- a/src/engine/platform/sound/vic20sound.c +++ b/src/engine/platform/sound/vic20sound.c @@ -92,6 +92,7 @@ int vic_sound_machine_calculate_samples(sound_vic20_t *snd, int16_t *pbuf, int n int s = 0; int i; float o; + float v; int16_t vicbuf; int samples_to_do; @@ -100,9 +101,14 @@ int vic_sound_machine_calculate_samples(sound_vic20_t *snd, int16_t *pbuf, int n snd->leftover_cycles += samples_to_do - snd->cycles_per_sample; vic_sound_clock(snd, samples_to_do); - o = snd->lowpassbuf - snd->highpassbuf; - snd->highpassbuf += snd->highpassbeta * (snd->lowpassbuf - snd->highpassbuf); - snd->lowpassbuf += snd->lowpassbeta * (voltagefunction[(((snd->accum * 7) / snd->accum_cycles) + 1) * snd->volume] - snd->lowpassbuf); + v = voltagefunction[(((snd->accum * 7) / snd->accum_cycles) + 1) * snd->volume]; + if (snd->filter_off) { + o = v; + } else { + o = snd->lowpassbuf - snd->highpassbuf; + snd->highpassbuf += snd->highpassbeta * (snd->lowpassbuf - snd->highpassbuf); + snd->lowpassbuf += snd->lowpassbeta * (v - snd->lowpassbuf); + } if (o < -32768) { vicbuf = -32768; @@ -202,7 +208,7 @@ void vic_sound_machine_store(sound_vic20_t *snd, uint16_t addr, uint8_t value) } } -int vic_sound_machine_init(sound_vic20_t *snd, int speed, int cycles_per_sec) +int vic_sound_machine_init(sound_vic20_t *snd, int speed, int cycles_per_sec, bool filter_off) { uint32_t i; float dt; @@ -214,6 +220,7 @@ int vic_sound_machine_init(sound_vic20_t *snd, int speed, int cycles_per_sec) snd->lowpassbuf = 0.0f; snd->highpassbuf = 0.0f; + snd->filter_off = filter_off; snd->speed = speed; diff --git a/src/engine/platform/sound/vic20sound.h b/src/engine/platform/sound/vic20sound.h index 7685bc555..36e685a15 100644 --- a/src/engine/platform/sound/vic20sound.h +++ b/src/engine/platform/sound/vic20sound.h @@ -32,6 +32,7 @@ extern "C" { #endif #include +#include struct sound_vic20_s { unsigned char div; @@ -56,13 +57,14 @@ struct sound_vic20_s { float highpassbeta; float lowpassbuf; float lowpassbeta; + bool filter_off; uint16_t noise_LFSR; uint8_t noise_LFSR0_old; }; typedef struct sound_vic20_s sound_vic20_t; -int vic_sound_machine_init(sound_vic20_t *snd, int speed, int cycles_per_sec); +int vic_sound_machine_init(sound_vic20_t *snd, int speed, int cycles_per_sec, bool filter_off); void vic_sound_machine_store(sound_vic20_t *snd, uint16_t addr, uint8_t value); int vic_sound_machine_calculate_samples(sound_vic20_t *snd, int16_t *pbuf, int nr, int soc, int scc, uint32_t delta_t); void vic_sound_clock(sound_vic20_t *snd, uint32_t cycles); diff --git a/src/engine/platform/vic20.cpp b/src/engine/platform/vic20.cpp index c3881e4ef..6d321fc68 100644 --- a/src/engine/platform/vic20.cpp +++ b/src/engine/platform/vic20.cpp @@ -317,7 +317,7 @@ void DivPlatformVIC20::reset() { chan[i]=Channel(); chan[i].std.setEngine(parent); } - vic_sound_machine_init(vic,rate,chipClock); + vic_sound_machine_init(vic,rate,chipClock,filterOff); hasWaveWrite=false; rWrite(14,15); // hack: starting noise channel right away after this would result in a dead @@ -336,6 +336,7 @@ void DivPlatformVIC20::notifyInsDeletion(void* ins) { } void DivPlatformVIC20::setFlags(const DivConfig& flags) { + filterOff=flags.getBool("filterOff",false); if (flags.getInt("clockSel",0)) { chipClock=COLOR_PAL/4.0; } else { diff --git a/src/engine/platform/vic20.h b/src/engine/platform/vic20.h index 962c1ef7e..ecce6ef7f 100644 --- a/src/engine/platform/vic20.h +++ b/src/engine/platform/vic20.h @@ -37,6 +37,7 @@ class DivPlatformVIC20: public DivDispatch { DivDispatchOscBuffer* oscBuf[4]; bool isMuted[4]; bool hasWaveWrite; + bool filterOff; unsigned char regPool[16]; sound_vic20_t* vic; diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 18a41e064..01d27088b 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -2612,6 +2612,25 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl } break; } + case DIV_SYSTEM_VIC20: { + bool sysPal=flags.getInt("clockSel",0); + bool filterOff=flags.getBool("filterOff",false); + + if (ImGui::Checkbox(_("PAL"),&sysPal)) { + altered=true; + } + if (ImGui::Checkbox(_("Disable filtering"),&filterOff)) { + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",(int)sysPal); + flags.set("filterOff",filterOff); + }); + } + break; + } case DIV_SYSTEM_SWAN: case DIV_SYSTEM_BUBSYS_WSG: case DIV_SYSTEM_PET: