mirror of https://github.com/stella-emu/stella.git
Added first pass of CpuWidget.
Renamed ByteGridWidget to DataGridWidget, because it can be used to accept data other than bytes (also words). Further work on making the GUI use whichever base you set as default. This one seems to be a hard nut to crack. Changed behaviour of '-debugheight' to specify the number of lines to use for the debugging area, vs the absolute pixels to use. So '-debugheight 20' would make the debugger be 20 lines tall (in the PromptWidget). The minimum height is now 15 lines, and all GUI elements will be drawn according to this. Still TODO is get the 'height' command to work in the debugger. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@533 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
f3fd39be4c
commit
b20a2ffc32
|
@ -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: makefile,v 1.101 2005-06-16 18:40:16 stephena Exp $
|
||||
## $Id: makefile,v 1.102 2005-06-20 18:32:10 stephena Exp $
|
||||
##============================================================================
|
||||
|
||||
##============================================================================
|
||||
|
@ -158,12 +158,12 @@ M6502_OBJS = D6502.o Device.o M6502.o M6502Low.o M6502Hi.o NullDev.o System.o
|
|||
GUI_OBJS = Font.o Menu.o Launcher.o \
|
||||
Widget.o PopUpWidget.o ScrollBarWidget.o ListWidget.o TabWidget.o \
|
||||
EditableWidget.o EditTextWidget.o EditNumWidget.o AddrValueWidget.o \
|
||||
ByteGridWidget.o \
|
||||
DataGridWidget.o \
|
||||
Dialog.o DialogContainer.o OptionsDialog.o VideoDialog.o AudioDialog.o \
|
||||
EventMappingDialog.o GameInfoDialog.o HelpDialog.o AboutDialog.o \
|
||||
LauncherDialog.o LauncherOptionsDialog.o BrowserDialog.o GameList.o \
|
||||
ProgressDialog.o \
|
||||
DebuggerDialog.o PromptWidget.o CheatWidget.o RamWidget.o
|
||||
DebuggerDialog.o PromptWidget.o CheatWidget.o RamWidget.o CpuWidget.o
|
||||
|
||||
DBG_OBJS = Debugger.o DebuggerParser.o EquateList.o PackedBitArray.o
|
||||
|
||||
|
@ -421,8 +421,8 @@ EditNumWidget.o: $(GUI)/EditNumWidget.cxx $(GUI)/EditNumWidget.hxx
|
|||
AddrValueWidget.o: $(GUI)/AddrValueWidget.cxx $(GUI)/AddrValueWidget.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/AddrValueWidget.cxx
|
||||
|
||||
ByteGridWidget.o: $(GUI)/ByteGridWidget.cxx $(GUI)/ByteGridWidget.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/ByteGridWidget.cxx
|
||||
DataGridWidget.o: $(GUI)/DataGridWidget.cxx $(GUI)/DataGridWidget.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/DataGridWidget.cxx
|
||||
|
||||
Dialog.o: $(GUI)/Dialog.cxx $(GUI)/Dialog.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Dialog.cxx
|
||||
|
@ -478,6 +478,9 @@ CheatWidget.o: $(GUI)/CheatWidget.cxx $(GUI)/CheatWidget.hxx
|
|||
RamWidget.o: $(GUI)/RamWidget.cxx $(GUI)/RamWidget.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/RamWidget.cxx
|
||||
|
||||
CpuWidget.o: $(GUI)/CpuWidget.cxx $(GUI)/CpuWidget.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/CpuWidget.cxx
|
||||
|
||||
Debugger.o: $(DBG)/Debugger.cxx $(DBG)/Debugger.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/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.19 2005-06-19 16:53:57 urchlay Exp $
|
||||
// $Id: Debugger.cxx,v 1.20 2005-06-20 18:32:11 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -59,14 +59,18 @@ Debugger::~Debugger()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::initialize()
|
||||
{
|
||||
// Calculate the actual pixels required for the # of lines
|
||||
// This is currently a bit of a hack, since it uses pixel
|
||||
// values that it shouldn't know about (font and tab height, etc)
|
||||
int userHeight = myOSystem->settings().getInt("debugheight");
|
||||
if(userHeight < kDebuggerHeight)
|
||||
userHeight = kDebuggerHeight;
|
||||
if(userHeight < kDebuggerLines)
|
||||
userHeight = kDebuggerLines;
|
||||
userHeight = (userHeight + 3) * kDebuggerLineHeight - 8;
|
||||
|
||||
int x = 0,
|
||||
y = myConsole->mediaSource().height(),
|
||||
w = kDebuggerWidth,
|
||||
h = userHeight - y;
|
||||
h = userHeight;
|
||||
|
||||
delete myBaseDialog;
|
||||
DebuggerDialog *dd = new DebuggerDialog(myOSystem, this, x, y, w, h);
|
||||
|
@ -77,9 +81,14 @@ void Debugger::initialize()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::initializeVideo()
|
||||
{
|
||||
// Calculate the actual pixels required for entire screen
|
||||
// This is currently a bit of a hack, since it uses pixel
|
||||
// values that it shouldn't know about (font and tab height, etc)
|
||||
int userHeight = myOSystem->settings().getInt("debugheight");
|
||||
if(userHeight < kDebuggerHeight)
|
||||
userHeight = kDebuggerHeight;
|
||||
if(userHeight < kDebuggerLines)
|
||||
userHeight = kDebuggerLines;
|
||||
userHeight = (userHeight + 3) * kDebuggerLineHeight - 8 +
|
||||
myConsole->mediaSource().height();
|
||||
|
||||
string title = string("Stella version ") + STELLA_VERSION + ": Debugger mode";
|
||||
myOSystem->frameBuffer().initialize(title, kDebuggerWidth, userHeight, false);
|
||||
|
@ -483,19 +492,20 @@ int Debugger::dpeek(int addr) {
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::setHeight(int height) {
|
||||
if(height == 0)
|
||||
height = kDebuggerHeight;
|
||||
bool Debugger::setHeight(int height)
|
||||
{
|
||||
myOSystem->settings().getInt("debugheight");
|
||||
|
||||
if(height < kDebuggerHeight)
|
||||
if(height == 0)
|
||||
height = kDebuggerLines;
|
||||
|
||||
if(height < kDebuggerLines)
|
||||
return false;
|
||||
|
||||
myOSystem->settings().setInt("debugheight", height);
|
||||
/*
|
||||
// FIXME: this segfaults
|
||||
quit();
|
||||
initialize();
|
||||
initializeVideo();
|
||||
*/
|
||||
|
||||
// Restart the debugger subsystem
|
||||
myOSystem->resetDebugger();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,14 +13,13 @@
|
|||
// 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.17 2005-06-19 16:53:57 urchlay Exp $
|
||||
// $Id: Debugger.hxx,v 1.18 2005-06-20 18:32:11 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_HXX
|
||||
#define DEBUGGER_HXX
|
||||
|
||||
class OSystem;
|
||||
class DebuggerParser;
|
||||
|
||||
class Console;
|
||||
class System;
|
||||
|
@ -28,6 +27,7 @@ class D6502;
|
|||
|
||||
#include "DialogContainer.hxx"
|
||||
#include "M6502.hxx"
|
||||
#include "DebuggerParser.hxx"
|
||||
#include "EquateList.hxx"
|
||||
#include "PackedBitArray.hxx"
|
||||
#include "PromptWidget.hxx"
|
||||
|
@ -35,7 +35,8 @@ class D6502;
|
|||
|
||||
enum {
|
||||
kDebuggerWidth = 511,
|
||||
kDebuggerHeight = 383
|
||||
kDebuggerLineHeight = 12, // based on the height of the console font
|
||||
kDebuggerLines = 15,
|
||||
};
|
||||
|
||||
// Constants for RAM area
|
||||
|
@ -49,7 +50,7 @@ enum {
|
|||
for all debugging operations in Stella (parser, 6502 debugger, etc).
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Debugger.hxx,v 1.17 2005-06-19 16:53:57 urchlay Exp $
|
||||
@version $Id: Debugger.hxx,v 1.18 2005-06-20 18:32:11 stephena Exp $
|
||||
*/
|
||||
class Debugger : public DialogContainer
|
||||
{
|
||||
|
@ -101,10 +102,6 @@ class Debugger : public DialogContainer
|
|||
sprintf(out, "%04x", i);
|
||||
return out;
|
||||
}
|
||||
static int hex_to_dec(const char* h)
|
||||
{
|
||||
return (int) strtoimax(h, NULL, 16);
|
||||
}
|
||||
static char *to_bin(int dec, int places, char *buf) {
|
||||
int bit = 1;
|
||||
buf[places] = '\0';
|
||||
|
@ -127,10 +124,21 @@ class Debugger : public DialogContainer
|
|||
return to_bin(dec, 16, buf);
|
||||
}
|
||||
|
||||
bool parseArgument(string& arg, int *value, string& rendered,
|
||||
BaseFormat outputBase)
|
||||
{
|
||||
return myParser->parseArgument(arg, value, rendered, outputBase);
|
||||
}
|
||||
|
||||
string parseValue(int value, BaseFormat outputBase)
|
||||
{
|
||||
return myParser->parseValue(value, outputBase);
|
||||
}
|
||||
|
||||
void toggleBreakPoint(int bp);
|
||||
bool breakPoint(int bp);
|
||||
string disassemble(int start, int lines);
|
||||
bool setHeight(int height);
|
||||
string disassemble(int start, int lines);
|
||||
bool setHeight(int height);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -181,8 +189,8 @@ class Debugger : public DialogContainer
|
|||
void toggleV();
|
||||
void toggleD();
|
||||
void reset();
|
||||
void autoLoadSymbols(string file);
|
||||
void nextFrame();
|
||||
void autoLoadSymbols(string file);
|
||||
void nextFrame();
|
||||
void clearAllBreakPoints();
|
||||
|
||||
void formatFlags(int f, char *out);
|
||||
|
|
|
@ -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.18 2005-06-20 02:36:39 urchlay Exp $
|
||||
// $Id: DebuggerParser.cxx,v 1.19 2005-06-20 18:32:11 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -50,7 +50,7 @@ int DebuggerParser::conv_hex_digit(char d) {
|
|||
else return -1;
|
||||
}
|
||||
|
||||
void DebuggerParser::setBase(int base) {
|
||||
void DebuggerParser::setBase(BaseFormat base) {
|
||||
defaultBase = base;
|
||||
}
|
||||
|
||||
|
@ -162,40 +162,49 @@ int DebuggerParser::decipher_arg(string &arg) {
|
|||
|
||||
// The GUI uses this:
|
||||
bool DebuggerParser::parseArgument(
|
||||
string& arg, int *value, char *rendered, int outputBase=kBASE_DEFAULT)
|
||||
string& arg, int *value, string& rendered, BaseFormat outputBase)
|
||||
{
|
||||
*value = decipher_arg(arg);
|
||||
*value = decipher_arg(arg);
|
||||
|
||||
if(*value == -1) {
|
||||
sprintf(rendered, "error");
|
||||
return false;
|
||||
}
|
||||
if(*value == -1 || *value > 0xffff) {
|
||||
rendered = "error";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(outputBase == kBASE_DEFAULT)
|
||||
outputBase = defaultBase;
|
||||
rendered = parseValue(*value, outputBase);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch(outputBase) {
|
||||
case kBASE_2:
|
||||
if(*value < 0x100)
|
||||
sprintf(rendered, Debugger::to_bin_8(*value));
|
||||
else
|
||||
sprintf(rendered, Debugger::to_bin_16(*value));
|
||||
break;
|
||||
string DebuggerParser::parseValue(int value, BaseFormat outputBase)
|
||||
{
|
||||
char rendered[32];
|
||||
|
||||
case kBASE_10:
|
||||
sprintf(rendered, "%d", *value);
|
||||
break;
|
||||
if(outputBase == kBASE_DEFAULT)
|
||||
outputBase = defaultBase;
|
||||
|
||||
case kBASE_16:
|
||||
default:
|
||||
if(*value < 0x100)
|
||||
sprintf(rendered, Debugger::to_hex_8(*value));
|
||||
else
|
||||
sprintf(rendered, Debugger::to_hex_16(*value));
|
||||
break;
|
||||
switch(outputBase)
|
||||
{
|
||||
case kBASE_2:
|
||||
if(value < 0x100)
|
||||
sprintf(rendered, Debugger::to_bin_8(value));
|
||||
else
|
||||
sprintf(rendered, Debugger::to_bin_16(value));
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
case kBASE_10:
|
||||
sprintf(rendered, "%d", value);
|
||||
break;
|
||||
|
||||
case kBASE_16:
|
||||
default:
|
||||
if(value < 0x100)
|
||||
sprintf(rendered, Debugger::to_hex_8(value));
|
||||
else
|
||||
sprintf(rendered, Debugger::to_hex_16(value));
|
||||
break;
|
||||
}
|
||||
|
||||
return string(rendered);
|
||||
}
|
||||
|
||||
bool DebuggerParser::getArgs(const string& command) {
|
||||
|
|
|
@ -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.hxx,v 1.10 2005-06-20 02:36:39 urchlay Exp $
|
||||
// $Id: DebuggerParser.hxx,v 1.11 2005-06-20 18:32:11 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_PARSER_HXX
|
||||
|
@ -26,12 +26,12 @@ class Debugger;
|
|||
|
||||
#define kMAX_ARGS 100
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
kBASE_16,
|
||||
kBASE_10,
|
||||
kBASE_2,
|
||||
kBASE_DEFAULT
|
||||
};
|
||||
} BaseFormat;
|
||||
|
||||
class DebuggerParser
|
||||
{
|
||||
|
@ -40,8 +40,10 @@ class DebuggerParser
|
|||
~DebuggerParser();
|
||||
|
||||
string run(const string& command);
|
||||
bool parseArgument(string& arg, int *value, char *rendered, int outputBase);
|
||||
void setBase(int base);
|
||||
bool parseArgument(string& arg, int *value, string& rendered,
|
||||
BaseFormat outputBase = kBASE_DEFAULT);
|
||||
string parseValue(int value, BaseFormat outputBase);
|
||||
void setBase(BaseFormat base);
|
||||
|
||||
private:
|
||||
bool getArgs(const string& command);
|
||||
|
@ -60,7 +62,7 @@ class DebuggerParser
|
|||
int args[kMAX_ARGS+1]; // FIXME: should be dynamic
|
||||
string argStrings[kMAX_ARGS+1];
|
||||
int argCount;
|
||||
int defaultBase;
|
||||
BaseFormat defaultBase;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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: OSystem.cxx,v 1.25 2005-06-16 00:55:58 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.26 2005-06-20 18:32:11 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -344,6 +344,16 @@ void OSystem::createLauncher()
|
|||
mySound->mute(true);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystem::resetDebugger()
|
||||
{
|
||||
// FIXME - this isn't working yet
|
||||
myDebugger->quit();
|
||||
myDebugger->setConsole(myConsole);
|
||||
myDebugger->initialize();
|
||||
myDebugger->start();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool OSystem::openROM(const string& rom, uInt8** image, int* size)
|
||||
{
|
||||
|
|
|
@ -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: OSystem.hxx,v 1.22 2005-06-17 21:59:53 urchlay Exp $
|
||||
// $Id: OSystem.hxx,v 1.23 2005-06-20 18:32:11 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef OSYSTEM_HXX
|
||||
|
@ -44,7 +44,7 @@ class Debugger;
|
|||
other objects belong.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: OSystem.hxx,v 1.22 2005-06-17 21:59:53 urchlay Exp $
|
||||
@version $Id: OSystem.hxx,v 1.23 2005-06-20 18:32:11 stephena Exp $
|
||||
*/
|
||||
class OSystem
|
||||
{
|
||||
|
@ -257,6 +257,11 @@ class OSystem
|
|||
*/
|
||||
void createLauncher();
|
||||
|
||||
/**
|
||||
Restarts the debugger subsystem.
|
||||
*/
|
||||
void resetDebugger();
|
||||
|
||||
/**
|
||||
The features which are conditionally compiled into Stella.
|
||||
|
||||
|
|
|
@ -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.50 2005-06-19 16:53:57 urchlay Exp $
|
||||
// $Id: Settings.cxx,v 1.51 2005-06-20 18:32:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -50,7 +50,7 @@ Settings::Settings(OSystem* osystem)
|
|||
set("grabmouse", "false");
|
||||
set("center", "true");
|
||||
set("palette", "standard");
|
||||
set("debugheight", "383");
|
||||
set("debugheight", "15");
|
||||
|
||||
set("sound", "true");
|
||||
set("fragsize", "512");
|
||||
|
|
|
@ -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: BrowserDialog.cxx,v 1.5 2005-06-16 00:55:59 stephena Exp $
|
||||
// $Id: BrowserDialog.cxx,v 1.6 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -58,6 +58,7 @@ BrowserDialog::BrowserDialog(GuiObject* boss, int x, int y, int w, int h)
|
|||
_fileList = new ListWidget(this, 10, 34, _w - 2 * 10, _h - 34 - 24 - 10);
|
||||
_fileList->setNumberingMode(kListNumberingOff);
|
||||
_fileList->setEditable(false);
|
||||
_fileList->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
|
||||
// Buttons
|
||||
addButton(10, _h - 24, "Go up", kGoUpCmd, 0);
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
//============================================================================
|
||||
//
|
||||
// SSSS tt lll lll
|
||||
// SS SS tt ll ll
|
||||
// SS tttttt eeee ll ll aaaa
|
||||
// SSSS tt ee ee ll ll aa
|
||||
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||
// SS SS tt ee ll ll aa aa
|
||||
// SSSS ttt eeeee llll llll aaaaa
|
||||
//
|
||||
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
|
||||
//
|
||||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CpuWidget.cxx,v 1.1 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "OSystem.hxx"
|
||||
#include "GuiUtils.hxx"
|
||||
#include "GuiObject.hxx"
|
||||
#include "Debugger.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "DataGridWidget.hxx"
|
||||
|
||||
#include "CpuWidget.hxx"
|
||||
|
||||
enum {
|
||||
kPCRegAddr,
|
||||
kSPRegAddr,
|
||||
kARegAddr,
|
||||
kXRegAddr,
|
||||
kYRegAddr,
|
||||
kNumRegs
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CpuWidget::CpuWidget(GuiObject* boss, int x, int y, int w, int h)
|
||||
: Widget(boss, x, y, w, h),
|
||||
CommandSender(boss)
|
||||
{
|
||||
int xpos = 10;
|
||||
int ypos = 20;
|
||||
int lwidth = 30;
|
||||
const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
|
||||
|
||||
/*
|
||||
// Create a 16x8 grid (16 x 8 = 128 RAM bytes) with labels
|
||||
for(int row = 0; row < 8; ++row)
|
||||
{
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2,
|
||||
lwidth, kLineHeight,
|
||||
Debugger::to_hex_16(row*16 + kRamStart) + string(":"),
|
||||
kTextAlignLeft);
|
||||
t->setFont(instance()->consoleFont());
|
||||
}
|
||||
for(int col = 0; col < 16; ++col)
|
||||
{
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, xpos + col*kColWidth + lwidth + 12,
|
||||
ypos - kLineHeight,
|
||||
lwidth, kLineHeight,
|
||||
Debugger::to_hex_4(col),
|
||||
kTextAlignLeft);
|
||||
t->setFont(instance()->consoleFont());
|
||||
}
|
||||
*/
|
||||
myCpuGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 1, 5, 8,
|
||||
0xffff);
|
||||
myCpuGrid->setTarget(this);
|
||||
myActiveWidget = myCpuGrid;
|
||||
|
||||
/*
|
||||
// Add some buttons for common actions
|
||||
ButtonWidget* b;
|
||||
xpos = vWidth + 10; ypos = 20;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "0", kRZeroCmd, 0);
|
||||
b->setTarget(this);
|
||||
|
||||
ypos += 16 + space;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "Inv", kRInvertCmd, 0);
|
||||
b->setTarget(this);
|
||||
|
||||
ypos += 16 + space;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "++", kRIncCmd, 0);
|
||||
b->setTarget(this);
|
||||
|
||||
ypos += 16 + space;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "<<", kRShiftLCmd, 0);
|
||||
b->setTarget(this);
|
||||
|
||||
xpos = vWidth + 30 + 10; ypos = 20;
|
||||
// b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "", kRCmd, 0);
|
||||
// b->setTarget(this);
|
||||
|
||||
ypos += 16 + space;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "Neg", kRNegateCmd, 0);
|
||||
b->setTarget(this);
|
||||
|
||||
ypos += 16 + space;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, "--", kRDecCmd, 0);
|
||||
b->setTarget(this);
|
||||
|
||||
ypos += 16 + space;
|
||||
b = new ButtonWidget(boss, xpos, ypos, buttonw, 16, ">>", kRShiftRCmd, 0);
|
||||
b->setTarget(this);
|
||||
*/
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CpuWidget::~CpuWidget()
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data)
|
||||
{
|
||||
// We simply change the values in the ByteGridWidget
|
||||
// It will then send the 'kBGItemDataChangedCmd' signal to change the actual
|
||||
// memory location
|
||||
int addr, value;
|
||||
unsigned char byte;
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case kDGItemDataChangedCmd:
|
||||
cerr << "info changed\n";
|
||||
/*
|
||||
addr = myRamGrid->getSelectedAddr() - kRamStart;
|
||||
value = myRamGrid->getSelectedValue();
|
||||
instance()->debugger().writeRAM(addr, value);
|
||||
*/
|
||||
break;
|
||||
|
||||
/*
|
||||
case kRZeroCmd:
|
||||
myRamGrid->setSelectedValue(0);
|
||||
break;
|
||||
|
||||
case kRInvertCmd:
|
||||
byte = (unsigned char) myRamGrid->getSelectedValue();
|
||||
byte = ~byte;
|
||||
myRamGrid->setSelectedValue((int)byte);
|
||||
break;
|
||||
|
||||
case kRNegateCmd:
|
||||
byte = (unsigned char) myRamGrid->getSelectedValue();
|
||||
byte = (~byte) + 1;
|
||||
myRamGrid->setSelectedValue((int)byte);
|
||||
break;
|
||||
|
||||
case kRIncCmd:
|
||||
byte = (unsigned char) myRamGrid->getSelectedValue();
|
||||
byte += 1;
|
||||
myRamGrid->setSelectedValue((int)byte);
|
||||
break;
|
||||
|
||||
case kRDecCmd:
|
||||
byte = (unsigned char) myRamGrid->getSelectedValue();
|
||||
byte -= 1;
|
||||
myRamGrid->setSelectedValue((int)byte);
|
||||
break;
|
||||
|
||||
case kRShiftLCmd:
|
||||
byte = (unsigned char) myRamGrid->getSelectedValue();
|
||||
byte <<= 1;
|
||||
myRamGrid->setSelectedValue((int)byte);
|
||||
break;
|
||||
|
||||
case kRShiftRCmd:
|
||||
byte = (unsigned char) myRamGrid->getSelectedValue();
|
||||
byte >>= 1;
|
||||
myRamGrid->setSelectedValue((int)byte);
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
instance()->frameBuffer().refresh();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CpuWidget::loadConfig()
|
||||
{
|
||||
fillGrid();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CpuWidget::fillGrid()
|
||||
{
|
||||
AddrList alist;
|
||||
ValueList vlist;
|
||||
|
||||
for(unsigned int i = 0; i < kNumRegs; i++)
|
||||
{
|
||||
alist.push_back(i*16);
|
||||
vlist.push_back(i*16);//instance()->debugger().readRAM(i));
|
||||
}
|
||||
|
||||
myCpuGrid->setList(alist, vlist);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
//============================================================================
|
||||
//
|
||||
// SSSS tt lll lll
|
||||
// SS SS tt ll ll
|
||||
// SS tttttt eeee ll ll aaaa
|
||||
// SSSS tt ee ee ll ll aa
|
||||
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||
// SS SS tt ee ll ll aa aa
|
||||
// SSSS ttt eeeee llll llll aaaaa
|
||||
//
|
||||
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
|
||||
//
|
||||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CpuWidget.hxx,v 1.1 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
//============================================================================
|
||||
|
||||
#ifndef CPU_WIDGET_HXX
|
||||
#define CPU_WIDGET_HXX
|
||||
|
||||
class GuiObject;
|
||||
class ButtonWidget;
|
||||
class StaticTextWidget;
|
||||
class DataGridWidget;
|
||||
|
||||
#include "Array.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "Command.hxx"
|
||||
|
||||
|
||||
class CpuWidget : public Widget, public CommandSender
|
||||
{
|
||||
public:
|
||||
CpuWidget(GuiObject* boss, int x, int y, int w, int h);
|
||||
virtual ~CpuWidget();
|
||||
|
||||
Widget* activeWidget() { return myActiveWidget; }
|
||||
|
||||
void handleCommand(CommandSender* sender, int cmd, int data);
|
||||
void loadConfig();
|
||||
|
||||
private:
|
||||
void fillGrid();
|
||||
|
||||
private:
|
||||
Widget* myActiveWidget;
|
||||
|
||||
DataGridWidget* myCpuGrid;
|
||||
// FIXME - add a ToggleBitWidget for processor status (ps) register
|
||||
};
|
||||
|
||||
#endif
|
|
@ -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.6 2005-06-17 21:46:23 stephena Exp $
|
||||
// $Id: DataGridWidget.cxx,v 1.1 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -27,16 +27,20 @@
|
|||
#include "Dialog.hxx"
|
||||
#include "Debugger.hxx"
|
||||
#include "FrameBuffer.hxx"
|
||||
#include "ByteGridWidget.hxx"
|
||||
#include "DataGridWidget.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ByteGridWidget::ByteGridWidget(GuiObject* boss, int x, int y, int cols, int rows)
|
||||
: EditableWidget(boss, x, y, kColWidth*cols + 1, kLineHeight*rows + 1),
|
||||
DataGridWidget::DataGridWidget(GuiObject* boss, int x, int y, int cols, int rows,
|
||||
int colchars, int range, BaseFormat base)
|
||||
: EditableWidget(boss, x, y, cols*(colchars * 6 + 8) + 1, kLineHeight*rows + 1),
|
||||
CommandSender(boss),
|
||||
_rows(rows),
|
||||
_cols(cols),
|
||||
_currentRow(0),
|
||||
_currentCol(0),
|
||||
_colWidth(colchars * 6 + 8),
|
||||
_range(range),
|
||||
_base(base),
|
||||
_selectedItem(0)
|
||||
{
|
||||
// This widget always uses a monospace font
|
||||
|
@ -44,7 +48,7 @@ ByteGridWidget::ByteGridWidget(GuiObject* boss, int x, int y, int cols, int rows
|
|||
|
||||
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
|
||||
WIDGET_TAB_NAVIGATE;
|
||||
_type = kByteGridWidget;
|
||||
_type = kDataGridWidget;
|
||||
_editMode = false;
|
||||
|
||||
_currentKeyDown = 0;
|
||||
|
@ -58,12 +62,12 @@ ByteGridWidget::ByteGridWidget(GuiObject* boss, int x, int y, int cols, int rows
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ByteGridWidget::~ByteGridWidget()
|
||||
DataGridWidget::~DataGridWidget()
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::setList(const ByteAddrList& alist, const ByteValueList& vlist)
|
||||
void DataGridWidget::setList(const AddrList& alist, const ValueList& vlist)
|
||||
{
|
||||
_addrList.clear();
|
||||
_valueList.clear();
|
||||
|
@ -77,12 +81,10 @@ void ByteGridWidget::setList(const ByteAddrList& alist, const ByteValueList& vli
|
|||
assert(size == _rows * _cols);
|
||||
|
||||
// An efficiency thing
|
||||
char temp[10];
|
||||
string temp;
|
||||
for(unsigned int i = 0; i < (unsigned int)size; ++i)
|
||||
{
|
||||
sprintf(temp, "%.4x:", _addrList[i]);
|
||||
_addrStringList.push_back(temp);
|
||||
sprintf(temp, "%.2x", _valueList[i]);
|
||||
temp = instance()->debugger().parseValue(_valueList[i], _base);
|
||||
_valueStringList.push_back(temp);
|
||||
}
|
||||
|
||||
|
@ -90,19 +92,19 @@ void ByteGridWidget::setList(const ByteAddrList& alist, const ByteValueList& vli
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::setSelectedValue(int value)
|
||||
void DataGridWidget::setSelectedValue(int value)
|
||||
{
|
||||
// Correctly format the data for viewing
|
||||
_editString = Debugger::to_hex_8(value);
|
||||
_editString = instance()->debugger().parseValue(value, _base);
|
||||
|
||||
_valueStringList[_selectedItem] = _editString;
|
||||
_valueList[_selectedItem] = value;
|
||||
|
||||
sendCommand(kBGItemDataChangedCmd, _selectedItem);
|
||||
sendCommand(kDGItemDataChangedCmd, _selectedItem);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
||||
void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
||||
{
|
||||
if (!isEnabled())
|
||||
return;
|
||||
|
@ -126,7 +128,7 @@ void ByteGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
|||
_currentRow = _selectedItem / _cols;
|
||||
_currentCol = _selectedItem - (_currentRow * _cols);
|
||||
|
||||
sendCommand(kBGSelectionChangedCmd, _selectedItem);
|
||||
sendCommand(kDGSelectionChangedCmd, _selectedItem);
|
||||
instance()->frameBuffer().refresh();
|
||||
}
|
||||
|
||||
|
@ -136,13 +138,13 @@ void ByteGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||
void DataGridWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||
{
|
||||
// If this was a double click and the mouse is still over the selected item,
|
||||
// send the double click command
|
||||
if (clickCount == 2 && (_selectedItem == findItem(x, y)))
|
||||
{
|
||||
sendCommand(kBGItemDoubleClickedCmd, _selectedItem);
|
||||
sendCommand(kDGItemDoubleClickedCmd, _selectedItem);
|
||||
|
||||
// Start edit mode
|
||||
if(_editable && !_editMode)
|
||||
|
@ -151,19 +153,19 @@ void ByteGridWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int ByteGridWidget::findItem(int x, int y)
|
||||
int DataGridWidget::findItem(int x, int y)
|
||||
{
|
||||
int row = (y - 1) / kLineHeight;
|
||||
if(row >= _rows) row = _rows - 1;
|
||||
|
||||
int col = x / kColWidth;
|
||||
int col = x / _colWidth;
|
||||
if(col >= _cols) col = _cols - 1;
|
||||
|
||||
return row * _cols + col;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool ByteGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||
bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
||||
{
|
||||
// Ignore all mod keys
|
||||
if(instance()->eventHandler().kbdControl(modifiers) ||
|
||||
|
@ -266,7 +268,7 @@ bool ByteGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
{
|
||||
_selectedItem = _currentRow*_cols + _currentCol;
|
||||
draw();
|
||||
sendCommand(kBGSelectionChangedCmd, _selectedItem);
|
||||
sendCommand(kDGSelectionChangedCmd, _selectedItem);
|
||||
instance()->frameBuffer().refresh();
|
||||
}
|
||||
|
||||
|
@ -275,7 +277,7 @@ bool ByteGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool ByteGridWidget::handleKeyUp(int ascii, int keycode, int modifiers)
|
||||
bool DataGridWidget::handleKeyUp(int ascii, int keycode, int modifiers)
|
||||
{
|
||||
if (keycode == _currentKeyDown)
|
||||
_currentKeyDown = 0;
|
||||
|
@ -283,14 +285,14 @@ bool ByteGridWidget::handleKeyUp(int ascii, int keycode, int modifiers)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::lostFocusWidget()
|
||||
void DataGridWidget::lostFocusWidget()
|
||||
{
|
||||
_editMode = false;
|
||||
draw();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::handleCommand(CommandSender* sender, int cmd, int data)
|
||||
void DataGridWidget::handleCommand(CommandSender* sender, int cmd, int data)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
|
@ -305,26 +307,26 @@ void ByteGridWidget::handleCommand(CommandSender* sender, int cmd, int data)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::drawWidget(bool hilite)
|
||||
void DataGridWidget::drawWidget(bool hilite)
|
||||
{
|
||||
FrameBuffer& fb = _boss->instance()->frameBuffer();
|
||||
int row, col, deltax;
|
||||
string buffer;
|
||||
|
||||
// Draw the internal grid and labels
|
||||
int linewidth = _cols * kColWidth;
|
||||
int linewidth = _cols * _colWidth;
|
||||
for (row = 0; row <= _rows; row++)
|
||||
fb.hLine(_x, _y + (row * kLineHeight), _x + linewidth, kColor);
|
||||
int lineheight = _rows * kLineHeight;
|
||||
for (col = 0; col <= _cols; col++)
|
||||
fb.vLine(_x + (col * kColWidth), _y, _y + lineheight, kColor);
|
||||
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
|
||||
|
||||
// Draw the list items
|
||||
for (row = 0; row < _rows; row++)
|
||||
{
|
||||
for (col = 0; col < _cols; col++)
|
||||
{
|
||||
int x = _x + 4 + (col * kColWidth);
|
||||
int x = _x + 4 + (col * _colWidth);
|
||||
int y = _y + 2 + (row * kLineHeight);
|
||||
int pos = row*_cols + col;
|
||||
|
||||
|
@ -332,9 +334,9 @@ void ByteGridWidget::drawWidget(bool hilite)
|
|||
if (_currentRow == row && _currentCol == col)
|
||||
{
|
||||
if (_hasFocus && !_editMode)
|
||||
fb.fillRect(x - 4, y - 2, kColWidth+1, kLineHeight+1, kTextColorHi);
|
||||
fb.fillRect(x - 4, y - 2, _colWidth+1, kLineHeight+1, kTextColorHi);
|
||||
else
|
||||
fb.frameRect(x - 4, y - 2, kColWidth+1, kLineHeight+1, kTextColorHi);
|
||||
fb.frameRect(x - 4, y - 2, _colWidth+1, kLineHeight+1, kTextColorHi);
|
||||
}
|
||||
|
||||
if (_selectedItem == pos && _editMode)
|
||||
|
@ -343,14 +345,14 @@ void ByteGridWidget::drawWidget(bool hilite)
|
|||
adjustOffset();
|
||||
deltax = -_editScrollOffset;
|
||||
|
||||
fb.drawString(_font, buffer, x, y, kColWidth, kTextColor,
|
||||
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor,
|
||||
kTextAlignLeft, deltax, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = _valueStringList[pos];
|
||||
deltax = 0;
|
||||
fb.drawString(_font, buffer, x, y, kColWidth, kTextColor);
|
||||
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,11 +363,11 @@ void ByteGridWidget::drawWidget(bool hilite)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
GUI::Rect ByteGridWidget::getEditRect() const
|
||||
GUI::Rect DataGridWidget::getEditRect() const
|
||||
{
|
||||
GUI::Rect r(1, 0, kColWidth, kLineHeight);
|
||||
GUI::Rect r(1, 0, _colWidth, kLineHeight);
|
||||
const int rowoffset = _currentRow * kLineHeight;
|
||||
const int coloffset = _currentCol * kColWidth + 4;
|
||||
const int coloffset = _currentCol * _colWidth + 4;
|
||||
r.top += rowoffset;
|
||||
r.bottom += rowoffset;
|
||||
r.left += coloffset;
|
||||
|
@ -375,7 +377,7 @@ GUI::Rect ByteGridWidget::getEditRect() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::startEditMode()
|
||||
void DataGridWidget::startEditMode()
|
||||
{
|
||||
if (_editable && !_editMode && _selectedItem >= 0)
|
||||
{
|
||||
|
@ -386,7 +388,7 @@ void ByteGridWidget::startEditMode()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::endEditMode()
|
||||
void DataGridWidget::endEditMode()
|
||||
{
|
||||
if (!_editMode)
|
||||
return;
|
||||
|
@ -395,17 +397,26 @@ void ByteGridWidget::endEditMode()
|
|||
_editMode = false;
|
||||
|
||||
// Update the both the string representation and the real data
|
||||
int value = Debugger::hex_to_dec(_editString.c_str());
|
||||
if(_editString.length() == 0 || value < 0 || value > 255)
|
||||
int value; string result;
|
||||
bool converted = instance()->debugger().parseArgument(_editString, &value,
|
||||
result, _base);
|
||||
if(!converted || value < 0 || value > _range)
|
||||
{
|
||||
abortEditMode();
|
||||
return;
|
||||
}
|
||||
setSelectedValue(value);
|
||||
|
||||
// Correctly format the data for viewing
|
||||
_editString = result;
|
||||
|
||||
_valueStringList[_selectedItem] = _editString;
|
||||
_valueList[_selectedItem] = value;
|
||||
|
||||
sendCommand(kDGItemDataChangedCmd, _selectedItem);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ByteGridWidget::abortEditMode()
|
||||
void DataGridWidget::abortEditMode()
|
||||
{
|
||||
// undo any changes made
|
||||
assert(_selectedItem >= 0);
|
||||
|
@ -413,14 +424,16 @@ void ByteGridWidget::abortEditMode()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool ByteGridWidget::tryInsertChar(char c, int pos)
|
||||
bool DataGridWidget::tryInsertChar(char c, int pos)
|
||||
{
|
||||
// Not sure how efficient this is, or should we even care?
|
||||
c = tolower(c);
|
||||
if (c >= '0' && c <= '9' || c >= 'a' && c <= 'f')
|
||||
if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
|
||||
c == '%' || c == '#' || c == '$')
|
||||
{
|
||||
_editString.insert(pos, 1, c);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else
|
||||
return false;
|
||||
}
|
|
@ -13,46 +13,44 @@
|
|||
// 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.5 2005-06-17 21:46:24 stephena Exp $
|
||||
// $Id: DataGridWidget.hxx,v 1.1 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
//============================================================================
|
||||
|
||||
#ifndef BYTE_GRID_WIDGET_HXX
|
||||
#define BYTE_GRID_WIDGET_HXX
|
||||
#ifndef DATA_GRID_WIDGET_HXX
|
||||
#define DATA_GRID_WIDGET_HXX
|
||||
|
||||
#include "GuiObject.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "Command.hxx"
|
||||
#include "Debugger.hxx"
|
||||
#include "StringList.hxx"
|
||||
#include "EditableWidget.hxx"
|
||||
#include "Array.hxx"
|
||||
#include "Rect.hxx"
|
||||
|
||||
typedef GUI::Array<int> ByteAddrList;
|
||||
typedef GUI::Array<int> ByteValueList;
|
||||
|
||||
enum {
|
||||
kColWidth = 2 * 6 + 8
|
||||
};
|
||||
typedef GUI::Array<int> AddrList;
|
||||
typedef GUI::Array<int> ValueList;
|
||||
|
||||
// Some special commands
|
||||
enum {
|
||||
kBGItemDoubleClickedCmd = 'BGdb',
|
||||
kBGItemActivatedCmd = 'BGac',
|
||||
kBGItemDataChangedCmd = 'BGch',
|
||||
kBGSelectionChangedCmd = 'BGsc'
|
||||
kDGItemDoubleClickedCmd = 'BGdb',
|
||||
kDGItemActivatedCmd = 'BGac',
|
||||
kDGItemDataChangedCmd = 'BGch',
|
||||
kDGSelectionChangedCmd = 'BGsc'
|
||||
};
|
||||
|
||||
/* ByteGridWidget */
|
||||
class ByteGridWidget : public EditableWidget, public CommandSender
|
||||
/* DataGridWidget */
|
||||
class DataGridWidget : public EditableWidget, public CommandSender
|
||||
{
|
||||
public:
|
||||
ByteGridWidget(GuiObject* boss, int x, int y, int cols, int rows);
|
||||
virtual ~ByteGridWidget();
|
||||
DataGridWidget(GuiObject* boss, int x, int y, int cols, int rows,
|
||||
int colchars, int range, BaseFormat format = kBASE_DEFAULT);
|
||||
virtual ~DataGridWidget();
|
||||
|
||||
void setList(const ByteAddrList& alist, const ByteValueList& vlist);
|
||||
void setList(const AddrList& alist, const ValueList& vlist);
|
||||
void setSelectedValue(int value);
|
||||
|
||||
int getSelectedAddr() const { return _addrList[_selectedItem]; }
|
||||
|
@ -72,6 +70,8 @@ class ByteGridWidget : public EditableWidget, public CommandSender
|
|||
void startEditMode();
|
||||
void endEditMode();
|
||||
|
||||
int colWidth() { return _colWidth; }
|
||||
|
||||
protected:
|
||||
void drawWidget(bool hilite);
|
||||
|
||||
|
@ -90,11 +90,15 @@ class ByteGridWidget : public EditableWidget, public CommandSender
|
|||
int _cols;
|
||||
int _currentRow;
|
||||
int _currentCol;
|
||||
int _colWidth;
|
||||
int _range;
|
||||
|
||||
ByteAddrList _addrList;
|
||||
ByteValueList _valueList;
|
||||
StringList _addrStringList;
|
||||
StringList _valueStringList;
|
||||
BaseFormat _base;
|
||||
|
||||
AddrList _addrList;
|
||||
ValueList _valueList;
|
||||
StringList _addrStringList;
|
||||
StringList _valueStringList;
|
||||
|
||||
bool _editable;
|
||||
bool _editMode;
|
|
@ -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.15 2005-06-18 13:45:34 stephena Exp $
|
||||
// $Id: DebuggerDialog.cxx,v 1.16 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -22,10 +22,10 @@
|
|||
#include "Widget.hxx"
|
||||
#include "Dialog.hxx"
|
||||
#include "TabWidget.hxx"
|
||||
#include "ListWidget.hxx"
|
||||
#include "PromptWidget.hxx"
|
||||
#include "CheatWidget.hxx"
|
||||
#include "CpuWidget.hxx"
|
||||
#include "RamWidget.hxx"
|
||||
#include "CheatWidget.hxx"
|
||||
#include "Debugger.hxx"
|
||||
|
||||
#include "DebuggerDialog.hxx"
|
||||
|
@ -56,7 +56,8 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent,
|
|||
|
||||
// 2) The CPU tab
|
||||
myTab->addTab("CPU");
|
||||
|
||||
CpuWidget* cpu = new CpuWidget(myTab, 2, 2, vWidth - vBorder, _h - 25);
|
||||
myTab->setParentWidget(1, cpu, cpu->activeWidget());
|
||||
|
||||
// 3) The RAM tab
|
||||
myTab->addTab("RAM");
|
||||
|
|
|
@ -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: EventMappingDialog.cxx,v 1.14 2005-06-16 00:55:59 stephena Exp $
|
||||
// $Id: EventMappingDialog.cxx,v 1.15 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -45,6 +45,8 @@ EventMappingDialog::EventMappingDialog(OSystem* osystem, DialogContainer* parent
|
|||
new StaticTextWidget(this, 10, 8, 150, 16, "Select an event to remap:", kTextAlignCenter);
|
||||
myActionsList = new ListWidget(this, 10, 20, 150, 100);
|
||||
myActionsList->setNumberingMode(kListNumberingOff);
|
||||
myActionsList->setEditable(false);
|
||||
myActionsList->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
|
||||
myKeyMapping = new StaticTextWidget(this, 10, 125, w - 20, 16,
|
||||
"Action: ", kTextAlignLeft);
|
||||
|
|
|
@ -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: LauncherDialog.cxx,v 1.22 2005-06-16 00:55:59 stephena Exp $
|
||||
// $Id: LauncherDialog.cxx,v 1.23 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -95,8 +95,8 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
|
|||
|
||||
// Add list with game titles
|
||||
myList = new ListWidget(this, 10, 24, _w - 20, _h - 24 - 26 - 10 - 10);
|
||||
myList->setEditable(false);
|
||||
myList->setNumberingMode(kListNumberingOff);
|
||||
myList->setEditable(false);
|
||||
myList->clearFlags(WIDGET_TAB_NAVIGATE);
|
||||
|
||||
// Add note textwidget to show any notes for the currently selected ROM
|
||||
|
|
|
@ -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.6 2005-06-18 06:59:43 urchlay Exp $
|
||||
// $Id: RamWidget.cxx,v 1.7 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -27,7 +27,7 @@
|
|||
#include "GuiObject.hxx"
|
||||
#include "Debugger.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "ByteGridWidget.hxx"
|
||||
#include "DataGridWidget.hxx"
|
||||
|
||||
#include "RamWidget.hxx"
|
||||
|
||||
|
@ -51,7 +51,11 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
|
|||
int lwidth = 30;
|
||||
const int vWidth = _w - kButtonWidth - 20, space = 6, buttonw = 24;
|
||||
|
||||
// Create a 16x8 grid (16 x 8 = 128 RAM bytes) with labels
|
||||
// Create a 16x8 grid holding byte values (16 x 8 = 128 RAM bytes) with labels
|
||||
myRamGrid = new DataGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8, 2, 0xff, kBASE_16);
|
||||
myRamGrid->setTarget(this);
|
||||
myActiveWidget = myRamGrid;
|
||||
|
||||
for(int row = 0; row < 8; ++row)
|
||||
{
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, xpos, ypos + row*kLineHeight + 2,
|
||||
|
@ -62,7 +66,8 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
|
|||
}
|
||||
for(int col = 0; col < 16; ++col)
|
||||
{
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, xpos + col*kColWidth + lwidth + 12,
|
||||
StaticTextWidget* t = new StaticTextWidget(boss,
|
||||
xpos + col*myRamGrid->colWidth() + lwidth + 12,
|
||||
ypos - kLineHeight,
|
||||
lwidth, kLineHeight,
|
||||
Debugger::to_hex_4(col),
|
||||
|
@ -70,10 +75,6 @@ RamWidget::RamWidget(GuiObject* boss, int x, int y, int w, int h)
|
|||
t->setFont(instance()->consoleFont());
|
||||
}
|
||||
|
||||
myRamGrid = new ByteGridWidget(boss, xpos+lwidth + 5, ypos, 16, 8);
|
||||
myRamGrid->setTarget(this);
|
||||
myActiveWidget = myRamGrid;
|
||||
|
||||
// Add some buttons for common actions
|
||||
ButtonWidget* b;
|
||||
xpos = vWidth + 10; ypos = 20;
|
||||
|
@ -118,14 +119,14 @@ RamWidget::~RamWidget()
|
|||
void RamWidget::handleCommand(CommandSender* sender, int cmd, int data)
|
||||
{
|
||||
// We simply change the values in the ByteGridWidget
|
||||
// It will then send the 'kBGItemDataChangedCmd' signal to change the actual
|
||||
// It will then send the 'kDGItemDataChangedCmd' signal to change the actual
|
||||
// memory location
|
||||
int addr, value;
|
||||
unsigned char byte;
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case kBGItemDataChangedCmd:
|
||||
case kDGItemDataChangedCmd:
|
||||
addr = myRamGrid->getSelectedAddr() - kRamStart;
|
||||
value = myRamGrid->getSelectedValue();
|
||||
instance()->debugger().writeRAM(addr, value);
|
||||
|
@ -184,8 +185,8 @@ void RamWidget::loadConfig()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void RamWidget::fillGrid()
|
||||
{
|
||||
ByteAddrList alist;
|
||||
ByteValueList vlist;
|
||||
AddrList alist;
|
||||
ValueList vlist;
|
||||
|
||||
for(unsigned int i = 0; i < kRamSize; i++)
|
||||
{
|
||||
|
|
|
@ -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.hxx,v 1.2 2005-06-16 22:18:02 stephena Exp $
|
||||
// $Id: RamWidget.hxx,v 1.3 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -25,7 +25,7 @@
|
|||
class GuiObject;
|
||||
class ButtonWidget;
|
||||
class StaticTextWidget;
|
||||
class ByteGridWidget;
|
||||
class DataGridWidget;
|
||||
|
||||
#include "Array.hxx"
|
||||
#include "Widget.hxx"
|
||||
|
@ -43,13 +43,13 @@ class RamWidget : public Widget, public CommandSender
|
|||
void handleCommand(CommandSender* sender, int cmd, int data);
|
||||
void loadConfig();
|
||||
|
||||
public:
|
||||
private:
|
||||
void fillGrid();
|
||||
|
||||
private:
|
||||
Widget* myActiveWidget;
|
||||
|
||||
ByteGridWidget* myRamGrid;
|
||||
DataGridWidget* myRamGrid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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: Widget.hxx,v 1.19 2005-06-16 22:18:02 stephena Exp $
|
||||
// $Id: Widget.hxx,v 1.20 2005-06-20 18:32:12 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -55,7 +55,7 @@ enum {
|
|||
kPopUpWidget = 'POPU',
|
||||
kTabWidget = 'TABW',
|
||||
kPromptWidget = 'PROM',
|
||||
kByteGridWidget = 'BGRI'
|
||||
kDataGridWidget = 'BGRI'
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -67,7 +67,7 @@ enum {
|
|||
This is the base class for all widgets.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Widget.hxx,v 1.19 2005-06-16 22:18:02 stephena Exp $
|
||||
@version $Id: Widget.hxx,v 1.20 2005-06-20 18:32:12 stephena Exp $
|
||||
*/
|
||||
class Widget : public GuiObject
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue