1
//============================================================================
5
// SS tttttt eeee ll ll aaaa
6
// SSSS tt ee ee ll ll aa
7
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8
// SS SS tt ee ll ll aa aa
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony
12
// and the Stella Team
14
// See the file "License.txt" for information on usage and redistribution of
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
17
// $Id: DrivingWidget.cxx 2352 2012-01-10 18:24:13Z stephena $
18
//============================================================================
20
#include "DataGridWidget.hxx"
21
#include "DrivingWidget.hxx"
23
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24
DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
25
int x, int y, Controller& controller)
26
: ControllerWidget(boss, font, x, y, controller),
29
bool leftport = myController.jack() == Controller::Left;
30
const string& label = leftport ? "Left (Driving):" : "Right (Driving):";
32
const int fontHeight = font.getFontHeight(),
33
bwidth = font.getStringWidth("Grey code +") + 10,
34
bheight = font.getLineHeight() + 4;
35
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving):");
38
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
39
fontHeight, label, kTextAlignLeft);
41
ypos += t->getHeight() + 20;
42
myGreyUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
43
"Grey code +", kGreyUpCmd);
44
myGreyUp->setTarget(this);
46
ypos += myGreyUp->getHeight() + 5;
47
myGreyDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
48
"Grey code -", kGreyDownCmd);
49
myGreyDown->setTarget(this);
51
xpos += myGreyDown->getWidth() + 10; ypos -= 10;
52
myGreyValue = new DataGridWidget(boss, font, xpos, ypos,
53
1, 1, 2, 8, kBASE_16);
54
myGreyValue->setTarget(this);
55
myGreyValue->setEditable(false);
57
xpos = x + 30; ypos += myGreyDown->getHeight() + 20;
58
myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd);
59
myFire->setTarget(this);
62
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63
DrivingWidget::~DrivingWidget()
67
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68
void DrivingWidget::loadConfig()
71
if(myController.read(Controller::One)) grey += 1;
72
if(myController.read(Controller::Two)) grey += 2;
74
for(myGreyIndex = 0; myGreyIndex < 4; ++myGreyIndex)
75
if(ourGreyTable[myGreyIndex] == grey)
78
myFire->setState(!myController.read(Controller::Six));
79
myGreyValue->setList(0, grey);
82
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
83
void DrivingWidget::handleCommand(
84
CommandSender* sender, int cmd, int data, int id)
89
myGreyIndex = (myGreyIndex + 1) % 4;
90
myController.set(Controller::One, (ourGreyTable[myGreyIndex] & 0x1) != 0);
91
myController.set(Controller::Two, (ourGreyTable[myGreyIndex] & 0x2) != 0);
92
myGreyValue->setList(0, ourGreyTable[myGreyIndex]);
95
myGreyIndex = myGreyIndex == 0 ? 3 : myGreyIndex - 1;
96
myController.set(Controller::One, (ourGreyTable[myGreyIndex] & 0x1) != 0);
97
myController.set(Controller::Two, (ourGreyTable[myGreyIndex] & 0x2) != 0);
98
myGreyValue->setList(0, ourGreyTable[myGreyIndex]);
101
myController.set(Controller::Six, !myFire->getState());
106
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107
uInt8 DrivingWidget::ourGreyTable[4] = { 0x03, 0x01, 0x00, 0x02 };
b'\\ No newline at end of file'