diff --git a/src/engine/platform/sound/vera_psg.c b/src/engine/platform/sound/vera_psg.c index be080ace9..7ed3d48e5 100644 --- a/src/engine/platform/sound/vera_psg.c +++ b/src/engine/platform/sound/vera_psg.c @@ -5,6 +5,7 @@ // Chip revisions // 0: V 0.3.0 // 1: V 47.0.0 (9-bit volume, phase reset on mute) +// 2: V 47.0.3 (Pulse Width XOR on Saw and Triangle) #include "vera_psg.h" @@ -88,8 +89,8 @@ render(struct VERA_PSG* psg, int16_t *left, int16_t *right) uint8_t v = 0; switch (ch->waveform) { case WF_PULSE: v = (ch->phase >> 10) > ch->pw ? 0 : 63; break; - case WF_SAWTOOTH: v = ch->phase >> 11; break; - case WF_TRIANGLE: v = (ch->phase & 0x10000) ? (~(ch->phase >> 10) & 0x3F) : ((ch->phase >> 10) & 0x3F); break; + case WF_SAWTOOTH: v = (ch->phase >> 11) ^ (psg->chipType < 2 ? 0 : (ch->pw ^ 0x3f) & 0x3f); break; + case WF_TRIANGLE: v = ((ch->phase & 0x10000) ? (~(ch->phase >> 10) & 0x3F) : ((ch->phase >> 10) & 0x3F)) ^ (psg->chipType < 2 ? 0 : (ch->pw ^ 0x3f) & 0x3f); break; case WF_NOISE: v = ch->noiseval; break; } int8_t sv = (v ^ 0x20); diff --git a/src/engine/zsm.cpp b/src/engine/zsm.cpp index 87dbde8d2..75cc3d9da 100644 --- a/src/engine/zsm.cpp +++ b/src/engine/zsm.cpp @@ -133,14 +133,6 @@ void DivZSM::writePSG(unsigned char a, unsigned char v) { } else if (a>=64) { return writePCM(a-64,v); } - if (optimize) { - if ((a&3)==3 && v>64) { - // Pulse width on non-pulse waves is nonsense and wasteful - // No need to preserve state here because the next write that - // selects pulse will also set the pulse width in this register - v&=0xc0; - } - } if (psgState[psg_PREV][a]==v) { if (psgState[psg_NEW][a]!=v) { // NEW value is being reset to the same as PREV value diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 0875f25c1..6ce257357 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -2482,7 +2482,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl break; } case DIV_SYSTEM_VERA: { - int chipType=flags.getInt("chipType",1); + int chipType=flags.getInt("chipType",2); ImGui::Text(_("Chip revision:")); ImGui::Indent(); @@ -2494,6 +2494,10 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl chipType=1; altered=true; } + if (ImGui::RadioButton(_("V 47.0.3 (Tri/Saw PW XOR)"),chipType==2)) { + chipType=2; + altered=true; + } ImGui::Unindent(); if (altered) {