Various code cleanups.

This commit is contained in:
Stephen Anthony 2020-11-28 22:16:47 -03:30
parent 0716ccc56e
commit c5f8191b7d
12 changed files with 29 additions and 30 deletions

View File

@ -43,8 +43,7 @@ namespace {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AudioSettings::AudioSettings(Settings& settings) AudioSettings::AudioSettings(Settings& settings)
: mySettings(settings), : mySettings(settings)
myIsPersistent(true)
{ {
setPreset(normalizedPreset(mySettings.getInt(SETTING_PRESET))); setPreset(normalizedPreset(mySettings.getInt(SETTING_PRESET)));
} }

View File

@ -131,13 +131,13 @@ class AudioSettings
Preset myPreset; Preset myPreset;
uInt32 myPresetSampleRate; uInt32 myPresetSampleRate{0};
uInt32 myPresetFragmentSize; uInt32 myPresetFragmentSize{0};
uInt32 myPresetBufferSize; uInt32 myPresetBufferSize{0};
uInt32 myPresetHeadroom; uInt32 myPresetHeadroom{0};
ResamplingQuality myPresetResamplingQuality; ResamplingQuality myPresetResamplingQuality;
bool myIsPersistent; bool myIsPersistent{true};
}; };
#endif // AUDIO_PARAMTERS_HXX #endif // AUDIO_PARAMTERS_HXX

View File

@ -19,12 +19,14 @@
using namespace std::chrono; using namespace std::chrono;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FpsMeter::FpsMeter(uInt32 queueSize) FpsMeter::FpsMeter(uInt32 queueSize)
: myQueue(queueSize) : myQueue(queueSize)
{ {
reset(); reset();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FpsMeter::reset(uInt32 garbageFrameLimit) void FpsMeter::reset(uInt32 garbageFrameLimit)
{ {
myQueue.clear(); myQueue.clear();
@ -35,6 +37,7 @@ void FpsMeter::reset(uInt32 garbageFrameLimit)
myGarbageFrameLimit = garbageFrameLimit; myGarbageFrameLimit = garbageFrameLimit;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FpsMeter::render(uInt32 frameCount) void FpsMeter::render(uInt32 frameCount)
{ {
if (myGarbageFrameCounter < myGarbageFrameLimit) { if (myGarbageFrameCounter < myGarbageFrameLimit) {
@ -67,6 +70,7 @@ void FpsMeter::render(uInt32 frameCount)
if (myTimeInterval > 0) myFps = (myFrameCount - first.frames) / myTimeInterval; if (myTimeInterval > 0) myFps = (myFrameCount - first.frames) / myTimeInterval;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float FpsMeter::fps() const float FpsMeter::fps() const
{ {
return myFps; return myFps;

View File

@ -217,7 +217,7 @@ void PhysicalJoystickHandler::mapStelladaptors(const string& saport)
// We know there will be only two such devices (at most), since the logic // We know there will be only two such devices (at most), since the logic
// in setupJoysticks take care of that // in setupJoysticks take care of that
int saCount = 0; int saCount = 0;
int saOrder[NUM_PORTS] = { 1, 2 }; int saOrder[] = { 1, 2 };
if(BSPF::equalsIgnoreCase(saport, "rl")) if(BSPF::equalsIgnoreCase(saport, "rl"))
{ {
saOrder[0] = 2; saOrder[1] = 1; saOrder[0] = 2; saOrder[1] = 1;

View File

@ -22,6 +22,7 @@
#include "PaletteHandler.hxx" #include "PaletteHandler.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteHandler::PaletteHandler(OSystem& system) PaletteHandler::PaletteHandler(OSystem& system)
: myOSystem(system) : myOSystem(system)
{ {

View File

@ -38,7 +38,7 @@ class PhosphorHandler
@return Averaged value of the two RGB colors @return Averaged value of the two RGB colors
*/ */
static inline uInt32 getPixel(const uInt32 c, const uInt32 p) static constexpr uInt32 getPixel(const uInt32 c, const uInt32 p)
{ {
// Mix current calculated frame with previous displayed frame // Mix current calculated frame with previous displayed frame
const uInt8 rc = static_cast<uInt8>(c >> 16), const uInt8 rc = static_cast<uInt8>(c >> 16),

View File

@ -232,7 +232,7 @@ class AtariNTSC
} }
// Common ntsc macros // Common ntsc macros
static inline constexpr void ATARI_NTSC_CLAMP( uInt32& io, uInt32 shift ) { static constexpr void ATARI_NTSC_CLAMP( uInt32& io, uInt32 shift ) {
uInt32 sub = io >> (9-(shift)) & atari_ntsc_clamp_mask; uInt32 sub = io >> (9-(shift)) & atari_ntsc_clamp_mask;
uInt32 clamp = atari_ntsc_clamp_add - sub; uInt32 clamp = atari_ntsc_clamp_add - sub;
io |= clamp; io |= clamp;
@ -240,31 +240,31 @@ class AtariNTSC
io &= clamp; io &= clamp;
} }
static inline constexpr void RGB_TO_YIQ(float r, float g, float b, static constexpr void RGB_TO_YIQ(float r, float g, float b,
float& y, float& i, float& q) { float& y, float& i, float& q) {
y = r * 0.299F + g * 0.587F + b * 0.114F; y = r * 0.299F + g * 0.587F + b * 0.114F;
i = r * 0.595716F - g * 0.274453F - b * 0.321263F; i = r * 0.595716F - g * 0.274453F - b * 0.321263F;
q = r * 0.211456F - g * 0.522591F + b * 0.311135F; q = r * 0.211456F - g * 0.522591F + b * 0.311135F;
} }
static inline constexpr void YIQ_TO_RGB(float y, float i, float q, static constexpr void YIQ_TO_RGB(float y, float i, float q,
const float* to_rgb, int& ir, int& ig, int& ib) { const float* to_rgb, int& ir, int& ig, int& ib) {
ir = static_cast<int>(y + to_rgb[0] * i + to_rgb[1] * q); ir = static_cast<int>(y + to_rgb[0] * i + to_rgb[1] * q);
ig = static_cast<int>(y + to_rgb[2] * i + to_rgb[3] * q); ig = static_cast<int>(y + to_rgb[2] * i + to_rgb[3] * q);
ib = static_cast<int>(y + to_rgb[4] * i + to_rgb[5] * q); ib = static_cast<int>(y + to_rgb[4] * i + to_rgb[5] * q);
} }
static inline constexpr uInt32 PACK_RGB( int r, int g, int b ) { static constexpr uInt32 PACK_RGB( int r, int g, int b ) {
return r << 21 | g << 11 | b << 1; return r << 21 | g << 11 | b << 1;
} }
// Converted from C-style macros; I don't even pretend to understand the logic here :) // Converted from C-style macros; I don't even pretend to understand the logic here :)
static inline constexpr int PIXEL_OFFSET1( int ntsc, int scaled ) { static constexpr int PIXEL_OFFSET1( int ntsc, int scaled ) {
return (kernel_size / 2 + ((ntsc) - (scaled) / rescale_out * rescale_in) + return (kernel_size / 2 + ((ntsc) - (scaled) / rescale_out * rescale_in) +
((((scaled) + rescale_out * 10) % rescale_out) != 0) + ((((scaled) + rescale_out * 10) % rescale_out) != 0) +
(rescale_out - (((scaled) + rescale_out * 10) % rescale_out)) % rescale_out + (rescale_out - (((scaled) + rescale_out * 10) % rescale_out)) % rescale_out +
(kernel_size * 2 * (((scaled) + rescale_out * 10) % rescale_out))); (kernel_size * 2 * (((scaled) + rescale_out * 10) % rescale_out)));
} }
static inline constexpr int PIXEL_OFFSET2( int ntsc ) { static constexpr int PIXEL_OFFSET2( int ntsc ) {
return 1.0F - (((ntsc) + 100) & 2); return 1.0F - (((ntsc) + 100) & 2);
} }

View File

@ -30,12 +30,12 @@
class BreakpointMap class BreakpointMap
{ {
private: private:
static const uInt16 ADDRESS_MASK = 0x1fff; // either 0x1fff or 0xffff (not needed then) static constexpr uInt16 ADDRESS_MASK = 0x1fff; // either 0x1fff or 0xffff (not needed then)
public: public:
// breakpoint flags // breakpoint flags
static const uInt32 ONE_SHOT = 1 << 0; // used for 'trace' command static constexpr uInt32 ONE_SHOT = 1 << 0; // used for 'trace' command
static const uInt8 ANY_BANK = 255; // breakpoint valid in any bank static constexpr uInt8 ANY_BANK = 255; // breakpoint valid in any bank
struct Breakpoint struct Breakpoint
{ {

View File

@ -76,9 +76,6 @@ class Debugger : public DialogContainer
Debugger(OSystem& osystem, Console& console); Debugger(OSystem& osystem, Console& console);
~Debugger() override; ~Debugger() override;
private:
static const Int8 ANY_BANK = -1;
public: public:
/** /**
Initialize the debugger dialog container. Initialize the debugger dialog container.
@ -284,8 +281,6 @@ class Debugger : public DialogContainer
*/ */
Dialog* baseDialog() override { return myDialog; } Dialog* baseDialog() override { return myDialog; }
static const Int32 NOT_FOUND = -1;
private: private:
/** /**
Save state of each debugger subsystem and, by default, mark all Save state of each debugger subsystem and, by default, mark all
@ -367,6 +362,8 @@ class Debugger : public DialogContainer
static std::array<BuiltinFunction, 18> ourBuiltinFunctions; static std::array<BuiltinFunction, 18> ourBuiltinFunctions;
static std::array<PseudoRegister, 16> ourPseudoRegisters; static std::array<PseudoRegister, 16> ourPseudoRegisters;
static constexpr Int8 ANY_BANK = -1;
private: private:
// rewind/unwind n states // rewind/unwind n states
uInt16 windStates(uInt16 numStates, bool unwind, string& message); uInt16 windStates(uInt16 numStates, bool unwind, string& message);

View File

@ -74,8 +74,6 @@ enum JoyHatMask {
EVENT_HATCENTER_M = 1<<4 EVENT_HATCENTER_M = 1<<4
}; };
static const int NUM_PORTS = 2;
enum class EventMode { enum class EventMode {
kEmulationMode, // active mapping used for emulation kEmulationMode, // active mapping used for emulation
kMenuMode, // mapping used for dialogs kMenuMode, // mapping used for dialogs

View File

@ -81,10 +81,10 @@ class DeveloperDialog : public Dialog
enum SettingsSet { player = 0, developer = 1 }; enum SettingsSet { player = 0, developer = 1 };
// MUST be aligned with RewindManager! // MUST be aligned with RewindManager!
static const int NUM_INTERVALS = 7; static constexpr int NUM_INTERVALS = 7;
static const int NUM_HORIZONS = 8; static constexpr int NUM_HORIZONS = 8;
static const int DEBUG_COLORS = 6; static constexpr int DEBUG_COLORS = 6;
TabWidget* myTab{nullptr}; TabWidget* myTab{nullptr};
// Emulator widgets // Emulator widgets

View File

@ -26,8 +26,8 @@
class TabWidget : public Widget, public CommandSender class TabWidget : public Widget, public CommandSender
{ {
public: public:
static const int NO_WIDTH = 0; static constexpr int NO_WIDTH = 0;
static const int AUTO_WIDTH = -1; static constexpr int AUTO_WIDTH = -1;
enum { enum {
kTabChangedCmd = 'TBCH' kTabChangedCmd = 'TBCH'