1 //============================================================================
2 //
3 //   SSSS    tt          lll  lll
4 //  SS  SS   tt           ll   ll
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
10 //
11 // Copyright (c) 1995-2014 by Bradford W. Mott, Stephen Anthony
12 // and the Stella Team
13 //
14 // See the file "License.txt" for information on usage and redistribution of
15 // this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 //
17 // $Id: Console.cxx 2838 2014-01-17 23:34:03Z stephena $
18 //============================================================================
19 
20 #include <cassert>
21 #include <iostream>
22 #include <sstream>
23 #include <fstream>
24 
25 #include "AtariVox.hxx"
26 #include "Booster.hxx"
27 #include "Cart.hxx"
28 #include "Control.hxx"
29 #include "Cart.hxx"
30 #include "Driving.hxx"
31 #include "Event.hxx"
32 #include "EventHandler.hxx"
33 #include "Joystick.hxx"
34 #include "Keyboard.hxx"
35 #include "KidVid.hxx"
36 #include "Genesis.hxx"
37 #include "MindLink.hxx"
38 #include "CompuMate.hxx"
39 #include "M6502.hxx"
40 #include "M6532.hxx"
41 #include "Paddles.hxx"
42 #include "Props.hxx"
43 #include "PropsSet.hxx"
44 #include "SaveKey.hxx"
45 #include "Settings.hxx"
46 #include "Sound.hxx"
47 #include "Switches.hxx"
48 #include "System.hxx"
49 #include "TIA.hxx"
50 #include "TrackBall.hxx"
51 #include "FrameBuffer.hxx"
52 #include "OSystem.hxx"
53 //#include "Menu.hxx"
54 //#include "CommandMenu.hxx"
55 #include "Serializable.hxx"
56 #include "Version.hxx"
57 
58 #ifdef DEBUGGER_SUPPORT
59   #include "Debugger.hxx"
60 #endif
61 
62 #ifdef CHEATCODE_SUPPORT
63   #include "CheatManager.hxx"
64 #endif
65 
66 #if defined(XBGR8888)
67 #define R_SHIFT 0
68 #define G_SHIFT 8
69 #define B_SHIFT 16
70 #else
71 #define R_SHIFT 16
72 #define G_SHIFT 8
73 #define B_SHIFT 0
74 #endif
75 
76 #include "Console.hxx"
77 
78 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console(OSystem * osystem,Cartridge * cart,const Properties & props)79 Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
80   : myOSystem(osystem),
81     myEvent(osystem->eventHandler().event()),
82     myProperties(props),
83     myTIA(0),
84     mySwitches(0),
85     mySystem(0),
86     myCart(cart),
87     myCMHandler(0),
88     myDisplayFormat(""),  // Unknown TV format @ start
89     myFramerate(0.0),     // Unknown framerate @ start
90     myCurrentFormat(0),   // Unknown format @ start
91     myUserPaletteDefined(false)
92 {
93   // Load user-defined palette for this ROM
94   loadUserPalette();
95 
96   // Create switches for the console
97   mySwitches = new Switches(myEvent, myProperties);
98 
99   // Construct the system and components
100   mySystem = new System(13, 6);
101 
102   // The real controllers for this console will be added later
103   // For now, we just add dummy joystick controllers, since autodetection
104   // runs the emulation for a while, and this may interfere with 'smart'
105   // controllers such as the AVox and SaveKey
106   // Note that the controllers must be added directly after the system
107   // has been created, and before any other device is added
108   // (particularly the M6532)
109   myControllers[0] = new Joystick(Controller::Left, myEvent, *mySystem);
110   myControllers[1] = new Joystick(Controller::Right, myEvent, *mySystem);
111 
112   M6502* m6502 = new M6502(1, myOSystem->settings());
113 
114   myRiot = new M6532(*this, myOSystem->settings());
115   myTIA  = new TIA(*this, myOSystem->sound(), myOSystem->settings());
116 
117   mySystem->attach(m6502);
118   mySystem->attach(myRiot);
119   mySystem->attach(myTIA);
120   mySystem->attach(myCart);
121 
122   // Auto-detect NTSC/PAL mode if it's requested
123   string autodetected = "";
124   myDisplayFormat = myProperties.get(Display_Format);
125   if(myDisplayFormat == "AUTO" || myOSystem->settings().getBool("rominfo"))
126   {
127     // Run the TIA, looking for PAL scanline patterns
128     // We turn off the SuperCharger progress bars, otherwise the SC BIOS
129     // will take over 250 frames!
130     // The 'fastscbios' option must be changed before the system is reset
131     bool fastscbios = myOSystem->settings().getBool("fastscbios");
132     myOSystem->settings().setValue("fastscbios", true);
133     mySystem->reset(true);  // autodetect in reset enabled
134     for(int i = 0; i < 60; ++i)
135       myTIA->update();
136     myDisplayFormat = myTIA->isPAL() ? "PAL" : "NTSC";
137     if(myProperties.get(Display_Format) == "AUTO")
138     {
139       autodetected = "*";
140       myCurrentFormat = 0;
141     }
142 
143     // Don't forget to reset the SC progress bars again
144     myOSystem->settings().setValue("fastscbios", fastscbios);
145   }
146   myConsoleInfo.DisplayFormat = myDisplayFormat + autodetected;
147 
148   // Set up the correct properties used when toggling format
149   // Note that this can be overridden if a format is forced
150   //   For example, if a PAL ROM is forced to be NTSC, it will use NTSC-like
151   //   properties (60Hz, 262 scanlines, etc), but likely result in flicker
152   // The TIA will self-adjust the framerate if necessary
153   setTIAProperties();
154   if(myDisplayFormat == "NTSC")         myCurrentFormat = 1;
155   else if(myDisplayFormat == "PAL")     myCurrentFormat = 2;
156   else if(myDisplayFormat == "SECAM")   myCurrentFormat = 3;
157   else if(myDisplayFormat == "NTSC50")  myCurrentFormat = 4;
158   else if(myDisplayFormat == "PAL60")   myCurrentFormat = 5;
159   else if(myDisplayFormat == "SECAM60") myCurrentFormat = 6;
160 
161   // Add the real controllers for this system
162   // This must be done before the debugger is initialized
163   const string& md5 = myProperties.get(Cartridge_MD5);
164   setControllers(md5);
165 
166   // Bumper Bash always requires all 4 directions
167   // Other ROMs can use it if the setting is enabled
168   bool joyallow4 = md5 == "aa1c41f86ec44c0a44eb64c332ce08af" ||
169                    md5 == "1bf503c724001b09be79c515ecfcbd03" ||
170                    myOSystem->settings().getBool("joyallow4");
171   myOSystem->eventHandler().allowAllDirections(joyallow4);
172 
173   // Reset the system to its power-on state
174   mySystem->reset();
175 
176   // Finally, add remaining info about the console
177   myConsoleInfo.CartName   = myProperties.get(Cartridge_Name);
178   myConsoleInfo.CartMD5    = myProperties.get(Cartridge_MD5);
179   myConsoleInfo.Control0   = myControllers[0]->about();
180   myConsoleInfo.Control1   = myControllers[1]->about();
181   myConsoleInfo.BankSwitch = cart->about();
182 
183   myCart->setRomName(myConsoleInfo.CartName);
184 }
185 
186 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
~Console()187 Console::~Console()
188 {
189   delete mySystem;
190   delete mySwitches;
191   delete myCMHandler;
192   delete myControllers[0];
193   delete myControllers[1];
194 }
195 
196 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
save(Serializer & out) const197 bool Console::save(Serializer& out) const
198 {
199   try
200   {
201     // First save state for the system
202     if(!mySystem->save(out))
203       return false;
204 
205     // Now save the console controllers and switches
206     if(!(myControllers[0]->save(out) && myControllers[1]->save(out) &&
207          mySwitches->save(out)))
208       return false;
209   }
210   catch(...)
211   {
212     cerr << "ERROR: Console::save" << endl;
213     return false;
214   }
215 
216   return true;  // success
217 }
218 
219 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
load(Serializer & in)220 bool Console::load(Serializer& in)
221 {
222   try
223   {
224     // First load state for the system
225     if(!mySystem->load(in))
226       return false;
227 
228     // Then load the console controllers and switches
229     if(!(myControllers[0]->load(in) && myControllers[1]->load(in) &&
230          mySwitches->load(in)))
231       return false;
232   }
233   catch(...)
234   {
235     cerr << "ERROR: Console::load" << endl;
236     return false;
237   }
238 
239   return true;  // success
240 }
241 
242 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleFormat(int direction)243 void Console::toggleFormat(int direction)
244 {
245   string saveformat, message;
246 
247   if(direction == 1)
248     myCurrentFormat = (myCurrentFormat + 1) % 7;
249   else if(direction == -1)
250     myCurrentFormat = myCurrentFormat > 0 ? (myCurrentFormat - 1) : 6;
251 
252   switch(myCurrentFormat)
253   {
254     case 0:  // auto-detect
255       myTIA->update();
256       myDisplayFormat = myTIA->isPAL() ? "PAL" : "NTSC";
257       message = "Auto-detect mode: " + myDisplayFormat;
258       saveformat = "AUTO";
259       break;
260     case 1:
261       saveformat = myDisplayFormat  = "NTSC";
262       message = "NTSC mode";
263       break;
264     case 2:
265       saveformat = myDisplayFormat  = "PAL";
266       message = "PAL mode";
267       break;
268     case 3:
269       saveformat = myDisplayFormat  = "SECAM";
270       message = "SECAM mode";
271       break;
272     case 4:
273       saveformat = myDisplayFormat  = "NTSC50";
274       message = "NTSC50 mode";
275       break;
276     case 5:
277       saveformat = myDisplayFormat  = "PAL60";
278       message = "PAL60 mode";
279       break;
280     case 6:
281       saveformat = myDisplayFormat  = "SECAM60";
282       message = "SECAM60 mode";
283       break;
284   }
285   myProperties.set(Display_Format, saveformat);
286 
287   setPalette(myOSystem->settings().getString("palette"));
288   setTIAProperties();
289   myTIA->frameReset();
290   initializeVideo();  // takes care of refreshing the screen
291 
292   myOSystem->frameBuffer().showMessage(message);
293 }
294 
295 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleColorLoss()296 void Console::toggleColorLoss()
297 {
298   bool colorloss = !myOSystem->settings().getBool("colorloss");
299   myOSystem->settings().setValue("colorloss", colorloss);
300   myTIA->enableColorLoss(colorloss);
301 
302   string message = string("PAL color-loss ") +
303                    (colorloss ? "enabled" : "disabled");
304   myOSystem->frameBuffer().showMessage(message);
305 }
306 
307 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleColorLoss(bool state)308 void Console::toggleColorLoss(bool state)
309 {
310   myTIA->enableColorLoss(state);
311 }
312 
313 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
togglePalette()314 void Console::togglePalette()
315 {
316   string palette, message;
317   palette = myOSystem->settings().getString("palette");
318 
319   if(palette == "standard")       // switch to z26
320   {
321     palette = "z26";
322     message = "Z26 palette";
323   }
324   else if(palette == "z26")       // switch to user or standard
325   {
326     // If we have a user-defined palette, it will come next in
327     // the sequence; otherwise loop back to the standard one
328     if(myUserPaletteDefined)
329     {
330       palette = "user";
331       message = "User-defined palette";
332     }
333     else
334     {
335       palette = "standard";
336       message = "Standard Stella palette";
337     }
338   }
339   else if(palette == "user")  // switch to standard
340   {
341     palette = "standard";
342     message = "Standard Stella palette";
343   }
344   else  // switch to standard mode if we get this far
345   {
346     palette = "standard";
347     message = "Standard Stella palette";
348   }
349 
350   myOSystem->settings().setValue("palette", palette);
351   myOSystem->frameBuffer().showMessage(message);
352 
353   setPalette(palette);
354 }
355 
356 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setPalette(const string & type)357 void Console::setPalette(const string& type)
358 {
359   // Look at all the palettes, since we don't know which one is
360   // currently active
361   uInt32* palettes[3][3] = {
362     { &ourNTSCPalette[0],    &ourPALPalette[0],    &ourSECAMPalette[0]    },
363     { &ourNTSCPaletteZ26[0], &ourPALPaletteZ26[0], &ourSECAMPaletteZ26[0] },
364     { 0, 0, 0 }
365   };
366   if(myUserPaletteDefined)
367   {
368     palettes[2][0] = &ourUserNTSCPalette[0];
369     palettes[2][1] = &ourUserPALPalette[0];
370     palettes[2][2] = &ourUserSECAMPalette[0];
371   }
372 
373   // See which format we should be using
374   int paletteNum = 0;
375   if(type == "standard")
376     paletteNum = 0;
377   else if(type == "z26")
378     paletteNum = 1;
379   else if(type == "user" && myUserPaletteDefined)
380     paletteNum = 2;
381 
382   // Now consider the current display format
383   currentPalette =
384     (myDisplayFormat.compare(0, 3, "PAL") == 0)   ? palettes[paletteNum][1] :
385     (myDisplayFormat.compare(0, 5, "SECAM") == 0) ? palettes[paletteNum][2] :
386      palettes[paletteNum][0];
387 
388   //myOSystem->frameBuffer().setTIAPalette(currentPalette);
389 }
390 
getPalette(int direction) const391 const uInt32* Console::getPalette(int direction) const
392 {
393 	return currentPalette;
394 }
395 
396 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
togglePhosphor()397 void Console::togglePhosphor()
398 {
399   const string& phosphor = myProperties.get(Display_Phosphor);
400   int blend = atoi(myProperties.get(Display_PPBlend).c_str());
401   bool enable;
402   if(phosphor == "YES")
403   {
404     myProperties.set(Display_Phosphor, "No");
405     enable = false;
406     myOSystem->frameBuffer().showMessage("Phosphor effect disabled");
407   }
408   else
409   {
410     myProperties.set(Display_Phosphor, "Yes");
411     enable = true;
412     myOSystem->frameBuffer().showMessage("Phosphor effect enabled");
413   }
414 
415   myOSystem->frameBuffer().enablePhosphor(enable, blend);
416 }
417 
418 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setProperties(const Properties & props)419 void Console::setProperties(const Properties& props)
420 {
421   myProperties = props;
422 }
423 
424 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
initializeVideo(bool full)425 FBInitStatus Console::initializeVideo(bool full)
426 {
427   FBInitStatus fbstatus = kSuccess;
428 
429   if(full)
430   {
431     const string& title = string("Stella ") + STELLA_VERSION +
432                    ": \"" + myProperties.get(Cartridge_Name) + "\"";
433     fbstatus = myOSystem->frameBuffer().initialize(title,
434                  myTIA->width() << 1, myTIA->height());
435     if(fbstatus != kSuccess)
436       return fbstatus;
437 
438     myOSystem->frameBuffer().showFrameStats(myOSystem->settings().getBool("stats"));
439     setColorLossPalette();
440   }
441 
442   bool enable = myProperties.get(Display_Phosphor) == "YES";
443   int blend = atoi(myProperties.get(Display_PPBlend).c_str());
444   myOSystem->frameBuffer().enablePhosphor(enable, blend);
445   setPalette(myOSystem->settings().getString("palette"));
446 
447   // Set the correct framerate based on the format of the ROM
448   // This can be overridden by changing the framerate in the
449   // VideoDialog box or on the commandline, but it can't be saved
450   // (ie, framerate is now determined based on number of scanlines).
451   //float framerate = myOSystem->settings().getFloat("framerate");
452   //if(framerate > 0) myFramerate = float(framerate);
453   myOSystem->setFramerate(myFramerate);
454 
455   // Make sure auto-frame calculation is only enabled when necessary
456   //myTIA->enableAutoFrame(framerate <= 0);
457 
458   return fbstatus;
459 }
460 
461 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
initializeAudio()462 void Console::initializeAudio()
463 {
464   // Initialize the sound interface.
465   // The # of channels can be overridden in the AudioDialog box or on
466   // the commandline, but it can't be saved.
467   //float framerate = myOSystem->settings().getFloat("framerate");
468   //if(framerate > 0) myFramerate = float(framerate);
469   const string& sound = myProperties.get(Cartridge_Sound);
470 
471   myOSystem->sound().close();
472   myOSystem->sound().setChannels(sound == "STEREO" ? 2 : 1);
473   myOSystem->sound().setFrameRate(myFramerate);
474   myOSystem->sound().open();
475 
476   // Make sure auto-frame calculation is only enabled when necessary
477   //myTIA->enableAutoFrame(framerate <= 0);
478 }
479 
480 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
481 /* Original frying research and code by Fred Quimby.
482    I've tried the following variations on this code:
483    - Both OR and Exclusive OR instead of AND. This generally crashes the game
484      without ever giving us realistic "fried" effects.
485    - Loop only over the RIOT RAM. This still gave us frying-like effects, but
486      it seemed harder to duplicate most effects. I have no idea why, but
487      munging the TIA regs seems to have some effect (I'd think it wouldn't).
488 
489    Fred says he also tried mangling the PC and registers, but usually it'd just
490    crash the game (e.g. black screen, no way out of it).
491 
492    It's definitely easier to get some effects (e.g. 255 lives in Battlezone)
493    with this code than it is on a real console. My guess is that most "good"
494    frying effects come from a RIOT location getting cleared to 0. Fred's
495    code is more likely to accomplish this than frying a real console is...
496 
497    Until someone comes up with a more accurate way to emulate frying, I'm
498    leaving this as Fred posted it.   -- B.
499 */
fry() const500 void Console::fry() const
501 {
502   for (int ZPmem=0; ZPmem<0x100; ZPmem += rand() % 4)
503     mySystem->poke(ZPmem, mySystem->peek(ZPmem) & (uInt8)rand() % 256);
504 }
505 
506 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
changeYStart(int direction)507 void Console::changeYStart(int direction)
508 {
509   uInt32 ystart = myTIA->ystart();
510 
511   if(direction == +1)       // increase YStart
512   {
513     if(ystart >= 64)
514     {
515       myOSystem->frameBuffer().showMessage("YStart at maximum");
516       return;
517     }
518     ystart++;
519   }
520   else if(direction == -1)  // decrease YStart
521   {
522     if(ystart == 0)
523     {
524       myOSystem->frameBuffer().showMessage("YStart at minimum");
525       return;
526     }
527     ystart--;
528   }
529   else
530     return;
531 
532   myTIA->setYStart(ystart);
533   myTIA->frameReset();
534   myOSystem->frameBuffer().refresh();
535 
536   ostringstream val;
537   val << ystart;
538   myOSystem->frameBuffer().showMessage("YStart " + val.str());
539   myProperties.set(Display_YStart, val.str());
540 }
541 
542 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
changeHeight(int direction)543 void Console::changeHeight(int direction)
544 {
545   uInt32 height = myTIA->height();
546 
547   if(direction == +1)       // increase Height
548   {
549     height++;
550     if(height > 256 || height > myOSystem->desktopHeight())
551     {
552       myOSystem->frameBuffer().showMessage("Height at maximum");
553       return;
554     }
555   }
556   else if(direction == -1)  // decrease Height
557   {
558     height--;
559     if(height < 210)
560     {
561       myOSystem->frameBuffer().showMessage("Height at minimum");
562       return;
563     }
564   }
565   else
566     return;
567 
568   myTIA->setHeight(height);
569   myTIA->frameReset();
570   initializeVideo();  // takes care of refreshing the screen
571 
572   ostringstream val;
573   val << height;
574   myOSystem->frameBuffer().showMessage("Height " + val.str());
575   myProperties.set(Display_Height, val.str());
576 }
577 
578 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setTIAProperties()579 void Console::setTIAProperties()
580 {
581   // TODO - query these values directly from the TIA if value is 'AUTO'
582   uInt32 ystart = atoi(myProperties.get(Display_YStart).c_str());
583   if(ystart > 64) ystart = 64;
584   uInt32 height = atoi(myProperties.get(Display_Height).c_str());
585   if(height < 210)      height = 210;
586   else if(height > 256) height = 256;
587 
588   if(myDisplayFormat == "NTSC" || myDisplayFormat == "PAL60" ||
589      myDisplayFormat == "SECAM60")
590   {
591     // Assume we've got ~262 scanlines (NTSC-like format)
592     //myFramerate = 60.0;
593     myFramerate = 59.92;
594     myConsoleInfo.InitialFrameRate = "60";
595   }
596   else
597   {
598     // Assume we've got ~312 scanlines (PAL-like format)
599     //myFramerate = 50.0;
600     myFramerate = 49.92;
601     myConsoleInfo.InitialFrameRate = "50";
602 
603     // PAL ROMs normally need at least 250 lines
604     height = MAX(height, 250u);
605   }
606 
607   // Make sure these values fit within the bounds of the desktop
608   // If not, attempt to center vertically
609   if(height > myOSystem->desktopHeight())
610   {
611     ystart += height - myOSystem->desktopHeight();
612     ystart  = MIN(ystart, 64u);
613     height  = myOSystem->desktopHeight();
614   }
615   myTIA->setYStart(ystart);
616   myTIA->setHeight(height);
617 }
618 
619 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setControllers(const string & rommd5)620 void Console::setControllers(const string& rommd5)
621 {
622   delete myControllers[0];
623   delete myControllers[1];
624 
625   // Setup the controllers based on properties
626   const string& left  = myProperties.get(Controller_Left);
627   const string& right = myProperties.get(Controller_Right);
628 
629   // Check for CompuMate controllers; they are special in that a handler
630   // creates them for us, and also that they must be used in both ports
631   if(left == "COMPUMATE" || right == "COMPUMATE")
632   {
633     delete myCMHandler;
634     myCMHandler = new CompuMate(*((CartridgeCM*)myCart), myEvent, *mySystem);
635     myControllers[0] = myCMHandler->leftController();
636     myControllers[1] = myCMHandler->rightController();
637     return;
638   }
639 
640   // Swap the ports if necessary
641   int leftPort, rightPort;
642   if(myProperties.get(Console_SwapPorts) == "NO")
643   {
644     leftPort = 0; rightPort = 1;
645   }
646   else
647   {
648     leftPort = 1; rightPort = 0;
649   }
650 
651   // Also check if we should swap the paddles plugged into a jack
652   bool swapPaddles = myProperties.get(Controller_SwapPaddles) == "YES";
653 
654   // Construct left controller
655   if(left == "BOOSTERGRIP")
656   {
657     myControllers[leftPort] = new BoosterGrip(Controller::Left, myEvent, *mySystem);
658   }
659   else if(left == "DRIVING")
660   {
661     myControllers[leftPort] = new Driving(Controller::Left, myEvent, *mySystem);
662   }
663   else if((left == "KEYBOARD") || (left == "KEYPAD"))
664   {
665     myControllers[leftPort] = new Keyboard(Controller::Left, myEvent, *mySystem);
666   }
667   else if(BSPF_startsWithIgnoreCase(left, "PADDLES"))
668   {
669     bool swapAxis = false, swapDir = false;
670     if(left == "PADDLES_IAXIS")
671       swapAxis = true;
672     else if(left == "PADDLES_IDIR")
673       swapDir = true;
674     else if(left == "PADDLES_IAXDR")
675       swapAxis = swapDir = true;
676     myControllers[leftPort] =
677       new Paddles(Controller::Left, myEvent, *mySystem,
678                   swapPaddles, swapAxis, swapDir);
679   }
680   else if(left == "TRACKBALL22")
681   {
682     myControllers[leftPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
683                                             Controller::TrackBall22);
684   }
685   else if(left == "TRACKBALL80")
686   {
687     myControllers[leftPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
688                                             Controller::TrackBall80);
689   }
690   else if(left == "AMIGAMOUSE")
691   {
692     myControllers[leftPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
693                                             Controller::AmigaMouse);
694   }
695   else if(left == "GENESIS")
696   {
697     myControllers[leftPort] = new Genesis(Controller::Left, myEvent, *mySystem);
698   }
699   else if(left == "MINDLINK")
700   {
701     myControllers[leftPort] = new MindLink(Controller::Left, myEvent, *mySystem);
702   }
703   else
704   {
705     myControllers[leftPort] = new Joystick(Controller::Left, myEvent, *mySystem);
706   }
707 
708   // Construct right controller
709   if(right == "BOOSTERGRIP")
710   {
711     myControllers[rightPort] = new BoosterGrip(Controller::Right, myEvent, *mySystem);
712   }
713   else if(right == "DRIVING")
714   {
715     myControllers[rightPort] = new Driving(Controller::Right, myEvent, *mySystem);
716   }
717   else if((right == "KEYBOARD") || (right == "KEYPAD"))
718   {
719     myControllers[rightPort] = new Keyboard(Controller::Right, myEvent, *mySystem);
720   }
721   else if(BSPF_startsWithIgnoreCase(right, "PADDLES"))
722   {
723     bool swapAxis = false, swapDir = false;
724     if(right == "PADDLES_IAXIS")
725       swapAxis = true;
726     else if(right == "PADDLES_IDIR")
727       swapDir = true;
728     else if(right == "PADDLES_IAXDR")
729       swapAxis = swapDir = true;
730     myControllers[rightPort] =
731       new Paddles(Controller::Right, myEvent, *mySystem,
732                   swapPaddles, swapAxis, swapDir);
733   }
734   else if(right == "TRACKBALL22")
735   {
736     myControllers[rightPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
737                                              Controller::TrackBall22);
738   }
739   else if(right == "TRACKBALL80")
740   {
741     myControllers[rightPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
742                                              Controller::TrackBall80);
743   }
744   else if(right == "AMIGAMOUSE")
745   {
746     myControllers[rightPort] = new TrackBall(Controller::Left, myEvent, *mySystem,
747                                              Controller::AmigaMouse);
748   }
749   else if(right == "ATARIVOX")
750   {
751     const string& nvramfile = myOSystem->nvramDir() + "atarivox_eeprom.dat";
752     myControllers[rightPort] = new AtariVox(Controller::Right, myEvent,
753                    *mySystem, myOSystem->serialPort(),
754                    myOSystem->settings().getString("avoxport"), nvramfile);
755   }
756   else if(right == "SAVEKEY")
757   {
758     const string& nvramfile = myOSystem->nvramDir() + "savekey_eeprom.dat";
759     myControllers[rightPort] = new SaveKey(Controller::Right, myEvent, *mySystem,
760                                            nvramfile);
761   }
762   else if(right == "GENESIS")
763   {
764     myControllers[rightPort] = new Genesis(Controller::Right, myEvent, *mySystem);
765   }
766   else if(right == "KIDVID")
767   {
768     myControllers[rightPort] = new KidVid(Controller::Right, myEvent, *mySystem, rommd5);
769   }
770   else if(right == "MINDLINK")
771   {
772     myControllers[rightPort] = new MindLink(Controller::Right, myEvent, *mySystem);
773   }
774   else
775   {
776     myControllers[rightPort] = new Joystick(Controller::Right, myEvent, *mySystem);
777   }
778 }
779 
780 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
loadUserPalette()781 void Console::loadUserPalette()
782 {
783   const string& palette = myOSystem->paletteFile();
784   ifstream in(palette.c_str(), ios::binary);
785   if(!in)
786     return;
787 
788   // Make sure the contains enough data for the NTSC, PAL and SECAM palettes
789   // This means 128 colours each for NTSC and PAL, at 3 bytes per pixel
790   // and 8 colours for SECAM at 3 bytes per pixel
791   in.seekg(0, ios::end);
792   streampos length = in.tellg();
793   in.seekg(0, ios::beg);
794   if(length < 128 * 3 * 2 + 8 * 3)
795   {
796     in.close();
797     cerr << "ERROR: invalid palette file " << palette << endl;
798     return;
799   }
800 
801   // Now that we have valid data, create the user-defined palettes
802   uInt8 pixbuf[3];  // Temporary buffer for one 24-bit pixel
803 
804   for(int i = 0; i < 128; i++)  // NTSC palette
805   {
806     in.read((char*)pixbuf, 3);
807     uInt32 pixel = ((int)pixbuf[0] << R_SHIFT) + ((int)pixbuf[1] << G_SHIFT) + (int)pixbuf[2] << B_SHIFT;
808     ourUserNTSCPalette[(i<<1)] = pixel;
809   }
810   for(int i = 0; i < 128; i++)  // PAL palette
811   {
812     in.read((char*)pixbuf, 3);
813     uInt32 pixel = ((int)pixbuf[0] << R_SHIFT) + ((int)pixbuf[1] << G_SHIFT) + (int)pixbuf[2] << B_SHIFT;
814     ourUserPALPalette[(i<<1)] = pixel;
815   }
816 
817   uInt32 secam[16];  // All 8 24-bit pixels, plus 8 colorloss pixels
818   for(int i = 0; i < 8; i++)    // SECAM palette
819   {
820     in.read((char*)pixbuf, 3);
821     uInt32 pixel = ((int)pixbuf[0] << R_SHIFT) + ((int)pixbuf[1] << G_SHIFT) + (int)pixbuf[2] << B_SHIFT;
822     secam[(i<<1)]   = pixel;
823     secam[(i<<1)+1] = 0;
824   }
825   uInt32* ptr = ourUserSECAMPalette;
826   for(int i = 0; i < 16; ++i)
827   {
828     uInt32* s = secam;
829     for(int j = 0; j < 16; ++j)
830       *ptr++ = *s++;
831   }
832 
833   in.close();
834   myUserPaletteDefined = true;
835 }
836 
837 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setColorLossPalette()838 void Console::setColorLossPalette()
839 {
840   // Look at all the palettes, since we don't know which one is
841   // currently active
842   uInt32* palette[9] = {
843     &ourNTSCPalette[0],    &ourPALPalette[0],    &ourSECAMPalette[0],
844     &ourNTSCPaletteZ26[0], &ourPALPaletteZ26[0], &ourSECAMPaletteZ26[0],
845     0, 0, 0
846   };
847   if(myUserPaletteDefined)
848   {
849     palette[6] = &ourUserNTSCPalette[0];
850     palette[7] = &ourUserPALPalette[0];
851     palette[8] = &ourUserSECAMPalette[0];
852   }
853 
854   for(int i = 0; i < 9; ++i)
855   {
856     if(palette[i] == 0)
857       continue;
858 
859     // Fill the odd numbered palette entries with gray values (calculated
860     // using the standard RGB -> grayscale conversion formula)
861     for(int j = 0; j < 128; ++j)
862     {
863       uInt32 pixel = palette[i][(j<<1)];
864       uInt8 r = (pixel >> R_SHIFT) & 0xff;
865       uInt8 g = (pixel >> G_SHIFT)  & 0xff;
866       uInt8 b = (pixel >> B_SHIFT)  & 0xff;
867       uInt8 sum = (uInt8) (((float)r * 0.2989) +
868                            ((float)g * 0.5870) +
869                            ((float)b * 0.1140));
870       palette[i][(j<<1)+1] = (sum << 16) + (sum << 8) + sum;
871     }
872   }
873 }
874 
875 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setFramerate(float framerate)876 void Console::setFramerate(float framerate)
877 {
878   myFramerate = framerate;
879   myOSystem->setFramerate(framerate);
880   myOSystem->sound().setFrameRate(framerate);
881 }
882 
883 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleTIABit(TIABit bit,const string & bitname,bool show) const884 void Console::toggleTIABit(TIABit bit, const string& bitname, bool show) const
885 {
886   bool result = myTIA->toggleBit(bit);
887   string message = bitname + (result ? " enabled" : " disabled");
888   myOSystem->frameBuffer().showMessage(message);
889 }
890 
891 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleBits() const892 void Console::toggleBits() const
893 {
894   bool enabled = myTIA->toggleBits();
895   string message = string("TIA bits") + (enabled ? " enabled" : " disabled");
896   myOSystem->frameBuffer().showMessage(message);
897 }
898 
899 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleTIACollision(TIABit bit,const string & bitname,bool show) const900 void Console::toggleTIACollision(TIABit bit, const string& bitname, bool show) const
901 {
902   bool result = myTIA->toggleCollision(bit);
903   string message = bitname + (result ? " collision enabled" : " collision disabled");
904   myOSystem->frameBuffer().showMessage(message);
905 }
906 
907 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleCollisions() const908 void Console::toggleCollisions() const
909 {
910   bool enabled = myTIA->toggleCollisions();
911   string message = string("TIA collisions") + (enabled ? " enabled" : " disabled");
912   myOSystem->frameBuffer().showMessage(message);
913 }
914 
915 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleHMOVE() const916 void Console::toggleHMOVE() const
917 {
918   if(myTIA->toggleHMOVEBlank())
919     myOSystem->frameBuffer().showMessage("HMOVE blanking enabled");
920   else
921     myOSystem->frameBuffer().showMessage("HMOVE blanking disabled");
922 }
923 
924 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
toggleFixedColors() const925 void Console::toggleFixedColors() const
926 {
927   if(myTIA->toggleFixedColors())
928     myOSystem->frameBuffer().showMessage("Fixed debug colors enabled");
929   else
930     myOSystem->frameBuffer().showMessage("Fixed debug colors disabled");
931 }
932 
933 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addDebugger()934 void Console::addDebugger()
935 {
936 #ifdef DEBUGGER_SUPPORT
937   myOSystem->createDebugger(*this);
938   mySystem->m6502().attach(myOSystem->debugger());
939 #endif
940 }
941 
942 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
stateChanged(EventHandler::State state)943 void Console::stateChanged(EventHandler::State state)
944 {
945   // For now, only the CompuMate cares about state changes
946   if(myCMHandler)
947     myCMHandler->enableKeyHandling(state == EventHandler::S_EMULATE);
948 }
949 
950 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
951 uInt32 Console::ourNTSCPalette[256] = {
952 #if defined(XBGR8888)
953   0x000000, 0, 0x4a4a4a, 0, 0x6f6f6f, 0, 0x8e8e8e, 0,
954   0xaaaaaa, 0, 0xc0c0c0, 0, 0xd6d6d6, 0, 0xececec, 0,
955   0x004848, 0, 0x0f6969, 0, 0x1d8686, 0, 0x2aa2a2, 0,
956   0x35bbbb, 0, 0x40d2d2, 0, 0x4ae8e8, 0, 0x54fcfc, 0,
957   0x002c7c, 0, 0x114890, 0, 0x2162a2, 0, 0x307ab4, 0,
958   0x3d90c3, 0, 0x4aa4d2, 0, 0x55b7df, 0, 0x60c8ec, 0,
959   0x001c90, 0, 0x1539a3, 0, 0x2853b5, 0, 0x3a6cc6, 0,
960   0x4a82d5, 0, 0x5997e3, 0, 0x67aaf0, 0, 0x74bcfc, 0,
961   0x000094, 0, 0x1a1aa7, 0, 0x3232b8, 0, 0x4848c8, 0,
962   0x5c5cd6, 0, 0x6f6fe4, 0, 0x8080f0, 0, 0x9090fc, 0,
963   0x640084, 0, 0x7a1997, 0, 0x8f30a8, 0, 0xa246b8, 0,
964   0xb359c6, 0, 0xc36cd4, 0, 0xd27ce0, 0, 0xe08cec, 0,
965   0x840050, 0, 0x9a1968, 0, 0xad307d, 0, 0xc04692, 0,
966   0xd059a4, 0, 0xe06cb5, 0, 0xee7cc5, 0, 0xfc8cd4, 0,
967   0x900014, 0, 0xa31a33, 0, 0xb5324e, 0, 0xc64868, 0,
968   0xd55c7f, 0, 0xe36f95, 0, 0xf080a9, 0, 0xfc90bc, 0,
969   0x940000, 0, 0xa71a18, 0, 0xb8322d, 0, 0xc84842, 0,
970   0xd65c54, 0, 0xe46f65, 0, 0xf08075, 0, 0xfc9084, 0,
971   0x881c00, 0, 0x9d3b18, 0, 0xb0572d, 0, 0xc27242, 0,
972   0xd28a54, 0, 0xe1a065, 0, 0xefb575, 0, 0xfcc884, 0,
973   0x643000, 0, 0x805018, 0, 0x986d2d, 0, 0xb08842, 0,
974   0xc5a054, 0, 0xd9b765, 0, 0xebcc75, 0, 0xfce084, 0,
975   0x304000, 0, 0x4e6218, 0, 0x69812d, 0, 0x829e42, 0,
976   0x99b854, 0, 0xaed165, 0, 0xc2e775, 0, 0xd4fc84, 0,
977   0x004400, 0, 0x1a661a, 0, 0x328432, 0, 0x48a048, 0,
978   0x5cba5c, 0, 0x6fd26f, 0, 0x80e880, 0, 0x90fc90, 0,
979   0x003c14, 0, 0x185f35, 0, 0x2d7e52, 0, 0x429c6e, 0,
980   0x54b787, 0, 0x65d09e, 0, 0x75e7b4, 0, 0x84fcc8, 0,
981   0x003830, 0, 0x165950, 0, 0x2b766d, 0, 0x3e9288, 0,
982   0x4faba0, 0, 0x5fc2b7, 0, 0x6ed8cc, 0, 0x7cece0, 0,
983   0x002c48, 0, 0x144d69, 0, 0x266a86, 0, 0x3886a2, 0,
984   0x479fbb, 0, 0x56b6d2, 0, 0x63cce8, 0, 0x70e0fc, 0
985 #else
986   0x000000, 0, 0x4a4a4a, 0, 0x6f6f6f, 0, 0x8e8e8e, 0,
987   0xaaaaaa, 0, 0xc0c0c0, 0, 0xd6d6d6, 0, 0xececec, 0,
988   0x484800, 0, 0x69690f, 0, 0x86861d, 0, 0xa2a22a, 0,
989   0xbbbb35, 0, 0xd2d240, 0, 0xe8e84a, 0, 0xfcfc54, 0,
990   0x7c2c00, 0, 0x904811, 0, 0xa26221, 0, 0xb47a30, 0,
991   0xc3903d, 0, 0xd2a44a, 0, 0xdfb755, 0, 0xecc860, 0,
992   0x901c00, 0, 0xa33915, 0, 0xb55328, 0, 0xc66c3a, 0,
993   0xd5824a, 0, 0xe39759, 0, 0xf0aa67, 0, 0xfcbc74, 0,
994   0x940000, 0, 0xa71a1a, 0, 0xb83232, 0, 0xc84848, 0,
995   0xd65c5c, 0, 0xe46f6f, 0, 0xf08080, 0, 0xfc9090, 0,
996   0x840064, 0, 0x97197a, 0, 0xa8308f, 0, 0xb846a2, 0,
997   0xc659b3, 0, 0xd46cc3, 0, 0xe07cd2, 0, 0xec8ce0, 0,
998   0x500084, 0, 0x68199a, 0, 0x7d30ad, 0, 0x9246c0, 0,
999   0xa459d0, 0, 0xb56ce0, 0, 0xc57cee, 0, 0xd48cfc, 0,
1000   0x140090, 0, 0x331aa3, 0, 0x4e32b5, 0, 0x6848c6, 0,
1001   0x7f5cd5, 0, 0x956fe3, 0, 0xa980f0, 0, 0xbc90fc, 0,
1002   0x000094, 0, 0x181aa7, 0, 0x2d32b8, 0, 0x4248c8, 0,
1003   0x545cd6, 0, 0x656fe4, 0, 0x7580f0, 0, 0x8490fc, 0,
1004   0x001c88, 0, 0x183b9d, 0, 0x2d57b0, 0, 0x4272c2, 0,
1005   0x548ad2, 0, 0x65a0e1, 0, 0x75b5ef, 0, 0x84c8fc, 0,
1006   0x003064, 0, 0x185080, 0, 0x2d6d98, 0, 0x4288b0, 0,
1007   0x54a0c5, 0, 0x65b7d9, 0, 0x75cceb, 0, 0x84e0fc, 0,
1008   0x004030, 0, 0x18624e, 0, 0x2d8169, 0, 0x429e82, 0,
1009   0x54b899, 0, 0x65d1ae, 0, 0x75e7c2, 0, 0x84fcd4, 0,
1010   0x004400, 0, 0x1a661a, 0, 0x328432, 0, 0x48a048, 0,
1011   0x5cba5c, 0, 0x6fd26f, 0, 0x80e880, 0, 0x90fc90, 0,
1012   0x143c00, 0, 0x355f18, 0, 0x527e2d, 0, 0x6e9c42, 0,
1013   0x87b754, 0, 0x9ed065, 0, 0xb4e775, 0, 0xc8fc84, 0,
1014   0x303800, 0, 0x505916, 0, 0x6d762b, 0, 0x88923e, 0,
1015   0xa0ab4f, 0, 0xb7c25f, 0, 0xccd86e, 0, 0xe0ec7c, 0,
1016   0x482c00, 0, 0x694d14, 0, 0x866a26, 0, 0xa28638, 0,
1017   0xbb9f47, 0, 0xd2b656, 0, 0xe8cc63, 0, 0xfce070, 0
1018 #endif
1019 };
1020 
1021 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1022 uInt32 Console::ourPALPalette[256] = {
1023 #if defined(XBGR8888)
1024   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1025   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0,
1026   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1027   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0,
1028   0x005880, 0, 0x1a7196, 0, 0x3287ab, 0, 0x489cbe, 0,
1029   0x5cafcf, 0, 0x6fc0df, 0, 0x80d1ee, 0, 0x90e0fc, 0,
1030   0x005c44, 0, 0x1a795e, 0, 0x329376, 0, 0x48ac8c, 0,
1031   0x5cc2a0, 0, 0x6fd7b3, 0, 0x80eac4, 0, 0x90fcd4, 0,
1032   0x003470, 0, 0x1a5189, 0, 0x326ba0, 0, 0x4884b6, 0,
1033   0x5c9ac9, 0, 0x6fafdc, 0, 0x80c2ec, 0, 0x90d4fc, 0,
1034   0x146400, 0, 0x35801a, 0, 0x529832, 0, 0x6eb048, 0,
1035   0x87c55c, 0, 0x9ed96f, 0, 0xb4eb80, 0, 0xc8fc90, 0,
1036   0x140070, 0, 0x351a89, 0, 0x5232a0, 0, 0x6e48b6, 0,
1037   0x875cc9, 0, 0x9e6fdc, 0, 0xb480ec, 0, 0xc890fc, 0,
1038   0x5c5c00, 0, 0x76761a, 0, 0x8e8e32, 0, 0xa4a448, 0,
1039   0xb8b85c, 0, 0xcbcb6f, 0, 0xdcdc80, 0, 0xecec90, 0,
1040   0x5c0070, 0, 0x741a84, 0, 0x893296, 0, 0x9e48a8, 0,
1041   0xb05cb7, 0, 0xc16fc6, 0, 0xd180d3, 0, 0xe090e0, 0,
1042   0x703c00, 0, 0x895a19, 0, 0xa0752f, 0, 0xb68e44, 0,
1043   0xc9a557, 0, 0xdcba68, 0, 0xecce79, 0, 0xfce088, 0,
1044   0x700058, 0, 0x891a6e, 0, 0xa03283, 0, 0xb64896, 0,
1045   0xc95ca7, 0, 0xdc6fb7, 0, 0xec80c6, 0, 0xfc90d4, 0,
1046   0x702000, 0, 0x893f19, 0, 0xa05a2f, 0, 0xb67444, 0,
1047   0xc98b57, 0, 0xdca168, 0, 0xecb579, 0, 0xfcc888, 0,
1048   0x800034, 0, 0x961a4a, 0, 0xab325f, 0, 0xbe4872, 0,
1049   0xcf5c83, 0, 0xdf6f93, 0, 0xee80a2, 0, 0xfc90b0, 0,
1050   0x880000, 0, 0x9d1a1a, 0, 0xb03232, 0, 0xc24848, 0,
1051   0xd25c5c, 0, 0xe16f6f, 0, 0xef8080, 0, 0xfc9090, 0,
1052   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1053   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0,
1054   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1055   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0
1056 #else
1057   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1058   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0,
1059   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1060   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0,
1061   0x805800, 0, 0x96711a, 0, 0xab8732, 0, 0xbe9c48, 0,
1062   0xcfaf5c, 0, 0xdfc06f, 0, 0xeed180, 0, 0xfce090, 0,
1063   0x445c00, 0, 0x5e791a, 0, 0x769332, 0, 0x8cac48, 0,
1064   0xa0c25c, 0, 0xb3d76f, 0, 0xc4ea80, 0, 0xd4fc90, 0,
1065   0x703400, 0, 0x89511a, 0, 0xa06b32, 0, 0xb68448, 0,
1066   0xc99a5c, 0, 0xdcaf6f, 0, 0xecc280, 0, 0xfcd490, 0,
1067   0x006414, 0, 0x1a8035, 0, 0x329852, 0, 0x48b06e, 0,
1068   0x5cc587, 0, 0x6fd99e, 0, 0x80ebb4, 0, 0x90fcc8, 0,
1069   0x700014, 0, 0x891a35, 0, 0xa03252, 0, 0xb6486e, 0,
1070   0xc95c87, 0, 0xdc6f9e, 0, 0xec80b4, 0, 0xfc90c8, 0,
1071   0x005c5c, 0, 0x1a7676, 0, 0x328e8e, 0, 0x48a4a4, 0,
1072   0x5cb8b8, 0, 0x6fcbcb, 0, 0x80dcdc, 0, 0x90ecec, 0,
1073   0x70005c, 0, 0x841a74, 0, 0x963289, 0, 0xa8489e, 0,
1074   0xb75cb0, 0, 0xc66fc1, 0, 0xd380d1, 0, 0xe090e0, 0,
1075   0x003c70, 0, 0x195a89, 0, 0x2f75a0, 0, 0x448eb6, 0,
1076   0x57a5c9, 0, 0x68badc, 0, 0x79ceec, 0, 0x88e0fc, 0,
1077   0x580070, 0, 0x6e1a89, 0, 0x8332a0, 0, 0x9648b6, 0,
1078   0xa75cc9, 0, 0xb76fdc, 0, 0xc680ec, 0, 0xd490fc, 0,
1079   0x002070, 0, 0x193f89, 0, 0x2f5aa0, 0, 0x4474b6, 0,
1080   0x578bc9, 0, 0x68a1dc, 0, 0x79b5ec, 0, 0x88c8fc, 0,
1081   0x340080, 0, 0x4a1a96, 0, 0x5f32ab, 0, 0x7248be, 0,
1082   0x835ccf, 0, 0x936fdf, 0, 0xa280ee, 0, 0xb090fc, 0,
1083   0x000088, 0, 0x1a1a9d, 0, 0x3232b0, 0, 0x4848c2, 0,
1084   0x5c5cd2, 0, 0x6f6fe1, 0, 0x8080ef, 0, 0x9090fc, 0,
1085   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1086   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0,
1087   0x000000, 0, 0x2b2b2b, 0, 0x525252, 0, 0x767676, 0,
1088   0x979797, 0, 0xb6b6b6, 0, 0xd2d2d2, 0, 0xececec, 0
1089 #endif
1090 };
1091 
1092 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1093 uInt32 Console::ourSECAMPalette[256] = {
1094 #if defined(XBGR8888)
1095   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1096   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1097   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1098   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1099   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1100   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1101   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1102   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1103   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1104   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1105   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1106   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1107   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1108   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1109   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1110   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1111   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1112   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1113   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1114   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1115   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1116   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1117   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1118   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1119   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1120   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1121   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1122   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1123   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1124   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1125   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff50ff, 0,
1126   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0
1127 #else
1128   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1129   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1130   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1131   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1132   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1133   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1134   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1135   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1136   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1137   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1138   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1139   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1140   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1141   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1142   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1143   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1144   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1145   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1146   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1147   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1148   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1149   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1150   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1151   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1152   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1153   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1154   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1155   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1156   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1157   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1158   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff50ff, 0,
1159   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0
1160 #endif
1161 };
1162 
1163 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1164 uInt32 Console::ourNTSCPaletteZ26[256] = {
1165 #if defined(XBGR8888)
1166   0x000000, 0, 0x505050, 0, 0x646464, 0, 0x787878, 0,
1167   0x8c8c8c, 0, 0xa0a0a0, 0, 0xb4b4b4, 0, 0xc8c8c8, 0,
1168   0x005444, 0, 0x006858, 0, 0x007c6c, 0, 0x009080, 0,
1169   0x14a494, 0, 0x28b8a8, 0, 0x3cccbc, 0, 0x50e0d0, 0,
1170   0x003967, 0, 0x004d7b, 0, 0x00618f, 0, 0x1375a3, 0,
1171   0x2789b7, 0, 0x3b9dcb, 0, 0x4fb1df, 0, 0x63c5f3, 0,
1172   0x04257b, 0, 0x18398f, 0, 0x2c4da3, 0, 0x4061b7, 0,
1173   0x5475cb, 0, 0x6889df, 0, 0x7c9df3, 0, 0x90b1ff, 0,
1174   0x2c127d, 0, 0x402691, 0, 0x543aa5, 0, 0x684eb9, 0,
1175   0x7c62cd, 0, 0x9076e1, 0, 0xa48af5, 0, 0xb89eff, 0,
1176   0x710873, 0, 0x851c87, 0, 0x99309b, 0, 0xad44af, 0,
1177   0xc158c3, 0, 0xd56cd7, 0, 0xe980eb, 0, 0xfd94ff, 0,
1178   0x920b5d, 0, 0xa61f71, 0, 0xba3385, 0, 0xce4799, 0,
1179   0xe25bad, 0, 0xf66fc1, 0, 0xff83d5, 0, 0xff97e9, 0,
1180   0x991540, 0, 0xad2954, 0, 0xc13d68, 0, 0xd5517c, 0,
1181   0xe96590, 0, 0xfd79a4, 0, 0xff8db8, 0, 0xffa1cc, 0,
1182   0x932525, 0, 0xa73939, 0, 0xbb4d4d, 0, 0xcf6161, 0,
1183   0xe37575, 0, 0xf78989, 0, 0xff9d9d, 0, 0xffb1b1, 0,
1184   0x80340f, 0, 0x944823, 0, 0xa85c37, 0, 0xbc704b, 0,
1185   0xd0845f, 0, 0xe49873, 0, 0xf8ac87, 0, 0xffc09b, 0,
1186   0x5a4204, 0, 0x6e5618, 0, 0x826a2c, 0, 0x967e40, 0,
1187   0xaa9254, 0, 0xbea668, 0, 0xd2ba7c, 0, 0xe6ce90, 0,
1188   0x304f04, 0, 0x446318, 0, 0x58772c, 0, 0x6c8b40, 0,
1189   0x809f54, 0, 0x94b368, 0, 0xa8c77c, 0, 0xbcdb90, 0,
1190   0x0a550f, 0, 0x1e6923, 0, 0x327d37, 0, 0x46914b, 0,
1191   0x5aa55f, 0, 0x6eb973, 0, 0x82cd87, 0, 0x96e19b, 0,
1192   0x00511f, 0, 0x056533, 0, 0x197947, 0, 0x2d8d5b, 0,
1193   0x41a16f, 0, 0x55b583, 0, 0x69c997, 0, 0x7dddab, 0,
1194   0x004634, 0, 0x005a48, 0, 0x146e5c, 0, 0x288270, 0,
1195   0x3c9684, 0, 0x50aa98, 0, 0x64beac, 0, 0x78d2c0, 0,
1196   0x003e46, 0, 0x05525a, 0, 0x19666e, 0, 0x2d7a82, 0,
1197   0x418e96, 0, 0x55a2aa, 0, 0x69b6be, 0, 0x7dcad2, 0
1198 #else
1199   0x000000, 0, 0x505050, 0, 0x646464, 0, 0x787878, 0,
1200   0x8c8c8c, 0, 0xa0a0a0, 0, 0xb4b4b4, 0, 0xc8c8c8, 0,
1201   0x445400, 0, 0x586800, 0, 0x6c7c00, 0, 0x809000, 0,
1202   0x94a414, 0, 0xa8b828, 0, 0xbccc3c, 0, 0xd0e050, 0,
1203   0x673900, 0, 0x7b4d00, 0, 0x8f6100, 0, 0xa37513, 0,
1204   0xb78927, 0, 0xcb9d3b, 0, 0xdfb14f, 0, 0xf3c563, 0,
1205   0x7b2504, 0, 0x8f3918, 0, 0xa34d2c, 0, 0xb76140, 0,
1206   0xcb7554, 0, 0xdf8968, 0, 0xf39d7c, 0, 0xffb190, 0,
1207   0x7d122c, 0, 0x912640, 0, 0xa53a54, 0, 0xb94e68, 0,
1208   0xcd627c, 0, 0xe17690, 0, 0xf58aa4, 0, 0xff9eb8, 0,
1209   0x730871, 0, 0x871c85, 0, 0x9b3099, 0, 0xaf44ad, 0,
1210   0xc358c1, 0, 0xd76cd5, 0, 0xeb80e9, 0, 0xff94fd, 0,
1211   0x5d0b92, 0, 0x711fa6, 0, 0x8533ba, 0, 0x9947ce, 0,
1212   0xad5be2, 0, 0xc16ff6, 0, 0xd583ff, 0, 0xe997ff, 0,
1213   0x401599, 0, 0x5429ad, 0, 0x683dc1, 0, 0x7c51d5, 0,
1214   0x9065e9, 0, 0xa479fd, 0, 0xb88dff, 0, 0xcca1ff, 0,
1215   0x252593, 0, 0x3939a7, 0, 0x4d4dbb, 0, 0x6161cf, 0,
1216   0x7575e3, 0, 0x8989f7, 0, 0x9d9dff, 0, 0xb1b1ff, 0,
1217   0x0f3480, 0, 0x234894, 0, 0x375ca8, 0, 0x4b70bc, 0,
1218   0x5f84d0, 0, 0x7398e4, 0, 0x87acf8, 0, 0x9bc0ff, 0,
1219   0x04425a, 0, 0x18566e, 0, 0x2c6a82, 0, 0x407e96, 0,
1220   0x5492aa, 0, 0x68a6be, 0, 0x7cbad2, 0, 0x90cee6, 0,
1221   0x044f30, 0, 0x186344, 0, 0x2c7758, 0, 0x408b6c, 0,
1222   0x549f80, 0, 0x68b394, 0, 0x7cc7a8, 0, 0x90dbbc, 0,
1223   0x0f550a, 0, 0x23691e, 0, 0x377d32, 0, 0x4b9146, 0,
1224   0x5fa55a, 0, 0x73b96e, 0, 0x87cd82, 0, 0x9be196, 0,
1225   0x1f5100, 0, 0x336505, 0, 0x477919, 0, 0x5b8d2d, 0,
1226   0x6fa141, 0, 0x83b555, 0, 0x97c969, 0, 0xabdd7d, 0,
1227   0x344600, 0, 0x485a00, 0, 0x5c6e14, 0, 0x708228, 0,
1228   0x84963c, 0, 0x98aa50, 0, 0xacbe64, 0, 0xc0d278, 0,
1229   0x463e00, 0, 0x5a5205, 0, 0x6e6619, 0, 0x827a2d, 0,
1230   0x968e41, 0, 0xaaa255, 0, 0xbeb669, 0, 0xd2ca7d, 0
1231 #endif
1232 };
1233 
1234 
1235 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1236 uInt32 Console::ourPALPaletteZ26[256] = {
1237 #if defined(XBGR8888)
1238   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1239   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0,
1240   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1241   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0,
1242   0x003a53, 0, 0x004e67, 0, 0x03627b, 0, 0x17768f, 0,
1243   0x2b8aa3, 0, 0x3f9eb7, 0, 0x53b2cb, 0, 0x67c6df, 0,
1244   0x00581b, 0, 0x006c2f, 0, 0x018043, 0, 0x159457, 0,
1245   0x29a86b, 0, 0x3dbc7f, 0, 0x51d093, 0, 0x65e4a7, 0,
1246   0x00296a, 0, 0x123d7e, 0, 0x265192, 0, 0x3a65a6, 0,
1247   0x4e79ba, 0, 0x628dce, 0, 0x76a1e2, 0, 0x8ab5f6, 0,
1248   0x005b07, 0, 0x116f1b, 0, 0x25832f, 0, 0x399743, 0,
1249   0x4dab57, 0, 0x61bf6b, 0, 0x75d37f, 0, 0x89e793, 0,
1250   0x2f1b74, 0, 0x432f88, 0, 0x57439c, 0, 0x6b57b0, 0,
1251   0x7f6bc4, 0, 0x937fd8, 0, 0xa793ec, 0, 0xbba7ff, 0,
1252   0x2e5700, 0, 0x426b10, 0, 0x567f24, 0, 0x6a9338, 0,
1253   0x7ea74c, 0, 0x92bb60, 0, 0xa6cf74, 0, 0xbae388, 0,
1254   0x5f166d, 0, 0x732a81, 0, 0x873e95, 0, 0x9b52a9, 0,
1255   0xaf66bd, 0, 0xc37ad1, 0, 0xd78ee5, 0, 0xeba2f9, 0,
1256   0x5e4c01, 0, 0x726015, 0, 0x867429, 0, 0x9a883d, 0,
1257   0xae9c51, 0, 0xc2b065, 0, 0xd6c479, 0, 0xead88d, 0,
1258   0x88155f, 0, 0x9c2973, 0, 0xb03d87, 0, 0xc4519b, 0,
1259   0xd865af, 0, 0xec79c3, 0, 0xff8dd7, 0, 0xffa1eb, 0,
1260   0x873b12, 0, 0x9b4f26, 0, 0xaf633a, 0, 0xc3774e, 0,
1261   0xd78b62, 0, 0xeb9f76, 0, 0xffb38a, 0, 0xffc79e, 0,
1262   0x9d1e45, 0, 0xb13259, 0, 0xc5466d, 0, 0xd95a81, 0,
1263   0xed6e95, 0, 0xff82a9, 0, 0xff96bd, 0, 0xffaad1, 0,
1264   0x9e2b2a, 0, 0xb23f3e, 0, 0xc65352, 0, 0xda6766, 0,
1265   0xee7b7a, 0, 0xff8f8e, 0, 0xffa3a2, 0, 0xffb7b6, 0,
1266   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1267   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0,
1268   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1269   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0
1270 #else
1271   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1272   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0,
1273   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1274   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0,
1275   0x533a00, 0, 0x674e00, 0, 0x7b6203, 0, 0x8f7617, 0,
1276   0xa38a2b, 0, 0xb79e3f, 0, 0xcbb253, 0, 0xdfc667, 0,
1277   0x1b5800, 0, 0x2f6c00, 0, 0x438001, 0, 0x579415, 0,
1278   0x6ba829, 0, 0x7fbc3d, 0, 0x93d051, 0, 0xa7e465, 0,
1279   0x6a2900, 0, 0x7e3d12, 0, 0x925126, 0, 0xa6653a, 0,
1280   0xba794e, 0, 0xce8d62, 0, 0xe2a176, 0, 0xf6b58a, 0,
1281   0x075b00, 0, 0x1b6f11, 0, 0x2f8325, 0, 0x439739, 0,
1282   0x57ab4d, 0, 0x6bbf61, 0, 0x7fd375, 0, 0x93e789, 0,
1283   0x741b2f, 0, 0x882f43, 0, 0x9c4357, 0, 0xb0576b, 0,
1284   0xc46b7f, 0, 0xd87f93, 0, 0xec93a7, 0, 0xffa7bb, 0,
1285   0x00572e, 0, 0x106b42, 0, 0x247f56, 0, 0x38936a, 0,
1286   0x4ca77e, 0, 0x60bb92, 0, 0x74cfa6, 0, 0x88e3ba, 0,
1287   0x6d165f, 0, 0x812a73, 0, 0x953e87, 0, 0xa9529b, 0,
1288   0xbd66af, 0, 0xd17ac3, 0, 0xe58ed7, 0, 0xf9a2eb, 0,
1289   0x014c5e, 0, 0x156072, 0, 0x297486, 0, 0x3d889a, 0,
1290   0x519cae, 0, 0x65b0c2, 0, 0x79c4d6, 0, 0x8dd8ea, 0,
1291   0x5f1588, 0, 0x73299c, 0, 0x873db0, 0, 0x9b51c4, 0,
1292   0xaf65d8, 0, 0xc379ec, 0, 0xd78dff, 0, 0xeba1ff, 0,
1293   0x123b87, 0, 0x264f9b, 0, 0x3a63af, 0, 0x4e77c3, 0,
1294   0x628bd7, 0, 0x769feb, 0, 0x8ab3ff, 0, 0x9ec7ff, 0,
1295   0x451e9d, 0, 0x5932b1, 0, 0x6d46c5, 0, 0x815ad9, 0,
1296   0x956eed, 0, 0xa982ff, 0, 0xbd96ff, 0, 0xd1aaff, 0,
1297   0x2a2b9e, 0, 0x3e3fb2, 0, 0x5253c6, 0, 0x6667da, 0,
1298   0x7a7bee, 0, 0x8e8fff, 0, 0xa2a3ff, 0, 0xb6b7ff, 0,
1299   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1300   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0,
1301   0x000000, 0, 0x4c4c4c, 0, 0x606060, 0, 0x747474, 0,
1302   0x888888, 0, 0x9c9c9c, 0, 0xb0b0b0, 0, 0xc4c4c4, 0
1303   #endif
1304 };
1305 
1306 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1307 uInt32 Console::ourSECAMPaletteZ26[256] = {
1308 #if defined(XBGR8888)
1309   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1310   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1311   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1312   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1313   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1314   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1315   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1316   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1317   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1318   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1319   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1320   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1321   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1322   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1323   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1324   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1325   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1326   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1327   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1328   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1329   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1330   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1331   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1332   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1333   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1334   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1335   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1336   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1337   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1338   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0,
1339   0x000000, 0, 0xff2121, 0, 0x793cf0, 0, 0xff3cff, 0,
1340   0x00ff7f, 0, 0xffff7f, 0, 0x3fffff, 0, 0xffffff, 0
1341 #else
1342   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1343   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1344   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1345   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1346   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1347   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1348   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1349   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1350   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1351   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1352   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1353   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1354   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1355   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1356   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1357   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1358   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1359   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1360   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1361   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1362   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1363   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1364   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1365   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1366   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1367   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1368   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1369   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1370   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1371   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0,
1372   0x000000, 0, 0x2121ff, 0, 0xf03c79, 0, 0xff3cff, 0,
1373   0x7fff00, 0, 0x7fffff, 0, 0xffff3f, 0, 0xffffff, 0
1374 #endif
1375 };
1376 
1377 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1378 uInt32 Console::ourUserNTSCPalette[256]  = { 0 }; // filled from external file
1379 
1380 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1381 uInt32 Console::ourUserPALPalette[256]   = { 0 }; // filled from external file
1382 
1383 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1384 uInt32 Console::ourUserSECAMPalette[256] = { 0 }; // filled from external file
1385 
1386 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console(const Console & console)1387 Console::Console(const Console& console)
1388   : myOSystem(console.myOSystem),
1389     myEvent(console.myEvent)
1390 {
1391   assert(false);
1392 }
1393 
1394 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
operator =(const Console &)1395 Console& Console::operator = (const Console&)
1396 {
1397   assert(false);
1398 
1399   return *this;
1400 }
1401