Merge remote-tracking branch 'remotes/origin/master' into feature-highscores

This commit is contained in:
thrust26 2020-11-29 22:26:37 +01:00
commit 56fb6b0956
21 changed files with 319 additions and 479 deletions

View File

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

View File

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

View File

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

View File

@ -48,7 +48,6 @@
#include "Cart.hxx"
#include "Console.hxx"
#include "Launcher.hxx"
#include "json.hxx"
#include "Base.hxx"
#include "HighScoresManager.hxx"
@ -57,7 +56,6 @@ using namespace BSPF;
using namespace std;
using namespace HSM;
using Common::Base;
using json = nlohmann::json;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HighScoresManager::HighScoresManager(OSystem& osystem)
@ -79,10 +77,23 @@ Int16 HighScoresManager::peek(uInt16 addr) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Properties& HighScoresManager::properties(Properties& props) const
const json HighScoresManager::properties(const Properties& props) const
{
const string& property = props.get(PropType::Cart_Highscore);
if (myOSystem.hasConsole())
if(property.empty())
return json::array();
return json::parse(property);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
json HighScoresManager::properties(json& jprops) const
{
Properties props;
if(myOSystem.hasConsole())
{
props = myOSystem.console().properties();
}
@ -91,323 +102,208 @@ Properties& HighScoresManager::properties(Properties& props) const
const string& md5 = myOSystem.launcher().selectedRomMD5();
myOSystem.propSet().getMD5(md5, props);
}
return props;
return jprops = properties(props);
}
//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//string HighScoresManager::getPropIdx(const Properties& props, PropType type, uInt32 idx) const
//{
// string property = props.get(type);
//
// replace(property.begin(), property.end(), ',', ' ');
// replace(property.begin(), property.end(), '|', ' ');
// istringstream buf(property);
// string result;
//
// for (uInt32 i = 0; i <= idx; ++i)
// if(!(buf >> result))
// return "";
//
// return result;
//}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::enabled() const
{
Properties props;
json hsProp;
return !getPropStr(properties(props), SCORE_ADDRESS_0).empty();
//return (!getPropIdx(properties(props), PropType::Cart_Addresses, 0).empty());
return properties(hsProp).contains(SCORE_ADDRESSES);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numVariations(const Properties& props) const
uInt32 HighScoresManager::numVariations(const json& jprops) const
{
return min(getPropInt(props, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS);
//string numVariations = getPropIdx(props, PropType::Cart_Variations);
//uInt32 maxVariations = MAX_VARIATIONS;
//return min(uInt32(stringToInt(numVariations, DEFAULT_VARIATION)), maxVariations);
return min(getPropInt(jprops, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
ScoresInfo& info) const
{
numVariationsR = numVariations(props);
json jprops = properties(props);
//info.armRAM = armRAM(props);
info.numDigits = numDigits(props);
info.trailingZeroes = trailingZeroes(props);
info.scoreBCD = scoreBCD(props);
info.scoreInvert = scoreInvert(props);
info.varsBCD = varBCD(props);
info.varsZeroBased = varZeroBased(props);
info.special = specialLabel(props);
info.specialBCD = specialBCD(props);
info.specialZeroBased = specialZeroBased(props);
info.notes = notes(props);
numVariationsR = numVariations(jprops);
info.varsAddr = varAddress(props);
info.specialAddr = specialAddress(props);
//info.armRAM = armRAM(jprops);
info.numDigits = numDigits(jprops);
info.trailingZeroes = trailingZeroes(jprops);
info.scoreBCD = scoreBCD(jprops);
info.scoreInvert = scoreInvert(jprops);
info.varsBCD = varBCD(jprops);
info.varsZeroBased = varZeroBased(jprops);
info.special = specialLabel(jprops);
info.specialBCD = specialBCD(jprops);
info.specialZeroBased = specialZeroBased(jprops);
info.notes = notes(jprops);
int num = numAddrBytes(props);
if(num >= 1)
info.scoreAddr[0] = getPropAddr(props, SCORE_ADDRESS_0);
if(num >= 2)
info.scoreAddr[1] = getPropAddr(props, SCORE_ADDRESS_1);
if(num >= 3)
info.scoreAddr[2] = getPropAddr(props, SCORE_ADDRESS_2);
if(num >= 4)
info.scoreAddr[3] = getPropAddr(props, SCORE_ADDRESS_3);
info.varsAddr = varAddress(jprops);
info.specialAddr = specialAddress(jprops);
return !getPropStr(props, SCORE_ADDRESS_0).empty();
info.scoreAddr = getPropScoreAddr(jprops);
//for (uInt32 a = 0; a < numAddrBytes(props); ++a)
//if(jprops.contains(SCORE_ADDRESSES))
//{
// const json addrProps = jprops.at(SCORE_ADDRESSES);
// if(!addrProps.empty() && addrProps.is_array())
// {
// int a = 0;
// for(const json& addresses : addrProps)
// {
// const string address = addresses.get<string>();
// string addr = getPropIdx(props, PropType::Cart_Addresses, a);
// if(address.empty())
// info.scoreAddr[a++] = DEFAULT_ADDRESS;
// else
// info.scoreAddr[a++] = fromHexStr(address);
// }
// info.scoreAddr[a] = stringToIntBase16(addr);
// }
//}
//return (!getPropIdx(props, PropType::Cart_Addresses, 0).empty());
return enabled();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HighScoresManager::set(Properties& props, uInt32 numVariations,
const ScoresInfo& info) const
{
uInt32 maxVariations = MAX_VARIATIONS;
json hsProp = json::object();
json jprops = json::object();
// handle variations
hsProp[VARIATIONS_COUNT] = min(numVariations, maxVariations);
jprops[VARIATIONS_COUNT] = min(numVariations, MAX_VARIATIONS);
if(numVariations != DEFAULT_VARIATION)
hsProp[VARIATIONS_ADDRESS] = "0x" + Base::toString(info.varsAddr, Base::Fmt::_16);
jprops[VARIATIONS_ADDRESS] = "0x" + Base::toString(info.varsAddr, Base::Fmt::_16);
if(info.varsBCD != DEFAULT_VARS_BCD)
hsProp[VARIATIONS_BCD] = info.varsBCD;
jprops[VARIATIONS_BCD] = info.varsBCD;
if(info.varsZeroBased != DEFAULT_VARS_ZERO_BASED)
hsProp[VARIATIONS_ZERO_BASED] = info.varsZeroBased;
jprops[VARIATIONS_ZERO_BASED] = info.varsZeroBased;
// handle score
if(info.numDigits != DEFAULT_DIGITS)
hsProp[SCORE_DIGITS] = info.numDigits;
jprops[SCORE_DIGITS] = info.numDigits;
if(info.trailingZeroes != DEFAULT_TRAILING)
hsProp[SCORE_TRAILING_ZEROES] = info.trailingZeroes;
jprops[SCORE_TRAILING_ZEROES] = info.trailingZeroes;
if(info.scoreBCD != DEFAULT_SCORE_BCD)
hsProp[SCORE_BCD] = info.scoreBCD;
jprops[SCORE_BCD] = info.scoreBCD;
if(info.scoreInvert != DEFAULT_SCORE_REVERSED)
hsProp[SCORE_INVERTED] = info.scoreInvert;
uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes);
jprops[SCORE_INVERTED] = info.scoreInvert;
uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes);
json addresses = json::array();
for(uInt32 a = 0; a < addrBytes; ++a)
addresses.push_back("0x" + Base::toString(info.scoreAddr[a], Base::Fmt::_16));
hsProp[SCORE_ADDRESSES] = addresses;
jprops[SCORE_ADDRESSES] = addresses;
// handle special
if(!info.special.empty())
hsProp[SPECIAL_LABEL] = info.special;
jprops[SPECIAL_LABEL] = info.special;
if(!info.special.empty())
hsProp[SPECIAL_ADDRESS] = "0x" + Base::toString(info.specialAddr, Base::Fmt::_16);
jprops[SPECIAL_ADDRESS] = "0x" + Base::toString(info.specialAddr, Base::Fmt::_16);
if(info.specialBCD != DEFAULT_SPECIAL_BCD)
hsProp[SPECIAL_BCD] = info.specialBCD;
jprops[SPECIAL_BCD] = info.specialBCD;
if(info.specialZeroBased != DEFAULT_SPECIAL_ZERO_BASED)
hsProp[SPECIAL_ZERO_BASED] = info.specialZeroBased;
jprops[SPECIAL_ZERO_BASED] = info.specialZeroBased;
// handle notes
if(!info.notes.empty())
hsProp[NOTES] = info.notes;
jprops[NOTES] = info.notes;
//if(info.armRAM != DEFAULT_ARM_RAM)
// hsProp[""] = info.armRAM ? "1" : "0"; // TODO add ',' to numDigits!
// jprops[""] = info.armRAM;
props.set(PropType::Cart_Highscore, hsProp.dump());
ostringstream buf;
string output;
props.set(PropType::Cart_Variations, to_string(min(numVariations, maxVariations)));
// fill from the back to skip default values
if (output.length() || !info.notes.empty())
output.insert(0, "," + toPropString(info.notes));
if (output.length() || info.specialZeroBased != DEFAULT_SPECIAL_ZERO_BASED)
output.insert(0, info.specialZeroBased ? ",1" : ",0");
if (output.length() || info.specialBCD != DEFAULT_SPECIAL_BCD)
output.insert(0, info.specialBCD ? ",B" : ",D");
if (output.length() || !info.special.empty())
output.insert(0, "," + toPropString(info.special.empty() ? "_" : info.special));
if (output.length() || info.varsZeroBased != DEFAULT_VARS_ZERO_BASED)
output.insert(0, info.varsZeroBased ? ",1" : ",0");
if (output.length() || info.varsBCD != DEFAULT_VARS_BCD)
output.insert(0, info.varsBCD ? ",B" : ",D");
if (output.length() || info.scoreInvert != DEFAULT_SCORE_REVERSED)
output.insert(0, info.scoreInvert ? ",1" : ",0");
if (output.length() || info.scoreBCD != DEFAULT_SCORE_BCD)
output.insert(0, info.scoreBCD ? ",B" : ",H");
if (output.length() || info.trailingZeroes != DEFAULT_TRAILING)
output.insert(0, "," + to_string(info.trailingZeroes));
if (output.length() || info.numDigits != DEFAULT_DIGITS)
output.insert(0, to_string(info.numDigits));
//if (output.length() || info.armRAM != DEFAULT_ARM_RAM)
// output.insert(0, info.armRAM ? "1" : "0"); // TODO add ',' to numDigits!
props.set(PropType::Cart_Formats, output);
for (uInt32 a = 0; a < numAddrBytes(info.numDigits, info.trailingZeroes); ++a)
buf << hex << info.scoreAddr[a] << ",";
// add optional addresses
if (numVariations != DEFAULT_VARIATION || !info.special.empty())
buf << info.varsAddr << "," ;
if (!info.special.empty())
buf << info.specialAddr << "," ;
output = buf.str();
output.pop_back();
props.set(PropType::Cart_Addresses, output);
props.set(PropType::Cart_Highscore, jprops.dump());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numDigits(const Properties& props) const
uInt32 HighScoresManager::numDigits(const json& jprops) const
{
return min(getPropInt(props, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS);
//string digits = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_DIGITS);
//uInt32 maxScoreDigits = MAX_SCORE_DIGITS;
//return min(uInt32(stringToInt(digits, DEFAULT_DIGITS)), maxScoreDigits);
return min(getPropInt(jprops, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::trailingZeroes(const Properties& props) const
uInt32 HighScoresManager::trailingZeroes(const json& jprops) const
{
return min(getPropInt(props, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING);
//string trailing = getPropIdx(props, PropType::Cart_Formats, IDX_TRAILING_ZEROES);
//const uInt32 maxTrailing = MAX_TRAILING;
//return min(uInt32(stringToInt(trailing, DEFAULT_TRAILING)), maxTrailing);
return min(getPropInt(jprops, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::scoreBCD(const Properties& props) const
bool HighScoresManager::scoreBCD(const json& jprops) const
{
return getPropBool(props, SCORE_BCD, DEFAULT_SCORE_BCD);
//string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_BCD);
//return bcd.empty() ? DEFAULT_SCORE_BCD : bcd == "B";
}
bool HighScoresManager::scoreInvert(const Properties& props) const
{
return getPropBool(props, SCORE_INVERTED, DEFAULT_SCORE_REVERSED);
//string reversed = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_INVERT);
//return reversed.empty() ? DEFAULT_SCORE_REVERSED : reversed != "0";
return getPropBool(jprops, SCORE_BCD, DEFAULT_SCORE_BCD);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::varBCD(const Properties& props) const
bool HighScoresManager::scoreInvert(const json& jprops) const
{
return getPropBool(props, VARIATIONS_BCD, DEFAULT_VARS_BCD);
//string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_VAR_BCD);
//return bcd.empty() ? DEFAULT_VARS_BCD : bcd == "B";
return getPropBool(jprops, SCORE_INVERTED, DEFAULT_SCORE_REVERSED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::varZeroBased(const Properties& props) const
bool HighScoresManager::varBCD(const json& jprops) const
{
return getPropBool(props, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED);
//string zeroBased = getPropIdx(props, PropType::Cart_Formats, IDX_VAR_ZERO_BASED);
//return zeroBased.empty() ? DEFAULT_VARS_ZERO_BASED : zeroBased != "0";
return getPropBool(jprops, VARIATIONS_BCD, DEFAULT_VARS_BCD);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::specialLabel(const Properties& props) const
bool HighScoresManager::varZeroBased(const json& jprops) const
{
return getPropStr(props, SPECIAL_LABEL);
//return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_LABEL));
return getPropBool(jprops, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::specialBCD(const Properties& props) const
const string HighScoresManager::specialLabel(const json& jprops) const
{
return getPropBool(props, SPECIAL_BCD, DEFAULT_SPECIAL_BCD);
//string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_BCD);
//return bcd.empty() ? DEFAULT_SPECIAL_BCD : bcd == "B";
return getPropStr(jprops, SPECIAL_LABEL);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::specialZeroBased(const Properties& props) const
bool HighScoresManager::specialBCD(const json& jprops) const
{
return getPropBool(props, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED);
//string zeroBased = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_ZERO_BASED);
//return zeroBased.empty() ? DEFAULT_SPECIAL_ZERO_BASED : zeroBased != "0";
return getPropBool(jprops, SPECIAL_BCD, DEFAULT_SPECIAL_BCD);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::notes(const Properties& props) const
bool HighScoresManager::specialZeroBased(const json& jprops) const
{
return getPropStr(props, NOTES);
//return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_NOTES));
return getPropBool(jprops, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*bool HighScoresManager::armRAM(const Properties& props) const
const string HighScoresManager::notes(const json& jprops) const
{
//string armRAM = getPropIdx(props, PropType::Cart_Formats, IDX_ARM_RAM);
return getPropStr(jprops, NOTES);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*bool HighScoresManager::armRAM(const json& jprops) const
{
//string armRAM = getPropIdx(jprops, PropType::Cart_Formats, IDX_ARM_RAM);
//return armRAM.empty() ? DEFAULT_ARM_RAM : armRAM != "0";
return false;
}*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::varAddress(const Properties& props) const
uInt16 HighScoresManager::varAddress(const json& jprops) const
{
return getPropAddr(props, VARIATIONS_ADDRESS, DEFAULT_ADDRESS);
//uInt32 idx = numAddrBytes(props) + IDX_VARS_ADDRESS;
//string addr = getPropIdx(props, PropType::Cart_Addresses, idx);
//return stringToIntBase16(addr, DEFAULT_ADDRESS);
return getPropAddr(jprops, VARIATIONS_ADDRESS, DEFAULT_ADDRESS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::specialAddress(const Properties& props) const
uInt16 HighScoresManager::specialAddress(const json& jprops) const
{
return getPropAddr(props, SPECIAL_ADDRESS, DEFAULT_ADDRESS);
//uInt32 idx = numAddrBytes(props) + IDX_SPECIAL_ADDRESS;
//string addr = getPropIdx(props, PropType::Cart_Addresses, idx);
//return stringToIntBase16(addr, DEFAULT_ADDRESS);
return getPropAddr(jprops, SPECIAL_ADDRESS, DEFAULT_ADDRESS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numAddrBytes(Int32 digits, Int32 trailing) const
{
@ -415,26 +311,26 @@ uInt32 HighScoresManager::numAddrBytes(Int32 digits, Int32 trailing) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numAddrBytes(const Properties& props) const
uInt32 HighScoresManager::numAddrBytes(const json& jprops) const
{
return numAddrBytes(numDigits(props), trailingZeroes(props));
return numAddrBytes(numDigits(jprops), trailingZeroes(jprops));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::numVariations() const
{
Properties props;
uInt16 vars = numVariations(properties(props));
json jprops;
uInt16 vars = numVariations(properties(jprops));
return vars;;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::specialLabel() const
const string HighScoresManager::specialLabel() const
{
Properties props;
json jprops;
return specialLabel(properties(props));
return specialLabel(properties(jprops));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -452,8 +348,8 @@ Int32 HighScoresManager::variation(uInt16 addr, bool varBCD, bool zeroBased,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::variation() const
{
Properties props;
uInt16 addr = varAddress(properties(props));
json jprops;
uInt16 addr = varAddress(properties(jprops));
if(addr == DEFAULT_ADDRESS) {
if(numVariations() == 1)
@ -462,7 +358,7 @@ Int32 HighScoresManager::variation() const
return NO_VALUE;
}
return variation(addr, varBCD(props), varZeroBased(props), numVariations(props));
return variation(addr, varBCD(jprops), varZeroBased(jprops), numVariations(jprops));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -501,73 +397,26 @@ Int32 HighScoresManager::score(uInt32 numAddrBytes, uInt32 trailingZeroes,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::score() const
{
Properties props;
uInt32 numBytes = numAddrBytes(properties(props));
ScoreAddresses scoreAddr;
json jprops;
uInt32 numBytes = numAddrBytes(properties(jprops));
const ScoreAddresses scoreAddr = getPropScoreAddr(jprops);
if(numBytes >= 1)
{
string addr = getPropStr(props, SCORE_ADDRESS_0);
if(addr.empty())
return NO_VALUE;
scoreAddr[0] = getPropAddr(props, SCORE_ADDRESS_0);
}
if(numBytes >= 2)
{
string addr = getPropStr(props, SCORE_ADDRESS_1);
if(addr.empty())
return NO_VALUE;
scoreAddr[1] = getPropAddr(props, SCORE_ADDRESS_1);
}
if(numBytes >= 3)
{
string addr = getPropStr(props, SCORE_ADDRESS_2);
if(addr.empty())
return NO_VALUE;
scoreAddr[2] = getPropAddr(props, SCORE_ADDRESS_2);
}
if(numBytes >= 4)
{
string addr = getPropStr(props, SCORE_ADDRESS_3);
if(addr.empty())
return NO_VALUE;
scoreAddr[3] = getPropAddr(props, SCORE_ADDRESS_3);
}
//for (uInt32 b = 0; b < numBytes; ++b)
//{
// string addr = getPropIdx(props, PropType::Cart_Addresses, b);
// if (addr.empty())
// return NO_VALUE;
// scoreAddr[b] = stringToIntBase16(addr);
//}
return score(numBytes, trailingZeroes(props), scoreBCD(props), scoreAddr);
if(uInt32(scoreAddr.size()) < numBytes)
return NO_VALUE;
return score(numBytes, trailingZeroes(jprops), scoreBCD(jprops), scoreAddr);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::formattedScore(Int32 score, Int32 width) const
const string HighScoresManager::formattedScore(Int32 score, Int32 width) const
{
if(score <= 0)
return "";
ostringstream buf;
Properties props;
Int32 digits = numDigits(properties(props));
json jprops;
Int32 digits = numDigits(properties(jprops));
if(scoreBCD(props))
if(scoreBCD(jprops))
{
if(width > digits)
digits = width;
@ -584,20 +433,20 @@ string HighScoresManager::formattedScore(Int32 score, Int32 width) const
bool HighScoresManager::scoreInvert() const
{
Properties props;
return scoreInvert(properties(props));
json jprops;
return scoreInvert(properties(jprops));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::special() const
{
Properties props;
uInt16 addr = specialAddress(properties(props));
json jprops;
uInt16 addr = specialAddress(properties(jprops));
if (addr == DEFAULT_ADDRESS)
return NO_VALUE;
return special(addr, specialBCD(props), specialZeroBased(props));
return special(addr, specialBCD(jprops), specialZeroBased(jprops));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -617,11 +466,11 @@ Int32 HighScoresManager::special(uInt16 addr, bool varBCD, bool zeroBased) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::notes() const
const string HighScoresManager::notes() const
{
Properties props;
json jprops;
return notes(properties(props));
return notes(properties(jprops));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -657,56 +506,63 @@ void replaceAll(std::string& str, const std::string& from, const std::string& to
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::getPropBool(const Properties& props, const string& key,
bool HighScoresManager::getPropBool(const json& jprops, const string& key,
bool defVal) const
{
const string& property = props.get(PropType::Cart_Highscore);
return jprops.contains(key) ? jprops.at(key).get<bool>() : defVal;
}
if(property.empty())
return defVal;
const json hsProp = json::parse(property);
return hsProp.contains(key) ? hsProp.at(key).get<bool>() : defVal;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::getPropInt(const json& jprops, const string& key,
uInt32 defVal) const
{
return jprops.contains(key) ? jprops.at(key).get<uInt32>() : defVal;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::getPropInt(const Properties& props, const string& key,
uInt32 defVal) const
const string HighScoresManager::getPropStr(const json& jprops, const string& key,
const string& defVal) const
{
const string& property = props.get(PropType::Cart_Highscore);
if(property.empty())
return defVal;
const json hsProp = json::parse(property);
return hsProp.contains(key) ? hsProp.at(key).get<uInt32>() : defVal;
return jprops.contains(key) ? jprops.at(key).get<string>() : defVal;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::getPropStr(const Properties& props, const string& key,
const string& defVal) const
uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key,
uInt16 defVal) const
{
const string& property = props.get(PropType::Cart_Highscore);
if(property.empty())
return defVal;
const json hsProp = json::parse(property);
return hsProp.contains(key) ? hsProp.at(key).get<string>() : defVal;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::getPropAddr(const Properties& props, const string& key,
uInt16 defVal) const
{
const string str = getPropStr(props, key);
const string str = getPropStr(jprops, key);
return str.empty() ? defVal : fromHexStr(str);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops) const
{
ScoreAddresses scoreAddr{};
if(jprops.contains(SCORE_ADDRESSES))
{
const json addrProps = jprops.at(SCORE_ADDRESSES);
if(!addrProps.empty() && addrProps.is_array())
{
int a = 0;
for(const json& addresses : addrProps)
{
const string address = addresses.get<string>();
if(address.empty())
scoreAddr[a++] = DEFAULT_ADDRESS;
else
scoreAddr[a++] = fromHexStr(address);
}
}
}
return scoreAddr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::fromHexStr(const string& addr) const
{
@ -728,42 +584,6 @@ Int32 HighScoresManager::fromBCD(uInt8 bcd) const
return (bcd >> 4) * 10 + bcd % 16;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::toPropString(const string& text) const
{
string result = text;
size_t pos;
while ((pos = result.find(" ")) != std::string::npos) {
result.replace(pos, 1, "_");
}
return result;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::fromPropString(const string& text) const
{
string result = text;
size_t pos;
while ((pos = result.find("_")) != std::string::npos) {
result.replace(pos, 1, " ");
}
// some ugly formatting
if(result.length())
{
char first = result[0];
result = BSPF::toLowerCase(result);
result[0] = first;
}
// remove leading spaces (especially for empty values)
size_t start = result.find_first_not_of(" ");
return (start == std::string::npos) ? "" : result.substr(start);
}
const string HighScoresManager::VARIATIONS_COUNT = "variations_number";
const string HighScoresManager::VARIATIONS_ADDRESS = "variations_address";
const string HighScoresManager::VARIATIONS_BCD = "variations_bcd";
@ -773,10 +593,6 @@ const string HighScoresManager::SCORE_TRAILING_ZEROES = "score_trailing_zeroes";
const string HighScoresManager::SCORE_BCD = "score_bcd";
const string HighScoresManager::SCORE_INVERTED = "score_inverted";
const string HighScoresManager::SCORE_ADDRESSES = "score_addresses";
const string HighScoresManager::SCORE_ADDRESS_0 = "score_address_0";
const string HighScoresManager::SCORE_ADDRESS_1 = "score_address_1";
const string HighScoresManager::SCORE_ADDRESS_2 = "score_address_2";
const string HighScoresManager::SCORE_ADDRESS_3 = "score_address_3";
const string HighScoresManager::SPECIAL_LABEL = "special_label";
const string HighScoresManager::SPECIAL_ADDRESS = "special_address";
const string HighScoresManager::SPECIAL_BCD = "special_bcd";

View File

@ -21,6 +21,9 @@
class OSystem;
#include "Props.hxx"
#include "json.hxx"
using json = nlohmann::json;
/**
This class provides an interface to all things related to high scores.
@ -92,15 +95,6 @@ class HighScoresManager
void set(Properties& props, uInt32 numVariations,
const HSM::ScoresInfo& info) const;
/**
Calculate the number of bytes for one player's score from given parameters
@return The number of score address bytes
*/
uInt32 numAddrBytes(Int32 digits, Int32 trailing) const;
// Retrieve current values from (using given parameters)
Int32 variation(uInt16 addr, bool varBCD, bool zeroBased, uInt32 numVariations) const;
/**
Calculate the score from given parameters
@ -109,44 +103,34 @@ class HighScoresManager
Int32 score(uInt32 numAddrBytes, uInt32 trailingZeroes, bool isBCD,
const HSM::ScoreAddresses& scoreAddr) const;
// Convert the given value, using only the maximum bits required by maxVal
// and adjusted for BCD and zero based data
Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const;
/**
Calculate the number of bytes for one player's score from given parameters
@return The number of score address bytes
*/
uInt32 numAddrBytes(Int32 digits, Int32 trailing) const;
Int32 special(uInt16 addr, bool varBCD, bool zeroBased) const;
// Retrieve current values (using game's properties)
Int32 numVariations() const;
string specialLabel() const;
const string specialLabel() const;
Int32 variation() const;
Int32 score() const;
string formattedScore(Int32 score, Int32 width = -1) const;
const string formattedScore(Int32 score, Int32 width = -1) const;
bool scoreInvert() const;
Int32 special() const;
string notes() const;
// converts the given value, using only the maximum bits required by maxVal
// and adjusted for BCD and zero based data
Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const;
const string notes() const;
// Peek into memory
Int16 peek(uInt16 addr) const;
private:
//enum {
// //IDX_ARM_RAM = 0,
// IDX_SCORE_DIGITS = 0,
// IDX_TRAILING_ZEROES,
// IDX_SCORE_BCD,
// IDX_SCORE_INVERT,
// IDX_VAR_BCD,
// IDX_VAR_ZERO_BASED,
// IDX_SPECIAL_LABEL,
// IDX_SPECIAL_BCD,
// IDX_SPECIAL_ZERO_BASED,
// IDX_NOTES,
//};
//enum {
// IDX_VARS_ADDRESS = 0,
// IDX_SPECIAL_ADDRESS
//};
static const string VARIATIONS_COUNT;
static const string VARIATIONS_ADDRESS;
static const string VARIATIONS_BCD;
@ -156,10 +140,6 @@ class HighScoresManager
static const string SCORE_BCD;
static const string SCORE_INVERTED;
static const string SCORE_ADDRESSES;
static const string SCORE_ADDRESS_0;
static const string SCORE_ADDRESS_1;
static const string SCORE_ADDRESS_2;
static const string SCORE_ADDRESS_3;
static const string SPECIAL_LABEL;
static const string SPECIAL_ADDRESS;
static const string SPECIAL_BCD;
@ -180,44 +160,45 @@ class HighScoresManager
static constexpr bool DEFAULT_SPECIAL_ZERO_BASED = false;
private:
// Get individual highscore info from properties
uInt32 numVariations(const Properties& props) const;
uInt16 varAddress(const Properties& props) const;
uInt16 specialAddress(const Properties& props) const;
uInt32 numDigits(const Properties& props) const;
uInt32 trailingZeroes(const Properties& props) const;
bool scoreBCD(const Properties& props) const;
bool scoreInvert(const Properties& props) const;
bool varBCD(const Properties& props) const;
bool varZeroBased(const Properties& props) const;
string specialLabel(const Properties& props) const;
bool specialBCD(const Properties& props) const;
bool specialZeroBased(const Properties& props) const;
string notes(const Properties& props) const;
//bool armRAM(const Properties& props) const;
// Retrieve current values from (using given parameters)
Int32 variation(uInt16 addr, bool varBCD, bool zeroBased, uInt32 numVariations) const;
// Get individual highscore info from properties
uInt32 numVariations(const json& jprops) const;
uInt16 varAddress(const json& jprops) const;
uInt16 specialAddress(const json& jprops) const;
uInt32 numDigits(const json& jprops) const;
uInt32 trailingZeroes(const json& jprops) const;
bool scoreBCD(const json& jprops) const;
bool scoreInvert(const json& jprops) const;
bool varBCD(const json& jprops) const;
bool varZeroBased(const json& jprops) const;
const string specialLabel(const json& jprops) const;
bool specialBCD(const json& jprops) const;
bool specialZeroBased(const json& jprops) const;
const string notes(const json& jprops) const;
//bool armRAM(const json& jprops) const;
// Calculate the number of bytes for one player's score from property parameters
uInt32 numAddrBytes(const Properties& props) const;
uInt32 numAddrBytes(const json& jprops) const;
// Get properties
Properties& properties(Properties& props) const;
//// Get value from highscore propterties at given index
//string getPropIdx(const Properties& props, PropType type, uInt32 idx = 0) const;
const json properties(const Properties& props) const;
json properties(json& jprops) const;
bool getPropBool(const Properties& props, const string& key,
// Get value from highscore properties for given key
bool getPropBool(const json& jprops, const string& key,
bool defVal = false) const;
uInt32 getPropInt(const Properties& props, const string& key,
uInt32 getPropInt(const json& jprops, const string& key,
uInt32 defVal = 0) const;
string getPropStr(const Properties& props, const string& key,
const string& defVal = "") const;
uInt16 getPropAddr(const Properties& props, const string& key,
const string getPropStr(const json& jprops, const string& key,
const string& defVal = "") const;
uInt16 getPropAddr(const json& jprops, const string& key,
uInt16 defVal = 0) const;
const HSM::ScoreAddresses getPropScoreAddr(const json& jprops) const;
uInt16 fromHexStr(const string& addr) const;
Int32 fromBCD(uInt8 bcd) const;
string toPropString(const string& test) const;
string fromPropString(const string& test) const;
private:
// Reference to the osystem object

View File

@ -240,8 +240,7 @@ int JoyMap::loadMapping(const json& eventMappings, const EventMode mode)
);
i++;
}
catch(json::exception) {
} catch (const json::exception&) {
Logger::error("ignoring invalid joystick event");
}
}

View File

@ -22,6 +22,52 @@
using json = nlohmann::json;
namespace {
json serializeModkeyMask(int mask)
{
if(mask == StellaMod::KBDM_NONE) return json(nullptr);
json serializedMask = json::array();
for(StellaMod mod: {
StellaMod::KBDM_CTRL,
StellaMod::KBDM_SHIFT,
StellaMod::KBDM_ALT,
StellaMod::KBDM_GUI,
StellaMod::KBDM_LSHIFT,
StellaMod::KBDM_RSHIFT,
StellaMod::KBDM_LCTRL,
StellaMod::KBDM_RCTRL,
StellaMod::KBDM_LALT,
StellaMod::KBDM_RALT,
StellaMod::KBDM_LGUI,
StellaMod::KBDM_RGUI,
StellaMod::KBDM_NUM,
StellaMod::KBDM_CAPS,
StellaMod::KBDM_MODE,
StellaMod::KBDM_RESERVED
}) {
if((mask & mod) != mod) continue;
serializedMask.push_back(json(mod));
mask &= ~mod;
}
return serializedMask.size() == 1 ? serializedMask.at(0) : serializedMask;
}
int deserializeModkeyMask(json serializedMask)
{
if (serializedMask.is_null()) return StellaMod::KBDM_NONE;
if (!serializedMask.is_array()) return serializedMask.get<StellaMod>();
int mask = 0;
for(const json& mod: serializedMask) mask |= mod.get<StellaMod>();
return mask;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void KeyMap::add(const Event::Type event, const Mapping& mapping)
{
@ -206,12 +252,11 @@ int KeyMap::loadMapping(const json& mappings, const EventMode mode) {
mapping.at("event").get<Event::Type>(),
mode,
mapping.at("key").get<StellaKey>(),
mapping.contains("mod") ? mapping.at("mod").get<StellaMod>() : StellaMod::KBDM_NONE
mapping.contains("mod") ? deserializeModkeyMask(mapping.at("mod")) : StellaMod::KBDM_NONE
);
i++;
}
catch(json::exception) {
} catch (const json::exception&) {
Logger::error("ignoring bad keyboard mapping");
}
}

View File

@ -47,7 +47,7 @@ PhysicalJoystickHandler::PhysicalJoystickHandler(
try {
mappings = json::parse(serializedMapping);
} catch (json::exception) {
} catch (const json::exception&) {
Logger::info("converting legacy joystick mappings");
mappings = convertLegacyMapping(serializedMapping);
@ -217,7 +217,7 @@ void PhysicalJoystickHandler::mapStelladaptors(const string& saport)
// We know there will be only two such devices (at most), since the logic
// in setupJoysticks take care of that
int saCount = 0;
int saOrder[NUM_PORTS] = { 1, 2 };
int saOrder[] = { 1, 2 };
if(BSPF::equalsIgnoreCase(saport, "rl"))
{
saOrder[0] = 2; saOrder[1] = 1;

View File

@ -74,7 +74,7 @@ void PhysicalKeyboardHandler::loadSerializedMappings(const string& serializedMap
try {
mapping = json::parse(serializedMapping);
} catch (json::exception) {
} catch (const json::exception&) {
Logger::info("converting legacy keyboard mappings");
mapping = KeyMap::convertLegacyMapping(serializedMapping);
@ -82,7 +82,7 @@ void PhysicalKeyboardHandler::loadSerializedMappings(const string& serializedMap
try {
myKeyMap.loadMapping(mapping, mode);
} catch (json::exception) {
} catch (const json::exception&) {
Logger::error("ignoring bad keyboard mappings");
}
}

View File

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

View File

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

View File

@ -87,7 +87,7 @@ bool PhysicalJoystick::setMap(const json& map)
try {
joyMap.loadMapping(entry.value(), eventModeFromJsonName(entry.key()));
} catch (json::exception) {
} catch (const json::exception&) {
Logger::error("ignoring invalid json mapping for " + entry.key());
}

View File

@ -41,18 +41,15 @@ void RewindManager::setup()
const string& prefix = myOSystem.settings().getBool("dev.settings") ? "dev." : "plr.";
// Work around a bug in XCode 11.2 with -O0 and -O1
const uInt32 maxBufSize = MAX_BUF_SIZE;
// TODO - Add proper bounds checking (define constexpr variables for this)
// Use those bounds in DeveloperDialog too
mySize = std::min<uInt32>(
myOSystem.settings().getInt(prefix + "tm.size"), maxBufSize);
myOSystem.settings().getInt(prefix + "tm.size"), MAX_BUF_SIZE);
if(mySize != myStateList.capacity())
resize(mySize);
myUncompressed = std::min<uInt32>(
myOSystem.settings().getInt(prefix + "tm.uncompressed"), maxBufSize);
myOSystem.settings().getInt(prefix + "tm.uncompressed"), MAX_BUF_SIZE);
myInterval = INTERVAL_CYCLES[0];
for(int i = 0; i < NUM_INTERVALS; ++i)

View File

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

View File

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

View File

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

View File

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

View File

@ -64,11 +64,8 @@ MT24LC256::MT24LC256(const FilesystemNode& eepromfile, const System& system,
if(!fileValid)
{
// Work around a bug in XCode 11.2 with -O0 and -O1
const uInt8 initialValue = INITIAL_VALUE;
myData = make_unique<uInt8[]>(FLASH_SIZE);
std::fill_n(myData.get(), FLASH_SIZE, initialValue);
std::fill_n(myData.get(), FLASH_SIZE, INITIAL_VALUE);
myDataChanged = true;
}
@ -142,24 +139,18 @@ void MT24LC256::systemReset()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MT24LC256::eraseAll()
{
// Work around a bug in XCode 11.2 with -O0 and -O1
const uInt8 initialValue = INITIAL_VALUE;
std::fill_n(myData.get(), FLASH_SIZE, initialValue);
std::fill_n(myData.get(), FLASH_SIZE, INITIAL_VALUE);
myDataChanged = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MT24LC256::eraseCurrent()
{
// Work around a bug in XCode 11.2 with -O0 and -O1
const uInt8 initialValue = INITIAL_VALUE;
for(uInt32 page = 0; page < PAGE_NUM; ++page)
{
if(myPageHit[page])
{
std::fill_n(myData.get() + page * PAGE_SIZE, PAGE_SIZE, initialValue);
std::fill_n(myData.get() + page * PAGE_SIZE, PAGE_SIZE, INITIAL_VALUE);
myDataChanged = true;
}
}

View File

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

View File

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

View File

@ -413,6 +413,8 @@
DC8078DB0B4BD5F3005E9305 /* DebuggerExpressions.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC8078DA0B4BD5F3005E9305 /* DebuggerExpressions.hxx */; };
DC8078EA0B4BD697005E9305 /* UIDialog.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC8078E60B4BD697005E9305 /* UIDialog.cxx */; };
DC8078EB0B4BD697005E9305 /* UIDialog.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC8078E70B4BD697005E9305 /* UIDialog.hxx */; };
DC816CF62572F92A00FBCCDA /* json.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC816CF42572F92A00FBCCDA /* json.hxx */; };
DC816CF72572F92A00FBCCDA /* json_lib.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC816CF52572F92A00FBCCDA /* json_lib.hxx */; };
DC84397B247B294E00C6A4FC /* CartTVBoy.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC843979247B294D00C6A4FC /* CartTVBoy.hxx */; };
DC84397C247B294E00C6A4FC /* CartTVBoy.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC84397A247B294D00C6A4FC /* CartTVBoy.cxx */; };
DC84397F247B297A00C6A4FC /* CartTVBoyWidget.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC84397D247B297A00C6A4FC /* CartTVBoyWidget.hxx */; };
@ -520,7 +522,6 @@
DCB60ACC25430FC600A5C1D2 /* FBBackend.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCB60ACB25430FC600A5C1D2 /* FBBackend.hxx */; };
DCB60AD02543100900A5C1D2 /* FBBackendSDL2.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCB60ACD2543100900A5C1D2 /* FBBackendSDL2.cxx */; };
DCB60AD12543100900A5C1D2 /* FBBackendSDL2.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCB60ACE2543100900A5C1D2 /* FBBackendSDL2.hxx */; };
DCB60AD22543100900A5C1D2 /* audio in Resources */ = {isa = PBXBuildFile; fileRef = DCB60ACF2543100900A5C1D2 /* audio */; };
DCB87E581A104C1E00BF2A3B /* MediaFactory.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCB87E571A104C1E00BF2A3B /* MediaFactory.hxx */; };
DCBA539925557E2800087DD7 /* UndoHandler.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCBA539725557E2700087DD7 /* UndoHandler.hxx */; };
DCBA539A25557E2800087DD7 /* UndoHandler.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCBA539825557E2800087DD7 /* UndoHandler.cxx */; };
@ -1182,6 +1183,8 @@
DC8078DA0B4BD5F3005E9305 /* DebuggerExpressions.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = DebuggerExpressions.hxx; sourceTree = "<group>"; };
DC8078E60B4BD697005E9305 /* UIDialog.cxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = UIDialog.cxx; sourceTree = "<group>"; };
DC8078E70B4BD697005E9305 /* UIDialog.hxx */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = UIDialog.hxx; sourceTree = "<group>"; };
DC816CF42572F92A00FBCCDA /* json.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = json.hxx; sourceTree = "<group>"; };
DC816CF52572F92A00FBCCDA /* json_lib.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = json_lib.hxx; sourceTree = "<group>"; };
DC843979247B294D00C6A4FC /* CartTVBoy.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CartTVBoy.hxx; sourceTree = "<group>"; };
DC84397A247B294D00C6A4FC /* CartTVBoy.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CartTVBoy.cxx; sourceTree = "<group>"; };
DC84397D247B297A00C6A4FC /* CartTVBoyWidget.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CartTVBoyWidget.hxx; sourceTree = "<group>"; };
@ -1290,7 +1293,6 @@
DCB60ACB25430FC600A5C1D2 /* FBBackend.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FBBackend.hxx; sourceTree = "<group>"; };
DCB60ACD2543100900A5C1D2 /* FBBackendSDL2.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FBBackendSDL2.cxx; sourceTree = "<group>"; };
DCB60ACE2543100900A5C1D2 /* FBBackendSDL2.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FBBackendSDL2.hxx; sourceTree = "<group>"; };
DCB60ACF2543100900A5C1D2 /* audio */ = {isa = PBXFileReference; lastKnownFileType = folder; path = audio; sourceTree = "<group>"; };
DCB87E571A104C1E00BF2A3B /* MediaFactory.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MediaFactory.hxx; sourceTree = "<group>"; };
DCBA539725557E2700087DD7 /* UndoHandler.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UndoHandler.hxx; sourceTree = "<group>"; };
DCBA539825557E2800087DD7 /* UndoHandler.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UndoHandler.cxx; sourceTree = "<group>"; };
@ -1563,6 +1565,7 @@
2D605130089879BA00C6DE89 /* debugger */,
2D6050CC0898776500C6DE89 /* emucore */,
2D6050FA0898786C00C6DE89 /* gui */,
DC816CF32572F8B400FBCCDA /* json */,
DCD6FC5A11C281A1005DA767 /* libpng */,
2D6050C60898771C00C6DE89 /* macos */,
2D6050C90898774B00C6DE89 /* unix */,
@ -1773,7 +1776,6 @@
isa = PBXGroup;
children = (
DCC6A4AD20A2620D00863C59 /* audio */,
DCB60ACF2543100900A5C1D2 /* audio */,
E09F413A201E901D004A3391 /* AudioQueue.cxx */,
E09F4139201E901C004A3391 /* AudioQueue.hxx */,
E0FABEEA20E9948100EB8E28 /* AudioSettings.cxx */,
@ -2274,6 +2276,15 @@
name = exception;
sourceTree = "<group>";
};
DC816CF32572F8B400FBCCDA /* json */ = {
isa = PBXGroup;
children = (
DC816CF52572F92A00FBCCDA /* json_lib.hxx */,
DC816CF42572F92A00FBCCDA /* json.hxx */,
);
path = json;
sourceTree = "<group>";
};
DCC467EA14FBEC9600E15508 /* tv_filters */ = {
isa = PBXGroup;
children = (
@ -2533,6 +2544,7 @@
DCBD31E92299ADB400567357 /* Rect.hxx in Headers */,
DCBA539925557E2800087DD7 /* UndoHandler.hxx in Headers */,
2D91741A09BA90380026E9FF /* FSNode.hxx in Headers */,
DC816CF72572F92A00FBCCDA /* json_lib.hxx in Headers */,
2D91741B09BA90380026E9FF /* OSystem.hxx in Headers */,
DC6A18F919B3E65500DEB242 /* CartMDMWidget.hxx in Headers */,
2D91741F09BA90380026E9FF /* AboutBox.h in Headers */,
@ -2743,6 +2755,7 @@
DCF8621A21C9D43300F95F52 /* StaggeredLogger.hxx in Headers */,
DCAAE5E31715887B0080BB82 /* CartF0Widget.hxx in Headers */,
DCAAE5E51715887B0080BB82 /* CartF4SCWidget.hxx in Headers */,
DC816CF62572F92A00FBCCDA /* json.hxx in Headers */,
DCAAE5E71715887B0080BB82 /* CartF4Widget.hxx in Headers */,
DC5963142139FA14002736F2 /* Bankswitch.hxx in Headers */,
DCAAE5E91715887B0080BB82 /* CartF6SCWidget.hxx in Headers */,
@ -2876,7 +2889,6 @@
2D91747109BA90380026E9FF /* docs in Resources */,
2D91747209BA90380026E9FF /* AboutBox.nib in Resources */,
2DEFB40C09C3386F00754289 /* Cart.icns in Resources */,
DCB60AD22543100900A5C1D2 /* audio in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};