mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-05 04:15:05 +00:00
HOTFIX: Better token handling and simplify clear string comparisons
This commit is contained in:
parent
744735cca8
commit
df1cb0e7fa
3 changed files with 11 additions and 12 deletions
|
@ -1040,11 +1040,10 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
ins->type = DIV_INS_FM;
|
||||
ins->fm.ops = 4;
|
||||
|
||||
// TODO 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
|
||||
|
||||
uint8_t tmp;
|
||||
|
||||
for (int i : opOrder) {
|
||||
tmp = reader.readC(); // MUL/DT
|
||||
ins->fm.op[i].mult = tmp & 0xF;
|
||||
|
@ -1254,7 +1253,7 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
|
||||
// Read each line for their respective params. They may not be written in the same LINE order but they
|
||||
// must absolutely be properly grouped per patch! Line prefixes must be separated by a space! (see inline comments)
|
||||
// must absolutely be properly grouped per patch! Line prefixes MUST be separated by a space! (see inline comments)
|
||||
|
||||
if (token.size() >= 2) {
|
||||
if (token[0] == '@') {
|
||||
|
@ -1264,7 +1263,7 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
newPatch->name = newPatch->name.size() > 0 ? newPatch->name : fmt::sprintf("%s[%d]", stripPath, readCount);
|
||||
patchNameRead = true;
|
||||
|
||||
} else if (token.compare(0,3,"CH:") == 0) {
|
||||
} else if (token == "CH:") {
|
||||
// CH: PAN FL CON AMS PMS SLOT NE
|
||||
reader.readStringToken(); // skip PAN
|
||||
newPatch->fm.fb = readIntStrWithinRange(reader.readStringToken(), 0, 7);
|
||||
|
@ -1275,22 +1274,22 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
reader.readStringToken(); // skip NE
|
||||
characteristicRead = true;
|
||||
|
||||
} else if (token.compare(0,3,"C1:") == 0) {
|
||||
} else if (token == "C1:") {
|
||||
// C1: AR D1R D2R RR D1L TL KS MUL DT1 DT2 AMS-EN
|
||||
readOpmOperator(reader, newPatch->fm.op[2]);
|
||||
c1Read = true;
|
||||
|
||||
} else if (token.compare(0,3,"C2:") == 0) {
|
||||
} else if (token == "C2:") {
|
||||
// C2: AR D1R D2R RR D1L TL KS MUL DT1 DT2 AMS-EN
|
||||
readOpmOperator(reader, newPatch->fm.op[3]);
|
||||
c2Read = true;
|
||||
|
||||
} else if (token.compare(0,3,"M1:") == 0) {
|
||||
} else if (token == "M1:") {
|
||||
// M1: AR D1R D2R RR D1L TL KS MUL DT1 DT2 AMS-EN
|
||||
readOpmOperator(reader, newPatch->fm.op[0]);
|
||||
m1Read = true;
|
||||
|
||||
} else if (token.compare(0,3,"M2:") == 0) {
|
||||
} else if (token == "M2:") {
|
||||
// M2: AR D1R D2R RR D1L TL KS MUL DT1 DT2 AMS-EN
|
||||
readOpmOperator(reader, newPatch->fm.op[1]);
|
||||
m2Read = true;
|
||||
|
|
|
@ -179,7 +179,7 @@ String SafeReader::readStringLine() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
String SafeReader::readStringToken(unsigned char delim) {
|
||||
String SafeReader::readStringToken(unsigned char delim, bool stripContiguous) {
|
||||
String ret;
|
||||
unsigned char c;
|
||||
if (isEOF()) throw EndOfFileException(this, len);
|
||||
|
@ -189,7 +189,7 @@ String SafeReader::readStringToken(unsigned char delim) {
|
|||
break;
|
||||
}
|
||||
if (c == delim) {
|
||||
if (ret.length() == 0) {
|
||||
if (ret.length() == 0 && stripContiguous) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@ -200,5 +200,5 @@ String SafeReader::readStringToken(unsigned char delim) {
|
|||
}
|
||||
|
||||
String SafeReader::readStringToken() {
|
||||
return readStringToken(' ');
|
||||
return readStringToken(' ', true);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class SafeReader {
|
|||
String readString();
|
||||
String readString(size_t len);
|
||||
String readStringLine();
|
||||
String readStringToken(unsigned char delim);
|
||||
String readStringToken(unsigned char delim, bool stripContiguous);
|
||||
String readStringToken();
|
||||
inline bool isEOF() { return curSeek >= len; };
|
||||
|
||||
|
|
Loading…
Reference in a new issue