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-2013 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: CartCMWidget.cxx 2743 2013-05-29 16:27:12Z stephena $
18
//============================================================================
21
#include "RiotDebug.hxx"
22
#include "DataGridWidget.hxx"
23
#include "EditTextWidget.hxx"
24
#include "PopUpWidget.hxx"
25
#include "ToggleBitWidget.hxx"
26
#include "CartCMWidget.hxx"
28
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29
CartridgeCMWidget::CartridgeCMWidget(
30
GuiObject* boss, const GUI::Font& font,
31
int x, int y, int w, int h, CartridgeCM& cart)
32
: CartDebugWidget(boss, font, x, y, w, h),
35
uInt16 size = 4 * 4096;
38
"CM cartridge, four 4K banks + 2K RAM\n"
39
"2K RAM accessible @ $1800 - $1FFF in read or write-only mode "
40
"(no separate ports)\n"
41
"All TIA controller registers (INPT0-INPT5) and RIOT SWCHA are "
42
"used to control the cart functionality\n"
43
"Startup bank = 3 (ROM), RAM disabled\n";
46
ypos = addBaseInformation(size, "CompuMate", info) + myLineHeight;
49
items.push_back(" 0 ");
50
items.push_back(" 1 ");
51
items.push_back(" 2 ");
52
items.push_back(" 3 ");
54
new PopUpWidget(boss, font, xpos, ypos-2, font.getStringWidth(" 0 "),
55
myLineHeight, items, "Set bank: ",
56
font.getStringWidth("Set bank: "), kBankChanged);
57
myBank->setTarget(this);
58
addFocusWidget(myBank);
60
// Raw SWCHA value (this will be broken down further in other UI elements)
61
int lwidth = font.getStringWidth("Current column: ");
62
ypos += myLineHeight + 8;
63
new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, myFontHeight,
64
"Current SWCHA: ", kTextAlignLeft);
66
mySWCHA = new ToggleBitWidget(boss, font, xpos, ypos, 8, 1);
67
mySWCHA->setTarget(this);
68
mySWCHA->setEditable(false);
70
// Current column number
71
xpos = 10; ypos += myLineHeight + 5;
72
new StaticTextWidget(boss, font, xpos, ypos, lwidth,
73
myFontHeight, "Current column: ", kTextAlignLeft);
76
myColumn = new DataGridWidget(boss, font, xpos, ypos-2, 1, 1, 2, 8, kBASE_16);
77
myColumn->setTarget(this);
78
myColumn->setEditable(false);
80
// Relevant pins of SWCHA
84
ypos += myLineHeight + 8;
85
myIncrease = new CheckboxWidget(boss, font, xpos, ypos, "Increase Column");
86
myIncrease->setTarget(this);
87
myIncrease->setEditable(false);
89
int orig_ypos = ypos; // save for when we go to the next column
92
ypos += myLineHeight + 4;
93
myReset = new CheckboxWidget(boss, font, xpos, ypos, "Reset Column");
94
myReset->setTarget(this);
95
myReset->setEditable(false);
98
ypos += myLineHeight + 4;
99
myRow[0] = new CheckboxWidget(boss, font, xpos, ypos, "Row 0");
100
myRow[0]->setTarget(this);
101
myRow[0]->setEditable(false);
102
ypos += myLineHeight + 4;
103
myRow[1] = new CheckboxWidget(boss, font, xpos, ypos, "Row 1");
104
myRow[1]->setTarget(this);
105
myRow[1]->setEditable(false);
106
ypos += myLineHeight + 4;
107
myRow[2] = new CheckboxWidget(boss, font, xpos, ypos, "Row 2");
108
myRow[2]->setTarget(this);
109
myRow[2]->setEditable(false);
110
ypos += myLineHeight + 4;
111
myRow[3] = new CheckboxWidget(boss, font, xpos, ypos, "Row 3");
112
myRow[3]->setTarget(this);
113
myRow[3]->setEditable(false);
115
// Func and Shift keys
116
ypos += myLineHeight + 4;
117
myFunc = new CheckboxWidget(boss, font, xpos, ypos, "FUNC key pressed");
118
myFunc->setTarget(this);
119
myFunc->setEditable(false);
120
ypos += myLineHeight + 4;
121
myShift = new CheckboxWidget(boss, font, xpos, ypos, "Shift key pressed");
122
myShift->setTarget(this);
123
myShift->setEditable(false);
125
// Move to next column
126
xpos += myShift->getWidth() + 20; ypos = orig_ypos;
129
myAudIn = new CheckboxWidget(boss, font, xpos, ypos, "Audio Input");
130
myAudIn->setTarget(this);
131
myAudIn->setEditable(false);
134
ypos += myLineHeight + 4;
135
myAudOut = new CheckboxWidget(boss, font, xpos, ypos, "Audio Output");
136
myAudOut->setTarget(this);
137
myAudOut->setEditable(false);
139
// Ram state (combination of several bits in SWCHA)
140
ypos += myLineHeight + 8;
141
lwidth = font.getStringWidth("Ram State: ");
142
new StaticTextWidget(boss, font, xpos, ypos, lwidth,
143
myFontHeight, "Ram State: ", kTextAlignLeft);
144
myRAM = new EditTextWidget(boss, font, xpos+lwidth, ypos-1,
145
font.getStringWidth(" Write-only "), myLineHeight, "");
146
myRAM->setEditable(false);
149
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
150
void CartridgeCMWidget::saveOldState()
152
myOldState.swcha = myCart.mySWCHA;
153
myOldState.column = myCart.myColumn;
156
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
157
void CartridgeCMWidget::loadConfig()
159
myBank->setSelected(myCart.myCurrentBank);
161
RiotDebug& riot = Debugger::debugger().riotDebug();
162
const RiotState& state = (RiotState&) riot.getState();
164
uInt8 swcha = myCart.mySWCHA;
167
BoolArray oldbits, newbits, changed;
168
Debugger::set_bits(myOldState.swcha, oldbits);
169
Debugger::set_bits(swcha, newbits);
171
for(uInt32 i = 0; i < oldbits.size(); ++i)
172
changed.push_back(oldbits[i] != newbits[i]);
173
mySWCHA->setState(newbits, changed);
176
myColumn->setList(0, myCart.myColumn, myCart.myColumn != myOldState.column);
178
// Various bits from SWCHA and INPTx
179
myIncrease->setState(swcha & 0x40);
180
myReset->setState(swcha & 0x20);
181
myRow[0]->setState(!(state.INPT4 & 0x80));
182
myRow[1]->setState(!(swcha & 0x04));
183
myRow[2]->setState(!(state.INPT5 & 0x80));
184
myRow[3]->setState(!(swcha & 0x08));
185
myFunc->setState(state.INPT0 & 0x80);
186
myShift->setState(state.INPT3 & 0x80);
188
// Audio in and out (used for communicating with the external cassette)
189
myAudIn->setState(swcha & 0x80);
190
myAudOut->setState(swcha & 0x40);
192
// RAM state (several bits from SWCHA)
193
const string& ram = swcha & 0x10 ? " Inactive" :
194
swcha & 0x20 ? " Read-only" : " Write-only";
195
myRAM->setText(ram, (swcha & 0x30) != (myOldState.swcha & 0x30));
197
CartDebugWidget::loadConfig();
200
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
201
void CartridgeCMWidget::handleCommand(CommandSender* sender,
202
int cmd, int data, int id)
204
if(cmd == kBankChanged)
207
myCart.mySWCHA &= 0xFC;
208
myCart.mySWCHA |= myBank->getSelected();
209
myCart.bank(myCart.mySWCHA & 0x03);
215
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
216
string CartridgeCMWidget::bankState()
218
ostringstream& buf = buffer();
220
buf << "Bank = " << myCart.myCurrentBank
221
<< ", RAM is" << (myCart.mySWCHA & 0x10 ? " Inactive" :
222
myCart.mySWCHA & 0x20 ? " Read-only" : " Write-only");