VGM export: fix song end effect hang

This commit is contained in:
tildearrow 2022-02-20 23:13:52 -05:00
parent 8e17f20de2
commit 1f6d44b29a

View file

@ -977,7 +977,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
writeLoop=true; writeLoop=true;
} }
} }
if (nextTick()) { if (nextTick() || !playing) {
done=true; done=true;
if (!loop) { if (!loop) {
for (int i=0; i<song.systemLen; i++) { for (int i=0; i<song.systemLen; i++) {
@ -991,6 +991,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
w->writeC(i); w->writeC(i);
loopSample[i]=-1; loopSample[i]=-1;
} }
if (!playing) {
writeLoop=false;
loopPos=-1;
}
} }
// get register dumps // get register dumps
for (int i=0; i<song.systemLen; i++) { for (int i=0; i<song.systemLen; i++) {
@ -1126,8 +1131,13 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
w->writeI(gd3Off-0x14); w->writeI(gd3Off-0x14);
w->writeI(tickCount); w->writeI(tickCount);
if (loop) { if (loop) {
if (loopPos==-1) {
w->writeI(0);
w->writeI(0);
} else {
w->writeI(loopPos-0x1c); w->writeI(loopPos-0x1c);
w->writeI(tickCount-loopTick-1); w->writeI(tickCount-loopTick-1);
}
} else { } else {
w->writeI(0); w->writeI(0);
w->writeI(0); w->writeI(0);