Fixes for warnings in latest g++ and clang, and update libretro port to latest changes.

This commit is contained in:
Stephen Anthony 2020-05-11 14:57:01 -02:30
parent c078bf135d
commit 5ddaea992d
18 changed files with 61 additions and 66 deletions

View File

@ -15,6 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================ //============================================================================
#include "OSystem.hxx"
#include "Console.hxx"
#include "EventHandler.hxx" #include "EventHandler.hxx"
#include "PKeyboardHandler.hxx" #include "PKeyboardHandler.hxx"

View File

@ -15,6 +15,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================ //============================================================================
#include <cmath>
#include "Console.hxx" #include "Console.hxx"
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
@ -303,7 +304,7 @@ PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
adjust[i] = powf(i * toFloat, gamma) * contrast + brightness; adjust[i] = powf(i * toFloat, gamma) * contrast + brightness;
// Transform original palette into destination palette // Transform original palette into destination palette
for(int i = 0; i < destPalette.size(); i += 2) for(size_t i = 0; i < destPalette.size(); i += 2)
{ {
const uInt32 pixel = palette[i]; const uInt32 pixel = palette[i];
int r = (pixel >> 16) & 0xff; int r = (pixel >> 16) & 0xff;
@ -396,8 +397,8 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing)
// color 0 is grayscale // color 0 is grayscale
for(int chroma = 1; chroma < NUM_CHROMA; chroma++) for(int chroma = 1; chroma < NUM_CHROMA; chroma++)
{ {
color[chroma][0] = SATURATION * sin(offset + shift * (chroma - 1)); color[chroma][0] = SATURATION * sinf(offset + shift * (chroma - 1));
color[chroma][1] = SATURATION * sin(offset + shift * (chroma - 1 - BSPF::PI_f)); color[chroma][1] = SATURATION * sinf(offset + shift * (chroma - 1 - BSPF::PI_f));
} }
for(int chroma = 0; chroma < NUM_CHROMA; chroma++) for(int chroma = 0; chroma < NUM_CHROMA; chroma++)
@ -488,17 +489,17 @@ void PaletteHandler::adjustHueSaturation(int& R, int& G, int& B, float H, float
// Adapted from http://beesbuzz.biz/code/16-hsv-color-transforms // Adapted from http://beesbuzz.biz/code/16-hsv-color-transforms
// (C) J. “Fluffy” Shagam // (C) J. “Fluffy” Shagam
// License: CC BY-SA 4.0 // License: CC BY-SA 4.0
const float su = S * cos(-H * BSPF::PI_f); const float su = S * cosf(-H * BSPF::PI_f);
const float sw = S * sin(-H * BSPF::PI_f); const float sw = S * sinf(-H * BSPF::PI_f);
const float r = (.299 + .701 * su + .168 * sw) * R const float r = (.299F + .701F * su + .168F * sw) * R
+ (.587 - .587 * su + .330 * sw) * G + (.587F - .587F * su + .330F * sw) * G
+ (.114 - .114 * su - .497 * sw) * B; + (.114F - .114F * su - .497F * sw) * B;
const float g = (.299 - .299 * su - .328 * sw) * R const float g = (.299F - .299F * su - .328F * sw) * R
+ (.587 + .413 * su + .035 * sw) * G + (.587F + .413F * su + .035F * sw) * G
+ (.114 - .114 * su + .292 * sw) * B; + (.114F - .114F * su + .292F * sw) * B;
const float b = (.299 - .300 * su + 1.25 * sw) * R const float b = (.299F - .300F * su + 1.25F * sw) * R
+ (.587 - .588 * su - 1.05 * sw) * G + (.587F - .588F * su - 1.05F * sw) * G
+ (.114 + .886 * su - .203 * sw) * B; + (.114F + .886F * su - .203F * sw) * B;
R = BSPF::clamp(r, 0.F, 255.F); R = BSPF::clamp(r, 0.F, 255.F);
G = BSPF::clamp(g, 0.F, 255.F); G = BSPF::clamp(g, 0.F, 255.F);

View File

@ -38,8 +38,8 @@ class PaletteHandler
// Externally used adjustment parameters // Externally used adjustment parameters
struct Adjustable { struct Adjustable {
float phaseNtsc, phasePal; float phaseNtsc{0.F}, phasePal{0.F};
uInt32 hue, saturation, contrast, brightness, gamma; uInt32 hue{0}, saturation{0}, contrast{0}, brightness{0}, gamma{0};
}; };
public: public:
@ -54,14 +54,14 @@ class PaletteHandler
void cyclePalette(bool next = true); void cyclePalette(bool next = true);
/* /*
Cycle through each palette adjustable Cycle through each palette adjustable.
@param next Select next adjustable, else previous one @param next Select next adjustable, else previous one
*/ */
void cycleAdjustable(bool next = true); void cycleAdjustable(bool next = true);
/* /*
Increase or decrease current palette adjustable Increase or decrease current palette adjustable.
@param increase Increase adjustable if true, else decrease @param increase Increase adjustable if true, else decrease
*/ */
@ -82,7 +82,7 @@ class PaletteHandler
/** /**
Sets the palette according to the given palette name. Sets the palette according to the given palette name.
@param palette The palette to switch to. @param name The palette to switch to
*/ */
void setPalette(const string& name); void setPalette(const string& name);
@ -107,11 +107,11 @@ class PaletteHandler
/** /**
Convert adjustables from/to 100% scale Convert adjustables from/to 100% scale
*/ */
float scaleFrom100(float x) const { return (x / 50.F) - 1.F; } constexpr float scaleFrom100(float x) const { return (x / 50.F) - 1.F; }
uInt32 scaleTo100(float x) const { return uInt32(50 * (x + 1.F)); } constexpr uInt32 scaleTo100(float x) const { return uInt32(50 * (x + 1.F)); }
/** /**
Convert palette settings name to enumeration Convert palette settings name to enumeration.
@param name The given palette's settings name @param name The given palette's settings name
@ -120,7 +120,7 @@ class PaletteHandler
PaletteType toPaletteType(const string& name) const; PaletteType toPaletteType(const string& name) const;
/** /**
Convert enumeration to palette settings name Convert enumeration to palette settings name.
@param type The given palette type @param type The given palette type
@ -133,7 +133,7 @@ class PaletteHandler
Note that there are two of these (NTSC and PAL). The currently Note that there are two of these (NTSC and PAL). The currently
active mode will determine which one is used. active mode will determine which one is used.
@param increase Increase if true, else decrease. @param increase Increase if true, else decrease
*/ */
void changeColorPhaseShift(bool increase = true); void changeColorPhaseShift(bool increase = true);
@ -145,16 +145,16 @@ class PaletteHandler
void generateCustomPalette(ConsoleTiming timing); void generateCustomPalette(ConsoleTiming timing);
/** /**
Create new palette by applying palette adjustments on given palette Create new palette by applying palette adjustments on given palette.
@param type The palette which should be adjusted @param source The palette which should be adjusted
@return An adjusted palette @return An adjusted palette
*/ */
PaletteArray adjustedPalette(const PaletteArray& source); PaletteArray adjustedPalette(const PaletteArray& source);
/** /**
Adjust hue and saturation for given RGB values Adjust hue and saturation for given RGB values.
@param R The red value to adjust @param R The red value to adjust
@param G The green value to adjust @param G The green value to adjust

View File

@ -16,6 +16,8 @@
//============================================================================ //============================================================================
#include "CartAR.hxx" #include "CartAR.hxx"
#include "Debugger.hxx"
#include "CartDebug.hxx"
#include "PopUpWidget.hxx" #include "PopUpWidget.hxx"
#include "CartARWidget.hxx" #include "CartARWidget.hxx"

View File

@ -49,7 +49,7 @@ string CartridgeE0Widget::romDescription()
info << "Segment #" << seg << " accessible @ $" info << "Segment #" << seg << " accessible @ $"
<< Common::Base::HEX4 << (ADDR_BASE | segmentOffset) << Common::Base::HEX4 << (ADDR_BASE | segmentOffset)
<< " - $" << (ADDR_BASE | segmentOffset + /*myCart.myBankSize - 1*/ 0x3FF) << ",\n"; << " - $" << (ADDR_BASE | (segmentOffset + /*myCart.myBankSize - 1*/ 0x3FF)) << ",\n";
if (seg < 3) if (seg < 3)
info << " Hotspots " << hotspotStr(0, seg, true) << " - " << hotspotStr(7, seg, true) << "\n"; info << " Hotspots " << hotspotStr(0, seg, true) << " - " << hotspotStr(7, seg, true) << "\n";
else else

View File

@ -33,7 +33,6 @@ class TiaOutputWidget;
class TiaZoomWidget; class TiaZoomWidget;
class CartDebugWidget; class CartDebugWidget;
class CartRamWidget; class CartRamWidget;
class OptionsDialog;
namespace Common { namespace Common {
struct Rect; struct Rect;
@ -41,6 +40,7 @@ namespace Common {
#include "Dialog.hxx" #include "Dialog.hxx"
#include "MessageBox.hxx" #include "MessageBox.hxx"
#include "OptionsDialog.hxx"
class DebuggerDialog : public Dialog class DebuggerDialog : public Dialog
{ {

View File

@ -15,6 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================ //============================================================================
#include <cmath>
#include "Control.hxx" #include "Control.hxx"
#include "Event.hxx" #include "Event.hxx"
#include "System.hxx" #include "System.hxx"

View File

@ -22,13 +22,13 @@ class TIA;
class Console; class Console;
class OSystem; class OSystem;
class FBSurface; class FBSurface;
class PaletteHandler;
#include <thread> #include <thread>
#include "Rect.hxx" #include "Rect.hxx"
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
#include "NTSCFilter.hxx" #include "NTSCFilter.hxx"
#include "PaletteHandler.hxx"
#include "PhosphorHandler.hxx" #include "PhosphorHandler.hxx"
#include "bspf.hxx" #include "bspf.hxx"
#include "TIAConstants.hxx" #include "TIAConstants.hxx"

View File

@ -108,6 +108,7 @@ void Thumbulator::setConsoleTiming(ConsoleTiming timing)
case ConsoleTiming::ntsc: timing_factor = NTSC; break; case ConsoleTiming::ntsc: timing_factor = NTSC; break;
case ConsoleTiming::secam: timing_factor = SECAM; break; case ConsoleTiming::secam: timing_factor = SECAM; break;
case ConsoleTiming::pal: timing_factor = PAL; break; case ConsoleTiming::pal: timing_factor = PAL; break;
default: break; // satisfy compiler
} }
} }

View File

@ -28,8 +28,8 @@ ColorWidget::ColorWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, int cmd, bool framed) int x, int y, int w, int h, int cmd, bool framed)
: Widget(boss, font, x, y, w, h), : Widget(boss, font, x, y, w, h),
CommandSender(boss), CommandSender(boss),
_cmd(cmd), _framed(framed),
_framed(framed) _cmd(cmd)
{ {
_flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS; _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS;
} }

View File

@ -384,4 +384,3 @@ void DialogContainer::reset()
uInt64 DialogContainer::_DOUBLE_CLICK_DELAY = 500; uInt64 DialogContainer::_DOUBLE_CLICK_DELAY = 500;
uInt64 DialogContainer::_REPEAT_INITIAL_DELAY = 400; uInt64 DialogContainer::_REPEAT_INITIAL_DELAY = 400;
uInt64 DialogContainer::_REPEAT_SUSTAIN_DELAY = 50; uInt64 DialogContainer::_REPEAT_SUSTAIN_DELAY = 50;

View File

@ -112,8 +112,7 @@ void VideoAudioDialog::addDisplayTab()
{ {
const int lineHeight = _font.getLineHeight(), const int lineHeight = _font.getLineHeight(),
fontHeight = _font.getFontHeight(), fontHeight = _font.getFontHeight(),
fontWidth = _font.getMaxCharWidth(), fontWidth = _font.getMaxCharWidth();
buttonHeight = _font.getLineHeight() * 1.25;
const int VGAP = fontHeight / 4; const int VGAP = fontHeight / 4;
const int VBORDER = fontHeight / 2; const int VBORDER = fontHeight / 2;
const int HBORDER = fontWidth * 1.25; const int HBORDER = fontWidth * 1.25;
@ -186,8 +185,7 @@ void VideoAudioDialog::addPaletteTab()
{ {
const int lineHeight = _font.getLineHeight(), const int lineHeight = _font.getLineHeight(),
fontHeight = _font.getFontHeight(), fontHeight = _font.getFontHeight(),
fontWidth = _font.getMaxCharWidth(), fontWidth = _font.getMaxCharWidth();
buttonHeight = _font.getLineHeight() * 1.25;
const int VBORDER = fontHeight / 2; const int VBORDER = fontHeight / 2;
const int HBORDER = fontWidth * 1.25; const int HBORDER = fontWidth * 1.25;
const int INDENT = fontWidth * 2; const int INDENT = fontWidth * 2;

View File

@ -110,7 +110,7 @@ class VideoAudioDialog : public Dialog
SliderWidget* myTVContrast{nullptr}; SliderWidget* myTVContrast{nullptr};
SliderWidget* myTVGamma{nullptr}; SliderWidget* myTVGamma{nullptr};
std::array<StaticTextWidget*, 16> myColorLbl{nullptr}; std::array<StaticTextWidget*, 16> myColorLbl{nullptr};
ColorWidget* myColor[16][8]{nullptr}; ColorWidget* myColor[16][8]{{nullptr}};
// Audio // Audio
CheckboxWidget* mySoundEnableCheckbox{nullptr}; CheckboxWidget* mySoundEnableCheckbox{nullptr};
@ -125,7 +125,7 @@ class VideoAudioDialog : public Dialog
SliderWidget* myDpcPitch{nullptr}; SliderWidget* myDpcPitch{nullptr};
string myPalette; string myPalette;
PaletteHandler::Adjustable myPaletteAdj{0.0F}; PaletteHandler::Adjustable myPaletteAdj;
enum { enum {
kZoomChanged = 'VDZo', kZoomChanged = 'VDZo',

View File

@ -23,6 +23,7 @@ SOURCES_CXX := \
$(CORE_DIR)/common/KeyMap.cxx \ $(CORE_DIR)/common/KeyMap.cxx \
$(CORE_DIR)/common/Logger.cxx \ $(CORE_DIR)/common/Logger.cxx \
$(CORE_DIR)/common/MouseControl.cxx \ $(CORE_DIR)/common/MouseControl.cxx \
$(CORE_DIR)/common/PaletteHandler.cxx \
$(CORE_DIR)/common/PhosphorHandler.cxx \ $(CORE_DIR)/common/PhosphorHandler.cxx \
$(CORE_DIR)/common/PhysicalJoystick.cxx \ $(CORE_DIR)/common/PhysicalJoystick.cxx \
$(CORE_DIR)/common/PJoystickHandler.cxx \ $(CORE_DIR)/common/PJoystickHandler.cxx \

View File

@ -40,7 +40,7 @@ StellaLIBRETRO::StellaLIBRETRO()
video_aspect_ntsc = 0; video_aspect_ntsc = 0;
video_aspect_pal = 0; video_aspect_pal = 0;
video_palette = "standard"; video_palette = PaletteHandler::SETTING_STANDARD;
video_filter = NTSCFilter::Preset::OFF; video_filter = NTSCFilter::Preset::OFF;
video_ready = false; video_ready = false;
@ -374,19 +374,12 @@ void StellaLIBRETRO::setVideoFilter(NTSCFilter::Preset mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaLIBRETRO::setVideoPalette(uInt32 mode) void StellaLIBRETRO::setVideoPalette(const string& mode)
{ {
switch (mode)
{
case 0: video_palette = "standard"; break;
case 1: video_palette = "z26"; break;
case 2: video_palette = "user"; break;
}
if (system_ready) if (system_ready)
{ {
myOSystem->settings().setValue("palette", video_palette); myOSystem->settings().setValue("palette", video_palette);
myOSystem->console().setPalette(video_palette); myOSystem->frameBuffer().tiaSurface().paletteHandler().setPalette(video_palette);
} }
} }

View File

@ -104,7 +104,7 @@ class StellaLIBRETRO
void setVideoAspectPAL(uInt32 value) { video_aspect_pal = value; }; void setVideoAspectPAL(uInt32 value) { video_aspect_pal = value; };
void setVideoFilter(NTSCFilter::Preset mode); void setVideoFilter(NTSCFilter::Preset mode);
void setVideoPalette(uInt32 mode); void setVideoPalette(const string& mode);
void setVideoPhosphor(uInt32 mode, uInt32 blend); void setVideoPhosphor(uInt32 mode, uInt32 blend);
void setAudioStereo(int mode); void setAudioStereo(int mode);

View File

@ -15,6 +15,7 @@
#include "StellaLIBRETRO.hxx" #include "StellaLIBRETRO.hxx"
#include "Event.hxx" #include "Event.hxx"
#include "NTSCFilter.hxx" #include "NTSCFilter.hxx"
#include "PaletteHandler.hxx"
#include "Version.hxx" #include "Version.hxx"
@ -30,11 +31,12 @@ static retro_audio_sample_batch_t audio_batch_cb;
// libretro UI settings // libretro UI settings
static int setting_ntsc, setting_pal; static int setting_ntsc, setting_pal;
static int setting_stereo, setting_palette; static int setting_stereo;
static int setting_phosphor, setting_console, setting_phosphor_blend; static int setting_phosphor, setting_console, setting_phosphor_blend;
static int stella_paddle_joypad_sensitivity; static int stella_paddle_joypad_sensitivity;
static int setting_crop_hoverscan, crop_left; static int setting_crop_hoverscan, crop_left;
static NTSCFilter::Preset setting_filter; static NTSCFilter::Preset setting_filter;
static const char* setting_palette;
static bool system_reset; static bool system_reset;
@ -275,17 +277,11 @@ static void update_variables(bool init = false)
RETRO_GET("stella_palette") RETRO_GET("stella_palette")
{ {
int value = 0; if(setting_palette != var.value)
if(!strcmp(var.value, "standard")) value = 0;
else if(!strcmp(var.value, "z26")) value = 1;
else if(!strcmp(var.value, "user")) value = 2;
if(setting_palette != value)
{ {
stella.setVideoPalette(value); stella.setVideoPalette(var.value);
setting_palette = value; setting_palette = var.value;
} }
} }
@ -494,7 +490,7 @@ void retro_set_environment(retro_environment_t cb)
static struct retro_variable variables[] = { static struct retro_variable variables[] = {
// Adding more variables and rearranging them is safe. // Adding more variables and rearranging them is safe.
{ "stella_console", "Console display; auto|ntsc|pal|secam|ntsc50|pal60|secam60" }, { "stella_console", "Console display; auto|ntsc|pal|secam|ntsc50|pal60|secam60" },
{ "stella_palette", "Palette colors; standard|z26|user" }, { "stella_palette", "Palette colors; standard|z26|user|custom" },
{ "stella_filter", "TV effects; disabled|composite|s-video|rgb|badly adjusted" }, { "stella_filter", "TV effects; disabled|composite|s-video|rgb|badly adjusted" },
{ "stella_ntsc_aspect", "NTSC aspect %; par|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|50|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99" }, { "stella_ntsc_aspect", "NTSC aspect %; par|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|50|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99" },
{ "stella_pal_aspect", "PAL aspect %; par|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|50|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99" }, { "stella_pal_aspect", "PAL aspect %; par|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|50|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99" },