Merge pull request #441 from djtuBIG-MaliceX/feature/Moar-patch-bank-support-part3

#79 bonanza - GYB, WOPN and WOPL patch bank loading
This commit is contained in:
tildearrow 2022-05-16 20:47:07 -05:00 committed by GitHub
commit 13532a6c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 792 additions and 165 deletions

View File

@ -1933,13 +1933,13 @@ int DivEngine::addSampleFromFile(const char* path) {
} }
extS+=i; extS+=i;
} }
if (extS==String(".dmc")) { // read as .dmc if (extS==".dmc") { // read as .dmc
size_t len=0; size_t len=0;
DivSample* sample=new DivSample; DivSample* sample=new DivSample;
int sampleCount=(int)song.sample.size(); int sampleCount=(int)song.sample.size();
sample->name=stripPath; sample->name=stripPath;
FILE* f=fopen(path,"rb"); FILE* f=ps_fopen(path,"rb");
if (f==NULL) { if (f==NULL) {
BUSY_END; BUSY_END;
lastError=fmt::sprintf("could not open file! (%s)",strerror(errno)); lastError=fmt::sprintf("could not open file! (%s)",strerror(errno));

View File

@ -397,8 +397,11 @@ class DivEngine {
void loadOPNI(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath); void loadOPNI(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadY12(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath); void loadY12(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadBNK(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath); void loadBNK(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadGYB(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath); void loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadFF(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath); void loadFF(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadWOPL(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadWOPN(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
int loadSampleROM(String path, ssize_t expectedSize, unsigned char*& ret); int loadSampleROM(String path, ssize_t expectedSize, unsigned char*& ret);

File diff suppressed because it is too large Load Diff

View File

@ -170,8 +170,8 @@ String SafeReader::readStringLine() {
unsigned char c; unsigned char c;
if (isEOF()) throw EndOfFileException(this, len); if (isEOF()) throw EndOfFileException(this, len);
while (!isEOF() && (c = readC()) != 0) { while (!isEOF() && (c=readC())!=0) {
if (c=='\r'||c=='\n') { if (c=='\r' || c=='\n') {
break; break;
} }
ret.push_back(c); ret.push_back(c);
@ -179,17 +179,17 @@ String SafeReader::readStringLine() {
return ret; return ret;
} }
String SafeReader::readStringToken(unsigned char delim) { String SafeReader::readStringToken(unsigned char delim, bool stripContiguous) {
String ret; String ret;
unsigned char c; unsigned char c;
if (isEOF()) throw EndOfFileException(this, len); if (isEOF()) throw EndOfFileException(this, len);
while (!isEOF() && (c=readC())!=0) { while (!isEOF() && (c=readC())!=0) {
if (c == '\r' || c == '\n') { if (c=='\r' || c=='\n') {
break; break;
} }
if (c == delim) { if (c==delim) {
if (ret.length() == 0) { if (ret.length()==0 && stripContiguous) {
continue; continue;
} }
break; break;
@ -200,5 +200,6 @@ String SafeReader::readStringToken(unsigned char delim) {
} }
String SafeReader::readStringToken() { String SafeReader::readStringToken() {
return readStringToken(' '); // This will strip LHS whitespace and only return contents after it.
return readStringToken(' ', true);
} }

View File

@ -67,7 +67,7 @@ class SafeReader {
String readString(); String readString();
String readString(size_t len); String readString(size_t len);
String readStringLine(); String readStringLine();
String readStringToken(unsigned char delim); String readStringToken(unsigned char delim, bool stripContiguous);
String readStringToken(); String readStringToken();
inline bool isEOF() { return curSeek >= len; }; inline bool isEOF() { return curSeek >= len; };

View File

@ -1261,9 +1261,25 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir(); if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
hasOpened=fileDialog->openLoad( hasOpened=fileDialog->openLoad(
"Load Instrument", "Load Instrument",
{"compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.opli *.opni *.y12 *.bnk *.ff *.opm", // TODO supply loadable formats in a dynamic, scalable, "DRY" way.
"all files", ".*"}, {"All compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.opli *.opni *.y12 *.bnk *.ff *.gyb *.opm *.wopl *.wopn",
"compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.opli,.opni,.y12,.bnk,.ff,.opm},.*", "Furnace Instrument", "*.fui",
"DefleMask Preset", "*.dmp",
"TFM Music Maker Instrument", "*.tfi",
"VGM Music Maker Instrument", "*.vgi",
"Scream Tracker 3 Instrument", "*.s3i",
"SoundBlaster Instrument", "*.sbi",
"Wohlstand OPL Instrument", "*.opli",
"Wohlstand OPN Instrument", "*.opni",
"Gens KMod Patch Dump", "*.y12",
"BNK File (Adlib)", "*.bnk",
"FF Preset Bank", "*.ff",
"2612edit GYB Preset Bank", "*.gyb",
"VOPM Preset Bank", "*.opm",
"Wohlstand WOPL Bank", "*.wopl",
"Wohlstand WOPN Bank", "*.wopn",
"All files", ".*"},
"All compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.opli,.opni,.y12,.bnk,.ff,.gyb,.opm,.wopl,.wopn},.*",
workingDirIns, workingDirIns,
dpiScale, dpiScale,
[this](const char* path) { [this](const char* path) {