From bacf57bb6502ce5c186db3c0e7c855ae3a4644b1 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 17 Feb 2022 03:15:51 -0500 Subject: [PATCH] add stop song effect! finally! --- src/engine/engine.cpp | 2 +- src/engine/playback.cpp | 10 +++++++++- src/gui/gui.cpp | 19 ++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 270d77b5b..8e88df545 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1458,7 +1458,7 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan) { case 0xef: return "EFxx: Set global tuning (quirky!)"; case 0xff: - return "FFxx: Stop song (not implemented yet)"; + return "FFxx: Stop song"; default: if (chan>=0 && changetEffectName(effect); diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 9df662309..ed99a31e5 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -738,7 +738,15 @@ void DivEngine::processRow(int i, bool afterDelay) { case 0xef: // global pitch globalPitch+=(signed char)(effectVal-0x80); break; - case 0xff: // stop song TODO + case 0xff: // stop song + freelance=false; + playing=false; + extValuePresent=false; + stepPlay=0; + remainingLoops=-1; + sPreview.sample=-1; + sPreview.wave=-1; + sPreview.pos=0; break; } } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0338634db..a1b2a544e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3575,9 +3575,12 @@ void FurnaceGUI::drawPattern() { if (i.cmd==DIV_CMD_PITCH) continue; if (i.cmd==DIV_CMD_NOTE_PORTA) continue; //if (i.cmd==DIV_CMD_NOTE_ON) continue; + if (i.cmd==DIV_CMD_PRE_PORTA) continue; if (i.cmd==DIV_CMD_PRE_NOTE) continue; if (i.cmd==DIV_CMD_INSTRUMENT) continue; if (i.cmd==DIV_CMD_SAMPLE_BANK) continue; + if (i.cmd==DIV_CMD_GET_VOLUME) continue; + if (i.cmd==DIV_ALWAYS_SET_VOLUME) continue; float width=patChanX[i.chan+1]-patChanX[i.chan]; float speedX=0.0f; @@ -3613,12 +3616,16 @@ void FurnaceGUI::drawPattern() { life=24.0f; lifeSpeed=4.0f; break; - case DIV_CMD_VOLUME: - speedY=-18.0f-(10.0f*((float)i.value/(float)e->getMaxVolumeChan(i.chan))); + case DIV_CMD_VOLUME: { + float scaledVol=(float)i.value/(float)e->getMaxVolumeChan(i.chan); + if (scaledVol>1.0f) scaledVol=1.0f; + speedY=-18.0f-(10.0f*scaledVol); + life=128+scaledVol*127; partIcon=ICON_FA_VOLUME_UP; - num=12.0f*((float)i.value/(float)e->getMaxVolumeChan(i.chan)); + num=12.0f*pow(scaledVol,2.0); color=volGrad; break; + } case DIV_CMD_PANNING: { if (i.value==0) { num=0; @@ -3653,6 +3660,7 @@ void FurnaceGUI::drawPattern() { num=10+pow(i.value,0.6); break; default: + //printf("unhandled %d\n",i.cmd); color=sysCmd1Grad; break; } @@ -3663,8 +3671,8 @@ void FurnaceGUI::drawPattern() { partIcon, off.x+patChanX[i.chan]+fmod(rand(),width), off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize), - speedX+randRange(-spread,spread), - speedY+randRange(-spread,spread), + (speedX+randRange(-spread,spread))*0.5*dpiScale, + (speedY+randRange(-spread,spread))*0.5*dpiScale, grav, frict, life-randRange(0,8), @@ -3736,6 +3744,7 @@ void FurnaceGUI::drawPattern() { for (size_t i=0; i255) part.life=255; fdl->AddText( iconFont, iconFont->FontSize,