mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-26 22:43:01 +00:00
fix .dnm and .eft loading
This commit is contained in:
parent
92b1c95259
commit
845eb582a6
5 changed files with 24 additions and 6 deletions
|
@ -632,7 +632,7 @@ class DivEngine {
|
||||||
void createNew(const char* description, String sysName, bool inBase64=true);
|
void createNew(const char* description, String sysName, bool inBase64=true);
|
||||||
void createNewFromDefaults();
|
void createNewFromDefaults();
|
||||||
// load a file.
|
// load a file.
|
||||||
bool load(unsigned char* f, size_t length);
|
bool load(unsigned char* f, size_t length, const char* nameHint=NULL);
|
||||||
// play a binary command stream.
|
// play a binary command stream.
|
||||||
bool playStream(unsigned char* f, size_t length);
|
bool playStream(unsigned char* f, size_t length);
|
||||||
// get the playing stream.
|
// get the playing stream.
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
#include "fileOpsCommon.h"
|
#include "fileOpsCommon.h"
|
||||||
|
|
||||||
bool DivEngine::load(unsigned char* f, size_t slen) {
|
bool DivEngine::load(unsigned char* f, size_t slen, const char* nameHint) {
|
||||||
unsigned char* file;
|
unsigned char* file;
|
||||||
size_t len;
|
size_t len;
|
||||||
if (slen<18) {
|
if (slen<21) {
|
||||||
logE("too small!");
|
logE("too small!");
|
||||||
lastError="file is too small";
|
lastError="file is too small";
|
||||||
delete[] f;
|
delete[] f;
|
||||||
|
@ -31,6 +31,21 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
||||||
|
|
||||||
if (!systemsRegistered) registerSystems();
|
if (!systemsRegistered) registerSystems();
|
||||||
|
|
||||||
|
// step 0: get extension of file
|
||||||
|
String extS;
|
||||||
|
if (nameHint!=NULL) {
|
||||||
|
const char* ext=strrchr(nameHint,'.');
|
||||||
|
if (ext!=NULL) {
|
||||||
|
for (; *ext; ext++) {
|
||||||
|
char i=*ext;
|
||||||
|
if (i>='A' && i<='Z') {
|
||||||
|
i+='a'-'A';
|
||||||
|
}
|
||||||
|
extS+=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// step 1: try loading as a zlib-compressed file
|
// step 1: try loading as a zlib-compressed file
|
||||||
logD("trying zlib...");
|
logD("trying zlib...");
|
||||||
try {
|
try {
|
||||||
|
@ -128,7 +143,9 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
||||||
if (memcmp(file,DIV_DMF_MAGIC,16)==0) {
|
if (memcmp(file,DIV_DMF_MAGIC,16)==0) {
|
||||||
return loadDMF(file,len);
|
return loadDMF(file,len);
|
||||||
} else if (memcmp(file,DIV_FTM_MAGIC,18)==0) {
|
} else if (memcmp(file,DIV_FTM_MAGIC,18)==0) {
|
||||||
return loadFTM(file,len,false,false,false);
|
return loadFTM(file,len,(extS==".dnm"),false,(extS==".eft"));
|
||||||
|
} else if (memcmp(file,DIV_DNM_MAGIC,21)==0) {
|
||||||
|
return loadFTM(file,len,true,true,false);
|
||||||
} else if (memcmp(file,DIV_FUR_MAGIC,16)==0) {
|
} else if (memcmp(file,DIV_FUR_MAGIC,16)==0) {
|
||||||
return loadFur(file,len);
|
return loadFur(file,len);
|
||||||
} else if (memcmp(file,DIV_FUR_MAGIC_DS0,16)==0) {
|
} else if (memcmp(file,DIV_FUR_MAGIC_DS0,16)==0) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct NotZlibException {
|
||||||
#define DIV_DMF_MAGIC ".DelekDefleMask."
|
#define DIV_DMF_MAGIC ".DelekDefleMask."
|
||||||
#define DIV_FUR_MAGIC "-Furnace module-"
|
#define DIV_FUR_MAGIC "-Furnace module-"
|
||||||
#define DIV_FTM_MAGIC "FamiTracker Module"
|
#define DIV_FTM_MAGIC "FamiTracker Module"
|
||||||
|
#define DIV_DNM_MAGIC "Dn-FamiTracker Module"
|
||||||
#define DIV_FC13_MAGIC "SMOD"
|
#define DIV_FC13_MAGIC "SMOD"
|
||||||
#define DIV_FC14_MAGIC "FC14"
|
#define DIV_FC14_MAGIC "FC14"
|
||||||
#define DIV_S3M_MAGIC "SCRM"
|
#define DIV_S3M_MAGIC "SCRM"
|
||||||
|
|
|
@ -2215,7 +2215,7 @@ int FurnaceGUI::load(String path) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (!e->load(file,(size_t)len)) {
|
if (!e->load(file,(size_t)len,path.c_str())) {
|
||||||
lastError=e->getLastError();
|
lastError=e->getLastError();
|
||||||
logE("could not open file!");
|
logE("could not open file!");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -612,7 +612,7 @@ int main(int argc, char** argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (!e.load(file,(size_t)len)) {
|
if (!e.load(file,(size_t)len,fileName.c_str())) {
|
||||||
reportError(fmt::sprintf("could not open file! (%s)",e.getLastError()));
|
reportError(fmt::sprintf("could not open file! (%s)",e.getLastError()));
|
||||||
e.everythingOK();
|
e.everythingOK();
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
|
|
Loading…
Reference in a new issue