mirror of https://github.com/stella-emu/stella.git
The CheatWidget seems complete; RAM contents can now be changed.
Still TODO is somehow draw around the currently active widget, to show which widget is actually active. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@504 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
c00de2813c
commit
1b332ef8f0
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: AddrValueWidget.cxx,v 1.1 2005-06-15 18:45:28 stephena Exp $
|
// $Id: AddrValueWidget.cxx,v 1.2 2005-06-15 21:18:47 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -103,7 +103,7 @@ void AddrValueWidget::setList(const AddrList& alist, const ValueList& vlist)
|
||||||
{
|
{
|
||||||
sprintf(temp, "%.4x:", _addrList[i]);
|
sprintf(temp, "%.4x:", _addrList[i]);
|
||||||
_addrStringList.push_back(temp);
|
_addrStringList.push_back(temp);
|
||||||
sprintf(temp, "%.3d", _valueList[i]);
|
sprintf(temp, "%3d", _valueList[i]);
|
||||||
_valueStringList.push_back(temp);
|
_valueStringList.push_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ void AddrValueWidget::drawWidget(bool hilite)
|
||||||
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++)
|
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++)
|
||||||
{
|
{
|
||||||
const OverlayColor textColor = (_selectedItem == pos && _editMode)
|
const OverlayColor textColor = (_selectedItem == pos && _editMode)
|
||||||
? kTextColor : kTextColor;
|
? kColor : kTextColor;
|
||||||
const int y = _y + 2 + kLineHeight * i;
|
const int y = _y + 2 + kLineHeight * i;
|
||||||
|
|
||||||
// Draw the selected item inverted, on a highlighted background.
|
// Draw the selected item inverted, on a highlighted background.
|
||||||
|
@ -413,7 +413,6 @@ void AddrValueWidget::scrollToCurrent()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void AddrValueWidget::startEditMode()
|
void AddrValueWidget::startEditMode()
|
||||||
{
|
{
|
||||||
cerr << "AddrValueWidget::startEditMode()\n";
|
|
||||||
if (_editable && !_editMode && _selectedItem >= 0)
|
if (_editable && !_editMode && _selectedItem >= 0)
|
||||||
{
|
{
|
||||||
_editMode = true;
|
_editMode = true;
|
||||||
|
@ -432,11 +431,17 @@ void AddrValueWidget::endEditMode()
|
||||||
_editMode = false;
|
_editMode = false;
|
||||||
|
|
||||||
// Update the both the string representation and the real data
|
// Update the both the string representation and the real data
|
||||||
_valueStringList[_selectedItem] = _editString;
|
int value = atoi(_editString.c_str());
|
||||||
|
if(_editString.length() == 0 || value < 0 || value > 255)
|
||||||
|
{
|
||||||
|
abortEditMode();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int value = atoi(_editString.c_str());
|
char temp[10];
|
||||||
cerr << "new value: " << value << endl;
|
sprintf(temp, "%3d", value);
|
||||||
_valueList[_selectedItem] = value; // FIXME - do error checking
|
_valueStringList[_selectedItem] = temp;
|
||||||
|
_valueList[_selectedItem] = value;
|
||||||
|
|
||||||
sendCommand(kAVItemDataChangedCmd, _selectedItem);
|
sendCommand(kAVItemDataChangedCmd, _selectedItem);
|
||||||
}
|
}
|
||||||
|
@ -444,8 +449,18 @@ cerr << "new value: " << value << endl;
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void AddrValueWidget::abortEditMode()
|
void AddrValueWidget::abortEditMode()
|
||||||
{
|
{
|
||||||
cerr << "AddrValueWidget::abortEditMode()\n";
|
|
||||||
// undo any changes made
|
// undo any changes made
|
||||||
assert(_selectedItem >= 0);
|
assert(_selectedItem >= 0);
|
||||||
_editMode = false;
|
_editMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool AddrValueWidget::tryInsertChar(char c, int pos)
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
{
|
||||||
|
_editString.insert(pos, 1, c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: AddrValueWidget.hxx,v 1.1 2005-06-15 18:45:28 stephena Exp $
|
// $Id: AddrValueWidget.hxx,v 1.2 2005-06-15 21:18:47 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -59,11 +59,11 @@ class AddrValueWidget : public EditableWidget, public CommandSender
|
||||||
void setList(const StringList& list);
|
void setList(const StringList& list);
|
||||||
void setList(const AddrList& alist, const ValueList& vlist);
|
void setList(const AddrList& alist, const ValueList& vlist);
|
||||||
|
|
||||||
// int getSelected() const { return _selectedItem; }
|
int getSelectedAddr() const { return _addrList[_selectedItem]; }
|
||||||
// void setSelected(int item);
|
int getSelectedValue() const { return _valueList[_selectedItem]; }
|
||||||
// const string& getSelectedString() const { return _list[_selectedItem]; }
|
|
||||||
bool isEditable() const { return _editable; }
|
bool isEditable() const { return _editable; }
|
||||||
void setEditable(bool editable) { _editable = editable; }
|
void setEditable(bool editable) { _editable = editable; }
|
||||||
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
||||||
void scrollTo(int item);
|
void scrollTo(int item);
|
||||||
|
|
||||||
|
@ -92,7 +92,9 @@ class AddrValueWidget : public EditableWidget, public CommandSender
|
||||||
void lostFocusWidget();
|
void lostFocusWidget();
|
||||||
void scrollToCurrent();
|
void scrollToCurrent();
|
||||||
|
|
||||||
protected:
|
bool tryInsertChar(char c, int pos);
|
||||||
|
|
||||||
|
protected:
|
||||||
AddrList _addrList;
|
AddrList _addrList;
|
||||||
ValueList _valueList;
|
ValueList _valueList;
|
||||||
StringList _addrStringList;
|
StringList _addrStringList;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheatWidget.cxx,v 1.5 2005-06-15 18:45:28 stephena Exp $
|
// $Id: CheatWidget.cxx,v 1.6 2005-06-15 21:18:47 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -55,7 +55,7 @@ CheatWidget::CheatWidget(GuiObject* boss, int x, int y, int w, int h)
|
||||||
"Enter a value:", kTextAlignLeft);
|
"Enter a value:", kTextAlignLeft);
|
||||||
|
|
||||||
myEditBox = new EditNumWidget(boss, 90, ypos - 2, charWidth*10, charHeight, "");
|
myEditBox = new EditNumWidget(boss, 90, ypos - 2, charWidth*10, charHeight, "");
|
||||||
myEditBox->setFont(_boss->instance()->consoleFont());
|
myEditBox->setFont(instance()->consoleFont());
|
||||||
// myEditBox->setTarget(this);
|
// myEditBox->setTarget(this);
|
||||||
myActiveWidget = myEditBox;
|
myActiveWidget = myEditBox;
|
||||||
ypos += border;
|
ypos += border;
|
||||||
|
@ -122,15 +122,9 @@ void CheatWidget::handleCommand(CommandSender* sender, int cmd, int data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kAVItemDataChangedCmd:
|
case kAVItemDataChangedCmd:
|
||||||
cerr << "data changed\n";
|
int addr = myResultsList->getSelectedAddr() - kRamStart;
|
||||||
break;
|
int value = myResultsList->getSelectedValue();
|
||||||
|
instance()->debugger().writeRAM(addr, value);
|
||||||
case kAVItemDoubleClickedCmd:
|
|
||||||
cerr << "kListItemDoubleClickedCmd\n";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kAVItemActivatedCmd:
|
|
||||||
cerr << "kListItemActivatedCmd\n";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,11 +140,11 @@ void CheatWidget::doSearch()
|
||||||
// An empty field means return all memory locations
|
// An empty field means return all memory locations
|
||||||
comparisonSearch = false;
|
comparisonSearch = false;
|
||||||
}
|
}
|
||||||
else if(str[0] == '+' || str[0] == '-')
|
else if(str.find_first_of("+-", 0) != string::npos)
|
||||||
{
|
{
|
||||||
// Don't accept these characters here, only in compare
|
// Don't accept these characters here, only in compare
|
||||||
myEditBox->setEditString("");
|
myResult->setLabel("Invalid input +|-");
|
||||||
return; // FIXME - message about invalid format
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int searchVal = atoi(str.c_str());
|
int searchVal = atoi(str.c_str());
|
||||||
|
@ -160,7 +154,7 @@ void CheatWidget::doSearch()
|
||||||
|
|
||||||
// Now, search all memory locations for this value, and add it to the
|
// Now, search all memory locations for this value, and add it to the
|
||||||
// search array
|
// search array
|
||||||
Debugger& dbg = _boss->instance()->debugger();
|
Debugger& dbg = instance()->debugger();
|
||||||
AddrValue av;
|
AddrValue av;
|
||||||
int searchCount = 0;
|
int searchCount = 0;
|
||||||
for(int addr = 0; addr < kRamSize; ++addr)
|
for(int addr = 0; addr < kRamSize; ++addr)
|
||||||
|
@ -216,6 +210,13 @@ void CheatWidget::doCompare()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do some pre-processing on the string
|
// Do some pre-processing on the string
|
||||||
|
if(str.find_first_of("+-", 0) > 0)
|
||||||
|
{
|
||||||
|
// Only accept '+' or '-' at the start of the string
|
||||||
|
myResult->setLabel("Input must be [+|-]NUM");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(str[0] == '+' || str[0] == '-')
|
if(str[0] == '+' || str[0] == '-')
|
||||||
{
|
{
|
||||||
bool negative = false;
|
bool negative = false;
|
||||||
|
@ -235,7 +236,7 @@ void CheatWidget::doCompare()
|
||||||
AddrValueList tempList;
|
AddrValueList tempList;
|
||||||
|
|
||||||
// Now, search all memory locations specified in mySearchArray for this value
|
// Now, search all memory locations specified in mySearchArray for this value
|
||||||
Debugger& dbg = _boss->instance()->debugger();
|
Debugger& dbg = instance()->debugger();
|
||||||
AddrValue av;
|
AddrValue av;
|
||||||
int searchCount = 0;
|
int searchCount = 0;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: ListWidget.cxx,v 1.18 2005-06-15 18:45:28 stephena Exp $
|
// $Id: ListWidget.cxx,v 1.19 2005-06-15 21:18:47 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -215,6 +215,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
_quickSelectStr = (char)ascii;
|
_quickSelectStr = (char)ascii;
|
||||||
else
|
else
|
||||||
_quickSelectStr += (char)ascii;
|
_quickSelectStr += (char)ascii;
|
||||||
|
_quickSelectTime = time + 300;
|
||||||
|
|
||||||
// FIXME: This is bad slow code (it scans the list linearly each time a
|
// FIXME: This is bad slow code (it scans the list linearly each time a
|
||||||
// key is pressed); it could be much faster. Only of importance if we have
|
// key is pressed); it could be much faster. Only of importance if we have
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: PromptWidget.cxx,v 1.3 2005-06-14 01:11:48 stephena Exp $
|
// $Id: PromptWidget.cxx,v 1.4 2005-06-15 21:18:47 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -259,11 +259,34 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 273: // cursor up
|
case 273: // cursor up
|
||||||
historyScroll(+1);
|
if (instance()->eventHandler().kbdShift(modifiers))
|
||||||
|
{
|
||||||
|
if(_scrollLine <= _firstLineInBuffer + _linesPerPage - 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_scrollLine -= 1;
|
||||||
|
updateScrollBuffer();
|
||||||
|
draw();
|
||||||
|
instance()->frameBuffer().refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
historyScroll(+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 274: // cursor down
|
case 274: // cursor down
|
||||||
historyScroll(-1);
|
if (instance()->eventHandler().kbdShift(modifiers))
|
||||||
|
{
|
||||||
|
// Don't scroll down when at bottom of buffer
|
||||||
|
if(_scrollLine >= _promptEndPos / _lineWidth)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_scrollLine += 1;
|
||||||
|
updateScrollBuffer();
|
||||||
|
draw();
|
||||||
|
instance()->frameBuffer().refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
historyScroll(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 275: // cursor right
|
case 275: // cursor right
|
||||||
|
|
Loading…
Reference in New Issue