diff --git a/src/engine/cmdStream.cpp b/src/engine/cmdStream.cpp index 40542ef98..f1b267869 100644 --- a/src/engine/cmdStream.cpp +++ b/src/engine/cmdStream.cpp @@ -364,6 +364,7 @@ bool DivCSPlayer::tick() { } if (sendVolume || chan[i].volSpeed!=0) { + int preSpeedVol=chan[i].volume; chan[i].volume+=chan[i].volSpeed; if (chan[i].volSpeedTarget!=-1) { bool atTarget=false; @@ -377,7 +378,11 @@ bool DivCSPlayer::tick() { } 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].volSpeedTarget=-1; } diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index c1e14109e..2dcb838fb 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1648,6 +1648,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) { if (!song.noSlidesOnFirstTick || !firstTick) { if (chan[i].volSpeed!=0) { 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; if (chan[i].volSpeedTarget!=-1) { bool atTarget=false; @@ -1661,7 +1662,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) { } 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].volSpeedTarget=-1; dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));