fix song stop screwing everything up

This commit is contained in:
tildearrow 2022-09-29 00:27:40 -05:00
parent 9f2cb1450f
commit 6ed50d717c
3 changed files with 20 additions and 9 deletions

View File

@ -401,6 +401,7 @@ void writePackedCommandValues(SafeWriter* w, const DivCommand& c) {
SafeWriter* DivEngine::saveCommand(bool binary) { SafeWriter* DivEngine::saveCommand(bool binary) {
stop(); stop();
repeatPattern=false; repeatPattern=false;
shallStop=false;
setOrder(0); setOrder(0);
BUSY_BEGIN_SOFT; BUSY_BEGIN_SOFT;
// determine loop point // determine loop point
@ -1873,6 +1874,7 @@ void DivEngine::play() {
sPreview.wave=-1; sPreview.wave=-1;
sPreview.pos=0; sPreview.pos=0;
sPreview.dir=false; sPreview.dir=false;
shallStop=false;
if (stepPlay==0) { if (stepPlay==0) {
freelance=false; freelance=false;
playSub(false); playSub(false);
@ -2031,6 +2033,7 @@ void DivEngine::reset() {
speed1=curSubSong->speed1; speed1=curSubSong->speed1;
speed2=curSubSong->speed2; speed2=curSubSong->speed2;
firstTick=false; firstTick=false;
shallStop=false;
nextSpeed=speed1; nextSpeed=speed1;
divider=60; divider=60;
if (curSubSong->customTempo) { if (curSubSong->customTempo) {

View File

@ -327,6 +327,7 @@ class DivEngine {
bool lowQuality; bool lowQuality;
bool playing; bool playing;
bool freelance; bool freelance;
bool shallStop;
bool speedAB; bool speedAB;
bool endOfSong; bool endOfSong;
bool consoleMode; bool consoleMode;
@ -998,6 +999,7 @@ class DivEngine {
lowQuality(false), lowQuality(false),
playing(false), playing(false),
freelance(false), freelance(false),
shallStop(false),
speedAB(false), speedAB(false),
endOfSong(false), endOfSong(false),
consoleMode(false), consoleMode(false),

View File

@ -844,15 +844,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
break; break;
case 0xff: // stop song case 0xff: // stop song
freelance=false; shallStop=true;
playing=false;
extValuePresent=false;
stepPlay=0;
remainingLoops=-1;
sPreview.sample=-1;
sPreview.wave=-1;
sPreview.pos=0;
sPreview.dir=false;
break; break;
} }
} }
@ -1285,6 +1277,20 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
firstTick=false; firstTick=false;
if (shallStop) {
freelance=false;
playing=false;
extValuePresent=false;
stepPlay=0;
remainingLoops=-1;
sPreview.sample=-1;
sPreview.wave=-1;
sPreview.pos=0;
sPreview.dir=false;
ret=true;
return ret;
}
// system tick // system tick
for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->tick(subticks==tickMult); for (int i=0; i<song.systemLen; i++) disCont[i].dispatch->tick(subticks==tickMult);