First pass at adding cart-specific info to the ROM tab in the debugger.

For now, only 4K is shown.  Eventually this will be included for all
bankswitch types, whereby the UI will be tailored to the specifics
of each scheme, so that ROM/RAM banks will be able to viewed and
changed more easily.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2680 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-04-04 21:38:22 +00:00
parent 831edca24e
commit 263e8e6240
18 changed files with 217 additions and 35 deletions

View File

@ -24,20 +24,30 @@
#include "bspf.hxx"
/**
This class converts a string into a StringList by splitting on a delimiter.
By default, the delimiter is a newline.
This class converts a string into a StringList by splitting on a delimiter
and size.
@author Stephen Anthony
*/
class StringParser
{
public:
StringParser(const string& str, char delim = '\n')
/**
Split the given string based on delimiter (by default, the newline
character, and by desired length (by default, not used).
@param str The string to split
@param len The maximum length of string to generate (0 means unlimited)
@param delim The character indicating the end of a line (newline by default)
*/
StringParser(const string& str, uInt32 len = 0, char delim = '\n')
{
stringstream buf(str);
string line;
while(std::getline(buf, line, delim))
{
myStringList.push_back(line);
}
}
const StringList& stringList() const { return myStringList; }

View File

@ -0,0 +1,46 @@
//============================================================================
//
// 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-2013 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#ifndef CARTRIDGE4K_WIDGET_HXX
#define CARTRIDGE4K_WIDGET_HXX
class Cartridge4K;
#include "CartDebugWidget.hxx"
class Cartridge4KWidget : public CartDebugWidget
{
public:
Cartridge4KWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
Cartridge4K& cart)
: CartDebugWidget(boss, font, x, y, w, h)
{
addBaseInformation(4096, "Atari", "Standard 4K cartridge, non-bankswitched\n"
"Accessible @ $1000 - $1FFF");
}
virtual ~Cartridge4KWidget() { }
// No implementation for non-bankswitched ROMs
void loadConfig() { }
void handleCommand(CommandSender* sender, int cmd, int data, int id) { }
};
#endif

View File

@ -0,0 +1,102 @@
//============================================================================
//
// 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-2013 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#ifndef CART_DEBUG_WIDGET_HXX
#define CART_DEBUG_WIDGET_HXX
class GuiObject;
class ButtonWidget;
#include "Font.hxx"
#include "Command.hxx"
#include "Widget.hxx"
#include "EditTextWidget.hxx"
#include "StringListWidget.hxx"
#include "StringParser.hxx"
class CartDebugWidget : public Widget, public CommandSender
{
public:
CartDebugWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: Widget(boss, font, x, y, w, h),
CommandSender(boss),
myFontWidth(font.getMaxCharWidth()),
myFontHeight(font.getFontHeight()),
myLineHeight(font.getLineHeight())
{
_type = kCartDebugWidget;
}
virtual ~CartDebugWidget() { };
public:
int addBaseInformation(int bytes, const string& manufacturer,
const string& desc)
{
const int lwidth = _font.getStringWidth("Manufacturer: "),
fwidth = _w - lwidth - 30;
EditTextWidget* w = 0;
StringListWidget* sw = 0;
int x = 10, y = 10;
// Add ROM size, manufacturer and bankswitch info
new StaticTextWidget(_boss, _font, x, y, lwidth,
myFontHeight, "ROM Size: ", kTextAlignLeft);
w = new EditTextWidget(_boss, _font, x+lwidth, y,
fwidth, myFontHeight, BSPF_toString(bytes) + " bytes / " +
BSPF_toString((bytes/1024)) + "KB");
w->setEditable(false);
y += myLineHeight + 4;
new StaticTextWidget(_boss, _font, x, y, lwidth,
myFontHeight, "Manufacturer: ", kTextAlignLeft);
w = new EditTextWidget(_boss, _font, x+lwidth, y,
fwidth, myFontHeight, manufacturer);
w->setEditable(false);
y += myLineHeight + 4;
StringParser bs(desc);
const StringList& sl = bs.stringList();
uInt32 lines = sl.size();
if(lines < 3) lines = 3;
if(lines > 6) lines = 6;
new StaticTextWidget(_boss, _font, x, y, lwidth,
myFontHeight, "Description: ", kTextAlignLeft);
sw = new StringListWidget(_boss, _font, x+lwidth, y,
fwidth, lines * myLineHeight, false);
sw->setEditable(false);
sw->setList(sl);
y += sw->getHeight() + 4;
return y;
}
virtual void loadConfig() { };
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) { };
protected:
// These will be needed by most of the child classes;
// we may as well make them protected variables
int myFontWidth, myFontHeight, myLineHeight;
};
#endif

View File

@ -33,6 +33,7 @@
#include "RiotWidget.hxx"
#include "RomWidget.hxx"
#include "TiaWidget.hxx"
#include "CartDebugWidget.hxx"
#include "DataGridOpsWidget.hxx"
#include "EditTextWidget.hxx"
#include "MessageBox.hxx"
@ -73,9 +74,7 @@ void DebuggerDialog::loadConfig()
myTiaZoom->loadConfig();
myCpu->loadConfig();
myRam->loadConfig();
myRomTab->loadConfig();
// myRom->loadConfig();
myMessageBox->setEditString("");
}
@ -326,13 +325,14 @@ void DebuggerDialog::addRomArea()
// The 'cart-specific' information tab
tabID = myRomTab->addTab(instance().console().cartridge().name());
#if 0
myRom = new RomWidget(myRomTab, instance().consoleFont(),
2, 2, tabWidth - 1,
tabHeight - myRomTab->getTabHeight() - 2);
myRomTab->setParentWidget(tabID, myRom);
addToFocusList(myRom->getFocusList(), myRomTab, tabID);
#endif
myCartDebug = instance().console().cartridge().debugWidget(
myRomTab, instance().consoleFont(), 2, 2, tabWidth - 1,
tabHeight - myRomTab->getTabHeight() - 2);
if(myCartDebug) // TODO - make this always non-null
{
myRomTab->setParentWidget(tabID, myCartDebug);
addToFocusList(myCartDebug->getFocusList(), myRomTab, tabID);
}
myRomTab->setActiveTab(0);
}

View File

@ -36,6 +36,7 @@ class EditTextWidget;
class TiaInfoWidget;
class TiaOutputWidget;
class TiaZoomWidget;
class CartDebugWidget;
#include "Dialog.hxx"
#include "MessageBox.hxx"
@ -81,6 +82,7 @@ class DebuggerDialog : public Dialog
CpuWidget* myCpu;
RamWidget* myRam;
RomWidget* myRom;
CartDebugWidget* myCartDebug;
EditTextWidget* myMessageBox;
ButtonWidget* myRewindButton;
GUI::MessageBox* myFatalError;

View File

@ -31,8 +31,6 @@ class NullControlWidget : public ControllerWidget
Controller& controller)
: ControllerWidget(boss, font, x, y, controller)
{
_type = kControllerWidget;
bool leftport = controller.jack() == Controller::Left;
ostringstream buf;
buf << (leftport ? "Left (" : "Right (")

View File

@ -25,18 +25,19 @@
class Cartridge;
class Properties;
class CartDebugWidget;
class GuiObject;
#include "bspf.hxx"
#include "Array.hxx"
#include "Device.hxx"
#include "Settings.hxx"
#include "Font.hxx"
#ifdef DEBUGGER_SUPPORT
struct RamArea {
uInt16 start; uInt16 size; uInt16 roffset; uInt16 woffset;
};
typedef Common::Array<RamArea> RamAreaList;
#endif
/**
A cartridge is a device which contains the machine code for a
@ -122,9 +123,7 @@ class Cartridge : public Device
*/
virtual bool bankChanged();
#ifdef DEBUGGER_SUPPORT
const RamAreaList& ramAreas() { return myRamAreaList; }
#endif
public:
//////////////////////////////////////////////////////////////////////
@ -199,6 +198,15 @@ class Cartridge : public Device
*/
virtual void setRomName(const string& name) { }
/**
Get debugger widget responsible for accessing the inner workings
of the cart. This will need to be overridden and implemented by
each specific cart type, since the bankswitching/inner workings
of each cart type can be very different from each other.
*/
virtual CartDebugWidget* debugWidget(GuiObject* boss,
const GUI::Font& font, int x, int y, int w, int h) { return NULL; }
protected:
/**
Add the given area to the RamArea list for this cart.
@ -371,10 +379,8 @@ class Cartridge : public Device
uInt8* myCodeAccessBase;
private:
#ifdef DEBUGGER_SUPPORT
// Contains RamArea entries for those carts with accessible RAM.
RamAreaList myRamAreaList;
#endif
// If myBankLocked is true, ignore attempts at bankswitching. This is used
// by the debugger, when disassembling/dumping ROM.

View File

@ -24,6 +24,9 @@ class System;
#include "bspf.hxx"
#include "Cart.hxx"
#ifdef DEBUGGER_SUPPORT
#include "Cart4KWidget.hxx"
#endif
/**
This is the standard Atari 4K cartridge. These cartridges are
@ -120,6 +123,18 @@ class Cartridge4K : public Cartridge
*/
string name() const { return "Cartridge4K"; }
#ifdef DEBUGGER_SUPPORT
/**
Get debugger widget responsible for accessing the inner workings
of the cart.
*/
CartDebugWidget* debugWidget(GuiObject* boss,
const GUI::Font& font, int x, int y, int w, int h)
{
return new Cartridge4KWidget(boss, font, x, y, w, h, *this);
}
#endif
public:
/**
Get the byte at the specified address.

View File

@ -75,7 +75,6 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
ypos += lineHeight;
_fileList = new StringListWidget(this, font, xpos, ypos,
_w - 2 * xpos, _h - buttonHeight - ypos - 20);
_fileList->setNumberingMode(kListNumberingOff);
_fileList->setEditable(false);
// Buttons

View File

@ -31,7 +31,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EditTextWidget::EditTextWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, const string& text)
: EditableWidget(boss, font, x, y - 1, w, h + 2),
: EditableWidget(boss, font, x, y - 1, w, h + 2, text),
_editable(true),
_changed(false)
{

View File

@ -26,10 +26,11 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EditableWidget::EditableWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
int x, int y, int w, int h, const string& str)
: Widget(boss, font, x, y, w, h),
CommandSender(boss),
_editable(true)
_editable(true),
_editString(str)
{
_caretVisible = false;
_caretTime = 0;

View File

@ -40,7 +40,7 @@ class EditableWidget : public Widget, public CommandSender
{
public:
EditableWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, int w, int h);
int x, int y, int w, int h, const string& str = "");
virtual ~EditableWidget();
virtual void setEditString(const string& str, bool changed = false);

View File

@ -54,7 +54,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myActionsList = new StringListWidget(boss, font, xpos, ypos,
_w - buttonWidth - 20, _h - 3*lineHeight);
myActionsList->setTarget(this);
myActionsList->setNumberingMode(kListNumberingOff);
myActionsList->setEditable(false);
myActionsList->setList(actions);
addFocusWidget(myActionsList);

View File

@ -110,7 +110,6 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
int listWidth = _w - (romWidth > 0 ? romWidth+5 : 0) - 20;
myList = new StringListWidget(this, font, xpos, ypos,
listWidth, _h - 28 - bheight - 2*fontHeight);
myList->setNumberingMode(kListNumberingOff);
myList->setEditable(false);
wid.push_back(myList);
if(myPattern) wid.push_back(myPattern); // Add after the list for tab order

View File

@ -55,8 +55,7 @@ LoggerDialog::LoggerDialog(OSystem* osystem, DialogContainer* parent,
xpos = 10; ypos = 10;
myLogInfo = new StringListWidget(this, instance().consoleFont(), xpos, ypos,
_w - 2 * xpos, _h - buttonHeight - ypos - 20 -
2 * lineHeight);
myLogInfo->setNumberingMode(kListNumberingOff);
2 * lineHeight, false);
myLogInfo->setEditable(false);
wid.push_back(myLogInfo);
ypos += myLogInfo->getHeight() + 8;

View File

@ -27,8 +27,12 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StringListWidget::StringListWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: ListWidget(boss, font, x, y, w, h)
int x, int y, int w, int h, bool hilite,
NumberingMode mode)
: ListWidget(boss, font, x, y, w, h),
_numberingMode(mode),
_hilite(hilite)
{
}
@ -67,7 +71,7 @@ void StringListWidget::drawWidget(bool hilite)
const int y = _y + 2 + _fontHeight * i;
// Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos)
if (_selectedItem == pos && _hilite)
{
if (_hasFocus && !_editMode)
s.fillRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);

View File

@ -36,11 +36,11 @@ class StringListWidget : public ListWidget
{
public:
StringListWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h);
int x, int y, int w, int h, bool hilite = true,
NumberingMode mode = kListNumberingOff);
virtual ~StringListWidget();
void setList(const StringList& list);
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
protected:
void drawWidget(bool hilite);
@ -48,6 +48,7 @@ class StringListWidget : public ListWidget
protected:
NumberingMode _numberingMode;
bool _hilite;
};
#endif

View File

@ -79,7 +79,8 @@ enum {
kToggleBitWidget = 'TGLB',
kTogglePixelWidget = 'TGLP',
kToggleWidget = 'TOGL',
kControllerWidget = 'CTRL'
kControllerWidget = 'CTRL',
kCartDebugWidget = 'CDBG'
};
/**