From 917a03eb070b8f195a4fcfa9828a0936c575f8bc Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 9 Sep 2022 23:40:21 -0500 Subject: [PATCH] TIA: fixes fixes fixes --- src/engine/platform/sound/tia/Audio.cpp | 6 ++++++ src/engine/platform/sound/tia/Audio.h | 1 + src/engine/platform/tia.cpp | 24 ++++++++++++++++++++---- src/engine/platform/tia.h | 2 ++ src/gui/sysConf.cpp | 18 ++++++++++++++++++ 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/engine/platform/sound/tia/Audio.cpp b/src/engine/platform/sound/tia/Audio.cpp index a90aee5a3..662bd7fd5 100644 --- a/src/engine/platform/sound/tia/Audio.cpp +++ b/src/engine/platform/sound/tia/Audio.cpp @@ -53,6 +53,9 @@ void Audio::reset(bool st) myCurrentSample[0]=0; myCurrentSample[1]=0; + myChannelOut[0]=0; + myChannelOut[1]=0; + myChannel0.reset(); myChannel1.reset(); } @@ -120,6 +123,9 @@ void Audio::addSample(unsigned char sample0, unsigned char sample1) else { myCurrentSample[0] = myMixingTableSum[sample0 + sample1]; } + + myChannelOut[0] = myMixingTableIndividual[sample0]; + myChannelOut[1] = myMixingTableIndividual[sample1]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/engine/platform/sound/tia/Audio.h b/src/engine/platform/sound/tia/Audio.h index ff3888074..4a782bb38 100644 --- a/src/engine/platform/sound/tia/Audio.h +++ b/src/engine/platform/sound/tia/Audio.h @@ -38,6 +38,7 @@ namespace TIA { AudioChannel& channel1(); short myCurrentSample[2]; + short myChannelOut[2]; private: void phase1(); diff --git a/src/engine/platform/tia.cpp b/src/engine/platform/tia.cpp index 54ef306f4..59c534913 100644 --- a/src/engine/platform/tia.cpp +++ b/src/engine/platform/tia.cpp @@ -41,7 +41,19 @@ const char** DivPlatformTIA::getRegisterSheet() { void DivPlatformTIA::acquire(short* bufL, short* bufR, size_t start, size_t len) { for (size_t h=start; h>1; + } else { + bufL[h]=tia.myCurrentSample[0]; + } + if (++chanOscCounter>=114) { + chanOscCounter=0; + oscBuf[0]->data[oscBuf[0]->needle++]=tia.myChannelOut[0]; + oscBuf[1]->data[oscBuf[1]->needle++]=tia.myChannelOut[1]; + } } } @@ -303,7 +315,7 @@ int DivPlatformTIA::getRegisterPoolSize() { } void DivPlatformTIA::reset() { - tia.reset(false); + tia.reset(mixingType); memset(regPool,0,16); for (int i=0; i<2; i++) { chan[i]=DivPlatformTIA::Channel(); @@ -313,7 +325,7 @@ void DivPlatformTIA::reset() { } bool DivPlatformTIA::isStereo() { - return false; + return (mixingType==2); } bool DivPlatformTIA::keyOffAffectsArp(int ch) { @@ -341,15 +353,19 @@ void DivPlatformTIA::setFlags(unsigned int flags) { rate=COLOR_NTSC; } chipClock=rate; + mixingType=(flags>>1)&3; for (int i=0; i<2; i++) { - oscBuf[i]->rate=rate; + oscBuf[i]->rate=rate/114; } + tia.reset(mixingType); } int DivPlatformTIA::init(DivEngine* p, int channels, int sugRate, unsigned int flags) { parent=p; dumpWrites=false; skipRegisterWrites=false; + mixingType=0; + chanOscCounter=0; for (int i=0; i<2; i++) { isMuted[i]=false; oscBuf[i]=new DivDispatchOscBuffer; diff --git a/src/engine/platform/tia.h b/src/engine/platform/tia.h index fe45c18b1..c6ea280d7 100644 --- a/src/engine/platform/tia.h +++ b/src/engine/platform/tia.h @@ -42,6 +42,8 @@ class DivPlatformTIA: public DivDispatch { Channel chan[2]; DivDispatchOscBuffer* oscBuf[2]; bool isMuted[2]; + unsigned char mixingType; + unsigned char chanOscCounter; TIA::Audio tia; unsigned char regPool[16]; friend void putDispatchChan(void*,int,int); diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index a6bbcb921..ba3ded1a6 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -402,6 +402,24 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool } break; } + case DIV_SYSTEM_TIA: { + ImGui::Text("Mixing mode:"); + if (ImGui::RadioButton("Mono",(flags&6)==0)) { + copyOfFlags=(flags&(~6)); + } + if (ImGui::RadioButton("Mono (no distortion)",(flags&6)==2)) { + copyOfFlags=(flags&(~6))|2; + } + if (ImGui::RadioButton("Stereo",(flags&6)==4)) { + copyOfFlags=(flags&(~6))|4; + } + + sysPal=flags&1; + if (ImGui::Checkbox("PAL",&sysPal)) { + copyOfFlags=(flags&(~1))|(unsigned int)sysPal; + } + break; + } case DIV_SYSTEM_PCSPKR: { ImGui::Text("Speaker type:"); if (ImGui::RadioButton("Unfiltered",(flags&3)==0)) {