fix: volume portamento no longer cancels set vol

in case where volume portamento was active but not complete, using the volume column to set volume to a point past the volume portamento target would be detected as "volume portamento complete" and set volume to the portamento target, even if the portamento target was actually lower/higher than the volume set by the volume command
This commit is contained in:
Adam Lederer 2024-09-06 16:27:51 -07:00 committed by freq-mod
parent a56729a4f2
commit ad000bc0c0
2 changed files with 12 additions and 2 deletions

View file

@ -364,6 +364,7 @@ bool DivCSPlayer::tick() {
} }
if (sendVolume || chan[i].volSpeed!=0) { if (sendVolume || chan[i].volSpeed!=0) {
int preSpeedVol=chan[i].volume;
chan[i].volume+=chan[i].volSpeed; chan[i].volume+=chan[i].volSpeed;
if (chan[i].volSpeedTarget!=-1) { if (chan[i].volSpeedTarget!=-1) {
bool atTarget=false; bool atTarget=false;
@ -377,7 +378,11 @@ bool DivCSPlayer::tick() {
} }
if (atTarget) { if (atTarget) {
chan[i].volume=chan[i].volSpeedTarget; if (chan[i].volSpeed>0) {
chan[i].volume=MAX(preSpeedVol,chan[i].volSpeedTarget);
} else if (chan[i].volSpeed<0) {
chan[i].volume=MIN(preSpeedVol,chan[i].volSpeedTarget);
}
chan[i].volSpeed=0; chan[i].volSpeed=0;
chan[i].volSpeedTarget=-1; chan[i].volSpeedTarget=-1;
} }

View file

@ -1648,6 +1648,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
if (!song.noSlidesOnFirstTick || !firstTick) { if (!song.noSlidesOnFirstTick || !firstTick) {
if (chan[i].volSpeed!=0) { if (chan[i].volSpeed!=0) {
chan[i].volume=(chan[i].volume&0xff)|(dispatchCmd(DivCommand(DIV_CMD_GET_VOLUME,i))<<8); chan[i].volume=(chan[i].volume&0xff)|(dispatchCmd(DivCommand(DIV_CMD_GET_VOLUME,i))<<8);
int preSpeedVol=chan[i].volume;
chan[i].volume+=chan[i].volSpeed; chan[i].volume+=chan[i].volSpeed;
if (chan[i].volSpeedTarget!=-1) { if (chan[i].volSpeedTarget!=-1) {
bool atTarget=false; bool atTarget=false;
@ -1661,7 +1662,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
} }
if (atTarget) { if (atTarget) {
chan[i].volume=chan[i].volSpeedTarget; if (chan[i].volSpeed>0) {
chan[i].volume=MAX(preSpeedVol,chan[i].volSpeedTarget);
} else if (chan[i].volSpeed<0) {
chan[i].volume=MIN(preSpeedVol,chan[i].volSpeedTarget);
}
chan[i].volSpeed=0; chan[i].volSpeed=0;
chan[i].volSpeedTarget=-1; chan[i].volSpeedTarget=-1;
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8)); dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));