diff --git a/src/engine/config.cpp b/src/engine/config.cpp index ce7b1b4a..86c7ddc0 100644 --- a/src/engine/config.cpp +++ b/src/engine/config.cpp @@ -54,6 +54,10 @@ String DivConfig::toBase64() { return taEncodeBase64(data); } +const std::map& DivConfig::configMap() { + return conf; +} + void DivConfig::parseLine(const char* line) { String key=""; String value=""; @@ -171,6 +175,15 @@ String DivConfig::getString(String key, String fallback) const { return fallback; } +bool DivConfig::has(String key) { + try { + String test=conf.at(key); + } catch (std::out_of_range& e) { + return false; + } + return true; +} + void DivConfig::set(String key, bool value) { if (value) { conf[key]="true"; diff --git a/src/engine/config.h b/src/engine/config.h index d573a451..a867dc82 100644 --- a/src/engine/config.h +++ b/src/engine/config.h @@ -35,6 +35,9 @@ class DivConfig { String toBase64(); bool save(const char* path); + // get the map + const std::map& configMap(); + // get a config value bool getBool(String key, bool fallback) const; int getInt(String key, int fallback) const; @@ -42,6 +45,9 @@ class DivConfig { double getDouble(String key, double fallback) const; String getString(String key, String fallback) const; + // check for existence + bool has(String key); + // set a config value void set(String key, bool value); void set(String key, int value); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 76af88fc..6fbc1681 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -592,12 +592,14 @@ void FurnaceGUI::updateWindowTitle() { void FurnaceGUI::autoDetectSystem() { std::map sysCountMap; + std::map sysConfMap; for (int i=0; isong.systemLen; i++) { try { sysCountMap.at(e->song.system[i])++; } catch (std::exception& ex) { sysCountMap[e->song.system[i]]=1; } + sysConfMap[e->song.system[i]]=e->song.systemFlags[i]; } logV("sysCountMap:"); @@ -607,16 +609,20 @@ void FurnaceGUI::autoDetectSystem() { bool isMatch=false; std::map defCountMap; + std::map defConfMap; for (FurnaceGUISysCategory& i: sysCategories) { for (FurnaceGUISysDef& j: i.systems) { defCountMap.clear(); - for (size_t k=0; k l: defConfMap.at(k.first).configMap()) { + if (!sysDC.has(l.first)) { + isMatch=false; + break; + } + if (sysDC.getString(l.first,"")!=l.second) { + isMatch=false; + break; + } + } + if (!isMatch) break; } catch (std::exception& ex) { isMatch=false; break; @@ -1825,6 +1843,7 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) { int FurnaceGUI::save(String path, int dmfVersion) { SafeWriter* w; + logD("saving file..."); if (dmfVersion) { if (dmfVersion<24) dmfVersion=24; w=e->saveDMF(dmfVersion); @@ -1833,11 +1852,14 @@ int FurnaceGUI::save(String path, int dmfVersion) { } if (w==NULL) { lastError=e->getLastError(); + logE("couldn't save! %s",lastError); return 3; } + logV("opening file for writing..."); FILE* outFile=ps_fopen(path.c_str(),"wb"); if (outFile==NULL) { lastError=strerror(errno); + logE("couldn't save! %s",lastError); w->finish(); return 1; } @@ -1918,6 +1940,7 @@ int FurnaceGUI::save(String path, int dmfVersion) { showWarning(e->getWarnings(),GUI_WARN_GENERIC); } pushRecentFile(path); + logD("save complete."); return 0; } @@ -4070,7 +4093,6 @@ bool FurnaceGUI::loop() { } break; case GUI_FILE_SAVE: { - logD("saving: %s",copyOfName.c_str()); bool saveWasSuccessful=true; if (save(copyOfName,0)>0) { showError(fmt::sprintf("Error while saving file! (%s)",lastError)); @@ -5057,6 +5079,7 @@ bool FurnaceGUI::loop() { } logD("saving backup..."); SafeWriter* w=e->saveFur(true); + logV("writing file..."); if (w!=NULL) { FILE* outFile=ps_fopen(backupPath.c_str(),"wb"); @@ -5071,6 +5094,7 @@ bool FurnaceGUI::loop() { w->finish(); } } + logD("backup saved."); backupTimer=30.0; return true; }); diff --git a/src/gui/gui.h b/src/gui/gui.h index bc12fe2c..2b7a2be4 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -948,6 +948,7 @@ struct FurnaceGUISysDef { const char* name; const char* extra; String definition; + std::vector orig; FurnaceGUISysDef(const char* n, std::initializer_list def, const char* e=NULL); }; diff --git a/src/gui/presets.cpp b/src/gui/presets.cpp index 639f3eb7..061173d3 100644 --- a/src/gui/presets.cpp +++ b/src/gui/presets.cpp @@ -114,6 +114,19 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_GB, 64, 0, "") } ); + ENTRY( + "Neo Geo Pocket", { + CH(DIV_SYSTEM_T6W28, 64, 0, ""), + CH(DIV_SYSTEM_PCM_DAC, 64, -127, + "rate=11025\n" + "outDepth=5\n" + ), + CH(DIV_SYSTEM_PCM_DAC, 64, 127, + "rate=11025\n" + "outDepth=5\n" + ) // don't know what the actual sample rate is + } + ); ENTRY( "NEC PC Engine/TurboGrafx-16", { CH(DIV_SYSTEM_PCE, 64, 0, "") @@ -190,6 +203,12 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_TIA, 64, 0, "") } ); + ENTRY( + "Atari 7800 + Ballblazer/Commando", { + CH(DIV_SYSTEM_TIA, 64, 0, ""), + CH(DIV_SYSTEM_POKEY, 64, 0, "") + } + ); ENTRY( "Atari Lynx", { CH(DIV_SYSTEM_LYNX, 64, 0, "") @@ -311,7 +330,7 @@ void FurnaceGUI::initSystemPresets() { ); ENTRY( "MSX", { - CH(DIV_SYSTEM_AY8910, 64, 0, "chipType=1") + CH(DIV_SYSTEM_AY8910, 64, 0, "clockSel=0\nchipType=1") } ); ENTRY( @@ -2020,6 +2039,33 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_MSM6295, 64, 127, "clockSel=14") // 1.193MHz (3.579545MHz / 3), Right output } ); + ENTRY( + "Atari Marble Madness", { + CH(DIV_SYSTEM_YM2151, 64, 0, ""), + CH(DIV_SYSTEM_POKEY, 64, 0, "") + } + ); + ENTRY( + "Atari Championship Sprint", { + CH(DIV_SYSTEM_YM2151, 64, 0, ""), + CH(DIV_SYSTEM_POKEY, 64, 0, ""), + CH(DIV_SYSTEM_POKEY, 64, 0, "") + } + ); + ENTRY( + "Atari Tetris", { + CH(DIV_SYSTEM_POKEY, 64, 0, ""), + CH(DIV_SYSTEM_POKEY, 64, 0, "") + } + ); + ENTRY( + "Atari I, Robot", { + CH(DIV_SYSTEM_POKEY, 64, 0, "customClock=1512000"), + CH(DIV_SYSTEM_POKEY, 64, 0, "customClock=1512000"), + CH(DIV_SYSTEM_POKEY, 64, 0, "customClock=1512000"), + CH(DIV_SYSTEM_POKEY, 64, 0, "customClock=1512000") + } + ); ENTRY( "Data East Karnov", { CH(DIV_SYSTEM_YM2203, 64, 0, "clockSel=5"), // 1.5MHz @@ -2251,6 +2297,20 @@ void FurnaceGUI::initSystemPresets() { ) // software controlled 8 bit DAC } ); + ENTRY( + "Alpha denshi Equites", { + CH(DIV_SYSTEM_MSM5232, 64, 0, "customClock=6144000"), + CH(DIV_SYSTEM_AY8910, 64, 0, "clockSel=14"), + CH(DIV_SYSTEM_PCM_DAC, 64, 0, + "rate=11025\n" + "outDepth=5\n" + ), + CH(DIV_SYSTEM_PCM_DAC, 64, 0, + "rate=11025\n" + "outDepth=5\n" + ) // don't know what the actual sample rate is + } + ); ENTRY( "Neo Geo MVS", { CH(DIV_SYSTEM_YM2610_FULL, 64, 0, "") @@ -2323,6 +2383,43 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_YM2610B_EXT, 64, 0, "") } ); + ENTRY( + "Taito Metal Soldier Isaac II", { + CH(DIV_SYSTEM_MSM5232, 64, 0, ""), + CH(DIV_SYSTEM_AY8910, 64, 0, "clockSel=3"), + CH(DIV_SYSTEM_AY8910, 64, 0, "clockSel=3") + } + ); + ENTRY( + "Taito The Fairyland Story", { + CH(DIV_SYSTEM_MSM5232, 64, 0, ""), + CH(DIV_SYSTEM_AY8910, 64, 0, + "clockSel=3\n" + "chipType=1\n" + ), + CH(DIV_SYSTEM_PCM_DAC, 64, 0, + "rate=11025\n" + "outDepth=7\n" + ) // don't know what the actual sample rate is + } + ); + ENTRY( + "Taito Wyvern F-0", { + CH(DIV_SYSTEM_MSM5232, 64, 0, ""), + CH(DIV_SYSTEM_AY8910, 64, 0, + "clockSel=3\n" + "chipType=1\n" + ), + CH(DIV_SYSTEM_AY8910, 64, 0, + "clockSel=3\n" + "chipType=1\n" + ), + CH(DIV_SYSTEM_PCM_DAC, 64, 0, + "rate=11025\n" + "outDepth=7\n" + ) // don't know what the actual sample rate is + } + ); ENTRY( "Seta 1", { CH(DIV_SYSTEM_X1_010, 64, 0, "") @@ -2514,9 +2611,9 @@ void FurnaceGUI::initSystemPresets() { FurnaceGUISysDef::FurnaceGUISysDef(const char* n, std::initializer_list def, const char* e): name(n), extra(e) { - std::vector uncompiled=def; + orig=def; int index=0; - for (FurnaceGUISysDefChip& i: uncompiled) { + for (FurnaceGUISysDefChip& i: orig) { definition+=fmt::sprintf( "id%d=%d\nvol%d=%d\npan%d=%d\nflags%d=%s\n", index, diff --git a/src/log.cpp b/src/log.cpp index 32023791..889e1cb5 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -163,6 +163,9 @@ void _logFileThread() { } bool startLogFile(const char* path) { + logFileAvail=false; + return false; + /* if (logFileAvail) return true; // rotate log file if possible @@ -181,6 +184,7 @@ bool startLogFile(const char* path) { logFileThread=new std::thread(_logFileThread); return true; + */ } bool finishLogFile() { @@ -196,4 +200,4 @@ bool finishLogFile() { fclose(logFile); return true; -} \ No newline at end of file +}