prepare to fix loading old .dmp files

This commit is contained in:
tildearrow 2022-01-31 12:55:51 -05:00
parent 0da7aaa56e
commit da8380a6e2

View file

@ -4397,18 +4397,30 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
return false;
}
} else { // read as .dmp
// this is a ridiculous mess
unsigned char version=0;
unsigned char sys=0;
try {
reader.seek(0,SEEK_SET);
unsigned char version=reader.readC();
if (version>11) {
lastError="unknown sample version!";
version=reader.readC();
} catch (EndOfFileException e) {
lastError="premature end of file";
logE("premature end of file!\n");
delete ins;
delete[] buf;
return false;
}
unsigned char sys=reader.readC();
if (version>11) {
lastError="unknown instrument version!";
delete ins;
delete[] buf;
return false;
}
if (version>=10) { // 1.0
try {
sys=reader.readC();
switch (sys) {
case 1: // YMU759
@ -4442,7 +4454,16 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
return false;
break;
}
} catch (EndOfFileException e) {
lastError="premature end of file";
logE("premature end of file!\n");
delete ins;
delete[] buf;
return false;
}
}
try {
bool mode=reader.readC();
if (mode==0 && ins->type==DIV_INS_FM) {
ins->type=DIV_INS_STD;