Fix another bug in the RLE decompressor, parsing instruments now
This commit is contained in:
parent
9f26257364
commit
9bbd673bfa
|
|
@ -47,10 +47,9 @@ class TFMRLEReader {
|
||||||
tagLenLeft|=(rleTag&0x7F)<<lenShift;
|
tagLenLeft|=(rleTag&0x7F)<<lenShift;
|
||||||
lenShift+=7;
|
lenShift+=7;
|
||||||
logD("RLE tag: %X, len shift: %d, len left: %d",rleTag,lenShift,tagLenLeft);
|
logD("RLE tag: %X, len shift: %d, len left: %d",rleTag,lenShift,tagLenLeft);
|
||||||
|
} while (!(rleTag&0x80));
|
||||||
// sync back since we've already read one character
|
// sync back since we've already read one character
|
||||||
tagLenLeft--;
|
tagLenLeft--;
|
||||||
} while (!(rleTag&0x80));
|
|
||||||
inTag=true;
|
inTag=true;
|
||||||
tagChar=prevChar;
|
tagChar=prevChar;
|
||||||
}
|
}
|
||||||
|
|
@ -133,6 +132,10 @@ public:
|
||||||
curSeek+=2;
|
curSeek+=2;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void skip(size_t l) {
|
||||||
|
while (l--) readC();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String TFMparseDate(short date) {
|
String TFMparseDate(short date) {
|
||||||
|
|
@ -225,6 +228,55 @@ bool DivEngine::loadTFM(unsigned char* file, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivInstrument* insMaps[256];
|
||||||
|
|
||||||
|
// instrument names
|
||||||
|
logD("parsing instruments");
|
||||||
|
unsigned char insName[16];
|
||||||
|
int insCount=0;
|
||||||
|
for (int i=0; i<255; i++) {
|
||||||
|
reader.read(insName,16);
|
||||||
|
|
||||||
|
if (memcmp(insName,"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF",16)==0) {
|
||||||
|
logD("instrument unused");
|
||||||
|
insMaps[i]=NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DivInstrument* ins=new DivInstrument;
|
||||||
|
ins->type=DIV_INS_FM;
|
||||||
|
ins->name=String((const char*)insName,strnlen((const char*)insName,16));
|
||||||
|
ds.ins.push_back(ins);
|
||||||
|
insCount++;
|
||||||
|
insMaps[i]=ins;
|
||||||
|
}
|
||||||
|
|
||||||
|
ds.insLen=insCount;
|
||||||
|
|
||||||
|
// instrument data
|
||||||
|
for (int i=0; i<255; i++) {
|
||||||
|
if (!insMaps[i]) {
|
||||||
|
reader.skip(42);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insMaps[i]->fm.alg=reader.readC();
|
||||||
|
insMaps[i]->fm.fb=reader.readC();
|
||||||
|
|
||||||
|
for (int j=0; j<4; j++) {
|
||||||
|
insMaps[i]->fm.op[j].mult=reader.readC();
|
||||||
|
insMaps[i]->fm.op[j].dt=reader.readC();
|
||||||
|
insMaps[i]->fm.op[j].tl=reader.readC()^0x7F;
|
||||||
|
insMaps[i]->fm.op[j].rs=reader.readC();
|
||||||
|
insMaps[i]->fm.op[j].ar=reader.readC()^0x1F;
|
||||||
|
insMaps[i]->fm.op[j].dr=reader.readC()^0x1F;
|
||||||
|
insMaps[i]->fm.op[j].d2r=reader.readC()^0x1F;
|
||||||
|
insMaps[i]->fm.op[j].rr=reader.readC()^0xF;
|
||||||
|
insMaps[i]->fm.op[j].sl=reader.readC();
|
||||||
|
insMaps[i]->fm.op[j].ssgEnv=reader.readC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ds.notes=notes;
|
ds.notes=notes;
|
||||||
BUSY_BEGIN_SOFT;
|
BUSY_BEGIN_SOFT;
|
||||||
saveLock.lock();
|
saveLock.lock();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue