This commit is contained in:
tildearrow 2024-08-17 16:29:13 -05:00
parent f5743da6e8
commit 636a9921a2
6 changed files with 18 additions and 16 deletions

View file

@ -597,7 +597,7 @@ class DivEngine {
bool loadDMF(unsigned char* file, size_t len); bool loadDMF(unsigned char* file, size_t len);
bool loadFur(unsigned char* file, size_t len, int variantID=0); bool loadFur(unsigned char* file, size_t len, int variantID=0);
bool loadMod(unsigned char* file, size_t len); bool loadMod(unsigned char* file, size_t len);
bool loadS3M(unsigned char* file, size_t len, bool opl2=false); bool loadS3M(unsigned char* file, size_t len);
bool loadXM(unsigned char* file, size_t len); bool loadXM(unsigned char* file, size_t len);
bool loadIT(unsigned char* file, size_t len); bool loadIT(unsigned char* file, size_t len);
bool loadFTM(unsigned char* file, size_t len, bool dnft, bool dnftSig, bool eft); bool loadFTM(unsigned char* file, size_t len, bool dnft, bool dnftSig, bool eft);
@ -689,7 +689,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, const char* nameHint=NULL, bool s3mOPL2=false); 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.

View file

@ -19,7 +19,7 @@
#include "fileOpsCommon.h" #include "fileOpsCommon.h"
bool DivEngine::load(unsigned char* f, size_t slen, const char* nameHint, bool s3mOPL2) { 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<21) { if (slen<21) {
@ -158,7 +158,7 @@ bool DivEngine::load(unsigned char* f, size_t slen, const char* nameHint, bool s
return loadIT(file,len); return loadIT(file,len);
} else if (len>=48) { } else if (len>=48) {
if (memcmp(&file[0x2c],DIV_S3M_MAGIC,4)==0) { if (memcmp(&file[0x2c],DIV_S3M_MAGIC,4)==0) {
return loadS3M(file,len,s3mOPL2); return loadS3M(file,len);
} else if (memcmp(file,DIV_XM_MAGIC,17)==0) { } else if (memcmp(file,DIV_XM_MAGIC,17)==0) {
return loadXM(file,len); return loadXM(file,len);
} }

View file

@ -48,9 +48,10 @@ static void readSbiOpData(sbi_t& sbi, SafeReader& reader) {
sbi.FeedConnect = reader.readC(); sbi.FeedConnect = reader.readC();
} }
bool DivEngine::loadS3M(unsigned char* file, size_t len, bool opl2) { bool DivEngine::loadS3M(unsigned char* file, size_t len) {
struct InvalidHeaderException {}; struct InvalidHeaderException {};
bool success=false; bool success=false;
bool opl2=!getConfInt("s3mOPL3",0);
char magic[4]={0,0,0,0}; char magic[4]={0,0,0,0};
SafeReader reader=SafeReader(file,len); SafeReader reader=SafeReader(file,len);
warnings=""; warnings="";

View file

@ -2417,7 +2417,7 @@ int FurnaceGUI::load(String path) {
return 1; return 1;
} }
fclose(f); fclose(f);
if (!e->load(file,(size_t)len,path.c_str(),settings.OPL2s3mImport)) { 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;
@ -4110,7 +4110,7 @@ bool FurnaceGUI::loop() {
if (!tutorial.introPlayed || settings.alwaysPlayIntro==3 || (settings.alwaysPlayIntro==2 && curFileName.empty())) { if (!tutorial.introPlayed || settings.alwaysPlayIntro==3 || (settings.alwaysPlayIntro==2 && curFileName.empty())) {
unsigned char* introTemp=new unsigned char[intro_fur_len]; unsigned char* introTemp=new unsigned char[intro_fur_len];
memcpy(introTemp,intro_fur,intro_fur_len); memcpy(introTemp,intro_fur,intro_fur_len);
e->load(introTemp,intro_fur_len,NULL,settings.OPL2s3mImport); e->load(introTemp,intro_fur_len);
} }
} }

View file

@ -1958,7 +1958,7 @@ class FurnaceGUI {
unsigned int maxUndoSteps; unsigned int maxUndoSteps;
float vibrationStrength; float vibrationStrength;
int vibrationLength; int vibrationLength;
bool OPL2s3mImport; int s3mOPL3;
String mainFontPath; String mainFontPath;
String headFontPath; String headFontPath;
String patFontPath; String patFontPath;
@ -2215,7 +2215,7 @@ class FurnaceGUI {
maxUndoSteps(100), maxUndoSteps(100),
vibrationStrength(0.5f), vibrationStrength(0.5f),
vibrationLength(20), vibrationLength(20),
OPL2s3mImport(false), s3mOPL3(0),
mainFontPath(""), mainFontPath(""),
headFontPath(""), headFontPath(""),
patFontPath(""), patFontPath(""),

View file

@ -1254,11 +1254,11 @@ void FurnaceGUI::drawSettings() {
} }
popDestColor(); popDestColor();
// SUBSECTION CONFIGURATION // SUBSECTION IMPORT
CONFIG_SUBSECTION(_("Modules import")); CONFIG_SUBSECTION(_("Import"));
bool s3mOPL2B=settings.OPL2s3mImport; bool s3mOPL3B=settings.s3mOPL3;
if (ImGui::Checkbox(_("Use OPL2 instead of OPL3 for .s3m modules import"),&s3mOPL2B)) { if (ImGui::Checkbox(_("Use OPL3 instead of OPL2 for S3M import"),&s3mOPL3B)) {
settings.OPL2s3mImport=s3mOPL2B; settings.s3mOPL3=s3mOPL3B;
settingsChanged=true; settingsChanged=true;
} }
@ -4754,7 +4754,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
settings.vibrationStrength=conf.getFloat("vibrationStrength",0.5f); settings.vibrationStrength=conf.getFloat("vibrationStrength",0.5f);
settings.vibrationLength=conf.getInt("vibrationLength",20); settings.vibrationLength=conf.getInt("vibrationLength",20);
settings.OPL2s3mImport=conf.getBool("OPL2s3mImport",false); settings.s3mOPL3=conf.getInt("s3mOPL3",0);
settings.backupEnable=conf.getInt("backupEnable",1); settings.backupEnable=conf.getInt("backupEnable",1);
settings.backupInterval=conf.getInt("backupInterval",30); settings.backupInterval=conf.getInt("backupInterval",30);
@ -5268,6 +5268,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
clampSetting(settings.backupMaxCopies,1,100); clampSetting(settings.backupMaxCopies,1,100);
clampSetting(settings.autoFillSave,0,1); clampSetting(settings.autoFillSave,0,1);
clampSetting(settings.autoMacroStepSize,0,1); clampSetting(settings.autoMacroStepSize,0,1);
clampSetting(settings.s3mOPL3,0,1);
if (settings.exportLoops<0.0) settings.exportLoops=0.0; if (settings.exportLoops<0.0) settings.exportLoops=0.0;
if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0; if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0;
@ -5341,7 +5342,7 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
conf.set("vibrationStrength",settings.vibrationStrength); conf.set("vibrationStrength",settings.vibrationStrength);
conf.set("vibrationLength",settings.vibrationLength); conf.set("vibrationLength",settings.vibrationLength);
conf.set("OPL2s3mImport",settings.OPL2s3mImport); conf.set("s3mOPL3",settings.s3mOPL3);
conf.set("backupEnable",settings.backupEnable); conf.set("backupEnable",settings.backupEnable);
conf.set("backupInterval",settings.backupInterval); conf.set("backupInterval",settings.backupInterval);