2005-06-03 17:52:06 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2005-06-16 00:56:00 +00:00
|
|
|
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
|
2005-06-03 17:52:06 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2005-08-10 18:44:37 +00:00
|
|
|
// $Id: DebuggerDialog.cxx,v 1.33 2005-08-10 18:44:37 stephena Exp $
|
2005-06-03 17:52:06 +00:00
|
|
|
//
|
|
|
|
// Based on code from ScummVM - Scumm Interpreter
|
|
|
|
// Copyright (C) 2002-2004 The ScummVM project
|
|
|
|
//============================================================================
|
|
|
|
|
2005-06-17 14:42:49 +00:00
|
|
|
#include "Widget.hxx"
|
|
|
|
#include "Dialog.hxx"
|
2005-06-10 17:46:07 +00:00
|
|
|
#include "TabWidget.hxx"
|
2005-07-19 17:59:59 +00:00
|
|
|
#include "TiaOutputWidget.hxx"
|
2005-07-21 19:30:17 +00:00
|
|
|
#include "TiaInfoWidget.hxx"
|
2005-06-10 17:46:07 +00:00
|
|
|
#include "PromptWidget.hxx"
|
2005-06-20 18:32:12 +00:00
|
|
|
#include "CpuWidget.hxx"
|
2005-06-16 18:40:17 +00:00
|
|
|
#include "RamWidget.hxx"
|
2005-07-06 15:09:16 +00:00
|
|
|
#include "TiaWidget.hxx"
|
2005-06-20 18:32:12 +00:00
|
|
|
#include "CheatWidget.hxx"
|
2005-08-10 18:44:37 +00:00
|
|
|
#include "DataGridOpsWidget.hxx"
|
2005-07-19 17:59:59 +00:00
|
|
|
#include "Rect.hxx"
|
2005-06-17 14:42:49 +00:00
|
|
|
#include "Debugger.hxx"
|
2005-06-12 20:12:10 +00:00
|
|
|
|
2005-06-03 17:52:06 +00:00
|
|
|
#include "DebuggerDialog.hxx"
|
|
|
|
|
2005-06-17 14:42:49 +00:00
|
|
|
enum {
|
|
|
|
kDDStepCmd = 'DDst',
|
2005-06-17 17:34:01 +00:00
|
|
|
kDDTraceCmd = 'DDtr',
|
|
|
|
kDDAdvCmd = 'DDav',
|
2005-07-15 15:27:29 +00:00
|
|
|
kDDSAdvCmd = 'DDsv',
|
2005-06-17 17:34:01 +00:00
|
|
|
kDDExitCmd = 'DDex'
|
2005-06-17 14:42:49 +00:00
|
|
|
};
|
|
|
|
|
2005-06-03 17:52:06 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-06-07 01:14:39 +00:00
|
|
|
DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent,
|
|
|
|
int x, int y, int w, int h)
|
|
|
|
: Dialog(osystem, parent, x, y, w, h),
|
2005-06-10 17:46:07 +00:00
|
|
|
myTab(NULL)
|
2005-06-03 17:52:06 +00:00
|
|
|
{
|
2005-07-19 17:59:59 +00:00
|
|
|
addTiaArea();
|
|
|
|
addTabArea();
|
|
|
|
addStatusArea();
|
2005-08-04 22:59:54 +00:00
|
|
|
addRomArea();
|
2005-06-03 17:52:06 +00:00
|
|
|
}
|
|
|
|
|
2005-06-09 19:04:59 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-06-10 17:46:07 +00:00
|
|
|
DebuggerDialog::~DebuggerDialog()
|
2005-06-09 19:04:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-06-07 01:27:06 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::loadConfig()
|
|
|
|
{
|
2005-08-10 12:23:42 +00:00
|
|
|
cerr << " ==> DebuggerDialog::loadConfig()\n";
|
2005-06-17 14:42:49 +00:00
|
|
|
myTab->loadConfig();
|
2005-07-21 19:30:17 +00:00
|
|
|
myTiaInfo->loadConfig();
|
2005-08-03 13:26:02 +00:00
|
|
|
myTiaOutput->loadConfig();
|
2005-08-10 12:23:42 +00:00
|
|
|
myCpu->loadConfig();
|
2005-08-10 14:44:01 +00:00
|
|
|
myRam->loadConfig();
|
2005-06-07 01:27:06 +00:00
|
|
|
}
|
|
|
|
|
2005-06-03 17:52:06 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-06-10 17:46:07 +00:00
|
|
|
void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
2005-06-03 17:52:06 +00:00
|
|
|
{
|
2005-06-24 12:01:27 +00:00
|
|
|
// Doing this means we disallow 'Alt xxx' events to any widget in the tabset
|
|
|
|
if(instance()->eventHandler().kbdAlt(modifiers))
|
|
|
|
{
|
|
|
|
if(ascii == 's')
|
|
|
|
doStep();
|
|
|
|
else if(ascii == 't')
|
|
|
|
doTrace();
|
2005-06-30 00:08:02 +00:00
|
|
|
else if(ascii == 'f')
|
|
|
|
doAdvance();
|
2005-07-15 15:27:29 +00:00
|
|
|
else if(ascii == 'l')
|
|
|
|
doScanlineAdvance();
|
2005-06-24 12:01:27 +00:00
|
|
|
}
|
|
|
|
else
|
2005-08-10 12:23:42 +00:00
|
|
|
Dialog::handleKeyDown(ascii, keycode, modifiers);
|
2005-06-03 17:52:06 +00:00
|
|
|
}
|
2005-06-17 03:49:10 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-07-05 15:25:45 +00:00
|
|
|
void DebuggerDialog::handleCommand(CommandSender* sender, int cmd,
|
|
|
|
int data, int id)
|
2005-06-17 14:42:49 +00:00
|
|
|
{
|
2005-06-17 17:34:01 +00:00
|
|
|
// We reload the tabs in the cases where the actions could possibly
|
|
|
|
// change their contents
|
2005-06-17 14:42:49 +00:00
|
|
|
switch(cmd)
|
|
|
|
{
|
|
|
|
case kDDStepCmd:
|
2005-06-24 12:01:27 +00:00
|
|
|
doStep();
|
2005-06-17 14:42:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kDDTraceCmd:
|
2005-06-24 12:01:27 +00:00
|
|
|
doTrace();
|
2005-06-17 17:34:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kDDAdvCmd:
|
2005-06-24 12:01:27 +00:00
|
|
|
doAdvance();
|
2005-06-17 17:34:01 +00:00
|
|
|
break;
|
|
|
|
|
2005-07-15 15:27:29 +00:00
|
|
|
case kDDSAdvCmd:
|
|
|
|
doScanlineAdvance();
|
|
|
|
break;
|
|
|
|
|
2005-06-17 17:34:01 +00:00
|
|
|
case kDDExitCmd:
|
2005-06-24 12:01:27 +00:00
|
|
|
doExit();
|
2005-06-17 14:42:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-07-05 15:25:45 +00:00
|
|
|
Dialog::handleCommand(sender, cmd, data, 0);
|
2005-06-17 14:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-19 17:59:59 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::addTiaArea()
|
|
|
|
{
|
|
|
|
GUI::Rect r = instance()->debugger().getTiaBounds();
|
|
|
|
|
|
|
|
myTiaOutput = new TiaOutputWidget(this, r.left, r.top, r.width(), r.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::addTabArea()
|
|
|
|
{
|
|
|
|
GUI::Rect r = instance()->debugger().getTabBounds();
|
|
|
|
|
2005-08-04 22:59:54 +00:00
|
|
|
const int vBorder = 4;
|
|
|
|
const int widWidth = r.width() - vBorder;
|
|
|
|
const int widHeight = r.height() - 25; // FIXME - magic number/font height
|
2005-08-10 12:23:42 +00:00
|
|
|
int tabID;
|
2005-08-04 22:59:54 +00:00
|
|
|
|
2005-07-19 17:59:59 +00:00
|
|
|
// The tab widget
|
2005-08-04 22:59:54 +00:00
|
|
|
myTab = new TabWidget(this, r.left, r.top + vBorder,
|
2005-08-10 12:23:42 +00:00
|
|
|
r.width(), r.height() - vBorder);
|
|
|
|
addTabWidget(myTab);
|
2005-07-19 17:59:59 +00:00
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
// The Prompt/console tab
|
|
|
|
tabID = myTab->addTab("Prompt");
|
2005-08-04 22:59:54 +00:00
|
|
|
myPrompt = new PromptWidget(myTab, 2, 2, widWidth, widHeight);
|
2005-08-10 12:23:42 +00:00
|
|
|
myTab->setParentWidget(tabID, myPrompt);
|
|
|
|
addToFocusList(myPrompt->getFocusList(), tabID);
|
2005-07-19 17:59:59 +00:00
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
// The TIA tab
|
|
|
|
tabID = myTab->addTab("TIA");
|
2005-08-04 22:59:54 +00:00
|
|
|
TiaWidget* tia = new TiaWidget(myTab, 2, 2, widWidth, widHeight);
|
2005-08-10 12:23:42 +00:00
|
|
|
myTab->setParentWidget(tabID, tia);
|
|
|
|
addToFocusList(tia->getFocusList(), tabID);
|
2005-07-19 17:59:59 +00:00
|
|
|
|
2005-08-10 14:44:01 +00:00
|
|
|
// The input/output tab (part of RIOT)
|
|
|
|
tabID = myTab->addTab("I/O");
|
|
|
|
|
2005-08-10 12:23:42 +00:00
|
|
|
// The Cheat tab
|
|
|
|
tabID = myTab->addTab("Cheat");
|
2005-08-04 22:59:54 +00:00
|
|
|
CheatWidget* cheat = new CheatWidget(myTab, 2, 2, widWidth, widHeight);
|
2005-08-10 12:23:42 +00:00
|
|
|
myTab->setParentWidget(tabID, cheat);
|
|
|
|
addToFocusList(cheat->getFocusList(), tabID);
|
2005-07-19 17:59:59 +00:00
|
|
|
|
|
|
|
myTab->setActiveTab(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::addStatusArea()
|
|
|
|
{
|
|
|
|
GUI::Rect r = instance()->debugger().getStatusBounds();
|
2005-07-21 19:30:17 +00:00
|
|
|
myTiaInfo = new TiaInfoWidget(this, r.left, r.top, r.width(), r.height());
|
2005-07-19 17:59:59 +00:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:59:54 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::addRomArea()
|
|
|
|
{
|
|
|
|
GUI::Rect r = instance()->debugger().getRomBounds();
|
2005-08-10 12:23:42 +00:00
|
|
|
int xpos, ypos;
|
|
|
|
|
|
|
|
xpos = r.left + 10; ypos = 10;
|
|
|
|
myCpu = new CpuWidget(this, instance()->consoleFont(), xpos, ypos);
|
|
|
|
addToFocusList(myCpu->getFocusList());
|
2005-08-04 22:59:54 +00:00
|
|
|
|
2005-08-10 18:44:37 +00:00
|
|
|
xpos = r.left + 10; ypos += myCpu->getHeight() + 10;
|
2005-08-10 14:44:01 +00:00
|
|
|
myRam = new RamWidget(this, instance()->consoleFont(), xpos, ypos);
|
|
|
|
addToFocusList(myRam->getFocusList());
|
|
|
|
|
2005-08-10 18:44:37 +00:00
|
|
|
xpos = r.left + 10 + myCpu->getWidth() + 20; ypos = 20;
|
|
|
|
DataGridOpsWidget* ops = new DataGridOpsWidget(this, xpos, ypos);
|
|
|
|
ops->setEnabled(false);
|
|
|
|
|
|
|
|
// Add the DataGridOpsWidget to any widgets which contain a
|
|
|
|
// DataGridWidget which we want controlled
|
|
|
|
myCpu->setOpsWidget(ops);
|
|
|
|
myRam->setOpsWidget(ops);
|
|
|
|
|
|
|
|
|
2005-08-04 22:59:54 +00:00
|
|
|
// Add some buttons that are always shown, no matter which tab we're in
|
|
|
|
// FIXME - these positions will definitely change
|
2005-08-10 12:23:42 +00:00
|
|
|
xpos = r.right - 100; ypos = r.bottom - 150;
|
|
|
|
addButton(xpos, ypos, "Step", kDDStepCmd, 0);
|
|
|
|
ypos += 22;
|
|
|
|
addButton(xpos, ypos, "Trace", kDDTraceCmd, 0);
|
|
|
|
ypos += 22;
|
|
|
|
addButton(xpos, ypos, "Scan +1", kDDSAdvCmd, 0);
|
|
|
|
ypos += 22;
|
|
|
|
addButton(xpos, ypos, "Frame +1", kDDAdvCmd, 0);
|
|
|
|
|
|
|
|
addButton(xpos, r.bottom - 22 - 10, "Exit", kDDExitCmd, 0);
|
2005-08-04 22:59:54 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:01:27 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::doStep()
|
|
|
|
{
|
|
|
|
instance()->debugger().step();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::doTrace()
|
|
|
|
{
|
|
|
|
instance()->debugger().trace();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::doAdvance()
|
|
|
|
{
|
|
|
|
instance()->debugger().nextFrame(1);
|
|
|
|
}
|
|
|
|
|
2005-07-15 15:27:29 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::doScanlineAdvance()
|
|
|
|
{
|
|
|
|
instance()->debugger().nextScanline(1);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:01:27 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DebuggerDialog::doExit()
|
|
|
|
{
|
|
|
|
instance()->debugger().quit();
|
|
|
|
}
|