Re-added (center) commandline argument, which was in a previous version

of Stella.  It defaults to true/on, so if you don't want centering, use
'-center false' on the commandline at least once (or edit the config file).

Some more work on the RamWidget and ByteGridWidget.  Entering values in hex
now works correctly, and 128 byte RAM area is now updated.

More work on the automatic updating of the tabs.  Tabs are now updated when
debugging mode is entered, or when a new tab is selected.

Shortened the width of the debugging tab area and added an area for commonly
use actions/buttons on the right.  Currently it contains 'Step' and 'Trace'
buttons.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@517 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-06-17 14:42:49 +00:00
parent 379aa0c3ed
commit 07ea0bbae1
11 changed files with 102 additions and 68 deletions

View File

@ -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 <fstream>
@ -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())

View File

@ -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);

View File

@ -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 <cassert>
@ -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 <size> 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 <original| Use the specified color palette\n"
<< " standard|\n"
<< " z26>\n"

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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();
}

View File

@ -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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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);