GUI: add ability to play from cursor position

Shift-Enter or F7
This commit is contained in:
tildearrow 2022-02-06 00:07:35 -05:00
parent 9091081b9f
commit 107187a20c
4 changed files with 33 additions and 8 deletions

View file

@ -4748,7 +4748,7 @@ void* DivEngine::getDispatchChanState(int ch) {
return disCont[dispatchOfChan[ch]].dispatch->getChanState(dispatchChanOfChan[ch]);
}
void DivEngine::playSub(bool preserveDrift) {
void DivEngine::playSub(bool preserveDrift, int goalRow) {
reset();
if (preserveDrift && curOrder==0) return;
bool oldRepeatPattern=repeatPattern;
@ -4774,8 +4774,13 @@ void DivEngine::playSub(bool preserveDrift) {
while (curOrder<goal) {
if (nextTick(preserveDrift)) break;
}
int oldOrder=curOrder;
while (curRow<goalRow) {
if (nextTick(preserveDrift)) break;
if (oldOrder!=curOrder) break;
}
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->setSkipRegisterWrites(false);
if (goal>0) {
if (goal>0 || goalRow>0) {
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->forceIns();
}
repeatPattern=oldRepeatPattern;
@ -4815,6 +4820,13 @@ void DivEngine::play() {
isBusy.unlock();
}
void DivEngine::playToRow(int row) {
isBusy.lock();
freelance=false;
playSub(false,row);
isBusy.unlock();
}
void DivEngine::stop() {
isBusy.lock();
freelance=false;

View file

@ -206,7 +206,7 @@ class DivEngine {
void recalcChans();
void renderSamples();
void reset();
void playSub(bool preserveDrift);
void playSub(bool preserveDrift, int goalRow=0);
bool loadDMF(unsigned char* file, size_t len);
bool loadFur(unsigned char* file, size_t len);
@ -285,6 +285,9 @@ class DivEngine {
// play
void play();
// play to row
void playToRow(int row);
// stop
void stop();