mirror of https://github.com/stella-emu/stella.git
Some cleanup of dead code, and changes to the file I/O in the debugger.
For now (and the next release), filenames are hardcoded to sane defaults. Eventually, the code may be extended to use BrowserDialog to query the names, but it's taking much too long to get working, and I want to get a new release done before the end of May. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2734 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
89e36662fe
commit
f533fcad34
|
@ -59,7 +59,6 @@ class FilesystemNodeZIP : public AbstractFSNode
|
||||||
bool isFile() const { return _numFiles == 1; }
|
bool isFile() const { return _numFiles == 1; }
|
||||||
bool isReadable() const { return _realNode && _realNode->isReadable(); }
|
bool isReadable() const { return _realNode && _realNode->isReadable(); }
|
||||||
bool isWritable() const { return false; }
|
bool isWritable() const { return false; }
|
||||||
bool isAbsolute() const { return _realNode && _realNode->isAbsolute(); }
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
// For now, ZIP files cannot be modified in any way
|
// For now, ZIP files cannot be modified in any way
|
||||||
|
|
|
@ -646,23 +646,28 @@ int CartDebug::getAddress(const string& label) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::loadSymbolFile(string file)
|
string CartDebug::loadSymbolFile()
|
||||||
{
|
{
|
||||||
if(file == "")
|
// Currently, the default naming/location for symbol files is:
|
||||||
file = myOSystem.romFile();
|
// 1) ROM dir based on properties entry name
|
||||||
|
|
||||||
string::size_type spos;
|
if(mySymbolFile == "")
|
||||||
if( (spos = file.find_last_of('.')) != string::npos )
|
|
||||||
file.replace(spos, file.size(), ".sym");
|
|
||||||
else
|
|
||||||
file += ".sym";
|
|
||||||
|
|
||||||
FilesystemNode node(file);
|
|
||||||
if(node.exists() && node.isFile())
|
|
||||||
{
|
{
|
||||||
|
const string& propsname =
|
||||||
|
myConsole.properties().get(Cartridge_Name) + ".sym";
|
||||||
|
|
||||||
|
FilesystemNode case1(FilesystemNode(myOSystem.romFile()).getParent().getPath() +
|
||||||
|
propsname);
|
||||||
|
if(case1.isFile() && case1.isReadable())
|
||||||
|
mySymbolFile = case1.getPath();
|
||||||
|
else
|
||||||
|
return DebuggerParser::red("symbol file not found in:\n " + case1.getShortPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
FilesystemNode node(mySymbolFile);
|
||||||
ifstream in(node.getPath().c_str());
|
ifstream in(node.getPath().c_str());
|
||||||
if(!in.is_open())
|
if(!in.is_open())
|
||||||
return DebuggerParser::red("symbol file '" + node.getShortPath() + "' not found");
|
return DebuggerParser::red("symbol file '" + node.getShortPath() + "' not readable");
|
||||||
|
|
||||||
myUserAddresses.clear();
|
myUserAddresses.clear();
|
||||||
myUserLabels.clear();
|
myUserLabels.clear();
|
||||||
|
@ -681,58 +686,38 @@ string CartDebug::loadSymbolFile(string file)
|
||||||
addLabel(label, value);
|
addLabel(label, value);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
myDebugger.rom().invalidate();
|
||||||
|
|
||||||
return "loaded " + node.getShortPath() + " OK";
|
return "loaded " + node.getShortPath() + " OK";
|
||||||
}
|
|
||||||
return DebuggerParser::red("symbol file '" + node.getShortPath() + "' not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::loadConfigFile(string file)
|
string CartDebug::loadConfigFile()
|
||||||
{
|
{
|
||||||
FilesystemNode node(file);
|
// There are two possible locations for loading config files
|
||||||
|
|
||||||
if(file == "")
|
|
||||||
{
|
|
||||||
// There are three possible locations for loading config files
|
|
||||||
// (in order of decreasing relevance):
|
// (in order of decreasing relevance):
|
||||||
// 1) ROM dir based on properties entry name
|
// 1) ROM dir based on properties entry name
|
||||||
// 2) ROM dir based on actual ROM name
|
// 2) CFG dir based on properties entry name
|
||||||
// 3) CFG dir based on properties entry name
|
|
||||||
|
|
||||||
|
if(myCfgFile == "")
|
||||||
|
{
|
||||||
const string& propsname =
|
const string& propsname =
|
||||||
myConsole.properties().get(Cartridge_Name) + ".cfg";
|
myConsole.properties().get(Cartridge_Name) + ".cfg";
|
||||||
|
|
||||||
// Case 1
|
|
||||||
FilesystemNode case1(FilesystemNode(myOSystem.romFile()).getParent().getPath() +
|
FilesystemNode case1(FilesystemNode(myOSystem.romFile()).getParent().getPath() +
|
||||||
propsname);
|
propsname);
|
||||||
if(case1.exists())
|
FilesystemNode case2(myOSystem.cfgDir() + propsname);
|
||||||
{
|
|
||||||
node = case1;
|
if(case1.isFile() && case1.isReadable())
|
||||||
}
|
myCfgFile = case1.getPath();
|
||||||
|
else if(case2.isFile() && case2.isReadable())
|
||||||
|
myCfgFile = case2.getPath();
|
||||||
else
|
else
|
||||||
{
|
return DebuggerParser::red("config file not found in:\n " +
|
||||||
file = myOSystem.romFile();
|
case1.getShortPath() + "\n " + case2.getShortPath());
|
||||||
string::size_type spos;
|
|
||||||
if((spos = file.find_last_of('.')) != string::npos )
|
|
||||||
file.replace(spos, file.size(), ".cfg");
|
|
||||||
else
|
|
||||||
file += ".cfg";
|
|
||||||
FilesystemNode case2(file);
|
|
||||||
if(case2.exists())
|
|
||||||
{
|
|
||||||
node = case2;
|
|
||||||
}
|
|
||||||
else // Use global config file based on properties cart name
|
|
||||||
{
|
|
||||||
FilesystemNode case3(myOSystem.cfgDir() + propsname);
|
|
||||||
if(case3.exists())
|
|
||||||
node = case3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.exists() && node.isFile())
|
FilesystemNode node(myCfgFile);
|
||||||
{
|
|
||||||
ifstream in(node.getPath().c_str());
|
ifstream in(node.getPath().c_str());
|
||||||
if(!in.is_open())
|
if(!in.is_open())
|
||||||
return "Unable to load directives from " + node.getPath();
|
return "Unable to load directives from " + node.getPath();
|
||||||
|
@ -812,39 +797,37 @@ string CartDebug::loadConfigFile(string file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
myDebugger.rom().invalidate();
|
||||||
|
|
||||||
return "loaded " + node.getShortPath() + " OK";
|
return "loaded " + node.getShortPath() + " OK";
|
||||||
}
|
|
||||||
else
|
|
||||||
return DebuggerParser::red("config file not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::saveConfigFile(string file)
|
string CartDebug::saveConfigFile()
|
||||||
{
|
{
|
||||||
FilesystemNode node(file);
|
// While there are two possible locations for loading config files,
|
||||||
|
// the main 'config' directory is used whenever possible when saving,
|
||||||
|
// unless the rom-specific file already exists
|
||||||
|
|
||||||
|
FilesystemNode node;
|
||||||
|
|
||||||
|
FilesystemNode case0(myCfgFile);
|
||||||
|
if(myCfgFile != "" && case0.isFile() && case0.isWritable())
|
||||||
|
node = case0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const string& propsname =
|
||||||
|
myConsole.properties().get(Cartridge_Name) + ".cfg";
|
||||||
|
|
||||||
|
node = FilesystemNode(myOSystem.cfgDir() + propsname);
|
||||||
|
}
|
||||||
|
|
||||||
const string& name = myConsole.properties().get(Cartridge_Name);
|
const string& name = myConsole.properties().get(Cartridge_Name);
|
||||||
const string& md5 = myConsole.properties().get(Cartridge_MD5);
|
const string& md5 = myConsole.properties().get(Cartridge_MD5);
|
||||||
|
|
||||||
if(file == "")
|
|
||||||
{
|
|
||||||
// There are two possible locations for saving config files
|
|
||||||
// (in order of decreasing relevance):
|
|
||||||
// 1) ROM dir based on properties entry name
|
|
||||||
// 2) ROM dir based on actual ROM name
|
|
||||||
//
|
|
||||||
// In either case, we're using the properties entry, since even ROMs that
|
|
||||||
// don't have a proper entry have a temporary one inserted by OSystem
|
|
||||||
node = FilesystemNode(FilesystemNode(
|
|
||||||
myOSystem.romFile()).getParent().getPath() + name + ".cfg");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(node.isFile())
|
|
||||||
{
|
|
||||||
ofstream out(node.getPath().c_str());
|
ofstream out(node.getPath().c_str());
|
||||||
if(!out.is_open())
|
if(!out.is_open())
|
||||||
return "Unable to save directives to " + node.getPath();
|
return "Unable to save directives to " + node.getShortPath();
|
||||||
|
|
||||||
// Store all bank information
|
// Store all bank information
|
||||||
out << "//Stella.pro: \"" << name << "\"" << endl
|
out << "//Stella.pro: \"" << name << "\"" << endl
|
||||||
|
@ -858,13 +841,10 @@ string CartDebug::saveConfigFile(string file)
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
return "saved " + node.getShortPath() + " OK";
|
return "saved " + node.getShortPath() + " OK";
|
||||||
}
|
|
||||||
else
|
|
||||||
return DebuggerParser::red("config file not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::saveDisassembly(string file)
|
string CartDebug::saveDisassembly()
|
||||||
{
|
{
|
||||||
#define ALIGN(x) setfill(' ') << left << setw(x)
|
#define ALIGN(x) setfill(' ') << left << setw(x)
|
||||||
|
|
||||||
|
@ -877,7 +857,7 @@ string CartDebug::saveDisassembly(string file)
|
||||||
// Some boilerplate, similar to what DiStella adds
|
// Some boilerplate, similar to what DiStella adds
|
||||||
time_t currtime;
|
time_t currtime;
|
||||||
time(&currtime);
|
time(&currtime);
|
||||||
buf << "; Disassembly of " << file << "\n"
|
buf << "; Disassembly of " << myOSystem.romFile() << "\n"
|
||||||
<< "; Disassembled " << ctime(&currtime)
|
<< "; Disassembled " << ctime(&currtime)
|
||||||
<< "; Using Stella " << STELLA_VERSION << "\n;\n"
|
<< "; Using Stella " << STELLA_VERSION << "\n;\n"
|
||||||
<< "; Settings used: TODO - add args\n;\n"
|
<< "; Settings used: TODO - add args\n;\n"
|
||||||
|
@ -994,6 +974,20 @@ string CartDebug::saveDisassembly(string file)
|
||||||
return DebuggerParser::red("not save to file yet");
|
return DebuggerParser::red("not save to file yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
string CartDebug::saveRom()
|
||||||
|
{
|
||||||
|
const string& path = "~" BSPF_PATH_SEPARATOR +
|
||||||
|
myConsole.properties().get(Cartridge_Name) + ".a26";
|
||||||
|
|
||||||
|
FilesystemNode node(path);
|
||||||
|
ofstream out(node.getPath().c_str(), ios::out | ios::binary);
|
||||||
|
if(out.is_open() && myConsole.cartridge().save(out))
|
||||||
|
return "saved ROM as " + node.getShortPath();
|
||||||
|
else
|
||||||
|
return DebuggerParser::red("failed to save ROM");
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string CartDebug::listConfig(int bank)
|
string CartDebug::listConfig(int bank)
|
||||||
{
|
{
|
||||||
|
|
|
@ -230,16 +230,21 @@ class CartDebug : public DebuggerSystem
|
||||||
int getAddress(const string& label) const;
|
int getAddress(const string& label) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load user equates from the given symbol file (as generated by DASM).
|
Load user equates from symbol file (as generated by DASM).
|
||||||
*/
|
*/
|
||||||
string loadSymbolFile(string file = "");
|
string loadSymbolFile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load/save Distella config file (Distella directives) and disassembly
|
Load/save Distella config files (Distella directives)
|
||||||
*/
|
*/
|
||||||
string loadConfigFile(string file = "");
|
string loadConfigFile();
|
||||||
string saveConfigFile(string file = "");
|
string saveConfigFile();
|
||||||
string saveDisassembly(string file = "");
|
|
||||||
|
/**
|
||||||
|
Save disassembly and ROM file
|
||||||
|
*/
|
||||||
|
string saveDisassembly();
|
||||||
|
string saveRom();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Show Distella directives (both set by the user and determined by Distella)
|
Show Distella directives (both set by the user and determined by Distella)
|
||||||
|
@ -357,6 +362,9 @@ class CartDebug : public DebuggerSystem
|
||||||
// The maximum length of all labels currently defined
|
// The maximum length of all labels currently defined
|
||||||
uInt16 myLabelLength;
|
uInt16 myLabelLength;
|
||||||
|
|
||||||
|
// Filenames to use for various I/O (currently these are hardcoded)
|
||||||
|
string mySymbolFile, myCfgFile, myDisasmFile, myRomFile;
|
||||||
|
|
||||||
/// Table of instruction mnemonics
|
/// Table of instruction mnemonics
|
||||||
static const char* ourTIAMnemonicR[64]; // read mode
|
static const char* ourTIAMnemonicR[64]; // read mode
|
||||||
static const char* ourTIAMnemonicW[128]; // write mode
|
static const char* ourTIAMnemonicW[128]; // write mode
|
||||||
|
|
|
@ -813,19 +813,6 @@ void Debugger::getCompletions(const char* in, StringList& list) const
|
||||||
list.push_back(pseudo_registers[i][0]);
|
list.push_back(pseudo_registers[i][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
string Debugger::saveROM(const string& filename) const
|
|
||||||
{
|
|
||||||
string path = FilesystemNode::createAbsolutePath(filename, "~", "a26");
|
|
||||||
FilesystemNode node(path);
|
|
||||||
|
|
||||||
ofstream out(node.getPath().c_str(), ios::out | ios::binary);
|
|
||||||
if(out.is_open() && myConsole.cartridge().save(out))
|
|
||||||
return node.getShortPath();
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Debugger::lockBankswitchState()
|
void Debugger::lockBankswitchState()
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,7 +75,6 @@ class Debugger : public DialogContainer
|
||||||
// Make these friend classes, to ease communications with the debugger
|
// Make these friend classes, to ease communications with the debugger
|
||||||
// Although it isn't enforced, these classes should use accessor methods
|
// Although it isn't enforced, these classes should use accessor methods
|
||||||
// directly, and not touch the instance variables
|
// directly, and not touch the instance variables
|
||||||
friend class DebuggerDialog;
|
|
||||||
friend class DebuggerParser;
|
friend class DebuggerParser;
|
||||||
friend class EventHandler;
|
friend class EventHandler;
|
||||||
|
|
||||||
|
@ -132,6 +131,11 @@ class Debugger : public DialogContainer
|
||||||
*/
|
*/
|
||||||
void getCompletions(const char* in, StringList& list) const;
|
void getCompletions(const char* in, StringList& list) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The dialog/GUI associated with the debugger
|
||||||
|
*/
|
||||||
|
Dialog& dialog() const { return *myDialog; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The debugger subsystem responsible for all CPU state
|
The debugger subsystem responsible for all CPU state
|
||||||
*/
|
*/
|
||||||
|
@ -156,6 +160,8 @@ class Debugger : public DialogContainer
|
||||||
PackedBitArray& breakpoints() const { return *myBreakPoints; }
|
PackedBitArray& breakpoints() const { return *myBreakPoints; }
|
||||||
PackedBitArray& readtraps() const { return *myReadTraps; }
|
PackedBitArray& readtraps() const { return *myReadTraps; }
|
||||||
PackedBitArray& writetraps() const { return *myWriteTraps; }
|
PackedBitArray& writetraps() const { return *myWriteTraps; }
|
||||||
|
PromptWidget& prompt() const { return myDialog->prompt(); }
|
||||||
|
RomWidget& rom() const { return myDialog->rom(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Run the debugger command and return the result.
|
Run the debugger command and return the result.
|
||||||
|
@ -240,8 +246,6 @@ class Debugger : public DialogContainer
|
||||||
|
|
||||||
void setBreakPoint(int bp, bool set);
|
void setBreakPoint(int bp, bool set);
|
||||||
|
|
||||||
string saveROM(const string& filename) const;
|
|
||||||
|
|
||||||
bool setBank(int bank);
|
bool setBank(int bank);
|
||||||
bool patchROM(int addr, int value);
|
bool patchROM(int addr, int value);
|
||||||
|
|
||||||
|
@ -294,9 +298,6 @@ class Debugger : public DialogContainer
|
||||||
void reset();
|
void reset();
|
||||||
void clearAllBreakPoints();
|
void clearAllBreakPoints();
|
||||||
|
|
||||||
PromptWidget& prompt() { return myDialog->prompt(); }
|
|
||||||
RomWidget& rom() { return myDialog->rom(); };
|
|
||||||
|
|
||||||
void saveState(int state);
|
void saveState(int state);
|
||||||
void loadState(int state);
|
void loadState(int state);
|
||||||
|
|
||||||
|
|
|
@ -1152,12 +1152,7 @@ void DebuggerParser::executeListtraps()
|
||||||
// "loadconfig"
|
// "loadconfig"
|
||||||
void DebuggerParser::executeLoadconfig()
|
void DebuggerParser::executeLoadconfig()
|
||||||
{
|
{
|
||||||
if(argCount == 1)
|
|
||||||
commandResult << debugger.cartDebug().loadConfigFile(argStrings[0]);
|
|
||||||
else
|
|
||||||
commandResult << debugger.cartDebug().loadConfigFile();
|
commandResult << debugger.cartDebug().loadConfigFile();
|
||||||
|
|
||||||
debugger.rom().invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1174,8 +1169,7 @@ void DebuggerParser::executeLoadstate()
|
||||||
// "loadsym"
|
// "loadsym"
|
||||||
void DebuggerParser::executeLoadsym()
|
void DebuggerParser::executeLoadsym()
|
||||||
{
|
{
|
||||||
commandResult << debugger.cartDebug().loadSymbolFile(argStrings[0]);
|
commandResult << debugger.cartDebug().loadSymbolFile();
|
||||||
debugger.rom().invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1416,9 +1410,6 @@ void DebuggerParser::executeSave()
|
||||||
// "saveconfig"
|
// "saveconfig"
|
||||||
void DebuggerParser::executeSaveconfig()
|
void DebuggerParser::executeSaveconfig()
|
||||||
{
|
{
|
||||||
if(argCount == 1)
|
|
||||||
commandResult << debugger.cartDebug().saveConfigFile(argStrings[0]);
|
|
||||||
else
|
|
||||||
commandResult << debugger.cartDebug().saveConfigFile();
|
commandResult << debugger.cartDebug().saveConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1426,9 +1417,6 @@ void DebuggerParser::executeSaveconfig()
|
||||||
// "savedis"
|
// "savedis"
|
||||||
void DebuggerParser::executeSavedisassembly()
|
void DebuggerParser::executeSavedisassembly()
|
||||||
{
|
{
|
||||||
if(argCount == 1)
|
|
||||||
commandResult << debugger.cartDebug().saveDisassembly(argStrings[0]);
|
|
||||||
else
|
|
||||||
commandResult << debugger.cartDebug().saveDisassembly();
|
commandResult << debugger.cartDebug().saveDisassembly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,11 +1424,7 @@ void DebuggerParser::executeSavedisassembly()
|
||||||
// "saverom"
|
// "saverom"
|
||||||
void DebuggerParser::executeSaverom()
|
void DebuggerParser::executeSaverom()
|
||||||
{
|
{
|
||||||
const string& result = debugger.saveROM(argStrings[0]);
|
commandResult << debugger.cartDebug().saveRom();
|
||||||
if(result != "")
|
|
||||||
commandResult << "saved ROM as " << result;
|
|
||||||
else
|
|
||||||
commandResult << red("failed to save ROM");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1917,10 +1901,10 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
|
||||||
|
|
||||||
{
|
{
|
||||||
"loadconfig",
|
"loadconfig",
|
||||||
"Load Distella config file [from file xx]",
|
"Load Distella config file",
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
{ kARG_FILE, kARG_MULTI_BYTE },
|
{ kARG_END_ARGS },
|
||||||
&DebuggerParser::executeLoadconfig
|
&DebuggerParser::executeLoadconfig
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1935,10 +1919,10 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
|
||||||
|
|
||||||
{
|
{
|
||||||
"loadsym",
|
"loadsym",
|
||||||
"Load symbol file named xx",
|
"Load symbol file",
|
||||||
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
{ kARG_END_ARGS },
|
||||||
{ kARG_FILE, kARG_END_ARGS },
|
|
||||||
&DebuggerParser::executeLoadsym
|
&DebuggerParser::executeLoadsym
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2079,28 +2063,28 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
|
||||||
|
|
||||||
{
|
{
|
||||||
"saveconfig",
|
"saveconfig",
|
||||||
"Save Distella config file [to file xx]",
|
"Save Distella config file",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
{ kARG_FILE, kARG_MULTI_BYTE },
|
{ kARG_END_ARGS },
|
||||||
&DebuggerParser::executeSaveconfig
|
&DebuggerParser::executeSaveconfig
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"savedis",
|
"savedis",
|
||||||
"Save Distella disassembly [to file xx]",
|
"Save Distella disassembly",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
{ kARG_FILE, kARG_MULTI_BYTE },
|
{ kARG_END_ARGS },
|
||||||
&DebuggerParser::executeSavedisassembly
|
&DebuggerParser::executeSavedisassembly
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"saverom",
|
"saverom",
|
||||||
"Save (possibly patched) ROM to file xx",
|
"Save (possibly patched) ROM",
|
||||||
true,
|
|
||||||
false,
|
false,
|
||||||
{ kARG_FILE, kARG_END_ARGS },
|
false,
|
||||||
|
{ kARG_END_ARGS },
|
||||||
&DebuggerParser::executeSaverom
|
&DebuggerParser::executeSaverom
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -135,12 +135,6 @@ bool FilesystemNode::isWritable() const
|
||||||
return _realNode ? _realNode->isWritable() : false;
|
return _realNode ? _realNode->isWritable() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
bool FilesystemNode::isAbsolute() const
|
|
||||||
{
|
|
||||||
return _realNode ? _realNode->isAbsolute() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool FilesystemNode::makeDir()
|
bool FilesystemNode::makeDir()
|
||||||
{
|
{
|
||||||
|
@ -184,30 +178,3 @@ uInt32 FilesystemNode::read(uInt8*& image) const
|
||||||
else
|
else
|
||||||
throw "ZLIB open/read error";
|
throw "ZLIB open/read error";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
string FilesystemNode::createAbsolutePath(
|
|
||||||
const string& p, const string& startpath, const string& ext)
|
|
||||||
{
|
|
||||||
FilesystemNode node(p);
|
|
||||||
string path = node.getShortPath();
|
|
||||||
|
|
||||||
// Is path already absolute, or does it start with the given startpath?
|
|
||||||
// If not, we prepend the given startpath
|
|
||||||
if(!BSPF_startsWithIgnoreCase(p, startpath+BSPF_PATH_SEPARATOR) &&
|
|
||||||
!node.isAbsolute())
|
|
||||||
path = startpath + BSPF_PATH_SEPARATOR + p;
|
|
||||||
|
|
||||||
// Does the path have a valid extension?
|
|
||||||
// If not, we append the given extension
|
|
||||||
string::size_type idx = path.find_last_of('.');
|
|
||||||
if(idx != string::npos)
|
|
||||||
{
|
|
||||||
if(!BSPF_equalsIgnoreCase(path.c_str() + idx + 1, ext))
|
|
||||||
path = path.replace(idx+1, ext.length(), ext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
path += "." + ext;
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
|
@ -213,13 +213,6 @@ class FilesystemNode
|
||||||
*/
|
*/
|
||||||
virtual bool isWritable() const;
|
virtual bool isWritable() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the path is a fully-qualified, absolute pathname.
|
|
||||||
*
|
|
||||||
* @return bool true if the object contains an absolute path, false otherwise.
|
|
||||||
*/
|
|
||||||
virtual bool isAbsolute() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory from the current node path.
|
* Create a directory from the current node path.
|
||||||
*
|
*
|
||||||
|
@ -246,15 +239,6 @@ class FilesystemNode
|
||||||
*/
|
*/
|
||||||
virtual uInt32 read(uInt8*& buffer) const;
|
virtual uInt32 read(uInt8*& buffer) const;
|
||||||
|
|
||||||
// TODO - this function is deprecated, and will be removed soon ...
|
|
||||||
/**
|
|
||||||
Create an absolute pathname from the given path (if it isn't already
|
|
||||||
absolute), pre-pending 'startpath' when necessary. If the path doesn't
|
|
||||||
have an extension matching 'ext', append it to the path.
|
|
||||||
*/
|
|
||||||
static string createAbsolutePath(const string& p, const string& startpath,
|
|
||||||
const string& ext);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::SharedPtr<AbstractFSNode> _realNode;
|
Common::SharedPtr<AbstractFSNode> _realNode;
|
||||||
FilesystemNode(AbstractFSNode* realNode);
|
FilesystemNode(AbstractFSNode* realNode);
|
||||||
|
@ -363,13 +347,6 @@ class AbstractFSNode
|
||||||
*/
|
*/
|
||||||
virtual bool isWritable() const = 0;
|
virtual bool isWritable() const = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the path is a fully-qualified, absolute pathname.
|
|
||||||
*
|
|
||||||
* @return bool true if the object contains an absolute path, false otherwise.
|
|
||||||
*/
|
|
||||||
virtual bool isAbsolute() const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory from the current node path.
|
* Create a directory from the current node path.
|
||||||
*
|
*
|
||||||
|
|
|
@ -724,12 +724,11 @@ Console* OSystem::openConsole(const FilesystemNode& romfile, string& md5,
|
||||||
// and that the md5 (and hence the cart) has changed
|
// and that the md5 (and hence the cart) has changed
|
||||||
if(props.get(Cartridge_MD5) != cartmd5)
|
if(props.get(Cartridge_MD5) != cartmd5)
|
||||||
{
|
{
|
||||||
const string& name = props.get(Cartridge_Name);
|
|
||||||
if(!myPropSet->getMD5(cartmd5, props))
|
if(!myPropSet->getMD5(cartmd5, props))
|
||||||
{
|
{
|
||||||
// Cart md5 wasn't found, so we create a new props for it
|
// Cart md5 wasn't found, so we create a new props for it
|
||||||
props.set(Cartridge_MD5, cartmd5);
|
props.set(Cartridge_MD5, cartmd5);
|
||||||
props.set(Cartridge_Name, name+id);
|
props.set(Cartridge_Name, props.get(Cartridge_Name)+id);
|
||||||
myPropSet->insert(props, false);
|
myPropSet->insert(props, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,13 +153,20 @@ void PropertiesSet::getMD5WithInsert(const FilesystemNode& rom,
|
||||||
{
|
{
|
||||||
if(!getMD5(md5, properties))
|
if(!getMD5(md5, properties))
|
||||||
{
|
{
|
||||||
// Create a name suitable for using in properties
|
|
||||||
size_t pos = rom.getName().find_last_of("/\\");
|
|
||||||
const string& name = pos == string::npos ? rom.getName() :
|
|
||||||
rom.getName().substr(pos+1);
|
|
||||||
|
|
||||||
properties.set(Cartridge_MD5, md5);
|
properties.set(Cartridge_MD5, md5);
|
||||||
|
|
||||||
|
// Create a name suitable for using in properties
|
||||||
|
const string& filename = rom.getName();
|
||||||
|
if(BSPF_endsWithIgnoreCase(filename, ".a26") ||
|
||||||
|
BSPF_endsWithIgnoreCase(filename, ".bin") ||
|
||||||
|
BSPF_endsWithIgnoreCase(filename, ".rom"))
|
||||||
|
{
|
||||||
|
const string& name = filename.substr(0, filename.size() - 4);
|
||||||
properties.set(Cartridge_Name, name);
|
properties.set(Cartridge_Name, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
properties.set(Cartridge_Name, filename);
|
||||||
|
|
||||||
insert(properties, false);
|
insert(properties, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,8 @@ BrowserDialog::~BrowserDialog()
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void BrowserDialog::show(const string& title, const string& startpath,
|
void BrowserDialog::show(const string& title, const string& startpath,
|
||||||
BrowserDialog::ListMode mode, int cmd)
|
BrowserDialog::ListMode mode, int cmd,
|
||||||
|
const string& ext)
|
||||||
{
|
{
|
||||||
_title->setLabel(title);
|
_title->setLabel(title);
|
||||||
_cmd = cmd;
|
_cmd = cmd;
|
||||||
|
@ -133,11 +134,13 @@ void BrowserDialog::show(const string& title, const string& startpath,
|
||||||
{
|
{
|
||||||
case FileLoad:
|
case FileLoad:
|
||||||
_fileList->setFileListMode(FilesystemNode::kListAll);
|
_fileList->setFileListMode(FilesystemNode::kListAll);
|
||||||
|
_fileList->setFileExtension(ext);
|
||||||
_selected->setEditable(false);
|
_selected->setEditable(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FileSave:
|
case FileSave:
|
||||||
_fileList->setFileListMode(FilesystemNode::kListAll);
|
_fileList->setFileListMode(FilesystemNode::kListAll);
|
||||||
|
_fileList->setFileExtension(ext);
|
||||||
_selected->setEditable(false); // FIXME - disable user input for now
|
_selected->setEditable(false); // FIXME - disable user input for now
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -191,6 +194,7 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case kChooseCmd:
|
case kChooseCmd:
|
||||||
|
case FileListWidget::ItemActivated:
|
||||||
// Send a signal to the calling class that a selection has been made
|
// Send a signal to the calling class that a selection has been made
|
||||||
// Since we aren't derived from a widget, we don't have a 'data' or 'id'
|
// Since we aren't derived from a widget, we don't have a 'data' or 'id'
|
||||||
if(_cmd) sendCommand(_cmd, -1, -1);
|
if(_cmd) sendCommand(_cmd, -1, -1);
|
||||||
|
@ -206,7 +210,6 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FileListWidget::ItemChanged:
|
case FileListWidget::ItemChanged:
|
||||||
case FileListWidget::ItemActivated:
|
|
||||||
updateUI();
|
updateUI();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class BrowserDialog : public Dialog, public CommandSender
|
||||||
|
|
||||||
/** Place the browser window onscreen, using the given attributes */
|
/** Place the browser window onscreen, using the given attributes */
|
||||||
void show(const string& title, const string& startpath,
|
void show(const string& title, const string& startpath,
|
||||||
BrowserDialog::ListMode mode, int cmd);
|
BrowserDialog::ListMode mode, int cmd, const string& ext = "");
|
||||||
|
|
||||||
/** Get resulting file node (called after receiving kChooseCmd) */
|
/** Get resulting file node (called after receiving kChooseCmd) */
|
||||||
const FilesystemNode& getResult() const;
|
const FilesystemNode& getResult() const;
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
FileListWidget::FileListWidget(GuiObject* boss, const GUI::Font& font,
|
FileListWidget::FileListWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y, int w, int h)
|
int x, int y, int w, int h)
|
||||||
: StringListWidget(boss, font, x, y, w, h),
|
: StringListWidget(boss, font, x, y, w, h),
|
||||||
_fsmode(FilesystemNode::kListAll)
|
_fsmode(FilesystemNode::kListAll),
|
||||||
|
_extension("")
|
||||||
{
|
{
|
||||||
// This widget is special, in that it catches signals and redirects them
|
// This widget is special, in that it catches signals and redirects them
|
||||||
setTarget(this);
|
setTarget(this);
|
||||||
|
@ -68,6 +69,8 @@ void FileListWidget::setLocation(const FilesystemNode& node, string select)
|
||||||
bool isDir = content[idx].isDirectory();
|
bool isDir = content[idx].isDirectory();
|
||||||
if(isDir)
|
if(isDir)
|
||||||
name = " [" + name + "]";
|
name = " [" + name + "]";
|
||||||
|
else if(!BSPF_endsWithIgnoreCase(name, _extension))
|
||||||
|
continue;
|
||||||
|
|
||||||
_gameList.appendGame(name, content[idx].getPath(), "", isDir);
|
_gameList.appendGame(name, content[idx].getPath(), "", isDir);
|
||||||
}
|
}
|
||||||
|
@ -110,14 +113,17 @@ void FileListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
|
||||||
|
|
||||||
case ListWidget::kActivatedCmd:
|
case ListWidget::kActivatedCmd:
|
||||||
case ListWidget::kDoubleClickedCmd:
|
case ListWidget::kDoubleClickedCmd:
|
||||||
cmd = ItemActivated;
|
|
||||||
if(_gameList.isDir(data))
|
if(_gameList.isDir(data))
|
||||||
{
|
{
|
||||||
|
cmd = ItemChanged;
|
||||||
if(_gameList.name(data) == " [..]")
|
if(_gameList.name(data) == " [..]")
|
||||||
selectParent();
|
selectParent();
|
||||||
else
|
else
|
||||||
setLocation(FilesystemNode(_gameList.path(data)));
|
setLocation(FilesystemNode(_gameList.path(data)));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
cmd = ItemActivated;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -53,6 +53,7 @@ class FileListWidget : public StringListWidget
|
||||||
|
|
||||||
/** Determines how to display files/folders */
|
/** Determines how to display files/folders */
|
||||||
void setFileListMode(FilesystemNode::ListMode mode) { _fsmode = mode; }
|
void setFileListMode(FilesystemNode::ListMode mode) { _fsmode = mode; }
|
||||||
|
void setFileExtension(const string& ext) { _extension = ext; }
|
||||||
|
|
||||||
/** Set current location (file or directory) */
|
/** Set current location (file or directory) */
|
||||||
void setLocation(const FilesystemNode& node, string select = "");
|
void setLocation(const FilesystemNode& node, string select = "");
|
||||||
|
@ -70,6 +71,7 @@ class FileListWidget : public StringListWidget
|
||||||
private:
|
private:
|
||||||
FilesystemNode::ListMode _fsmode;
|
FilesystemNode::ListMode _fsmode;
|
||||||
FilesystemNode _node, _selected;
|
FilesystemNode _node, _selected;
|
||||||
|
string _extension;
|
||||||
|
|
||||||
GameList _gameList;
|
GameList _gameList;
|
||||||
};
|
};
|
||||||
|
|
|
@ -327,57 +327,49 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
|
|
||||||
case kRomDirChosenCmd:
|
case kRomDirChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
myRomPath->setEditString(myBrowser->getResult().getShortPath());
|
||||||
myRomPath->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kSnapSaveDirChosenCmd:
|
case kSnapSaveDirChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
mySnapSavePath->setEditString(myBrowser->getResult().getShortPath());
|
||||||
mySnapSavePath->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kSnapLoadDirChosenCmd:
|
case kSnapLoadDirChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
mySnapLoadPath->setEditString(myBrowser->getResult().getShortPath());
|
||||||
mySnapLoadPath->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kCheatFileChosenCmd:
|
case kCheatFileChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
myCheatFile->setEditString(myBrowser->getResult().getShortPath());
|
||||||
myCheatFile->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kPaletteFileChosenCmd:
|
case kPaletteFileChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
myPaletteFile->setEditString(myBrowser->getResult().getShortPath());
|
||||||
myPaletteFile->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kPropsFileChosenCmd:
|
case kPropsFileChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
myPropsFile->setEditString(myBrowser->getResult().getShortPath());
|
||||||
myPropsFile->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kNVRamDirChosenCmd:
|
case kNVRamDirChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
myNVRamPath->setEditString(myBrowser->getResult().getShortPath());
|
||||||
myNVRamPath->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kStateDirChosenCmd:
|
case kStateDirChosenCmd:
|
||||||
{
|
{
|
||||||
FilesystemNode dir(myBrowser->getResult());
|
myStatePath->setEditString(myBrowser->getResult().getShortPath());
|
||||||
myStatePath->setEditString(dir.getShortPath());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,12 +205,6 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
bool FilesystemNodePOSIX::isAbsolute() const
|
|
||||||
{
|
|
||||||
return _path.length() > 0 && (_path[0] == '~' || _path[0] == '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool FilesystemNodePOSIX::makeDir()
|
bool FilesystemNodePOSIX::makeDir()
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,7 +75,6 @@ class FilesystemNodePOSIX : public AbstractFSNode
|
||||||
bool isFile() const { return _isFile; }
|
bool isFile() const { return _isFile; }
|
||||||
bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
||||||
bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
|
bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
|
||||||
bool isAbsolute() const;
|
|
||||||
bool makeDir();
|
bool makeDir();
|
||||||
bool rename(const string& newfile);
|
bool rename(const string& newfile);
|
||||||
|
|
||||||
|
|
|
@ -283,12 +283,6 @@ bool FilesystemNodeWin32::
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
bool FilesystemNodeWin32::isAbsolute() const
|
|
||||||
{
|
|
||||||
return _path.length() >= 2 && (_path[0] == '~' || _path[1] == ':');
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool FilesystemNodeWin32::makeDir()
|
bool FilesystemNodeWin32::makeDir()
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,6 @@ class FilesystemNodeWin32 : public AbstractFSNode
|
||||||
bool isFile() const { return _isFile; }
|
bool isFile() const { return _isFile; }
|
||||||
bool isReadable() const;
|
bool isReadable() const;
|
||||||
bool isWritable() const;
|
bool isWritable() const;
|
||||||
bool isAbsolute() const;
|
|
||||||
bool makeDir();
|
bool makeDir();
|
||||||
bool rename(const string& newfile);
|
bool rename(const string& newfile);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue