mirror of https://github.com/stella-emu/stella.git
Some C++20 additions.
This commit is contained in:
parent
2d57f9e028
commit
7a85faef55
|
@ -462,8 +462,8 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD,
|
||||||
//maxVal += zeroBased ? 0 : 1;
|
//maxVal += zeroBased ? 0 : 1;
|
||||||
maxVal -= zeroBased ? 1 : 0;
|
maxVal -= zeroBased ? 1 : 0;
|
||||||
const Int32 bits = isBCD
|
const Int32 bits = isBCD
|
||||||
? ceil(log(maxVal) / log(10) * 4)
|
? ceil(log(maxVal) / std::numbers::ln10 * 4)
|
||||||
: ceil(log(maxVal) / log(2));
|
: ceil(log(maxVal) / std::numbers::ln2);
|
||||||
|
|
||||||
// limit to maxVal's bits
|
// limit to maxVal's bits
|
||||||
val %= 1 << bits;
|
val %= 1 << bits;
|
||||||
|
|
|
@ -60,26 +60,17 @@ class Variant
|
||||||
const string& toString() const { return data; }
|
const string& toString() const { return data; }
|
||||||
const char* toCString() const { return data.c_str(); }
|
const char* toCString() const { return data.c_str(); }
|
||||||
Int32 toInt() const {
|
Int32 toInt() const {
|
||||||
istringstream ss(data);
|
try { return std::stoi(data); } catch(...) { return 0; }
|
||||||
Int32 parsed;
|
|
||||||
ss >> parsed;
|
|
||||||
|
|
||||||
return parsed;
|
|
||||||
}
|
}
|
||||||
float toFloat() const {
|
float toFloat() const {
|
||||||
istringstream ss(data);
|
try { return std::stof(data); } catch(...) { return 0.F; }
|
||||||
float parsed;
|
|
||||||
ss >> parsed;
|
|
||||||
|
|
||||||
return parsed;
|
|
||||||
}
|
}
|
||||||
bool toBool() const { return data == "1" || data == "true"; }
|
bool toBool() const { return data == "1" || data == "true"; }
|
||||||
Common::Size toSize() const { return Common::Size(data); }
|
Common::Size toSize() const { return Common::Size(data); }
|
||||||
Common::Point toPoint() const { return Common::Point(data); }
|
Common::Point toPoint() const { return Common::Point(data); }
|
||||||
|
|
||||||
// Comparison
|
// Comparison
|
||||||
bool operator==(const Variant& v) const { return data == v.data; }
|
bool operator<=>(const Variant& v) const = default;
|
||||||
bool operator!=(const Variant& v) const { return data != v.data; }
|
|
||||||
|
|
||||||
friend ostream& operator<<(ostream& os, const Variant& v) {
|
friend ostream& operator<<(ostream& os, const Variant& v) {
|
||||||
return os << v.data;
|
return os << v.data;
|
||||||
|
|
|
@ -38,7 +38,6 @@ QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system,
|
||||||
myOSystem{osystem},
|
myOSystem{osystem},
|
||||||
myProperties{properties}
|
myProperties{properties}
|
||||||
{
|
{
|
||||||
Controller::Type firstType, secondType;
|
|
||||||
string first, second;
|
string first, second;
|
||||||
|
|
||||||
if(jack == Controller::Jack::Left)
|
if(jack == Controller::Jack::Left)
|
||||||
|
@ -51,7 +50,7 @@ QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system,
|
||||||
first = properties.get(PropType::Controller_Right1);
|
first = properties.get(PropType::Controller_Right1);
|
||||||
second = properties.get(PropType::Controller_Right2);
|
second = properties.get(PropType::Controller_Right2);
|
||||||
}
|
}
|
||||||
firstType = Controller::getType(first);
|
Controller::Type firstType = Controller::getType(first),
|
||||||
secondType = Controller::getType(second);
|
secondType = Controller::getType(second);
|
||||||
|
|
||||||
// Autodetect QuadTari controllers:
|
// Autodetect QuadTari controllers:
|
||||||
|
|
|
@ -134,8 +134,6 @@ void QuadTariDialog::show(bool enableLeft, bool enableRight)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void QuadTariDialog::loadControllerProperties(const Properties& props)
|
void QuadTariDialog::loadControllerProperties(const Properties& props)
|
||||||
{
|
{
|
||||||
string controller;
|
|
||||||
|
|
||||||
if(myLeftPortLabel->isEnabled())
|
if(myLeftPortLabel->isEnabled())
|
||||||
{
|
{
|
||||||
defineController(props, PropType::Controller_Left1, Controller::Jack::Left,
|
defineController(props, PropType::Controller_Left1, Controller::Jack::Left,
|
||||||
|
@ -160,7 +158,7 @@ void QuadTariDialog::defineController(const Properties& props, PropType key,
|
||||||
ByteBuffer image;
|
ByteBuffer image;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
string controllerName = props.get(key);
|
const string& controllerName = props.get(key);
|
||||||
popupWidget->setSelected(controllerName, "AUTO");
|
popupWidget->setSelected(controllerName, "AUTO");
|
||||||
|
|
||||||
// try to load the image for auto detection
|
// try to load the image for auto detection
|
||||||
|
@ -173,7 +171,7 @@ void QuadTariDialog::defineController(const Properties& props, PropType key,
|
||||||
&& (image = instance().openROM(node, md5, size)) != nullptr;
|
&& (image = instance().openROM(node, md5, size)) != nullptr;
|
||||||
}
|
}
|
||||||
string label;
|
string label;
|
||||||
Controller::Type type = Controller::getType(popupWidget->getSelectedTag().toString());
|
const Controller::Type type = Controller::getType(popupWidget->getSelectedTag().toString());
|
||||||
|
|
||||||
if(type == Controller::Type::Unknown)
|
if(type == Controller::Type::Unknown)
|
||||||
{
|
{
|
||||||
|
|
|
@ -323,7 +323,7 @@ bool RomImageWidget::loadPng(const string& fileName)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(data.first == "Software"
|
if(data.first == "Software"
|
||||||
&& data.second.toString().find("Stella") == 0)
|
&& data.second.toString().starts_with("Stella"))
|
||||||
myLabel = "Snapshot"; // default for Stella snapshots with missing "Title" meta data
|
myLabel = "Snapshot"; // default for Stella snapshots with missing "Title" meta data
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue