diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 1a182b1ac..119f437a7 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.cxx,v 1.112 2007-08-12 23:05:12 stephena Exp $ +// $Id: Debugger.cxx,v 1.113 2007-08-14 19:49:20 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -233,78 +233,81 @@ void Debugger::autoLoadSymbols(string fileName) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string Debugger::loadListFile(string f) { - char buffer[255]; +string Debugger::loadListFile(string f) +{ + char buffer[255]; - if(f == "") { - f = myOSystem->romFile(); + if(f == "") + { + f = myOSystem->romFile(); - string::size_type pos; - if( (pos = f.find_last_of('.')) != string::npos ) { - f.replace(pos, f.size(), ".lst"); - } else { - f += ".lst"; - } - } + string::size_type pos; + if( (pos = f.find_last_of('.')) != string::npos ) + f.replace(pos, f.size(), ".lst"); + else + f += ".lst"; + } - ifstream in(f.c_str()); - if(!in.is_open()) - return "Unable to read listing from " + f; + ifstream in(f.c_str()); + if(!in.is_open()) + return "Unable to read listing from " + f; - sourceLines.clear(); - int count = 0; - while( !in.eof() ) { - if(!in.getline(buffer, 255)) - break; + sourceLines.clear(); + int count = 0; + while( !in.eof() ) + { + if(!in.getline(buffer, 255)) + break; - if( strlen(buffer) >= 14 && - buffer[0] == ' ' && - buffer[7] == ' ' && - buffer[8] == ' ' && - isxdigit(buffer[9]) && - isxdigit(buffer[12]) && - BSPF_isblank(buffer[13])) - { - count++; - char addr[5]; - for(int i=0; i<4; i++) - addr[i] = buffer[9+i]; + if(strlen(buffer) >= 14 && + buffer[0] == ' ' && + buffer[7] == ' ' && + buffer[8] == ' ' && + isxdigit(buffer[9]) && + isxdigit(buffer[12]) && + BSPF_isblank(buffer[13])) + { + count++; + char addr[5]; + for(int i=0; i<4; i++) + addr[i] = buffer[9+i]; - for(char *c = buffer; *c != '\0'; c++) - if(*c == '\t') *c = ' '; + for(char *c = buffer; *c != '\0'; c++) + if(*c == '\t') *c = ' '; - addr[4] = '\0'; - string a = addr; - string b = buffer; - sourceLines.insert(make_pair(a, b)); - } - } + addr[4] = '\0'; + string a = addr; + string b = buffer; + sourceLines.insert(make_pair(a, b)); + } + } + in.close(); - in.close(); - - return valueToString(count) + " lines loaded from " + f; + return valueToString(count) + " lines loaded from " + f; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Debugger::getSourceLines(int addr) { - if(sourceLines.size() == 0) - return "no list file loaded (try \"loadlst file.lst\")"; +const string Debugger::getSourceLines(int addr) +{ + if(sourceLines.size() == 0) + return ""; - string ret; - string want = to_hex_16(addr); + string ret; + string want = to_hex_16(addr); - bool found = false; - pair lines = sourceLines.equal_range(want); - for(ListIter i = lines.first; i != lines.second; i++) { - found = true; - ret += i->second; - ret += "\n"; - } + bool found = false; + pair lines = sourceLines.equal_range(want); + for(ListIter i = lines.first; i != lines.second; i++) + { + found = true; + ret += i->second; + ret += "\n"; + } - if(found) - return ret; - else - return ""; + if(found) + return ret; + else + return ""; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -901,8 +904,9 @@ void Debugger::addLabel(string label, int address) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::reloadROM() { - myOSystem->createConsole( myOSystem->romFile() ); +void Debugger::reloadROM() +{ + myOSystem->createConsole(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1003,13 +1007,14 @@ GUI::Rect Debugger::getStatusBounds() const { // The status area is the full area to the right of the TIA image // extending as far as necessary + // 30% of any space above 1030 pixels will be allocated to this area GUI::Rect dlg = getDialogBounds(); GUI::Rect tia = getTiaBounds(); int x1 = tia.right + 1; int y1 = 0; int x2 = tia.right + 225 + (dlg.width() > 1030 ? - (int) (0.2 * (dlg.width() - 1030)) : 0); + (int) (0.3 * (dlg.width() - 1030)) : 0); int y2 = tia.bottom; GUI::Rect r(x1, y1, x2, y2); diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 85a9d2ac7..7e9bc52ee 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.hxx,v 1.88 2007-08-10 18:27:10 stephena Exp $ +// $Id: Debugger.hxx,v 1.89 2007-08-14 19:49:20 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -69,7 +69,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)(); for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.88 2007-08-10 18:27:10 stephena Exp $ + @version $Id: Debugger.hxx,v 1.89 2007-08-14 19:49:20 stephena Exp $ */ class Debugger : public DialogContainer { @@ -275,6 +275,7 @@ class Debugger : public DialogContainer string loadListFile(string f = ""); const string getSourceLines(int addr); + bool haveListFile() { return sourceLines.size() > 0; } bool saveROM(string filename); diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 997b13d24..d3912b2b8 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.97 2007-08-10 18:27:10 stephena Exp $ +// $Id: DebuggerParser.cxx,v 1.98 2007-08-14 19:49:20 stephena Exp $ //============================================================================ #include @@ -111,6 +111,7 @@ string DebuggerParser::run(const string& command) if(commands[i].refreshRequired) debugger->myBaseDialog->loadConfig(); +cerr << " ==> commandResult = " << commandResult << endl; return commandResult; } } @@ -412,7 +413,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb) argStrings.push_back(curArg); argCount = argStrings.size(); - +cerr << "count = " << argCount << endl; /* cerr << "verb = " << verb << endl; cerr << "arguments (" << argCount << "):\n"; @@ -964,6 +965,9 @@ void DebuggerParser::executeFunction() // "list" void DebuggerParser::executeList() { + if(!debugger->haveListFile()) + commandResult = "no list file loaded (try \"loadlist file.lst\")"; + for(int i=args[0] - 2; igetSourceLines(i); } @@ -1097,9 +1101,10 @@ void DebuggerParser::executeRam() // "reload" void DebuggerParser::executeReload() { - debugger->reloadROM(); + debugger->quit(); + debugger->getOSystem()->createConsole(); debugger->start(); - commandResult = "reloaded"; + commandResult = "_EXIT_DEBUGGER"; // Set PromptWidget for more info } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1147,7 +1152,7 @@ void DebuggerParser::executeRun() { debugger->saveOldState(); debugger->quit(); - commandResult = "exiting debugger"; + commandResult = "_EXIT_DEBUGGER"; // See PromptWidget for more info } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1571,7 +1576,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { { "list", "List source (if loaded with loadlst)", - false, + true, false, { kARG_WORD, kARG_END_ARGS }, &DebuggerParser::executeList diff --git a/stella/src/debugger/gui/DebuggerDialog.cxx b/stella/src/debugger/gui/DebuggerDialog.cxx index 5caaea2f0..ececef71d 100644 --- a/stella/src/debugger/gui/DebuggerDialog.cxx +++ b/stella/src/debugger/gui/DebuggerDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerDialog.cxx,v 1.20 2007-08-06 20:16:51 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.21 2007-08-14 19:49:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -199,6 +199,7 @@ void DebuggerDialog::addTabArea() void DebuggerDialog::addStatusArea() { const GUI::Font& font = instance()->consoleFont(); + const int lineHeight = font.getLineHeight(); GUI::Rect r = instance()->debugger().getStatusBounds(); int xpos, ypos; @@ -206,10 +207,11 @@ void DebuggerDialog::addStatusArea() myTiaInfo = new TiaInfoWidget(this, instance()->consoleFont(), xpos, ypos); ypos += myTiaInfo->getHeight() + 10; - myTiaZoom = new TiaZoomWidget(this, instance()->consoleFont(), xpos+10, ypos); + myTiaZoom = new TiaZoomWidget(this, instance()->consoleFont(), xpos+10, ypos, + r.width()-10, r.height()-lineHeight-ypos-10); addToFocusList(myTiaZoom->getFocusList()); - xpos += 10; ypos += myTiaZoom->getHeight() + 20; + xpos += 10; ypos += myTiaZoom->getHeight() + 10; myMessageBox = new EditTextWidget(this, instance()->consoleFont(), xpos, ypos, myTiaZoom->getWidth(), font.getLineHeight(), ""); diff --git a/stella/src/debugger/gui/PromptWidget.cxx b/stella/src/debugger/gui/PromptWidget.cxx index 8a120f169..57877e716 100644 --- a/stella/src/debugger/gui/PromptWidget.cxx +++ b/stella/src/debugger/gui/PromptWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptWidget.cxx,v 1.18 2007-08-12 23:05:12 stephena Exp $ +// $Id: PromptWidget.cxx,v 1.19 2007-08-14 19:49:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -189,8 +189,17 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) addToHistory(command.c_str()); // Pass the command to the debugger, and print the result - string result = instance()->debugger().run(command) + "\n"; - print( result ); + string result = instance()->debugger().run(command); + + // This is a bit of a hack + // Certain commands remove the debugger dialog from underneath us, + // so we shouldn't print any messages + // Those commands will return 'EXIT_DEBUGGER' as their result +//cerr << " ==> result = \'" << result << "\'\n"; + if(result == "_EXIT_DEBUGGER") + return true; + + print(result + "\n"); } printPrompt(); @@ -500,6 +509,18 @@ GUI::Rect PromptWidget::getRect() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptWidget::loadConfig() { +cerr << "loadConfig()" << endl + << "_promptStartPos = " << _promptStartPos << endl + << "_promptEndPos = " << _promptEndPos << endl + << "_currentPos = " << _currentPos << endl + << endl; + + if(_promptStartPos != _currentPos) + { + print(PROMPT); + _promptStartPos = _promptEndPos = _currentPos; + } + // See logic at the end of handleKeyDown for an explanation of this _makeDirty = true; diff --git a/stella/src/debugger/gui/PromptWidget.hxx b/stella/src/debugger/gui/PromptWidget.hxx index d563158df..298f8f13c 100644 --- a/stella/src/debugger/gui/PromptWidget.hxx +++ b/stella/src/debugger/gui/PromptWidget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptWidget.hxx,v 1.9 2007-01-01 18:04:44 stephena Exp $ +// $Id: PromptWidget.hxx,v 1.10 2007-08-14 19:49:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -85,7 +85,7 @@ class PromptWidget : public Widget, public CommandSender void loadConfig(); - protected: + private: int _buffer[kBufferSize]; int _linesInBuffer; diff --git a/stella/src/debugger/gui/TiaZoomWidget.cxx b/stella/src/debugger/gui/TiaZoomWidget.cxx index fee799b0a..e37d6b73a 100644 --- a/stella/src/debugger/gui/TiaZoomWidget.cxx +++ b/stella/src/debugger/gui/TiaZoomWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TiaZoomWidget.cxx,v 1.11 2007-01-01 18:04:44 stephena Exp $ +// $Id: TiaZoomWidget.cxx,v 1.12 2007-08-14 19:49:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,7 +29,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, - int x, int y) + int x, int y, int w, int h) : Widget(boss, font, x, y, 16, 16), CommandSender(boss), myMenu(NULL) @@ -37,8 +37,12 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANTS_RAWDATA; _type = kTiaZoomWidget; - _w = 210; - _h = 120; + _bgcolor = _bgcolorhi = kDlgColor; + + // Use all available space, up to the maximum bounds of the TIA image + // Width myst + _w = BSPF_min(w, 320); + _h = BSPF_min(h, 260); addFocusWidget(this); diff --git a/stella/src/debugger/gui/TiaZoomWidget.hxx b/stella/src/debugger/gui/TiaZoomWidget.hxx index 271769c13..576564787 100644 --- a/stella/src/debugger/gui/TiaZoomWidget.hxx +++ b/stella/src/debugger/gui/TiaZoomWidget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TiaZoomWidget.hxx,v 1.6 2007-01-01 18:04:44 stephena Exp $ +// $Id: TiaZoomWidget.hxx,v 1.7 2007-08-14 19:49:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -32,7 +32,8 @@ class ContextMenu; class TiaZoomWidget : public Widget, public CommandSender { public: - TiaZoomWidget(GuiObject *boss, const GUI::Font& font, int x, int y); + TiaZoomWidget(GuiObject *boss, const GUI::Font& font, + int x, int y, int w, int h); virtual ~TiaZoomWidget(); void loadConfig();