fix walkSong
This commit is contained in:
parent
187653a70f
commit
a99f1bd8a0
|
@ -147,37 +147,68 @@ void DivEngine::walkSong(int& loopOrder, int& loopRow, int& loopEnd) {
|
||||||
int nextOrder=-1;
|
int nextOrder=-1;
|
||||||
int nextRow=0;
|
int nextRow=0;
|
||||||
int effectVal=0;
|
int effectVal=0;
|
||||||
|
int lastSuspectedLoopEnd=-1;
|
||||||
DivPattern* pat[DIV_MAX_CHANS];
|
DivPattern* pat[DIV_MAX_CHANS];
|
||||||
|
unsigned char wsWalked[8192];
|
||||||
|
memset(wsWalked,0,8192);
|
||||||
for (int i=0; i<curSubSong->ordersLen; i++) {
|
for (int i=0; i<curSubSong->ordersLen; i++) {
|
||||||
for (int j=0; j<chans; j++) {
|
for (int j=0; j<chans; j++) {
|
||||||
pat[j]=curPat[j].getPattern(curOrders->ord[j][i],false);
|
pat[j]=curPat[j].getPattern(curOrders->ord[j][i],false);
|
||||||
}
|
}
|
||||||
|
if (i>lastSuspectedLoopEnd) {
|
||||||
|
lastSuspectedLoopEnd=i;
|
||||||
|
}
|
||||||
for (int j=nextRow; j<curSubSong->patLen; j++) {
|
for (int j=nextRow; j<curSubSong->patLen; j++) {
|
||||||
nextRow=0;
|
nextRow=0;
|
||||||
|
bool changingOrder=false;
|
||||||
|
bool jumpingOrder=false;
|
||||||
|
if (wsWalked[((i<<5)+(j>>3))&8191]&(1<<(j&7))) {
|
||||||
|
loopOrder=i;
|
||||||
|
loopRow=j;
|
||||||
|
loopEnd=lastSuspectedLoopEnd;
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int k=0; k<chans; k++) {
|
for (int k=0; k<chans; k++) {
|
||||||
for (int l=0; l<curPat[k].effectCols; l++) {
|
for (int l=0; l<curPat[k].effectCols; l++) {
|
||||||
effectVal=pat[k]->data[j][5+(l<<1)];
|
effectVal=pat[k]->data[j][5+(l<<1)];
|
||||||
if (effectVal<0) effectVal=0;
|
if (effectVal<0) effectVal=0;
|
||||||
if (pat[k]->data[j][4+(l<<1)]==0x0d) {
|
if (pat[k]->data[j][4+(l<<1)]==0x0d) {
|
||||||
|
if (song.jumpTreatment==2) {
|
||||||
|
if ((i<curSubSong->ordersLen-1 || !song.ignoreJumpAtEnd)) {
|
||||||
|
nextOrder=i+1;
|
||||||
|
nextRow=effectVal;
|
||||||
|
jumpingOrder=true;
|
||||||
|
}
|
||||||
|
} else if (song.jumpTreatment==1) {
|
||||||
if (nextOrder==-1 && (i<curSubSong->ordersLen-1 || !song.ignoreJumpAtEnd)) {
|
if (nextOrder==-1 && (i<curSubSong->ordersLen-1 || !song.ignoreJumpAtEnd)) {
|
||||||
nextOrder=i+1;
|
nextOrder=i+1;
|
||||||
nextRow=effectVal;
|
nextRow=effectVal;
|
||||||
|
jumpingOrder=true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((i<curSubSong->ordersLen-1 || !song.ignoreJumpAtEnd)) {
|
||||||
|
if (!changingOrder) {
|
||||||
|
nextOrder=i+1;
|
||||||
|
}
|
||||||
|
jumpingOrder=true;
|
||||||
|
nextRow=effectVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (pat[k]->data[j][4+(l<<1)]==0x0b) {
|
} else if (pat[k]->data[j][4+(l<<1)]==0x0b) {
|
||||||
if (nextOrder==-1) {
|
if (nextOrder==-1 || song.jumpTreatment==0) {
|
||||||
nextOrder=effectVal;
|
nextOrder=effectVal;
|
||||||
|
if (song.jumpTreatment==1 || song.jumpTreatment==2 || !jumpingOrder) {
|
||||||
nextRow=0;
|
nextRow=0;
|
||||||
}
|
}
|
||||||
|
changingOrder=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wsWalked[((i<<5)+(j>>3))&8191]|=1<<(j&7);
|
||||||
|
|
||||||
if (nextOrder!=-1) {
|
if (nextOrder!=-1) {
|
||||||
if (nextOrder<=i) {
|
|
||||||
loopOrder=nextOrder;
|
|
||||||
loopRow=nextRow;
|
|
||||||
loopEnd=i;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
i=nextOrder-1;
|
i=nextOrder-1;
|
||||||
nextOrder=-1;
|
nextOrder=-1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue