diff --git a/src/cheat/CheatCodeDialog.cxx b/src/cheat/CheatCodeDialog.cxx index bcb5c8f89..32c91b429 100644 --- a/src/cheat/CheatCodeDialog.cxx +++ b/src/cheat/CheatCodeDialog.cxx @@ -89,12 +89,12 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent, myCheatInput->setTarget(this); // Add filtering for each textfield - EditableWidget::TextFilter f0 = [](char c) { + const EditableWidget::TextFilter f0 = [](char c) { return isprint(c) && c != '\"' && c != ':'; }; myCheatInput->setTextFilter(f0, 0); - EditableWidget::TextFilter f1 = [](char c) { + const EditableWidget::TextFilter f1 = [](char c) { return (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9'); }; myCheatInput->setTextFilter(f1, 1); diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index e3d462031..b1cda388f 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -36,7 +36,7 @@ CheatManager::CheatManager(OSystem& osystem) bool CheatManager::add(const string& name, const string& code, bool enable, int idx) { - shared_ptr cheat = createCheat(name, code); + const shared_ptr cheat = createCheat(name, code); if(!cheat) return false; @@ -120,7 +120,7 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab void CheatManager::addOneShot(const string& name, const string& code) { // Evaluate this cheat once, and then immediately discard it - shared_ptr cheat = createCheat(name, code); + const shared_ptr cheat = createCheat(name, code); if(cheat) cheat->evaluate(); } @@ -299,7 +299,7 @@ void CheatManager::saveCheats(const string& md5sum) cheats << ","; } - bool changed = cheats.str() != myCurrentCheat; + const bool changed = cheats.str() != myCurrentCheat; // Only update the list if absolutely necessary if(changed) diff --git a/src/common/AudioQueue.cxx b/src/common/AudioQueue.cxx index 6144cae7e..1162cd204 100644 --- a/src/common/AudioQueue.cxx +++ b/src/common/AudioQueue.cxx @@ -54,7 +54,7 @@ uInt32 AudioQueue::capacity() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 AudioQueue::size() const { - lock_guard guard(myMutex); + const lock_guard guard(myMutex); return mySize; } @@ -74,7 +74,7 @@ uInt32 AudioQueue::fragmentSize() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Int16* AudioQueue::enqueue(Int16* fragment) { - lock_guard guard(myMutex); + const lock_guard guard(myMutex); Int16* newFragment = nullptr; @@ -105,7 +105,7 @@ Int16* AudioQueue::enqueue(Int16* fragment) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Int16* AudioQueue::dequeue(Int16* fragment) { - lock_guard guard(myMutex); + const lock_guard guard(myMutex); if (mySize == 0) return nullptr; @@ -128,7 +128,7 @@ Int16* AudioQueue::dequeue(Int16* fragment) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AudioQueue::closeSink(Int16* fragment) { - lock_guard guard(myMutex); + const lock_guard guard(myMutex); if (myFirstFragmentForDequeue && fragment) throw runtime_error("attempt to return unknown buffer on closeSink"); diff --git a/src/common/AudioSettings.cxx b/src/common/AudioSettings.cxx index 5a28d0df1..f197bb174 100644 --- a/src/common/AudioSettings.cxx +++ b/src/common/AudioSettings.cxx @@ -51,7 +51,7 @@ AudioSettings::AudioSettings(Settings& settings) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AudioSettings::normalize(Settings& settings) { - int settingPreset = settings.getInt(SETTING_PRESET); + const int settingPreset = settings.getInt(SETTING_PRESET); const Preset preset = normalizedPreset(settingPreset); if (static_cast(preset) != settingPreset) settings.setValue(SETTING_PRESET, static_cast(DEFAULT_PRESET)); @@ -80,18 +80,19 @@ void AudioSettings::normalize(Settings& settings) break; } - int settingBufferSize = settings.getInt(SETTING_BUFFER_SIZE); + const int settingBufferSize = settings.getInt(SETTING_BUFFER_SIZE); if (settingBufferSize < 0 || settingBufferSize > MAX_BUFFER_SIZE) settings.setValue(SETTING_BUFFER_SIZE, DEFAULT_BUFFER_SIZE); - int settingHeadroom = settings.getInt(SETTING_HEADROOM); + const int settingHeadroom = settings.getInt(SETTING_HEADROOM); if (settingHeadroom < 0 || settingHeadroom > MAX_HEADROOM) settings.setValue(SETTING_HEADROOM, DEFAULT_HEADROOM); - int settingResamplingQuality = settings.getInt(SETTING_RESAMPLING_QUALITY); - const ResamplingQuality resamplingQuality = normalizeResamplingQuality(settingResamplingQuality); + const int settingResamplingQuality = settings.getInt(SETTING_RESAMPLING_QUALITY); + const ResamplingQuality resamplingQuality = + normalizeResamplingQuality(settingResamplingQuality); if (static_cast(resamplingQuality) != settingResamplingQuality) settings.setValue(SETTING_RESAMPLING_QUALITY, static_cast(DEFAULT_RESAMPLING_QUALITY)); - int settingVolume = settings.getInt(SETTING_VOLUME); + const int settingVolume = settings.getInt(SETTING_VOLUME); if (settingVolume < 0 || settingVolume > 100) settings.setValue(SETTING_VOLUME, DEFAULT_VOLUME); } diff --git a/src/common/FBBackendSDL2.cxx b/src/common/FBBackendSDL2.cxx index 117c6c551..83b199a2a 100644 --- a/src/common/FBBackendSDL2.cxx +++ b/src/common/FBBackendSDL2.cxx @@ -309,7 +309,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode, mode.screenS.w, mode.screenS.h, flags); if(myWindow == nullptr) { - string msg = "ERROR: Unable to open SDL window: " + string(SDL_GetError()); + const string msg = "ERROR: Unable to open SDL window: " + string(SDL_GetError()); Logger::error(msg); return false; } @@ -438,7 +438,7 @@ bool FBBackendSDL2::createRenderer() if(myRenderer == nullptr) { - string msg = "ERROR: Unable to create SDL renderer: " + string(SDL_GetError()); + const string msg = "ERROR: Unable to create SDL renderer: " + string(SDL_GetError()); Logger::error(msg); return false; } diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index f3e085888..44c54eb36 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -131,7 +131,7 @@ uInt32 HighScoresManager::numVariations(const json& jprops) bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR, ScoresProps& info) const { - json jprops = properties(props); + const json jprops = properties(props); numVariationsR = numVariations(jprops); @@ -313,7 +313,7 @@ Int32 HighScoresManager::variation(uInt16 addr, bool varBCD, bool zeroBased, Int32 HighScoresManager::variation() const { json jprops; - uInt16 addr = varAddress(properties(jprops)); + const uInt16 addr = varAddress(properties(jprops)); if(addr == DEFAULT_ADDRESS) { if(numVariations() == 1) @@ -361,7 +361,7 @@ Int32 HighScoresManager::score(uInt32 numAddrBytes, uInt32 trailingZeroes, Int32 HighScoresManager::score() const { json jprops; - uInt32 numBytes = numAddrBytes(properties(jprops)); + const uInt32 numBytes = numAddrBytes(properties(jprops)); const ScoreAddresses scoreAddr = getPropScoreAddr(jprops); if(static_cast(scoreAddr.size()) < numBytes) @@ -432,7 +432,7 @@ Int32 HighScoresManager::special() const return NO_VALUE; json jprops; - uInt16 addr = specialAddress(properties(jprops)); + const uInt16 addr = specialAddress(properties(jprops)); if (addr == DEFAULT_ADDRESS) return NO_VALUE; diff --git a/src/common/JPGLibrary.cxx b/src/common/JPGLibrary.cxx index 175b141d6..ebeceedd2 100644 --- a/src/common/JPGLibrary.cxx +++ b/src/common/JPGLibrary.cxx @@ -36,7 +36,7 @@ JPGLibrary::JPGLibrary(OSystem& osystem) void JPGLibrary::loadImage(const string& filename, FBSurface& surface, VariantList& metaData) { - const auto loadImageERROR = [&](const char* s) { + const auto loadImageERROR = [](const char* s) { if(s) throw runtime_error(s); }; diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index 6f679f040..abe16b589 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -248,11 +248,21 @@ int JoyMap::loadMapping(const json& eventMappings, const EventMode mode) int i = 0; for(const json& eventMapping : eventMappings) { - int button = eventMapping.contains("button") ? eventMapping.at("button").get() : JOY_CTRL_NONE; - JoyAxis axis = eventMapping.contains("axis") ? eventMapping.at("axis").get() : JoyAxis::NONE; - JoyDir axisDirection = eventMapping.contains("axis") ? eventMapping.at("axisDirection").get() : JoyDir::NONE; - int hat = eventMapping.contains("hat") ? eventMapping.at("hat").get() : -1; - JoyHatDir hatDirection = eventMapping.contains("hat") ? eventMapping.at("hatDirection").get() : JoyHatDir::CENTER; + const int button = eventMapping.contains("button") + ? eventMapping.at("button").get() + : JOY_CTRL_NONE; + const JoyAxis axis = eventMapping.contains("axis") + ? eventMapping.at("axis").get() + : JoyAxis::NONE; + const JoyDir axisDirection = eventMapping.contains("axis") + ? eventMapping.at("axisDirection").get() + : JoyDir::NONE; + const int hat = eventMapping.contains("hat") + ? eventMapping.at("hat").get() + : -1; + const JoyHatDir hatDirection = eventMapping.contains("hat") + ? eventMapping.at("hatDirection").get() + : JoyHatDir::CENTER; try { // avoid blocking mappings for NoType events diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index e05e90f02..3ceab78a8 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -29,7 +29,7 @@ namespace { json serializedMask = json::array(); - for(StellaMod mod: { + for(const StellaMod mod: { StellaMod::KBDM_CTRL, StellaMod::KBDM_SHIFT, StellaMod::KBDM_ALT, @@ -207,15 +207,16 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -KeyMap::MappingArray KeyMap::getEventMapping(const Event::Type event, const EventMode mode) const +KeyMap::MappingArray KeyMap::getEventMapping(const Event::Type event, + const EventMode mode) const { - MappingArray map; + MappingArray ma; for (const auto& [_mapping, _event]: myMap) if (_event == event && _mapping.mode == mode) - map.push_back(_mapping); + ma.push_back(_mapping); - return map; + return ma; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/Logger.cxx b/src/common/Logger.cxx index 2f5fb6047..add0fc2b9 100644 --- a/src/common/Logger.cxx +++ b/src/common/Logger.cxx @@ -51,7 +51,7 @@ void Logger::debug(const string& message) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Logger::logMessage(const string& message, Level level) { - std::lock_guard lock(mutex); + const std::lock_guard lock(mutex); if(level == Logger::Level::ERR) { diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index e04828f3a..15dbbbb3b 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -169,8 +169,8 @@ void MouseControl::addLeftControllerModes(bool noswap) { ostringstream msg; msg << "Mouse is left " << myLeftController.name() << " controller"; - Controller::Type type = myLeftController.type(); - int id = noswap ? 0 : 1; + const Controller::Type type = myLeftController.type(); + const int id = noswap ? 0 : 1; myModeList.emplace_back(type, id, type, id, msg.str()); } } @@ -190,8 +190,8 @@ void MouseControl::addRightControllerModes(bool noswap) { ostringstream msg; msg << "Mouse is right " << myRightController.name() << " controller"; - Controller::Type type = myRightController.type(); - int id = noswap ? 1 : 0; + const Controller::Type type = myRightController.type(); + const int id = noswap ? 1 : 0; myModeList.emplace_back(type, id, type, id, msg.str()); } } diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index efb4c4d68..cb4a443b1 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -190,7 +190,7 @@ bool PhysicalJoystickHandler::remove(int id) // So we use the 'active' joystick list to access them try { - PhysicalJoystickPtr stick = mySticks.at(id); + const PhysicalJoystickPtr stick = mySticks.at(id); const auto it = myDatabase.find(stick->name); if(it != myDatabase.end() && it->second.joy == stick) @@ -607,7 +607,7 @@ void PhysicalJoystickHandler::enableMapping(const Event::Type event, EventMode m { const PhysicalJoystickPtr j = stick.second; - JoyMap::JoyMappingArray joyMappings = j->joyMap.getEventMapping(event, mode); + const JoyMap::JoyMappingArray joyMappings = j->joyMap.getEventMapping(event, mode); for (const auto& mapping : joyMappings) j->joyMap.add(event, EventMode::kEmulationMode, mapping.button, @@ -713,7 +713,7 @@ void PhysicalJoystickHandler::saveMapping() for(const auto& [_name, _info]: myDatabase) { - json map = _info.joy ? _info.joy->getMap() : _info.mapping; + const json map = _info.joy ? _info.joy->getMap() : _info.mapping; if (!map.is_null()) mapping.emplace_back(map); } @@ -1042,8 +1042,9 @@ ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeDigitalDeadZone(int direction) { - int deadZone = BSPF::clamp(myOSystem.settings().getInt("joydeadzone") + direction, - Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); + const int deadZone = + BSPF::clamp(myOSystem.settings().getInt("joydeadzone") + direction, + Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); myOSystem.settings().setValue("joydeadzone", deadZone); Controller::setDigitalDeadZone(deadZone); @@ -1051,15 +1052,17 @@ void PhysicalJoystickHandler::changeDigitalDeadZone(int direction) ostringstream ss; ss << std::round(Controller::digitalDeadZoneValue(deadZone) * 100.F / 32768) << "%"; - myOSystem.frameBuffer().showGaugeMessage("Digital controller dead zone", ss. str(), deadZone, - Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); + myOSystem.frameBuffer().showGaugeMessage( + "Digital controller dead zone", ss. str(), deadZone, + Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeAnalogPaddleDeadZone(int direction) { - int deadZone = BSPF::clamp(myOSystem.settings().getInt("adeadzone") + direction, - Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); + const int deadZone = + BSPF::clamp(myOSystem.settings().getInt("adeadzone") + direction, + Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); myOSystem.settings().setValue("adeadzone", deadZone); Controller::setAnalogDeadZone(deadZone); @@ -1067,15 +1070,17 @@ void PhysicalJoystickHandler::changeAnalogPaddleDeadZone(int direction) ostringstream ss; ss << std::round(Controller::analogDeadZoneValue(deadZone) * 100.F / 32768) << "%"; - myOSystem.frameBuffer().showGaugeMessage("Analog controller dead zone", ss.str(), deadZone, - Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); + myOSystem.frameBuffer().showGaugeMessage( + "Analog controller dead zone", ss.str(), deadZone, + Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeAnalogPaddleSensitivity(int direction) { - int sense = BSPF::clamp(myOSystem.settings().getInt("psense") + direction, - Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE); + const int sense = + BSPF::clamp(myOSystem.settings().getInt("psense") + direction, + Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE); myOSystem.settings().setValue("psense", sense); Paddles::setAnalogSensitivity(sense); @@ -1083,15 +1088,17 @@ void PhysicalJoystickHandler::changeAnalogPaddleSensitivity(int direction) ostringstream ss; ss << std::round(Paddles::analogSensitivityValue(sense) * 100.F) << "%"; - myOSystem.frameBuffer().showGaugeMessage("Analog paddle sensitivity", ss.str(), sense, - Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE); + myOSystem.frameBuffer().showGaugeMessage( + "Analog paddle sensitivity", ss.str(), sense, + Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeAnalogPaddleLinearity(int direction) { - int linear = BSPF::clamp(myOSystem.settings().getInt("plinear") + direction * 5, - Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY); + const int linear = + BSPF::clamp(myOSystem.settings().getInt("plinear") + direction * 5, + Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY); myOSystem.settings().setValue("plinear", linear); Paddles::setAnalogLinearity(linear); @@ -1102,15 +1109,17 @@ void PhysicalJoystickHandler::changeAnalogPaddleLinearity(int direction) else ss << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Analog paddle linearity", ss.str(), linear, - Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY); + myOSystem.frameBuffer().showGaugeMessage( + "Analog paddle linearity", ss.str(), linear, + Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changePaddleDejitterAveraging(int direction) { - int dejitter = BSPF::clamp(myOSystem.settings().getInt("dejitter.base") + direction, - Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); + const int dejitter = + BSPF::clamp(myOSystem.settings().getInt("dejitter.base") + direction, + Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); myOSystem.settings().setValue("dejitter.base", dejitter); Paddles::setDejitterBase(dejitter); @@ -1121,16 +1130,17 @@ void PhysicalJoystickHandler::changePaddleDejitterAveraging(int direction) else ss << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Analog paddle dejitter averaging", - ss.str(), dejitter, - Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); + myOSystem.frameBuffer().showGaugeMessage( + "Analog paddle dejitter averaging", ss.str(), dejitter, + Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changePaddleDejitterReaction(int direction) { - int dejitter = BSPF::clamp(myOSystem.settings().getInt("dejitter.diff") + direction, - Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); + const int dejitter = + BSPF::clamp(myOSystem.settings().getInt("dejitter.diff") + direction, + Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); myOSystem.settings().setValue("dejitter.diff", dejitter); Paddles::setDejitterDiff(dejitter); @@ -1141,16 +1151,17 @@ void PhysicalJoystickHandler::changePaddleDejitterReaction(int direction) else ss << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Analog paddle dejitter reaction", - ss.str(), dejitter, - Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); + myOSystem.frameBuffer().showGaugeMessage( + "Analog paddle dejitter reaction", ss.str(), dejitter, + Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeDigitalPaddleSensitivity(int direction) { - int sense = BSPF::clamp(myOSystem.settings().getInt("dsense") + direction, - Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE); + const int sense = + BSPF::clamp(myOSystem.settings().getInt("dsense") + direction, + Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE); myOSystem.settings().setValue("dsense", sense); Paddles::setDigitalSensitivity(sense); @@ -1161,16 +1172,17 @@ void PhysicalJoystickHandler::changeDigitalPaddleSensitivity(int direction) else ss << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Digital sensitivity", - ss.str(), sense, - Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE); + myOSystem.frameBuffer().showGaugeMessage( + "Digital sensitivity", ss.str(), sense, + Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeMousePaddleSensitivity(int direction) { - int sense = BSPF::clamp(myOSystem.settings().getInt("msense") + direction, - Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); + const int sense = + BSPF::clamp(myOSystem.settings().getInt("msense") + direction, + Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); myOSystem.settings().setValue("msense", sense); Controller::setMouseSensitivity(sense); @@ -1178,16 +1190,17 @@ void PhysicalJoystickHandler::changeMousePaddleSensitivity(int direction) ostringstream ss; ss << sense * 10 << "%"; - myOSystem.frameBuffer().showGaugeMessage("Mouse paddle sensitivity", - ss.str(), sense, - Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); + myOSystem.frameBuffer().showGaugeMessage( + "Mouse paddle sensitivity", ss.str(), sense, + Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeMouseTrackballSensitivity(int direction) { - int sense = BSPF::clamp(myOSystem.settings().getInt("tsense") + direction, - PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE); + const int sense = + BSPF::clamp(myOSystem.settings().getInt("tsense") + direction, + PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE); myOSystem.settings().setValue("tsense", sense); PointingDevice::setSensitivity(sense); @@ -1195,16 +1208,17 @@ void PhysicalJoystickHandler::changeMouseTrackballSensitivity(int direction) ostringstream ss; ss << sense * 10 << "%"; - myOSystem.frameBuffer().showGaugeMessage("Mouse trackball sensitivity", - ss.str(), sense, - PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE); + myOSystem.frameBuffer().showGaugeMessage( + "Mouse trackball sensitivity", ss.str(), sense, + PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystickHandler::changeDrivingSensitivity(int direction) { - int sense = BSPF::clamp(myOSystem.settings().getInt("dcsense") + direction, - Driving::MIN_SENSE, Driving::MAX_SENSE); + const int sense = + BSPF::clamp(myOSystem.settings().getInt("dcsense") + direction, + Driving::MIN_SENSE, Driving::MAX_SENSE); myOSystem.settings().setValue("dcsense", sense); Driving::setSensitivity(sense); @@ -1212,9 +1226,9 @@ void PhysicalJoystickHandler::changeDrivingSensitivity(int direction) ostringstream ss; ss << sense * 10 << "%"; - myOSystem.frameBuffer().showGaugeMessage("Driving controller sensitivity", - ss.str(), sense, - Driving::MIN_SENSE, Driving::MAX_SENSE); + myOSystem.frameBuffer().showGaugeMessage( + "Driving controller sensitivity", ss.str(), sense, + Driving::MIN_SENSE, Driving::MAX_SENSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 4c45d3b49..369490722 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -44,7 +44,7 @@ PhysicalKeyboardHandler::PhysicalKeyboardHandler(OSystem& system, EventHandler& : myOSystem{system}, myHandler{handler} { - Int32 version = myOSystem.settings().getInt("event_ver"); + const Int32 version = myOSystem.settings().getInt("event_ver"); bool updateDefaults = false; // Compare if event list version has changed so that key maps became invalid @@ -396,7 +396,7 @@ void PhysicalKeyboardHandler::enableMapping(const Event::Type event, EventMode mode) { // copy from controller mode into emulation mode - KeyMap::MappingArray mappings = myKeyMap.getEventMapping(event, mode); + const KeyMap::MappingArray mappings = myKeyMap.getEventMapping(event, mode); for (const auto& mapping : mappings) myKeyMap.add(event, EventMode::kEmulationMode, mapping.key, mapping.mod); diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index d2fa8114d..cd49155cf 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -295,9 +295,9 @@ void PNGLibrary::takeSnapshot(uInt32 number) // Figure out the correct snapshot name string filename; - string sspath = myOSystem.snapshotSaveDir().getPath() + - (myOSystem.settings().getString("snapname") != "int" ? - myOSystem.romFile().getNameWithExt() + const string sspath = myOSystem.snapshotSaveDir().getPath() + + (myOSystem.settings().getString("snapname") != "int" + ? myOSystem.romFile().getNameWithExt("") : myOSystem.console().properties().get(PropType::Cart_Name)); // Check whether we want multiple snapshots created @@ -313,7 +313,7 @@ void PNGLibrary::takeSnapshot(uInt32 number) // Determine if the file already exists, checking each successive filename // until one doesn't exist filename = sspath + ".png"; - FSNode node(filename); + const FSNode node(filename); if(node.exists()) { ostringstream buf; @@ -321,7 +321,7 @@ void PNGLibrary::takeSnapshot(uInt32 number) { buf.str(""); buf << sspath << "_" << i << ".png"; - FSNode next(buf.str()); + const FSNode next(buf.str()); if(!next.exists()) break; } diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index c8a9987e5..94b719e0a 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -477,7 +477,6 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const float G = Y + dotProduct(IQ[chroma], IQG); float B = Y + dotProduct(IQ[chroma], IQB); - if(R < 0) R = 0; if(G < 0) G = 0; if(B < 0) B = 0; @@ -486,9 +485,9 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const G = powf(G, 0.9F); B = powf(B, 0.9F); - int r = BSPF::clamp(R * 255.F, 0.F, 255.F); - int g = BSPF::clamp(G * 255.F, 0.F, 255.F); - int b = BSPF::clamp(B * 255.F, 0.F, 255.F); + const int r = BSPF::clamp(R * 255.F, 0.F, 255.F), + g = BSPF::clamp(G * 255.F, 0.F, 255.F), + b = BSPF::clamp(B * 255.F, 0.F, 255.F); ourCustomNTSCPalette[(chroma * NUM_LUMA + luma) << 1] = (r << 16) + (g << 8) + b; } @@ -504,7 +503,7 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const // colors 0, 1, 14 and 15 are grayscale for(int chroma = 2; chroma < NUM_CHROMA - 2; chroma++) { - int idx = NUM_CHROMA - 1 - chroma; + const int idx = NUM_CHROMA - 1 - chroma; UV[idx].x = SATURATION * sinf(offset - fixedShift * chroma); if ((idx & 1) == 0) @@ -539,9 +538,9 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const G = powf(G, 1.2F); B = powf(B, 1.2F); - int r = BSPF::clamp(R * 255.F, 0.F, 255.F); - int g = BSPF::clamp(G * 255.F, 0.F, 255.F); - int b = BSPF::clamp(B * 255.F, 0.F, 255.F); + const int r = BSPF::clamp(R * 255.F, 0.F, 255.F), + g = BSPF::clamp(G * 255.F, 0.F, 255.F), + b = BSPF::clamp(B * 255.F, 0.F, 255.F); ourCustomPALPalette[(chroma * NUM_LUMA + luma) << 1] = (r << 16) + (g << 8) + b; } diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 9053fcae3..7c31bb92a 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -245,7 +245,7 @@ string RewindManager::saveAllStates() const uInt32 curIdx = getCurrentIdx(); rewindStates(MAX_BUF_SIZE); - uInt32 numStates = static_cast(cyclesList().size()); + const uInt32 numStates = static_cast(cyclesList().size()); // Save header buf.str(""); @@ -296,7 +296,7 @@ string RewindManager::loadAllStates() << ".sta"; // Make sure the file can be opened for reading - Serializer in(buf.str(), Serializer::Mode::ReadOnly); + const Serializer in(buf.str(), Serializer::Mode::ReadOnly); if (!in) return "Can't load from all states file"; diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 679a7e641..37e658f20 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -159,7 +159,7 @@ void SoundSDL2::setEnabled(bool enable) void SoundSDL2::open(shared_ptr audioQueue, EmulationTiming* emulationTiming) { - string pre_about = myAboutString; + const string pre_about = myAboutString; // Do we need to re-open the sound device? // Only do this when absolutely necessary @@ -344,12 +344,13 @@ void SoundSDL2::processFragment(float* stream, uInt32 length) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SoundSDL2::initResampler() { - Resampler::NextFragmentCallback nextFragmentCallback = [this] () -> Int16* { + const Resampler::NextFragmentCallback nextFragmentCallback = [this] () -> Int16* { Int16* nextFragment = nullptr; if(myUnderrun) - nextFragment = myAudioQueue->size() >= myEmulationTiming->prebufferFragmentCount() ? - myAudioQueue->dequeue(myCurrentFragment) : nullptr; + nextFragment = myAudioQueue->size() >= myEmulationTiming->prebufferFragmentCount() + ? myAudioQueue->dequeue(myCurrentFragment) + : nullptr; else nextFragment = myAudioQueue->dequeue(myCurrentFragment); @@ -360,10 +361,10 @@ void SoundSDL2::initResampler() return nextFragment; }; - Resampler::Format formatFrom = + const Resampler::Format formatFrom = Resampler::Format(myEmulationTiming->audioSampleRate(), myAudioQueue->fragmentSize(), myAudioQueue->isStereo()); - Resampler::Format formatTo = + const Resampler::Format formatTo = Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1); @@ -401,39 +402,44 @@ void SoundSDL2::callback(void* udata, uInt8* stream, int len) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool SoundSDL2::playWav(const string& fileName, uInt32 position, uInt32 length) +bool SoundSDL2::playWav(const string& fileName, const uInt32 position, + const uInt32 length) { - uInt32 wavLength{0}; - - // Stop any playing WAVs - stopWav(); - // Load WAV file - auto* result = SDL_LoadWAV(fileName.c_str(), &myWavSpec, &myWavBuffer, &wavLength); - if(result == nullptr || position > wavLength) + if(fileName != myWavFilename || myWavBuffer == nullptr) + { + if(myWavBuffer) + { + SDL_FreeWAV(myWavBuffer); + myWavBuffer = nullptr; + } + if(SDL_LoadWAV(fileName.c_str(), &myWavSpec, &myWavBuffer, &myWavLength) == nullptr) + return false; + // Set the callback function + myWavSpec.callback = wavCallback; + myWavSpec.userdata = nullptr; + } + if(position > myWavLength) return false; - length = length - ? std::min(length, wavLength - position) - : wavLength; - - // Set the callback function - myWavSpec.callback = wavCallback; - myWavSpec.userdata = nullptr; + myWavFilename = fileName; + myWavLen = length + ? std::min(length, myWavLength - position) + : myWavLength; myWavPos = myWavBuffer + position; - myWavLen = length; // Open audio device - const char* device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() : nullptr; - - myWavDevice = SDL_OpenAudioDevice(device, 0, &myWavSpec, nullptr, 0); if(!myWavDevice) - return false; - - // Play audio - SDL_PauseAudioDevice(myWavDevice, 0); + { + const char* device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() : nullptr; + myWavDevice = SDL_OpenAudioDevice(device, 0, &myWavSpec, nullptr, 0); + if(!myWavDevice) + return false; + // Play audio + SDL_PauseAudioDevice(myWavDevice, 0); + } return true; } @@ -443,9 +449,10 @@ void SoundSDL2::stopWav() if(myWavBuffer) { // Clean up + myWavLen = 0; SDL_CloseAudioDevice(myWavDevice); + myWavDevice = 0; SDL_FreeWAV(myWavBuffer); - myWavBuffer = nullptr; } } diff --git a/src/common/SoundSDL2.hxx b/src/common/SoundSDL2.hxx index b2b9b4ee6..60868b2f9 100644 --- a/src/common/SoundSDL2.hxx +++ b/src/common/SoundSDL2.hxx @@ -116,8 +116,8 @@ class SoundSDL2 : public Sound @return True, if the WAV file can be played */ - bool playWav(const string& fileName, uInt32 position = 0, - uInt32 length = 0) override; + bool playWav(const string& fileName, const uInt32 position = 0, + const uInt32 length = 0) override; /** Stop any currently playing WAV file. @@ -186,6 +186,8 @@ class SoundSDL2 : public Sound AudioSettings& myAudioSettings; // WAV file sound variables + string myWavFilename{EmptyString}; + uInt32 myWavLength{0}; SDL_AudioDeviceID myWavDevice{0}; uInt8* myWavBuffer{nullptr}; diff --git a/src/common/StaggeredLogger.cxx b/src/common/StaggeredLogger.cxx index 62210c287..d7ab3d892 100644 --- a/src/common/StaggeredLogger.cxx +++ b/src/common/StaggeredLogger.cxx @@ -25,7 +25,7 @@ using namespace std::chrono; namespace { string currentTimestamp() { - std::tm now = BSPF::localTime(); + const std::tm now = BSPF::localTime(); std::array formattedTime; formattedTime.fill(0); @@ -57,7 +57,7 @@ StaggeredLogger::~StaggeredLogger() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StaggeredLogger::log() { - std::lock_guard lock(myMutex); + const std::lock_guard lock(myMutex); _log(); } @@ -132,7 +132,7 @@ void StaggeredLogger::startInterval() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StaggeredLogger::onTimerExpired(uInt32 timerCallbackId) { - std::lock_guard lock(myMutex); + const std::lock_guard lock(myMutex); if (timerCallbackId != myTimerCallbackId) return; diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index 48a873fbb..11689550a 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -313,7 +313,7 @@ void StateManager::changeState(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StateManager::toggleAutoSlot() { - bool autoSlot = !myOSystem.settings().getBool("autoslot"); + const bool autoSlot = !myOSystem.settings().getBool("autoslot"); // Print appropriate message ostringstream buf; diff --git a/src/common/TimerManager.cxx b/src/common/TimerManager.cxx index b0ffdd34d..1f058f22f 100644 --- a/src/common/TimerManager.cxx +++ b/src/common/TimerManager.cxx @@ -98,14 +98,14 @@ void TimerManager::clear() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::size_t TimerManager::size() const noexcept { - ScopedLock lock(sync); + const ScopedLock lock(sync); return active.size(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool TimerManager::empty() const noexcept { - ScopedLock lock(sync); + const ScopedLock lock(sync); return active.empty(); } diff --git a/src/common/ZipHandler.cxx b/src/common/ZipHandler.cxx index 461b0f396..7a986f3b1 100644 --- a/src/common/ZipHandler.cxx +++ b/src/common/ZipHandler.cxx @@ -284,7 +284,7 @@ void ZipHandler::ZipFile::readEcd() buflen = myLength; // Allocate buffer - ByteBuffer buffer = make_unique(buflen + 1); + const ByteBuffer buffer = make_unique(buflen + 1); if(buffer == nullptr) throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY)); diff --git a/src/common/main.cxx b/src/common/main.cxx index 61f8b5f3f..4b3bed980 100644 --- a/src/common/main.cxx +++ b/src/common/main.cxx @@ -259,7 +259,7 @@ int main(int ac, char* av[]) // Check to see if the user requested info about a specific ROM, // or the list of internal ROMs // If so, show the information and immediately exit - string romfile = localOpts["ROMFILE"].toString(); + const string romfile = localOpts["ROMFILE"].toString(); if(localOpts["listrominfo"].toBool()) { attachConsole(); @@ -272,7 +272,7 @@ int main(int ac, char* av[]) { attachConsole(); Logger::debug("Showing output from 'rominfo' ..."); - FSNode romnode(romfile); + const FSNode romnode(romfile); Logger::error(theOSystem->getROMInfo(romnode)); freeConsole(); return Cleanup(); @@ -293,11 +293,11 @@ int main(int ac, char* av[]) // open the rom launcher in that directory. // If not, use the built-in ROM launcher. In this case, we enter 'launcher' // mode and let the main event loop take care of opening a new console/ROM. - FSNode romnode(romfile); + const FSNode romnode(romfile); if(romfile.empty() || romnode.isDirectory()) { Logger::debug("Attempting to use ROM launcher ..."); - bool launcherOpened = !romfile.empty() ? + const bool launcherOpened = !romfile.empty() ? theOSystem->createLauncher(romnode.getPath()) : theOSystem->createLauncher(); if(!launcherOpened) { @@ -336,7 +336,7 @@ int main(int ac, char* av[]) if(!localOpts["break"].toString().empty()) { Debugger& dbg = theOSystem->debugger(); - uInt16 bp = uInt16(dbg.stringToValue(localOpts["break"].toString())); + const uInt16 bp = uInt16(dbg.stringToValue(localOpts["break"].toString())); dbg.setBreakPoint(bp); } #endif diff --git a/src/common/repository/KeyValueRepositoryJsonFile.cxx b/src/common/repository/KeyValueRepositoryJsonFile.cxx index a49e9afe9..a72486c2b 100644 --- a/src/common/repository/KeyValueRepositoryJsonFile.cxx +++ b/src/common/repository/KeyValueRepositoryJsonFile.cxx @@ -23,7 +23,7 @@ using nlohmann::json; namespace { json jsonIfValid(const string& s) { - json parsed = json::parse(s, nullptr, false); + const json parsed = json::parse(s, nullptr, false); return parsed.is_discarded() ? json(s) : parsed; } diff --git a/src/common/repository/sqlite/SqliteDatabase.cxx b/src/common/repository/sqlite/SqliteDatabase.cxx index 92db05671..9a66c5878 100644 --- a/src/common/repository/sqlite/SqliteDatabase.cxx +++ b/src/common/repository/sqlite/SqliteDatabase.cxx @@ -60,7 +60,7 @@ void SqliteDatabase::initialize() if (!dbInitialized) { if (myHandle) { - string emsg = sqlite3_errmsg(myHandle); + const string emsg = sqlite3_errmsg(myHandle); sqlite3_close_v2(myHandle); myHandle = nullptr; diff --git a/src/common/sdl_blitter/BilinearBlitter.cxx b/src/common/sdl_blitter/BilinearBlitter.cxx index da1cea870..cc96d6d9c 100644 --- a/src/common/sdl_blitter/BilinearBlitter.cxx +++ b/src/common/sdl_blitter/BilinearBlitter.cxx @@ -68,7 +68,7 @@ void BilinearBlitter::free() ASSERT_MAIN_THREAD; - std::array textures = { myTexture, mySecondaryTexture }; + const std::array textures = { myTexture, mySecondaryTexture }; for (SDL_Texture* texture: textures) { if (!texture) continue; @@ -128,7 +128,7 @@ void BilinearBlitter::recreateTexturesIfNecessary() if (myAttributes.blending) { const auto blendAlpha = static_cast(myAttributes.blendalpha * 2.55); - std::array textures = { myTexture, mySecondaryTexture }; + const std::array textures = { myTexture, mySecondaryTexture }; for (SDL_Texture* texture: textures) { if (!texture) continue; diff --git a/src/common/sdl_blitter/QisBlitter.cxx b/src/common/sdl_blitter/QisBlitter.cxx index 431ba0707..4752fd6c3 100644 --- a/src/common/sdl_blitter/QisBlitter.cxx +++ b/src/common/sdl_blitter/QisBlitter.cxx @@ -75,7 +75,7 @@ void QisBlitter::free() ASSERT_MAIN_THREAD; - std::array textures = { + const std::array textures = { mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture }; for (SDL_Texture* texture: textures) { @@ -183,7 +183,7 @@ void QisBlitter::recreateTexturesIfNecessary() if (myAttributes.blending) { const auto blendAlpha = static_cast(myAttributes.blendalpha * 2.55); - std::array textures = { + const std::array textures = { mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture }; for (SDL_Texture* texture: textures) { diff --git a/src/common/tv_filters/AtariNTSC.cxx b/src/common/tv_filters/AtariNTSC.cxx index 6990f95af..a3228ceb8 100644 --- a/src/common/tv_filters/AtariNTSC.cxx +++ b/src/common/tv_filters/AtariNTSC.cxx @@ -343,12 +343,10 @@ void AtariNTSC::init(init_t& impl, const Setup& setup) int n2 = 3; do { - float i = *in++; - float q = *in++; - *out++ = i; - *out++ = q; + *out++ = *in++; + *out++ = *in++; } - while ( --n2 ); + while (--n2); #if 0 // burst_count is always 0 if ( burst_count > 1 ) ROTATE_IQ( s, c, 0.866025F, -0.5F ); /* +120 degrees */ @@ -387,7 +385,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup) pow_a_n * cosf( maxh * angle ) + pow_a_n * rolloff * cosf( (maxh - 1) * angle ); const float den = 1 - rolloff_cos_a - rolloff_cos_a + rolloff * rolloff; - float dsf = num / den; + const float dsf = num / den; kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - 0.5F; } } @@ -397,7 +395,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup) for ( int i = 0; i < kernel_half * 2 + 1; i++ ) { const float x = BSPF::PI_f * 2 / (kernel_half * 2) * i; - float blackman = 0.42F - 0.5F * cosf( x ) + 0.08F * cosf( x * 2 ); + const float blackman = 0.42F - 0.5F * cosf( x ) + 0.08F * cosf( x * 2 ); sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman); } @@ -454,12 +452,12 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup) for ( int i = 0; i < kernel_size * 2; i++ ) { const float cur = kernels [i]; - float m = cur * weight; + const float m = cur * weight; *out++ = m + remain; remain = cur - m; } } - while ( --n ); + while (--n); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/BreakpointMap.cxx b/src/debugger/BreakpointMap.cxx index ece14d4f2..cc999b5e8 100644 --- a/src/debugger/BreakpointMap.cxx +++ b/src/debugger/BreakpointMap.cxx @@ -101,7 +101,7 @@ bool BreakpointMap::check(const uInt16 addr, const uInt8 bank) const BreakpointMap::BreakpointList BreakpointMap::getBreakpoints() const { BreakpointList map; - std::map ordered(myMap.begin(), myMap.end()); + const std::map ordered(myMap.begin(), myMap.end()); for(const auto& item : ordered) map.push_back(item.first); diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 22561c378..67547ceda 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -386,8 +386,8 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, Disassembly& disassembly, disassembly.fieldwidth = 24 + myLabelLength; // line offset must be set before calling DiStella! auto lineOfs = static_cast(myDisassembly.list.size()); - DiStella distella(*this, disassembly.list, info, DiStella::settings, - myDisLabels, myDisDirectives, myReserved); + const DiStella distella(*this, disassembly.list, info, DiStella::settings, + myDisLabels, myDisDirectives, myReserved); // Parts of the disassembly will be accessed later in different ways // We place those parts in separate maps, to speed up access @@ -812,7 +812,7 @@ string CartDebug::loadListFile() // The default naming/location for list files is the ROM dir based on the // actual ROM filename - FSNode lst(myOSystem.romFile().getPathWithExt(".lst")); + const FSNode lst(myOSystem.romFile().getPathWithExt(".lst")); if(!lst.isReadable()) return DebuggerParser::red("list file \'" + lst.getShortPath() + "\' not found"); @@ -873,7 +873,7 @@ string CartDebug::loadSymbolFile() // The default naming/location for symbol files is the ROM dir based on the // actual ROM filename - FSNode sym(myOSystem.romFile().getPathWithExt(".sym")); + const FSNode sym(myOSystem.romFile().getPathWithExt(".sym")); if(!sym.isReadable()) return DebuggerParser::red("symbol file \'" + sym.getShortPath() + "\' not found"); @@ -934,7 +934,7 @@ string CartDebug::loadConfigFile() // The default naming/location for config files is the CFG dir and based // on the actual ROM filename - FSNode romNode(myOSystem.romFile().getPathWithExt(".cfg")); + const FSNode romNode(myOSystem.romFile().getPathWithExt(".cfg")); FSNode cfg = myOSystem.cfgDir(); cfg /= romNode.getName(); if(!cfg.isReadable()) return DebuggerParser::red("config file \'" + cfg.getShortPath() + "\' not found"); @@ -1073,7 +1073,7 @@ string CartDebug::saveConfigFile() stringstream retVal; try { - FSNode romNode(myOSystem.romFile().getPathWithExt(".cfg")); + const FSNode romNode(myOSystem.romFile().getPathWithExt(".cfg")); FSNode cfg = myOSystem.cfgDir(); cfg /= romNode.getName(); if(!cfg.getParent().isWritable()) return DebuggerParser::red("config file \'" + cfg.getShortPath() + "\' not writable"); @@ -1145,8 +1145,8 @@ string CartDebug::saveDisassembly(string path) // Disassemble bank disasm.list.clear(); - DiStella distella(*this, disasm.list, info, settings, - myDisLabels, myDisDirectives, myReserved); + const DiStella distella(*this, disasm.list, info, settings, + myDisLabels, myDisDirectives, myReserved); if (myReserved.breakFound) addLabel("Break", myDebugger.dpeek(0xfffe)); @@ -1258,7 +1258,7 @@ string CartDebug::saveDisassembly(string path) if(myConsole.timing() == ConsoleTiming::ntsc) { - string NTSC_COLOR[16] = { + const string NTSC_COLOR[16] = { "BLACK", "YELLOW", "BROWN", "ORANGE", "RED", "MAUVE", "VIOLET", "PURPLE", "BLUE", "BLUE_CYAN", "CYAN", "CYAN_GREEN", @@ -1270,7 +1270,7 @@ string CartDebug::saveDisassembly(string path) } else if(myConsole.timing() == ConsoleTiming::pal) { - string PAL_COLOR[16] = { + const string PAL_COLOR[16] = { "BLACK0", "BLACK1", "YELLOW", "GREEN_YELLOW", "ORANGE", "GREEN", "RED", "CYAN_GREEN", "MAUVE", "CYAN", "VIOLET", "BLUE_CYAN", @@ -1282,7 +1282,7 @@ string CartDebug::saveDisassembly(string path) } else { - string SECAM_COLOR[8] = { + const string SECAM_COLOR[8] = { "BLACK", "BLUE", "RED", "PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE" }; @@ -1410,7 +1410,7 @@ string CartDebug::saveDisassembly(string path) if(path.find_last_of('.') == string::npos) path += ".asm"; - FSNode node(path); + const FSNode node(path); stringstream retVal; try { @@ -1438,7 +1438,7 @@ string CartDebug::saveRom(string path) if(path.find_last_of('.') == string::npos) path += ".a26"; - FSNode node(path); + const FSNode node(path); if(myConsole.cartridge().saveROM(node)) return "saved ROM as " + node.getShortPath(); @@ -1464,7 +1464,7 @@ string CartDebug::saveAccessFile(string path) if(path.find_last_of('.') == string::npos) path += ".csv"; - FSNode node(path); + const FSNode node(path); node.write(out); return "saved access counters as " + node.getShortPath(); @@ -1489,7 +1489,7 @@ string CartDebug::listConfig(int bank) buf << "(items marked '*' are user-defined)" << endl; for(uInt32 b = startbank; b < endbank; ++b) { - BankInfo& info = myBankInfo[b]; + const BankInfo& info = myBankInfo[b]; buf << "Bank [" << b << "]" << endl; for(const auto& i: info.directiveList) { diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 0f99bf825..ad39ae5e3 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -112,7 +112,7 @@ void Debugger::initialize() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FBInitStatus Debugger::initializeVideo() { - string title = string("Stella ") + STELLA_VERSION + ": Debugger mode"; + const string title = string("Stella ") + STELLA_VERSION + ": Debugger mode"; return myOSystem.frameBuffer().createDisplay( title, BufferType::Debugger, mySize ); @@ -177,13 +177,13 @@ string Debugger::autoExec(StringList* history) ostringstream buf; // autoexec.script is always run - FSNode autoexec(myOSystem.baseDir().getPath() + "autoexec.script"); + const FSNode autoexec(myOSystem.baseDir().getPath() + "autoexec.script"); buf << "autoExec():" << endl << myParser->exec(autoexec, history) << endl; // Also, "romname.script" if present const string path = myOSystem.userDir().getPath() + myOSystem.romFile().getNameWithExt(".script"); - FSNode romname(path); + const FSNode romname(path); buf << myParser->exec(romname, history) << endl; // Init builtins diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 052c308cf..60ef25da1 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -165,7 +165,7 @@ string DebuggerParser::exec(const FSNode& file, StringList* history) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerParser::outputCommandError(const string& errorMsg, int command) { - string example = commands[command].extendedDesc.substr(commands[command].extendedDesc.find("Example:")); + const string example = commands[command].extendedDesc.substr(commands[command].extendedDesc.find("Example:")); commandResult << red(errorMsg); if(!example.empty()) @@ -614,8 +614,8 @@ void DebuggerParser::listTraps(bool listCond) string DebuggerParser::trapStatus(const Trap& trap) { stringstream result; - string lblb = debugger.cartDebug().getLabel(trap.begin, !trap.write); - string lble = debugger.cartDebug().getLabel(trap.end, !trap.write); + const string lblb = debugger.cartDebug().getLabel(trap.begin, !trap.write); + const string lble = debugger.cartDebug().getLabel(trap.end, !trap.write); if(!lblb.empty()) { result << " ("; @@ -643,7 +643,7 @@ string DebuggerParser::trapStatus(const Trap& trap) string DebuggerParser::saveScriptFile(string file) { stringstream out; - Debugger::FunctionDefMap funcs = debugger.getFunctionDefMap(); + const Debugger::FunctionDefMap funcs = debugger.getFunctionDefMap(); for(const auto& [name, cmd]: funcs) if (!Debugger::isBuiltinFunction(name)) out << "function " << name << " {" << cmd << "}" << endl; @@ -691,7 +691,7 @@ string DebuggerParser::saveScriptFile(string file) if(file.find_first_of(FSNode::PATH_SEPARATOR) == string::npos) file = debugger.myOSystem.userDir().getPath() + file; - FSNode node(file); + const FSNode node(file); if(node.exists() || out.str().length()) { @@ -770,7 +770,7 @@ void DebuggerParser::executeAud() // "autoSave" void DebuggerParser::executeAutoSave() { - bool enable = !settings.getBool("dbg.autosave"); + const bool enable = !settings.getBool("dbg.autosave"); settings.setValue("dbg.autosave", enable); commandResult << "autoSave " << (enable ? "enabled" : "disabled"); @@ -871,10 +871,10 @@ void DebuggerParser::executeBreak() // "breakIf" void DebuggerParser::executeBreakIf() { - int res = YaccParser::parse(argStrings[0]); + const int res = YaccParser::parse(argStrings[0]); if(res == 0) { - string condition = argStrings[0]; + const string condition = argStrings[0]; for(uInt32 i = 0; i < debugger.m6502().getCondBreakNames().size(); ++i) { if(condition == debugger.m6502().getCondBreakNames()[i]) @@ -1276,7 +1276,7 @@ void DebuggerParser::executeDump() { if(OK) { - stringstream localOut(outStr); + const stringstream localOut(outStr); ostringstream localResult(resultStr, std::ios_base::app); saveDump(node, localOut, localResult); @@ -1350,7 +1350,7 @@ void DebuggerParser::executeFunction() return; } - int res = YaccParser::parse(argStrings[1]); + const int res = YaccParser::parse(argStrings[1]); if(res == 0) { debugger.addFunction(argStrings[0], argStrings[1], YaccParser::getResult()); @@ -1608,8 +1608,6 @@ void DebuggerParser::executeListFunctions() // "listSaveStateIfs" void DebuggerParser::executeListSaveStateIfs() { - ostringstream buf; - StringList conds = debugger.m6502().getCondSaveStateNames(); if(!conds.empty()) { @@ -1629,7 +1627,7 @@ void DebuggerParser::executeListSaveStateIfs() // "listTraps" void DebuggerParser::executeListTraps() { - StringList names = debugger.m6502().getCondTrapNames(); + const StringList names = debugger.m6502().getCondTrapNames(); if(myTraps.size() != names.size()) { @@ -2085,10 +2083,10 @@ void DebuggerParser::executeSaveState() // "saveStateIf" void DebuggerParser::executeSaveStateIf() { - int res = YaccParser::parse(argStrings[0]); + const int res = YaccParser::parse(argStrings[0]); if(res == 0) { - string condition = argStrings[0]; + const string condition = argStrings[0]; for(uInt32 i = 0; i < debugger.m6502().getCondSaveStateNames().size(); ++i) { if(condition == debugger.m6502().getCondSaveStateNames()[i]) @@ -2128,7 +2126,7 @@ void DebuggerParser::executeStep() // "stepWhile" void DebuggerParser::executeStepWhile() { - int res = YaccParser::parse(argStrings[0]); + const int res = YaccParser::parse(argStrings[0]); if(res != 0) { commandResult << red("invalid expression"); return; @@ -2225,9 +2223,9 @@ void DebuggerParser::executeTrapWriteIf() void DebuggerParser::executeTraps(bool read, bool write, const string& command, bool hasCond) { - const uInt32 ofs = hasCond ? 1 : 0; - uInt32 begin = args[ofs]; - uInt32 end = argCount == 2 + ofs ? args[1 + ofs] : begin; + const uInt32 ofs = hasCond ? 1 : 0, + begin = args[ofs], + end = argCount == 2 + ofs ? args[1 + ofs] : begin; if(argCount < 1 + ofs) { @@ -2284,7 +2282,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command, const string condition = conditionBuf.str(); - int res = YaccParser::parse(condition); + const int res = YaccParser::parse(condition); if(res == 0) { // duplicates will remove each other @@ -2309,7 +2307,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command, } if(add) { - uInt32 ret = debugger.m6502().addCondTrap( + const uInt32 ret = debugger.m6502().addCondTrap( YaccParser::getResult(), hasCond ? argStrings[0] : ""); commandResult << "added trap " << Base::toString(ret); @@ -2466,7 +2464,7 @@ void DebuggerParser::executeWatch() void DebuggerParser::executeWinds(bool unwind) { const uInt16 states = (argCount == 0) ? 1 : args[0]; - string type = unwind ? "unwind" : "rewind"; + const string type = unwind ? "unwind" : "rewind"; string message; const uInt16 winds = unwind ? debugger.unwindStates(states, message) diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index f0eea7bf9..c65b1a0b2 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -1139,19 +1139,19 @@ void DiStella::outputGraphics() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DiStella::outputColors() { - string NTSC_COLOR[16] = { + const string NTSC_COLOR[16] = { "BLACK", "YELLOW", "BROWN", "ORANGE", "RED", "MAUVE", "VIOLET", "PURPLE", "BLUE", "BLUE_CYAN", "CYAN", "CYAN_GREEN", "GREEN", "GREEN_YELLOW", "GREEN_BEIGE", "BEIGE" }; - string PAL_COLOR[16] = { + const string PAL_COLOR[16] = { "BLACK0", "BLACK1", "YELLOW", "GREEN_YELLOW", "ORANGE", "GREEN", "RED", "CYAN_GREEN", "MAUVE", "CYAN", "VIOLET", "BLUE_CYAN", "PURPLE", "BLUE", "BLACKE", "BLACKF" }; - string SECAM_COLOR[8] = { + const string SECAM_COLOR[8] = { "BLACK", "BLUE", "RED", "PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE" }; diff --git a/src/debugger/gui/Cart4A50Widget.cxx b/src/debugger/gui/Cart4A50Widget.cxx index 9099d69f6..1ec331945 100644 --- a/src/debugger/gui/Cart4A50Widget.cxx +++ b/src/debugger/gui/Cart4A50Widget.cxx @@ -26,7 +26,7 @@ Cartridge4A50Widget::Cartridge4A50Widget( : CartDebugWidget(boss, lfont, nfont, x, y, w, h), myCart{cart} { - string info = + const string info = "4A50 cartridge - 128K ROM and 32K RAM, split in various bank configurations\n" "Multiple hotspots, see documentation for further details\n" "Lower bank region (2K) : $F000 - $F7FF\n" @@ -55,9 +55,9 @@ Cartridge4A50Widget::Cartridge4A50Widget( VarList::push_back(items256, i); VarList::push_back(items256, "Inactive", ""); - string lowerlabel = "Set lower 2K region ($F000 - $F7FF): "; - string middlelabel = "Set middle 1.5K region ($F800 - $FDFF): "; - string highlabel = "Set high 256B region ($FE00 - $FEFF): "; + const string lowerlabel = "Set lower 2K region ($F000 - $F7FF): "; + const string middlelabel = "Set middle 1.5K region ($F800 - $FDFF): "; + const string highlabel = "Set high 256B region ($FE00 - $FEFF): "; const int lwidth = _font.getStringWidth(middlelabel), fwidth = _font.getStringWidth("Inactive"), flwidth = _font.getStringWidth("ROM "); diff --git a/src/debugger/gui/CartARMWidget.cxx b/src/debugger/gui/CartARMWidget.cxx index 3361e9ce7..46b6895bc 100644 --- a/src/debugger/gui/CartARMWidget.cxx +++ b/src/debugger/gui/CartARMWidget.cxx @@ -141,7 +141,7 @@ void CartridgeARMWidget::saveOldState() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeARMWidget::loadConfig() { - bool devSettings = instance().settings().getBool("dev.settings"); + const bool devSettings = instance().settings().getBool("dev.settings"); IntArray alist; IntArray vlist; BoolArray changed; @@ -218,16 +218,18 @@ void CartridgeARMWidget::handleCommand(CommandSender* sender, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeARMWidget::handleChipType() { - bool devSettings = instance().settings().getBool("dev.settings"); + const bool devSettings = instance().settings().getBool("dev.settings"); myChipType->setEnabled(devSettings); if(devSettings) { - instance().settings().setValue("dev.thumb.chiptype", myChipType->getSelectedTag().toInt()); + instance().settings().setValue("dev.thumb.chiptype", + myChipType->getSelectedTag().toInt()); - Thumbulator::ChipPropsType chipProps - = myCart.setChipType(static_cast(myChipType->getSelectedTag().toInt())); + const Thumbulator::ChipPropsType chipProps = + myCart.setChipType(static_cast + (myChipType->getSelectedTag().toInt())); // update tooltip with currently selecte chip's properties string tip = myChipType->getToolTip(Common::Point(0, 0)); @@ -258,10 +260,9 @@ void CartridgeARMWidget::handleMamMode() // override MAM mode set by ROM const Int32 mode = myMamMode->getSelected(); - string name = myMamMode->getSelectedName(); + const string name = myMamMode->getSelectedName(); myMamMode->setSelectedName(name + "XXX"); - instance().settings().setValue("dev.thumb.mammode", mode); myCart.setMamMode(static_cast(mode)); } diff --git a/src/debugger/gui/CartARWidget.cxx b/src/debugger/gui/CartARWidget.cxx index f29ea71f7..07852b8d1 100644 --- a/src/debugger/gui/CartARWidget.cxx +++ b/src/debugger/gui/CartARWidget.cxx @@ -31,7 +31,7 @@ CartridgeARWidget::CartridgeARWidget( { const size_t size = myCart.mySize; - string info = + const string info = "Supercharger cartridge, four 2K slices (3 RAM, 1 ROM)\n" "\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n"; diff --git a/src/debugger/gui/CartCDFWidget.cxx b/src/debugger/gui/CartCDFWidget.cxx index 21d2dbb6c..3f93ac4b4 100644 --- a/src/debugger/gui/CartCDFWidget.cxx +++ b/src/debugger/gui/CartCDFWidget.cxx @@ -207,7 +207,7 @@ CartridgeCDFWidget::CartridgeCDFWidget( xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP; - int lwidth2 = _font.getStringWidth("Sample Pointer "); + const int lwidth2 = _font.getStringWidth("Sample Pointer "); new StaticTextWidget(boss, _font, xpos, ypos, "Sample Pointer"); mySamplePointer = new DataGridWidget(boss, _nfont, xpos + lwidth2, ypos - 2, 1, 1, 8, 32, diff --git a/src/debugger/gui/CartCMWidget.cxx b/src/debugger/gui/CartCMWidget.cxx index c9dbe0081..ab2a96caa 100644 --- a/src/debugger/gui/CartCMWidget.cxx +++ b/src/debugger/gui/CartCMWidget.cxx @@ -35,7 +35,7 @@ CartridgeCMWidget::CartridgeCMWidget( { constexpr uInt16 size = 4 * 4096; - string info = + const string info = "CM cartridge, four 4K banks + 2K RAM\n" "2K RAM accessible @ $1800 - $1FFF in read or write-only mode " "(no separate ports)\n" diff --git a/src/debugger/gui/CartCTYWidget.cxx b/src/debugger/gui/CartCTYWidget.cxx index 251ca209a..3449ce677 100644 --- a/src/debugger/gui/CartCTYWidget.cxx +++ b/src/debugger/gui/CartCTYWidget.cxx @@ -31,7 +31,7 @@ CartridgeCTYWidget::CartridgeCTYWidget( { constexpr uInt16 size = 8 * 4096; - string info = + const string info = "Chetiry cartridge, eight 4K banks (bank 0 is ARM code and is ignored)\n" "64 bytes RAM @ $F000 - $F080\n" " $F040 - $F07F (R), $F000 - $F03F (W)\n" diff --git a/src/debugger/gui/CartDebugWidget.cxx b/src/debugger/gui/CartDebugWidget.cxx index f00aa693f..defdd12a9 100644 --- a/src/debugger/gui/CartDebugWidget.cxx +++ b/src/debugger/gui/CartDebugWidget.cxx @@ -66,7 +66,8 @@ int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer w->setEditable(false); y += myLineHeight + 4; - StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth - 4); + const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / + myFontWidth - 4); const StringList& sl = bs.stringList(); size_t lines = sl.size(); if(lines < 3) lines = 3; diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index 6508e33ec..6da9078ef 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -105,13 +105,13 @@ string CartridgeEnhancedWidget::romDescription() { uInt16 start = (image[offset + 1] << 8) | image[offset]; start -= start % 0x1000; - string hash = myCart.romBankCount() > 10 && bank < 10 ? " #" : "#"; + const string hash = myCart.romBankCount() > 10 && bank < 10 ? " #" : "#"; info << "Bank " << hash << std::dec << bank << " @ $" << Common::Base::HEX4 << (start + myCart.myRomOffset) << " - $" << (start + 0xFFF); if(myCart.hotspot() != 0) { - string hs = hotspotStr(bank, 0, true); + const string hs = hotspotStr(bank, 0, true); if(hs.length() > 22) info << "\n "; info << " " << hs; diff --git a/src/debugger/gui/CartRamWidget.cxx b/src/debugger/gui/CartRamWidget.cxx index e792b33ee..da8ffce11 100644 --- a/src/debugger/gui/CartRamWidget.cxx +++ b/src/debugger/gui/CartRamWidget.cxx @@ -39,8 +39,8 @@ CartRamWidget::CartRamWidget( myLineHeight{lfont.getLineHeight()}, myButtonHeight{myLineHeight + 4} { - int lwidth = lfont.getStringWidth("Description "); - const int fwidth = w - lwidth - 20; + const int lwidth = lfont.getStringWidth("Description "), + fwidth = w - lwidth - 20; EditTextWidget* etw = nullptr; ostringstream buf; diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 25f7c3900..ad8e8b708 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -133,7 +133,6 @@ void DataGridWidget::setList(const IntArray& alist, const IntArray& vlist, _changedList = changed; // An efficiency thing - string temp; for(size_t i = 0; i < size; ++i) _valueStringList.push_back(Common::Base::toString(_valueList[i], _base)); @@ -759,8 +758,8 @@ void DataGridWidget::endEditMode() enableEditMode(false); // Update the both the string representation and the real data - if(!editString().empty() && !(editString()[0] == '$' || - editString()[0] == '#' || editString()[0] == '\\')) + if(!editString().empty() && editString()[0] != '$' && + editString()[0] != '#' && editString()[0] != '\\') { switch(_base) { diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index cf751e81d..caff2019a 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -377,8 +377,8 @@ void DebuggerDialog::doExitRom() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::createFont() { - string fontSize = instance().settings().getString("dbg.fontsize"); - int fontStyle = instance().settings().getInt("dbg.fontstyle"); + const string fontSize = instance().settings().getString("dbg.fontsize"); + const int fontStyle = instance().settings().getInt("dbg.fontstyle"); if(fontSize == "large") { diff --git a/src/debugger/gui/DelayQueueWidget.cxx b/src/debugger/gui/DelayQueueWidget.cxx index 80e262862..3e85e67fd 100644 --- a/src/debugger/gui/DelayQueueWidget.cxx +++ b/src/debugger/gui/DelayQueueWidget.cxx @@ -45,7 +45,7 @@ DelayQueueWidget::DelayQueueWidget( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DelayQueueWidget::loadConfig() { - shared_ptr delayQueueIterator = + const shared_ptr delayQueueIterator = instance().debugger().tiaDebug().delayQueueIterator(); using Common::Base; diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index b8947fb59..b3e655698 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -122,7 +122,7 @@ void PromptWidget::handleMouseWheel(int x, int y, int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptWidget::printPrompt() { - string watches = instance().debugger().showWatches(); + const string watches = instance().debugger().showWatches(); if(watches.length() > 0) print(watches); @@ -374,7 +374,7 @@ void PromptWidget::loadConfig() _firstTime = false; // Display greetings & prompt - string version = string("Stella ") + STELLA_VERSION + "\n"; + const string version = string("Stella ") + STELLA_VERSION + "\n"; print(version); print(PROMPT); @@ -534,9 +534,7 @@ void PromptWidget::textCut() void PromptWidget::textCopy() { #if defined(PSEUDO_CUT_COPY_PASTE) - string text = getLine(); - - instance().eventHandler().copyText(text); + instance().eventHandler().copyText(getLine()); #endif } @@ -598,7 +596,7 @@ void PromptWidget::addToHistory(const char* str) do { - int prevJ = j; + const int prevJ = j; historyDir(j, +1); _history[prevJ] = _history[j]; } @@ -676,13 +674,13 @@ bool PromptWidget::execute() if(len > 0) { // Copy the user input to command - string command = getLine(); + const string command = getLine(); // Add the input to the history addToHistory(command.c_str()); // Pass the command to the debugger, and print the result - string result = instance().debugger().run(command); + const string result = instance().debugger().run(command); // This is a bit of a hack // Certain commands remove the debugger dialog from underneath us, diff --git a/src/debugger/gui/QuadTariWidget.cxx b/src/debugger/gui/QuadTariWidget.cxx index 4c4b0f78a..615706b27 100644 --- a/src/debugger/gui/QuadTariWidget.cxx +++ b/src/debugger/gui/QuadTariWidget.cxx @@ -33,7 +33,7 @@ QuadTariWidget::QuadTariWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)"); + const string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)"); const StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label); const QuadTari& qt = static_cast(controller); @@ -79,7 +79,7 @@ void QuadTariWidget::addController(GuiObject* boss, int x, int y, widget = new NullControlWidget(boss, _font, x, y, controller, true); break; } - WidgetArray focusList = widget->getFocusList(); + const WidgetArray focusList = widget->getFocusList(); if(!focusList.empty()) addToFocusList(focusList); } diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 4eeac582c..c01e85c54 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -177,7 +177,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n myLabel->setEditable(false, true); // Inputbox which will pop up when searching RAM - StringList labels = { "Value" }; + const StringList labels = { "Value" }; myInputBox = make_unique(boss, lfont, nfont, labels, " "); myInputBox->setTarget(this); diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 469f4525a..ddca888e7 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -390,7 +390,7 @@ void RiotWidget::loadConfig() myP0Diff->setSelectedIndex(riot.diffP0(), state.swchbReadBits[1] != oldstate.swchbReadBits[1]); myP1Diff->setSelectedIndex(riot.diffP1(), state.swchbReadBits[0] != oldstate.swchbReadBits[0]); - bool devSettings = instance().settings().getBool("dev.settings"); + const bool devSettings = instance().settings().getBool("dev.settings"); myConsole->setText(instance().settings().getString(devSettings ? "dev.console" : "plr.console") == "7800" ? "Atari 7800" : "Atari 2600"); myConsole->setEditable(false, true); @@ -565,8 +565,9 @@ RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font& font, void RiotWidget::handleConsole() { RiotDebug& riot = instance().debugger().riotDebug(); - bool devSettings = instance().settings().getBool("dev.settings"); - bool is7800 = instance().settings().getString(devSettings ? "dev.console" : "plr.console") == "7800"; + const bool devSettings = instance().settings().getBool("dev.settings"); + const bool is7800 = instance().settings().getString( + devSettings ? "dev.console" : "plr.console") == "7800"; myTVType->setEnabled(!is7800); myPause->setEnabled(is7800); diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index d3260dcb0..694d8ef12 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -90,7 +90,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, } // Add filtering - EditableWidget::TextFilter f = [&](char c) + const EditableWidget::TextFilter f = [&](char c) { switch(_base) { diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 4f72f4dac..67b4dc8a4 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -36,8 +36,6 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n : Widget(boss, lfont, x, y, w, h), CommandSender(boss) { - WidgetArray wid; - // Show current bank state int xpos = x, ypos = y + 7; auto* t = new StaticTextWidget(boss, lfont, xpos, ypos, "Info "); @@ -165,7 +163,7 @@ void RomWidget::toggleBreak(int disasm_line) if (address != 0) { - Debugger& debugger = instance().debugger(); + const Debugger& debugger = instance().debugger(); debugger.toggleBreakPoint(address, debugger.cartDebug().getBank(address)); } diff --git a/src/debugger/gui/TiaInfoWidget.cxx b/src/debugger/gui/TiaInfoWidget.cxx index 8ac6b6f44..4dc7d0bde 100644 --- a/src/debugger/gui/TiaInfoWidget.cxx +++ b/src/debugger/gui/TiaInfoWidget.cxx @@ -38,7 +38,7 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, const int VGAP = lfont.getLineHeight() / 4; constexpr int VBORDER = 5 + 1; const int COLUMN_GAP = _fontWidth * 1.25; - bool longstr = lfont.getStringWidth("Frame Cycls12345") + _fontWidth * 0.5 + const bool longstr = lfont.getStringWidth("Frame Cycls12345") + _fontWidth * 0.5 + COLUMN_GAP + lfont.getStringWidth("Scanline262262") + EditTextWidget::calcWidth(lfont) * 3 <= max_w; const int lineHeight = lfont.getLineHeight(); diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 1e1dbc416..186debed0 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -87,7 +87,7 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix, { // Determine if the file already exists, checking each successive filename // until one doesn't exist - FSNode node(sspath.str() + ".png"); + const FSNode node(sspath.str() + ".png"); if(node.exists()) { ostringstream suffix; @@ -98,7 +98,7 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix, suffix.str(""); suffix << "_" << i; buf << sspath.str() << suffix.str() << ".png"; - FSNode next(buf.str()); + const FSNode next(buf.str()); if(!next.exists()) break; } @@ -166,7 +166,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in if(lines > 0) { command << "scanLine #" << lines; - string message = instance().debugger().parser().run(command.str()); + const string message = instance().debugger().parser().run(command.str()); instance().frameBuffer().showTextMessage(message); } } @@ -266,7 +266,7 @@ void TiaOutputWidget::drawWidget(bool hilite) for(uInt32 x = 0; x < width; ++x, ++i) { const uInt8 shift = i >= scanoffset ? 1 : 0; - uInt32 pixel = tiaSurface.mapIndexedPixel(tiaOutputBuffer[i], shift); + const uInt32 pixel = tiaSurface.mapIndexedPixel(tiaOutputBuffer[i], shift); *line_ptr++ = pixel; *line_ptr++ = pixel; } diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index a78665736..7878b9ae3 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -255,7 +255,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int if(lines > 0) { command << "scanline #" << lines; - string message = instance().debugger().parser().run(command.str()); + const string& message = instance().debugger().parser().run(command.str()); instance().frameBuffer().showTextMessage(message); } } diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 2aa3ee034..872df6850 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -36,7 +36,7 @@ Cartridge::Cartridge(const Settings& settings, const string& md5) const uInt32 seed = to_uInt32(md5, 0) ^ to_uInt32(md5, 8) ^ to_uInt32(md5, 16) ^ to_uInt32(md5, 24); - Random rand(seed); + const Random rand(seed); for(uInt32 i = 0; i < 256; ++i) myRWPRandomValues[i] = rand.next(); @@ -95,7 +95,7 @@ uInt16 Cartridge::bankSize(uInt16 bank) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 Cartridge::peekRAM(uInt8& dest, uInt16 address) { - uInt8 value = myRWPRandomValues[address & 0xFF]; + const uInt8 value = myRWPRandomValues[address & 0xFF]; // Reading from the write port triggers an unwanted write // But this only happens when in normal emulation mode diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index 45c706f20..99402c0cf 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -59,7 +59,7 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size, // Pointer to BUS driver in RAM myDriverImage = myRAM.data(); - bool devSettings = settings.getBool("dev.settings"); + const bool devSettings = settings.getBool("dev.settings"); if (myBUSSubtype == BUSSubtype::BUS0) { diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index a835162e0..2033f741e 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -99,7 +99,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size, } // Create Thumbulator ARM emulator - bool devSettings = settings.getBool("dev.settings"); + const bool devSettings = settings.getBool("dev.settings"); myThumbEmulator = make_unique( reinterpret_cast(myImage.get()), reinterpret_cast(myRAM.data()), diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 1cd7d5b02..d6bbd2fe6 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -512,7 +512,7 @@ void CartridgeCTY::updateTune() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeCTY::loadScore(uInt8 index) { - Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly); + const Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly); if(serializer) { std::array scoreRAM; diff --git a/src/emucore/CartCreator.cxx b/src/emucore/CartCreator.cxx index 57ccae82f..4be8ec751 100644 --- a/src/emucore/CartCreator.cxx +++ b/src/emucore/CartCreator.cxx @@ -200,7 +200,7 @@ CartCreator::createFromMultiCart(const ByteBuffer& image, size_t& size, settings.setValue("romloadcount", i); size /= numRoms; - ByteBuffer slice = make_unique(size); + const ByteBuffer slice = make_unique(size); std::copy_n(image.get() + i * size, size, slice.get()); // We need a new md5 and name diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index c208664f6..6c5ad8dfb 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -48,7 +48,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size, myFrequencyImage = myDisplayImage + 4_KB; // Create Thumbulator ARM emulator - bool devSettings = settings.getBool("dev.settings"); + const bool devSettings = settings.getBool("dev.settings"); myThumbEmulator = make_unique (reinterpret_cast(myImage.get()), reinterpret_cast(myDPCRAM.data()), diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 20ffc7748..e0af1daf8 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -221,7 +221,7 @@ Console::Console(OSystem& osystem, unique_ptr& cart, setTIAProperties(); - bool joyallow4 = myOSystem.settings().getBool("joyallow4"); + const bool joyallow4 = myOSystem.settings().getBool("joyallow4"); myOSystem.eventHandler().allowAllDirections(joyallow4); // Reset the system to its power-on state @@ -280,7 +280,7 @@ void Console::autodetectFrameLayout(bool reset) // will take over 250 frames! // The 'fastscbios' option must be changed before the system is reset Settings& settings = myOSystem.settings(); - bool fastscbios = settings.getBool("fastscbios"); + const bool fastscbios = settings.getBool("fastscbios"); settings.setValue("fastscbios", true); FrameLayoutDetector frameLayoutDetector; @@ -363,7 +363,7 @@ string Console::formatFromFilename() const { try { - std::regex rgx(pat[0], std::regex_constants::icase); + const std::regex rgx(pat[0], std::regex_constants::icase); if(std::regex_search(filename, rgx)) return pat[1]; } @@ -426,7 +426,6 @@ bool Console::load(Serializer& in) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::selectFormat(int direction) { - string saveformat, message; Int32 format = myCurrentFormat; format = BSPF::clampw(format + direction, 0, 6); @@ -534,8 +533,8 @@ void Console::toggleColorLoss(bool toggle) myOSystem.settings().setValue( myOSystem.settings().getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss", colorloss); - string message = string("PAL color-loss ") + - (colorloss ? "enabled" : "disabled"); + const string message = string("PAL color-loss ") + + (colorloss ? "enabled" : "disabled"); myOSystem.frameBuffer().showTextMessage(message); } else @@ -576,7 +575,7 @@ void Console::toggleInter(bool toggle) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::toggleTurbo() { - bool enabled = myOSystem.settings().getBool("turbo"); + const bool enabled = myOSystem.settings().getBool("turbo"); myOSystem.settings().setValue("turbo", !enabled); @@ -595,7 +594,7 @@ void Console::toggleTurbo() void Console::changeSpeed(int direction) { int speed = mapSpeed(myOSystem.settings().getFloat("speed")); - bool turbo = myOSystem.settings().getBool("turbo"); + const bool turbo = myOSystem.settings().getBool("turbo"); speed = BSPF::clamp(speed + direction * SPEED_STEP, MIN_SPEED, MAX_SPEED); myOSystem.settings().setValue("speed", unmapSpeed(speed)); @@ -674,7 +673,7 @@ FBInitStatus Console::initializeVideo(bool full) Common::Size(TIAConstants::viewableWidth, TIAConstants::viewableHeight) : Common::Size(2 * myTIA->width(), myTIA->height()); - bool devSettings = myOSystem.settings().getBool("dev.settings"); + const bool devSettings = myOSystem.settings().getBool("dev.settings"); const string& title = string("Stella ") + STELLA_VERSION + ": \"" + myProperties.get(PropType::Cart_Name) + "\""; fbstatus = myOSystem.frameBuffer().createDisplay(title, @@ -827,7 +826,7 @@ void Console::setTIAProperties() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::createAudioQueue() { - bool useStereo = myOSystem.settings().getBool(AudioSettings::SETTING_STEREO) + const bool useStereo = myOSystem.settings().getBool(AudioSettings::SETTING_STEREO) || myProperties.get(PropType::Cart_Sound) == "STEREO"; myAudioQueue = make_shared( @@ -971,7 +970,8 @@ unique_ptr Console::getControllerPort(const Controller::Type type, case Controller::Type::PaddlesIAxDr: { // Also check if we should swap the paddles plugged into a jack - bool swapPaddles = myProperties.get(PropType::Controller_SwapPaddles) == "YES"; + const bool swapPaddles = + myProperties.get(PropType::Controller_SwapPaddles) == "YES"; bool swapAxis = false, swapDir = false; if(type == Controller::Type::PaddlesIAxis) swapAxis = true; @@ -1002,8 +1002,9 @@ unique_ptr Console::getControllerPort(const Controller::Type type, { FSNode nvramfile = myOSystem.nvramDir(); nvramfile /= "atarivox_eeprom.dat"; - Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) { - bool devSettings = os.settings().getBool("dev.settings"); + const Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) + { + const bool devSettings = os.settings().getBool("dev.settings"); if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess")) os.frameBuffer().showTextMessage(msg); }; @@ -1015,8 +1016,9 @@ unique_ptr Console::getControllerPort(const Controller::Type type, { FSNode nvramfile = myOSystem.nvramDir(); nvramfile /= "savekey_eeprom.dat"; - Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) { - bool devSettings = os.settings().getBool("dev.settings"); + const Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) + { + const bool devSettings = os.settings().getBool("dev.settings"); if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess")) os.frameBuffer().showTextMessage(msg); }; @@ -1029,12 +1031,14 @@ unique_ptr Console::getControllerPort(const Controller::Type type, case Controller::Type::KidVid: { - Controller::onMessageCallbackForced callback = [&os = myOSystem](const string& msg, bool force) { - bool devSettings = os.settings().getBool("dev.settings"); + const Controller::onMessageCallbackForced callback = + [&os = myOSystem](const string& msg, bool force) { + const bool devSettings = os.settings().getBool("dev.settings"); if(force || os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess")) os.frameBuffer().showTextMessage(msg); }; - controller = make_unique(port, myEvent, myOSystem, *mySystem, romMd5, callback); + controller = make_unique + (port, myEvent, myOSystem, *mySystem, romMd5, callback); break; } @@ -1043,7 +1047,8 @@ unique_ptr Console::getControllerPort(const Controller::Type type, break; case Controller::Type::Lightgun: - controller = make_unique(port, myEvent, *mySystem, romMd5, myOSystem.frameBuffer()); + controller = make_unique + (port, myEvent, *mySystem, romMd5, myOSystem.frameBuffer()); break; case Controller::Type::QuadTari: @@ -1159,7 +1164,7 @@ void Console::changePaddleAxesRange(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::toggleAutoFire(bool toggle) { - bool enabled = myOSystem.settings().getBool("autofire"); + const bool enabled = myOSystem.settings().getBool("autofire"); if(toggle) { diff --git a/src/emucore/EmulationWorker.cxx b/src/emucore/EmulationWorker.cxx index 2e59230e1..ebc6a836d 100644 --- a/src/emucore/EmulationWorker.cxx +++ b/src/emucore/EmulationWorker.cxx @@ -44,7 +44,7 @@ EmulationWorker::~EmulationWorker() { // This has to run in a block in order to release the mutex before joining { - std::unique_lock lock(myThreadIsRunningMutex); + const std::unique_lock lock(myThreadIsRunningMutex); if (myState != State::exception) { signalQuit(); @@ -61,7 +61,7 @@ EmulationWorker::~EmulationWorker() void EmulationWorker::handlePossibleException() { if (myState == State::exception && myPendingException) { - std::exception_ptr ex = myPendingException; + const std::exception_ptr ex = myPendingException; // Make sure that the exception is not thrown a second time (destructor!!!) myPendingException = nullptr; @@ -78,8 +78,8 @@ void EmulationWorker::start(uInt32 cyclesPerSecond, uInt64 maxCycles, uInt64 min // Run in a block to release the mutex before notifying; this avoids an unecessary // block that will waste a timeslice { - // Aquire the mutex -> wait until the thread is suspended - std::unique_lock lock(myThreadIsRunningMutex); + // Acquire the mutex -> wait until the thread is suspended + const std::unique_lock lock(myThreadIsRunningMutex); // Pass on possible exceptions handlePossibleException(); @@ -115,7 +115,7 @@ uInt64 EmulationWorker::stop() uInt64 totalCycles{0}; { - std::unique_lock lock(myThreadIsRunningMutex); + const std::unique_lock lock(myThreadIsRunningMutex); // Paranoia: make sure that we don't doublecount an emulation timeslice totalCycles = myTotalCycles; @@ -148,7 +148,7 @@ void EmulationWorker::threadMain(std::condition_variable* initializedCondition, try { { // Wait until our parent releases the lock and sleeps - std::lock_guard guard(*initializationMutex); + const std::lock_guard guard(*initializationMutex); // Update the state... myState = State::initialized; @@ -303,7 +303,7 @@ void EmulationWorker::dispatchEmulation(std::unique_lock& lock) void EmulationWorker::clearSignal() { { - std::unique_lock lock(mySignalChangeMutex); + const std::unique_lock lock(mySignalChangeMutex); myPendingSignal = Signal::none; } @@ -314,7 +314,7 @@ void EmulationWorker::clearSignal() void EmulationWorker::signalQuit() { { - std::unique_lock lock(mySignalChangeMutex); + const std::unique_lock lock(mySignalChangeMutex); myPendingSignal = Signal::quit; } diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index aa4213ea2..4930b186f 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -1539,7 +1539,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { StringList msg; const string saveOnExit = myOSystem.settings().getString("saveonexit"); - bool activeTM = myOSystem.settings().getBool( + const bool activeTM = myOSystem.settings().getBool( myOSystem.settings().getBool("dev.settings") ? "dev.timemachine" : "plr.timemachine"); @@ -1986,11 +1986,11 @@ void EventHandler::setComboMap() { for(const json& combo : mapping) { - int i = combo.at("combo").get() - Event::Combo1, - j = 0; - json events = combo.at("events"); + const int i = combo.at("combo").get() - Event::Combo1; + int j = 0; + const json events = combo.at("events"); - for(const json& event : events) + for(const json& event: events) myComboTable[i][j++] = event; } } @@ -2297,7 +2297,7 @@ VariantList EventHandler::getComboList() { const Event::Type event = EventHandler::ourEmulActionList[i].event; // exclude combos events - if(!(event >= Event::Combo1 && event <= Event::Combo16)) + if(event < Event::Combo1 || event > Event::Combo16) { buf << i; VarList::push_back(l, EventHandler::ourEmulActionList[i].action, buf.str()); @@ -2549,7 +2549,7 @@ void EventHandler::changeMouseControllerMode(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EventHandler::changeMouseCursor(int direction) { - int cursor = BSPF::clampw(myOSystem.settings().getInt("cursor") + direction, 0, 3); + const int cursor = BSPF::clampw(myOSystem.settings().getInt("cursor") + direction, 0, 3); myOSystem.settings().setValue("cursor", cursor); myOSystem.frameBuffer().setCursorState(); diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index 596bb4578..1e6b12243 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -191,8 +191,8 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, bby = desc.bbx[chr].y; // NOLINT } - uInt32 cx = tx + bbx; - uInt32 cy = ty + desc.ascent - bby - bbh; + const uInt32 cx = tx + bbx; + const uInt32 cy = ty + desc.ascent - bby - bbh; if(!checkBounds(cx , cy) || !checkBounds(cx + bbw - 1, cy + bbh - 1)) return; diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index d7ac41571..bf8f08cf0 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -85,7 +85,7 @@ bool FSNode::getAllChildren(FSList& fslist, ListMode mode, { if(BSPF::endsWithIgnoreCase(i.getPath(), ".zip")) { - FSNodeZIP zipNode(i.getPath()); + const FSNodeZIP zipNode(i.getPath()); i.setName(zipNode.getName()); } } @@ -108,9 +108,9 @@ bool FSNode::getAllChildren(FSList& fslist, ListMode mode, if(BSPF::endsWithIgnoreCase(i.getPath(), ".zip")) { // Force ZIP c'tor to be called - AbstractFSNodePtr ptr = FSNodeFactory::create( + const AbstractFSNodePtr ptr = FSNodeFactory::create( i.getPath(), FSNodeFactory::Type::ZIP); - FSNode zipNode(ptr); + const FSNode zipNode(ptr); i = zipNode; } } @@ -149,7 +149,7 @@ bool FSNode::getChildren(FSList& fslist, ListMode mode, { if(BSPF::endsWithIgnoreCase(i->getPath(), ".zip")) { - FSNodeZIP node(i->getPath()); + const FSNodeZIP node(i->getPath()); i->setName(node.getName()); } } @@ -184,9 +184,9 @@ bool FSNode::getChildren(FSList& fslist, ListMode mode, if (BSPF::endsWithIgnoreCase(i->getPath(), ".zip")) { // Force ZIP c'tor to be called - AbstractFSNodePtr ptr = FSNodeFactory::create( + const AbstractFSNodePtr ptr = FSNodeFactory::create( i->getPath(), FSNodeFactory::Type::ZIP); - FSNode zipNode(ptr); + const FSNode zipNode(ptr); if(filter(zipNode)) { @@ -195,7 +195,7 @@ bool FSNode::getChildren(FSList& fslist, ListMode mode, else { // filter by zip node but add file node - FSNode node(i); + const FSNode node(i); fslist.emplace_back(node); } } @@ -203,7 +203,7 @@ bool FSNode::getChildren(FSList& fslist, ListMode mode, else #endif { - FSNode node(i); + const FSNode node(i); if(includeChildDirectories) { diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 11cfedec2..64e974419 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -170,10 +170,12 @@ void FrameBuffer::setupFonts() else { constexpr int NUM_FONTS = 7; - FontDesc FONT_DESC[NUM_FONTS] = {GUI::consoleDesc, GUI::consoleMediumDesc, GUI::stellaMediumDesc, - GUI::stellaLargeDesc, GUI::stella12x24tDesc, GUI::stella14x28tDesc, GUI::stella16x32tDesc}; + const FontDesc FONT_DESC[NUM_FONTS] = { + GUI::consoleDesc, GUI::consoleMediumDesc, GUI::stellaMediumDesc, + GUI::stellaLargeDesc, GUI::stella12x24tDesc, GUI::stella14x28tDesc, + GUI::stella16x32tDesc}; const string& dialogFont = myOSystem.settings().getString("dialogfont"); - FontDesc fd = getFontDesc(dialogFont); + const FontDesc fd = getFontDesc(dialogFont); // The general font used in all UI elements myFont = make_unique(fd); // default: 9x18 @@ -274,9 +276,9 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, if(myBufferType == BufferType::Emulator) { // Determine possible TIA windowed zoom levels - float currentTIAZoom = myOSystem.settings().getFloat("tia.zoom"); + const float currentTIAZoom = myOSystem.settings().getFloat("tia.zoom"); myOSystem.settings().setValue("tia.zoom", - BSPF::clampw(currentTIAZoom, supportedTIAMinZoom(), supportedTIAMaxZoom())); + BSPF::clampw(currentTIAZoom, supportedTIAMinZoom(), supportedTIAMaxZoom())); } #ifdef GUI_SUPPORT // TODO: put message stuff in its own class @@ -311,7 +313,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, myVidModeHandler.setImageSize(size); // Initialize video subsystem - string pre_about = myBackend->about(); + const string pre_about = myBackend->about(); const FBInitStatus status = applyVideoMode(); // Only set phosphor once when ROM is started @@ -344,7 +346,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, } else { - string post_about = myBackend->about(); + const string post_about = myBackend->about(); if(post_about != pre_about) Logger::info(post_about); } @@ -383,7 +385,7 @@ void FrameBuffer::update(UpdateMode mode) case EventHandlerState::PAUSE: { // Show a pause message immediately and then every 7 seconds - bool shade = myOSystem.settings().getBool("pausedim"); + const bool shade = myOSystem.settings().getBool("pausedim"); if(myPausedCount-- <= 0) { @@ -1214,7 +1216,7 @@ void FrameBuffer::switchVideoMode(int direction) // is irrelevant if(direction == +1 || direction == -1) { - bool stretch = myOSystem.settings().getBool("tia.fs_stretch"); + const bool stretch = myOSystem.settings().getBool("tia.fs_stretch"); myOSystem.settings().setValue("tia.fs_stretch", !stretch); } } @@ -1366,7 +1368,7 @@ bool FrameBuffer::grabMouseAllowed() const bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse")); // Disable grab while cursor is shown in emulation - bool cursorHidden = !(myOSystem.settings().getInt("cursor") & 1); + const bool cursorHidden = !(myOSystem.settings().getInt("cursor") & 1); return emulation && (analog || usesLightgun || alwaysUseMouse) && cursorHidden; } diff --git a/src/emucore/KidVid.cxx b/src/emucore/KidVid.cxx index c06043eb9..085e01349 100644 --- a/src/emucore/KidVid.cxx +++ b/src/emucore/KidVid.cxx @@ -68,7 +68,7 @@ void KidVid::update() { // Continue playing song after state load const uInt8 temp = ourSongPositions[mySongPointer - 1] & 0x7f; - const uInt32 songLength = ourSongStart[temp + 1] - ourSongStart[temp]; + const uInt32 songLength = ourSongStart[temp + 1] - ourSongStart[temp] - (262 * ClickFrames); // Play the remaining WAV file const string& fileName = myOSystem.baseDir().getPath() + ((temp < 10) ? "KVSHARED.WAV" : getFileName()); @@ -140,6 +140,10 @@ void KidVid::update() { setPin(DigitalPin::Four, (ourData[myIdx >> 3] << (myIdx & 0x07)) & 0x80); + #ifdef DEBUG_BUILD + cerr << (DigitalPin::Four, (ourData[myIdx >> 3] << (myIdx & 0x07)) & 0x80 ? "X" : "."); + #endif + // increase to next bit ++myIdx; --myBlockIdx; @@ -172,7 +176,7 @@ void KidVid::update() if(mySongPlaying) { mySongLength = myOSystem.sound().wavSize(); - myTapeBusy = (mySongLength > 262 * ClickFrames) || !myBeep; + myTapeBusy = (mySongLength > 262 * TapeFrames) || !myBeep; // Check for end of played sample if(mySongLength == 0) { @@ -188,7 +192,7 @@ void KidVid::update() if(mySongLength) { --mySongLength; - myTapeBusy = (mySongLength > ClickFrames); + myTapeBusy = (mySongLength > TapeFrames); } } } @@ -259,6 +263,7 @@ void KidVid::openSampleFiles() 44 + 38 + 42 + 62 }; +#ifdef SOUND_SUPPORT if(!myFilesFound) { int i = myGame == Game::Smurfs ? myTape - 1 : myTape + 2; @@ -267,13 +272,14 @@ void KidVid::openSampleFiles() myFilesFound = FSNode(myOSystem.baseDir().getPath() + getFileName()).exists() && FSNode(myOSystem.baseDir().getPath() + "KVSHARED.WAV").exists(); -#ifdef DEBUG_BUILD + #ifdef DEBUG_BUILD if(myFilesFound) cerr << endl << "found file: " << getFileName() << endl << "found file: " << "KVSHARED.WAV" << endl; -#endif + #endif +#endif mySongLength = 0; mySongPointer = firstSongPointer[i]; } @@ -288,7 +294,7 @@ void KidVid::setNextSong() myBeep = (ourSongPositions[mySongPointer] & 0x80) == 0; const uInt8 temp = ourSongPositions[mySongPointer] & 0x7f; - mySongLength = ourSongStart[temp + 1] - ourSongStart[temp]; + mySongLength = ourSongStart[temp + 1] - ourSongStart[temp] - (262 * ClickFrames); // Play the WAV file const string& fileName = (temp < 10) ? "KVSHARED.WAV" : getFileName(); @@ -298,9 +304,9 @@ void KidVid::setNextSong() msg << "Read song #" << mySongPointer << " (" << fileName << ")"; myCallback(msg.str(), false); -#ifdef DEBUG_BUILD + #ifdef DEBUG_BUILD cerr << fileName << ": " << (ourSongPositions[mySongPointer] & 0x7f) << endl; -#endif + #endif mySongPlaying = myTapeBusy = true; ++mySongPointer; @@ -309,7 +315,7 @@ void KidVid::setNextSong() { myBeep = true; myTapeBusy = true; - mySongLength = 80; /* delay needed for Harmony without tape */ + mySongLength = TapeFrames + 32; /* delay needed for Harmony without tape */ } } @@ -438,14 +444,14 @@ const std::array KidVid::ourSongStart = { 3059116, /* kvs1 */ - 44, /* Harmony into 1 */ - 164685, /* falling notes (into 2) */ + 44, /* Harmony intro 1 */ + 164685, /* falling notes (intro 2) */ 395182, /* instructions */ 750335, /* high notes are high */ 962016, /* my hat's off to you */ 1204273, /* 1 2 3 do re mi */ 1538258, /* Harmony */ - 1801683, /* concratulations (all of the Smurfs voted) */ + 1801683, /* congratulations (all of the Smurfs voted) */ 2086276, /* line or space */ 2399093, /* hooray */ 2589606, /* hear yeeh */ diff --git a/src/emucore/KidVid.hxx b/src/emucore/KidVid.hxx index b4c9cbacd..583660473 100644 --- a/src/emucore/KidVid.hxx +++ b/src/emucore/KidVid.hxx @@ -111,7 +111,8 @@ class KidVid : public Controller NumBlockBits = NumBlocks * 8, // number of bits / block SongPosSize = 44 + 38 + 42 + 62 + 80 + 62, SongStartSize = 104, - ClickFrames = 48 // eliminate click noise at song end + TapeFrames = 60, + ClickFrames = 3 // eliminate click noise at song end ; // Whether the KidVid device is enabled (only for games that it diff --git a/src/emucore/Lightgun.cxx b/src/emucore/Lightgun.cxx index fc031a2d2..79584697e 100644 --- a/src/emucore/Lightgun.cxx +++ b/src/emucore/Lightgun.cxx @@ -103,9 +103,8 @@ bool Lightgun::read(DigitalPin pin) if (xTia < 0) xTia += TIAConstants::H_CLOCKS; - const bool enable = !((xTia - xMouse) >= 0 && (xTia - xMouse) < 15 && (yTia - yMouse) >= 0); - - return enable; + return (xTia - xMouse) < 0 || (xTia - xMouse) >= 15 || + (yTia - yMouse) < 0; } default: return Controller::read(pin); diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 257a65f8e..df9e9c73f 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -65,7 +65,7 @@ void M6502::reset() myExecutionStatus = 0; // Set registers to random or default values - bool devSettings = mySettings.getBool("dev.settings"); + const bool devSettings = mySettings.getBool("dev.settings"); const string& cpurandom = mySettings.getString(devSettings ? "dev.cpurandom" : "plr.cpurandom"); SP = BSPF::containsIgnoreCase(cpurandom, "S") ? mySystem->randGenerator().next() : 0xfd; diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index c23631718..703493f3b 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -47,7 +47,7 @@ void M6532::reset() }; // Initialize the 128 bytes of memory - bool devSettings = mySettings.getBool("dev.settings"); + const bool devSettings = mySettings.getBool("dev.settings"); if(mySettings.getString(devSettings ? "dev.console" : "plr.console") == "7800") std::copy_n(RAM_7800.begin(), RAM_7800.size(), myRAM.begin()); else if(mySettings.getBool(devSettings ? "dev.ramrandom" : "plr.ramrandom")) diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index 9ea48666c..2e3ddb44a 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -143,7 +143,7 @@ static void MD5Update(MD5_CTX* context, const uInt8* const input, auto index = static_cast((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += (inputLen << 3)) < (inputLen << 3)) + if ((context->count[0] += (inputLen << 3)) < (inputLen << 3)) // NOLINT context->count[1]++; context->count[1] += (inputLen >> 29); diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 6276217b1..65d5f223c 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -474,9 +474,10 @@ string OSystem::createConsole(const FSNode& rom, const string& md5sum, } myConsole->initializeAudio(); - string saveOnExit = settings().getString("saveonexit"); - bool devSettings = settings().getBool("dev.settings"); - bool activeTM = settings().getBool(devSettings ? "dev.timemachine" : "plr.timemachine"); + const string saveOnExit = settings().getString("saveonexit"); + const bool devSettings = settings().getBool("dev.settings"); + const bool activeTM = settings().getBool( + devSettings ? "dev.timemachine" : "plr.timemachine"); if (saveOnExit == "all" && activeTM) myEventHandler->handleEvent(Event::LoadAllStates); @@ -492,7 +493,7 @@ string OSystem::createConsole(const FSNode& rom, const string& md5sum, } buf << "Game console created:" << endl << " ROM file: " << myRomFile.getShortPath() << endl; - FSNode propsFile(myRomFile.getPathWithExt(".pro")); + const FSNode propsFile(myRomFile.getPathWithExt(".pro")); if(propsFile.exists()) buf << " PRO file: " << propsFile.getShortPath() << endl; buf << endl << getROMInfo(*myConsole); @@ -528,7 +529,7 @@ string OSystem::createConsole(const FSNode& rom, const string& md5sum, constexpr int ID_LEN = 32; const char* HEX_DIGITS = "0123456789ABCDEF"; char id_chr[ID_LEN] = { 0 }; - Random rnd; + const Random rnd; for(char& c : id_chr) c = HEX_DIGITS[rnd.next() % 16]; @@ -667,7 +668,7 @@ unique_ptr OSystem::openConsole(const FSNode& romfile, string& md5) const string& type = props.get(PropType::Cart_Type); const Cartridge::messageCallback callback = [&os = *this](const string& msg) { - bool devSettings = os.settings().getBool("dev.settings"); + const bool devSettings = os.settings().getBool("dev.settings"); if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess")) os.frameBuffer().showTextMessage(msg); diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 21eff5ecd..67b36ea09 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -215,7 +215,7 @@ Paddles::getReadOut(int lastAxis,int& newAxis, int center) // dejitter, suppress small changes only const float dejitter = powf(baseFactor, std::abs(newAxis - lastAxis) * diffFactor); - int newVal = newAxis * (1 - dejitter) + lastAxis * dejitter; + const int newVal = newAxis * (1 - dejitter) + lastAxis * dejitter; // only use new dejittered value for larger differences if(abs(newVal - newAxis) > 10) diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index 9a76cb2e0..ccc3c1e2e 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -90,7 +90,7 @@ class PlusROMRequest { << "nick=" << myId.nick; httplib::Client client(myDestination.host); - httplib::Headers headers = { + const httplib::Headers headers = { {"PlusROM-Info", content.str()} }; @@ -375,7 +375,7 @@ bool PlusROM::isValidHost(const string& host) // of each part between '.' in the range 1 .. 63 // Perhaps a better function will be included with whatever network // library we decide to use - static std::regex rgx(R"(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)", std::regex_constants::icase); + static const std::regex rgx(R"(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)", std::regex_constants::icase); return std::regex_match(host, rgx); } diff --git a/src/emucore/ProfilingRunner.cxx b/src/emucore/ProfilingRunner.cxx index 58af4eb84..acea8691c 100644 --- a/src/emucore/ProfilingRunner.cxx +++ b/src/emucore/ProfilingRunner.cxx @@ -60,14 +60,14 @@ ProfilingRunner::ProfilingRunner(int argc, char* argv[]) for (int i = 2; i < argc; i++) { ProfilingRun& run(profilingRuns[i-2]); - string arg = argv[i]; + const string arg = argv[i]; const size_t splitPoint = arg.find_first_of(':'); run.romFile = splitPoint == string::npos ? arg : arg.substr(0, splitPoint); if (splitPoint == string::npos) run.runtime = RUNTIME_DEFAULT; else { - int runtime = BSPF::stringToInt(arg.substr(splitPoint+1, string::npos)); + const int runtime = BSPF::stringToInt(arg.substr(splitPoint+1, string::npos)); run.runtime = runtime > 0 ? runtime : RUNTIME_DEFAULT; } } @@ -95,7 +95,7 @@ bool ProfilingRunner::run() // stacksize '16384'. Consider moving some data to heap. bool ProfilingRunner::runOne(const ProfilingRun& run) { - FSNode imageFile(run.romFile); + const FSNode imageFile(run.romFile); if (!imageFile.isFile()) { cout << "ERROR: " << run.romFile << " is not a ROM image" << endl; @@ -110,7 +110,7 @@ bool ProfilingRunner::runOne(const ProfilingRun& run) } string md5 = MD5::hash(image, size); - string type; + const string type; unique_ptr cartridge = CartCreator::create( imageFile, image, size, md5, type, mySettings); @@ -121,7 +121,7 @@ bool ProfilingRunner::runOne(const ProfilingRun& run) IO consoleIO; Random rng(0); - Event event; + const Event event; M6502 cpu(mySettings); M6532 riot(consoleIO, mySettings); diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index f7acec38f..a74d5e0b2 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -154,7 +154,7 @@ void PropertiesSet::loadPerROM(const FSNode& rom, const string& md5) // First, does this ROM have a per-ROM properties entry? // If so, load it into the database - FSNode propsNode(rom.getPathWithExt(".pro")); + const FSNode propsNode(rom.getPathWithExt(".pro")); if (propsNode.exists()) { KeyValueRepositoryPropertyFile repo(propsNode); props.load(repo); diff --git a/src/emucore/QuadTari.cxx b/src/emucore/QuadTari.cxx index c132cc54a..ef7bbdec6 100644 --- a/src/emucore/QuadTari.cxx +++ b/src/emucore/QuadTari.cxx @@ -69,18 +69,19 @@ QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system, unique_ptr QuadTari::addController(const Controller::Type type, bool second) { FSNode nvramfile = myOSystem.nvramDir(); - Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) { - bool devSettings = os.settings().getBool("dev.settings"); - if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess")) - os.frameBuffer().showTextMessage(msg); - }; + const Controller::onMessageCallback callback = [&os = myOSystem] + (const string& msg) { + const bool devSettings = os.settings().getBool("dev.settings"); + if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess")) + os.frameBuffer().showTextMessage(msg); + }; switch(type) { case Controller::Type::Paddles: { // Check if we should swap the paddles plugged into a jack - bool swapPaddles = myProperties.get(PropType::Controller_SwapPaddles) == "YES"; + const bool swapPaddles = myProperties.get(PropType::Controller_SwapPaddles) == "YES"; return make_unique(myJack, myEvent, mySystem, swapPaddles, false, false, second); diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index 50ba83f98..22434056c 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -26,7 +26,7 @@ Serializer::Serializer(const string& filename, Mode m) { if(m == Mode::ReadOnly) { - FSNode node(filename); + const FSNode node(filename); if(node.isFile() && node.isReadable()) { unique_ptr str = make_unique(filename, ios::in | ios::binary); diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index f351b377c..6afaabeb1 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -306,7 +306,7 @@ void Settings::setRepository(shared_ptr repository) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::load(const Options& options) { - Options fromFile = myRespository->load(); + const Options fromFile = myRespository->load(); for (const auto& opt: fromFile) setValue(opt.first, opt.second, false); @@ -330,7 +330,7 @@ void Settings::save() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::validate() { - float f = getFloat("speed"); + const float f = getFloat("speed"); if (f <= 0) setValue("speed", "1.0"); int i = getInt("tia.vsizeadjust"); diff --git a/src/emucore/Sound.hxx b/src/emucore/Sound.hxx index 902fb80a5..f06aa710b 100644 --- a/src/emucore/Sound.hxx +++ b/src/emucore/Sound.hxx @@ -114,8 +114,8 @@ class Sound @return True, if the WAV file can be played */ - virtual bool playWav(const string& fileName, uInt32 position = 0, - uInt32 length = 0) { return false; } + virtual bool playWav(const string& fileName, const uInt32 position = 0, + const uInt32 length = 0) { return false; } /** Stop any currently playing WAV file. diff --git a/src/emucore/Switches.cxx b/src/emucore/Switches.cxx index 1a42bb4e8..99283fae1 100644 --- a/src/emucore/Switches.cxx +++ b/src/emucore/Switches.cxx @@ -188,7 +188,7 @@ bool Switches::load(Serializer& in) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Switches::check7800Mode(const Settings& settings) { - bool devSettings = settings.getBool("dev.settings"); + const bool devSettings = settings.getBool("dev.settings"); myIs7800 = (settings.getString(devSettings ? "dev.console" : "plr.console") == "7800"); return myIs7800; diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index ef0c1cccf..6e96726c2 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -3088,7 +3088,7 @@ bool Thumbulator::isMamBuffered(uInt32 addr, AccessType accessType) else // e.g. LPC2104_05_06 { // dual Flash bank - uInt32 bank = (addr & 0x80) ? 1 : 0; + const uInt32 bank = (addr & 0x80) ? 1 : 0; addr &= ~0x7F; // 128-bit address line diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 63a9b63f9..29a939e0d 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -191,9 +191,10 @@ void TIA::initialize() applyDeveloperSettings(); // Must be done last, after all other items have reset - bool devSettings = mySettings.getBool("dev.settings"); + const bool devSettings = mySettings.getBool("dev.settings"); setFixedColorPalette(mySettings.getString("tia.dbgcolors")); - enableFixedColors(mySettings.getBool(devSettings ? "dev.debugcolors" : "plr.debugcolors")); + enableFixedColors( + mySettings.getBool(devSettings ? "dev.debugcolors" : "plr.debugcolors")); #ifdef DEBUGGER_SUPPORT createAccessArrays(); @@ -941,10 +942,11 @@ bool TIA::loadDisplay(const Serializer& in) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::applyDeveloperSettings() { - bool devSettings = mySettings.getBool("dev.settings"); + const bool devSettings = mySettings.getBool("dev.settings"); if(devSettings) { - bool custom = BSPF::equalsIgnoreCase("custom", mySettings.getString("dev.tia.type")); + const bool custom = + BSPF::equalsIgnoreCase("custom", mySettings.getString("dev.tia.type")); setPlInvertedPhaseClock(custom ? mySettings.getBool("dev.tia.plinvphase") diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index 9444b0452..a90793b42 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -65,14 +65,16 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, addCancelWidget(b); xpos = HBORDER; ypos = _th + VBORDER + (buttonHeight - fontHeight) / 2; - int bwidth = font.getStringWidth("What's New" + ELLIPSIS) + fontWidth * 2.5; + const int bwidth = font.getStringWidth("What's New" + ELLIPSIS) + fontWidth * 2.5; - myTitle = new StaticTextWidget(this, font, xpos + bwidth, ypos, _w - (xpos + bwidth) * 2, + myTitle = new StaticTextWidget(this, font, xpos + bwidth, ypos, + _w - (xpos + bwidth) * 2, fontHeight, "", TextAlign::Center); myTitle->setTextColor(kTextColorEm); myWhatsNewButton = - new ButtonWidget(this, font, _w - HBORDER - bwidth, ypos - (buttonHeight - fontHeight) / 2, + new ButtonWidget(this, font, _w - HBORDER - bwidth, + ypos - (buttonHeight - fontHeight) / 2, bwidth, buttonHeight, "What's New" + ELLIPSIS, kWhatsNew); wid.push_back(myWhatsNewButton); @@ -320,7 +322,7 @@ string AboutDialog::getUrl(const string& text) for(size_t i = 0; i < text.size(); ++i) { - string remainder = text.substr(i); + const string remainder = text.substr(i); const char ch = text[i]; if(!isUrl diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 311f4a76b..7df3803c4 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -167,7 +167,7 @@ void BrowserDialog::show(const string& startpath, if(_mode != Mode::Directories) { // split startpath into path and filename - FSNode fs = FSNode(startpath); + const FSNode fs = FSNode(startpath); fileName = fs.getName(); directory = fs.isDirectory() ? "" : fs.getParent().getPath(); } diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index e76183201..e4ac74484 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -137,7 +137,7 @@ void ContextMenu::setSelected(const Variant& tag, const Variant& defaultTag) }; // First try searching for a valid tag - bool tagSelected = tag != "" && SEARCH_AND_SELECT(tag); + const bool tagSelected = tag != "" && SEARCH_AND_SELECT(tag); // Otherwise use the default tag if(!tagSelected) diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index b6375d19c..f22e51303 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -98,7 +98,7 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) int ypos = VBORDER; WidgetArray wid; VariantList items; - int tabID = myTab->addTab(" Emulation ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Emulation ", TabWidget::AUTO_WIDTH); // settings set mySettingsGroupEmulation = new RadioButtonGroup(); @@ -139,8 +139,8 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) items.clear(); VarList::push_back(items, "Atari 2600", "2600"); VarList::push_back(items, "Atari 7800", "7800"); - int lwidth = font.getStringWidth("Console "); - int pwidth = font.getStringWidth("Atari 2600"); + const int lwidth = font.getStringWidth("Console "); + const int pwidth = font.getStringWidth("Atari 2600"); myConsoleWidget = new PopUpWidget(myTab, font, HBORDER + INDENT * 1, ypos, pwidth, lineHeight, items, "Console ", lwidth, kConsole); @@ -232,10 +232,10 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font) VGAP = Dialog::vGap(), INDENT = Dialog::indent(); int ypos = VBORDER; - int pwidth = font.getStringWidth("Faulty Cosmic Ark stars"); + const int pwidth = font.getStringWidth("Faulty Cosmic Ark stars"); WidgetArray wid; VariantList items; - int tabID = myTab->addTab(" TIA ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" TIA ", TabWidget::AUTO_WIDTH); wid.clear(); @@ -354,7 +354,7 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font) int pwidth = fontWidth * 6; WidgetArray wid; VariantList items; - int tabID = myTab->addTab(" Video ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Video ", TabWidget::AUTO_WIDTH); wid.clear(); @@ -516,7 +516,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) lwidth = fontWidth * 11; WidgetArray wid; VariantList items; - int tabID = myTab->addTab(" Time Machine ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Time Machine ", TabWidget::AUTO_WIDTH); // settings set mySettingsGroupTM = new RadioButtonGroup(); @@ -574,7 +574,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) items.clear(); for(int i = 0; i < NUM_INTERVALS; ++i) VarList::push_back(items, INTERVALS[i], INT_SETTINGS[i]); - int pwidth = font.getStringWidth("10 seconds"); + const int pwidth = font.getStringWidth("10 seconds"); myStateIntervalWidget = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, "Interval ", 0, kIntervalChanged); myStateIntervalWidget->setToolTip("Define the interval between each saved state."); @@ -606,7 +606,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::addDebuggerTab(const GUI::Font& font) { - int tabID = myTab->addTab(" Debugger ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Debugger ", TabWidget::AUTO_WIDTH); WidgetArray wid; #ifdef DEBUGGER_SUPPORT @@ -816,7 +816,7 @@ void DeveloperDialog::setWidgetStates(SettingsSet set) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::loadConfig() { - bool devSettings = instance().settings().getBool("dev.settings"); + const bool devSettings = instance().settings().getBool("dev.settings"); handleSettings(devSettings); mySettings = devSettings; mySettingsGroupEmulation->setSelected(devSettings ? 1 : 0); @@ -842,11 +842,11 @@ void DeveloperDialog::loadConfig() myDebuggerHeightSlider->setValue(h); // Debugger font size - string size = instance().settings().getString("dbg.fontsize"); + const string size = instance().settings().getString("dbg.fontsize"); myDebuggerFontSize->setSelected(size, "medium"); // Debugger font style - int style = instance().settings().getInt("dbg.fontstyle"); + const int style = instance().settings().getInt("dbg.fontstyle"); myDebuggerFontStyle->setSelected(style, "0"); // Ghost reads trap @@ -1121,7 +1121,7 @@ void DeveloperDialog::handleSettings(bool devSettings) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleTVJitterChange() { - bool enable = myTVJitterWidget->getState(); + const bool enable = myTVJitterWidget->getState(); myTVJitterSenseWidget->setEnabled(enable); myTVJitterRecWidget->setEnabled(enable); diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 792237cea..7687cf307 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -167,7 +167,8 @@ void Dialog::initHelp() { if(_helpWidget == nullptr) { - string key = instance().eventHandler().getMappingDesc(Event::UIHelp, EventMode::kMenuMode); + const string key = instance().eventHandler().getMappingDesc( + Event::UIHelp, EventMode::kMenuMode); _helpWidget = new ButtonWidget(this, _font, _w - _font.getMaxCharWidth() * 3.5, 0, diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 08ed17bda..f6f206f22 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -412,7 +412,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod) case Event::Undo: case Event::Redo: { - string oldString = _editString; + const string oldString = _editString; myUndoHandler->endChars(_editString); // Reverse Y and Z for QWERTZ keyboards @@ -846,7 +846,7 @@ bool EditableWidget::cutSelectedText() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EditableWidget::copySelectedText() { - string selected = selectString(); + const string selected = selectString(); // only copy if anything is selected, else keep old copied text if(!selected.empty()) @@ -860,7 +860,7 @@ bool EditableWidget::copySelectedText() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EditableWidget::pasteSelectedText() { - bool selected = !selectString().empty(); + const bool selected = !selectString().empty(); string pasted; myUndoHandler->endChars(_editString); diff --git a/src/gui/EmulationDialog.cxx b/src/gui/EmulationDialog.cxx index 3ea0511f1..1d372878a 100644 --- a/src/gui/EmulationDialog.cxx +++ b/src/gui/EmulationDialog.cxx @@ -74,9 +74,8 @@ EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, HBORDER = Dialog::hBorder(), VGAP = Dialog::vGap(), INDENT = Dialog::indent(); - int lwidth = font.getStringWidth("Emulation speed "); + const int lwidth = font.getStringWidth("Emulation speed "); WidgetArray wid; - VariantList items; const int swidth = fontWidth * 10; // Set real dimensions @@ -174,7 +173,7 @@ void EmulationDialog::loadConfig() const Settings& settings = instance().settings(); // Emulation speed - int speed = mapSpeed(settings.getFloat("speed")); + const int speed = mapSpeed(settings.getFloat("speed")); mySpeed->setValue(speed); mySpeed->setValueLabel(formatSpeed(speed)); @@ -200,7 +199,7 @@ void EmulationDialog::loadConfig() myConfirmExitWidget->setState(settings.getBool("confirmexit")); // Save on exit - string saveOnExit = settings.getString("saveonexit"); + const string saveOnExit = settings.getString("saveonexit"); mySaveOnExitGroup->setSelected(saveOnExit == "all" ? 2 : saveOnExit == "current" ? 1 : 0); // Automatically change save state slots myAutoSlotWidget->setState(settings.getBool("autoslot")); diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index b6377dbb6..fa4464b07 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -121,8 +121,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font, myComboButton->setTarget(this); addFocusWidget(myComboButton); - VariantList combolist = EventHandler::getComboList(); - myComboDialog = make_unique(boss, font, combolist); + myComboDialog = make_unique(boss, font, EventHandler::getComboList()); // Show message for currently selected event xpos = HBORDER; @@ -166,9 +165,7 @@ void EventMappingWidget::updateActions() ? EventMode::kMenuMode : EventMode::kEmulationMode; - StringList actions = EventHandler::getActionList(myEventGroup); - - myActionsList->setList(actions); + myActionsList->setList(EventHandler::getActionList(myEventGroup)); myActionSelected = myActionsList->getSelected(); drawKeyMapping(); enableButtons(true); diff --git a/src/gui/FavoritesManager.cxx b/src/gui/FavoritesManager.cxx index bebbf6fe0..f928f3908 100644 --- a/src/gui/FavoritesManager.cxx +++ b/src/gui/FavoritesManager.cxx @@ -42,10 +42,10 @@ void FavoritesManager::load() try { const json& jUser = json::parse(serializedUser); - for (const auto& u : jUser) + for (const auto& u: jUser) { const string& path = u.get(); - FSNode node(path); + const FSNode node(path); if (node.exists()) addUser(path); } @@ -66,10 +66,10 @@ void FavoritesManager::load() try { const json& jRecent = json::parse(serializedRecent); - for (const auto& r : jRecent) + for (const auto& r: jRecent) { const string& path = r.get(); - FSNode node(path); + const FSNode node(path); if (node.exists()) addRecent(path); } @@ -89,11 +89,11 @@ void FavoritesManager::load() try { const json& jPopular = json::parse(serializedPopular); - for (const auto& p : jPopular) + for (const auto& p: jPopular) { const string& path = p[0].get(); const uInt32 count = p[1].get(); - FSNode node(path); + const FSNode node(path); if (node.exists()) myPopularMap.emplace(path, count); } @@ -186,9 +186,10 @@ const FavoritesManager::UserList& FavoritesManager::userList() const [](const string& a, const string& b) { // Sort without path - FSNode aNode(a); - FSNode bNode(b); - const bool realDir = aNode.isDirectory() && !BSPF::endsWithIgnoreCase(aNode.getPath(), ".zip"); + const FSNode aNode(a); + const FSNode bNode(b); + const bool realDir = aNode.isDirectory() && + !BSPF::endsWithIgnoreCase(aNode.getPath(), ".zip"); if(realDir != (bNode.isDirectory() && !BSPF::endsWithIgnoreCase(bNode.getPath(), ".zip"))) return realDir; @@ -237,7 +238,7 @@ void FavoritesManager::removeAllRecent() const FavoritesManager::RecentList& FavoritesManager::recentList() const { static RecentList sortedList; - bool sortByName = mySettings.getBool("altsorting"); + const bool sortByName = mySettings.getBool("altsorting"); sortedList.clear(); if(sortByName) @@ -248,8 +249,8 @@ const FavoritesManager::RecentList& FavoritesManager::recentList() const [](const string& a, const string& b) { // Sort alphabetical, without path - FSNode aNode(a); - FSNode bNode(b); + const FSNode aNode(a); + const FSNode bNode(b); return BSPF::compareIgnoreCase(aNode.getName(), bNode.getName()) < 0; }); @@ -288,7 +289,7 @@ void FavoritesManager::incPopular(const string& path) // Limit number of entries and age data if(myPopularMap.size() >= max_popular) { - PopularList sortedList = sortedPopularList(); // sorted by frequency! + const PopularList& sortedList = sortedPopularList(); // sorted by frequency! for(const auto& item: sortedList) { const auto entry = myPopularMap.find(item.first); @@ -313,7 +314,8 @@ const FavoritesManager::PopularList& FavoritesManager::popularList() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const FavoritesManager::PopularList& FavoritesManager::sortedPopularList(bool sortByName) const +const FavoritesManager::PopularList& +FavoritesManager::sortedPopularList(bool sortByName) const { // Return most to least popular or sorted by name static PopularList sortedList; @@ -329,8 +331,8 @@ const FavoritesManager::PopularList& FavoritesManager::sortedPopularList(bool so return a.second > b.second; // 2. Sort alphabetical, without path - FSNode aNode(a.first); - FSNode bNode(b.first); + const FSNode aNode(a.first); + const FSNode bNode(b.first); return BSPF::compareIgnoreCase(aNode.getName(), bNode.getName()) < 0; }); return sortedList; diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 60eb1ce9f..ddcaf69f0 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -94,7 +94,7 @@ void FileListWidget::setLocation(const FSNode& node, const string& select) // Now fill the list widget with the names from the file list, // even if cancelled StringList list; - size_t orgLen = _node.getShortPath().length(); + const size_t orgLen = _node.getShortPath().length(); _dirList.clear(); _iconTypeList.clear(); @@ -193,7 +193,7 @@ void FileListWidget::selectParent() if(_node.hasParent()) { string name = _node.getName(); - FSNode parent(_node.getParent()); + const FSNode parent(_node.getParent()); _currentHistory->selected = selected().getName(); addHistory(parent); @@ -672,10 +672,10 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const 0b11111111111'11111111110 }; const int idx = static_cast(IconType::numTypes); - static const Icon* small_icons[idx] = { + static const Icon* const small_icons[idx] = { &unknown_small, &rom_small, &directory_small, &zip_small, &up_small }; - static const Icon* large_icons[idx] = { + static const Icon* const large_icons[idx] = { &unknown_large, &rom_large, &directory_large, &zip_large, &up_large, }; const bool smallIcon = iconWidth() < 24; diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index d40ff20fc..fd7417baf 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -114,7 +114,7 @@ void GameInfoDialog::addEmulationTab() VariantList items; // 1) Emulation properties - int tabID = myTab->addTab("Emulation", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab("Emulation", TabWidget::AUTO_WIDTH); int ypos = VBORDER; @@ -209,11 +209,11 @@ void GameInfoDialog::addConsoleTab() WidgetArray wid; // 2) Console properties - int tabID = myTab->addTab(" Console ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Console ", TabWidget::AUTO_WIDTH); const int xpos = HBORDER; int ypos = VBORDER; - int lwidth = _font.getStringWidth(GUI::RIGHT_DIFFICULTY + " "); + const int lwidth = _font.getStringWidth(GUI::RIGHT_DIFFICULTY + " "); new StaticTextWidget(myTab, _font, xpos, ypos + 1, "TV type"); myTVTypeGroup = new RadioButtonGroup(); @@ -275,7 +275,7 @@ void GameInfoDialog::addControllersTab() // 3) Controller properties wid.clear(); - int tabID = myTab->addTab("Controllers", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab("Controllers", TabWidget::AUTO_WIDTH); items.clear(); VarList::push_back(items, "Auto-detect", "AUTO"); @@ -429,15 +429,14 @@ void GameInfoDialog::addCartridgeTab() VGAP = Dialog::vGap(), HGAP = Dialog::fontWidth() / 4; WidgetArray wid; - VariantList items; wid.clear(); - int tabID = myTab->addTab("Cartridge", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab("Cartridge", TabWidget::AUTO_WIDTH); const int xpos = HBORDER; int ypos = VBORDER; - int lwidth = _font.getStringWidth("Manufacturer "); - const int fwidth = _w - lwidth - HBORDER * 2 - 2; + const int lwidth = _font.getStringWidth("Manufacturer "), + fwidth = _w - lwidth - HBORDER * 2 - 2; new StaticTextWidget(myTab, _font, xpos, ypos + 1, lwidth, fontHeight, "Name"); myName = new EditTextWidget(myTab, _font, xpos + lwidth, ypos - 1, fwidth, lineHeight, ""); @@ -503,21 +502,20 @@ void GameInfoDialog::addHighScoresTab() WidgetArray wid; VariantList items; - int tabID = myTab->addTab("High Scores", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab("High Scores", TabWidget::AUTO_WIDTH); - EditableWidget::TextFilter fAddr = [](char c) { + const EditableWidget::TextFilter fAddr = [](char c) { return (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9'); }; - EditableWidget::TextFilter fVars = [](char c) { + const EditableWidget::TextFilter fVars = [](char c) { return (c >= '0' && c <= '9'); }; - - EditableWidget::TextFilter fText = [](char c) { + const EditableWidget::TextFilter fText = [](char c) { return (c >= 'a' && c <= 'z') || (c >= ' ' && c < ',') || (c > ',' && c < '@'); }; int xpos = HBORDER, ypos = VBORDER; - int lwidth = _font.getStringWidth("Variations "); + const int lwidth = _font.getStringWidth("Variations "); myHighScores = new CheckboxWidget(myTab, _font, xpos, ypos + 1, "Enable High Scores", kHiScoresChanged); @@ -976,7 +974,7 @@ void GameInfoDialog::saveProperties() if(myMouseControl->getState()) mcontrol = myMouseX->getSelectedTag().toString() + myMouseY->getSelectedTag().toString(); - string range = myMouseRange->getValueLabel(); + const string range = myMouseRange->getValueLabel(); if(range != "100") mcontrol += " " + range; myGameProperties.set(PropType::Controller_MouseAxis, mcontrol); @@ -1073,7 +1071,7 @@ void GameInfoDialog::saveHighScoresProperties() info.scoreAddr[a] = stringToIntBase16(strAddr, HSM::DEFAULT_ADDRESS); } - string strVars = myVariations->getText(); + const string strVars = myVariations->getText(); HighScoresManager::set(myGameProperties, stringToInt(strVars, HSM::DEFAULT_VARIATION), info); @@ -1322,7 +1320,7 @@ void GameInfoDialog::eraseEEPROM() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void GameInfoDialog::updateLink() { - string link = myUrl->getText(); + const string link = myUrl->getText(); const bool enable = startsWithIgnoreCase(link, "http://") || startsWithIgnoreCase(link, "https://") || startsWithIgnoreCase(link, "www."); @@ -1401,7 +1399,7 @@ void GameInfoDialog::updateHighScoresWidgets() if(a < numAddr) { setAddressVal(myScoreAddress[a], myScoreAddressVal[a]); - string strAddr = myScoreAddress[a]->getText(); + const string strAddr = myScoreAddress[a]->getText(); scoreAddr[a] = stringToIntBase16(strAddr, HSM::DEFAULT_ADDRESS); } else diff --git a/src/gui/GlobalPropsDialog.cxx b/src/gui/GlobalPropsDialog.cxx index 1ca293d15..8674cc03c 100644 --- a/src/gui/GlobalPropsDialog.cxx +++ b/src/gui/GlobalPropsDialog.cxx @@ -39,8 +39,8 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font) VBORDER = Dialog::vBorder(), HBORDER = Dialog::hBorder(), VGAP = Dialog::vGap(); - int lwidth = font.getStringWidth("Right difficulty "), - pwidth = font.getStringWidth("CM (SpectraVideo CompuMate)"); + const int lwidth = font.getStringWidth("Right difficulty "); + int pwidth = font.getStringWidth("CM (SpectraVideo CompuMate)"); WidgetArray wid; VariantList items; const GUI::Font& infofont = instance().frameBuffer().infoFont(); diff --git a/src/gui/HelpDialog.cxx b/src/gui/HelpDialog.cxx index fcd994162..005d749bf 100644 --- a/src/gui/HelpDialog.cxx +++ b/src/gui/HelpDialog.cxx @@ -60,7 +60,7 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent, xpos += buttonWidth + fontWidth; - int updButtonWidth = Dialog::buttonWidth("Check for Update" + ELLIPSIS); + const int updButtonWidth = Dialog::buttonWidth("Check for Update" + ELLIPSIS); myUpdateButton = new ButtonWidget(this, font, xpos, ypos, updButtonWidth, buttonHeight, "Check for Update" + ELLIPSIS, kUpdateCmd); diff --git a/src/gui/HighScoresDialog.cxx b/src/gui/HighScoresDialog.cxx index d1097b257..b4c9c6a11 100644 --- a/src/gui/HighScoresDialog.cxx +++ b/src/gui/HighScoresDialog.cxx @@ -117,16 +117,16 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent, HBORDER = Dialog::hBorder(), VGAP = Dialog::vGap(); const int xposRank = HBORDER; - int xposScore = xposRank + _font.getStringWidth("Rank"); - int xposSpecial = xposScore + _font.getStringWidth(" Score "); - int xposName = xposSpecial + _font.getStringWidth("Round "); - int xposDate = xposName + _font.getStringWidth("Name "); - int xposDelete = xposDate + _font.getStringWidth("YY-MM-DD HH:MM "); - int nWidth = _font.getStringWidth("ABC") + fontWidth * 0.75; + const int xposScore = xposRank + _font.getStringWidth("Rank"); + const int xposSpecial = xposScore + _font.getStringWidth(" Score "); + const int xposName = xposSpecial + _font.getStringWidth("Round "); + const int xposDate = xposName + _font.getStringWidth("Name "); + const int xposDelete = xposDate + _font.getStringWidth("YY-MM-DD HH:MM "); + const int nWidth = _font.getStringWidth("ABC") + fontWidth * 0.75; const bool smallFont = _font.getFontHeight() < 24; const int buttonSize = smallFont ? BUTTON_GFX_H : BUTTON_GFX_H_LARGE; WidgetArray wid; - VariantList items; + const VariantList items; const int xpos = HBORDER; int ypos = VBORDER + _th; @@ -542,7 +542,7 @@ string HighScoresDialog::cartName() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string HighScoresDialog::now() { - std::tm now = BSPF::localTime(); + const std::tm now = BSPF::localTime(); ostringstream ss; ss << std::setfill('0') << std::right diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 5ddf5ff09..385b7b365 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -66,7 +66,7 @@ InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent, addTabWidget(myTab); // 1) Event mapper - int tabID = myTab->addTab(" Event Mappings ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Event Mappings ", TabWidget::AUTO_WIDTH); myEventMapper = new EventMappingWidget(myTab, _font, 2, 2, myTab->getWidth(), myTab->getHeight() - VGAP); @@ -110,7 +110,7 @@ void InputDialog::addDevicePortTab() WidgetArray wid; // Devices/ports - int tabID = myTab->addTab(" Devices & Ports ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Devices & Ports ", TabWidget::AUTO_WIDTH); int xpos = HBORDER, ypos = VBORDER; int lwidth = _font.getStringWidth("Digital paddle sensitivity "); @@ -282,11 +282,11 @@ void InputDialog::addMouseTab() VariantList items; // Mouse - int tabID = myTab->addTab(" Mouse ", TabWidget::AUTO_WIDTH); + const int tabID = myTab->addTab(" Mouse ", TabWidget::AUTO_WIDTH); int xpos = HBORDER, ypos = VBORDER; int lwidth = _font.getStringWidth("Use mouse as a controller "); - int pwidth = _font.getStringWidth("-UI, -Emulation"); + const int pwidth = _font.getStringWidth("-UI, -Emulation"); // Use mouse as controller VarList::push_back(items, "Always", "always"); diff --git a/src/gui/Launcher.cxx b/src/gui/Launcher.cxx index bac8a7c00..d68a16e43 100644 --- a/src/gui/Launcher.cxx +++ b/src/gui/Launcher.cxx @@ -31,7 +31,7 @@ Launcher::Launcher(OSystem& osystem) mySize{myOSystem.settings().getSize("launcherres")} { const Common::Size& d = myOSystem.frameBuffer().desktopSize(BufferType::Launcher); - double overscan = 1 - myOSystem.settings().getInt("tia.fs_overscan") / 100.0; + const double overscan = 1 - myOSystem.settings().getInt("tia.fs_overscan") / 100.0; // The launcher dialog is resizable, within certain bounds // We check those bounds now @@ -54,7 +54,7 @@ Launcher::~Launcher() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FBInitStatus Launcher::initializeVideo() { - string title = string("Stella ") + STELLA_VERSION; + const string title = string("Stella ") + STELLA_VERSION; return myOSystem.frameBuffer().createDisplay( title, BufferType::Launcher, mySize ); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 9d1bc90e8..37f8c6b53 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -447,7 +447,7 @@ const FSNode& LauncherDialog::currentDir() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherDialog::reload() { - bool extensions = instance().settings().getBool("launcherextensions"); + const bool extensions = instance().settings().getBool("launcherextensions"); myMD5List.clear(); myList->setShowFileExtensions(extensions); @@ -646,7 +646,7 @@ void LauncherDialog::setRomInfoFont(const Common::Size& area) { // TODO: Perhaps offer a setting to override the font used? - FontDesc FONTS[7] = { + const FontDesc FONTS[7] = { GUI::stella16x32tDesc, GUI::stella14x28tDesc, GUI::stella12x24tDesc, GUI::stellaLargeDesc, GUI::stellaMediumDesc, GUI::consoleMediumBDesc, GUI::consoleBDesc @@ -1352,7 +1352,7 @@ void LauncherDialog::toggleSubDirs(bool toggle) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherDialog::toggleExtensions() { - bool extensions = !instance().settings().getBool("launcherextensions"); + const bool extensions = !instance().settings().getBool("launcherextensions"); instance().settings().setValue("launcherextensions", extensions); myList->setShowFileExtensions(extensions); @@ -1365,7 +1365,7 @@ void LauncherDialog::toggleSorting() if(myList->inVirtualDir()) { // Toggle between normal and alternative sorting of virtual directories - bool altSorting = !instance().settings().getBool("altsorting"); + const bool altSorting = !instance().settings().getBool("altsorting"); instance().settings().setValue("altsorting", altSorting); reload(); diff --git a/src/gui/LauncherFileListWidget.cxx b/src/gui/LauncherFileListWidget.cxx index 618da666f..67cc3ef78 100644 --- a/src/gui/LauncherFileListWidget.cxx +++ b/src/gui/LauncherFileListWidget.cxx @@ -86,7 +86,7 @@ void LauncherFileListWidget::getChildren(const FSNode::CancelCheck& isCancelled) { for(const auto& item : myFavorites->popularList()) { - FSNode node(item.first); + const FSNode node(item.first); if(_filter(node)) _fileList.emplace_back(node); } @@ -95,7 +95,7 @@ void LauncherFileListWidget::getChildren(const FSNode::CancelCheck& isCancelled) { for(const auto& item : myFavorites->recentList()) { - FSNode node(item); + const FSNode node(item); if(_filter(node)) _fileList.emplace_back(node); } @@ -104,7 +104,8 @@ void LauncherFileListWidget::getChildren(const FSNode::CancelCheck& isCancelled) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void LauncherFileListWidget::addFolder(StringList& list, int& offset, const string& name, IconType icon) +void LauncherFileListWidget::addFolder(StringList& list, int& offset, + const string& name, IconType icon) { _fileList.insert(_fileList.begin() + offset, FSNode(_node.getPath() + name)); @@ -115,10 +116,11 @@ void LauncherFileListWidget::addFolder(StringList& list, int& offset, const stri ++offset; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string LauncherFileListWidget::startRomDir() { - string romDir = instance().settings().getString("startromdir"); - FSNode node(romDir); + const string romDir = instance().settings().getString("startromdir"); + const FSNode node(romDir); return node.getPath(); } @@ -509,12 +511,11 @@ const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const 0b11111111111'11111111110 }; static constexpr auto NLT = static_cast(IconType::numLauncherTypes); - static const Icon* small_icons[NLT] = { + static const Icon* const small_icons[NLT] = { &favrom_small, &favdir_small, &favzip_small, &user_small, &recent_small, &popular_small - }; - static const Icon* large_icons[NLT] = { + static const Icon* const large_icons[NLT] = { &favrom_large, &favdir_large, &favzip_large, &user_large, &recent_large, &popular_large }; diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index 3b8f02c61..6c773fc6f 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -222,7 +222,7 @@ void ListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) resetSelection(); // First check whether the selection changed - int newSelectedItem = findItem(x, y); + const int newSelectedItem = findItem(x, y); if (newSelectedItem >= static_cast(_list.size())) return; diff --git a/src/gui/LoggerDialog.cxx b/src/gui/LoggerDialog.cxx index c57a5178d..5400cbc4c 100644 --- a/src/gui/LoggerDialog.cxx +++ b/src/gui/LoggerDialog.cxx @@ -90,7 +90,7 @@ LoggerDialog::LoggerDialog(OSystem& osystem, DialogContainer& parent, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LoggerDialog::loadConfig() { - StringParser parser(Logger::instance().logMessages()); + const StringParser parser(Logger::instance().logMessages()); myLogInfo->setList(parser.stringList()); myLogInfo->setSelected(0); myLogInfo->scrollToEnd(); diff --git a/src/gui/NavigationWidget.cxx b/src/gui/NavigationWidget.cxx index bb222420b..75dcf6c99 100644 --- a/src/gui/NavigationWidget.cxx +++ b/src/gui/NavigationWidget.cxx @@ -134,7 +134,7 @@ void NavigationWidget::handleCommand(CommandSender* sender, int cmd, int data, { case kFolderClicked: { - FSNode node(myPath->getPath(id)); + const FSNode node(myPath->getPath(id)); myList->selectDirectory(node); break; } diff --git a/src/gui/OptionsDialog.cxx b/src/gui/OptionsDialog.cxx index f487f5f72..9d1040839 100644 --- a/src/gui/OptionsDialog.cxx +++ b/src/gui/OptionsDialog.cxx @@ -53,7 +53,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, myMode{mode} { // do not show basic settings options in debugger - bool minSettings = osystem.settings().getBool("minimal_ui") && mode != AppMode::debugger; + const bool minSettings = osystem.settings().getBool("minimal_ui") + && mode != AppMode::debugger; const int buttonHeight = Dialog::buttonHeight(), VBORDER = Dialog::vBorder(), HBORDER = Dialog::hBorder(), @@ -279,7 +280,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd, case kLoggerCmd: { uInt32 w = 0, h = 0; - bool uselargefont = getDynamicBounds(w, h); + const bool uselargefont = getDynamicBounds(w, h); myDialog = make_unique(instance(), parent(), _font, w, h, uselargefont); myDialog->open(); diff --git a/src/gui/PlusRomsSetupDialog.cxx b/src/gui/PlusRomsSetupDialog.cxx index 401a1988f..6fc6d0e1e 100644 --- a/src/gui/PlusRomsSetupDialog.cxx +++ b/src/gui/PlusRomsSetupDialog.cxx @@ -27,7 +27,7 @@ PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& pare const GUI::Font& font) : InputTextDialog(osystem, parent, font, "Nickname", "PlusROM backends setup", MAX_NICK_LEN) { - EditableWidget::TextFilter filter = [](char c) { + const EditableWidget::TextFilter filter = [](char c) { return isalnum(c) || (c == ' ') || (c == '_') || (c == '.'); }; diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index 346c57d43..4969d004f 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -111,7 +111,7 @@ void RomAuditDialog::auditRoms() myResults1->setText(""); myResults2->setText(""); - FSNode node(auditPath); + const FSNode node(auditPath); FSList files; files.reserve(2048); node.getChildren(files, FSNode::ListMode::FilesOnly); diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index a8b97334f..da64d5364 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -90,7 +90,7 @@ void RomImageWidget::reloadProperties(const FSNode& node) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomImageWidget::parseProperties(const FSNode& node, bool full) { - uInt64 startTime = TimerManager::getTicks() / 1000; + const uInt64 startTime = TimerManager::getTicks() / 1000; if(myNavSurface == nullptr) { @@ -205,14 +205,13 @@ bool RomImageWidget::getImageList(const string& propName, const string& romName, // Look for or (# is a number) const std::regex rgx("^(" + rgxPropName + "|" + rgxRomName + ")(_\\d+)?\\.(png|jpg)$"); - FSNode::NameFilter filter = ([&](const FSNode& node) - { + const FSNode::NameFilter filter = ([&](const FSNode& node) { return std::regex_match(node.getName(), rgx); } ); // Find all images matching the given names and the extension - FSNode node(instance().snapshotLoadDir().getPath()); + const FSNode node(instance().snapshotLoadDir().getPath()); node.getChildren(myImageList, FSNode::ListMode::FilesOnly, filter, false, false); // Sort again, not considering extensions, else would be at @@ -220,7 +219,8 @@ bool RomImageWidget::getImageList(const string& propName, const string& romName, std::sort(myImageList.begin(), myImageList.end(), [oldFileName](const FSNode& node1, const FSNode& node2) { - int compare = BSPF::compareIgnoreCase(node1.getNameWithExt(), node2.getNameWithExt()); + const int compare = BSPF::compareIgnoreCase( + node1.getNameWithExt(), node2.getNameWithExt()); return compare < 0 || // PNGs first! diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index 68b717fd8..91360d4ce 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -46,7 +46,6 @@ StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& pa ButtonWidget* bw = nullptr; WidgetArray wid; - VariantList items; // Set real dimensions setSize(35 * fontWidth + HBORDER * 2 + 5, @@ -98,7 +97,7 @@ void StellaSettingsDialog::addUIOptions(WidgetArray& wid, int xpos, int& ypos) const int lineHeight = Dialog::lineHeight(), VGAP = Dialog::vGap(); VariantList items; - int pwidth = _font.getStringWidth("Right bottom"); // align width with other popup + const int pwidth = _font.getStringWidth("Right bottom"); // align width with other popup ypos += 1; VarList::push_back(items, "Standard", "standard"); @@ -139,8 +138,8 @@ void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int xpos, int& ypos VarList::push_back(items, "S-Video", static_cast(NTSCFilter::Preset::SVIDEO)); VarList::push_back(items, "Composite", static_cast(NTSCFilter::Preset::COMPOSITE)); VarList::push_back(items, "Bad adjust", static_cast(NTSCFilter::Preset::BAD)); - int pwidth = _font.getStringWidth("Right bottom"); - int lwidth = _font.getStringWidth("Scanline intensity "); + const int pwidth = _font.getStringWidth("Right bottom"); + const int lwidth = _font.getStringWidth("Scanline intensity "); myTVMode = new PopUpWidget(this, _font, xpos, ypos, pwidth, lineHeight, items, "TV mode "); @@ -196,7 +195,7 @@ void StellaSettingsDialog::addGameOptions(WidgetArray& wid, int xpos, int& ypos) VarList::push_back(ctrls, "Joy2B+", "JOY_2B+"); // TODO: should work, but needs testing with real hardware VarList::push_back(ctrls, "QuadTari", "QUADTARI"); - int pwidth = _font.getStringWidth("Sega Genesis"); + const int pwidth = _font.getStringWidth("Sega Genesis"); myLeftPortLabel = new StaticTextWidget(this, _font, xpos, ypos + 1, "Left port "); myLeftPort = new PopUpWidget(this, _font, myLeftPortLabel->getRight(), myLeftPortLabel->getTop() - 1, pwidth, lineHeight, ctrls, "", 0, kLeftCChanged); @@ -244,8 +243,6 @@ void StellaSettingsDialog::loadConfig() handleOverscanChange(); // Controllers - Properties props; - if (instance().hasConsole()) { myGameProperties = instance().console().properties(); diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index a8f1eada9..3f2aedcfa 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -480,7 +480,7 @@ void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd, void TimeMachineDialog::initBar() { const RewindManager& r = instance().state().rewindManager(); - IntArray cycles = r.cyclesList(); + const IntArray cycles = r.cyclesList(); // Set range and intervals for timeline const uInt32 maxValue = cycles.size() > 1 ? static_cast(cycles.size() - 1) : 0; @@ -532,7 +532,7 @@ void TimeMachineDialog::handleWinds(Int32 numWinds) const uInt64 elapsed = instance().console().tia().cycles() - startCycles; if(elapsed > 0) { - string message = r.getUnitString(elapsed); + const string message = r.getUnitString(elapsed); // TODO: add message text from addState() myMessageWidget->setLabel((numWinds < 0 ? "(-" : "(+") + message + ")"); diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index e3f0e3d9a..98aa2291f 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -384,7 +384,7 @@ void UIDialog::loadConfig() mySnapLoadPath->setText(settings.getString("snaploaddir")); // Exit to launcher - bool exitlauncher = settings.getBool("exitlauncher"); + const bool exitlauncher = settings.getBool("exitlauncher"); myLauncherExitWidget->setState(exitlauncher); // UI palette @@ -413,23 +413,23 @@ void UIDialog::loadConfig() myCenter->setState(settings.getBool("center")); // Listwidget quick delay - int delay = settings.getInt("listdelay"); + const int delay = settings.getInt("listdelay"); myListDelaySlider->setValue(delay); // Mouse wheel lines - int mw = settings.getInt("mwheel"); + const int mw = settings.getInt("mwheel"); myWheelLinesSlider->setValue(mw); // Mouse double click - int md = settings.getInt("mdouble"); + const int md = settings.getInt("mdouble"); myDoubleClickSlider->setValue(md); // Controller input delay - int cs = settings.getInt("ctrldelay"); + const int cs = settings.getInt("ctrldelay"); myControllerDelaySlider->setValue(cs); // Controller input rate - int cr = settings.getInt("ctrlrate"); + const int cr = settings.getInt("ctrlrate"); myControllerRateSlider->setValue(cr); handleLauncherSize(); @@ -539,8 +539,9 @@ void UIDialog::setDefaults() break; case 1: // Launcher options { - FSNode node("~"); - const Common::Size& size = instance().frameBuffer().desktopSize(BufferType::Launcher); + const FSNode node("~"); + const Common::Size& size = + instance().frameBuffer().desktopSize(BufferType::Launcher); myRomPath->setText(node.getShortPath()); const uInt32 w = std::min(size.w, 900); @@ -568,12 +569,12 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id) { case GuiObject::kOKCmd: { - bool informPath = myIsGlobal && + const bool informPath = myIsGlobal && (myRomPath->getText() != instance().settings().getString("romdir") || myRomPath->getText() != instance().settings().getString("startromdir")); - bool informFav = myIsGlobal && + const bool informFav = myIsGlobal && myFavoritesWidget->getState() != instance().settings().getBool("favorites"); - bool informExt = myIsGlobal && + const bool informExt = myIsGlobal && myLauncherExtensionsWidget->getState() != instance().settings().getBool("launcherextensions"); saveConfig(); close(); diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index 94af92af7..715c1d12a 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -115,7 +115,6 @@ void VideoAudioDialog::addDisplayTab() const int xpos = HBORDER; int ypos = VBORDER; WidgetArray wid; - VariantList items; const int tabID = myTab->addTab(" Display ", TabWidget::AUTO_WIDTH); // Video renderer @@ -192,7 +191,8 @@ void VideoAudioDialog::addDisplayTab() // Add message concerning usage ypos = myTab->getHeight() - fontHeight - ifont.getFontHeight() - VGAP - VBORDER; - int iwidth = ifont.getStringWidth("(*) Change may require an application restart"); + const int iwidth = + ifont.getStringWidth("(*) Change may require an application restart"); new StaticTextWidget(myTab, ifont, xpos, ypos, std::min(iwidth, _w - HBORDER * 2), ifont.getFontHeight(), "(*) Change may require an application restart"); @@ -664,7 +664,7 @@ void VideoAudioDialog::loadConfig() // TV Mode myTVMode->setSelected( settings.getString("tv.filter"), "0"); - int preset = settings.getInt("tv.filter"); + const int preset = settings.getInt("tv.filter"); handleTVModeChange(static_cast(preset)); // TV Custom adjustables diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 3b849ce39..47bef00a1 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -309,8 +309,10 @@ void Widget::setToolTip(Event::Type event1, Event::Type event2, EventMode mode) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Widget::getToolTip(const Common::Point& pos) const { - string hotkey = instance().eventHandler().keyHandler().getMappingDesc(_toolTipEvent1, _toolTipMode); - string hotkey2 = instance().eventHandler().keyHandler().getMappingDesc(_toolTipEvent2, _toolTipMode); + string hotkey = instance().eventHandler().keyHandler().getMappingDesc( + _toolTipEvent1, _toolTipMode); + const string hotkey2 = instance().eventHandler().keyHandler().getMappingDesc( + _toolTipEvent2, _toolTipMode); if(hotkey2 != EmptyString) { @@ -320,9 +322,11 @@ string Widget::getToolTip(const Common::Point& pos) const if(p != string::npos) { - string testKey = hotkey.substr(0, p) + hotkey.substr(p + string(mod).length()); + const string testKey = hotkey.substr(0, p) + + hotkey.substr(p + string(mod).length()); if(testKey == hotkey2) - hotkey = hotkey.substr(0, p) + "[" + mod + "]" + hotkey.substr(p + string(mod).length()); + hotkey = hotkey.substr(0, p) + "[" + mod + "]" + + hotkey.substr(p + string(mod).length()); else hotkey += ", " + hotkey2; } diff --git a/src/os/unix/SerialPortUNIX.cxx b/src/os/unix/SerialPortUNIX.cxx index a47280542..48de27ac6 100644 --- a/src/os/unix/SerialPortUNIX.cxx +++ b/src/os/unix/SerialPortUNIX.cxx @@ -98,7 +98,7 @@ StringList SerialPortUNIX::portNames() // Check if port is valid; for now that means if it can be opened // Eventually we may extend this to do more intensive checks const auto isPortValid = [](const string& port) { - int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); + const int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); if(handle > 0) close(handle); return handle > 0; }; @@ -111,7 +111,7 @@ StringList SerialPortUNIX::portNames() FSList portList; portList.reserve(5); - FSNode dev("/dev/"); + const FSNode dev("/dev/"); dev.getChildren(portList, FSNode::ListMode::All, filter, false); // Add only those that can be opened