setting to choose between OPL2 and OPL3, channel naming
This commit is contained in:
parent
41e094d79d
commit
5770f381ba
|
|
@ -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 loadS3M(unsigned char* file, size_t len, bool opl2=false);
|
||||||
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 load(unsigned char* f, size_t length, const char* nameHint=NULL, bool s3mOPL2=false);
|
||||||
// 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,7 +19,7 @@
|
||||||
|
|
||||||
#include "fileOpsCommon.h"
|
#include "fileOpsCommon.h"
|
||||||
|
|
||||||
bool DivEngine::load(unsigned char* f, size_t slen, const char* nameHint) {
|
bool DivEngine::load(unsigned char* f, size_t slen, const char* nameHint, bool s3mOPL2) {
|
||||||
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) {
|
||||||
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);
|
return loadS3M(file,len,s3mOPL2);
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ 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 DivEngine::loadS3M(unsigned char* file, size_t len, bool opl2) {
|
||||||
struct InvalidHeaderException {};
|
struct InvalidHeaderException {};
|
||||||
bool success=false;
|
bool success=false;
|
||||||
char magic[4]={0,0,0,0};
|
char magic[4]={0,0,0,0};
|
||||||
|
|
@ -273,11 +273,16 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
||||||
bool hasPCM=false;
|
bool hasPCM=false;
|
||||||
bool hasFM=false;
|
bool hasFM=false;
|
||||||
int numChans=0;
|
int numChans=0;
|
||||||
|
int realNumChans=0;
|
||||||
|
|
||||||
for (int i=0; i<32; i++) {
|
for (int ch=0; ch<32; ch++) {
|
||||||
if (chanSettings[i]==255) continue;
|
if (chanSettings[ch]!=255) realNumChans++;
|
||||||
if ((chanSettings[i]&127)>=32) continue;
|
}
|
||||||
if ((chanSettings[i]&127)>=16) {
|
|
||||||
|
for (int ch=0; ch<32; ch++) {
|
||||||
|
if (chanSettings[ch]==255) continue;
|
||||||
|
if ((chanSettings[ch]&127)>=32) continue;
|
||||||
|
if ((chanSettings[ch]&127)>=16) {
|
||||||
hasFM=true;
|
hasFM=true;
|
||||||
} else {
|
} else {
|
||||||
hasPCM=true;
|
hasPCM=true;
|
||||||
|
|
@ -287,48 +292,69 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
||||||
if (hasFM && hasPCM) break;
|
if (hasFM && hasPCM) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pcmChan=hasFM?18:0;
|
int pcmChan=hasFM?(opl2 ? 9 : 18):0;
|
||||||
int fmChan=hasPCM?32:0;
|
int fmChan=hasPCM?32:0;
|
||||||
int invalidChan=40;
|
int invalidChan=40;
|
||||||
|
|
||||||
for (int i=0; i<32; i++) {
|
for (int ch=0; ch<32; ch++) {
|
||||||
if (chanSettings[i]==255) {
|
if (chanSettings[ch]==255) {
|
||||||
chanMap[i]=invalidChan++;
|
chanMap[ch]=invalidChan++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((chanSettings[i]&127)>=32) {
|
if ((chanSettings[ch]&127)>=32) {
|
||||||
chanMap[i]=invalidChan++;
|
chanMap[ch]=invalidChan++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((chanSettings[i]&127)>=16) {
|
if ((chanSettings[ch]&127)>=16) {
|
||||||
chanMap[i]=fmChan++;
|
chanMap[ch]=fmChan++;
|
||||||
} else {
|
} else {
|
||||||
chanMap[i]=pcmChan++;
|
chanMap[ch]=pcmChan++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char buffer[40];
|
||||||
|
int chanIndex = 1;
|
||||||
|
|
||||||
if (hasPCM) {
|
if (hasPCM) {
|
||||||
for (int i=pcmChan; i<32; i++) {
|
for(int ch = 0; ch < pcmChan - (realNumChans - (hasFM ? 9 : 0)); ch++)
|
||||||
ds.subsong[0]->chanShow[i]=false;
|
{
|
||||||
ds.subsong[0]->chanShowChanOsc[i]=false;
|
ds.subsong[0]->chanShow[ch]=false;
|
||||||
|
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFM) {
|
for (int ch=pcmChan; ch<32; ch++) {
|
||||||
for (int i=0; i<18; i++) {
|
ds.subsong[0]->chanShow[ch]=false;
|
||||||
ds.subsong[0]->chanShow[i]=false;
|
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||||
ds.subsong[0]->chanShowChanOsc[i]=false;
|
}
|
||||||
|
|
||||||
|
for(int ch = 0; ch < 32; ch++)
|
||||||
|
{
|
||||||
|
if(ds.subsong[0]->chanShow[ch])
|
||||||
|
{
|
||||||
|
snprintf(buffer, 40, _("Channel %d"), chanIndex);
|
||||||
|
ds.subsong[0]->chanName[ch] = buffer;
|
||||||
|
chanIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFM) {
|
if (hasFM && !opl2) {
|
||||||
for (int i=(hasPCM?32:0) + 9; i<(hasPCM?32:0) + 18; i++) {
|
for (int ch=(hasPCM?32:0) + 9; ch<(hasPCM?32:0) + 18; ch++) {
|
||||||
ds.subsong[0]->chanShow[i]=false;
|
ds.subsong[0]->chanShow[ch]=false;
|
||||||
ds.subsong[0]->chanShowChanOsc[i]=false;
|
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
chanIndex = 1;
|
||||||
|
|
||||||
|
for (int ch=(hasPCM?32:0); ch<(hasPCM?32:0) + 9; ch++) {
|
||||||
|
snprintf(buffer, 40, _("FM %d"), chanIndex);
|
||||||
|
ds.subsong[0]->chanName[ch] = buffer;
|
||||||
|
chanIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logV("numChans: %d",numChans);
|
logV("numChans: %d",numChans);
|
||||||
|
logV("realNumChans: %d",realNumChans);
|
||||||
|
|
||||||
ds.systemName="PC";
|
ds.systemName="PC";
|
||||||
if (hasPCM) {
|
if (hasPCM) {
|
||||||
|
|
@ -341,7 +367,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
||||||
ds.systemLen++;
|
ds.systemLen++;
|
||||||
}
|
}
|
||||||
if (hasFM) {
|
if (hasFM) {
|
||||||
ds.system[ds.systemLen]=DIV_SYSTEM_OPL3;
|
ds.system[ds.systemLen]=opl2 ? DIV_SYSTEM_OPL2 : DIV_SYSTEM_OPL3;
|
||||||
ds.systemVol[ds.systemLen]=1.0f;
|
ds.systemVol[ds.systemLen]=1.0f;
|
||||||
ds.systemPan[ds.systemLen]=0;
|
ds.systemPan[ds.systemLen]=0;
|
||||||
ds.systemLen++;
|
ds.systemLen++;
|
||||||
|
|
|
||||||
|
|
@ -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())) {
|
if (!e->load(file,(size_t)len,path.c_str(),settings.OPL2s3mImport)) {
|
||||||
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);
|
e->load(introTemp,intro_fur_len,NULL,settings.OPL2s3mImport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1958,6 +1958,7 @@ class FurnaceGUI {
|
||||||
unsigned int maxUndoSteps;
|
unsigned int maxUndoSteps;
|
||||||
float vibrationStrength;
|
float vibrationStrength;
|
||||||
int vibrationLength;
|
int vibrationLength;
|
||||||
|
bool OPL2s3mImport;
|
||||||
String mainFontPath;
|
String mainFontPath;
|
||||||
String headFontPath;
|
String headFontPath;
|
||||||
String patFontPath;
|
String patFontPath;
|
||||||
|
|
@ -2214,6 +2215,7 @@ class FurnaceGUI {
|
||||||
maxUndoSteps(100),
|
maxUndoSteps(100),
|
||||||
vibrationStrength(0.5f),
|
vibrationStrength(0.5f),
|
||||||
vibrationLength(20),
|
vibrationLength(20),
|
||||||
|
OPL2s3mImport(false),
|
||||||
mainFontPath(""),
|
mainFontPath(""),
|
||||||
headFontPath(""),
|
headFontPath(""),
|
||||||
patFontPath(""),
|
patFontPath(""),
|
||||||
|
|
|
||||||
|
|
@ -1254,6 +1254,14 @@ void FurnaceGUI::drawSettings() {
|
||||||
}
|
}
|
||||||
popDestColor();
|
popDestColor();
|
||||||
|
|
||||||
|
// SUBSECTION CONFIGURATION
|
||||||
|
CONFIG_SUBSECTION(_("Modules import"));
|
||||||
|
bool s3mOPL2B=settings.OPL2s3mImport;
|
||||||
|
if (ImGui::Checkbox(_("Use OPL2 instead of OPL3 for .s3m modules import"),&s3mOPL2B)) {
|
||||||
|
settings.OPL2s3mImport=s3mOPL2B;
|
||||||
|
settingsChanged=true;
|
||||||
|
}
|
||||||
|
|
||||||
END_SECTION;
|
END_SECTION;
|
||||||
}
|
}
|
||||||
CONFIG_SECTION(_("Audio")) {
|
CONFIG_SECTION(_("Audio")) {
|
||||||
|
|
@ -4746,6 +4754,8 @@ 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.getInt("OPL2s3mImport",false);
|
||||||
|
|
||||||
settings.backupEnable=conf.getInt("backupEnable",1);
|
settings.backupEnable=conf.getInt("backupEnable",1);
|
||||||
settings.backupInterval=conf.getInt("backupInterval",30);
|
settings.backupInterval=conf.getInt("backupInterval",30);
|
||||||
settings.backupMaxCopies=conf.getInt("backupMaxCopies",5);
|
settings.backupMaxCopies=conf.getInt("backupMaxCopies",5);
|
||||||
|
|
@ -5331,6 +5341,8 @@ 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("backupEnable",settings.backupEnable);
|
conf.set("backupEnable",settings.backupEnable);
|
||||||
conf.set("backupInterval",settings.backupInterval);
|
conf.set("backupInterval",settings.backupInterval);
|
||||||
conf.set("backupMaxCopies",settings.backupMaxCopies);
|
conf.set("backupMaxCopies",settings.backupMaxCopies);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue