From c766f9871977cd2b3ad594eafc5c334667da02c3 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 18 May 2021 02:53:59 -0500 Subject: [PATCH] implement arp speed and arp tick --- src/engine/engine.h | 3 ++- src/engine/platform/genesis.cpp | 2 ++ src/engine/playback.cpp | 33 +++++++++++++++++++++------------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index 29aea64b3..2d0b63605 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -11,7 +11,7 @@ struct DivChannelState { int volume, volSpeed, cut, rowDelay, volMax; int vibratoDepth, vibratoRate, vibratoPos, vibratoDir; int tremoloDepth, tremoloRate, tremoloPos; - unsigned char arp, arpStage; + unsigned char arp, arpStage, arpTicks; bool doNote, legato; DivChannelState(): @@ -32,6 +32,7 @@ struct DivChannelState { tremoloPos(0), arp(0), arpStage(-1), + arpTicks(1), doNote(false), legato(false) {} }; diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 1b2fb87fb..d5e838639 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -331,6 +331,8 @@ int DivPlatformGenesis::dispatch(DivCommand c) { case DIV_CMD_GET_VOLMAX: return 127; break; + case DIV_CMD_PRE_PORTA: + break; default: printf("WARNING: unimplemented command %d\n",c.cmd); break; diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 28f3c8eba..f376d6cfe 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -218,6 +218,9 @@ void DivEngine::processRow(int i, bool afterDelay) { chan[i].rowDelay=effectVal+1; break; + case 0xe0: // arp speed + song.arpLen=effectVal; + break; case 0xe1: // portamento up chan[i].portaNote=chan[i].note+(effectVal&15); chan[i].portaSpeed=(effectVal>>4)*4; @@ -239,6 +242,9 @@ void DivEngine::processRow(int i, bool afterDelay) { case 0xec: // delayed note cut chan[i].cut=effectVal+1; break; + case 0xee: // external command + printf("\x1b[1;36m%d: extern command %d\x1b[m\n",i,effectVal); + break; } } @@ -393,18 +399,21 @@ void DivEngine::nextTick() { } } if (chan[i].arp!=0 && chan[i].portaSpeed<1) { - chan[i].arpStage++; - if (chan[i].arpStage>2) chan[i].arpStage=0; - switch (chan[i].arpStage) { - case 0: - dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note)); - break; - case 1: - dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp>>4))); - break; - case 2: - dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp&15))); - break; + if (--chan[i].arpTicks<1) { + chan[i].arpTicks=song.arpLen; + chan[i].arpStage++; + if (chan[i].arpStage>2) chan[i].arpStage=0; + switch (chan[i].arpStage) { + case 0: + dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note)); + break; + case 1: + dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp>>4))); + break; + case 2: + dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp&15))); + break; + } } } }