Added the ability to dynamically switch which palette the emulator

uses to the SDL port.  Currently, the three choices are the current
Stella palette (standard), the palette from version 1.1 (original),
and the one from the z26 emulator (z26).

The '-palette <standard|original|z26>' option can be used from the
commandline, and Control-P can be used while within the emulator.

I haven't actually added the z26 palette yet, so when you switch to
that one, you get a blank screen.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@225 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-12-04 19:18:45 +00:00
parent eaa92d3faf
commit 083245cf9c
6 changed files with 217 additions and 20 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.cxx,v 1.21 2003-11-19 15:57:10 stephena Exp $ // $Id: Console.cxx,v 1.22 2003-12-04 19:18:45 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -283,7 +283,6 @@ Properties Console::ourDefaultProperties;
void Console::toggleFormat() void Console::toggleFormat()
{ {
string format = myProperties.get("Display.Format"); string format = myProperties.get("Display.Format");
string message;
if(format == "NTSC") if(format == "NTSC")
{ {
@ -297,6 +296,33 @@ void Console::toggleFormat()
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::togglePalette()
{
string type = mySettings.getString("palette");
if(type == "standard") // switch to original
{
myFrameBuffer.showMessage("Original Stella colors");
mySettings.setString("palette", "original");
}
else if(type == "original") // switch to z26
{
myFrameBuffer.showMessage("Z26 colors");
mySettings.setString("palette", "z26");
}
else if(type == "z26") // switch to standard
{
myFrameBuffer.showMessage("Standard Stella colors");
mySettings.setString("palette", "standard");
}
else // switch to standard mode if we get this far
{
myFrameBuffer.showMessage("Standard Stella colors");
mySettings.setString("palette", "standard");
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeXStart(const uInt32 direction) void Console::changeXStart(const uInt32 direction)
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.hxx,v 1.16 2003-11-19 15:57:10 stephena Exp $ // $Id: Console.hxx,v 1.17 2003-12-04 19:18:45 stephena Exp $
//============================================================================ //============================================================================
#ifndef CONSOLE_HXX #ifndef CONSOLE_HXX
@ -41,7 +41,7 @@ class FrameBuffer;
This class represents the entire game console. This class represents the entire game console.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Console.hxx,v 1.16 2003-11-19 15:57:10 stephena Exp $ @version $Id: Console.hxx,v 1.17 2003-12-04 19:18:45 stephena Exp $
*/ */
class Console class Console
{ {
@ -185,10 +185,17 @@ class Console
#ifdef DEVELOPER_SUPPORT #ifdef DEVELOPER_SUPPORT
public: public:
/** /**
Toggle between NTSC and PAL mode. The frontends may need to reload their palette. Toggle between NTSC and PAL mode. The frontends will need to
reload their palette.
*/ */
void toggleFormat(); void toggleFormat();
/**
Toggle between the available palettes. The frontends will need to
reload their palette.
*/
void togglePalette();
/** /**
Change the "Display.XStart" variable. Currently, a system reset is issued Change the "Display.XStart" variable. Currently, a system reset is issued
after the change. GUI's may need to resize their viewports. after the change. GUI's may need to resize their viewports.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Settings.cxx,v 1.14 2003-11-24 14:51:06 stephena Exp $ // $Id: Settings.cxx,v 1.15 2003-12-04 19:18:45 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -47,6 +47,7 @@ Settings::Settings()
set("showinfo", "false"); set("showinfo", "false");
set("mergeprops", "false"); set("mergeprops", "false");
set("paddle", "0"); set("paddle", "0");
set("palette", "standard");
#ifdef SNAPSHOT_SUPPORT #ifdef SNAPSHOT_SUPPORT
set("ssdir", ""); set("ssdir", "");

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.cxx,v 1.25 2003-10-26 19:40:39 stephena Exp $ // $Id: TIA.cxx,v 1.26 2003-12-04 19:18:45 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -28,6 +28,7 @@
#include "TIA.hxx" #include "TIA.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include "Settings.hxx"
#include "TIASound.h" #include "TIASound.h"
#define HBLANK 68 #define HBLANK 68
@ -568,15 +569,18 @@ void TIA::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32* TIA::palette() const const uInt32* TIA::palette() const
{ {
// See which palette we should be using based on properties // See which palette we should be using
if(myConsole.properties().get("Display.Format") == "PAL") string type = myConsole.settings().getString("palette");
{ string format = myConsole.properties().get("Display.Format");
return ourPALPalette;
} if(type == "standard")
else return (format == "PAL") ? ourPALPalette : ourNTSCPalette;
{ else if(type == "original")
return ourNTSCPalette; return (format == "PAL") ? ourPALPalette11 : ourNTSCPalette11;
} else if(type == "z26")
return (format == "PAL") ? ourPALPaletteZ26 : ourNTSCPaletteZ26;
else // return normal palette by default
return (format == "PAL") ? ourPALPalette : ourNTSCPalette;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -3083,6 +3087,148 @@ const uInt32 TIA::ourPALPalette[256] = {
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec 0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TIA::ourNTSCPalette11[256] = {
0x000000, 0x1c1c1c, 0x393939, 0x595959,
0x797979, 0x929292, 0xababab, 0xbcbcbc,
0xcdcdcd, 0xd9d9d9, 0xe6e6e6, 0xececec,
0xf2f2f2, 0xf8f8f8, 0xffffff, 0xffffff,
0x391701, 0x5e2304, 0x833008, 0xa54716,
0xc85f24, 0xe37820, 0xff911d, 0xffab1d,
0xffc51d, 0xffce34, 0xffd84c, 0xffe651,
0xfff456, 0xfff977, 0xffff98, 0xffff98,
0x451904, 0x721e11, 0x9f241e, 0xb33a20,
0xc85122, 0xe36920, 0xff811e, 0xff8c25,
0xff982c, 0xffae38, 0xffc545, 0xffc559,
0xffc66d, 0xffd587, 0xffe4a1, 0xffe4a1,
0x4a1704, 0x7e1a0d, 0xb21d17, 0xc82119,
0xdf251c, 0xec3b38, 0xfa5255, 0xfc6161,
0xff706e, 0xff7f7e, 0xff8f8f, 0xff9d9e,
0xffabad, 0xffb9bd, 0xffc7ce, 0xffc7ce,
0x050568, 0x3b136d, 0x712272, 0x8b2a8c,
0xa532a6, 0xb938ba, 0xcd3ecf, 0xdb47dd,
0xea51eb, 0xf45ff5, 0xfe6dff, 0xfe7afd,
0xff87fb, 0xff95fd, 0xffa4ff, 0xffa4ff,
0x280479, 0x400984, 0x590f90, 0x70249d,
0x8839aa, 0xa441c3, 0xc04adc, 0xd054ed,
0xe05eff, 0xe96dff, 0xf27cff, 0xf88aff,
0xff98ff, 0xfea1ff, 0xfeabff, 0xfeabff,
0x35088a, 0x420aad, 0x500cd0, 0x6428d0,
0x7945d0, 0x8d4bd4, 0xa251d9, 0xb058ec,
0xbe60ff, 0xc56bff, 0xcc77ff, 0xd183ff,
0xd790ff, 0xdb9dff, 0xdfaaff, 0xdfaaff,
0x051e81, 0x0626a5, 0x082fca, 0x263dd4,
0x444cde, 0x4f5aee, 0x5a68ff, 0x6575ff,
0x7183ff, 0x8091ff, 0x90a0ff, 0x97a9ff,
0x9fb2ff, 0xafbeff, 0xc0cbff, 0xc0cbff,
0x0c048b, 0x2218a0, 0x382db5, 0x483ec7,
0x584fda, 0x6159ec, 0x6b64ff, 0x7a74ff,
0x8a84ff, 0x918eff, 0x9998ff, 0xa5a3ff,
0xb1aeff, 0xb8b8ff, 0xc0c2ff, 0xc0c2ff,
0x1d295a, 0x1d3876, 0x1d4892, 0x1c5cac,
0x1c71c6, 0x3286cf, 0x489bd9, 0x4ea8ec,
0x55b6ff, 0x70c7ff, 0x8cd8ff, 0x93dbff,
0x9bdfff, 0xafe4ff, 0xc3e9ff, 0xc3e9ff,
0x2f4302, 0x395202, 0x446103, 0x417a12,
0x3e9421, 0x4a9f2e, 0x57ab3b, 0x5cbd55,
0x61d070, 0x69e27a, 0x72f584, 0x7cfa8d,
0x87ff97, 0x9affa6, 0xadffb6, 0xadffb6,
0x0a4108, 0x0d540a, 0x10680d, 0x137d0f,
0x169212, 0x19a514, 0x1cb917, 0x1ec919,
0x21d91b, 0x47e42d, 0x6ef040, 0x78f74d,
0x83ff5b, 0x9aff7a, 0xb2ff9a, 0xb2ff9a,
0x04410b, 0x05530e, 0x066611, 0x077714,
0x088817, 0x099b1a, 0x0baf1d, 0x48c41f,
0x86d922, 0x8fe924, 0x99f927, 0xa8fc41,
0xb7ff5b, 0xc9ff6e, 0xdcff81, 0xdcff81,
0x02350f, 0x073f15, 0x0c4a1c, 0x2d5f1e,
0x4f7420, 0x598324, 0x649228, 0x82a12e,
0xa1b034, 0xa9c13a, 0xb2d241, 0xc4d945,
0xd6e149, 0xe4f04e, 0xf2ff53, 0xf2ff53,
0x263001, 0x243803, 0x234005, 0x51541b,
0x806931, 0x978135, 0xaf993a, 0xc2a73e,
0xd5b543, 0xdbc03d, 0xe1cb38, 0xe2d836,
0xe3e534, 0xeff258, 0xfbff7d, 0xfbff7d,
0x401a02, 0x581f05, 0x702408, 0x8d3a13,
0xab511f, 0xb56427, 0xbf7730, 0xd0853a,
0xe19344, 0xeda04e, 0xf9ad58, 0xfcb75c,
0xffc160, 0xffc671, 0xffcb83, 0xffcb83
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TIA::ourPALPalette11[256] = {
0x000000, 0x000000, 0x242424, 0x242424,
0x484848, 0x484848, 0x6d6d6d, 0x6d6d6d,
0x919191, 0x919191, 0xb6b6b6, 0xb6b6b6,
0xdadada, 0xdadada, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x242424, 0x242424,
0x484848, 0x484848, 0x6d6d6d, 0x6d6d6d,
0x919191, 0x919191, 0xb6b6b6, 0xb6b6b6,
0xdadada, 0xdadada, 0xffffff, 0xffffff,
0x4a3700, 0x4a3700, 0x705813, 0x705813,
0x8c732a, 0x8c732a, 0xa68d46, 0xa68d46,
0xbea767, 0xbea767, 0xd4c18b, 0xd4c18b,
0xeadcb3, 0xeadcb3, 0xfff6de, 0xfff6de,
0x284a00, 0x284a00, 0x44700f, 0x44700f,
0x5c8c21, 0x5c8c21, 0x74a638, 0x74a638,
0x8cbe51, 0x8cbe51, 0xa6d46e, 0xa6d46e,
0xc0ea8e, 0xc0ea8e, 0xdbffb0, 0xdbffb0,
0x4a1300, 0x4a1300, 0x70280f, 0x70280f,
0x8c3d21, 0x8c3d21, 0xa65438, 0xa65438,
0xbe6d51, 0xbe6d51, 0xd4886e, 0xd4886e,
0xeaa58e, 0xeaa58e, 0xffc4b0, 0xffc4b0,
0x004a22, 0x004a22, 0x0f703b, 0x0f703b,
0x218c52, 0x218c52, 0x38a66a, 0x38a66a,
0x51be83, 0x51be83, 0x6ed49d, 0x6ed49d,
0x8eeab8, 0x8eeab8, 0xb0ffd4, 0xb0ffd4,
0x4a0028, 0x4a0028, 0x700f44, 0x700f44,
0x8c215c, 0x8c215c, 0xa63874, 0xa63874,
0xbe518c, 0xbe518c, 0xd46ea6, 0xd46ea6,
0xea8ec0, 0xea8ec0, 0xffb0db, 0xffb0db,
0x00404a, 0x00404a, 0x0f6370, 0x0f6370,
0x217e8c, 0x217e8c, 0x3897a6, 0x3897a6,
0x51afbe, 0x51afbe, 0x6ec7d4, 0x6ec7d4,
0x8edeea, 0x8edeea, 0xb0f4ff, 0xb0f4ff,
0x43002c, 0x43002c, 0x650f4b, 0x650f4b,
0x7e2165, 0x7e2165, 0x953880, 0x953880,
0xa6519a, 0xa6519a, 0xbf6eb7, 0xbf6eb7,
0xd38ed3, 0xd38ed3, 0xe5b0f1, 0xe5b0f1,
0x001d4a, 0x001d4a, 0x0f3870, 0x0f3870,
0x21538c, 0x21538c, 0x386ea6, 0x386ea6,
0x518dbe, 0x518dbe, 0x6ea8d4, 0x6ea8d4,
0x8ec8ea, 0x8ec8ea, 0xb0e9ff, 0xb0e9ff,
0x37004a, 0x37004a, 0x570f70, 0x570f70,
0x70218c, 0x70218c, 0x8938a6, 0x8938a6,
0xa151be, 0xa151be, 0xba6ed4, 0xba6ed4,
0xd28eea, 0xd28eea, 0xeab0ff, 0xeab0ff,
0x00184a, 0x00184a, 0x0f2e70, 0x0f2e70,
0x21448c, 0x21448c, 0x385ba6, 0x385ba6,
0x5174be, 0x5174be, 0x6e8fd4, 0x6e8fd4,
0x8eabea, 0x8eabea, 0xb0c9ff, 0xb0c9ff,
0x13004a, 0x13004a, 0x280f70, 0x280f70,
0x3d218c, 0x3d218c, 0x5438a6, 0x5438a6,
0x6d51be, 0x6d51be, 0x886ed4, 0x886ed4,
0xa58eea, 0xa58eea, 0xc4b0ff, 0xc4b0ff,
0x00014a, 0x00014a, 0x0f1170, 0x0f1170,
0x21248c, 0x21248c, 0x383aa6, 0x383aa6,
0x5153be, 0x5153be, 0x6e70d4, 0x6e70d4,
0x8e8fea, 0x8e8fea, 0xb0b2ff, 0xb0b2ff,
0x000000, 0x000000, 0x242424, 0x242424,
0x484848, 0x484848, 0x6d6d6d, 0x6d6d6d,
0x919191, 0x919191, 0xb6b6b6, 0xb6b6b6,
0xdadada, 0xdadada, 0xffffff, 0xffffff,
0x000000, 0x000000, 0x242424, 0x242424,
0x484848, 0x484848, 0x6d6d6d, 0x6d6d6d,
0x919191, 0x919191, 0xb6b6b6, 0xb6b6b6,
0xdadada, 0xdadada, 0xffffff, 0xffffff
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TIA::ourNTSCPaletteZ26[256] = { 0 }; // FIXME
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TIA::ourPALPaletteZ26[256] = { 0 }; // FIXME
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(const TIA& c) TIA::TIA(const TIA& c)
: myConsole(c.myConsole), : myConsole(c.myConsole),

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.hxx,v 1.10 2003-10-26 19:40:39 stephena Exp $ // $Id: TIA.hxx,v 1.11 2003-12-04 19:18:45 stephena Exp $
//============================================================================ //============================================================================
#ifndef TIA_HXX #ifndef TIA_HXX
@ -43,7 +43,7 @@ class Deserializer;
in a bounded queue. in a bounded queue.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: TIA.hxx,v 1.10 2003-10-26 19:40:39 stephena Exp $ @version $Id: TIA.hxx,v 1.11 2003-12-04 19:18:45 stephena Exp $
*/ */
class TIA : public Device , public MediaSource class TIA : public Device , public MediaSource
{ {
@ -539,6 +539,18 @@ class TIA : public Device , public MediaSource
// the PAL color loss effect. // the PAL color loss effect.
static const uInt32 ourPALPalette[256]; static const uInt32 ourPALPalette[256];
// Table of RGB values for NTSC - Stella 1.1 version
static const uInt32 ourNTSCPalette11[256];
// Table of RGB values for PAL - Stella 1.1 version
static const uInt32 ourPALPalette11[256];
// Table of RGB values for NTSC - Z26 version
static const uInt32 ourNTSCPaletteZ26[256];
// Table of RGB values for PAL - Z26 version
static const uInt32 ourPALPaletteZ26[256];
private: private:
// Copy constructor isn't supported by this class so make it private // Copy constructor isn't supported by this class so make it private
TIA(const TIA&); TIA(const TIA&);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainSDL.cxx,v 1.62 2003-11-30 03:36:51 stephena Exp $ // $Id: mainSDL.cxx,v 1.63 2003-12-04 19:18:45 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -391,6 +391,11 @@ void handleEvents()
theConsole->toggleFormat(); theConsole->toggleFormat();
theDisplay->setupPalette(1.0); theDisplay->setupPalette(1.0);
} }
else if(key == SDLK_p) // Ctrl-p toggles different palettes
{
theConsole->togglePalette();
theDisplay->setupPalette(1.0);
}
else if(key == SDLK_END) // Ctrl-End increases Width else if(key == SDLK_END) // Ctrl-End increases Width
{ {
theConsole->changeWidth(1); theConsole->changeWidth(1);