From 08f1381feeab5a88bda265db828e28964a886b39 Mon Sep 17 00:00:00 2001 From: Adam Lederer Date: Fri, 23 Aug 2024 11:24:24 -0700 Subject: [PATCH] minor cleanup --- src/engine/cmdStream.h | 2 +- src/engine/engine.h | 2 +- src/engine/playback.cpp | 35 ++++++++++++++++------------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/engine/cmdStream.h b/src/engine/cmdStream.h index 33fcdd2cf..2d8e6e97e 100644 --- a/src/engine/cmdStream.h +++ b/src/engine/cmdStream.h @@ -56,7 +56,7 @@ struct DivCSChannelState { volume(0x7f00), volMax(0), volSpeed(0), - volSpeedTarget(0), + volSpeedTarget(-1), vibratoDepth(0), vibratoRate(0), vibratoPos(0), diff --git a/src/engine/engine.h b/src/engine/engine.h index e7788149e..308c6f5cd 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -157,7 +157,7 @@ struct DivChannelState { portaNote(-1), volume(0x7f00), volSpeed(0), - volSpeedTarget(0), + volSpeedTarget(-1), cut(-1), volCut(-1), legatoDelay(-1), diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index e56489f05..2c7e97e0e 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -661,7 +661,6 @@ void DivEngine::processRow(int i, bool afterDelay) { if (pat->data[whatRow][0]==0 && pat->data[whatRow][1]==0) { chan[i].midiAftertouch=true; } - chan[i].volume=pat->data[whatRow][3]<<8; dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8)); dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8)); @@ -962,6 +961,22 @@ void DivEngine::processRow(int i, bool afterDelay) { chan[i].cutType=0; } break; + case 0xd3: // volume portamento (vol porta) + // tremolo and vol slides are incompatible + chan[i].tremoloDepth=0; + chan[i].tremoloRate=0; + chan[i].volSpeed=volPortaTarget<0 ? 0 : volPortaTarget>chan[i].volume ? effectVal : -effectVal; + chan[i].volSpeedTarget=chan[i].volSpeed==0 ? -1 : volPortaTarget; + dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE_TARGET,i,chan[i].volSpeed,chan[i].volSpeedTarget)); + break; + case 0xd4: // volume portamento fast (vol porta fast) + // tremolo and vol slides are incompatible + chan[i].tremoloDepth=0; + chan[i].tremoloRate=0; + chan[i].volSpeed=volPortaTarget<0 ? 0 : volPortaTarget>chan[i].volume ? 256*effectVal : -256*effectVal; + chan[i].volSpeedTarget=chan[i].volSpeed==0 ? -1 : volPortaTarget; + dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE_TARGET,i,chan[i].volSpeed,chan[i].volSpeedTarget)); + break; case 0xe0: // arp speed if (effectVal>0) { curSubSong->arpLen=effectVal; @@ -1149,24 +1164,6 @@ void DivEngine::processRow(int i, bool afterDelay) { chan[i].volSpeedTarget=-1; dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed)); break; - case 0xd3: { // volume portamento (vol porta) - // tremolo and vol slides are incompatible - chan[i].tremoloDepth=0; - chan[i].tremoloRate=0; - chan[i].volSpeed=volPortaTarget<0 ? 0 : volPortaTarget>chan[i].volume ? effectVal : -effectVal; - chan[i].volSpeedTarget=chan[i].volSpeed==0 ? -1 : volPortaTarget; - dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE_TARGET,i,chan[i].volSpeed,chan[i].volSpeedTarget)); - break; - } - case 0xd4: { // volume portamento fast (vol porta fast) - // tremolo and vol slides are incompatible - chan[i].tremoloDepth=0; - chan[i].tremoloRate=0; - chan[i].volSpeed=volPortaTarget<0 ? 0 : volPortaTarget>chan[i].volume ? 256*effectVal : -256*effectVal; - chan[i].volSpeedTarget=chan[i].volSpeed==0 ? -1 : volPortaTarget; - dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE_TARGET,i,chan[i].volSpeed,chan[i].volSpeedTarget)); - break; - } case 0xfc: // delayed note release if (song.delayBehavior==2 || effectVal