mirror of https://github.com/stella-emu/stella.git
Added driving controller widget to the debugger I/O tab.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2351 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
30bfa0e639
commit
3113bea297
|
@ -146,6 +146,20 @@ void DataGridWidget::setList(int a, int v, bool c)
|
||||||
setList(alist, vlist, changed);
|
setList(alist, vlist, changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void DataGridWidget::setList(int a, int v)
|
||||||
|
{
|
||||||
|
IntArray alist, vlist;
|
||||||
|
BoolArray changed;
|
||||||
|
|
||||||
|
alist.push_back(a);
|
||||||
|
vlist.push_back(v);
|
||||||
|
bool diff = _addrList.size() == 1 ? getSelectedValue() != v : false;
|
||||||
|
changed.push_back(diff);
|
||||||
|
|
||||||
|
setList(alist, vlist, changed);
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DataGridWidget::setHiliteList(const BoolArray& hilitelist)
|
void DataGridWidget::setHiliteList(const BoolArray& hilitelist)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ class DataGridWidget : public EditableWidget
|
||||||
const BoolArray& changed);
|
const BoolArray& changed);
|
||||||
/** Convenience method for when the datagrid contains only one value */
|
/** Convenience method for when the datagrid contains only one value */
|
||||||
void setList(int a, int v, bool changed);
|
void setList(int a, int v, bool changed);
|
||||||
|
void setList(int a, int v); // automatically calculate if changed
|
||||||
|
|
||||||
void setHiliteList(const BoolArray& hilitelist);
|
void setHiliteList(const BoolArray& hilitelist);
|
||||||
void setNumRows(int rows);
|
void setNumRows(int rows);
|
||||||
|
|
|
@ -17,24 +17,46 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "OSystem.hxx"
|
#include "DataGridWidget.hxx"
|
||||||
#include "EventHandler.hxx"
|
|
||||||
#include "DrivingWidget.hxx"
|
#include "DrivingWidget.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
|
DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y, Controller& controller)
|
int x, int y, Controller& controller)
|
||||||
: ControllerWidget(boss, font, x, y, controller)
|
: ControllerWidget(boss, font, x, y, controller),
|
||||||
|
myGreyIndex(0)
|
||||||
{
|
{
|
||||||
bool leftport = myController.jack() == Controller::Left;
|
bool leftport = myController.jack() == Controller::Left;
|
||||||
const string& label = leftport ? "Left (Driving):" : "Right (Driving):";
|
const string& label = leftport ? "Left (Driving):" : "Right (Driving):";
|
||||||
|
|
||||||
const int fontHeight = font.getFontHeight();
|
const int fontHeight = font.getFontHeight(),
|
||||||
|
bwidth = font.getStringWidth("Grey code +") + 10,
|
||||||
|
bheight = font.getLineHeight() + 4;
|
||||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving):");
|
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving):");
|
||||||
StaticTextWidget* t;
|
StaticTextWidget* t;
|
||||||
|
|
||||||
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||||
fontHeight, label, kTextAlignLeft);
|
fontHeight, label, kTextAlignLeft);
|
||||||
|
|
||||||
|
ypos += t->getHeight() + 10;
|
||||||
|
myGreyUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||||
|
"Grey code +", kGreyUpCmd);
|
||||||
|
myGreyUp->setTarget(this);
|
||||||
|
|
||||||
|
ypos += myGreyUp->getHeight() + 5;
|
||||||
|
myGreyDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||||
|
"Grey code -", kGreyDownCmd);
|
||||||
|
myGreyDown->setTarget(this);
|
||||||
|
|
||||||
|
xpos += myGreyDown->getWidth() + 10; ypos -= 10;
|
||||||
|
myGreyValue = new DataGridWidget(boss, font, xpos, ypos,
|
||||||
|
1, 1, 2, 8, kBASE_16);
|
||||||
|
myGreyValue->setTarget(this);
|
||||||
|
myGreyValue->setEditable(false);
|
||||||
|
|
||||||
|
xpos = x + 30; ypos += myGreyDown->getHeight() + 20;
|
||||||
|
myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd);
|
||||||
|
myFire->setTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -45,10 +67,41 @@ DrivingWidget::~DrivingWidget()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DrivingWidget::loadConfig()
|
void DrivingWidget::loadConfig()
|
||||||
{
|
{
|
||||||
|
uInt8 grey = 0;
|
||||||
|
if(myController.read(Controller::One)) grey += 1;
|
||||||
|
if(myController.read(Controller::Two)) grey += 2;
|
||||||
|
|
||||||
|
for(myGreyIndex = 0; myGreyIndex < 4; ++myGreyIndex)
|
||||||
|
if(ourGreyTable[myGreyIndex] == grey)
|
||||||
|
break;
|
||||||
|
|
||||||
|
myFire->setState(!myController.read(Controller::Six));
|
||||||
|
myGreyValue->setList(0, grey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DrivingWidget::handleCommand(
|
void DrivingWidget::handleCommand(
|
||||||
CommandSender* sender, int cmd, int data, int id)
|
CommandSender* sender, int cmd, int data, int id)
|
||||||
{
|
{
|
||||||
|
switch(cmd)
|
||||||
|
{
|
||||||
|
case kGreyUpCmd:
|
||||||
|
myGreyIndex = (myGreyIndex + 1) % 4;
|
||||||
|
myController.set(Controller::One, (ourGreyTable[myGreyIndex] & 0x1) != 0);
|
||||||
|
myController.set(Controller::Two, (ourGreyTable[myGreyIndex] & 0x2) != 0);
|
||||||
|
myGreyValue->setList(0, ourGreyTable[myGreyIndex]);
|
||||||
|
break;
|
||||||
|
case kGreyDownCmd:
|
||||||
|
myGreyIndex = myGreyIndex == 0 ? 3 : myGreyIndex - 1;
|
||||||
|
myController.set(Controller::One, (ourGreyTable[myGreyIndex] & 0x1) != 0);
|
||||||
|
myController.set(Controller::Two, (ourGreyTable[myGreyIndex] & 0x2) != 0);
|
||||||
|
myGreyValue->setList(0, ourGreyTable[myGreyIndex]);
|
||||||
|
break;
|
||||||
|
case kFireCmd:
|
||||||
|
myController.set(Controller::Six, !myFire->getState());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
uInt8 DrivingWidget::ourGreyTable[4] = { 0x03, 0x01, 0x00, 0x02 };
|
|
@ -20,6 +20,10 @@
|
||||||
#ifndef DRIVING_WIDGET_HXX
|
#ifndef DRIVING_WIDGET_HXX
|
||||||
#define DRIVING_WIDGET_HXX
|
#define DRIVING_WIDGET_HXX
|
||||||
|
|
||||||
|
class ButtonWidget;
|
||||||
|
class CheckboxWidget;
|
||||||
|
class DataGridWidget;
|
||||||
|
|
||||||
#include "Control.hxx"
|
#include "Control.hxx"
|
||||||
#include "Event.hxx"
|
#include "Event.hxx"
|
||||||
#include "ControllerWidget.hxx"
|
#include "ControllerWidget.hxx"
|
||||||
|
@ -35,6 +39,18 @@ class DrivingWidget : public ControllerWidget
|
||||||
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum {
|
||||||
|
kGreyUpCmd = 'DWup',
|
||||||
|
kGreyDownCmd = 'DWdn',
|
||||||
|
kFireCmd = 'DWfr'
|
||||||
|
};
|
||||||
|
ButtonWidget *myGreyUp, *myGreyDown;
|
||||||
|
DataGridWidget* myGreyValue;
|
||||||
|
CheckboxWidget* myFire;
|
||||||
|
|
||||||
|
int myGreyIndex;
|
||||||
|
|
||||||
|
static uInt8 ourGreyTable[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue