mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-30 16:33:01 +00:00
Fix GYBv1/2 instrument name read
This commit is contained in:
parent
f720e0af47
commit
c9f289e44a
1 changed files with 22 additions and 21 deletions
|
@ -1024,9 +1024,9 @@ void DivEngine::loadFF(SafeReader& reader, std::vector<DivInstrument*>& ret, Str
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < insCount; ++i) {
|
for (unsigned int i = 0; i < insCount; ++i) {
|
||||||
ret.push_back(insList[i]);
|
ret.push_back(insList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath) {
|
void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath) {
|
||||||
|
@ -1035,7 +1035,7 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
int readCount = 0;
|
int readCount = 0;
|
||||||
bool is_failed = false;
|
bool is_failed = false;
|
||||||
auto readInstrument = [](SafeReader& reader, bool readRegB4) -> DivInstrument* {
|
auto readInstrument = [](SafeReader& reader, bool readRegB4) -> DivInstrument* {
|
||||||
const int opOrder[] = {0,2,1,3};
|
const int opOrder[] = { 0,2,1,3 };
|
||||||
DivInstrument* ins = new DivInstrument;
|
DivInstrument* ins = new DivInstrument;
|
||||||
ins->type = DIV_INS_FM;
|
ins->type = DIV_INS_FM;
|
||||||
ins->fm.ops = 4;
|
ins->fm.ops = 4;
|
||||||
|
@ -1047,7 +1047,7 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // MUL/DT
|
tmp = reader.readC(); // MUL/DT
|
||||||
ins->fm.op[i].mult = tmp & 0xF;
|
ins->fm.op[i].mult = tmp & 0xF;
|
||||||
ins->fm.op[i].dt = ((tmp>>4) & 0x7);
|
ins->fm.op[i].dt = ((tmp >> 4) & 0x7);
|
||||||
}
|
}
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // TL
|
tmp = reader.readC(); // TL
|
||||||
|
@ -1056,12 +1056,12 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // AR/RS
|
tmp = reader.readC(); // AR/RS
|
||||||
ins->fm.op[i].ar = tmp & 0x1F;
|
ins->fm.op[i].ar = tmp & 0x1F;
|
||||||
ins->fm.op[i].rs = ((tmp>>6) & 0x3);
|
ins->fm.op[i].rs = ((tmp >> 6) & 0x3);
|
||||||
}
|
}
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // DR/AM-ENA
|
tmp = reader.readC(); // DR/AM-ENA
|
||||||
ins->fm.op[i].dr = tmp & 0x1F;
|
ins->fm.op[i].dr = tmp & 0x1F;
|
||||||
ins->fm.op[i].am = ((tmp>>7) & 0x1);
|
ins->fm.op[i].am = ((tmp >> 7) & 0x1);
|
||||||
}
|
}
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // SR (D2R)
|
tmp = reader.readC(); // SR (D2R)
|
||||||
|
@ -1070,7 +1070,7 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // RR/SL
|
tmp = reader.readC(); // RR/SL
|
||||||
ins->fm.op[i].rr = tmp & 0xF;
|
ins->fm.op[i].rr = tmp & 0xF;
|
||||||
ins->fm.op[i].sl = ((tmp>>4) & 0xF);
|
ins->fm.op[i].sl = ((tmp >> 4) & 0xF);
|
||||||
}
|
}
|
||||||
for (int i : opOrder) {
|
for (int i : opOrder) {
|
||||||
tmp = reader.readC(); // SSG-EG
|
tmp = reader.readC(); // SSG-EG
|
||||||
|
@ -1079,12 +1079,12 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
// ALG/FB
|
// ALG/FB
|
||||||
tmp = reader.readC();
|
tmp = reader.readC();
|
||||||
ins->fm.alg = tmp & 0x3;
|
ins->fm.alg = tmp & 0x3;
|
||||||
ins->fm.fb = ((tmp>>3) & 0x3);
|
ins->fm.fb = ((tmp >> 3) & 0x3);
|
||||||
|
|
||||||
if (!readRegB4) { // PAN / PMS / AMS
|
if (!readRegB4) { // PAN / PMS / AMS
|
||||||
tmp = reader.readC();
|
tmp = reader.readC();
|
||||||
ins->fm.fms = tmp & 0x7;
|
ins->fm.fms = tmp & 0x7;
|
||||||
ins->fm.ams = ((tmp>>4) & 0x3);
|
ins->fm.ams = ((tmp >> 4) & 0x3);
|
||||||
}
|
}
|
||||||
return ins;
|
return ins;
|
||||||
};
|
};
|
||||||
|
@ -1096,7 +1096,7 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
|
|
||||||
if (header == 0x0C1A) { // 26 12 in decimal bytes
|
if (header == 0x0C1A) { // 26 12 in decimal bytes
|
||||||
uint8_t version = reader.readC();
|
uint8_t version = reader.readC();
|
||||||
if ((version^3)>0) { // GYBv1/2
|
if ((version ^ 3) > 0) { // GYBv1/2
|
||||||
insMelodyCount = reader.readC();
|
insMelodyCount = reader.readC();
|
||||||
insDrumCount = reader.readC();
|
insDrumCount = reader.readC();
|
||||||
|
|
||||||
|
@ -1113,23 +1113,25 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instrument data
|
// Instrument data
|
||||||
for (int i = 0; i < (insMelodyCount+insDrumCount); ++i) {
|
for (int i = 0; i < (insMelodyCount + insDrumCount); ++i) {
|
||||||
// TODO determine if a patch is 'empty' -> ignore and move on
|
|
||||||
bool isDrum = (i >= insMelodyCount);
|
bool isDrum = (i >= insMelodyCount);
|
||||||
DivInstrument* newIns = readInstrument(reader, (version==2));
|
DivInstrument* newIns = readInstrument(reader, (version == 2));
|
||||||
reader.readC(); // skip transpose
|
reader.readC(); // skip transpose
|
||||||
if (version == 2) {
|
if (version == 2) {
|
||||||
reader.readC(); // skip padding
|
reader.readC(); // skip padding
|
||||||
}
|
}
|
||||||
|
reader.readC();
|
||||||
uint8_t nameLen = reader.readC();
|
|
||||||
String insName = (nameLen > 0) ? reader.readString(nameLen) : fmt::sprintf("%s [%d]", stripPath, readCount);
|
|
||||||
|
|
||||||
newIns->name = insName;
|
|
||||||
insList.push_back(newIns);
|
insList.push_back(newIns);
|
||||||
++readCount;
|
++readCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Instrument name
|
||||||
|
for (int i = 0; i < (insMelodyCount + insDrumCount); ++i) {
|
||||||
|
uint8_t nameLen = reader.readC();
|
||||||
|
String insName = (nameLen > 0) ? reader.readString(nameLen) : fmt::sprintf("%s [%d]", stripPath, readCount);
|
||||||
|
insList[i]->name = insName;
|
||||||
|
}
|
||||||
|
|
||||||
// Map to note assignment currently not supported.
|
// Map to note assignment currently not supported.
|
||||||
|
|
||||||
} else { // GYBv3+
|
} else { // GYBv3+
|
||||||
|
@ -1166,9 +1168,8 @@ void DivEngine::loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
||||||
newIns->name = insName;
|
newIns->name = insName;
|
||||||
insList.push_back(newIns);
|
insList.push_back(newIns);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.seek(0, SEEK_END);
|
|
||||||
}
|
}
|
||||||
|
reader.seek(0, SEEK_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (EndOfFileException& e) {
|
} catch (EndOfFileException& e) {
|
||||||
|
|
Loading…
Reference in a new issue