Added paddle widget to the debugger I/O tab. This is actually the

first time that paddle movement is able to be set from within
the debugger!


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2337 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-01-06 18:17:41 +00:00
parent 6453a1ac14
commit 35255514c8
11 changed files with 245 additions and 47 deletions

View File

@ -33,9 +33,24 @@ class ControllerWidget : public Widget, public CommandSender
Controller& controller)
: Widget(boss, font, x, y, 16, 16),
CommandSender(boss),
_controller(controller)
myController(controller)
{
_type = kControllerWidget;
/* FIXME - add this to controllers that won't have their own widget class
bool leftport = controller.jack() == Controller::Left;
const string& label = leftport ? "Left (Unknown):" : "Right (Unknown):";
const int fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight(),
lwidth = font.getStringWidth("Controller not implemented");
new StaticTextWidget(boss, font, x, y+2, lwidth,
fontHeight, label, kTextAlignLeft);
new StaticTextWidget(boss, font, x, y+2+2*lineHeight, lwidth,
fontHeight, "Controller not implemented",
kTextAlignLeft);
_w = lwidth + 10;
_h = 6 * lineHeight;
*/
}
virtual ~ControllerWidget() { };
@ -44,7 +59,7 @@ class ControllerWidget : public Widget, public CommandSender
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) { };
protected:
Controller& _controller;
Controller& myController;
};
#endif

View File

@ -26,68 +26,46 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, Controller& controller)
: ControllerWidget(boss, font, x, y, controller)
{
bool leftport = _controller.jack() == Controller::Left;
if(leftport)
{
myPinEvent[kJUp] = Event::JoystickZeroUp;
myPinEvent[kJDown] = Event::JoystickZeroDown;
myPinEvent[kJLeft] = Event::JoystickZeroLeft;
myPinEvent[kJRight] = Event::JoystickZeroRight;
myPinEvent[kJFire] = Event::JoystickZeroFire1;
}
else
{
myPinEvent[kJUp] = Event::JoystickOneUp;
myPinEvent[kJDown] = Event::JoystickOneDown;
myPinEvent[kJLeft] = Event::JoystickOneLeft;
myPinEvent[kJRight] = Event::JoystickOneRight;
myPinEvent[kJFire] = Event::JoystickOneFire1;
}
bool leftport = myController.jack() == Controller::Left;
const string& label = leftport ? "Left (Joystick):" : "Right (Joystick):";
const int fontWidth = font.getMaxCharWidth(),
const int /*fontWidth = font.getMaxCharWidth(),*/
fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight();
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Joystick):");
StaticTextWidget* t;
_w = lwidth + 10;
_h = 6 * lineHeight;
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, kTextAlignLeft);
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 5;
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10;
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJUp]->setID(kJUp);
myPins[kJUp]->setTarget(this);
addFocusWidget(myPins[kJUp]);
ypos += myPins[kJUp]->getHeight() * 2 + 10;
myPins[kJDown] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJDown]->setID(kJDown);
myPins[kJDown]->setTarget(this);
addFocusWidget(myPins[kJDown]);
xpos -= myPins[kJUp]->getWidth() + 5;
ypos -= myPins[kJUp]->getHeight() + 5;
myPins[kJLeft] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJLeft]->setID(kJLeft);
myPins[kJLeft]->setTarget(this);
addFocusWidget(myPins[kJLeft]);
_w = xpos;
xpos += (myPins[kJUp]->getWidth() + 5) * 2;
myPins[kJRight] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJRight]->setID(kJRight);
myPins[kJRight]->setTarget(this);
addFocusWidget(myPins[kJRight]);
xpos -= (myPins[kJUp]->getWidth() + 5) * 2;
ypos = 20 + (myPins[kJUp]->getHeight() + 10) * 3;
myPins[kJFire] = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kCheckActionCmd);
myPins[kJFire]->setID(kJFire);
myPins[kJFire]->setTarget(this);
addFocusWidget(myPins[kJFire]);
_h = ypos;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -98,10 +76,23 @@ JoystickWidget::~JoystickWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoystickWidget::loadConfig()
{
myPins[kJUp]->setState(!myController.read(ourPinNo[kJUp]));
myPins[kJDown]->setState(!myController.read(ourPinNo[kJDown]));
myPins[kJLeft]->setState(!myController.read(ourPinNo[kJLeft]));
myPins[kJRight]->setState(!myController.read(ourPinNo[kJRight]));
myPins[kJFire]->setState(!myController.read(ourPinNo[kJFire]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void JoystickWidget::handleCommand(
CommandSender* sender, int cmd, int data, int id)
{
if(cmd == kCheckActionCmd)
myController.set(ourPinNo[id], !myPins[id]->getState());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Controller::DigitalPin JoystickWidget::ourPinNo[5] = {
Controller::One, Controller::Two, Controller::Three, Controller::Four,
Controller::Six
};

View File

@ -38,7 +38,7 @@ class JoystickWidget : public ControllerWidget
enum { kJUp = 0, kJDown, kJLeft, kJRight, kJFire };
CheckboxWidget* myPins[5];
Event::Type myPinEvent[5];
static Controller::DigitalPin ourPinNo[5];
};
#endif

View File

@ -0,0 +1,108 @@
//============================================================================
//
// 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-2012 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$
//============================================================================
#include "OSystem.hxx"
#include "EventHandler.hxx"
#include "PaddleWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, Controller& controller)
: ControllerWidget(boss, font, x, y, controller)
{
bool leftport = myController.jack() == Controller::Left;
const string& label = leftport ? "Left (Paddles):" : "Right (Paddles):";
const int fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight();
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Paddles):");
StaticTextWidget* t;
_w = lwidth + 10;
_h = 6 * lineHeight;
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, kTextAlignLeft);
xpos = x; ypos += t->getHeight() + 10;
const string& p0string = leftport ? "P0 pot: " : "P2 pot: ";
const string& p1string = leftport ? "P1 pot: " : "P3 pot: ";
lwidth = font.getStringWidth("P3 pot: ");
myP0Resistance =
new SliderWidget(boss, font, xpos, ypos, 10*fontWidth, lineHeight,
p0string, lwidth, kP0Changed);
myP0Resistance->setMinValue(0); myP0Resistance->setMaxValue(1400000);
myP0Resistance->setStepValue(1400000/100);
myP0Resistance->setTarget(this);
xpos += 20; ypos += myP0Resistance->getHeight() + 4;
myP0Fire = new CheckboxWidget(boss, font, xpos, ypos,
"Fire", kP0Fire);
myP0Fire->setTarget(this);
xpos = x; ypos += 2*lineHeight;
myP1Resistance =
new SliderWidget(boss, font, xpos, ypos, 10*fontWidth, lineHeight,
p1string, lwidth, kP1Changed);
myP1Resistance->setMinValue(0); myP1Resistance->setMaxValue(1400000);
myP1Resistance->setStepValue(1400000/100);
myP1Resistance->setTarget(this);
xpos += 20; ypos += myP1Resistance->getHeight() + 4;
myP1Fire = new CheckboxWidget(boss, font, xpos, ypos,
"Fire", kP1Fire);
myP1Fire->setTarget(this);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaddleWidget::~PaddleWidget()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaddleWidget::loadConfig()
{
myP0Resistance->setValue(1400000 - (Int32)myController.read(Controller::Nine));
myP1Resistance->setValue(1400000 - (Int32)myController.read(Controller::Five));
myP0Fire->setState(!myController.read(Controller::Four));
myP1Fire->setState(!myController.read(Controller::Three));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaddleWidget::handleCommand(
CommandSender* sender, int cmd, int data, int id)
{
switch(cmd)
{
case kP0Changed:
myController.set(Controller::Nine, 1400000 - myP0Resistance->getValue());
break;
case kP1Changed:
myController.set(Controller::Five, 1400000 - myP1Resistance->getValue());
break;
case kP0Fire:
myController.set(Controller::Four, !myP0Fire->getState());
break;
case kP1Fire:
myController.set(Controller::Three, !myP1Fire->getState());
break;
}
}

View File

@ -0,0 +1,45 @@
//============================================================================
//
// 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-2012 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 PADDLE_WIDGET_HXX
#define PADDLE_WIDGET_HXX
#include "Control.hxx"
#include "Event.hxx"
#include "ControllerWidget.hxx"
class PaddleWidget : public ControllerWidget
{
public:
PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
Controller& controller);
virtual ~PaddleWidget();
void loadConfig();
void handleCommand(CommandSender* sender, int cmd, int data, int id);
private:
enum { kP0Changed = 'P0ch', kP1Changed = 'P1ch',
kP0Fire = 'P0fr', kP1Fire = 'P1fr' };
SliderWidget *myP0Resistance, *myP1Resistance;
CheckboxWidget *myP0Fire, *myP1Fire;
};
#endif

View File

@ -32,6 +32,7 @@
#include "ControllerWidget.hxx"
#include "JoystickWidget.hxx"
#include "PaddleWidget.hxx"
#include "RiotWidget.hxx"
@ -129,10 +130,9 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
xpos = col; ypos = 10;
myLeftControl = addControlWidget(boss, font, xpos, ypos,
riot.controller(Controller::Left));
xpos += col + myLeftControl->getWidth() + 15;
xpos += myLeftControl->getWidth() + 15;
myRightControl = addControlWidget(boss, font, xpos, ypos,
riot.controller(Controller::Right));
//FIXME - add focus to these widget??
// PO & P1 difficulty switches
int pwidth = font.getStringWidth("B/easy");
@ -248,6 +248,9 @@ void RiotWidget::loadConfig()
myTVType->setSelected((int)riot.tvType());
mySelect->setState(!riot.select());
myReset->setState(!riot.reset());
myLeftControl->loadConfig();
myRightControl->loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -337,6 +340,8 @@ ControllerWidget* RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font&
{
case Controller::Joystick:
return new JoystickWidget(boss, font, x, y, controller);
case Controller::Paddles:
return new PaddleWidget(boss, font, x, y, controller);
default:
return new ControllerWidget(boss, font, x, y, controller);
}

View File

@ -19,7 +19,8 @@ MODULE_OBJS := \
src/debugger/gui/ToggleBitWidget.o \
src/debugger/gui/TogglePixelWidget.o \
src/debugger/gui/ToggleWidget.o \
src/debugger/gui/JoystickWidget.o
src/debugger/gui/JoystickWidget.o \
src/debugger/gui/PaddleWidget.o
MODULE_DIRS += \
src/debugger/gui

View File

@ -92,6 +92,7 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
// Construct the system and components
mySystem = new System(13, 6);
#if 0
// The real controllers for this console will be added later
// For now, we just add dummy joystick controllers, since autodetection
// runs the emulation for a while, and this may interfere with 'smart'
@ -101,6 +102,19 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
// (particularly the M6532)
myControllers[0] = new Joystick(Controller::Left, *myEvent, *mySystem);
myControllers[1] = new Joystick(Controller::Right, *myEvent, *mySystem);
#endif
const string& md5 = myProperties.get(Cartridge_MD5);
// Add the real controllers for this system
setControllers(md5);
// Bumper Bash always requires all 4 directions
// Other ROMs can use it if the setting is enabled
bool joyallow4 = md5 == "aa1c41f86ec44c0a44eb64c332ce08af" ||
md5 == "1bf503c724001b09be79c515ecfcbd03" ||
myOSystem->settings().getBool("joyallow4");
myOSystem->eventHandler().allowAllDirections(joyallow4);
M6502* m6502 = new M6502(1);
#ifdef DEBUGGER_SUPPORT
@ -198,18 +212,6 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
myTIA->setHeight(height);
}
const string& md5 = myProperties.get(Cartridge_MD5);
// Add the real controllers for this system
setControllers(md5);
// Bumper Bash always requires all 4 directions
// Other ROMs can use it if the setting is enabled
bool joyallow4 = md5 == "aa1c41f86ec44c0a44eb64c332ce08af" ||
md5 == "1bf503c724001b09be79c515ecfcbd03" ||
myOSystem->settings().getBool("joyallow4");
myOSystem->eventHandler().allowAllDirections(joyallow4);
// Reset the system to its power-on state
mySystem->reset();

View File

@ -134,6 +134,18 @@ Int32 Controller::read(AnalogPin pin)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Controller::set(DigitalPin pin, bool value)
{
myDigitalPinState[pin] = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Controller::set(AnalogPin pin, Int32 value)
{
myAnalogPinValue[pin] = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Controller::save(Serializer& out) const
{

View File

@ -181,7 +181,6 @@ class Controller : public Serializable
*/
virtual void update() = 0;
/**
Notification method invoked by the system right before the
system resets its cycle counter to zero. It may be necessary
@ -218,6 +217,18 @@ class Controller : public Serializable
*/
virtual string about() const;
/**
The following two functions are used by the debugger to set
the specified pins to the given value. Note that this isn't the
same as a write; the debugger is allowed special access and is
actually 'below' the controller level.
@param pin The pin of the controller jack to modify
@param value The value to set on the pin
*/
void set(DigitalPin pin, bool value);
void set(AnalogPin pin, Int32 value);
/**
Saves the current state of this controller to the given Serializer.

View File

@ -326,6 +326,8 @@
DCCF47DE14B60DEE00814FAB /* ControllerWidget.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCCF47DB14B60DEE00814FAB /* ControllerWidget.hxx */; };
DCCF47DF14B60DEE00814FAB /* JoystickWidget.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCCF47DC14B60DEE00814FAB /* JoystickWidget.cxx */; };
DCCF47E014B60DEE00814FAB /* JoystickWidget.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCCF47DD14B60DEE00814FAB /* JoystickWidget.hxx */; };
DCCF49B714B7544A00814FAB /* PaddleWidget.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCCF49B514B7544A00814FAB /* PaddleWidget.cxx */; };
DCCF49B814B7544A00814FAB /* PaddleWidget.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCCF49B614B7544A00814FAB /* PaddleWidget.hxx */; };
DCD2839812E39F1200A808DC /* Thumbulator.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCD2839612E39F1200A808DC /* Thumbulator.cxx */; };
DCD2839912E39F1200A808DC /* Thumbulator.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCD2839712E39F1200A808DC /* Thumbulator.hxx */; };
DCD3F7C511340AAF00DBA3AE /* Genesis.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCD3F7C311340AAF00DBA3AE /* Genesis.cxx */; };
@ -747,6 +749,8 @@
DCCF47DB14B60DEE00814FAB /* ControllerWidget.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ControllerWidget.hxx; path = ../debugger/gui/ControllerWidget.hxx; sourceTree = SOURCE_ROOT; };
DCCF47DC14B60DEE00814FAB /* JoystickWidget.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JoystickWidget.cxx; path = ../debugger/gui/JoystickWidget.cxx; sourceTree = SOURCE_ROOT; };
DCCF47DD14B60DEE00814FAB /* JoystickWidget.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = JoystickWidget.hxx; path = ../debugger/gui/JoystickWidget.hxx; sourceTree = SOURCE_ROOT; };
DCCF49B514B7544A00814FAB /* PaddleWidget.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PaddleWidget.cxx; path = ../debugger/gui/PaddleWidget.cxx; sourceTree = SOURCE_ROOT; };
DCCF49B614B7544A00814FAB /* PaddleWidget.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PaddleWidget.hxx; path = ../debugger/gui/PaddleWidget.hxx; sourceTree = SOURCE_ROOT; };
DCD2839612E39F1200A808DC /* Thumbulator.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Thumbulator.cxx; path = ../emucore/Thumbulator.cxx; sourceTree = SOURCE_ROOT; };
DCD2839712E39F1200A808DC /* Thumbulator.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Thumbulator.hxx; path = ../emucore/Thumbulator.hxx; sourceTree = SOURCE_ROOT; };
DCD3F7C311340AAF00DBA3AE /* Genesis.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Genesis.cxx; path = ../emucore/Genesis.cxx; sourceTree = SOURCE_ROOT; };
@ -925,6 +929,8 @@
2D20F9ED08C603EC00A73076 /* DebuggerDialog.hxx */,
DCCF47DC14B60DEE00814FAB /* JoystickWidget.cxx */,
DCCF47DD14B60DEE00814FAB /* JoystickWidget.hxx */,
DCCF49B514B7544A00814FAB /* PaddleWidget.cxx */,
DCCF49B614B7544A00814FAB /* PaddleWidget.hxx */,
2D20F9EE08C603EC00A73076 /* PromptWidget.cxx */,
2D20F9EF08C603EC00A73076 /* PromptWidget.hxx */,
2D20F9F008C603EC00A73076 /* RamWidget.cxx */,
@ -1522,6 +1528,7 @@
DC8C1BB214B25DE7006440EE /* MindLink.hxx in Headers */,
DCCF47DE14B60DEE00814FAB /* ControllerWidget.hxx in Headers */,
DCCF47E014B60DEE00814FAB /* JoystickWidget.hxx in Headers */,
DCCF49B814B7544A00814FAB /* PaddleWidget.hxx in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1788,6 +1795,7 @@
DC8C1BAF14B25DE7006440EE /* CompuMate.cxx in Sources */,
DC8C1BB114B25DE7006440EE /* MindLink.cxx in Sources */,
DCCF47DF14B60DEE00814FAB /* JoystickWidget.cxx in Sources */,
DCCF49B714B7544A00814FAB /* PaddleWidget.cxx in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};