parent
13c63f60bb
commit
e495c8d990
2 changed files with 125 additions and 124 deletions
|
|
@ -618,13 +618,14 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
|
||||
unsigned short dataLen=reader.readS();
|
||||
unsigned int dataEnd=reader.tell()+dataLen;
|
||||
int readRow=0;
|
||||
|
||||
while (reader.tell()<dataEnd) {
|
||||
unsigned char what=reader.readC();
|
||||
|
||||
if (what==0) {
|
||||
curRow++;
|
||||
if (curRow>=64) break;
|
||||
readRow++;
|
||||
if (readRow>=64) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -711,10 +712,10 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
|
||||
unsigned short dataLen=reader.readS();
|
||||
unsigned int dataEnd=reader.tell()+dataLen;
|
||||
int readRow=0;
|
||||
|
||||
logV("length: %d",dataLen);
|
||||
|
||||
int curRow=0;
|
||||
bool mustCommitInitial=true;
|
||||
|
||||
memset(effectCol,4,32);
|
||||
|
|
@ -745,55 +746,55 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
for (int j=0; j<32; j++) {
|
||||
DivPattern* p=ds.subsong[0]->pat[chanMap[j]].getPattern(i,true);
|
||||
if (vibing[j]!=vibingOld[j] || vibStatusChanged[j]) {
|
||||
p->data[curRow][effectCol[j]++]=0x04;
|
||||
p->data[curRow][effectCol[j]++]=vibing[j]?vibStatus[j]:0;
|
||||
p->data[readRow][effectCol[j]++]=0x04;
|
||||
p->data[readRow][effectCol[j]++]=vibing[j]?vibStatus[j]:0;
|
||||
doesVibrato[j]=true;
|
||||
} else if (doesVibrato[j] && mustCommitInitial) {
|
||||
p->data[curRow][effectCol[j]++]=0x04;
|
||||
p->data[curRow][effectCol[j]++]=0;
|
||||
p->data[readRow][effectCol[j]++]=0x04;
|
||||
p->data[readRow][effectCol[j]++]=0;
|
||||
}
|
||||
|
||||
if (volSliding[j]!=volSlidingOld[j] || volSlideStatusChanged[j]) {
|
||||
if (volSlideStatus[j]>=0xf1 && volSliding[j]) {
|
||||
p->data[curRow][effectCol[j]++]=0xf9;
|
||||
p->data[curRow][effectCol[j]++]=volSlideStatus[j]&15;
|
||||
p->data[readRow][effectCol[j]++]=0xf9;
|
||||
p->data[readRow][effectCol[j]++]=volSlideStatus[j]&15;
|
||||
volSliding[j]=false;
|
||||
} else if ((volSlideStatus[j]&15)==15 && volSlideStatus[j]>=0x10 && volSliding[j]) {
|
||||
p->data[curRow][effectCol[j]++]=0xf8;
|
||||
p->data[curRow][effectCol[j]++]=volSlideStatus[j]>>4;
|
||||
p->data[readRow][effectCol[j]++]=0xf8;
|
||||
p->data[readRow][effectCol[j]++]=volSlideStatus[j]>>4;
|
||||
volSliding[j]=false;
|
||||
} else {
|
||||
p->data[curRow][effectCol[j]++]=0xfa;
|
||||
p->data[curRow][effectCol[j]++]=volSliding[j]?volSlideStatus[j]:0;
|
||||
p->data[readRow][effectCol[j]++]=0xfa;
|
||||
p->data[readRow][effectCol[j]++]=volSliding[j]?volSlideStatus[j]:0;
|
||||
}
|
||||
doesVolSlide[j]=true;
|
||||
} else if (doesVolSlide[j] && mustCommitInitial) {
|
||||
p->data[curRow][effectCol[j]++]=0xfa;
|
||||
p->data[curRow][effectCol[j]++]=0;
|
||||
p->data[readRow][effectCol[j]++]=0xfa;
|
||||
p->data[readRow][effectCol[j]++]=0;
|
||||
}
|
||||
|
||||
if (porting[j]!=portingOld[j] || portaStatusChanged[j]) {
|
||||
if (portaStatus[j]>=0xe0 && portaType[j]!=3 && porting[j]) {
|
||||
p->data[curRow][effectCol[j]++]=portaType[j]|0xf0;
|
||||
p->data[curRow][effectCol[j]++]=(portaStatus[j]&15)*((portaStatus[j]>=0xf0)?1:1);
|
||||
p->data[readRow][effectCol[j]++]=portaType[j]|0xf0;
|
||||
p->data[readRow][effectCol[j]++]=(portaStatus[j]&15)*((portaStatus[j]>=0xf0)?1:1);
|
||||
porting[j]=false;
|
||||
} else {
|
||||
p->data[curRow][effectCol[j]++]=portaType[j];
|
||||
p->data[curRow][effectCol[j]++]=porting[j]?portaStatus[j]:0;
|
||||
p->data[readRow][effectCol[j]++]=portaType[j];
|
||||
p->data[readRow][effectCol[j]++]=porting[j]?portaStatus[j]:0;
|
||||
}
|
||||
doesPitchSlide[j]=true;
|
||||
} else if (doesPitchSlide[j] && mustCommitInitial) {
|
||||
p->data[curRow][effectCol[j]++]=0x01;
|
||||
p->data[curRow][effectCol[j]++]=0;
|
||||
p->data[readRow][effectCol[j]++]=0x01;
|
||||
p->data[readRow][effectCol[j]++]=0;
|
||||
}
|
||||
|
||||
if (arping[j]!=arpingOld[j] || arpStatusChanged[j]) {
|
||||
p->data[curRow][effectCol[j]++]=0x00;
|
||||
p->data[curRow][effectCol[j]++]=arping[j]?arpStatus[j]:0;
|
||||
p->data[readRow][effectCol[j]++]=0x00;
|
||||
p->data[readRow][effectCol[j]++]=arping[j]?arpStatus[j]:0;
|
||||
doesArp[j]=true;
|
||||
} else if (doesArp[j] && mustCommitInitial) {
|
||||
p->data[curRow][effectCol[j]++]=0x00;
|
||||
p->data[curRow][effectCol[j]++]=0;
|
||||
p->data[readRow][effectCol[j]++]=0x00;
|
||||
p->data[readRow][effectCol[j]++]=0;
|
||||
}
|
||||
|
||||
if (effectCol[j]>=4+8*2) {
|
||||
|
|
@ -805,7 +806,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
curRow++;
|
||||
readRow++;
|
||||
memset(effectCol,4,32);
|
||||
memcpy(vibingOld,vibing,32*sizeof(bool));
|
||||
memcpy(volSlidingOld,volSliding,32*sizeof(bool));
|
||||
|
|
@ -821,7 +822,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
memset(arping,0,32*sizeof(bool));
|
||||
memset(did,0,32);
|
||||
mustCommitInitial=false;
|
||||
if (curRow>=64) break;
|
||||
if (readRow>=64) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -831,7 +832,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
bool hasEffect=what&128;
|
||||
|
||||
if (did[chan]) {
|
||||
logW("pat %d chan %d row %d: we already populated this channel!",i,chan,curRow);
|
||||
logW("pat %d chan %d row %d: we already populated this channel!",i,chan,readRow);
|
||||
} else {
|
||||
did[chan]=true;
|
||||
}
|
||||
|
|
@ -842,22 +843,22 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
unsigned char ins=reader.readC();
|
||||
|
||||
if (note==254) { // note off
|
||||
p->data[curRow][0]=100;
|
||||
p->data[curRow][1]=0;
|
||||
p->data[readRow][0]=100;
|
||||
p->data[readRow][1]=0;
|
||||
} else if (note!=255) {
|
||||
p->data[curRow][0]=note&15;
|
||||
p->data[curRow][1]=note>>4;
|
||||
p->data[readRow][0]=note&15;
|
||||
p->data[readRow][1]=note>>4;
|
||||
if ((note&15)==0) {
|
||||
p->data[curRow][0]=12;
|
||||
p->data[curRow][1]--;
|
||||
p->data[readRow][0]=12;
|
||||
p->data[readRow][1]--;
|
||||
}
|
||||
}
|
||||
p->data[curRow][2]=(short)ins-1;
|
||||
p->data[readRow][2]=(short)ins-1;
|
||||
}
|
||||
if (hasVol) {
|
||||
unsigned char vol=reader.readC();
|
||||
if (vol==255) {
|
||||
p->data[curRow][3]=-1;
|
||||
p->data[readRow][3]=-1;
|
||||
} else {
|
||||
// check for OPL channel
|
||||
if ((chanSettings[chan]&31)>=16) {
|
||||
|
|
@ -865,17 +866,17 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
} else {
|
||||
if (vol>64) vol=64;
|
||||
}
|
||||
p->data[curRow][3]=vol;
|
||||
p->data[readRow][3]=vol;
|
||||
}
|
||||
} else if (p->data[curRow][2]!=-1) {
|
||||
} else if (p->data[readRow][2]!=-1) {
|
||||
// populate with instrument volume
|
||||
unsigned char vol=defVol[p->data[curRow][2]&255];
|
||||
unsigned char vol=defVol[p->data[readRow][2]&255];
|
||||
if ((chanSettings[chan]&31)>=16) {
|
||||
if (vol>63) vol=63;
|
||||
} else {
|
||||
if (vol>64) vol=64;
|
||||
}
|
||||
p->data[curRow][3]=vol;
|
||||
p->data[readRow][3]=vol;
|
||||
}
|
||||
if (hasEffect) {
|
||||
unsigned char effect=reader.readC();
|
||||
|
|
@ -883,17 +884,17 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
|
||||
switch (effect+'A'-1) {
|
||||
case 'A': // speed
|
||||
p->data[curRow][effectCol[chan]++]=0x0f;
|
||||
p->data[curRow][effectCol[chan]++]=effectVal;
|
||||
p->data[readRow][effectCol[chan]++]=0x0f;
|
||||
p->data[readRow][effectCol[chan]++]=effectVal;
|
||||
break;
|
||||
case 'B': // go to order
|
||||
p->data[curRow][effectCol[chan]++]=0x0b;
|
||||
p->data[readRow][effectCol[chan]++]=0x0b;
|
||||
logD("0B: %x %x",effectVal,orders[effectVal]);
|
||||
p->data[curRow][effectCol[chan]++]=orders[effectVal];
|
||||
p->data[readRow][effectCol[chan]++]=orders[effectVal];
|
||||
break;
|
||||
case 'C': // next order
|
||||
p->data[curRow][effectCol[chan]++]=0x0d;
|
||||
p->data[curRow][effectCol[chan]++]=(effectVal>>4)*10+(effectVal&15);
|
||||
p->data[readRow][effectCol[chan]++]=0x0d;
|
||||
p->data[readRow][effectCol[chan]++]=(effectVal>>4)*10+(effectVal&15);
|
||||
break;
|
||||
case 'D': // vol slide
|
||||
if (effectVal!=0) {
|
||||
|
|
@ -985,32 +986,32 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
case 'N': // channel vol slide (extension)
|
||||
break;
|
||||
case 'O': // offset
|
||||
p->data[curRow][effectCol[chan]++]=0x91;
|
||||
p->data[curRow][effectCol[chan]++]=effectVal;
|
||||
p->data[readRow][effectCol[chan]++]=0x91;
|
||||
p->data[readRow][effectCol[chan]++]=effectVal;
|
||||
break;
|
||||
case 'P': // pan slide (extension)
|
||||
break;
|
||||
case 'Q': // retrigger
|
||||
p->data[curRow][effectCol[chan]++]=0x0c;
|
||||
p->data[curRow][effectCol[chan]++]=effectVal&15;
|
||||
p->data[readRow][effectCol[chan]++]=0x0c;
|
||||
p->data[readRow][effectCol[chan]++]=effectVal&15;
|
||||
break;
|
||||
case 'R': // tremolo
|
||||
break;
|
||||
case 'S': // special...
|
||||
switch (effectVal>>4) {
|
||||
case 0xc:
|
||||
p->data[curRow][effectCol[chan]++]=0xec;
|
||||
p->data[curRow][effectCol[chan]++]=effectVal&15;
|
||||
p->data[readRow][effectCol[chan]++]=0xec;
|
||||
p->data[readRow][effectCol[chan]++]=effectVal&15;
|
||||
break;
|
||||
case 0xd:
|
||||
p->data[curRow][effectCol[chan]++]=0xed;
|
||||
p->data[curRow][effectCol[chan]++]=effectVal&15;
|
||||
p->data[readRow][effectCol[chan]++]=0xed;
|
||||
p->data[readRow][effectCol[chan]++]=effectVal&15;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'T': // tempo
|
||||
p->data[curRow][effectCol[chan]++]=0xf0;
|
||||
p->data[curRow][effectCol[chan]++]=effectVal;
|
||||
p->data[readRow][effectCol[chan]++]=0xf0;
|
||||
p->data[readRow][effectCol[chan]++]=effectVal;
|
||||
break;
|
||||
case 'U': // fine vibrato
|
||||
if (effectVal!=0) {
|
||||
|
|
@ -1025,8 +1026,8 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
break;
|
||||
case 'X': // panning (extension)
|
||||
if (effectVal<=0x80) {
|
||||
p->data[curRow][effectCol[chan]++]=0x80;
|
||||
p->data[curRow][effectCol[chan]++]=(effectVal&0x80)?0xff:(effectVal<<1);
|
||||
p->data[readRow][effectCol[chan]++]=0x80;
|
||||
p->data[readRow][effectCol[chan]++]=(effectVal&0x80)?0xff:(effectVal<<1);
|
||||
}
|
||||
break;
|
||||
case 'Y': // panbrello (extension)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue