code cleanup and bug fixing

This commit is contained in:
thrust26 2020-05-11 10:47:43 +02:00
parent 5aa57decb5
commit 614e28375d
10 changed files with 193 additions and 159 deletions

View File

@ -491,8 +491,6 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
{Event::ToggleColorLoss, KBDK_L, KBDM_CTRL}, {Event::ToggleColorLoss, KBDK_L, KBDM_CTRL},
{Event::PaletteDecrease, KBDK_P, KBDM_SHIFT | KBDM_CTRL}, {Event::PaletteDecrease, KBDK_P, KBDM_SHIFT | KBDM_CTRL},
{Event::PaletteIncrease, KBDK_P, KBDM_CTRL}, {Event::PaletteIncrease, KBDK_P, KBDM_CTRL},
{Event::ColorShiftDecrease, KBDK_9, KBDM_SHIFT | KBDM_CTRL},
{Event::ColorShiftIncrease, KBDK_9, KBDM_CTRL},
{Event::ToggleInter, KBDK_I, KBDM_CTRL}, {Event::ToggleInter, KBDK_I, KBDM_CTRL},
{Event::ToggleTurbo, KBDK_T, KBDM_CTRL}, {Event::ToggleTurbo, KBDK_T, KBDM_CTRL},
{Event::ToggleJitter, KBDK_J, MOD3}, {Event::ToggleJitter, KBDK_J, MOD3},

View File

@ -54,19 +54,14 @@ string PaletteHandler::toPaletteName(PaletteType type) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaletteHandler::changePalette(bool increase) void PaletteHandler::cyclePalette(bool next)
{ {
const string MESSAGES[PaletteType::NumTypes] = { const string MESSAGES[PaletteType::NumTypes] = {
"Standard Stella", "Z26", "User-defined", "Custom" "Standard Stella", "Z26", "User-defined", "Custom"
}; };
string palette, message;
palette = myOSystem.settings().getString("palette");
int type = toPaletteType(myOSystem.settings().getString("palette")); int type = toPaletteType(myOSystem.settings().getString("palette"));
if(increase) if(next)
{ {
if(type == PaletteType::MaxType) if(type == PaletteType::MaxType)
type = PaletteType::Standard; type = PaletteType::Standard;
@ -87,8 +82,8 @@ void PaletteHandler::changePalette(bool increase)
type--; type--;
} }
palette = toPaletteName(PaletteType(type)); const string palette = toPaletteName(PaletteType(type));
message = MESSAGES[type] + " palette"; const string message = MESSAGES[type] + " palette";
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showMessage(message);
@ -96,9 +91,10 @@ void PaletteHandler::changePalette(bool increase)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaletteHandler::selectAdjustable(bool next) void PaletteHandler::cycleAdjustable(bool next)
{ {
const bool isCustomPalette = "custom" == myOSystem.settings().getString("palette"); const bool isCustomPalette = SETTING_CUSTOM == myOSystem.settings().getString("palette");
bool isPhaseShift;
do { do {
if(next) if(next)
@ -113,11 +109,19 @@ void PaletteHandler::selectAdjustable(bool next)
else else
myCurrentAdjustable--; myCurrentAdjustable--;
} }
} while(!isCustomPalette && myAdjustables[myCurrentAdjustable].value == nullptr); isPhaseShift = myAdjustables[myCurrentAdjustable].value == nullptr;
// skip phase shift when 'Custom' palette is not selected
} while(isPhaseShift && !isCustomPalette);
ostringstream buf; ostringstream buf;
buf << "Palette adjustable '" << myAdjustables[myCurrentAdjustable].type buf << "Palette adjustable '" << myAdjustables[myCurrentAdjustable].name
<< "' selected"; << "' selected (";
if(isPhaseShift)
buf << (myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC)
<< DEGREE << ")";
else
buf << scaleTo100(*myAdjustables[myCurrentAdjustable].value) << "%)";
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showMessage(buf.str());
} }
@ -129,25 +133,19 @@ void PaletteHandler::changeAdjustable(bool increase)
changeColorPhaseShift(increase); changeColorPhaseShift(increase);
else else
{ {
float newVal = (*myAdjustables[myCurrentAdjustable].value); int newVal = scaleTo100(*myAdjustables[myCurrentAdjustable].value);
if(increase) if(increase)
{ newVal += 2; // += 2%
newVal += 0.05F;
if(newVal > 1.0F)
newVal = 1.0F;
}
else else
{ newVal -= 2; // -= 2%
newVal -= 0.05F; newVal = BSPF::clamp(newVal, 0, 100);
if(newVal < -1.0F)
newVal = -1.0F; *myAdjustables[myCurrentAdjustable].value = scaleFrom100(newVal);
}
*myAdjustables[myCurrentAdjustable].value = newVal;
ostringstream buf; ostringstream buf;
buf << "Custom '" << myAdjustables[myCurrentAdjustable].type buf << "Custom '" << myAdjustables[myCurrentAdjustable].name
<< "' set to " << int((newVal + 1.0F) * 100.0F + 0.5F) << "%"; << "' set to " << newVal << "%";
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showMessage(buf.str());
setPalette(); setPalette();
@ -162,32 +160,27 @@ void PaletteHandler::changeColorPhaseShift(bool increase)
// SECAM is not supported // SECAM is not supported
if(timing != ConsoleTiming::secam) if(timing != ConsoleTiming::secam)
{ {
constexpr char DEGREE = 0x1c;
const bool isNTSC = timing == ConsoleTiming::ntsc; const bool isNTSC = timing == ConsoleTiming::ntsc;
const float shift = isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT; const float shift = isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT;
float phase = isNTSC ? myPhaseNTSC : myPhasePAL; float newPhase = isNTSC ? myPhaseNTSC : myPhasePAL;
if(increase) // increase color phase shift if(increase) // increase color phase shift
{ newPhase += 0.3F;
phase += 0.3F;
phase = std::min(phase, shift + MAX_SHIFT);
}
else // decrease color phase shift else // decrease color phase shift
{ newPhase -= 0.3F;
phase -= 0.3F; newPhase = BSPF::clamp(newPhase, shift - MAX_SHIFT, shift + MAX_SHIFT);
phase = std::max(phase, shift - MAX_SHIFT);
}
if(isNTSC) if(isNTSC)
myPhaseNTSC = phase; myPhaseNTSC = newPhase;
else else
myPhasePAL = phase; myPhasePAL = newPhase;
generateCustomPalette(timing); generateCustomPalette(timing);
setPalette("custom"); setPalette(SETTING_CUSTOM);
ostringstream ss; ostringstream ss;
ss << "Color phase shift at " ss << "Color phase shift at "
<< std::fixed << std::setprecision(1) << phase << DEGREE; << std::fixed << std::setprecision(1) << newPhase << DEGREE;
myOSystem.frameBuffer().showMessage(ss.str()); myOSystem.frameBuffer().showMessage(ss.str());
} }
@ -259,6 +252,8 @@ void PaletteHandler::setPalette(const string& name)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaletteHandler::setPalette() void PaletteHandler::setPalette()
{
if(myOSystem.hasConsole())
{ {
const string& name = myOSystem.settings().getString("palette"); const string& name = myOSystem.settings().getString("palette");
@ -279,11 +274,12 @@ void PaletteHandler::setPalette()
if(paletteType == PaletteType::Custom) if(paletteType == PaletteType::Custom)
generateCustomPalette(timing); generateCustomPalette(timing);
myOSystem.frameBuffer().setTIAPalette(adjustPalette(*palette)); myOSystem.frameBuffer().setTIAPalette(adjustedPalette(*palette));
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteArray PaletteHandler::adjustPalette(const PaletteArray& palette) PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
{ {
PaletteArray destPalette; PaletteArray destPalette;
// Constants for saturation and gray scale calculation // Constants for saturation and gray scale calculation
@ -387,15 +383,15 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing)
{ {
constexpr int NUM_CHROMA = 16; constexpr int NUM_CHROMA = 16;
constexpr int NUM_LUMA = 8; constexpr int NUM_LUMA = 8;
constexpr float SATURATION = 0.25F; constexpr float SATURATION = 0.25F; // default saturation
float color[NUM_CHROMA][2] = {{0.0F}}; float color[NUM_CHROMA][2] = {{0.0F}};
if(timing == ConsoleTiming::ntsc) if(timing == ConsoleTiming::ntsc)
{ {
// YIQ is YUV shifted by 33° // YIQ is YUV shifted by 33°
constexpr float offset = 33 * (2 * BSPF::PI_f / 360); constexpr float offset = 33 * BSPF::PI_f / 180;
const float shift = myPhaseNTSC * (2 * BSPF::PI_f / 360); const float shift = myPhaseNTSC * BSPF::PI_f / 180;
// color 0 is grayscale // color 0 is grayscale
for(int chroma = 1; chroma < NUM_CHROMA; chroma++) for(int chroma = 1; chroma < NUM_CHROMA; chroma++)
@ -425,13 +421,9 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing)
G = powf(G, 0.9F); G = powf(G, 0.9F);
B = powf(B, 0.9F); B = powf(B, 0.9F);
if(R > 1) R = 1; int r = BSPF::clamp(R * 255.F, 0.F, 255.F);
if(G > 1) G = 1; int g = BSPF::clamp(G * 255.F, 0.F, 255.F);
if(B > 1) B = 1; int b = BSPF::clamp(B * 255.F, 0.F, 255.F);
int r = R * 255.F;
int g = G * 255.F;
int b = B * 255.F;
ourCustomNTSCPalette[(chroma * NUM_LUMA + luma) << 1] = (r << 16) + (g << 8) + b; ourCustomNTSCPalette[(chroma * NUM_LUMA + luma) << 1] = (r << 16) + (g << 8) + b;
} }
@ -439,9 +431,9 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing)
} }
else if(timing == ConsoleTiming::pal) else if(timing == ConsoleTiming::pal)
{ {
constexpr float offset = 180 * (2 * BSPF::PI_f / 360); constexpr float offset = BSPF::PI_f;
const float shift = myPhasePAL * (2 * BSPF::PI_f / 360); const float shift = myPhasePAL * BSPF::PI_f / 180;
constexpr float fixedShift = 22.5F * (2 * BSPF::PI_f / 360); constexpr float fixedShift = 22.5F * BSPF::PI_f / 180;
// colors 0, 1, 14 and 15 are grayscale // colors 0, 1, 14 and 15 are grayscale
for(int chroma = 2; chroma < NUM_CHROMA - 2; chroma++) for(int chroma = 2; chroma < NUM_CHROMA - 2; chroma++)
@ -480,13 +472,9 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing)
G = powf(G, 1.2F); G = powf(G, 1.2F);
B = powf(B, 1.2F); B = powf(B, 1.2F);
if(R > 1) R = 1; int r = BSPF::clamp(R * 255.F, 0.F, 255.F);
if(G > 1) G = 1; int g = BSPF::clamp(G * 255.F, 0.F, 255.F);
if(B > 1) B = 1; int b = BSPF::clamp(B * 255.F, 0.F, 255.F);
int r = R * 255.F;
int g = G * 255.F;
int b = B * 255.F;
ourCustomPALPalette[(chroma * NUM_LUMA + luma) << 1] = (r << 16) + (g << 8) + b; ourCustomPALPalette[(chroma * NUM_LUMA + luma) << 1] = (r << 16) + (g << 8) + b;
} }

View File

@ -25,22 +25,18 @@
class PaletteHandler class PaletteHandler
{ {
public: public:
// Setting names of palette types
static constexpr const char* SETTING_STANDARD = "standard"; static constexpr const char* SETTING_STANDARD = "standard";
static constexpr const char* SETTING_Z26 = "z26"; static constexpr const char* SETTING_Z26 = "z26";
static constexpr const char* SETTING_USER = "user"; static constexpr const char* SETTING_USER = "user";
static constexpr const char* SETTING_CUSTOM = "custom"; static constexpr const char* SETTING_CUSTOM = "custom";
// Phase shift default and limits
static constexpr float DEF_NTSC_SHIFT = 26.2F; static constexpr float DEF_NTSC_SHIFT = 26.2F;
static constexpr float DEF_PAL_SHIFT = 31.3F; // 360 / 11.5 static constexpr float DEF_PAL_SHIFT = 31.3F; // ~= 360 / 11.5
static constexpr float MAX_SHIFT = 4.5F; static constexpr float MAX_SHIFT = 4.5F;
enum DisplayType { // Externally used adjustment parameters
NTSC,
PAL,
SECAM,
NumDisplayTypes
};
struct Adjustable { struct Adjustable {
float phaseNtsc, phasePal; float phaseNtsc, phasePal;
uInt32 hue, saturation, contrast, brightness, gamma; uInt32 hue, saturation, contrast, brightness, gamma;
@ -51,28 +47,38 @@ class PaletteHandler
virtual ~PaletteHandler() = default; virtual ~PaletteHandler() = default;
/** /**
Switch between the available palettes. Cycle through available palettes.
*/
void changePalette(bool increase = true);
void selectAdjustable(bool next = true); @param next Select next palette, else previous one
*/
void cyclePalette(bool next = true);
/*
Cycle through each palette adjustable
@param next Select next adjustable, else previous one
*/
void cycleAdjustable(bool next = true);
/*
Increase or decrease current palette adjustable
@param increase Increase adjustable if true, else decrease
*/
void changeAdjustable(bool increase = true); void changeAdjustable(bool increase = true);
// Load adjustables from settings
void loadConfig(const Settings& settings); void loadConfig(const Settings& settings);
// Save adjustables to settings
void saveConfig(Settings& settings) const; void saveConfig(Settings& settings) const;
// Set adjustables
void setAdjustables(const Adjustable& adjustable); void setAdjustables(const Adjustable& adjustable);
// Retrieve current adjustables
void getAdjustables(Adjustable& adjustable) const; void getAdjustables(Adjustable& adjustable) const;
/**
Change the "phase shift" variable.
Note that there are two of these (NTSC and PAL). The currently
active mode will determine which one is used.
@param increase increase if true, else decrease.
*/
void changeColorPhaseShift(bool increase = true);
/** /**
Sets the palette according to the given palette name. Sets the palette according to the given palette name.
@ -80,18 +86,14 @@ class PaletteHandler
*/ */
void setPalette(const string& name); void setPalette(const string& name);
/** /**
Sets the palette from current settings. Sets the palette from current settings.
*/ */
void setPalette(); void setPalette();
/**
Generates a custom palette, based on user defined phase shifts.
*/
void generateCustomPalette(ConsoleTiming timing);
private: private:
static constexpr char DEGREE = 0x1c;
enum PaletteType { enum PaletteType {
Standard, Standard,
Z26, Z26,
@ -102,14 +104,64 @@ class PaletteHandler
MaxType = Custom MaxType = Custom
}; };
/**
Convert adjustables from/to 100% scale
*/
float scaleFrom100(float x) const { return (x / 50.F) - 1.F; } float scaleFrom100(float x) const { return (x / 50.F) - 1.F; }
uInt32 scaleTo100(float x) const { return uInt32(50 * (x + 1.F)); } uInt32 scaleTo100(float x) const { return uInt32(50 * (x + 1.F)); }
/**
Convert palette settings name to enumeration
@param name The given palette's settings name
@return The palette type
*/
PaletteType toPaletteType(const string& name) const; PaletteType toPaletteType(const string& name) const;
/**
Convert enumeration to palette settings name
@param type The given palette type
@return The palette's settings name
*/
string toPaletteName(PaletteType type) const; string toPaletteName(PaletteType type) const;
PaletteArray adjustPalette(const PaletteArray& source); /**
Change the "phase shift" variable.
Note that there are two of these (NTSC and PAL). The currently
active mode will determine which one is used.
@param increase Increase if true, else decrease.
*/
void changeColorPhaseShift(bool increase = true);
/**
Generates a custom palette, based on user defined phase shifts.
@param timing Use NTSC or PAL phase shift and generate according palette
*/
void generateCustomPalette(ConsoleTiming timing);
/**
Create new palette by applying palette adjustments on given palette
@param type The palette which should be adjusted
@return An adjusted palette
*/
PaletteArray adjustedPalette(const PaletteArray& source);
/**
Adjust hue and saturation for given RGB values
@param R The red value to adjust
@param G The green value to adjust
@param B The blue value to adjust
@param H The hue adjustment value
@param S The saturation
*/
void adjustHueSaturation(int& R, int& G, int& B, float H, float S); void adjustHueSaturation(int& R, int& G, int& B, float H, float S);
/** /**
@ -118,15 +170,16 @@ class PaletteHandler
*/ */
void loadUserPalette(); void loadUserPalette();
private: private:
static constexpr int NUM_ADJUSTABLES = 6; static constexpr int NUM_ADJUSTABLES = 6;
OSystem& myOSystem; OSystem& myOSystem;
// The currently selected adjustable
uInt32 myCurrentAdjustable{0}; uInt32 myCurrentAdjustable{0};
struct AdjustableTag { struct AdjustableTag {
const char* const type{nullptr}; const char* const name{nullptr};
float* value{nullptr}; float* value{nullptr};
}; };
const std::array<AdjustableTag, NUM_ADJUSTABLES> myAdjustables = const std::array<AdjustableTag, NUM_ADJUSTABLES> myAdjustables =
@ -139,8 +192,9 @@ class PaletteHandler
{ "gamma", &myGamma }, { "gamma", &myGamma },
} }; } };
float myPhaseNTSC{0.0F}; // NTSC and PAL color phase shifts
float myPhasePAL{0.0F}; float myPhaseNTSC{DEF_NTSC_SHIFT};
float myPhasePAL{DEF_PAL_SHIFT};
// range -1.0 to +1.0 (as in AtariNTSC) // range -1.0 to +1.0 (as in AtariNTSC)
// Basic parameters // Basic parameters
float myHue{0.0F}; // -1 = -180 degrees +1 = +180 degrees float myHue{0.0F}; // -1 = -180 degrees +1 = +180 degrees
@ -169,7 +223,7 @@ class PaletteHandler
static PaletteArray ourUserPALPalette; static PaletteArray ourUserPALPalette;
static PaletteArray ourUserSECAMPalette; static PaletteArray ourUserSECAMPalette;
// Table of RGB values for NTSC, PAL - custom-defined // Table of RGB values for NTSC, PAL - custom-defined and generated
static PaletteArray ourCustomNTSCPalette; static PaletteArray ourCustomNTSCPalette;
static PaletteArray ourCustomPALPalette; static PaletteArray ourCustomPALPalette;

View File

@ -74,8 +74,8 @@ string NTSCFilter::getPreset() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::setNextAdjustable() string NTSCFilter::setNextAdjustable()
{ {
if(myPreset != Preset::CUSTOM) //if(myPreset != Preset::CUSTOM)
return "'Custom' TV mode not selected"; // return "'Custom' TV mode not selected";
#ifdef BLARGG_PALETTE #ifdef BLARGG_PALETTE
myCurrentAdjustable = (myCurrentAdjustable + 1) % 10; myCurrentAdjustable = (myCurrentAdjustable + 1) % 10;
@ -85,7 +85,8 @@ string NTSCFilter::setNextAdjustable()
ostringstream buf; ostringstream buf;
buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' selected"; << "' selected ("
<< scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value) << "%)";
return buf.str(); return buf.str();
} }
@ -93,8 +94,8 @@ string NTSCFilter::setNextAdjustable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::setPreviousAdjustable() string NTSCFilter::setPreviousAdjustable()
{ {
if(myPreset != Preset::CUSTOM) //if(myPreset != Preset::CUSTOM)
return "'Custom' TV mode not selected"; // return "'Custom' TV mode not selected";
#ifdef BLARGG_PALETTE #ifdef BLARGG_PALETTE
if(myCurrentAdjustable == 0) myCurrentAdjustable = 9; if(myCurrentAdjustable == 0) myCurrentAdjustable = 9;
@ -104,7 +105,8 @@ string NTSCFilter::setPreviousAdjustable()
else --myCurrentAdjustable; else --myCurrentAdjustable;
ostringstream buf; ostringstream buf;
buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' selected"; << "' selected ("
<< scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value) << "%)";
return buf.str(); return buf.str();
} }
@ -112,8 +114,8 @@ string NTSCFilter::setPreviousAdjustable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::increaseAdjustable() string NTSCFilter::increaseAdjustable()
{ {
if(myPreset != Preset::CUSTOM) //if(myPreset != Preset::CUSTOM)
return "'Custom' TV mode not selected"; // return "'Custom' TV mode not selected";
uInt32 newval = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value); uInt32 newval = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value);
newval += 2; if(newval > 100) newval = 100; newval += 2; if(newval > 100) newval = 100;
@ -121,7 +123,7 @@ string NTSCFilter::increaseAdjustable()
ostringstream buf; ostringstream buf;
buf << "Custom '" << ourCustomAdjustables[myCurrentAdjustable].type buf << "Custom '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' set to " << newval; << "' set to " << newval << "%";
setPreset(myPreset); setPreset(myPreset);
return buf.str(); return buf.str();
@ -130,8 +132,8 @@ string NTSCFilter::increaseAdjustable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::decreaseAdjustable() string NTSCFilter::decreaseAdjustable()
{ {
if(myPreset != Preset::CUSTOM) //if(myPreset != Preset::CUSTOM)
return "'Custom' TV mode not selected"; // return "'Custom' TV mode not selected";
uInt32 newval = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value); uInt32 newval = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value);
if(newval < 2) newval = 0; if(newval < 2) newval = 0;
@ -140,7 +142,7 @@ string NTSCFilter::decreaseAdjustable()
ostringstream buf; ostringstream buf;
buf << "Custom '" << ourCustomAdjustables[myCurrentAdjustable].type buf << "Custom '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' set to " << newval; << "' set to " << newval << "%";
setPreset(myPreset); setPreset(myPreset);
return buf.str(); return buf.str();

View File

@ -101,7 +101,6 @@ class Event
RewindPause, UnwindPause, RewindPause, UnwindPause,
FormatDecrease, FormatIncrease, PaletteDecrease, PaletteIncrease, ToggleColorLoss, FormatDecrease, FormatIncrease, PaletteDecrease, PaletteIncrease, ToggleColorLoss,
ColorShiftDecrease, ColorShiftIncrease,
PreviousPaletteAttribute, NextPaletteAttribute, PreviousPaletteAttribute, NextPaletteAttribute,
PaletteAttributeDecrease, PaletteAttributeIncrease, PaletteAttributeDecrease, PaletteAttributeIncrease,
ToggleFullScreen, VidmodeDecrease, VidmodeIncrease, ToggleFullScreen, VidmodeDecrease, VidmodeIncrease,

View File

@ -437,11 +437,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::PreviousPaletteAttribute: case Event::PreviousPaletteAttribute:
if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().selectAdjustable(false); if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().cycleAdjustable(false);
return; return;
case Event::NextPaletteAttribute: case Event::NextPaletteAttribute:
if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().selectAdjustable(true); if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().cycleAdjustable(true);
return; return;
case Event::PaletteAttributeDecrease: case Event::PaletteAttributeDecrease:
@ -452,14 +452,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().changeAdjustable(true); if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().changeAdjustable(true);
return; return;
case Event::ColorShiftDecrease:
if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().changeColorPhaseShift(false);
return;
case Event::ColorShiftIncrease:
if (pressed) myOSystem.frameBuffer().tiaSurface().paletteHandler().changeColorPhaseShift(true);
return;
case Event::ToggleFullScreen: case Event::ToggleFullScreen:
if (pressed && !repeated) myOSystem.frameBuffer().toggleFullscreen(); if (pressed && !repeated) myOSystem.frameBuffer().toggleFullscreen();
return; return;
@ -565,11 +557,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::PaletteDecrease: case Event::PaletteDecrease:
if (pressed && !repeated) myOSystem.frameBuffer().tiaSurface().paletteHandler().changePalette(false); if (pressed && !repeated) myOSystem.frameBuffer().tiaSurface().paletteHandler().cyclePalette(false);
return; return;
case Event::PaletteIncrease: case Event::PaletteIncrease:
if (pressed && !repeated) myOSystem.frameBuffer().tiaSurface().paletteHandler().changePalette(true); if (pressed && !repeated) myOSystem.frameBuffer().tiaSurface().paletteHandler().cyclePalette(true);
return; return;
case Event::ToggleInter: case Event::ToggleInter:
@ -1965,8 +1957,6 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::NextPaletteAttribute, "Select next palette attribute", "" }, { Event::NextPaletteAttribute, "Select next palette attribute", "" },
{ Event::PaletteAttributeDecrease,"Decrease selected palette attribute", "" }, { Event::PaletteAttributeDecrease,"Decrease selected palette attribute", "" },
{ Event::PaletteAttributeIncrease,"Increase selected palette attribute", "" }, { Event::PaletteAttributeIncrease,"Increase selected palette attribute", "" },
{ Event::ColorShiftDecrease, "Decrease custom palette phase shift", "" },
{ Event::ColorShiftIncrease, "Increase custom palette phase shift", "" },
{ Event::ToggleInter, "Toggle display interpolation", "" }, { Event::ToggleInter, "Toggle display interpolation", "" },
// Blargg TV effects: // Blargg TV effects:
{ Event::VidmodeStd, "Disable TV effects", "" }, { Event::VidmodeStd, "Disable TV effects", "" },
@ -2097,7 +2087,6 @@ const Event::EventSet EventHandler::AudioVideoEvents = {
Event::ScanlineAdjustDecrease, Event::ScanlineAdjustIncrease, Event::ScanlineAdjustDecrease, Event::ScanlineAdjustIncrease,
Event::OverscanDecrease, Event::OverscanIncrease, Event::OverscanDecrease, Event::OverscanIncrease,
Event::PaletteDecrease, Event::PaletteIncrease, Event::PaletteDecrease, Event::PaletteIncrease,
Event::ColorShiftDecrease, Event::ColorShiftIncrease,
Event::PreviousVideoMode, Event::NextVideoMode, Event::PreviousVideoMode, Event::NextVideoMode,
Event::PreviousPaletteAttribute, Event::NextPaletteAttribute, Event::PreviousPaletteAttribute, Event::NextPaletteAttribute,
Event::PaletteAttributeDecrease, Event::PaletteAttributeIncrease, Event::PaletteAttributeDecrease, Event::PaletteAttributeIncrease,

View File

@ -468,7 +468,7 @@ class EventHandler
#else #else
PNG_SIZE = 0, PNG_SIZE = 0,
#endif #endif
EMUL_ACTIONLIST_SIZE = 154 + PNG_SIZE + COMBO_SIZE, EMUL_ACTIONLIST_SIZE = 152 + PNG_SIZE + COMBO_SIZE,
MENU_ACTIONLIST_SIZE = 18 MENU_ACTIONLIST_SIZE = 18
; ;

View File

@ -21,6 +21,7 @@
#include "Version.hxx" #include "Version.hxx"
#include "Logger.hxx" #include "Logger.hxx"
#include "AudioSettings.hxx" #include "AudioSettings.hxx"
#include "PaletteHandler.hxx"
#include "Paddles.hxx" #include "Paddles.hxx"
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
@ -45,7 +46,7 @@ Settings::Settings()
setPermanent("center", "true"); setPermanent("center", "true");
setPermanent("windowedpos", Common::Point(50, 50)); setPermanent("windowedpos", Common::Point(50, 50));
setPermanent("display", 0); setPermanent("display", 0);
setPermanent("palette", "standard"); setPermanent("palette", PaletteHandler::SETTING_STANDARD);
setPermanent("uimessages", "true"); setPermanent("uimessages", "true");
// TIA specific options // TIA specific options
@ -358,8 +359,11 @@ void Settings::validate()
else if(i > 10) setValue("ssinterval", "10"); else if(i > 10) setValue("ssinterval", "10");
s = getString("palette"); s = getString("palette");
if(s != "standard" && s != "z26" && s != "user" && s != "custom") if(s != PaletteHandler::SETTING_STANDARD
setValue("palette", "standard"); && s != PaletteHandler::SETTING_Z26
&& s != PaletteHandler::SETTING_USER
&& s != PaletteHandler::SETTING_CUSTOM)
setValue("palette", PaletteHandler::SETTING_STANDARD);
s = getString("launcherfont"); s = getString("launcherfont");
if(s != "small" && s != "low_medium" && s != "medium" && s != "large" if(s != "small" && s != "low_medium" && s != "medium" && s != "large"

View File

@ -204,7 +204,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kPaletteCmd: case kPaletteCmd:
instance().frameBuffer().tiaSurface().paletteHandler().changePalette(); instance().frameBuffer().tiaSurface().paletteHandler().cyclePalette();
updatePalette(); updatePalette();
break; break;
@ -270,11 +270,11 @@ void CommandDialog::updatePalette()
string palette, label; string palette, label;
palette = instance().settings().getString("palette"); palette = instance().settings().getString("palette");
if(BSPF::equalsIgnoreCase(palette, "standard")) if(BSPF::equalsIgnoreCase(palette, PaletteHandler::SETTING_STANDARD))
label = "Stella Palette"; label = "Stella Palette";
else if(BSPF::equalsIgnoreCase(palette, "z26")) else if(BSPF::equalsIgnoreCase(palette, PaletteHandler::SETTING_Z26))
label = "Z26 Palette"; label = "Z26 Palette";
else if(BSPF::equalsIgnoreCase(palette, "user")) else if(BSPF::equalsIgnoreCase(palette, PaletteHandler::SETTING_USER))
label = "User Palette"; label = "User Palette";
else else
label = "Custom Palette"; label = "Custom Palette";

View File

@ -269,11 +269,11 @@ void VideoDialog::addPaletteTab()
// TIA Palette // TIA Palette
items.clear(); items.clear();
VarList::push_back(items, "Standard", "standard"); VarList::push_back(items, "Standard", PaletteHandler::SETTING_STANDARD);
VarList::push_back(items, "z26", "z26"); VarList::push_back(items, "z26", PaletteHandler::SETTING_Z26);
if (instance().checkUserPalette()) if (instance().checkUserPalette())
VarList::push_back(items, "User", "user"); VarList::push_back(items, "User", PaletteHandler::SETTING_USER);
VarList::push_back(items, "Custom", "custom"); VarList::push_back(items, "Custom", PaletteHandler::SETTING_CUSTOM);
myTIAPalette = new PopUpWidget(myTab, _font, xpos, ypos, pwidth, myTIAPalette = new PopUpWidget(myTab, _font, xpos, ypos, pwidth,
lineHeight, items, "Palette ", lwidth, kPaletteChanged); lineHeight, items, "Palette ", lwidth, kPaletteChanged);
wid.push_back(myTIAPalette); wid.push_back(myTIAPalette);
@ -421,7 +421,7 @@ void VideoDialog::loadConfig()
// TIA Palette // TIA Palette
myPalette = instance().settings().getString("palette"); myPalette = instance().settings().getString("palette");
myTIAPalette->setSelected(myPalette, "standard"); myTIAPalette->setSelected(myPalette, PaletteHandler::SETTING_STANDARD);
// Palette adjustables // Palette adjustables
instance().frameBuffer().tiaSurface().paletteHandler().getAdjustables(myPaletteAdj); instance().frameBuffer().tiaSurface().paletteHandler().getAdjustables(myPaletteAdj);
@ -610,7 +610,7 @@ void VideoDialog::setDefaults()
} }
case 1: // Palettes case 1: // Palettes
myTIAPalette->setSelected("standard", ""); myTIAPalette->setSelected(PaletteHandler::SETTING_STANDARD);
myPhaseShiftNtsc->setValue(PaletteHandler::DEF_NTSC_SHIFT * 10); myPhaseShiftNtsc->setValue(PaletteHandler::DEF_NTSC_SHIFT * 10);
myPhaseShiftPal->setValue(PaletteHandler::DEF_PAL_SHIFT * 10); myPhaseShiftPal->setValue(PaletteHandler::DEF_PAL_SHIFT * 10);
myTVHue->setValue(50); myTVHue->setValue(50);