1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//============================================================================
//
// 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-2007 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Console.hxx,v 1.61 2007/07/27 13:49:16 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
#define CONSOLE_HXX
class Console;
class Controller;
class Event;
class MediaSource;
class Switches;
class System;
#include "m6502/src/bspf/src/bspf.hxx"
#include "Control.hxx"
#include "Props.hxx"
#include "TIA.hxx"
#include "Cart.hxx"
#include "M6532.hxx"
#include "AtariVox.hxx"
/**
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.61 2007/07/27 13:49:16 stephena Exp $
*/
class Console
{
public:
/**
Create a new console for emulating the specified game using the
given game image and operating system.
@param osystem The OSystem object to use
@param cart The cartridge to use with this console
@param props The properties for the cartridge
*/
Console(OSystem* osystem, Cartridge* cart, const Properties& props);
/**
Create a new console object by copying another one
@param console The object to copy
*/
Console(const Console& console);
/**
Destructor
*/
virtual ~Console();
public:
/**
Get the controller plugged into the specified jack
@return The specified controller
*/
Controller& controller(Controller::Jack jack) const
{
return (jack == Controller::Left) ? *myControllers[0] : *myControllers[1];
}
/**
Get the MediaSource for this console
@return The mediasource
*/
MediaSource& mediaSource() const { return *myMediaSource; }
/**
Get the properties being used by the game
@return The properties being used by the game
*/
const Properties& properties() const { return myProperties; }
/**
Get the console switches
@return The console switches
*/
Switches& switches() const { return *mySwitches; }
/**
Get the 6502 based system used by the console to emulate the game
@return The 6502 based system
*/
System& system() const { return *mySystem; }
/**
Returns the OSystem for this emulator.
@return The OSystem.
*/
OSystem& osystem() const { return *myOSystem; }
/**
Get the cartridge used by the console which contains the ROM code
@return The cartridge for this console
*/
Cartridge& cartridge() const { return *myCart; }
/**
Get the 6532 used by the console
@return The 6532 for this console
*/
M6532& riot() const { return *myRiot; }
/**
Set the properties to those given
@param The properties to use for the current game
*/
void setProperties(const Properties& props);
/**
Query some information about this console.
*/
const std::string& about() const { return myAboutString; }
public:
/**
Overloaded assignment operator
@param console The console object to set myself equal to
@return Myself after assignment has taken place
*/
Console& operator = (const Console& console);
public:
/**
Toggle between NTSC/PAL/PAL60 display format.
*/
void toggleFormat();
/**
Query the currently selected display format (NTSC/PAL/PAL60).
*/
std::string getFormat() const { return myDisplayFormat; }
/**
Toggle between the available palettes.
*/
void togglePalette();
/**
Toggles phosphor effect.
*/
void togglePhosphor();
/**
Initialize the video subsystem wrt this class.
This is required for changing window size, title, etc.
@param full Whether we want a full initialization,
or only reset certain attributes.
*/
void initializeVideo(bool full = true);
/**
Initialize the audio subsystem wrt this class.
This is required any time the sound settings change.
*/
void initializeAudio();
/**
"Fry" the Atari (mangle memory/TIA contents)
*/
void fry() const;
/**
Change the "Display.YStart" variable.
@param direction +1 indicates increase, -1 indicates decrease.
*/
void changeYStart(int direction);
/**
Change the "Display.Height" variable.
@param direction +1 indicates increase, -1 indicates decrease.
*/
void changeHeight(int direction);
/**
Toggles the TIA bit specified in the method name.
*/
void toggleP0Bit() const { toggleTIABit(TIA::P0, "P0"); }
void toggleP1Bit() const { toggleTIABit(TIA::P1, "P1"); }
void toggleM0Bit() const { toggleTIABit(TIA::M0, "M0"); }
void toggleM1Bit() const { toggleTIABit(TIA::M1, "M1"); }
void toggleBLBit() const { toggleTIABit(TIA::BL, "BL"); }
void togglePFBit() const { toggleTIABit(TIA::PF, "PF"); }
void enableBits(bool enable) const;
#ifdef ATARIVOX_SUPPORT
AtariVox *atariVox() { return vox; }
#endif
private:
void toggleTIABit(TIA::TIABit bit, const std::string& bitname, bool show = true) const;
/**
Returns the framerate based on a number of factors
(whether 'framerate' is set, what display format is in use, etc)
*/
uInt32 getFrameRate() const;
private:
// Pointer to the osystem object
OSystem* myOSystem;
// Pointers to the left and right controllers
Controller* myControllers[2];
// Pointer to the event object to use
Event* myEvent;
// Pointer to the media source object
MediaSource* myMediaSource;
// Properties for the game
Properties myProperties;
// Pointer to the switches on the front of the console
Switches* mySwitches;
// Pointer to the 6502 based system being emulated
System* mySystem;
// Pointer to the Cartridge (the debugger needs it)
Cartridge *myCart;
// Pointer to the 6532 (aka RIOT) (the debugger needs it)
// A RIOT of my own! (...with apologies to The Clash...)
M6532 *myRiot;
#ifdef ATARIVOX_SUPPORT
AtariVox *vox;
#endif
// The currently defined display format (NTSC/PAL/PAL60)
std::string myDisplayFormat;
// Indicates whether an external palette was found and
// successfully loaded
bool myUserPaletteDefined;
// Contains info about this console in string format
std::string myAboutString;
};
#endif