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;
}
if (extS==String(".dmc")) { // read as .dmc
if (extS==".dmc") { // read as .dmc
size_t len=0;
DivSample* sample=new DivSample;
int sampleCount=(int)song.sample.size();
sample->name=stripPath;
FILE* f=fopen(path,"rb");
FILE* f=ps_fopen(path,"rb");
if (f==NULL) {
BUSY_END;
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 loadY12(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 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);

File diff suppressed because it is too large Load Diff

View File

@ -170,8 +170,8 @@ String SafeReader::readStringLine() {
unsigned char c;
if (isEOF()) throw EndOfFileException(this, len);
while (!isEOF() && (c = readC()) != 0) {
if (c=='\r'||c=='\n') {
while (!isEOF() && (c=readC())!=0) {
if (c=='\r' || c=='\n') {
break;
}
ret.push_back(c);
@ -179,17 +179,17 @@ 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);
while (!isEOF() && (c=readC())!=0) {
if (c == '\r' || c == '\n') {
if (c=='\r' || c=='\n') {
break;
}
if (c == delim) {
if (ret.length() == 0) {
if (c==delim) {
if (ret.length()==0 && stripContiguous) {
continue;
}
break;
@ -200,5 +200,6 @@ String SafeReader::readStringToken(unsigned char delim) {
}
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(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; };

View File

@ -1261,9 +1261,25 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
hasOpened=fileDialog->openLoad(
"Load Instrument",
{"compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.opli *.opni *.y12 *.bnk *.ff *.opm",
"all files", ".*"},
"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 compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.opli *.opni *.y12 *.bnk *.ff *.gyb *.opm *.wopl *.wopn",
"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,
dpiScale,
[this](const char* path) {