fix song stopping too early

This commit is contained in:
tildearrow 2022-10-22 03:46:39 -05:00
parent b073368b21
commit a8def55d56
3 changed files with 12 additions and 4 deletions

View File

@ -2357,6 +2357,7 @@ void DivEngine::reset() {
speed2=curSubSong->speed2; speed2=curSubSong->speed2;
firstTick=false; firstTick=false;
shallStop=false; shallStop=false;
shallStopSched=false;
nextSpeed=speed1; nextSpeed=speed1;
divider=60; divider=60;
if (curSubSong->customTempo) { if (curSubSong->customTempo) {

View File

@ -328,7 +328,7 @@ class DivEngine {
bool lowQuality; bool lowQuality;
bool playing; bool playing;
bool freelance; bool freelance;
bool shallStop; bool shallStop, shallStopSched;
bool speedAB; bool speedAB;
bool endOfSong; bool endOfSong;
bool consoleMode; bool consoleMode;
@ -1017,6 +1017,7 @@ class DivEngine {
playing(false), playing(false),
freelance(false), freelance(false),
shallStop(false), shallStop(false),
shallStopSched(false),
speedAB(false), speedAB(false),
endOfSong(false), endOfSong(false),
consoleMode(false), consoleMode(false),

View File

@ -844,7 +844,8 @@ void DivEngine::processRow(int i, bool afterDelay) {
break; break;
case 0xff: // stop song case 0xff: // stop song
shallStop=true; shallStopSched=true;
logV("scheduling stop");
break; break;
} }
} }
@ -1132,7 +1133,11 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
tempoAccum-=curSubSong->virtualTempoD; tempoAccum-=curSubSong->virtualTempoD;
if (--ticks<=0) { if (--ticks<=0) {
ret=endOfSong; ret=endOfSong;
if (endOfSong) { if (shallStopSched) {
logV("acknowledging scheduled stop");
shallStop=true;
break;
} else if (endOfSong) {
if (song.loopModality!=2) { if (song.loopModality!=2) {
playSub(true); playSub(true);
} }
@ -1147,7 +1152,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
if (tempoAccum>1023) tempoAccum=1023; if (tempoAccum>1023) tempoAccum=1023;
} }
// process stuff // process stuff
for (int i=0; i<chans; i++) { if (!shallStop) for (int i=0; i<chans; i++) {
if (chan[i].rowDelay>0) { if (chan[i].rowDelay>0) {
if (--chan[i].rowDelay==0) { if (--chan[i].rowDelay==0) {
processRow(i,true); processRow(i,true);
@ -1291,6 +1296,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
sPreview.dir=false; sPreview.dir=false;
ret=true; ret=true;
shallStop=false; shallStop=false;
shallStopSched=false;
return ret; return ret;
} }