GYBv3 sorta loading... just need to fix up some read issues

This commit is contained in:
James Alan Nguyen 2022-05-08 15:49:33 +10:00
parent 7ae72f0fe4
commit e289ba652d

View file

@ -1045,6 +1045,7 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
// see https://plutiedev.com/ym2612-registers // see https://plutiedev.com/ym2612-registers
// and https://github.com/Wohlstand/OPN2BankEditor/blob/master/Specifications/GYB-file-specification.txt // and https://github.com/Wohlstand/OPN2BankEditor/blob/master/Specifications/GYB-file-specification.txt
try {
uint8_t reg; uint8_t reg;
for (int i : opOrder) { for (int i : opOrder) {
reg = reader.readC(); // MUL/DT reg = reader.readC(); // MUL/DT
@ -1089,6 +1090,12 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
ins->fm.ams = ((reg >> 4) & 0x3); ins->fm.ams = ((reg >> 4) & 0x3);
} }
return ins; return ins;
} catch (...) {
// Deallocate and rethrow to outer handler
delete ins;
throw;
}
}; };
try { try {
@ -1166,10 +1173,13 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
reader.readC(); reader.readC();
} }
} }
reader.readC(); // padding
reader.readC(); // padding
uint8_t nameLen = reader.readC(); uint8_t nameLen = reader.readC();
String insName = (nameLen > 0) ? reader.readString(nameLen) : fmt::sprintf("%s [%d]", stripPath, readCount++); String insName = (nameLen > 0) ? reader.readString(nameLen) : fmt::sprintf("%s [%d]", stripPath, readCount++);
newIns->name = insName; newIns->name = insName;
insList.push_back(newIns); insList.push_back(newIns);
++readCount;
} }
} }
reader.seek(0, SEEK_END); reader.seek(0, SEEK_END);