More conversions of C-style to std::array.

That's it for a little while; getting tired now ...
This commit is contained in:
Stephen Anthony 2019-12-27 19:22:09 -03:30
parent 3250fa4f5d
commit f195b36baa
102 changed files with 458 additions and 496 deletions

View File

@ -60,7 +60,7 @@ class PhosphorHandler
float myPhosphorPercent; float myPhosphorPercent;
// Precalculated averaged phosphor colors // Precalculated averaged phosphor colors
using PhosphorLUT = std::array<std::array<uInt8, kColor>, kColor>; using PhosphorLUT = BSPF::array2D<uInt8, kColor, kColor>;
static PhosphorLUT ourPhosphorLUT; static PhosphorLUT ourPhosphorLUT;
private: private:

View File

@ -111,7 +111,8 @@ bool RewindManager::addState(const string& message, bool timeMachine)
// adjust frame timed intervals to actual scanlines (vs 262) // adjust frame timed intervals to actual scanlines (vs 262)
if(interval >= 76 * 262 && interval <= 76 * 262 * 30) if(interval >= 76 * 262 && interval <= 76 * 262 * 30)
{ {
const uInt32 scanlines = std::max(myOSystem.console().tia().scanlinesLastFrame(), 240u); const uInt32 scanlines = std::max<uInt32>
(myOSystem.console().tia().scanlinesLastFrame(), 240);
interval = interval * scanlines / 262; interval = interval * scanlines / 262;
} }
@ -401,15 +402,19 @@ string RewindManager::loadState(Int64 startCycles, uInt32 numStates)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RewindManager::getUnitString(Int64 cycles) string RewindManager::getUnitString(Int64 cycles)
{ {
constexpr Int32 NTSC_FREQ = 1193182; // ~76*262*60
constexpr Int32 PAL_FREQ = 1182298; // ~76*312*50
const Int32 scanlines = std::max(myOSystem.console().tia().scanlinesLastFrame(), 240u); const Int32 scanlines = std::max(myOSystem.console().tia().scanlinesLastFrame(), 240u);
const bool isNTSC = scanlines <= 287; const bool isNTSC = scanlines <= 287;
const Int32 NTSC_FREQ = 1193182; // ~76*262*60
const Int32 PAL_FREQ = 1182298; // ~76*312*50
const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second
const Int32 NUM_UNITS = 5; constexpr Int32 NUM_UNITS = 5;
const string UNIT_NAMES[NUM_UNITS] = { "cycle", "scanline", "frame", "second", "minute" }; const std::array<string, NUM_UNITS> UNIT_NAMES = {
const Int64 UNIT_CYCLES[NUM_UNITS + 1] = { 1, 76, 76 * scanlines, freq, freq * 60, Int64(1) << 62 }; "cycle", "scanline", "frame", "second", "minute"
};
const std::array<Int64, NUM_UNITS+1> UNIT_CYCLES = {
1, 76, 76 * scanlines, freq, freq * 60, Int64(1) << 62
};
stringstream result; stringstream result;
Int32 i; Int32 i;

View File

@ -52,7 +52,7 @@ class RewindManager
static constexpr uInt32 MAX_BUF_SIZE = 1000; static constexpr uInt32 MAX_BUF_SIZE = 1000;
static constexpr int NUM_INTERVALS = 7; static constexpr int NUM_INTERVALS = 7;
// cycle values for the intervals // cycle values for the intervals
const uInt32 INTERVAL_CYCLES[NUM_INTERVALS] = { const std::array<uInt32, NUM_INTERVALS> INTERVAL_CYCLES = {
76 * 262, 76 * 262,
76 * 262 * 3, 76 * 262 * 3,
76 * 262 * 10, 76 * 262 * 10,
@ -62,7 +62,7 @@ class RewindManager
76 * 262 * 60 * 10 76 * 262 * 60 * 10
}; };
// settings values for the intervals // settings values for the intervals
const string INT_SETTINGS[NUM_INTERVALS] = { const std::array<string, NUM_INTERVALS> INT_SETTINGS = {
"1f", "1f",
"3f", "3f",
"10f", "10f",
@ -74,7 +74,7 @@ class RewindManager
static constexpr int NUM_HORIZONS = 8; static constexpr int NUM_HORIZONS = 8;
// cycle values for the horzions // cycle values for the horzions
const uInt64 HORIZON_CYCLES[NUM_HORIZONS] = { const std::array<uInt64, NUM_HORIZONS> HORIZON_CYCLES = {
76 * 262 * 60 * 3, 76 * 262 * 60 * 3,
76 * 262 * 60 * 10, 76 * 262 * 60 * 10,
76 * 262 * 60 * 30, 76 * 262 * 60 * 30,
@ -85,7 +85,7 @@ class RewindManager
uInt64(76) * 262 * 60 * 60 * 60 uInt64(76) * 262 * 60 * 60 * 60
}; };
// settings values for the horzions // settings values for the horzions
const string HOR_SETTINGS[NUM_HORIZONS] = { const std::array<string, NUM_HORIZONS> HOR_SETTINGS = {
"3s", "3s",
"10s", "10s",
"30s", "30s",

View File

@ -42,7 +42,7 @@ class Variant
} }
public: public:
Variant() { } Variant() { } // NOLINT
Variant(const string& s) : data(s) { } Variant(const string& s) : data(s) { }
Variant(const char* s) : data(s) { } Variant(const char* s) : data(s) { }

View File

@ -41,7 +41,7 @@ namespace {
{ {
// We calculate the sinc with double precision in order to compensate for precision loss // We calculate the sinc with double precision in order to compensate for precision loss
// around zero // around zero
return x == 0.f ? 1 : static_cast<float>( return x == 0.F ? 1 : static_cast<float>(
sin(BSPF::PI_d * static_cast<double>(x)) / BSPF::PI_d / static_cast<double>(x) sin(BSPF::PI_d * static_cast<double>(x)) / BSPF::PI_d / static_cast<double>(x)
); );
} }
@ -108,7 +108,7 @@ void LanczosResampler::precomputeKernels()
for (uInt32 j = 0; j < 2 * myKernelParameter; ++j) { for (uInt32 j = 0; j < 2 * myKernelParameter; ++j) {
kernel[j] = lanczosKernel( kernel[j] = lanczosKernel(
center - static_cast<float>(j) + static_cast<float>(myKernelParameter) - 1.f, myKernelParameter center - static_cast<float>(j) + static_cast<float>(myKernelParameter) - 1.F, myKernelParameter
) * CLIPPING_FACTOR; ) * CLIPPING_FACTOR;
} }
@ -141,7 +141,7 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
} }
if (!myCurrentFragment) { if (!myCurrentFragment) {
std::fill_n(fragment, length, 0.f); std::fill_n(fragment, length, 0.F);
return; return;
} }
@ -160,7 +160,7 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
fragment[2*i + 1] = sampleR; fragment[2*i + 1] = sampleR;
} }
else else
fragment[i] = (sampleL + sampleR) / 2.f; fragment[i] = (sampleL + sampleR) / 2.F;
} else { } else {
float sample = myBuffer->convoluteWith(kernel); float sample = myBuffer->convoluteWith(kernel);

View File

@ -60,7 +60,7 @@ class Resampler {
virtual void fillFragment(float* fragment, uInt32 length) = 0; virtual void fillFragment(float* fragment, uInt32 length) = 0;
virtual ~Resampler() {} virtual ~Resampler() = default;
protected: protected:

View File

@ -118,6 +118,10 @@ namespace BSPF
static const string ARCH = "NOARCH"; static const string ARCH = "NOARCH";
#endif #endif
// Make 2D-arrays using std::array less verbose
template<class T, size_t ROW, size_t COL>
using array2D = std::array<std::array<T, COL>, ROW>;
// Combines 'max' and 'min', and clamps value to the upper/lower value // Combines 'max' and 'min', and clamps value to the upper/lower value
// if it is outside the specified range // if it is outside the specified range
template<class T> inline T clamp(T val, T lower, T upper) template<class T> inline T clamp(T val, T lower, T upper)

View File

@ -393,7 +393,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
float sum; float sum;
/* quadratic mapping to reduce negative (blurring) range */ /* quadratic mapping to reduce negative (blurring) range */
float to_angle = setup.resolution + 1; float to_angle = setup.resolution + 1;
to_angle = BSPF::PI_f / maxh * luma_cutoff * (to_angle * to_angle + 1.f); to_angle = BSPF::PI_f / maxh * luma_cutoff * (to_angle * to_angle + 1.F);
kernels [kernel_size * 3 / 2] = maxh; /* default center value */ kernels [kernel_size * 3 / 2] = maxh; /* default center value */
for ( int i = 0; i < kernel_half * 2 + 1; i++ ) for ( int i = 0; i < kernel_half * 2 + 1; i++ )

View File

@ -152,10 +152,10 @@ class AtariNTSC
; ;
std::array<uInt8, palette_size*3> myRGBPalette; std::array<uInt8, palette_size*3> myRGBPalette;
std::array<std::array<uInt32, entry_size>, palette_size> myColorTable; BSPF::array2D<uInt32, palette_size, entry_size> myColorTable;
// Rendering threads // Rendering threads
unique_ptr<std::thread[]> myThreads; unique_ptr<std::thread[]> myThreads; // NOLINT
// Number of rendering and total threads // Number of rendering and total threads
uInt32 myWorkerThreads, myTotalThreads; uInt32 myWorkerThreads, myTotalThreads;

View File

@ -20,8 +20,8 @@
#include "NTSCFilter.hxx" #include "NTSCFilter.hxx"
constexpr float scaleFrom100(float x) { return (x/50.f) - 1.f; } constexpr float scaleFrom100(float x) { return (x/50.F) - 1.F; }
constexpr uInt32 scaleTo100(float x) { return uInt32(50*(x+1.f)); } constexpr uInt32 scaleTo100(float x) { return uInt32(50*(x+1.F)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NTSCFilter::NTSCFilter() NTSCFilter::NTSCFilter()
@ -149,16 +149,16 @@ string NTSCFilter::decreaseAdjustable()
void NTSCFilter::loadConfig(const Settings& settings) void NTSCFilter::loadConfig(const Settings& settings)
{ {
// Load adjustables for custom mode // Load adjustables for custom mode
myCustomSetup.hue = BSPF::clamp(settings.getFloat("tv.hue"), -1.0f, 1.0f); myCustomSetup.hue = BSPF::clamp(settings.getFloat("tv.hue"), -1.0F, 1.0F);
myCustomSetup.saturation = BSPF::clamp(settings.getFloat("tv.saturation"), -1.0f, 1.0f); myCustomSetup.saturation = BSPF::clamp(settings.getFloat("tv.saturation"), -1.0F, 1.0F);
myCustomSetup.contrast = BSPF::clamp(settings.getFloat("tv.contrast"), -1.0f, 1.0f); myCustomSetup.contrast = BSPF::clamp(settings.getFloat("tv.contrast"), -1.0F, 1.0F);
myCustomSetup.brightness = BSPF::clamp(settings.getFloat("tv.brightness"), -1.0f, 1.0f); myCustomSetup.brightness = BSPF::clamp(settings.getFloat("tv.brightness"), -1.0F, 1.0F);
myCustomSetup.sharpness = BSPF::clamp(settings.getFloat("tv.sharpness"), -1.0f, 1.0f); myCustomSetup.sharpness = BSPF::clamp(settings.getFloat("tv.sharpness"), -1.0F, 1.0F);
myCustomSetup.gamma = BSPF::clamp(settings.getFloat("tv.gamma"), -1.0f, 1.0f); myCustomSetup.gamma = BSPF::clamp(settings.getFloat("tv.gamma"), -1.0F, 1.0F);
myCustomSetup.resolution = BSPF::clamp(settings.getFloat("tv.resolution"), -1.0f, 1.0f); myCustomSetup.resolution = BSPF::clamp(settings.getFloat("tv.resolution"), -1.0F, 1.0F);
myCustomSetup.artifacts = BSPF::clamp(settings.getFloat("tv.artifacts"), -1.0f, 1.0f); myCustomSetup.artifacts = BSPF::clamp(settings.getFloat("tv.artifacts"), -1.0F, 1.0F);
myCustomSetup.fringing = BSPF::clamp(settings.getFloat("tv.fringing"), -1.0f, 1.0f); myCustomSetup.fringing = BSPF::clamp(settings.getFloat("tv.fringing"), -1.0F, 1.0F);
myCustomSetup.bleed = BSPF::clamp(settings.getFloat("tv.bleed"), -1.0f, 1.0f); myCustomSetup.bleed = BSPF::clamp(settings.getFloat("tv.bleed"), -1.0F, 1.0F);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -150,7 +150,9 @@ uInt8 RiotDebug::swbcnt(int newVal)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 RiotDebug::inpt(int x) uInt8 RiotDebug::inpt(int x)
{ {
static TIARegister _inpt[6] = { INPT0, INPT1, INPT2, INPT3, INPT4, INPT5 }; static constexpr std::array<TIARegister, 6> _inpt = {
INPT0, INPT1, INPT2, INPT3, INPT4, INPT5
};
return mySystem.peek(_inpt[x]); return mySystem.peek(_inpt[x]);
} }

View File

@ -967,6 +967,7 @@ string TIADebug::colorSwatch(uInt8 c) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FIXME - how does this work; is this even needed ?? // FIXME - how does this work; is this even needed ??
// convert to stringstream, get rid of snprintf
string TIADebug::audFreq(uInt8 div) string TIADebug::audFreq(uInt8 div)
{ {
string ret; string ret;

View File

@ -24,7 +24,7 @@ AmigaMouseWidget::AmigaMouseWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 AmigaMouseWidget::getGrayCodeTable(const int index, const int direction) uInt8 AmigaMouseWidget::getGrayCodeTable(const int index, const int) const
{ {
return myGrayCodeTable[index]; return myGrayCodeTable[index];
} }

View File

@ -31,9 +31,9 @@ class AmigaMouseWidget : public PointingDeviceWidget
virtual ~AmigaMouseWidget() = default; virtual ~AmigaMouseWidget() = default;
private: private:
uInt8 myGrayCodeTable[4] = { 0b00, 0b10, 0b11, 0b01 }; const std::array<uInt8, 4> myGrayCodeTable = { 0b00, 0b10, 0b11, 0b01 };
uInt8 getGrayCodeTable(const int index, const int direction) override; uInt8 getGrayCodeTable(const int index, const int direction) const override;
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
AmigaMouseWidget() = delete; AmigaMouseWidget() = delete;

View File

@ -24,7 +24,7 @@ AtariMouseWidget::AtariMouseWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 AtariMouseWidget::getGrayCodeTable(const int index, const int direction) uInt8 AtariMouseWidget::getGrayCodeTable(const int index, const int direction) const
{ {
return myGrayCodeTable[index]; return myGrayCodeTable[index];
} }

View File

@ -31,9 +31,9 @@ class AtariMouseWidget : public PointingDeviceWidget
virtual ~AtariMouseWidget() = default; virtual ~AtariMouseWidget() = default;
private: private:
uInt8 myGrayCodeTable[4] = { 0b00, 0b01, 0b11, 0b10 }; const std::array<uInt8, 4> myGrayCodeTable = { 0b00, 0b01, 0b11, 0b10 };
uInt8 getGrayCodeTable(const int index, const int direction) override; uInt8 getGrayCodeTable(const int index, const int direction) const override;
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
AtariMouseWidget() = delete; AtariMouseWidget() = delete;

View File

@ -141,28 +141,26 @@ void AudioWidget::handleVolume()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) void AudioWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{ {
switch(cmd) if(cmd == DataGridWidget::kItemDataChangedCmd)
{ {
case DataGridWidget::kItemDataChangedCmd: switch(id)
switch(id) {
{ case kAUDFID:
case kAUDFID: changeFrequencyRegs();
changeFrequencyRegs(); break;
break;
case kAUDCID: case kAUDCID:
changeControlRegs(); changeControlRegs();
break; break;
case kAUDVID: case kAUDVID:
changeVolumeRegs(); changeVolumeRegs();
break; break;
default: default:
cerr << "AudioWidget DG changed\n"; cerr << "AudioWidget DG changed\n";
break; break;
} }
break;
} }
} }
@ -181,6 +179,9 @@ void AudioWidget::changeFrequencyRegs()
case kAud1Addr: case kAud1Addr:
instance().debugger().tiaDebug().audF1(value); instance().debugger().tiaDebug().audF1(value);
break; break;
default:
break;
} }
} }
@ -199,6 +200,9 @@ void AudioWidget::changeControlRegs()
case kAud1Addr: case kAud1Addr:
instance().debugger().tiaDebug().audC1(value); instance().debugger().tiaDebug().audC1(value);
break; break;
default:
break;
} }
handleVolume(); handleVolume();
} }
@ -225,11 +229,12 @@ void AudioWidget::changeVolumeRegs()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 AudioWidget::getEffectiveVolume() uInt32 AudioWidget::getEffectiveVolume()
{ {
const int EFF_VOL[] = { static constexpr std::array<int, 31> EFF_VOL = {
0, 6, 13, 18, 24, 29, 33, 38, 0, 6, 13, 18, 24, 29, 33, 38,
42, 46, 50, 54, 57, 60, 64, 67, 42, 46, 50, 54, 57, 60, 64, 67,
70, 72, 75, 78, 80, 82, 85, 87, 70, 72, 75, 78, 80, 82, 85, 87,
89, 91, 93, 95, 97, 98,100}; 89, 91, 93, 95, 97, 98, 100
};
return EFF_VOL[(instance().debugger().tiaDebug().audC0() ? instance().debugger().tiaDebug().audV0() : 0) + return EFF_VOL[(instance().debugger().tiaDebug().audC0() ? instance().debugger().tiaDebug().audV0() : 0) +
(instance().debugger().tiaDebug().audC1() ? instance().debugger().tiaDebug().audV1() : 0)]; (instance().debugger().tiaDebug().audC1() ? instance().debugger().tiaDebug().audV1() : 0)];

View File

@ -115,12 +115,11 @@ void BoosterWidget::handleCommand(
myPins[id]->getState() ? Controller::MIN_RESISTANCE : myPins[id]->getState() ? Controller::MIN_RESISTANCE :
Controller::MAX_RESISTANCE); Controller::MAX_RESISTANCE);
break; break;
default:
break;
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Controller::DigitalPin BoosterWidget::ourPinNo[5] = { constexpr std::array<Controller::DigitalPin, 5> BoosterWidget::ourPinNo;
Controller::DigitalPin::One, Controller::DigitalPin::Two, Controller::DigitalPin::Three, Controller::DigitalPin::Four,
Controller::DigitalPin::Six
};

View File

@ -31,8 +31,12 @@ class BoosterWidget : public ControllerWidget
private: private:
enum { kJUp = 0, kJDown, kJLeft, kJRight, kJFire, kJBooster, kJTrigger }; enum { kJUp = 0, kJDown, kJLeft, kJRight, kJFire, kJBooster, kJTrigger };
CheckboxWidget* myPins[7]; std::array<CheckboxWidget*, 7> myPins;
static Controller::DigitalPin ourPinNo[5]; static constexpr std::array<Controller::DigitalPin, 5> ourPinNo = {{
Controller::DigitalPin::One, Controller::DigitalPin::Two,
Controller::DigitalPin::Three, Controller::DigitalPin::Four,
Controller::DigitalPin::Six
}};
private: private:
void loadConfig() override; void loadConfig() override;

View File

@ -87,7 +87,7 @@ string Cartridge0840Widget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$800", "$840" }; static const std::array<string, 2> spot = { "$800", "$840" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -137,7 +137,7 @@ void Cartridge3EPlusWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3EPlusWidget::handleCommand(CommandSender* sender, void Cartridge3EPlusWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id) int cmd, int data, int id)
{ {
uInt16 segment = 0; uInt16 segment = 0;
switch(cmd) switch(cmd)
@ -154,6 +154,8 @@ void Cartridge3EPlusWidget::handleCommand(CommandSender* sender,
case kBank3Changed: case kBank3Changed:
segment = 3; segment = 3;
break; break;
default:
break;
} }
// Ignore bank if either number or type hasn't been selected // Ignore bank if either number or type hasn't been selected
@ -330,6 +332,6 @@ uInt8 Cartridge3EPlusWidget::internalRamGetValue(int addr)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Cartridge3EPlusWidget::BankID Cartridge3EPlusWidget::bankEnum[4] = { const std::array<Cartridge3EPlusWidget::BankID, 4> Cartridge3EPlusWidget::bankEnum = {
kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed
}; };

View File

@ -40,10 +40,10 @@ class Cartridge3EPlusWidget : public CartDebugWidget
private: private:
Cartridge3EPlus& myCart; Cartridge3EPlus& myCart;
PopUpWidget* myBankNumber[4]; std::array<PopUpWidget*, 4> myBankNumber;
PopUpWidget* myBankType[4]; std::array<PopUpWidget*, 4> myBankType;
ButtonWidget* myBankCommit[4]; std::array<ButtonWidget*, 4> myBankCommit;
EditTextWidget* myBankState[8]; std::array<EditTextWidget*, 8> myBankState;
struct CartState { struct CartState {
ByteArray internalram; ByteArray internalram;
@ -56,7 +56,7 @@ class Cartridge3EPlusWidget : public CartDebugWidget
kBank2Changed = 'b2CH', kBank2Changed = 'b2CH',
kBank3Changed = 'b3CH' kBank3Changed = 'b3CH'
}; };
static const BankID bankEnum[4]; static const std::array<BankID, 4> bankEnum;
private: private:
void saveOldState() override; void saveOldState() override;

View File

@ -256,6 +256,9 @@ void Cartridge4A50Widget::handleCommand(CommandSender* sender,
myCart.bankROMHigh(0); myCart.bankROMHigh(0);
} }
break; break;
default:
break;
} }
myCart.lockBank(); myCart.lockBank();

View File

@ -159,7 +159,7 @@ string CartridgeBFSCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 64> spot = {
"$FF80", "$FF81", "$FF82", "$FF83", "$FF84", "$FF85", "$FF86", "$FF87", "$FF80", "$FF81", "$FF82", "$FF83", "$FF84", "$FF85", "$FF86", "$FF87",
"$FF88", "$FF89", "$FF8A", "$FF8B", "$FF8C", "$FF8D", "$FF8E", "$FF8F", "$FF88", "$FF89", "$FF8A", "$FF8B", "$FF8C", "$FF8D", "$FF8E", "$FF8F",
"$FF90", "$FF91", "$FF92", "$FF93", "$FF94", "$FF95", "$FF96", "$FF97", "$FF90", "$FF91", "$FF92", "$FF93", "$FF94", "$FF95", "$FF96", "$FF97",

View File

@ -149,7 +149,7 @@ string CartridgeBFWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 64> spot = {
"$FF80", "$FF81", "$FF82", "$FF83", "$FF84", "$FF85", "$FF86", "$FF87", "$FF80", "$FF81", "$FF82", "$FF83", "$FF84", "$FF85", "$FF86", "$FF87",
"$FF88", "$FF89", "$FF8A", "$FF8B", "$FF8C", "$FF8D", "$FF8E", "$FF8F", "$FF88", "$FF89", "$FF8A", "$FF8B", "$FF8C", "$FF8D", "$FF8E", "$FF8F",
"$FF90", "$FF91", "$FF92", "$FF93", "$FF94", "$FF95", "$FF96", "$FF97", "$FF90", "$FF91", "$FF92", "$FF93", "$FF94", "$FF95", "$FF96", "$FF97",

View File

@ -388,7 +388,7 @@ string CartridgeBUSWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 7> spot = {
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -63,9 +63,9 @@ class CartridgeBUSWidget : public CartDebugWidget
DataGridWidget* myMusicWaveforms; DataGridWidget* myMusicWaveforms;
DataGridWidget* myMusicWaveformSizes; DataGridWidget* myMusicWaveformSizes;
DataGridWidget* mySamplePointer; DataGridWidget* mySamplePointer;
StaticTextWidget* myDatastreamLabels[6];
CheckboxWidget* myBusOverdrive; CheckboxWidget* myBusOverdrive;
CheckboxWidget* myDigitalSample; CheckboxWidget* myDigitalSample;
std::array<StaticTextWidget*, 6> myDatastreamLabels;
CartState myOldState; CartState myOldState;
enum { kBankChanged = 'bkCH' }; enum { kBankChanged = 'bkCH' };

View File

@ -387,7 +387,7 @@ string CartridgeCDFWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 7> spot = {
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -65,7 +65,7 @@ class CartridgeCDFWidget : public CartDebugWidget
DataGridWidget* myMusicWaveforms; DataGridWidget* myMusicWaveforms;
DataGridWidget* myMusicWaveformSizes; DataGridWidget* myMusicWaveformSizes;
DataGridWidget* mySamplePointer; DataGridWidget* mySamplePointer;
StaticTextWidget* myDatastreamLabels[10]; std::array<StaticTextWidget*, 10> myDatastreamLabels;
CheckboxWidget* myFastFetch; CheckboxWidget* myFastFetch;
CheckboxWidget* myDigitalSample; CheckboxWidget* myDigitalSample;

View File

@ -50,9 +50,9 @@ class CartridgeCMWidget : public CartDebugWidget
ToggleBitWidget* mySWCHA; ToggleBitWidget* mySWCHA;
DataGridWidget* myColumn; DataGridWidget* myColumn;
CheckboxWidget *myAudIn, *myAudOut, *myIncrease, *myReset; CheckboxWidget *myAudIn, *myAudOut, *myIncrease, *myReset;
CheckboxWidget* myRow[4];
CheckboxWidget *myFunc, *myShift; CheckboxWidget *myFunc, *myShift;
EditTextWidget* myRAM; EditTextWidget* myRAM;
std::array<CheckboxWidget*, 4> myRow;
CartState myOldState; CartState myOldState;

View File

@ -92,7 +92,7 @@ string CartridgeCTYWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 8> spot = {
"", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
uInt16 bank = myCart.getBank(); uInt16 bank = myCart.getBank();

View File

@ -152,6 +152,8 @@ void CartridgeDASHWidget::handleCommand(CommandSender* sender,
case kBank3Changed: case kBank3Changed:
segment = 3; segment = 3;
break; break;
default:
break;
} }
// Ignore bank if either number or type hasn't been selected // Ignore bank if either number or type hasn't been selected
@ -364,6 +366,6 @@ uInt8 CartridgeDASHWidget::internalRamGetValue(int addr)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const CartridgeDASHWidget::BankID CartridgeDASHWidget::bankEnum[4] = { const std::array<CartridgeDASHWidget::BankID, 4> CartridgeDASHWidget::bankEnum = {
kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed kBank0Changed, kBank1Changed, kBank2Changed, kBank3Changed
}; };

View File

@ -40,10 +40,10 @@ class CartridgeDASHWidget : public CartDebugWidget
private: private:
CartridgeDASH& myCart; CartridgeDASH& myCart;
PopUpWidget* myBankNumber[4]; std::array<PopUpWidget*, 4> myBankNumber;
PopUpWidget* myBankType[4]; std::array<PopUpWidget*, 4> myBankType;
ButtonWidget* myBankCommit[4]; std::array<ButtonWidget*, 4> myBankCommit;
EditTextWidget* myBankState[8]; std::array<EditTextWidget*, 8> myBankState;
struct CartState { struct CartState {
ByteArray internalram; ByteArray internalram;
@ -56,7 +56,7 @@ class CartridgeDASHWidget : public CartDebugWidget
kBank2Changed = 'b2CH', kBank2Changed = 'b2CH',
kBank3Changed = 'b3CH' kBank3Changed = 'b3CH'
}; };
static const BankID bankEnum[4]; static const std::array<BankID, 4> bankEnum;
private: private:
void saveOldState() override; void saveOldState() override;

View File

@ -127,7 +127,7 @@ string CartridgeDFSCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 32> spot = {
"$FFC0", "$FFC1", "$FFC2", "$FFC3", "$FFC4", "$FFC5", "$FFC6", "$FFC7", "$FFC0", "$FFC1", "$FFC2", "$FFC3", "$FFC4", "$FFC5", "$FFC6", "$FFC7",
"$FFC8", "$FFC9", "$FFCA", "$FFCB", "$FFCC", "$FFCD", "$FFCE", "$FFCF", "$FFC8", "$FFC9", "$FFCA", "$FFCB", "$FFCC", "$FFCD", "$FFCE", "$FFCF",
"$FFD0", "$FFD1", "$FFD2", "$FFD3", "$FFD4", "$FFD5", "$FFD6", "$FFE7", "$FFD0", "$FFD1", "$FFD2", "$FFD3", "$FFD4", "$FFD5", "$FFD6", "$FFE7",

View File

@ -117,7 +117,7 @@ string CartridgeDFWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 32> spot = {
"$FFC0", "$FFC1", "$FFC2", "$FFC3", "$FFC4", "$FFC5", "$FFC6", "$FFC7", "$FFC0", "$FFC1", "$FFC2", "$FFC3", "$FFC4", "$FFC5", "$FFC6", "$FFC7",
"$FFC8", "$FFC9", "$FFCA", "$FFCB", "$FFCC", "$FFCD", "$FFCE", "$FFCF", "$FFC8", "$FFC9", "$FFCA", "$FFCB", "$FFCC", "$FFCD", "$FFCE", "$FFCF",
"$FFD0", "$FFD1", "$FFD2", "$FFD3", "$FFD4", "$FFD5", "$FFD6", "$FFD7", "$FFD0", "$FFD1", "$FFD2", "$FFD3", "$FFD4", "$FFD5", "$FFD6", "$FFD7",

View File

@ -229,7 +229,7 @@ string CartridgeDPCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$FFF8", "$FFF9" }; static constexpr std::array<const char*, 2> spot = { "$FFF8", "$FFF9" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -19,15 +19,15 @@
#include "PopUpWidget.hxx" #include "PopUpWidget.hxx"
#include "CartE0Widget.hxx" #include "CartE0Widget.hxx"
static const char* const seg0[] = { static constexpr std::array<const char*, 8> seg0 = {
"0 ($FFE0)", "1 ($FFE1)", "2 ($FFE2)", "3 ($FFE3)", "0 ($FFE0)", "1 ($FFE1)", "2 ($FFE2)", "3 ($FFE3)",
"4 ($FFE4)", "5 ($FFE5)", "6 ($FFE6)", "7 ($FFE7)" "4 ($FFE4)", "5 ($FFE5)", "6 ($FFE6)", "7 ($FFE7)"
}; };
static const char* const seg1[] = { static constexpr std::array<const char*, 8> seg1 = {
"0 ($FFE8)", "1 ($FFE9)", "2 ($FFEA)", "3 ($FFEB)", "0 ($FFE8)", "1 ($FFE9)", "2 ($FFEA)", "3 ($FFEB)",
"4 ($FFEC)", "5 ($FFED)", "6 ($FFEE)", "7 ($FFEF)" "4 ($FFEC)", "5 ($FFED)", "6 ($FFEE)", "7 ($FFEF)"
}; };
static const char* const seg2[] = { static constexpr std::array<const char*, 8> seg2 = {
"0 ($FFF0)", "1 ($FFF1)", "2 ($FFF2)", "3 ($FFF3)", "0 ($FFF0)", "1 ($FFF1)", "2 ($FFF2)", "3 ($FFF3)",
"4 ($FFF4)", "5 ($FFF5)", "6 ($FFF6)", "7 ($FFF7)" "4 ($FFF4)", "5 ($FFF5)", "6 ($FFF6)", "7 ($FFF7)"
}; };

View File

@ -52,7 +52,7 @@ CartridgeE78KWidget::CartridgeE78KWidget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE78KWidget::getSpotLower(int idx) const char* CartridgeE78KWidget::getSpotLower(int idx)
{ {
static const char* const spot_lower[] = { static constexpr std::array<const char*, 4> spot_lower = {
"0 - ROM ($FFE4)", "1 - ROM ($FFE5)", "2 - ROM ($FFE6)", "3 - RAM ($FFE7)" "0 - ROM ($FFE4)", "1 - ROM ($FFE5)", "2 - ROM ($FFE6)", "3 - RAM ($FFE7)"
}; };
@ -62,7 +62,7 @@ const char* CartridgeE78KWidget::getSpotLower(int idx)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE78KWidget::getSpotUpper(int idx) const char* CartridgeE78KWidget::getSpotUpper(int idx)
{ {
static const char* const spot_upper[] = { static constexpr std::array<const char*, 4> spot_upper = {
"0 - RAM ($FFE8)", "1 - RAM ($FFE9)", "2 - RAM ($FFEA)", "3 - RAM ($FFEB)" "0 - RAM ($FFE8)", "1 - RAM ($FFE9)", "2 - RAM ($FFEA)", "3 - RAM ($FFEB)"
}; };

View File

@ -51,7 +51,7 @@ CartridgeE7Widget::CartridgeE7Widget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE7Widget::getSpotLower(int idx) const char* CartridgeE7Widget::getSpotLower(int idx)
{ {
static const char* const spot_lower[] = { static constexpr std::array<const char*, 8> spot_lower = {
"0 - ROM ($FFE0)", "1 - ROM ($FFE1)", "2 - ROM ($FFE2)", "3 - ROM ($FFE3)", "0 - ROM ($FFE0)", "1 - ROM ($FFE1)", "2 - ROM ($FFE2)", "3 - ROM ($FFE3)",
"4 - ROM ($FFE4)", "5 - ROM ($FFE5)", "6 - ROM ($FFE6)", "7 - RAM ($FFE7)" "4 - ROM ($FFE4)", "5 - ROM ($FFE5)", "6 - ROM ($FFE6)", "7 - RAM ($FFE7)"
}; };
@ -62,7 +62,7 @@ const char* CartridgeE7Widget::getSpotLower(int idx)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* CartridgeE7Widget::getSpotUpper(int idx) const char* CartridgeE7Widget::getSpotUpper(int idx)
{ {
static const char* const spot_upper[] = { static constexpr std::array<const char*, 4> spot_upper = {
"0 - RAM ($FFE8)", "1 - RAM ($FFE9)", "2 - RAM ($FFEA)", "3 - RAM ($FFEB)" "0 - RAM ($FFE8)", "1 - RAM ($FFE9)", "2 - RAM ($FFEA)", "3 - RAM ($FFEB)"
}; };

View File

@ -111,7 +111,7 @@ string CartridgeEFSCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 16> spot = {
"$FFE0", "$FFE1", "$FFE2", "$FFE3", "$FFE4", "$FFE5", "$FFE6", "$FFE7", "$FFE0", "$FFE1", "$FFE2", "$FFE3", "$FFE4", "$FFE5", "$FFE6", "$FFE7",
"$FFE8", "$FFE9", "$FFEA", "$FFEB", "$FFEC", "$FFED", "$FFEE", "$FFEF" "$FFE8", "$FFE9", "$FFEA", "$FFEB", "$FFEC", "$FFED", "$FFEE", "$FFEF"
}; };

View File

@ -101,7 +101,7 @@ string CartridgeEFWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 16> spot = {
"$FFE0", "$FFE1", "$FFE2", "$FFE3", "$FFE4", "$FFE5", "$FFE6", "$FFE7", "$FFE0", "$FFE1", "$FFE2", "$FFE3", "$FFE4", "$FFE5", "$FFE6", "$FFE7",
"$FFE8", "$FFE9", "$FFEA", "$FFEB", "$FFEC", "$FFED", "$FFEE", "$FFEF" "$FFE8", "$FFE9", "$FFEA", "$FFEB", "$FFEC", "$FFED", "$FFEE", "$FFEF"
}; };

View File

@ -102,7 +102,7 @@ string CartridgeF4SCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 8> spot = {
"$FFF4", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF4", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -92,7 +92,7 @@ string CartridgeF4Widget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 8> spot = {
"$FFF4", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF4", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -98,7 +98,7 @@ string CartridgeF6SCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$FFF6", "$FFF7", "$FFF8", "$FFF9" }; static constexpr std::array<const char*, 4> spot = { "$FFF6", "$FFF7", "$FFF8", "$FFF9" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -88,7 +88,7 @@ string CartridgeF6Widget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$FFF6", "$FFF7", "$FFF8", "$FFF9" }; static constexpr std::array<const char*, 4> spot = { "$FFF6", "$FFF7", "$FFF8", "$FFF9" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -96,7 +96,7 @@ string CartridgeF8SCWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$FFF8", "$FFF9" }; static constexpr std::array<const char*, 2> spot = { "$FFF8", "$FFF9" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -86,7 +86,7 @@ string CartridgeF8Widget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$FFF8", "$FFF9" }; static constexpr std::array<const char*, 2> spot = { "$FFF8", "$FFF9" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -140,6 +140,9 @@ void CartridgeFA2Widget::handleCommand(CommandSender* sender,
case kFlashSave: case kFlashSave:
myCart.flash(2); myCart.flash(2);
break; break;
default:
break;
} }
} }
@ -148,7 +151,7 @@ string CartridgeFA2Widget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { static constexpr std::array<const char*, 7> spot = {
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -97,7 +97,7 @@ string CartridgeFAWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$FFF8", "$FFF9", "$FFFA" }; static constexpr std::array<const char*, 3> spot = { "$FFF8", "$FFF9", "$FFFA" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()]; << ", hotspot = " << spot[myCart.getBank()];

View File

@ -79,7 +79,7 @@ string CartridgeFEWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const range[] = { "$F000", "$D000" }; static constexpr std::array<const char*, 2> range = { "$F000", "$D000" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", address range = " << range[myCart.getBank()]; << ", address range = " << range[myCart.getBank()];

View File

@ -39,7 +39,7 @@ CartridgeMDMWidget::CartridgeMDMWidget(
ypos = addBaseInformation(size, "Edwin Blink", info.str(), 15) + myLineHeight; ypos = addBaseInformation(size, "Edwin Blink", info.str(), 15) + myLineHeight;
VariantList items; VariantList items;
for(uInt32 i = 0x800; i < (0x800u + myCart.bankCount()); ++i) for(uInt32 i = 0x800; i < (0x800U + myCart.bankCount()); ++i)
{ {
info.str(""); info.str("");
info << std::dec << (i & 0xFF) << " ($" << Common::Base::HEX4 << i << ")"; info << std::dec << (i & 0xFF) << " ($" << Common::Base::HEX4 << i << ")";

View File

@ -98,6 +98,8 @@ void CartridgeMNetworkWidget::handleCommand(CommandSender* sender,
case kUpperChanged: case kUpperChanged:
myCart.bankRAM(myUpper256B->getSelected()); myCart.bankRAM(myUpper256B->getSelected());
break; break;
default:
break;
} }
myCart.lockBank(); myCart.lockBank();

View File

@ -110,8 +110,8 @@ CartRamWidget::InternalRamWidget::InternalRamWidget(GuiObject* boss,
int x, int y, int w, int h, int x, int y, int w, int h,
CartDebugWidget& dbg) CartDebugWidget& dbg)
: RamWidget(boss, lfont, nfont, x, y, w, h, : RamWidget(boss, lfont, nfont, x, y, w, h,
dbg.internalRamSize(), std::min(dbg.internalRamSize() / 16, 16u), dbg.internalRamSize(), std::min(dbg.internalRamSize() / 16, 16U),
std::min(dbg.internalRamSize() / 16, 16u) * 16), std::min(dbg.internalRamSize() / 16, 16U) * 16),
myCart(dbg) myCart(dbg)
{ {
} }

View File

@ -96,9 +96,9 @@ string CartridgeUAWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const spot[] = { "$220, $2A0", "$240, $2C0" }; static constexpr std::array<const char*, 2> spot = { "$220, $2A0", "$240, $2C0" };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspots = " << spot[myCart.getBank() ^ (mySwappedHotspots ? 1u : 0u)]; << ", hotspots = " << spot[myCart.getBank() ^ (mySwappedHotspots ? 1U : 0U)];
return buf.str(); return buf.str();
} }

View File

@ -101,7 +101,7 @@ string CartridgeWDWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static const char* const segments[] = { static constexpr std::array<const char*, 8> segments = {
"[0,0,1,3]", "[0,1,2,3]", "[4,5,6,7]", "[7,4,2,3]", "[0,0,1,3]", "[0,1,2,3]", "[4,5,6,7]", "[7,4,2,3]",
"[0,0,6,7]", "[0,1,7,6]", "[2,3,4,5]", "[6,0,5,1]" "[0,0,6,7]", "[0,1,7,6]", "[2,3,4,5]", "[6,0,5,1]"
}; };

View File

@ -108,4 +108,4 @@ void DrivingWidget::setValue(int idx)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 DrivingWidget::ourGrayTable[4] = { 0x03, 0x01, 0x00, 0x02 }; const std::array<uInt8, 4> DrivingWidget::ourGrayTable = { 0x03, 0x01, 0x00, 0x02 };

View File

@ -44,7 +44,7 @@ class DrivingWidget : public ControllerWidget
int myGrayIndex; int myGrayIndex;
static uInt8 ourGrayTable[4]; static const std::array<uInt8, 4> ourGrayTable;
private: private:
void loadConfig() override; void loadConfig() override;

View File

@ -25,7 +25,7 @@ FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font,
: ControllerWidget(boss, font, x, y, controller), : ControllerWidget(boss, font, x, y, controller),
myEEPROMEraseCurrent(nullptr) myEEPROMEraseCurrent(nullptr)
{ {
std::fill(myPage, myPage + MAX_PAGES, nullptr); myPage.fill(nullptr);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -38,7 +38,7 @@ class FlashWidget : public ControllerWidget
enum { kEEPROMEraseCurrent = 'eeEC' }; enum { kEEPROMEraseCurrent = 'eeEC' };
static constexpr uInt32 MAX_PAGES = 5; static constexpr uInt32 MAX_PAGES = 5;
StaticTextWidget* myPage[MAX_PAGES]; std::array<StaticTextWidget*, MAX_PAGES> myPage;
private: private:
void loadConfig() override; void loadConfig() override;

View File

@ -46,7 +46,7 @@ class PointingDeviceWidget : public ControllerWidget
CheckboxWidget* myFire; CheckboxWidget* myFire;
private: private:
virtual uInt8 getGrayCodeTable(const int index, const int direction) = 0; virtual uInt8 getGrayCodeTable(const int index, const int direction) const = 0;
void loadConfig() override; void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -24,7 +24,7 @@ TrakBallWidget::TrakBallWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TrakBallWidget::getGrayCodeTable(const int index, const int direction) uInt8 TrakBallWidget::getGrayCodeTable(const int index, const int direction) const
{ {
return myGrayCodeTable[(index & 0b1) + direction * 2]; return myGrayCodeTable[(index & 0b1) + direction * 2];
} }

View File

@ -31,9 +31,9 @@ class TrakBallWidget : public PointingDeviceWidget
virtual ~TrakBallWidget() = default; virtual ~TrakBallWidget() = default;
private: private:
uInt8 myGrayCodeTable[4] = { 0b00, 0b10, 0b01, 0b11 }; const std::array<uInt8, 4> myGrayCodeTable = { 0b00, 0b10, 0b01, 0b11 };
uInt8 getGrayCodeTable(const int index, const int direction) override; uInt8 getGrayCodeTable(const int index, const int direction) const override;
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
TrakBallWidget() = delete; TrakBallWidget() = delete;

View File

@ -20,7 +20,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Bankswitch::typeToName(Bankswitch::Type type) string Bankswitch::typeToName(Bankswitch::Type type)
{ {
return BSList[int(type)].name; return BSList[static_cast<int>(type)].name;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -36,7 +36,7 @@ Bankswitch::Type Bankswitch::nameToType(const string& name)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Bankswitch::typeToDesc(Bankswitch::Type type) string Bankswitch::typeToDesc(Bankswitch::Type type)
{ {
return BSList[int(type)].desc; return BSList[static_cast<int>(type)].desc;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -92,7 +92,8 @@ bool Bankswitch::isValidRomName(const string& name)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Bankswitch::Description Bankswitch::BSList[int(Bankswitch::Type::NumSchemes)] = { const std::array<Bankswitch::Description, static_cast<int>(Bankswitch::Type::NumSchemes)>
Bankswitch::BSList = {{
{ "AUTO" , "Auto-detect" }, { "AUTO" , "Auto-detect" },
{ "0840" , "0840 (8K ECONObank)" }, { "0840" , "0840 (8K ECONObank)" },
{ "2IN1" , "2IN1 Multicart (4-32K)" }, { "2IN1" , "2IN1 Multicart (4-32K)" },
@ -149,7 +150,7 @@ Bankswitch::Description Bankswitch::BSList[int(Bankswitch::Type::NumSchemes)] =
#if defined(CUSTOM_ARM) #if defined(CUSTOM_ARM)
{ "CUSTOM" , "CUSTOM (ARM)" } { "CUSTOM" , "CUSTOM (ARM)" }
#endif #endif
}; }};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Bankswitch::ExtensionMap Bankswitch::ourExtensions = { Bankswitch::ExtensionMap Bankswitch::ourExtensions = {

View File

@ -58,7 +58,7 @@ class Bankswitch
const char* const name; const char* const name;
const char* const desc; const char* const desc;
}; };
static Description BSList[int(Type::NumSchemes)]; static const std::array<Description, static_cast<int>(Type::NumSchemes)> BSList;
public: public:
// Convert BSType enum to string // Convert BSType enum to string
@ -95,10 +95,10 @@ class Bankswitch
return BSPF::compareIgnoreCase(a, b) < 0; return BSPF::compareIgnoreCase(a, b) < 0;
} }
}; };
using ExtensionMap = std::map<string, Bankswitch::Type, TypeComparator>; using ExtensionMap = const std::map<string, Bankswitch::Type, TypeComparator>;
static ExtensionMap ourExtensions; static ExtensionMap ourExtensions;
using NameToTypeMap = std::map<string, Bankswitch::Type, TypeComparator>; using NameToTypeMap = const std::map<string, Bankswitch::Type, TypeComparator>;
static NameToTypeMap ourNameToTypes; static NameToTypeMap ourNameToTypes;
private: private:

View File

@ -336,7 +336,7 @@ class Cartridge : public Device
bool myBankLocked; bool myBankLocked;
// Semi-random values to use when a read from write port occurs // Semi-random values to use when a read from write port occurs
uInt8 myRWPRandomValues[256]; std::array<uInt8, 256> myRWPRandomValues;
// Contains various info about this cartridge // Contains various info about this cartridge
// This needs to be stored separately from child classes, since // This needs to be stored separately from child classes, since

View File

@ -480,6 +480,9 @@ uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
case 3: case 3:
myMusicWaveformSize[value1] = value2; myMusicWaveformSize[value1] = value2;
break; break;
default:
break;
} }
return 0; return 0;

View File

@ -589,7 +589,7 @@ inline void CartridgeCTY::updateMusicModeDataFetchers()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 CartridgeCTY::ourFrequencyTable[63] = const std::array<uInt32, 63> CartridgeCTY::ourFrequencyTable =
{ {
// this should really be referenced from within the ROM, but its part of // this should really be referenced from within the ROM, but its part of
// the Harmony/Melody CTY Driver, which does not appear to be in the ROM. // the Harmony/Melody CTY Driver, which does not appear to be in the ROM.

View File

@ -309,7 +309,7 @@ class CartridgeCTY : public Cartridge
// Indicates the offset into the ROM image (aligns to current bank) // Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset; uInt16 myBankOffset;
static const uInt32 ourFrequencyTable[63]; static const std::array<uInt32, 63> ourFrequencyTable;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -145,7 +145,7 @@ inline void CartridgeDPCPlus::clockRandomNumberGenerator()
inline void CartridgeDPCPlus::priorClockRandomNumberGenerator() inline void CartridgeDPCPlus::priorClockRandomNumberGenerator()
{ {
// Update random number generator (32-bit LFSR, reversed) // Update random number generator (32-bit LFSR, reversed)
myRandomNumber = ((myRandomNumber & (1u<<31)) ? myRandomNumber = ((myRandomNumber & (1U<<31)) ?
((0x10adab1e^myRandomNumber) << 11) | ((0x10adab1e^myRandomNumber) >> 21) : ((0x10adab1e^myRandomNumber) << 11) | ((0x10adab1e^myRandomNumber) >> 21) :
(myRandomNumber << 11) | (myRandomNumber >> 21)); (myRandomNumber << 11) | (myRandomNumber >> 21));
} }
@ -288,6 +288,9 @@ uInt8 CartridgeDPCPlus::peek(uInt16 address)
case 0x06: // reserved case 0x06: // reserved
case 0x07: // reserved case 0x07: // reserved
break; break;
default:
break;
} }
break; break;
} }

View File

@ -57,15 +57,10 @@ uInt8 CartridgeFC::peek(uInt16 address)
address &= 0x0FFF; address &= 0x0FFF;
// Switch banks if necessary // Switch banks if necessary
switch (address) if(address == 0x0FFC)
{ {
case 0x0FFC: // Trigger the bank switch
// Trigger the bank switch bank(myTargetBank);
bank(myTargetBank);
break;
default:
break;
} }
return myImage[myBankOffset + address]; return myImage[myBankOffset + address];

View File

@ -309,7 +309,7 @@ bool CartridgeWD::load(Serializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeWD::BankOrg CartridgeWD::ourBankOrg[8] = { const std::array<CartridgeWD::BankOrg, 8> CartridgeWD::ourBankOrg = {{
// 0 1 2 3 4 5 6 7 // 0 1 2 3 4 5 6 7
{ 0, 0, 1, 3 }, // Bank 0, 8 2 1 - 1 - - - - { 0, 0, 1, 3 }, // Bank 0, 8 2 1 - 1 - - - -
{ 0, 1, 2, 3 }, // Bank 1, 9 1 1 1 1 - - - - { 0, 1, 2, 3 }, // Bank 1, 9 1 1 1 1 - - - -
@ -320,4 +320,4 @@ CartridgeWD::BankOrg CartridgeWD::ourBankOrg[8] = {
{ 2, 3, 4, 5 }, // Bank 6, 14 - - 1 1 1 1 - - { 2, 3, 4, 5 }, // Bank 6, 14 - - 1 1 1 1 - -
{ 6, 0, 5, 1 } // Bank 7, 15 1 1 - - - 1 1 - { 6, 0, 5, 1 } // Bank 7, 15 1 1 - - - 1 1 -
// count 7 4 3 4 3 3 4 4 // count 7 4 3 4 3 3 4 4
}; }};

View File

@ -231,7 +231,7 @@ class CartridgeWD : public Cartridge
struct BankOrg { struct BankOrg {
uInt8 zero, one, two, three; uInt8 zero, one, two, three;
}; };
static BankOrg ourBankOrg[8]; static const std::array<BankOrg, 8> ourBankOrg;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -107,7 +107,7 @@ bool Controller::load(Serializer& in)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::getName(const Type type) string Controller::getName(const Type type)
{ {
string NAMES[int(Controller::Type::LastType)] = static const std::array<string, int(Controller::Type::LastType)> NAMES =
{ {
"Unknown", "Unknown",
"AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate", "AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate",
@ -121,7 +121,7 @@ string Controller::getName(const Type type)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::getPropName(const Type type) string Controller::getPropName(const Type type)
{ {
string PROP_NAMES[int(Controller::Type::LastType)] = static const std::array<string, int(Controller::Type::LastType)> PROP_NAMES =
{ {
"AUTO", "AUTO",
"AMIGAMOUSE", "ATARIMOUSE", "ATARIVOX", "BOOSTERGRIP", "COMPUMATE", "AMIGAMOUSE", "ATARIMOUSE", "ATARIVOX", "BOOSTERGRIP", "COMPUMATE",

View File

@ -469,7 +469,7 @@ class EventHandler
; ;
// The event(s) assigned to each combination event // The event(s) assigned to each combination event
Event::Type myComboTable[COMBO_SIZE][EVENTS_PER_COMBO]; BSPF::array2D<Event::Type, COMBO_SIZE, EVENTS_PER_COMBO> myComboTable;
// Holds static strings for the remap menu (emulation and menu events) // Holds static strings for the remap menu (emulation and menu events)
using EmulActionList = std::array<ActionList, EMUL_ACTIONLIST_SIZE>; using EmulActionList = std::array<ActionList, EMUL_ACTIONLIST_SIZE>;

View File

@ -238,7 +238,7 @@ uInt32 FilesystemNode::read(ByteBuffer& image) const
if (length == 0) if (length == 0)
throw runtime_error("Zero-byte file"); throw runtime_error("Zero-byte file");
size = std::min(uInt32(length), 512u * 1024u); size = std::min<uInt32>(length, 512 * 1024);
in.read(reinterpret_cast<char*>(image.get()), size); in.read(reinterpret_cast<char*>(image.get()), size);
} }
else else

View File

@ -907,7 +907,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
for(auto& mode: myFullscreenModeLists) for(auto& mode: myFullscreenModeLists)
mode.clear(); mode.clear();
for(size_t i = myFullscreenModeLists.size(); i < myFullscreenDisplays.size(); ++i) for(size_t i = myFullscreenModeLists.size(); i < myFullscreenDisplays.size(); ++i)
myFullscreenModeLists.push_back(VideoModeList()); myFullscreenModeLists.emplace_back(VideoModeList());
// Check if zooming is allowed for this state (currently only allowed // Check if zooming is allowed for this state (currently only allowed
// for TIA screens) // for TIA screens)

View File

@ -222,13 +222,13 @@ void Paddles::update()
int sa_yaxis = myEvent.get(myP1AxisValue); int sa_yaxis = myEvent.get(myP1AxisValue);
int new_val; int new_val;
const double bFac[MAX_DEJITTER - MIN_DEJITTER + 1] = { static constexpr std::array<double, MAX_DEJITTER - MIN_DEJITTER + 1> bFac = {
// higher values mean more dejitter strength // higher values mean more dejitter strength
0, // off 0, // off
0.50, 0.59, 0.67, 0.74, 0.80, 0.50, 0.59, 0.67, 0.74, 0.80,
0.85, 0.89, 0.92, 0.94, 0.95 0.85, 0.89, 0.92, 0.94, 0.95
}; };
const double dFac[MAX_DEJITTER - MIN_DEJITTER + 1] = { static constexpr std::array<double, MAX_DEJITTER - MIN_DEJITTER + 1> dFac = {
// lower values mean more dejitter strength // lower values mean more dejitter strength
1, // off 1, // off
1.0 / 181, 1.0 / 256, 1.0 / 362, 1.0 / 512, 1.0 / 724, 1.0 / 181, 1.0 / 256, 1.0 / 362, 1.0 / 512, 1.0 / 724,
@ -430,6 +430,4 @@ int Paddles::DEJITTER_BASE = 0;
int Paddles::DEJITTER_DIFF = 0; int Paddles::DEJITTER_DIFF = 0;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Controller::DigitalPin Paddles::ourButtonPin[2] = { const std::array<Controller::DigitalPin, 2> Paddles::ourButtonPin;
DigitalPin::Four, DigitalPin::Three
};

View File

@ -48,7 +48,6 @@ class Paddles : public Controller
virtual ~Paddles() = default; virtual ~Paddles() = default;
public: public:
static constexpr int MAX_DIGITAL_SENSE = 20; static constexpr int MAX_DIGITAL_SENSE = 20;
static constexpr int MAX_MOUSE_SENSE = 20; static constexpr int MAX_MOUSE_SENSE = 20;
static constexpr int MIN_DEJITTER = 0; static constexpr int MIN_DEJITTER = 0;
@ -147,7 +146,7 @@ class Paddles : public Controller
bool myKeyRepeat0, myKeyRepeat1; bool myKeyRepeat0, myKeyRepeat1;
int myPaddleRepeat0, myPaddleRepeat1; int myPaddleRepeat0, myPaddleRepeat1;
int myCharge[2], myLastCharge[2]; std::array<int, 2> myCharge, myLastCharge;
int myLastAxisX, myLastAxisY; int myLastAxisX, myLastAxisY;
int myAxisDigitalZero, myAxisDigitalOne; int myAxisDigitalZero, myAxisDigitalOne;
@ -163,7 +162,9 @@ class Paddles : public Controller
// Lookup table for associating paddle buttons with controller pins // Lookup table for associating paddle buttons with controller pins
// Yes, this is hideously complex // Yes, this is hideously complex
static const Controller::DigitalPin ourButtonPin[2]; static constexpr std::array<Controller::DigitalPin, 2> ourButtonPin = {
DigitalPin::Four, DigitalPin::Three
};
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -58,7 +58,7 @@ Thumbulator::Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, uInt16 rom_size
Cartridge* cartridge) Cartridge* cartridge)
: rom(rom_ptr), : rom(rom_ptr),
romSize(rom_size), romSize(rom_size),
decodedRom(new Op[romSize / 2]), decodedRom(make_unique<Op[]>(romSize / 2)),
ram(ram_ptr), ram(ram_ptr),
T1TCR(0), T1TCR(0),
T1TC(0), T1TC(0),
@ -994,7 +994,7 @@ int Thumbulator::execute()
if(rc & 0x80000000) if(rc & 0x80000000)
{ {
do_cflag_bit(1); do_cflag_bit(1);
rc = ~0u; rc = ~0U;
} }
else else
{ {
@ -1008,7 +1008,7 @@ int Thumbulator::execute()
ra = rc & 0x80000000; ra = rc & 0x80000000;
rc >>= rb; rc >>= rb;
if(ra) //asr, sign is shifted in if(ra) //asr, sign is shifted in
rc |= (~0u) << (32-rb); rc |= (~0U) << (32-rb);
} }
write_register(rd, rc); write_register(rd, rc);
do_nflag(rc); do_nflag(rc);
@ -1034,7 +1034,7 @@ int Thumbulator::execute()
rc >>= rb; rc >>= rb;
if(ra) //asr, sign is shifted in if(ra) //asr, sign is shifted in
{ {
rc |= (~0u) << (32-rb); rc |= (~0U) << (32-rb);
} }
} }
else else
@ -1042,7 +1042,7 @@ int Thumbulator::execute()
if(rc & 0x80000000) if(rc & 0x80000000)
{ {
do_cflag_bit(1); do_cflag_bit(1);
rc = (~0u); rc = (~0U);
} }
else else
{ {
@ -1060,7 +1060,7 @@ int Thumbulator::execute()
case Op::b1: { case Op::b1: {
rb = (inst >> 0) & 0xFF; rb = (inst >> 0) & 0xFF;
if(rb & 0x80) if(rb & 0x80)
rb |= (~0u) << 8; rb |= (~0U) << 8;
op=(inst >> 8) & 0xF; op=(inst >> 8) & 0xF;
rb <<= 1; rb <<= 1;
rb += pc; rb += pc;
@ -1175,7 +1175,7 @@ int Thumbulator::execute()
case Op::b2: { case Op::b2: {
rb = (inst >> 0) & 0x7FF; rb = (inst >> 0) & 0x7FF;
if(rb & (1 << 10)) if(rb & (1 << 10))
rb |= (~0u) << 11; rb |= (~0U) << 11;
rb <<= 1; rb <<= 1;
rb += pc; rb += pc;
rb += 2; rb += 2;
@ -1771,7 +1771,7 @@ int Thumbulator::execute()
} }
rc &= 0xFF; rc &= 0xFF;
if(rc & 0x80) if(rc & 0x80)
rc |= ((~0u) << 8); rc |= ((~0U) << 8);
write_register(rd, rc); write_register(rd, rc);
return 0; return 0;
} }
@ -1786,7 +1786,7 @@ int Thumbulator::execute()
rc = read16(rb); rc = read16(rb);
rc &= 0xFFFF; rc &= 0xFFFF;
if(rc & 0x8000) if(rc & 0x8000)
rc |= ((~0u) << 16); rc |= ((~0U) << 16);
write_register(rd, rc); write_register(rd, rc);
return 0; return 0;
} }
@ -2442,7 +2442,7 @@ int Thumbulator::execute()
ra = read_register(rm); ra = read_register(rm);
rc = ra & 0xFF; rc = ra & 0xFF;
if(rc & 0x80) if(rc & 0x80)
rc |= (~0u) << 8; rc |= (~0U) << 8;
write_register(rd, rc); write_register(rd, rc);
return 0; return 0;
} }
@ -2455,7 +2455,7 @@ int Thumbulator::execute()
ra = read_register(rm); ra = read_register(rm);
rc = ra & 0xFFFF; rc = ra & 0xFFFF;
if(rc & 0x8000) if(rc & 0x8000)
rc |= (~0u) << 16; rc |= (~0U) << 16;
write_register(rd, rc); write_register(rd, rc);
return 0; return 0;
} }
@ -2513,7 +2513,7 @@ int Thumbulator::execute()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Thumbulator::reset() int Thumbulator::reset()
{ {
std::fill(reg_norm, reg_norm+12, 0); reg_norm.fill(0);
reg_norm[13] = 0x40001FB4; reg_norm[13] = 0x40001FB4;
switch(configuration) switch(configuration)

View File

@ -187,10 +187,10 @@ class Thumbulator
private: private:
const uInt16* rom; const uInt16* rom;
uInt16 romSize; uInt16 romSize;
const unique_ptr<Op[]> decodedRom; const unique_ptr<Op[]> decodedRom; // NOLINT
uInt16* ram; uInt16* ram;
uInt32 reg_norm[16]; // normal execution mode, do not have a thread mode std::array<uInt32, 16> reg_norm; // normal execution mode, do not have a thread mode
uInt32 cpsr, mamcr; uInt32 cpsr, mamcr;
bool handler_mode; bool handler_mode;
uInt32 systick_ctrl, systick_reload, systick_count, systick_calibrate; uInt32 systick_ctrl, systick_reload, systick_count, systick_calibrate;

View File

@ -789,6 +789,9 @@ bool TIA::poke(uInt16 address, uInt8 value)
myCollisionMask = 0; myCollisionMask = 0;
myShadowRegisters[address] = value; myShadowRegisters[address] = value;
break; break;
default:
break;
} }
return true; return true;
@ -1670,6 +1673,9 @@ void TIA::delayedWrite(uInt8 address, uInt8 value)
case ENAM1: case ENAM1:
myMissile1.enam(value); myMissile1.enam(value);
break; break;
default:
break;
} }
} }

View File

@ -539,7 +539,7 @@ class TIA : public Device
* Palette and indices for fixed debug colors. * Palette and indices for fixed debug colors.
*/ */
enum FixedObject { P0, M0, P1, M1, PF, BL, BK }; enum FixedObject { P0, M0, P1, M1, PF, BL, BK };
FixedColor myFixedColorPalette[3][7]; BSPF::array2D<FixedColor, 3, 7> myFixedColorPalette;
std::array<string, 7> myFixedColorNames; std::array<string, 7> myFixedColorNames;
private: private:

View File

@ -138,11 +138,10 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
wid.push_back(myRandomizeCPULabel); wid.push_back(myRandomizeCPULabel);
int xpos = myRandomizeCPULabel->getRight() + 10; int xpos = myRandomizeCPULabel->getRight() + 10;
const char* const cpuregs[] = { "SP", "A", "X", "Y", "PS" };
for(int i = 0; i < 5; ++i) for(int i = 0; i < 5; ++i)
{ {
myRandomizeCPUWidget[i] = new CheckboxWidget(myTab, font, xpos, ypos + 1, myRandomizeCPUWidget[i] = new CheckboxWidget(myTab, font, xpos, ypos + 1,
cpuregs[i], kRandCPUID); ourCPUregs[i], kRandCPUID);
wid.push_back(myRandomizeCPUWidget[i]); wid.push_back(myRandomizeCPUWidget[i]);
xpos += CheckboxWidget::boxSize() + font.getStringWidth("XX") + 20; xpos += CheckboxWidget::boxSize() + font.getStringWidth("XX") + 20;
} }
@ -331,7 +330,7 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font)
VarList::push_back(items, "Purple", "p"); VarList::push_back(items, "Purple", "p");
VarList::push_back(items, "Blue", "b"); VarList::push_back(items, "Blue", "b");
static constexpr int dbg_cmds[DEBUG_COLORS] = { static constexpr std::array<int, DEBUG_COLORS> dbg_cmds = {
kP0ColourChangedCmd, kM0ColourChangedCmd, kP1ColourChangedCmd, kP0ColourChangedCmd, kM0ColourChangedCmd, kP1ColourChangedCmd,
kM1ColourChangedCmd, kPFColourChangedCmd, kBLColourChangedCmd kM1ColourChangedCmd, kPFColourChangedCmd, kBLColourChangedCmd
}; };
@ -367,7 +366,7 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) void DeveloperDialog::addTimeMachineTab(const GUI::Font& font)
{ {
const string INTERVALS[NUM_INTERVALS] = { const std::array<string, NUM_INTERVALS> INTERVALS = {
" 1 frame", " 1 frame",
" 3 frames", " 3 frames",
"10 frames", "10 frames",
@ -376,7 +375,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font)
" 3 seconds", " 3 seconds",
"10 seconds" "10 seconds"
}; };
const string INT_SETTINGS[NUM_INTERVALS] = { const std::array<string, NUM_INTERVALS> INT_SETTINGS = {
"1f", "1f",
"3f", "3f",
"10f", "10f",
@ -385,7 +384,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font)
"3s", "3s",
"10s" "10s"
}; };
const string HORIZONS[NUM_HORIZONS] = { const std::array<string, NUM_HORIZONS> HORIZONS = {
" 3 seconds", " 3 seconds",
"10 seconds", "10 seconds",
"30 seconds", "30 seconds",
@ -395,7 +394,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font)
"30 minutes", "30 minutes",
"60 minutes" "60 minutes"
}; };
const string HOR_SETTINGS[NUM_HORIZONS] = { const std::array<string, NUM_HORIZONS> HOR_SETTINGS = {
"3s", "3s",
"10s", "10s",
"30s", "30s",
@ -724,10 +723,9 @@ void DeveloperDialog::getWidgetStates(SettingsSet set)
myRandomBank[set] = myRandomBankWidget->getState(); myRandomBank[set] = myRandomBankWidget->getState();
myRandomizeRAM[set] = myRandomizeRAMWidget->getState(); myRandomizeRAM[set] = myRandomizeRAMWidget->getState();
string cpurandom; string cpurandom;
const char* const cpuregs[] = { "S", "A", "X", "Y", "P" };
for(int i = 0; i < 5; ++i) for(int i = 0; i < 5; ++i)
if(myRandomizeCPUWidget[i]->getState()) if(myRandomizeCPUWidget[i]->getState())
cpurandom += cpuregs[i]; cpurandom += ourCPUregs[i];
myRandomizeCPU[set] = cpurandom; myRandomizeCPU[set] = cpurandom;
// Undriven TIA pins // Undriven TIA pins
myUndrivenPins[set] = myUndrivenPinsWidget->getState(); myUndrivenPins[set] = myUndrivenPinsWidget->getState();
@ -777,9 +775,8 @@ void DeveloperDialog::setWidgetStates(SettingsSet set)
myRandomizeRAMWidget->setState(myRandomizeRAM[set]); myRandomizeRAMWidget->setState(myRandomizeRAM[set]);
const string& cpurandom = myRandomizeCPU[set]; const string& cpurandom = myRandomizeCPU[set];
const char* const cpuregs[] = { "S", "A", "X", "Y", "P" };
for(int i = 0; i < 5; ++i) for(int i = 0; i < 5; ++i)
myRandomizeCPUWidget[i]->setState(BSPF::containsIgnoreCase(cpurandom, cpuregs[i])); myRandomizeCPUWidget[i]->setState(BSPF::containsIgnoreCase(cpurandom, ourCPUregs[i]));
// Undriven TIA pins // Undriven TIA pins
myUndrivenPinsWidget->setState(myUndrivenPins[set]); myUndrivenPinsWidget->setState(myUndrivenPins[set]);
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
@ -1387,7 +1384,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color)
return; return;
} }
static constexpr ColorId dbg_color[3][DEBUG_COLORS] = { static constexpr BSPF::array2D<ColorId, 3, DEBUG_COLORS> dbg_color = {{
{ {
TIA::FixedColor::NTSC_RED, TIA::FixedColor::NTSC_RED,
TIA::FixedColor::NTSC_ORANGE, TIA::FixedColor::NTSC_ORANGE,
@ -1412,7 +1409,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color)
TIA::FixedColor::SECAM_PURPLE, TIA::FixedColor::SECAM_PURPLE,
TIA::FixedColor::SECAM_BLUE TIA::FixedColor::SECAM_BLUE
} }
}; }};
int timing = instance().console().timing() == ConsoleTiming::ntsc ? 0 int timing = instance().console().timing() == ConsoleTiming::ntsc ? 0
: instance().console().timing() == ConsoleTiming::pal ? 1 : 2; : instance().console().timing() == ConsoleTiming::pal ? 1 : 2;
@ -1421,7 +1418,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color)
myDbgColour[idx]->setSelectedIndex(color); myDbgColour[idx]->setSelectedIndex(color);
// make sure the selected debug colors are all different // make sure the selected debug colors are all different
bool usedCol[DEBUG_COLORS]; std::array<bool, DEBUG_COLORS> usedCol;
// identify used colors // identify used colors
for(int i = 0; i < DEBUG_COLORS; ++i) for(int i = 0; i < DEBUG_COLORS; ++i)
@ -1507,3 +1504,8 @@ void DeveloperDialog::handleFontSize()
myDebuggerHeightSlider->setValue(minH); myDebuggerHeightSlider->setValue(minH);
#endif #endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const std::array<string, 5> DeveloperDialog::ourCPUregs = {
"SP", "A", "X", "Y", "PS"
};

View File

@ -95,8 +95,8 @@ class DeveloperDialog : public Dialog
CheckboxWidget* myRandomBankWidget; CheckboxWidget* myRandomBankWidget;
CheckboxWidget* myRandomizeRAMWidget; CheckboxWidget* myRandomizeRAMWidget;
StaticTextWidget* myRandomizeCPULabel; StaticTextWidget* myRandomizeCPULabel;
CheckboxWidget* myRandomizeCPUWidget[5];
CheckboxWidget* myUndrivenPinsWidget; CheckboxWidget* myUndrivenPinsWidget;
std::array<CheckboxWidget*, 5> myRandomizeCPUWidget;
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
CheckboxWidget* myRWPortBreakWidget; CheckboxWidget* myRWPortBreakWidget;
CheckboxWidget* myWRPortBreakWidget; CheckboxWidget* myWRPortBreakWidget;
@ -125,8 +125,8 @@ class DeveloperDialog : public Dialog
StaticTextWidget* myTVJitterRecLabelWidget; StaticTextWidget* myTVJitterRecLabelWidget;
CheckboxWidget* myColorLossWidget; CheckboxWidget* myColorLossWidget;
CheckboxWidget* myDebugColorsWidget; CheckboxWidget* myDebugColorsWidget;
PopUpWidget* myDbgColour[DEBUG_COLORS]; std::array<PopUpWidget*, DEBUG_COLORS> myDbgColour;
ColorWidget* myDbgColourSwatch[DEBUG_COLORS]; std::array<ColorWidget*, DEBUG_COLORS> myDbgColourSwatch;
// States widgets // States widgets
RadioButtonGroup* mySettingsGroupTM; RadioButtonGroup* mySettingsGroupTM;
@ -148,37 +148,39 @@ class DeveloperDialog : public Dialog
bool mySettings; bool mySettings;
// Emulator sets // Emulator sets
bool myFrameStats[2]; std::array<bool, 2> myFrameStats;
int myConsole[2]; std::array<int, 2> myConsole;
bool myRandomBank[2]; std::array<bool, 2> myRandomBank;
bool myRandomizeRAM[2]; std::array<bool, 2> myRandomizeRAM;
string myRandomizeCPU[2]; std::array<string, 2> myRandomizeCPU;
bool myColorLoss[2]; std::array<bool, 2> myColorLoss;
bool myTVJitter[2]; std::array<bool, 2> myTVJitter;
int myTVJitterRec[2]; std::array<int, 2> myTVJitterRec;
bool myDebugColors[2]; std::array<bool, 2> myDebugColors;
bool myUndrivenPins[2]; std::array<bool, 2> myUndrivenPins;
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
bool myRWPortBreak[2]; std::array<bool, 2> myRWPortBreak;
bool myWRPortBreak[2]; std::array<bool, 2> myWRPortBreak;
#endif #endif
bool myThumbException[2]; std::array<bool, 2> myThumbException;
bool myEEPROMAccess[2]; std::array<bool, 2> myEEPROMAccess;
// TIA sets // TIA sets
string myTIAType[2]; std::array<string, 2> myTIAType;
bool myPlInvPhase[2]; std::array<bool, 2> myPlInvPhase;
bool myMsInvPhase[2]; std::array<bool, 2> myMsInvPhase;
bool myBlInvPhase[2]; std::array<bool, 2> myBlInvPhase;
bool myPFBits[2]; std::array<bool, 2> myPFBits;
bool myPFColor[2]; std::array<bool, 2> myPFColor;
bool myPlSwap[2]; std::array<bool, 2> myPlSwap;
bool myBlSwap[2]; std::array<bool, 2> myBlSwap;
// States sets // States sets
bool myTimeMachine[2]; std::array<bool, 2> myTimeMachine;
int myStateSize[2]; std::array<int, 2> myStateSize;
int myUncompressed[2]; std::array<int, 2> myUncompressed;
string myStateInterval[2]; std::array<string, 2> myStateInterval;
string myStateHorizon[2]; std::array<string, 2> myStateHorizon;
static const std::array<string, 5> ourCPUregs;
private: private:
void addEmulationTab(const GUI::Font& font); void addEmulationTab(const GUI::Font& font);

View File

@ -509,5 +509,8 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup), instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup),
instance().eventHandler().actionAtIndex(myActionSelected, myEventGroup)); instance().eventHandler().actionAtIndex(myActionSelected, myEventGroup));
break; break;
default:
break;
} }
} }

View File

@ -179,7 +179,7 @@ int GlobalPropsDialog::addHoldWidgets(const GUI::Font& font, int x, int y,
ypos += myHoldSelect->getHeight() + VGAP; ypos += myHoldSelect->getHeight() + VGAP;
myHoldReset = new CheckboxWidget(this, font, xpos, ypos, "Reset"); myHoldReset = new CheckboxWidget(this, font, xpos, ypos, "Reset");
const int TAB_ORDER[10] = { static constexpr std::array<int, 10> TAB_ORDER = {
kJ0Up, kJ0Left, kJ0Right, kJ0Down, kJ0Fire, kJ0Up, kJ0Left, kJ0Right, kJ0Down, kJ0Fire,
kJ1Up, kJ1Left, kJ1Right, kJ1Down, kJ1Fire kJ1Up, kJ1Left, kJ1Right, kJ1Down, kJ1Fire
}; };
@ -292,6 +292,6 @@ void GlobalPropsDialog::handleCommand(CommandSender* sender, int cmd,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* const GlobalPropsDialog::ourJoyState[10] = { const std::array<string, 10> GlobalPropsDialog::ourJoyState = {
"U", "D", "L", "R", "F", "U", "D", "L", "R", "F" "U", "D", "L", "R", "F", "U", "D", "L", "R", "F"
}; };

View File

@ -54,11 +54,11 @@ class GlobalPropsDialog : public Dialog, public CommandSender
PopUpWidget* myTVType; PopUpWidget* myTVType;
PopUpWidget* myDebug; PopUpWidget* myDebug;
CheckboxWidget* myJoy[10]; std::array<CheckboxWidget*, 10> myJoy;
CheckboxWidget* myHoldSelect; CheckboxWidget* myHoldSelect;
CheckboxWidget* myHoldReset; CheckboxWidget* myHoldReset;
static const char* const ourJoyState[10]; static const std::array<string, 10> ourJoyState;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -166,6 +166,9 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
ADD_TEXT("'Options/Input" + ELLIPSIS + "' dialog for"); ADD_TEXT("'Options/Input" + ELLIPSIS + "' dialog for");
ADD_TEXT("more information."); ADD_TEXT("more information.");
break; break;
default:
break;
} }
while(i < lines) while(i < lines)

View File

@ -45,10 +45,10 @@ class HelpDialog : public Dialog
ButtonWidget* myPrevButton; ButtonWidget* myPrevButton;
StaticTextWidget* myTitle; StaticTextWidget* myTitle;
StaticTextWidget* myKey[LINES_PER_PAGE]; std::array<StaticTextWidget*, LINES_PER_PAGE> myKey;
StaticTextWidget* myDesc[LINES_PER_PAGE]; std::array<StaticTextWidget*, LINES_PER_PAGE> myDesc;
string myKeyStr[LINES_PER_PAGE]; std::array<string, LINES_PER_PAGE> myKeyStr;
string myDescStr[LINES_PER_PAGE]; std::array<string, LINES_PER_PAGE> myDescStr;
uInt8 myPage; uInt8 myPage;
uInt8 myNumPages; uInt8 myNumPages;

View File

@ -388,18 +388,16 @@ void ListWidget::lostFocusWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{ {
switch (cmd) if (cmd == GuiObject::kSetPositionCmd)
{ {
case GuiObject::kSetPositionCmd: if (_currentPos != data)
if (_currentPos != data) {
{ _currentPos = data;
_currentPos = data; setDirty();
setDirty();
// Let boss know the list has scrolled // Let boss know the list has scrolled
sendCommand(ListWidget::kScrolledCmd, _currentPos, _id); sendCommand(ListWidget::kScrolledCmd, _currentPos, _id);
} }
break;
} }
} }

View File

@ -79,24 +79,17 @@ void MessageBox::addText(const GUI::Font& font, const StringList& text)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageBox::handleCommand(CommandSender* sender, int cmd, int data, int id) void MessageBox::handleCommand(CommandSender* sender, int cmd, int data, int id)
{ {
switch(cmd) if(cmd == GuiObject::kOKCmd)
{ {
case GuiObject::kOKCmd: close();
{
close();
// Send a signal to the calling class that 'OK' has been selected // Send a signal to the calling class that 'OK' has been selected
// Since we aren't derived from a widget, we don't have a 'data' or 'id' // Since we aren't derived from a widget, we don't have a 'data' or 'id'
if(myCmd) if(myCmd)
sendCommand(myCmd, 0, 0); sendCommand(myCmd, 0, 0);
break;
}
default:
Dialog::handleCommand(sender, cmd, data, id);
break;
} }
else
Dialog::handleCommand(sender, cmd, data, id);
} }
} // namespace GUI } // namespace GUI

View File

@ -250,6 +250,9 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd,
case kExitGameCmd: case kExitGameCmd:
instance().eventHandler().handleEvent(Event::ExitMode); instance().eventHandler().handleEvent(Event::ExitMode);
break; break;
default:
return;
} }
// Console commands should be performed right away, after leaving the menu // Console commands should be performed right away, after leaving the menu

View File

@ -23,18 +23,6 @@
#include "DialogContainer.hxx" #include "DialogContainer.hxx"
#include "PopUpWidget.hxx" #include "PopUpWidget.hxx"
// Little down arrow
static uInt32 down_arrow[8] = {
0b100000001,
0b110000011,
0b111000111,
0b011101110,
0b001111100,
0b000111000,
0b000010000,
0b000000000
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, const VariantList& list, int x, int y, int w, int h, const VariantList& list,
@ -192,6 +180,18 @@ void PopUpWidget::handleCommand(CommandSender* sender, int cmd, int data, int id
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::drawWidget(bool hilite) void PopUpWidget::drawWidget(bool hilite)
{ {
// Little down arrow
static constexpr std::array<uInt32, 8> down_arrow = {
0b100000001,
0b110000011,
0b111000111,
0b011101110,
0b001111100,
0b000111000,
0b000010000,
0b000000000
};
//cerr << "PopUpWidget::drawWidget\n"; //cerr << "PopUpWidget::drawWidget\n";
FBSurface& s = dialog().surface(); FBSurface& s = dialog().surface();
bool onTop = _boss->dialog().isOnTop(); bool onTop = _boss->dialog().isOnTop();
@ -212,7 +212,7 @@ void PopUpWidget::drawWidget(bool hilite)
s.fillRect(x + 1, _y + 1, w - 17, _h - 2, onTop ? _changed ? kDbgChangedColor : kWidColor : kDlgColor); s.fillRect(x + 1, _y + 1, w - 17, _h - 2, onTop ? _changed ? kDbgChangedColor : kWidColor : kDlgColor);
s.fillRect(x + w - 15, _y + 2, 13, _h - 4, onTop ? isEnabled() && hilite ? kWidColor : kBGColorHi : kBGColorLo); s.fillRect(x + w - 15, _y + 2, 13, _h - 4, onTop ? isEnabled() && hilite ? kWidColor : kBGColorHi : kBGColorLo);
// Draw an arrow pointing down at the right end to signal this is a dropdown/popup // Draw an arrow pointing down at the right end to signal this is a dropdown/popup
s.drawBitmap(down_arrow, x + w - 13, _y + myArrowsY + 1, s.drawBitmap(down_arrow.data(), x + w - 13, _y + myArrowsY + 1,
!(isEnabled() && onTop) ? kColor : kTextColor, 9U, 8U); !(isEnabled() && onTop) ? kColor : kTextColor, 9U, 8U);
// Draw the selected entry, if any // Draw the selected entry, if any

View File

@ -161,6 +161,9 @@ void R77HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
ADD_TEXT("and consult the 'Options/Input" + ELLIPSIS + "'"); ADD_TEXT("and consult the 'Options/Input" + ELLIPSIS + "'");
ADD_TEXT("dialog for more information."); ADD_TEXT("dialog for more information.");
break; break;
default:
return;
} }
while (i < lines) while (i < lines)

View File

@ -46,12 +46,12 @@ class R77HelpDialog : public Dialog
ButtonWidget* myPrevButton; ButtonWidget* myPrevButton;
StaticTextWidget* myTitle; StaticTextWidget* myTitle;
StaticTextWidget* myJoy[LINES_PER_PAGE]; std::array<StaticTextWidget*, LINES_PER_PAGE> myJoy;
StaticTextWidget* myBtn[LINES_PER_PAGE]; std::array<StaticTextWidget*, LINES_PER_PAGE> myBtn;
StaticTextWidget* myDesc[LINES_PER_PAGE]; std::array<StaticTextWidget*, LINES_PER_PAGE> myDesc;
string myJoyStr[LINES_PER_PAGE]; std::array<string, LINES_PER_PAGE> myJoyStr;
string myBtnStr[LINES_PER_PAGE]; std::array<string, LINES_PER_PAGE> myBtnStr;
string myDescStr[LINES_PER_PAGE]; std::array<string, LINES_PER_PAGE> myDescStr;
uInt8 myPage; uInt8 myPage;
uInt8 myNumPages; uInt8 myNumPages;

View File

@ -21,66 +21,26 @@
#include "RadioButtonWidget.hxx" #include "RadioButtonWidget.hxx"
/* Radiobutton bitmaps */ /* Radiobutton bitmaps */
static uInt32 radio_img_outercircle[14] = static constexpr std::array<uInt32, 14> radio_img_outercircle = {
{ 0b00001111110000, 0b00110000001100, 0b01000000000010,
0b00001111110000, 0b01000000000010, 0b10000000000001, 0b10000000000001,
0b00110000001100, 0b10000000000001, 0b10000000000001, 0b10000000000001,
0b01000000000010, 0b10000000000001, 0b01000000000010, 0b01000000000010,
0b01000000000010, 0b00110000001100, 0b00001111110000
0b10000000000001,
0b10000000000001,
0b10000000000001,
0b10000000000001,
0b10000000000001,
0b10000000000001,
0b01000000000010,
0b01000000000010,
0b00110000001100,
0b00001111110000
}; };
static constexpr std::array<uInt32, 12> radio_img_innercircle = {
static uInt32 radio_img_innercircle[12] = 0b000111111000, 0b011111111110, 0b011111111110, 0b111111111111,
{ 0b111111111111, 0b111111111111, 0b111111111111, 0b111111111111,
0b000111111000, 0b111111111111, 0b011111111110, 0b011111111110, 0b000111111000
0b011111111110,
0b011111111110,
0b111111111111,
0b111111111111,
0b111111111111,
0b111111111111,
0b111111111111,
0b111111111111,
0b011111111110,
0b011111111110,
0b000111111000
}; };
static constexpr uInt32 RADIO_IMG_FILL_SIZE = 10;
static uInt32 radio_img_active[10] = static constexpr std::array<uInt32, RADIO_IMG_FILL_SIZE> radio_img_active = {
{ 0b0011111100, 0b0111111110, 0b1111111111, 0b1111111111, 0b1111111111,
0b0011111100, 0b1111111111, 0b1111111111, 0b1111111111, 0b0111111110, 0b0011111100,
0b0111111110,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b0111111110,
0b0011111100,
}; };
static constexpr std::array<uInt32, RADIO_IMG_FILL_SIZE> radio_img_inactive = {
static uInt32 radio_img_inactive[10] = 0b0011111100, 0b0111111110, 0b1111001111, 0b1110000111, 0b1100000011,
{ 0b1100000011, 0b1110000111, 0b1111001111, 0b0111111110, 0b0011111100
0b0011111100,
0b0111111110,
0b1111001111,
0b1110000111,
0b1100000011,
0b1100000011,
0b1110000111,
0b1111001111,
0b0111111110,
0b0011111100
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -144,10 +104,10 @@ void RadioButtonWidget::setFill(FillType type)
switch(type) switch(type)
{ {
case CheckboxWidget::FillType::Normal: case CheckboxWidget::FillType::Normal:
_img = radio_img_active; _img = radio_img_active.data();
break; break;
case CheckboxWidget::FillType::Inactive: case CheckboxWidget::FillType::Inactive:
_img = radio_img_inactive; _img = radio_img_inactive.data();
break; break;
default: default:
break; break;
@ -160,17 +120,20 @@ void RadioButtonWidget::drawWidget(bool hilite)
FBSurface& s = _boss->dialog().surface(); FBSurface& s = _boss->dialog().surface();
// Draw the outer bounding circle // Draw the outer bounding circle
s.drawBitmap(radio_img_outercircle, _x, _y + _boxY, hilite ? kWidColorHi : kColor, 14, 14); s.drawBitmap(radio_img_outercircle.data(), _x, _y + _boxY,
hilite ? kWidColorHi : kColor,
radio_img_outercircle.size(), radio_img_outercircle.size());
// Draw the inner bounding circle with enabled color // Draw the inner bounding circle with enabled color
s.drawBitmap(radio_img_innercircle, _x + 1, _y + _boxY + 1, isEnabled() s.drawBitmap(radio_img_innercircle.data(), _x + 1, _y + _boxY + 1,
? _bgcolor : kColor, 12, 12); isEnabled() ? _bgcolor : kColor,
radio_img_innercircle.size(), radio_img_innercircle.size());
// draw state // draw state
if(_state) if(_state)
s.drawBitmap(_img, _x + 2, _y + _boxY + 2, isEnabled() s.drawBitmap(_img, _x + 2, _y + _boxY + 2, isEnabled()
? hilite ? kWidColorHi : kCheckColor ? hilite ? kWidColorHi : kCheckColor
: kColor, 10); : kColor, RADIO_IMG_FILL_SIZE);
// Finally draw the label // Finally draw the label
s.drawString(_font, _label, _x + 20, _y + _textY, _w, s.drawString(_font, _label, _x + 20, _y + _textY, _w,

View File

@ -30,30 +30,6 @@
#define UP_DOWN_BOX_HEIGHT 18 #define UP_DOWN_BOX_HEIGHT 18
// Up arrow
static uInt32 up_arrow[8] = {
0b00000000,
0b00010000,
0b00111000,
0b01111100,
0b11101110,
0b11000110,
0b10000010,
0b00000000
};
// Down arrow
static uInt32 down_arrow[8] = {
0b00000000,
0b10000010,
0b11000110,
0b11101110,
0b01111100,
0b00111000,
0b00010000,
0b00000000
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ScrollBarWidget::ScrollBarWidget(GuiObject* boss, const GUI::Font& font, ScrollBarWidget::ScrollBarWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h) int x, int y, int w, int h)
@ -247,6 +223,30 @@ void ScrollBarWidget::recalc()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::drawWidget(bool hilite) void ScrollBarWidget::drawWidget(bool hilite)
{ {
// Up arrow
static constexpr std::array<uInt32, 8> up_arrow = {
0b00000000,
0b00010000,
0b00111000,
0b01111100,
0b11101110,
0b11000110,
0b10000010,
0b00000000
};
// Down arrow
static constexpr std::array<uInt32, 8> down_arrow = {
0b00000000,
0b10000010,
0b11000110,
0b11101110,
0b01111100,
0b00111000,
0b00010000,
0b00000000
};
//cerr << "ScrollBarWidget::drawWidget\n"; //cerr << "ScrollBarWidget::drawWidget\n";
FBSurface& s = _boss->dialog().surface(); FBSurface& s = _boss->dialog().surface();
bool onTop = _boss->dialog().isOnTop(); bool onTop = _boss->dialog().isOnTop();
@ -261,18 +261,16 @@ void ScrollBarWidget::drawWidget(bool hilite)
// Up arrow // Up arrow
if(hilite && _part == kUpArrowPart) if(hilite && _part == kUpArrowPart)
s.fillRect(_x + 1, _y + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor); s.fillRect(_x + 1, _y + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor);
s.drawBitmap(up_arrow, _x+4, _y+5, s.drawBitmap(up_arrow.data(), _x+4, _y+5,
onTop onTop ? isSinglePage ? kColor : (hilite && _part == kUpArrowPart) ? kWidColor
? isSinglePage ? kColor : (hilite && _part == kUpArrowPart) ? kWidColor : kTextColor : kTextColor : kColor, 8);
: kColor, 8);
// Down arrow // Down arrow
if(hilite && _part == kDownArrowPart) if(hilite && _part == kDownArrowPart)
s.fillRect(_x + 1, bottomY - UP_DOWN_BOX_HEIGHT + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor); s.fillRect(_x + 1, bottomY - UP_DOWN_BOX_HEIGHT + 1, _w - 2, UP_DOWN_BOX_HEIGHT - 2, kScrollColor);
s.drawBitmap(down_arrow, _x+4, bottomY - UP_DOWN_BOX_HEIGHT + 5, s.drawBitmap(down_arrow.data(), _x+4, bottomY - UP_DOWN_BOX_HEIGHT + 5,
onTop onTop ? isSinglePage ? kColor : (hilite && _part == kDownArrowPart) ?
? isSinglePage ? kColor : (hilite && _part == kDownArrowPart) ? kWidColor : kTextColor kWidColor : kTextColor : kColor, 8);
: kColor, 8);
// Slider // Slider
if(!isSinglePage) if(!isSinglePage)

View File

@ -465,8 +465,10 @@ void StellaSettingsDialog::loadControllerProperties(const Properties& props)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int StellaSettingsDialog::levelToValue(int level) int StellaSettingsDialog::levelToValue(int level)
{ {
const int NUM_LEVELS = 11; constexpr int NUM_LEVELS = 11;
uInt8 values[NUM_LEVELS] = { 0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95 }; static constexpr std::array<uInt8, NUM_LEVELS> values = {
0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95
};
return values[std::min(level, NUM_LEVELS - 1)]; return values[std::min(level, NUM_LEVELS - 1)];
} }
@ -474,10 +476,12 @@ int StellaSettingsDialog::levelToValue(int level)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int StellaSettingsDialog::valueToLevel(int value) int StellaSettingsDialog::valueToLevel(int value)
{ {
const int NUM_LEVELS = 11; constexpr int NUM_LEVELS = 11;
uInt8 values[NUM_LEVELS] = { 0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95 }; static constexpr std::array<uInt8, NUM_LEVELS> values = {
0, 5, 11, 18, 26, 35, 45, 56, 68, 81, 95
};
for (uInt32 i = NUM_LEVELS - 1; i > 0; --i) for (int i = NUM_LEVELS - 1; i > 0; --i)
{ {
if (value >= values[i]) if (value >= values[i])
return i; return i;

View File

@ -34,10 +34,9 @@
#include "Base.hxx" #include "Base.hxx"
using Common::Base; using Common::Base;
const int BUTTON_W = 14, BUTTON_H = 14; static constexpr int BUTTON_W = 14, BUTTON_H = 14;
static uInt32 RECORD[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> RECORD = {
{
0b00000111100000, 0b00000111100000,
0b00011111111000, 0b00011111111000,
0b00111111111100, 0b00111111111100,
@ -53,9 +52,7 @@ static uInt32 RECORD[BUTTON_H] =
0b00011111111000, 0b00011111111000,
0b00000111100000 0b00000111100000
}; };
static constexpr std::array<uInt32, BUTTON_H> STOP = {
static uInt32 STOP[BUTTON_H] =
{
0b11111111111111, 0b11111111111111,
0b11111111111111, 0b11111111111111,
0b11111111111111, 0b11111111111111,
@ -71,9 +68,7 @@ static uInt32 STOP[BUTTON_H] =
0b11111111111111, 0b11111111111111,
0b11111111111111 0b11111111111111
}; };
static constexpr std::array<uInt32, BUTTON_H> PLAY = {
static uInt32 PLAY[BUTTON_H] =
{
0b11000000000000, 0b11000000000000,
0b11110000000000, 0b11110000000000,
0b11111100000000, 0b11111100000000,
@ -89,8 +84,7 @@ static uInt32 PLAY[BUTTON_H] =
0b11110000000000, 0b11110000000000,
0b11000000000000 0b11000000000000
}; };
static uInt32 REWIND_ALL[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> REWIND_ALL = {
{
0, 0,
0b11000011000011, 0b11000011000011,
0b11000111000111, 0b11000111000111,
@ -106,8 +100,7 @@ static uInt32 REWIND_ALL[BUTTON_H] =
0b11000011000011, 0b11000011000011,
0 0
}; };
static uInt32 REWIND_1[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> REWIND_1 = {
{
0, 0,
0b00000110001110, 0b00000110001110,
0b00001110001110, 0b00001110001110,
@ -123,8 +116,7 @@ static uInt32 REWIND_1[BUTTON_H] =
0b00000110001110, 0b00000110001110,
0 0
}; };
static uInt32 UNWIND_1[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> UNWIND_1 = {
{
0, 0,
0b01110001100000, 0b01110001100000,
0b01110001110000, 0b01110001110000,
@ -140,8 +132,7 @@ static uInt32 UNWIND_1[BUTTON_H] =
0b01110001100000, 0b01110001100000,
0 0
}; };
static uInt32 UNWIND_ALL[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> UNWIND_ALL = {
{
0, 0,
0b11000011000011, 0b11000011000011,
0b11100011100011, 0b11100011100011,
@ -157,8 +148,7 @@ static uInt32 UNWIND_ALL[BUTTON_H] =
0b11000011000011, 0b11000011000011,
0 0
}; };
static uInt32 SAVE_ALL[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> SAVE_ALL = {
{
0b00000111100000, 0b00000111100000,
0b00000111100000, 0b00000111100000,
0b00000111100000, 0b00000111100000,
@ -174,8 +164,7 @@ static uInt32 SAVE_ALL[BUTTON_H] =
0b11111111111111, 0b11111111111111,
0b11111111111111, 0b11111111111111,
}; };
static uInt32 LOAD_ALL[BUTTON_H] = static constexpr std::array<uInt32, BUTTON_H> LOAD_ALL = {
{
0b00000011000000, 0b00000011000000,
0b00000111100000, 0b00000111100000,
0b00001111110000, 0b00001111110000,
@ -241,41 +230,41 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4; xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4;
// Add buttons // Add buttons
myToggleWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, STOP, myToggleWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kToggle); STOP.data(), BUTTON_W, BUTTON_H, kToggle);
xpos += buttonWidth + BUTTON_GAP; xpos += buttonWidth + BUTTON_GAP;
myPlayWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, PLAY, myPlayWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kPlay); PLAY.data(), BUTTON_W, BUTTON_H, kPlay);
xpos += buttonWidth + BUTTON_GAP * 4; xpos += buttonWidth + BUTTON_GAP * 4;
myRewindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_ALL, myRewindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kRewindAll); REWIND_ALL.data(), BUTTON_W, BUTTON_H, kRewindAll);
xpos += buttonWidth + BUTTON_GAP; xpos += buttonWidth + BUTTON_GAP;
myRewind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_1, myRewind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kRewind1, true); REWIND_1.data(), BUTTON_W, BUTTON_H, kRewind1, true);
xpos += buttonWidth + BUTTON_GAP; xpos += buttonWidth + BUTTON_GAP;
myUnwind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_1, myUnwind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kUnwind1, true); UNWIND_1.data(), BUTTON_W, BUTTON_H, kUnwind1, true);
xpos += buttonWidth + BUTTON_GAP; xpos += buttonWidth + BUTTON_GAP;
myUnwindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_ALL, myUnwindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kUnwindAll); UNWIND_ALL.data(), BUTTON_W, BUTTON_H, kUnwindAll);
xpos = myUnwindAllWidget->getRight() + BUTTON_GAP * 4; xpos = myUnwindAllWidget->getRight() + BUTTON_GAP * 4;
mySaveAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, SAVE_ALL, mySaveAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kSaveAll); SAVE_ALL.data(), BUTTON_W, BUTTON_H, kSaveAll);
xpos = mySaveAllWidget->getRight() + BUTTON_GAP; xpos = mySaveAllWidget->getRight() + BUTTON_GAP;
myLoadAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, LOAD_ALL, myLoadAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
BUTTON_W, BUTTON_H, kLoadAll); LOAD_ALL.data(), BUTTON_W, BUTTON_H, kLoadAll);
xpos = myLoadAllWidget->getRight() + BUTTON_GAP * 4; xpos = myLoadAllWidget->getRight() + BUTTON_GAP * 4;
// Add message // Add message
myMessageWidget = new StaticTextWidget(this, font, xpos, ypos + 3, " ", myMessageWidget = new StaticTextWidget(this, font, xpos, ypos + 3,
TextAlign::Left, kBGColor); " ", TextAlign::Left, kBGColor);
myMessageWidget->setTextColor(kColorInfo); myMessageWidget->setTextColor(kColorInfo);
} }
@ -479,6 +468,6 @@ void TimeMachineDialog::handleWinds(Int32 numWinds)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimeMachineDialog::handleToggle() void TimeMachineDialog::handleToggle()
{ {
myToggleWidget->setBitmap(instance().state().mode() == StateManager::Mode::Off ? RECORD : STOP, myToggleWidget->setBitmap(instance().state().mode() == StateManager::Mode::Off ?
BUTTON_W, BUTTON_H); RECORD.data() : STOP.data(), BUTTON_W, BUTTON_H);
} }

View File

@ -337,9 +337,7 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StaticTextWidget::setValue(int value) void StaticTextWidget::setValue(int value)
{ {
char buf[256]; _label = std::to_string(value);
std::snprintf(buf, 255, "%d", value);
_label = buf;
setDirty(); setDirty();
} }
@ -406,14 +404,14 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font, ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, int x, int y, int w, int h,
uInt32* bitmap, int bmw, int bmh, const uInt32* bitmap, int bmw, int bmh,
int cmd, bool repeat) int cmd, bool repeat)
: ButtonWidget(boss, font, x, y, w, h, "", cmd, repeat) : ButtonWidget(boss, font, x, y, w, h, "", cmd, repeat)
{ {
_bitmap = bitmap;
_bmh = bmh;
_bmw = bmw;
_useBitmap = true; _useBitmap = true;
_bitmap = bitmap;
_bmw = bmw;
_bmh = bmh;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -431,20 +429,15 @@ void ButtonWidget::handleMouseLeft()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ButtonWidget::handleEvent(Event::Type e) bool ButtonWidget::handleEvent(Event::Type e)
{ {
if(!isEnabled()) if(!isEnabled() || e != Event::UISelect)
return false; return false;
switch(e) // Simulate mouse event
{ handleMouseUp(0, 0, MouseButton::LEFT, 0);
case Event::UISelect: return true;
// Simulate mouse event
handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true;
default:
return false;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ButtonWidget::handleMouseClicks(int x, int y, MouseButton b) bool ButtonWidget::handleMouseClicks(int x, int y, MouseButton b)
{ {
return _repeat; return _repeat;
@ -471,12 +464,12 @@ void ButtonWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::setBitmap(uInt32* bitmap, int bmw, int bmh) void ButtonWidget::setBitmap(const uInt32* bitmap, int bmw, int bmh)
{ {
_useBitmap = true;
_bitmap = bitmap; _bitmap = bitmap;
_bmh = bmh; _bmh = bmh;
_bmw = bmw; _bmw = bmw;
_useBitmap = true;
setDirty(); setDirty();
} }
@ -502,50 +495,6 @@ void ButtonWidget::drawWidget(bool hilite)
setDirty(); setDirty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* 8x8 checkbox bitmap */
static uInt32 checked_img_active[10] =
{
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111
};
static uInt32 checked_img_inactive[10] =
{
0b1111111111,
0b1111111111,
0b1111001111,
0b1110000111,
0b1100000011,
0b1100000011,
0b1110000111,
0b1111001111,
0b1111111111,
0b1111111111
};
static uInt32 checked_img_circle[10] =
{
0b0001111000,
0b0111111110,
0b0111111110,
0b1111111111,
0b1111111111,
0b1111111111,
0b1111111111,
0b0111111110,
0b0111111110,
0b0001111000
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font, CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, const string& label, int x, int y, const string& label,
@ -625,18 +574,34 @@ void CheckboxWidget::setEditable(bool editable)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::setFill(FillType type) void CheckboxWidget::setFill(FillType type)
{ {
/* 8x8 checkbox bitmap */
static constexpr std::array<uInt32, 10> checked_img_active = {
0b1111111111, 0b1111111111, 0b1111111111, 0b1111111111, 0b1111111111,
0b1111111111, 0b1111111111, 0b1111111111, 0b1111111111, 0b1111111111
};
static constexpr std::array<uInt32, 10> checked_img_inactive = {
0b1111111111, 0b1111111111, 0b1111001111, 0b1110000111, 0b1100000011,
0b1100000011, 0b1110000111, 0b1111001111, 0b1111111111, 0b1111111111
};
static constexpr std::array<uInt32, 10> checked_img_circle = {
0b0001111000, 0b0111111110, 0b0111111110, 0b1111111111, 0b1111111111,
0b1111111111, 0b1111111111, 0b0111111110, 0b0111111110, 0b0001111000
};
switch(type) switch(type)
{ {
case CheckboxWidget::FillType::Normal: case CheckboxWidget::FillType::Normal:
_img = checked_img_active; _img = checked_img_active.data();
_drawBox = true; _drawBox = true;
break; break;
case CheckboxWidget::FillType::Inactive: case CheckboxWidget::FillType::Inactive:
_img = checked_img_inactive; _img = checked_img_inactive.data();
_drawBox = true; _drawBox = true;
break; break;
case CheckboxWidget::FillType::Circle: case CheckboxWidget::FillType::Circle:
_img = checked_img_circle; _img = checked_img_circle.data();
_drawBox = false; _drawBox = false;
break; break;
} }
@ -765,10 +730,7 @@ void SliderWidget::setValueLabel(const string& valueLabel)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::setValueLabel(int value) void SliderWidget::setValueLabel(int value)
{ {
char buf[256]; _valueLabel = std::to_string(value);
std::snprintf(buf, 255, "%d", value);
_valueLabel = buf;
setDirty(); setDirty();
} }

Some files were not shown because too many files have changed in this diff Show More