diff --git a/stella/src/common/mainSDL.cxx b/stella/src/common/mainSDL.cxx index 517c7a528..87d67cbbd 100644 --- a/stella/src/common/mainSDL.cxx +++ b/stella/src/common/mainSDL.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: mainSDL.cxx,v 1.45 2005-06-16 16:36:48 urchlay Exp $ +// $Id: mainSDL.cxx,v 1.46 2005-06-17 14:42:48 stephena Exp $ //============================================================================ #include @@ -152,7 +152,8 @@ int main(int argc, char* argv[]) } // Request that the SDL window be centered, if possible - // putenv("SDL_VIDEO_CENTERED=1"); + if(theOSystem->settings().getBool("center")) + putenv("SDL_VIDEO_CENTERED=1"); // Create the framebuffer(s) if(!theOSystem->createFrameBuffer()) diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index e630c2842..669c73bf8 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.9 2005-06-17 03:49:08 urchlay Exp $ +// $Id: Debugger.hxx,v 1.10 2005-06-17 14:42:49 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -49,7 +49,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.9 2005-06-17 03:49:08 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.10 2005-06-17 14:42:49 stephena Exp $ */ class Debugger : public DialogContainer { @@ -95,6 +95,10 @@ class Debugger : public DialogContainer sprintf(out, "%04x", i); return out; } + static int hex_to_dec(const char* h) + { + return (int) strtoimax(h, NULL, 16); + } void toggleBreakPoint(int bp); bool breakPoint(int bp); diff --git a/stella/src/emucore/Settings.cxx b/stella/src/emucore/Settings.cxx index 8ad22bc5d..cd14fea82 100644 --- a/stella/src/emucore/Settings.cxx +++ b/stella/src/emucore/Settings.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: Settings.cxx,v 1.48 2005-06-16 01:11:28 stephena Exp $ +// $Id: Settings.cxx,v 1.49 2005-06-17 14:42:49 stephena Exp $ //============================================================================ #include @@ -48,6 +48,7 @@ Settings::Settings(OSystem* osystem) set("zoom", "2"); set("fullscreen", "false"); set("grabmouse", "false"); + set("center", "true"); set("palette", "standard"); set("sound", "true"); @@ -241,6 +242,7 @@ void Settings::usage() << " -zoom Makes window be 'size' times normal\n" << " -fullscreen <1|0> Play the game in fullscreen mode\n" << " -grabmouse <1|0> Keeps the mouse in the game window\n" + << " -center <1|0> Centers game window (if possible)\n" << " -palette \n" diff --git a/stella/src/gui/ByteGridWidget.cxx b/stella/src/gui/ByteGridWidget.cxx index 1f2c1073d..7d6a419b5 100644 --- a/stella/src/gui/ByteGridWidget.cxx +++ b/stella/src/gui/ByteGridWidget.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: ByteGridWidget.cxx,v 1.2 2005-06-16 22:18:02 stephena Exp $ +// $Id: ByteGridWidget.cxx,v 1.3 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -25,6 +25,7 @@ #include "OSystem.hxx" #include "Widget.hxx" #include "Dialog.hxx" +#include "Debugger.hxx" #include "FrameBuffer.hxx" #include "ByteGridWidget.hxx" @@ -50,10 +51,7 @@ ByteGridWidget::ByteGridWidget(GuiObject* boss, int x, int y, int cols, int rows _type = kByteGridWidget; _editMode = false; - _currentPos = 0; _currentKeyDown = 0; - - _quickSelectTime = 0; // The item is selected, thus _bgcolor is used to draw the caret and // _textcolorhi to erase it @@ -80,7 +78,7 @@ void ByteGridWidget::setList(const ByteAddrList& alist, const ByteValueList& vli _valueList = vlist; int size = _addrList.size(); // assume vlist is the same size -//FIXME assert(size != _rows * _cols); + assert(size == _rows * _cols); // An efficiency thing char temp[10]; @@ -92,13 +90,6 @@ void ByteGridWidget::setList(const ByteAddrList& alist, const ByteValueList& vli _valueStringList.push_back(temp); } - if (_currentPos >= size) - _currentPos = size - 1; - if (_currentPos < 0) - _currentPos = 0; - _selectedItem = 0; - _currentRow = 0; - _currentCol = 0; _editMode = false; } @@ -296,9 +287,9 @@ void ByteGridWidget::handleCommand(CommandSender* sender, int cmd, int data) switch (cmd) { case kSetPositionCmd: - if (_currentPos != (int)data) + if (_selectedItem != (int)data) { - _currentPos = data; + _selectedItem = data; draw(); } break; @@ -396,7 +387,7 @@ void ByteGridWidget::endEditMode() _editMode = false; // Update the both the string representation and the real data - int value = atoi(_editString.c_str()); + int value = Debugger::hex_to_dec(_editString.c_str()); if(_editString.length() == 0 || value < 0 || value > 255) { abortEditMode(); @@ -404,10 +395,10 @@ void ByteGridWidget::endEditMode() } // Append a leading 0 when necessary - if(value < 10) + if(value < 16) // In hex, this is the largest single-digit value _editString = "0" + _editString; - _valueStringList[_selectedItem] = _editString; // FIXME - make sure only length of 2 + _valueStringList[_selectedItem] = _editString; _valueList[_selectedItem] = value; sendCommand(kBGItemDataChangedCmd, _selectedItem); @@ -424,7 +415,9 @@ void ByteGridWidget::abortEditMode() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool ByteGridWidget::tryInsertChar(char c, int pos) { - if (c >= '0' && c <= '9') + // Not sure how efficient this is, or should we even care? + c = tolower(c); + if (c >= '0' && c <= '9' || c >= 'a' && c <= 'f') { _editString.insert(pos, 1, c); return true; diff --git a/stella/src/gui/ByteGridWidget.hxx b/stella/src/gui/ByteGridWidget.hxx index ccedfe8f7..a33d2720e 100644 --- a/stella/src/gui/ByteGridWidget.hxx +++ b/stella/src/gui/ByteGridWidget.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: ByteGridWidget.hxx,v 1.2 2005-06-16 22:18:02 stephena Exp $ +// $Id: ByteGridWidget.hxx,v 1.3 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -50,8 +50,8 @@ class ByteGridWidget : public EditableWidget, public CommandSender void setList(const ByteAddrList& alist, const ByteValueList& vlist); -// int getSelectedAddr() const { return _addrList[_selectedItem]; } -// int getSelectedValue() const { return _valueList[_selectedItem]; } + int getSelectedAddr() const { return _addrList[_selectedItem]; } + int getSelectedValue() const { return _valueList[_selectedItem]; } bool isEditable() const { return _editable; } void setEditable(bool editable) { _editable = editable; } @@ -93,14 +93,9 @@ class ByteGridWidget : public EditableWidget, public CommandSender bool _editable; bool _editMode; - int _currentPos; - int _entriesPerPage; int _selectedItem; int _currentKeyDown; string _backupString; - - string _quickSelectStr; - int _quickSelectTime; }; #endif diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index e98c209dc..0b769a18a 100644 --- a/stella/src/gui/DebuggerDialog.cxx +++ b/stella/src/gui/DebuggerDialog.cxx @@ -13,20 +13,28 @@ // 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.12 2005-06-17 03:49:10 urchlay Exp $ +// $Id: DebuggerDialog.cxx,v 1.13 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project //============================================================================ +#include "Widget.hxx" +#include "Dialog.hxx" #include "TabWidget.hxx" #include "ListWidget.hxx" #include "PromptWidget.hxx" #include "CheatWidget.hxx" #include "RamWidget.hxx" +#include "Debugger.hxx" #include "DebuggerDialog.hxx" +enum { + kDDStepCmd = 'DDst', + kDDTraceCmd = 'DDtr' +}; + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent, int x, int y, int w, int h) @@ -34,13 +42,14 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent, myTab(NULL) { const int vBorder = 4; + const int vWidth = _w - kButtonWidth - 20; // The tab widget - myTab = new TabWidget(this, 0, vBorder, _w, _h - vBorder - 1); + myTab = new TabWidget(this, 0, vBorder, vWidth, _h - vBorder - 1); // 1) The Prompt/console tab myTab->addTab("Prompt"); - myPrompt = new PromptWidget(myTab, 2, 2, _w - vBorder, _h - 25); + myPrompt = new PromptWidget(myTab, 2, 2, vWidth - vBorder, _h - 25); myTab->setParentWidget(0, myPrompt, myPrompt); // 2) The CPU tab @@ -49,7 +58,7 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent, // 3) The RAM tab myTab->addTab("RAM"); - RamWidget* ram = new RamWidget(myTab, 2, 2, _w - vBorder, _h - 25); + RamWidget* ram = new RamWidget(myTab, 2, 2, vWidth - vBorder, _h - 25); myTab->setParentWidget(2, ram, ram->activeWidget()); // 4) The ROM tab @@ -63,11 +72,17 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent, // 6) The Cheat tab myTab->addTab("Cheat"); CheatWidget* cheat = new CheatWidget(myTab, 2, 2, - _w - vBorder, _h - 25); + vWidth - vBorder, _h - 25); myTab->setParentWidget(5, cheat, cheat->activeWidget()); // Set active tab to prompt myTab->setActiveTab(0); + + // Add some buttons that are always shown, no matter which tab we're in + int yoff = vBorder + kTabHeight + 5; + addButton(vWidth + 10, yoff, "Step", kDDStepCmd, 0); + yoff += 22; + addButton(vWidth + 10, yoff, "Trace", kDDTraceCmd, 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -78,6 +93,7 @@ DebuggerDialog::~DebuggerDialog() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::loadConfig() { + myTab->loadConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -87,6 +103,27 @@ void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PromptWidget *DebuggerDialog::prompt() { +void DebuggerDialog::handleCommand(CommandSender* sender, int cmd, int data) +{ + switch(cmd) + { + case kDDStepCmd: + instance()->debugger().step(); + myTab->loadConfig(); // make sure all the tabs are updated + break; + + case kDDTraceCmd: + instance()->debugger().trace(); + myTab->loadConfig(); // make sure all the tabs are updated + break; + + default: + Dialog::handleCommand(sender, cmd, data); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +PromptWidget *DebuggerDialog::prompt() +{ return myPrompt; } diff --git a/stella/src/gui/DebuggerDialog.hxx b/stella/src/gui/DebuggerDialog.hxx index 8f45b4c37..813446610 100644 --- a/stella/src/gui/DebuggerDialog.hxx +++ b/stella/src/gui/DebuggerDialog.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: DebuggerDialog.hxx,v 1.8 2005-06-17 03:49:10 urchlay Exp $ +// $Id: DebuggerDialog.hxx,v 1.9 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -39,6 +39,7 @@ class DebuggerDialog : public Dialog PromptWidget *prompt(); virtual void loadConfig(); virtual void handleKeyDown(int ascii, int keycode, int modifiers); + virtual void handleCommand(CommandSender* sender, int cmd, int data); protected: TabWidget* myTab; diff --git a/stella/src/gui/EditableWidget.cxx b/stella/src/gui/EditableWidget.cxx index 7ba29f65c..1cdb08cc2 100644 --- a/stella/src/gui/EditableWidget.cxx +++ b/stella/src/gui/EditableWidget.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: EditableWidget.cxx,v 1.4 2005-06-16 18:40:17 stephena Exp $ +// $Id: EditableWidget.cxx,v 1.5 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -127,7 +127,7 @@ bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers) default: if (tryInsertChar((char)ascii, _caretPos)) { - _caretPos++; + _caretPos++; dirty = true; } else diff --git a/stella/src/gui/RamWidget.cxx b/stella/src/gui/RamWidget.cxx index ae7d71fa0..1704c52f5 100644 --- a/stella/src/gui/RamWidget.cxx +++ b/stella/src/gui/RamWidget.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: RamWidget.cxx,v 1.2 2005-06-16 22:18:02 stephena Exp $ +// $Id: RamWidget.cxx,v 1.3 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -62,8 +62,6 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h) myRamGrid->setTarget(this); myActiveWidget = myRamGrid; - fillGrid(); - #if 0 const int border = 20; const int bwidth = 50; @@ -130,35 +128,17 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data) { switch(cmd) { -/* - case kBGItemDoubleClickedCmd: - cerr << "double-clicked on " << data << endl; - break; - - case kBGItemActivatedCmd: - cerr << "item activated on " << data << endl; - break; - - case kBGSelectionChangedCmd: - cerr << "selection changed on " << data << endl; - break; -*/ case kBGItemDataChangedCmd: - cerr << "data changed on " << data << endl; -/* - int addr = myResultsList->getSelectedAddr() - kRamStart; - int value = myResultsList->getSelectedValue(); + int addr = myRamGrid->getSelectedAddr() - kRamStart; + int value = myRamGrid->getSelectedValue(); instance()->debugger().writeRAM(addr, value); -*/ break; } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RamWidget::loadConfig() { -cerr << "RamWidget::loadConfig()\n"; fillGrid(); } diff --git a/stella/src/gui/TabWidget.cxx b/stella/src/gui/TabWidget.cxx index 219e6752f..0b5d72c80 100644 --- a/stella/src/gui/TabWidget.cxx +++ b/stella/src/gui/TabWidget.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: TabWidget.cxx,v 1.8 2005-06-16 22:18:02 stephena Exp $ +// $Id: TabWidget.cxx,v 1.9 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -28,8 +28,6 @@ #include "TabWidget.hxx" enum { - kTabHeight = 16, - kTabLeftOffset = 4, kTabSpacing = 2, kTabPadding = 3 @@ -253,6 +251,21 @@ void TabWidget::handleCommand(CommandSender* sender, int cmd, int data) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TabWidget::loadConfig() +{ + // (Re)load the contents of all tabs + // It's up to each tab to decide if it wants to do anything on a reload + for (int id = 0; id < (int)_tabs.size(); ++id) + { + if(_tabs[id].parentWidget) + _tabs[id].parentWidget->loadConfig(); + } + + // Make sure changes are seen onscreen + instance()->frameBuffer().refresh(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool omitBottom) @@ -300,11 +313,13 @@ void TabWidget::drawWidget(bool hilite) x += _tabWidth + kTabSpacing; } - // Draw more horizontal lines + // Draw a frame around the widget area (belows the tabs) fb.hLine(left1, _y + kTabHeight - 1, right1, kColor); fb.hLine(left2, _y + kTabHeight - 1, right2, kColor); fb.hLine(_x+1, _y + _h - 2, _x + _w - 2, kShadowColor); fb.hLine(_x+1, _y + _h - 1, _x + _w - 2, kColor); + fb.vLine(_x + _w - 2, _y + kTabHeight - 1, _y + _h - 2, kColor); + fb.vLine(_x + _w - 1, _y + kTabHeight - 1, _y + _h - 2, kShadowColor); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/TabWidget.hxx b/stella/src/gui/TabWidget.hxx index 0abe7830d..c7a1bcf07 100644 --- a/stella/src/gui/TabWidget.hxx +++ b/stella/src/gui/TabWidget.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: TabWidget.hxx,v 1.6 2005-06-16 22:18:02 stephena Exp $ +// $Id: TabWidget.hxx,v 1.7 2005-06-17 14:42:49 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -28,6 +28,10 @@ #include "Array.hxx" #include "bspf.hxx" +enum { + kTabHeight = 16 +}; + class TabWidget : public Widget, public CommandSender { struct Tab { @@ -65,6 +69,8 @@ class TabWidget : public Widget, public CommandSender virtual bool handleKeyDown(int ascii, int keycode, int modifiers); virtual void handleCommand(CommandSender* sender, int cmd, int data); + virtual void loadConfig(); + protected: virtual void drawWidget(bool hilite); virtual Widget *findWidget(int x, int y);