mirror of https://github.com/stella-emu/stella.git
Fix 'saveconfig' not saving file correctly (fixes #602).
This commit is contained in:
parent
108d9c26f9
commit
85f0ae18c6
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
* Added detection of color and audio data in DiStella.
|
* Added detection of color and audio data in DiStella.
|
||||||
|
|
||||||
|
* Restored 'cfg' directory for Distella config files.
|
||||||
|
|
||||||
-Have fun!
|
-Have fun!
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -843,12 +843,13 @@ string CartDebug::loadSymbolFile()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::loadConfigFile()
|
string CartDebug::loadConfigFile()
|
||||||
{
|
{
|
||||||
// The default naming/location for config files is the ROM dir based on the
|
// The default naming/location for config files is the CFG dir and based
|
||||||
// actual ROM filename
|
// on the actual ROM filename
|
||||||
|
|
||||||
if(myCfgFile == "")
|
if(myCfgFile == "")
|
||||||
{
|
{
|
||||||
FilesystemNode cfg(myOSystem.romFile().getPathWithExt("") + ".cfg");
|
FilesystemNode romNode(myOSystem.romFile().getPathWithExt("") + ".cfg");
|
||||||
|
FilesystemNode cfg(myOSystem.cfgDir() + romNode.getName());
|
||||||
if(cfg.isFile() && cfg.isReadable())
|
if(cfg.isFile() && cfg.isReadable())
|
||||||
myCfgFile = cfg.getPath();
|
myCfgFile = cfg.getPath();
|
||||||
else
|
else
|
||||||
|
@ -964,14 +965,14 @@ string CartDebug::loadConfigFile()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::saveConfigFile()
|
string CartDebug::saveConfigFile()
|
||||||
{
|
{
|
||||||
// The default naming/location for config files is the ROM dir based on the
|
// The default naming/location for config files is the CFG dir and based
|
||||||
// actual ROM filename
|
// on the actual ROM filename
|
||||||
|
|
||||||
FilesystemNode cfg;
|
|
||||||
if(myCfgFile == "")
|
if(myCfgFile == "")
|
||||||
{
|
{
|
||||||
cfg = FilesystemNode(myOSystem.romFile().getPathWithExt("") + ".cfg");
|
FilesystemNode romNode(myOSystem.romFile().getPathWithExt("") + ".cfg");
|
||||||
if(cfg.isFile() && cfg.isWritable())
|
FilesystemNode cfg(myOSystem.cfgDir() + romNode.getName());
|
||||||
|
if(cfg.getParent().isWritable())
|
||||||
myCfgFile = cfg.getPath();
|
myCfgFile = cfg.getPath();
|
||||||
else
|
else
|
||||||
return DebuggerParser::red("config file \'" + cfg.getShortPath() + "\' not writable");
|
return DebuggerParser::red("config file \'" + cfg.getShortPath() + "\' not writable");
|
||||||
|
@ -980,13 +981,14 @@ string CartDebug::saveConfigFile()
|
||||||
const string& name = myConsole.properties().get(PropType::Cart_Name);
|
const string& name = myConsole.properties().get(PropType::Cart_Name);
|
||||||
const string& md5 = myConsole.properties().get(PropType::Cart_MD5);
|
const string& md5 = myConsole.properties().get(PropType::Cart_MD5);
|
||||||
|
|
||||||
|
FilesystemNode cfg(myCfgFile);
|
||||||
ofstream out(cfg.getPath());
|
ofstream out(cfg.getPath());
|
||||||
if(!out.is_open())
|
if(!out.is_open())
|
||||||
return "Unable to save directives to " + cfg.getShortPath();
|
return "Unable to save directives to " + cfg.getShortPath();
|
||||||
|
|
||||||
// Store all bank information
|
// Store all bank information
|
||||||
out << "//Stella.pro: \"" << name << "\"" << endl
|
out << "// Stella.pro: \"" << name << "\"" << endl
|
||||||
<< "//MD5: " << md5 << endl
|
<< "// MD5: " << md5 << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
for(uInt32 b = 0; b < myConsole.cartridge().bankCount(); ++b)
|
for(uInt32 b = 0; b < myConsole.cartridge().bankCount(); ++b)
|
||||||
{
|
{
|
||||||
|
|
|
@ -343,7 +343,7 @@ class CartDebug : public DebuggerSystem
|
||||||
uInt16 myLabelLength{8}; // longest pre-defined label
|
uInt16 myLabelLength{8}; // longest pre-defined label
|
||||||
|
|
||||||
// Filenames to use for various I/O (currently these are hardcoded)
|
// Filenames to use for various I/O (currently these are hardcoded)
|
||||||
string myListFile, mySymbolFile, myCfgFile, myDisasmFile, myRomFile;
|
string myListFile, mySymbolFile, myCfgFile, myDisasmFile;
|
||||||
|
|
||||||
/// Table of instruction mnemonics
|
/// Table of instruction mnemonics
|
||||||
static std::array<const char*, 16> ourTIAMnemonicR; // read mode
|
static std::array<const char*, 16> ourTIAMnemonicR; // read mode
|
||||||
|
|
|
@ -268,6 +268,9 @@ void OSystem::setConfigPaths()
|
||||||
|
|
||||||
buildDirIfRequired(myStateDir, myBaseDir + "state");
|
buildDirIfRequired(myStateDir, myBaseDir + "state");
|
||||||
buildDirIfRequired(myNVRamDir, myBaseDir + "nvram");
|
buildDirIfRequired(myNVRamDir, myBaseDir + "nvram");
|
||||||
|
#ifdef DEBUGGER_SUPPORT
|
||||||
|
buildDirIfRequired(myCfgDir, myBaseDir + "cfg");
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SUPPORT
|
#ifdef PNG_SUPPORT
|
||||||
mySnapshotSaveDir = mySettings->getString("snapsavedir");
|
mySnapshotSaveDir = mySettings->getString("snapsavedir");
|
||||||
|
@ -292,6 +295,7 @@ void OSystem::setConfigPaths()
|
||||||
dbgPath("base dir ", myBaseDir);
|
dbgPath("base dir ", myBaseDir);
|
||||||
dbgPath("state dir ", myStateDir);
|
dbgPath("state dir ", myStateDir);
|
||||||
dbgPath("nvram dir ", myNVRamDir);
|
dbgPath("nvram dir ", myNVRamDir);
|
||||||
|
dbgPath("cfg dir ", myCfgDir);
|
||||||
dbgPath("ssave dir ", mySnapshotSaveDir);
|
dbgPath("ssave dir ", mySnapshotSaveDir);
|
||||||
dbgPath("sload dir ", mySnapshotLoadDir);
|
dbgPath("sload dir ", mySnapshotLoadDir);
|
||||||
dbgPath("cheat file", myCheatFile);
|
dbgPath("cheat file", myCheatFile);
|
||||||
|
|
|
@ -270,6 +270,13 @@ class OSystem
|
||||||
const string& cheatFile() const { return myCheatFile; }
|
const string& cheatFile() const { return myCheatFile; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUGGER_SUPPORT
|
||||||
|
/**
|
||||||
|
Return the full/complete directory name for storing Distella cfg files.
|
||||||
|
*/
|
||||||
|
const string& cfgDir() const { return myCfgDir; }
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SUPPORT
|
#ifdef PNG_SUPPORT
|
||||||
/**
|
/**
|
||||||
Return the full/complete directory name for saving and loading
|
Return the full/complete directory name for saving and loading
|
||||||
|
@ -529,6 +536,7 @@ class OSystem
|
||||||
string mySnapshotSaveDir;
|
string mySnapshotSaveDir;
|
||||||
string mySnapshotLoadDir;
|
string mySnapshotLoadDir;
|
||||||
string myNVRamDir;
|
string myNVRamDir;
|
||||||
|
string myCfgDir;
|
||||||
string myDefaultSaveDir;
|
string myDefaultSaveDir;
|
||||||
string myDefaultLoadDir;
|
string myDefaultLoadDir;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue