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();

View file

@ -4630,9 +4630,13 @@ void FurnaceGUI::doRedo() {
redoHist.pop_back();
}
void FurnaceGUI::play() {
void FurnaceGUI::play(int row) {
e->walkSong(loopOrder,loopRow,loopEnd);
e->play();
if (row>0) {
e->playToRow(row);
} else {
e->play();
}
curNibble=false;
orderNibble=false;
activeNotes.clear();
@ -4726,7 +4730,9 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
play();
break;
case SDLK_F7:
play();
if (!e->isPlaying()) {
play(cursor.y);
}
break;
case SDLK_F8:
stop();
@ -4755,7 +4761,11 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
if (e->isPlaying()) {
stop();
} else {
play();
if (ev.key.keysym.mod&KMOD_SHIFT) {
play(cursor.y);
} else {
play();
}
}
break;
}

View file

@ -383,7 +383,7 @@ class FurnaceGUI {
void doUndo();
void doRedo();
void play();
void play(int row=0);
void stop();
void previewNote(int refChan, int note);