From 8ce175c30c3be4167bd0850d50aeb310ab9fdb0e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 30 Sep 2022 03:13:41 -0500 Subject: [PATCH] chip flags rewrite, part 7 fix GUI completely - flags are now usable --- src/gui/sysConf.cpp | 1006 +++++++++++++++++++++++++++++-------------- 1 file changed, 683 insertions(+), 323 deletions(-) diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index da0aa858..b7c0ed09 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -174,9 +174,11 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo } if (altered) { - flags.set("clockSel",(int)clockSel); - flags.set("chipType",chipType); - flags.set("noPhaseReset",noAntiClick); + e->lockSave([&]() { + flags.set("clockSel",(int)clockSel); + flags.set("chipType",chipType); + flags.set("noPhaseReset",noAntiClick); + }); } break; } @@ -250,492 +252,792 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo } rightClickable if (altered) { - flags.set("clockSel",clockSel); - flags.set("echo",echo); - flags.set("swapEcho",swapEcho); - flags.set("sampleMemSize",sampleMemSize); - flags.set("pdm",pdm); - flags.set("echoDelay",echoDelay); - flags.set("echoFeedback",echoFeedback); - flags.set("echoResolution",echoResolution); - flags.set("echoVol",(unsigned char)echoVol); + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("echo",echo); + flags.set("swapEcho",swapEcho); + flags.set("sampleMemSize",sampleMemSize); + flags.set("pdm",pdm); + flags.set("echoDelay",echoDelay); + flags.set("echoFeedback",echoFeedback); + flags.set("echoResolution",echoResolution); + flags.set("echoVol",(unsigned char)echoVol); + }); } break; } - /* case DIV_SYSTEM_GB: { - bool antiClick=flags&8; - if (ImGui::Checkbox("Disable anti-click",&antiClick)) { - copyOfFlags=(flags&(~8))|(antiClick<<3); + int chipType=flags.getInt("chipType",0); + bool noAntiClick=flags.getBool("noAntiClick",false); + + if (ImGui::Checkbox("Disable anti-click",&noAntiClick)) { + altered=true; } ImGui::Text("Chip revision:"); - if (ImGui::RadioButton("Original (DMG)",(flags&7)==0)) { - copyOfFlags=(flags&(~7))|0; + if (ImGui::RadioButton("Original (DMG)",chipType==0)) { + chipType=0; + altered=true; } - if (ImGui::RadioButton("Game Boy Color (rev C)",(flags&7)==1)) { - copyOfFlags=(flags&(~7))|1; + if (ImGui::RadioButton("Game Boy Color (rev C)",chipType==1)) { + chipType=1; + altered=true; } - if (ImGui::RadioButton("Game Boy Color (rev E)",(flags&7)==2)) { - copyOfFlags=(flags&(~7))|2; + if (ImGui::RadioButton("Game Boy Color (rev E)",chipType==2)) { + chipType=2; + altered=true; } - if (ImGui::RadioButton("Game Boy Advance",(flags&7)==3)) { - copyOfFlags=(flags&(~7))|3; + if (ImGui::RadioButton("Game Boy Advance",chipType==3)) { + chipType=3; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("chipType",chipType); + flags.set("noPhaseReset",noAntiClick); + }); } break; } case DIV_SYSTEM_OPLL: case DIV_SYSTEM_OPLL_DRUMS: case DIV_SYSTEM_VRC7: { + int clockSel=flags.getInt("clockSel",0); + int patchSet=flags.getInt("patchSet",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("NTSC (3.58MHz)",(flags&15)==0)) { - copyOfFlags=(flags&(~15))|0; + if (ImGui::RadioButton("NTSC (3.58MHz)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("PAL (3.55MHz)",(flags&15)==1)) { - copyOfFlags=(flags&(~15))|1; + if (ImGui::RadioButton("PAL (3.55MHz)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("Arcade (4MHz)",(flags&15)==2)) { - copyOfFlags=(flags&(~15))|2; + if (ImGui::RadioButton("Arcade (4MHz)",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("Half NTSC (1.79MHz)",(flags&15)==3)) { - copyOfFlags=(flags&(~15))|3; + if (ImGui::RadioButton("Half NTSC (1.79MHz)",clockSel==3)) { + clockSel=3; + altered=true; } if (type!=DIV_SYSTEM_VRC7) { ImGui::Text("Patch set:"); - if (ImGui::RadioButton("Yamaha YM2413",((flags>>4)&15)==0)) { - copyOfFlags=(flags&(~0xf0))|0; + if (ImGui::RadioButton("Yamaha YM2413",patchSet==0)) { + patchSet=0; + altered=true; } - if (ImGui::RadioButton("Yamaha YMF281",((flags>>4)&15)==1)) { - copyOfFlags=(flags&(~0xf0))|0x10; + if (ImGui::RadioButton("Yamaha YMF281",patchSet==1)) { + patchSet=1; + altered=true; } - if (ImGui::RadioButton("Yamaha YM2423",((flags>>4)&15)==2)) { - copyOfFlags=(flags&(~0xf0))|0x20; + if (ImGui::RadioButton("Yamaha YM2423",patchSet==2)) { + patchSet=2; + altered=true; } - if (ImGui::RadioButton("Konami VRC7",((flags>>4)&15)==3)) { - copyOfFlags=(flags&(~0xf0))|0x30; + if (ImGui::RadioButton("Konami VRC7",patchSet==3)) { + patchSet=3; + altered=true; } } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + if (type!=DIV_SYSTEM_VRC7) { + flags.set("patchSet",patchSet); + } + }); + } break; } - case DIV_SYSTEM_YM2151: - if (ImGui::RadioButton("NTSC/X16 (3.58MHz)",flags==0)) { - copyOfFlags=0; + case DIV_SYSTEM_YM2151: { + int clockSel=flags.getInt("clockSel",0); + + if (ImGui::RadioButton("NTSC/X16 (3.58MHz)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("PAL (3.55MHz)",flags==1)) { - copyOfFlags=1; + if (ImGui::RadioButton("PAL (3.55MHz)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("X1/X68000 (4MHz)",flags==2)) { - copyOfFlags=2; + if (ImGui::RadioButton("X1/X68000 (4MHz)",clockSel==2)) { + clockSel=2; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; + } case DIV_SYSTEM_NES: case DIV_SYSTEM_VRC6: case DIV_SYSTEM_FDS: - case DIV_SYSTEM_MMC5: - if (ImGui::RadioButton("NTSC (1.79MHz)",flags==0)) { - copyOfFlags=0; + case DIV_SYSTEM_MMC5: { + int clockSel=flags.getInt("clockSel",0); + + if (ImGui::RadioButton("NTSC (1.79MHz)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("PAL (1.67MHz)",flags==1)) { - copyOfFlags=1; + if (ImGui::RadioButton("PAL (1.67MHz)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("Dendy (1.77MHz)",flags==2)) { - copyOfFlags=2; + if (ImGui::RadioButton("Dendy (1.77MHz)",clockSel==2)) { + clockSel=2; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; + } case DIV_SYSTEM_C64_8580: - case DIV_SYSTEM_C64_6581: - if (ImGui::RadioButton("NTSC (1.02MHz)",flags==0)) { - copyOfFlags=0; + case DIV_SYSTEM_C64_6581: { + int clockSel=flags.getInt("clockSel",0); + + if (ImGui::RadioButton("NTSC (1.02MHz)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("PAL (0.99MHz)",flags==1)) { - copyOfFlags=1; + if (ImGui::RadioButton("PAL (0.99MHz)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("SSI 2001 (0.89MHz)",flags==2)) { - copyOfFlags=2; + if (ImGui::RadioButton("SSI 2001 (0.89MHz)",clockSel==2)) { + clockSel=2; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; + } case DIV_SYSTEM_YM2610: case DIV_SYSTEM_YM2610_EXT: case DIV_SYSTEM_YM2610_FULL: case DIV_SYSTEM_YM2610_FULL_EXT: case DIV_SYSTEM_YM2610B: - case DIV_SYSTEM_YM2610B_EXT: - if (ImGui::RadioButton("8MHz (Neo Geo MVS)",(flags&0xff)==0)) { - copyOfFlags=(flags&(~0xff))|0; + case DIV_SYSTEM_YM2610B_EXT: { + int clockSel=flags.getInt("clockSel",0); + + if (ImGui::RadioButton("8MHz (Neo Geo MVS)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("8.06MHz (Neo Geo AES)",(flags&0xff)==1)) { - copyOfFlags=(flags&(~0xff))|1; + if (ImGui::RadioButton("8.06MHz (Neo Geo AES)",clockSel==1)) { + clockSel=1; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; + } case DIV_SYSTEM_AY8910: case DIV_SYSTEM_AY8930: { + int clockSel=flags.getInt("clockSel",0); + int chipType=flags.getInt("chipType",0); + bool halfClock=flags.getBool("halfClock",false); + bool stereo=flags.getBool("stereo",false); + int stereoSep=flags.getInt("stereoSep",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("1.79MHz (ZX Spectrum NTSC/MSX)",(flags&15)==0)) { - copyOfFlags=(flags&(~15))|0; + if (ImGui::RadioButton("1.79MHz (ZX Spectrum NTSC/MSX)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("1.77MHz (ZX Spectrum)",(flags&15)==1)) { - copyOfFlags=(flags&(~15))|1; + if (ImGui::RadioButton("1.77MHz (ZX Spectrum)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("1.75MHz (ZX Spectrum)",(flags&15)==2)) { - copyOfFlags=(flags&(~15))|2; + if (ImGui::RadioButton("1.75MHz (ZX Spectrum)",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("2MHz (Atari ST/Sharp X1)",(flags&15)==3)) { - copyOfFlags=(flags&(~15))|3; + if (ImGui::RadioButton("2MHz (Atari ST/Sharp X1)",clockSel==3)) { + clockSel=3; + altered=true; } - if (ImGui::RadioButton("1.5MHz (Vectrex)",(flags&15)==4)) { - copyOfFlags=(flags&(~15))|4; + if (ImGui::RadioButton("1.5MHz (Vectrex)",clockSel==4)) { + clockSel=4; + altered=true; } - if (ImGui::RadioButton("1MHz (Amstrad CPC)",(flags&15)==5)) { - copyOfFlags=(flags&(~15))|5; + if (ImGui::RadioButton("1MHz (Amstrad CPC)",clockSel==5)) { + clockSel=5; + altered=true; } - if (ImGui::RadioButton("0.89MHz (Pre-divided Sunsoft 5B)",(flags&15)==6)) { - copyOfFlags=(flags&(~15))|6; + if (ImGui::RadioButton("0.89MHz (Pre-divided Sunsoft 5B)",clockSel==6)) { + clockSel=6; + altered=true; } - if (ImGui::RadioButton("1.67MHz (?)",(flags&15)==7)) { - copyOfFlags=(flags&(~15))|7; + if (ImGui::RadioButton("1.67MHz (?)",clockSel==7)) { + clockSel=7; + altered=true; } - if (ImGui::RadioButton("0.83MHz (Pre-divided Sunsoft 5B on PAL)",(flags&15)==8)) { - copyOfFlags=(flags&(~15))|8; + if (ImGui::RadioButton("0.83MHz (Pre-divided Sunsoft 5B on PAL)",clockSel==8)) { + clockSel=8; + altered=true; } - if (ImGui::RadioButton("1.10MHz (Gamate/VIC-20 PAL)",(flags&15)==9)) { - copyOfFlags=(flags&(~15))|9; + if (ImGui::RadioButton("1.10MHz (Gamate/VIC-20 PAL)",clockSel==9)) { + clockSel=9; + altered=true; } - if (ImGui::RadioButton("2^21Hz (Game Boy)",(flags&15)==10)) { - copyOfFlags=(flags&(~15))|10; + if (ImGui::RadioButton("2^21Hz (Game Boy)",clockSel==10)) { + clockSel=10; + altered=true; } - if (ImGui::RadioButton("3.58MHz (Darky)",(flags&15)==11)) { - copyOfFlags=(flags&(~15))|11; + if (ImGui::RadioButton("3.58MHz (Darky)",clockSel==11)) { + clockSel=11; + altered=true; } - if (ImGui::RadioButton("3.6MHz (Darky)",(flags&15)==12)) { - copyOfFlags=(flags&(~15))|12; + if (ImGui::RadioButton("3.6MHz (Darky)",clockSel==12)) { + clockSel=12; + altered=true; } - if (ImGui::RadioButton("1.25MHz (Mag Max)",(flags&15)==13)) { - copyOfFlags=(flags&(~15))|13; + if (ImGui::RadioButton("1.25MHz (Mag Max)",clockSel==13)) { + clockSel=13; + altered=true; } - if (ImGui::RadioButton("1.536MHz (Kyugo)",(flags&15)==14)) { - copyOfFlags=(flags&(~15))|14; + if (ImGui::RadioButton("1.536MHz (Kyugo)",clockSel==14)) { + clockSel=14; + altered=true; } if (type==DIV_SYSTEM_AY8910) { ImGui::Text("Chip type:"); - if (ImGui::RadioButton("AY-3-8910",(flags&0x30)==0)) { - copyOfFlags=(flags&(~0x30))|0; + if (ImGui::RadioButton("AY-3-8910",chipType==0)) { + chipType=0; + altered=true; } - if (ImGui::RadioButton("YM2149(F)",(flags&0x30)==16)) { - copyOfFlags=(flags&(~0x30))|16; + if (ImGui::RadioButton("YM2149(F)",chipType==1)) { + chipType=1; + altered=true; } - if (ImGui::RadioButton("Sunsoft 5B",(flags&0x30)==32)) { - copyOfFlags=(flags&(~0x30))|32; + if (ImGui::RadioButton("Sunsoft 5B",chipType==2)) { + chipType=2; + altered=true; } - if (ImGui::RadioButton("AY-3-8914",(flags&0x30)==48)) { - copyOfFlags=(flags&(~0x30))|48; + if (ImGui::RadioButton("AY-3-8914",chipType==3)) { + chipType=3; + altered=true; } } - bool stereo=flags&0x40; - ImGui::BeginDisabled((type==DIV_SYSTEM_AY8910) && ((flags&0x30)==32)); + ImGui::BeginDisabled(type==DIV_SYSTEM_AY8910 && chipType==2); if (ImGui::Checkbox("Stereo##_AY_STEREO",&stereo)) { - copyOfFlags=(flags&(~0x40))|(stereo?0x40:0); + altered=true; } if (stereo) { - int sep=256-((flags>>8)&255); + int sep=256-(stereoSep&255); if (CWSliderInt("Separation",&sep,1,256)) { if (sep<1) sep=1; if (sep>256) sep=256; - copyOfFlags=(flags&(~0xff00))|((256-sep)<<8); + stereoSep=256-sep; + altered=true; } } ImGui::EndDisabled(); - bool clockSel=flags&0x80; - ImGui::BeginDisabled((type==DIV_SYSTEM_AY8910) && ((flags&0x30)!=16)); - if (ImGui::Checkbox("Half Clock divider##_AY_CLKSEL",&clockSel)) { - copyOfFlags=(flags&(~0x80))|(clockSel?0x80:0); + ImGui::BeginDisabled(type==DIV_SYSTEM_AY8910 && chipType!=1); + if (ImGui::Checkbox("Half Clock divider##_AY_CLKSEL",&halfClock)) { + altered=true; } ImGui::EndDisabled(); + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + if (type==DIV_SYSTEM_AY8910) { + flags.set("chipType",chipType); + } + flags.set("halfClock",halfClock); + flags.set("stereo",stereo); + flags.set("stereoSep",stereoSep); + }); + } break; } - case DIV_SYSTEM_SAA1099: - if (ImGui::RadioButton("SAM Coupé (8MHz)",flags==0)) { - copyOfFlags=0; + case DIV_SYSTEM_SAA1099: { + int clockSel=flags.getInt("clockSel",0); + + if (ImGui::RadioButton("SAM Coupé (8MHz)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("NTSC (7.15MHz)",flags==1)) { - copyOfFlags=1; + if (ImGui::RadioButton("NTSC (7.15MHz)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("PAL (7.09MHz)",flags==2)) { - copyOfFlags=2; + if (ImGui::RadioButton("PAL (7.09MHz)",clockSel==2)) { + clockSel=2; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; + } case DIV_SYSTEM_AMIGA: { + bool clockSel=flags.getInt("clockSel",0); + int chipType=flags.getInt("chipType",0); + int stereoSep=flags.getInt("stereoSep",0); + bool bypassLimits=flags.getBool("bypassLimits",false); + ImGui::Text("Stereo separation:"); - int stereoSep=(flags>>8)&127; if (CWSliderInt("##StereoSep",&stereoSep,0,127)) { if (stereoSep<0) stereoSep=0; if (stereoSep>127) stereoSep=127; - copyOfFlags=(flags&(~0x7f00))|((stereoSep&127)<<8); + altered=true; } rightClickable - if (ImGui::RadioButton("Amiga 500 (OCS)",(flags&2)==0)) { - copyOfFlags=flags&(~2); + if (ImGui::RadioButton("Amiga 500 (OCS)",chipType==0)) { + chipType=0; + altered=true; } - if (ImGui::RadioButton("Amiga 1200 (AGA)",(flags&2)==2)) { - copyOfFlags=(flags&(~2))|2; + if (ImGui::RadioButton("Amiga 1200 (AGA)",chipType==1)) { + chipType=1; + altered=true; } - sysPal=flags&1; - if (ImGui::Checkbox("PAL",&sysPal)) { - copyOfFlags=(flags&(~1))|(unsigned int)sysPal; + if (ImGui::Checkbox("PAL",&clockSel)) { + altered=true; } - bool bypassLimits=flags&4; if (ImGui::Checkbox("Bypass frequency limits",&bypassLimits)) { - copyOfFlags=(flags&(~4))|(bypassLimits<<2); + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",(int)clockSel); + flags.set("chipType",chipType); + flags.set("stereoSep",stereoSep); + flags.set("bypassLimits",bypassLimits); + }); } break; } case DIV_SYSTEM_TIA: { + bool clockSel=flags.getInt("clockSel",0); + int mixingType=flags.getInt("mixingType",0); + ImGui::Text("Mixing mode:"); - if (ImGui::RadioButton("Mono",(flags&6)==0)) { - copyOfFlags=(flags&(~6)); + if (ImGui::RadioButton("Mono",mixingType==0)) { + mixingType=0; + altered=true; } - if (ImGui::RadioButton("Mono (no distortion)",(flags&6)==2)) { - copyOfFlags=(flags&(~6))|2; + if (ImGui::RadioButton("Mono (no distortion)",mixingType==1)) { + mixingType=1; + altered=true; } - if (ImGui::RadioButton("Stereo",(flags&6)==4)) { - copyOfFlags=(flags&(~6))|4; + if (ImGui::RadioButton("Stereo",mixingType==2)) { + mixingType=2; + altered=true; } - sysPal=flags&1; - if (ImGui::Checkbox("PAL",&sysPal)) { - copyOfFlags=(flags&(~1))|(unsigned int)sysPal; + if (ImGui::Checkbox("PAL",&clockSel)) { + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",(int)clockSel); + flags.set("mixingType",mixingType); + }); } break; } case DIV_SYSTEM_PCSPKR: { + int speakerType=flags.getInt("speakerType",0); + ImGui::Text("Speaker type:"); - if (ImGui::RadioButton("Unfiltered",(flags&3)==0)) { - copyOfFlags=(flags&(~3))|0; + if (ImGui::RadioButton("Unfiltered",speakerType==0)) { + speakerType=0; + altered=true; } - if (ImGui::RadioButton("Cone",(flags&3)==1)) { - copyOfFlags=(flags&(~3))|1; + if (ImGui::RadioButton("Cone",speakerType==1)) { + speakerType=1; + altered=true; } - if (ImGui::RadioButton("Piezo",(flags&3)==2)) { - copyOfFlags=(flags&(~3))|2; + if (ImGui::RadioButton("Piezo",speakerType==2)) { + speakerType=2; + altered=true; } - if (ImGui::RadioButton("Use system beeper (Linux only!)",(flags&3)==3)) { - copyOfFlags=(flags&(~3))|3; + if (ImGui::RadioButton("Use system beeper (Linux only!)",speakerType==3)) { + speakerType=3; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("speakerType",speakerType); + }); } break; } case DIV_SYSTEM_QSOUND: { + int echoDelay=flags.getInt("echoDelay",0); + int echoFeedback=flags.getInt("echoFeedback",0)&255; + ImGui::Text("Echo delay:"); - int echoBufSize=2725 - (flags & 4095); - if (CWSliderInt("##EchoBufSize",&echoBufSize,0,2725)) { - if (echoBufSize<0) echoBufSize=0; - if (echoBufSize>2725) echoBufSize=2725; - copyOfFlags=(flags & ~4095) | ((2725 - echoBufSize) & 4095); + int echoBufSize1=2725-echoDelay; + if (CWSliderInt("##EchoBufSize",&echoBufSize1,0,2725)) { + if (echoBufSize1<0) echoBufSize1=0; + if (echoBufSize1>2725) echoBufSize1=2725; + echoDelay=2725-echoBufSize1; + altered=true;; } rightClickable ImGui::Text("Echo feedback:"); - int echoFeedback=(flags>>12)&255; if (CWSliderInt("##EchoFeedback",&echoFeedback,0,255)) { if (echoFeedback<0) echoFeedback=0; if (echoFeedback>255) echoFeedback=255; - copyOfFlags=(flags & ~(255 << 12)) | ((echoFeedback & 255) << 12); + altered=true; } rightClickable + + if (altered) { + e->lockSave([&]() { + flags.set("echoDelay",echoDelay); + flags.set("echoFeedback",echoFeedback); + }); + } break; } case DIV_SYSTEM_X1_010: { + int clockSel=flags.getInt("clockSel",0); + bool stereo=flags.getBool("stereo",false); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("16MHz (Seta 1)",(flags&15)==0)) { - copyOfFlags=(flags&(~15))|0; + if (ImGui::RadioButton("16MHz (Seta 1)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("16.67MHz (Seta 2)",(flags&15)==1)) { - copyOfFlags=(flags&(~15))|1; + if (ImGui::RadioButton("16.67MHz (Seta 2)",clockSel==1)) { + clockSel=1; + altered=true; } - bool x1_010Stereo=flags&16; - if (ImGui::Checkbox("Stereo",&x1_010Stereo)) { - copyOfFlags=(flags&(~16))|(x1_010Stereo<<4); + + if (ImGui::Checkbox("Stereo",&stereo)) { + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("stereo",stereo); + }); } break; } case DIV_SYSTEM_N163: { + int clockSel=flags.getInt("clockSel",0); + int channels=flags.getInt("channels",0)+1; + bool multiplex=flags.getBool("multiplex",false); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("NTSC (1.79MHz)",(flags&15)==0)) { - copyOfFlags=(flags&(~15))|0; + if (ImGui::RadioButton("NTSC (1.79MHz)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("PAL (1.67MHz)",(flags&15)==1)) { - copyOfFlags=(flags&(~15))|1; + if (ImGui::RadioButton("PAL (1.67MHz)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("Dendy (1.77MHz)",(flags&15)==2)) { - copyOfFlags=(flags&(~15))|2; + if (ImGui::RadioButton("Dendy (1.77MHz)",clockSel==2)) { + clockSel=2; + altered=true; } ImGui::Text("Initial channel limit:"); - int initialChannelLimit=((flags>>4)&7)+1; - if (CWSliderInt("##InitialChannelLimit",&initialChannelLimit,1,8)) { - if (initialChannelLimit<1) initialChannelLimit=1; - if (initialChannelLimit>8) initialChannelLimit=8; - copyOfFlags=(flags & ~(7 << 4)) | (((initialChannelLimit-1) & 7) << 4); - + if (CWSliderInt("##InitialChannelLimit",&channels,1,8)) { + if (channels<1) channels=1; + if (channels>8) channels=8; + altered=true; } rightClickable - bool n163Multiplex=flags&128; - if (ImGui::Checkbox("Disable hissing",&n163Multiplex)) { - copyOfFlags=(flags&(~128))|(n163Multiplex<<7); + if (ImGui::Checkbox("Disable hissing",&multiplex)) { + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("channels",channels-1); + flags.set("multiplex",multiplex); + }); } break; } case DIV_SYSTEM_OPN: case DIV_SYSTEM_OPN_EXT: { + int clockSel=flags.getInt("clockSel",0); + int prescale=flags.getInt("prescale",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("3.58MHz (NTSC)",(flags&31)==0)) { - copyOfFlags=(flags&(~31))|0; + if (ImGui::RadioButton("3.58MHz (NTSC)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("3.54MHz (PAL)",(flags&31)==1)) { - copyOfFlags=(flags&(~31))|1; + if (ImGui::RadioButton("3.54MHz (PAL)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("4MHz",(flags&31)==2)) { - copyOfFlags=(flags&(~31))|2; + if (ImGui::RadioButton("4MHz",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("3MHz",(flags&31)==3)) { - copyOfFlags=(flags&(~31))|3; + if (ImGui::RadioButton("3MHz",clockSel==3)) { + clockSel=3; + altered=true; } - if (ImGui::RadioButton("3.9936MHz (PC-88/PC-98)",(flags&31)==4)) { - copyOfFlags=(flags&(~31))|4; + if (ImGui::RadioButton("3.9936MHz (PC-88/PC-98)",clockSel==4)) { + clockSel=4; + altered=true; } - if (ImGui::RadioButton("1.5MHz",(flags&31)==5)) { - copyOfFlags=(flags&(~31))|5; + if (ImGui::RadioButton("1.5MHz",clockSel==5)) { + clockSel=5; + altered=true; } ImGui::Text("Output rate:"); - if (ImGui::RadioButton("FM: clock / 72, SSG: clock / 16",(flags&96)==0)) { - copyOfFlags=(flags&(~96))|0; + if (ImGui::RadioButton("FM: clock / 72, SSG: clock / 16",prescale==0)) { + prescale=0; + altered=true; } - if (ImGui::RadioButton("FM: clock / 36, SSG: clock / 8",(flags&96)==32)) { - copyOfFlags=(flags&(~96))|32; + if (ImGui::RadioButton("FM: clock / 36, SSG: clock / 8",prescale==1)) { + prescale=1; + altered=true; } - if (ImGui::RadioButton("FM: clock / 24, SSG: clock / 4",(flags&96)==64)) { - copyOfFlags=(flags&(~96))|64; + if (ImGui::RadioButton("FM: clock / 24, SSG: clock / 4",prescale==2)) { + prescale=2; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("prescale",prescale); + }); } break; } case DIV_SYSTEM_PC98: case DIV_SYSTEM_PC98_EXT: { + int clockSel=flags.getInt("clockSel",0); + int prescale=flags.getInt("prescale",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("8MHz (Arcade)",(flags&31)==0)) { - copyOfFlags=(flags&(~31))|0; + if (ImGui::RadioButton("8MHz (Arcade)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("7.987MHz (PC-88/PC-98)",(flags&31)==1)) { - copyOfFlags=(flags&(~31))|1; + if (ImGui::RadioButton("7.987MHz (PC-88/PC-98)",clockSel==1)) { + clockSel=1; + altered=true; } ImGui::Text("Output rate:"); - if (ImGui::RadioButton("FM: clock / 144, SSG: clock / 32",(flags&96)==0)) { - copyOfFlags=(flags&(~96))|0; + if (ImGui::RadioButton("FM: clock / 144, SSG: clock / 32",prescale==0)) { + prescale=0; + altered=true; } - if (ImGui::RadioButton("FM: clock / 72, SSG: clock / 16",(flags&96)==32)) { - copyOfFlags=(flags&(~96))|32; + if (ImGui::RadioButton("FM: clock / 72, SSG: clock / 16",prescale==1)) { + prescale=1; + altered=true; } - if (ImGui::RadioButton("FM: clock / 48, SSG: clock / 8",(flags&96)==64)) { - copyOfFlags=(flags&(~96))|64; + if (ImGui::RadioButton("FM: clock / 48, SSG: clock / 8",prescale==2)) { + prescale=2; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("prescale",prescale); + }); } break; } case DIV_SYSTEM_RF5C68: { + int clockSel=flags.getInt("clockSel",0); + int chipType=flags.getInt("chipType",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("8MHz (FM Towns)",(flags&15)==0)) { - copyOfFlags=(flags&(~15))|0; + if (ImGui::RadioButton("8MHz (FM Towns)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("10MHz (Sega System 18)",(flags&15)==1)) { - copyOfFlags=(flags&(~15))|1; + if (ImGui::RadioButton("10MHz (Sega System 18)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("12.5MHz (Sega CD/System 32)",(flags&15)==2)) { - copyOfFlags=(flags&(~15))|2; + if (ImGui::RadioButton("12.5MHz (Sega CD/System 32)",clockSel==2)) { + clockSel=2; + altered=true; } ImGui::Text("Chip type:"); - if (ImGui::RadioButton("RF5C68 (10-bit output)",((flags>>4)&15)==0)) { - copyOfFlags=(flags&(~240))|0; + if (ImGui::RadioButton("RF5C68 (10-bit output)",chipType==0)) { + chipType=0; + altered=true; } - if (ImGui::RadioButton("RF5C164 (16-bit output)",((flags>>4)&15)==1)) { - copyOfFlags=(flags&(~240))|16; + if (ImGui::RadioButton("RF5C164 (16-bit output)",chipType==1)) { + chipType=1; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("chipType",chipType); + }); } break; } case DIV_SYSTEM_MSM6258: { + int clockSel=flags.getInt("clockSel",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("4MHz",flags==0)) { - copyOfFlags=0; + if (ImGui::RadioButton("4MHz",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("4.096MHz",flags==1)) { - copyOfFlags=1; + if (ImGui::RadioButton("4.096MHz",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("8MHz (X68000)",flags==2)) { - copyOfFlags=2; + if (ImGui::RadioButton("8MHz (X68000)",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("8.192MHz",flags==3)) { - copyOfFlags=3; + if (ImGui::RadioButton("8.192MHz",clockSel==3)) { + clockSel=3; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; } case DIV_SYSTEM_MSM6295: { + int clockSel=flags.getInt("clockSel",0); + bool rateSel=flags.getBool("rateSel",false); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("1MHz",(flags&127)==0)) { - copyOfFlags=(flags&(~127))|0; + if (ImGui::RadioButton("1MHz",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("1.056MHz",(flags&127)==1)) { - copyOfFlags=(flags&(~127))|1; + if (ImGui::RadioButton("1.056MHz",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("4MHz",(flags&127)==2)) { - copyOfFlags=(flags&(~127))|2; + if (ImGui::RadioButton("4MHz",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("4.224MHz",(flags&127)==3)) { - copyOfFlags=(flags&(~127))|3; + if (ImGui::RadioButton("4.224MHz",clockSel==3)) { + clockSel=3; + altered=true; } - if (ImGui::RadioButton("3.58MHz",(flags&127)==4)) { - copyOfFlags=(flags&(~127))|4; + if (ImGui::RadioButton("3.58MHz",clockSel==4)) { + clockSel=4; + altered=true; } - if (ImGui::RadioButton("1.79MHz",(flags&127)==5)) { - copyOfFlags=(flags&(~127))|5; + if (ImGui::RadioButton("1.79MHz",clockSel==5)) { + clockSel=5; + altered=true; } - if (ImGui::RadioButton("1.02MHz",(flags&127)==6)) { - copyOfFlags=(flags&(~127))|6; + if (ImGui::RadioButton("1.02MHz",clockSel==6)) { + clockSel=6; + altered=true; } - if (ImGui::RadioButton("0.89MHz",(flags&127)==7)) { - copyOfFlags=(flags&(~127))|7; + if (ImGui::RadioButton("0.89MHz",clockSel==7)) { + clockSel=7; + altered=true; } - if (ImGui::RadioButton("2MHz",(flags&127)==8)) { - copyOfFlags=(flags&(~127))|8; + if (ImGui::RadioButton("2MHz",clockSel==8)) { + clockSel=8; + altered=true; } - if (ImGui::RadioButton("2.112MHz",(flags&127)==9)) { - copyOfFlags=(flags&(~127))|9; + if (ImGui::RadioButton("2.112MHz",clockSel==9)) { + clockSel=9; + altered=true; } - if (ImGui::RadioButton("0.875MHz",(flags&127)==10)) { - copyOfFlags=(flags&(~127))|10; + if (ImGui::RadioButton("0.875MHz",clockSel==10)) { + clockSel=10; + altered=true; } - if (ImGui::RadioButton("0.9375MHz",(flags&127)==11)) { - copyOfFlags=(flags&(~127))|11; + if (ImGui::RadioButton("0.9375MHz",clockSel==11)) { + clockSel=11; + altered=true; } - if (ImGui::RadioButton("1.5MHz",(flags&127)==12)) { - copyOfFlags=(flags&(~127))|12; + if (ImGui::RadioButton("1.5MHz",clockSel==12)) { + clockSel=12; + altered=true; } - if (ImGui::RadioButton("3MHz",(flags&127)==13)) { - copyOfFlags=(flags&(~127))|13; + if (ImGui::RadioButton("3MHz",clockSel==13)) { + clockSel=13; + altered=true; } - if (ImGui::RadioButton("1.193MHz (Atari)",(flags&127)==14)) { - copyOfFlags=(flags&(~127))|14; + if (ImGui::RadioButton("1.193MHz (Atari)",clockSel==14)) { + clockSel=14; + altered=true; } ImGui::Text("Output rate:"); - if (ImGui::RadioButton("clock / 132",(flags&128)==0)) { - copyOfFlags=(flags&(~128))|0; + if (ImGui::RadioButton("clock / 132",rateSel==0)) { + rateSel=false; + altered=true; } - if (ImGui::RadioButton("clock / 165",(flags&128)==128)) { - copyOfFlags=(flags&(~128))|128; + if (ImGui::RadioButton("clock / 165",rateSel==1)) { + rateSel=true; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + flags.set("rateSel",rateSel); + }); } break; } case DIV_SYSTEM_SCC: case DIV_SYSTEM_SCC_PLUS: { + int clockSel=flags.getInt("clockSel",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("1.79MHz (NTSC/MSX)",(flags&127)==0)) { - copyOfFlags=(flags&(~127))|0; + if (ImGui::RadioButton("1.79MHz (NTSC/MSX)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("1.77MHz (PAL)",(flags&127)==1)) { - copyOfFlags=(flags&(~127))|1; + if (ImGui::RadioButton("1.77MHz (PAL)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("1.5MHz (Arcade)",(flags&127)==2)) { - copyOfFlags=(flags&(~127))|2; + if (ImGui::RadioButton("1.5MHz (Arcade)",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("2MHz",(flags&127)==3)) { - copyOfFlags=(flags&(~127))|3; + if (ImGui::RadioButton("2MHz",clockSel==3)) { + clockSel=3; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; } @@ -745,106 +1047,163 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo case DIV_SYSTEM_OPL2_DRUMS: case DIV_SYSTEM_Y8950: case DIV_SYSTEM_Y8950_DRUMS: { + int clockSel=flags.getInt("clockSel",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("3.58MHz (NTSC)",(flags&255)==0)) { - copyOfFlags=(flags&(~255))|0; + if (ImGui::RadioButton("3.58MHz (NTSC)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("3.54MHz (PAL)",(flags&255)==1)) { - copyOfFlags=(flags&(~255))|1; + if (ImGui::RadioButton("3.54MHz (PAL)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("4MHz",(flags&255)==2)) { - copyOfFlags=(flags&(~255))|2; + if (ImGui::RadioButton("4MHz",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("3MHz",(flags&255)==3)) { - copyOfFlags=(flags&(~255))|3; + if (ImGui::RadioButton("3MHz",clockSel==3)) { + clockSel=3; + altered=true; } - if (ImGui::RadioButton("3.9936MHz (PC-88/PC-98)",(flags&255)==4)) { - copyOfFlags=(flags&(~255))|4; + if (ImGui::RadioButton("3.9936MHz (PC-88/PC-98)",clockSel==4)) { + clockSel=4; + altered=true; } - if (ImGui::RadioButton("3.5MHz",(flags&255)==5)) { - copyOfFlags=(flags&(~255))|5; + if (ImGui::RadioButton("3.5MHz",clockSel==5)) { + clockSel=5; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; } case DIV_SYSTEM_OPL3: case DIV_SYSTEM_OPL3_DRUMS: { + int clockSel=flags.getInt("clockSel",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("14.32MHz (NTSC)",(flags&255)==0)) { - copyOfFlags=(flags&(~255))|0; + if (ImGui::RadioButton("14.32MHz (NTSC)",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("14.19MHz (PAL)",(flags&255)==1)) { - copyOfFlags=(flags&(~255))|1; + if (ImGui::RadioButton("14.19MHz (PAL)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("14MHz",(flags&255)==2)) { - copyOfFlags=(flags&(~255))|2; + if (ImGui::RadioButton("14MHz",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("16MHz",(flags&255)==3)) { - copyOfFlags=(flags&(~255))|3; + if (ImGui::RadioButton("16MHz",clockSel==3)) { + clockSel=3; + altered=true; } - if (ImGui::RadioButton("15MHz",(flags&255)==4)) { - copyOfFlags=(flags&(~255))|4; + if (ImGui::RadioButton("15MHz",clockSel==4)) { + clockSel=4; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; } case DIV_SYSTEM_YMZ280B: { + int clockSel=flags.getInt("clockSel",0); + ImGui::Text("Clock rate:"); - if (ImGui::RadioButton("16.9344MHz",(flags&255)==0)) { - copyOfFlags=(flags&(~255))|0; + if (ImGui::RadioButton("16.9344MHz",clockSel==0)) { + clockSel=0; + altered=true; } - if (ImGui::RadioButton("14.32MHz (NTSC)",(flags&255)==1)) { - copyOfFlags=(flags&(~255))|1; + if (ImGui::RadioButton("14.32MHz (NTSC)",clockSel==1)) { + clockSel=1; + altered=true; } - if (ImGui::RadioButton("14.19MHz (PAL)",(flags&255)==2)) { - copyOfFlags=(flags&(~255))|2; + if (ImGui::RadioButton("14.19MHz (PAL)",clockSel==2)) { + clockSel=2; + altered=true; } - if (ImGui::RadioButton("16MHz",(flags&255)==3)) { - copyOfFlags=(flags&(~255))|3; + if (ImGui::RadioButton("16MHz",clockSel==3)) { + clockSel=3; + altered=true; } - if (ImGui::RadioButton("16.67MHz",(flags&255)==4)) { - copyOfFlags=(flags&(~255))|4; + if (ImGui::RadioButton("16.67MHz",clockSel==4)) { + clockSel=4; + altered=true; } - if (ImGui::RadioButton("14MHz",(flags&255)==5)) { - copyOfFlags=(flags&(~255))|5; + if (ImGui::RadioButton("14MHz",clockSel==5)) { + clockSel=5; + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",clockSel); + }); } break; } case DIV_SYSTEM_PCM_DAC: { // default to 44100Hz 16-bit stereo - if (!flags) copyOfFlags=flags=0x1f0000|44099; - int sampRate=(flags&65535)+1; - int bitDepth=((flags>>16)&15)+1; - bool stereo=(flags>>20)&1; + int sampRate=flags.getInt("rate",44100); + int bitDepth=flags.getInt("outDepth",15)+1; + bool stereo=flags.getBool("stereo",false); + ImGui::Text("Output rate:"); - if (CWSliderInt("##SampRate",&sampRate,1000,65536)) { + if (CWSliderInt("##SampRate",&sampRate,1000,96000)) { if (sampRate<1000) sampRate=1000; - if (sampRate>65536) sampRate=65536; - copyOfFlags=(flags&(~65535))|(sampRate-1); + if (sampRate>96000) sampRate=96000; + altered=true; } rightClickable ImGui::Text("Output bit depth:"); if (CWSliderInt("##BitDepth",&bitDepth,1,16)) { if (bitDepth<1) bitDepth=1; if (bitDepth>16) bitDepth=16; - copyOfFlags=(flags&(~(15<<16)))|((bitDepth-1)<<16); + altered=true; } rightClickable if (ImGui::Checkbox("Stereo",&stereo)) { - copyOfFlags=(flags&(~(1<<20)))|(stereo<<20); + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("rate",sampRate); + flags.set("outDepth",bitDepth-1); + flags.set("stereo",stereo); + }); } break; } - case DIV_SYSTEM_SNES: { + case DIV_SYSTEM_SNES: { // TODO: echo + int vsL=127-(flags.getInt("volScaleL",0)&127); + int vsR=127-(flags.getInt("volScaleR",0)&127); + ImGui::Text("Volume scale:"); - int vsL=127-(flags&127); - int vsR=127-((flags>>8)&127); if (CWSliderInt("Left##VolScaleL",&vsL,0,127)) { if (vsL<0) vsL=0; if (vsL>127) vsL=127; - copyOfFlags=(flags&(~0x7f))|(127-vsL); + altered=true; } rightClickable if (CWSliderInt("Right##VolScaleL",&vsR,0,127)) { if (vsR<0) vsR=0; if (vsR>127) vsR=127; - copyOfFlags=(flags&(~0x7f00))|((127-vsR)<<8); + altered=true; } rightClickable + + if (altered) { + e->lockSave([&]() { + flags.set("volScaleL",127-vsL); + flags.set("volScaleR",127-vsR); + }); + } break; } case DIV_SYSTEM_SWAN: @@ -855,19 +1214,20 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo case DIV_SYSTEM_T6W28: ImGui::Text("nothing to configure"); break; - default: - if (ImGui::Checkbox("PAL",&sysPal)) { - copyOfFlags=sysPal; - } - break; - */ - default: - ImGui::Text("Wait... is that right? No... I don't think so."); + default: { + bool sysPal=flags.getInt("clockSel",0); - if (ImGui::Button("But it is right!")) { - showError("https://github.com/tildearrow/furnace/issues/new"); + if (ImGui::Checkbox("PAL",&sysPal)) { + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("clockSel",(int)sysPal); + }); } break; + } } if (altered) {