From f987c3f72cf79b918a9e1c41f3139ba785a4cdeb Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 20 Aug 2022 15:32:15 -0230 Subject: [PATCH] Yay, got clang-tidy working again. First pass at fixing suggestions. --- src/cheat/CheatCodeDialog.cxx | 2 +- src/cheat/CheatManager.cxx | 4 +- src/common/AudioQueue.cxx | 14 +- src/common/Base.cxx | 51 +++++--- src/common/EventHandlerSDL2.cxx | 2 +- src/common/FBBackendSDL2.cxx | 12 +- src/common/FBBackendSDL2.hxx | 2 +- src/common/FBSurfaceSDL2.cxx | 5 +- src/common/HighScoresManager.cxx | 15 ++- src/common/JPGLibrary.cxx | 2 +- src/common/JPGLibrary.hxx | 3 +- src/common/KeyMap.cxx | 2 +- src/common/MouseControl.cxx | 6 +- src/common/PJoystickHandler.cxx | 8 +- src/common/PKeyboardHandler.cxx | 8 +- src/common/PNGLibrary.cxx | 69 +++++----- src/common/PNGLibrary.hxx | 4 +- src/common/PaletteHandler.cxx | 2 +- src/common/PhysicalJoystick.cxx | 6 +- src/common/RewindManager.cxx | 31 ++--- src/common/SoundSDL2.cxx | 4 +- src/common/StaggeredLogger.cxx | 2 +- src/common/StateManager.cxx | 2 +- src/common/TimerManager.cxx | 4 +- src/common/ZipHandler.cxx | 10 +- src/common/audio/LanczosResampler.cxx | 24 ++-- src/common/audio/SimpleResampler.cxx | 15 ++- .../repository/CompositeKVRJsonAdapter.cxx | 2 +- .../CompositeKeyValueRepository.cxx | 4 +- .../repository/KeyValueRepositoryJsonFile.cxx | 11 +- .../KeyValueRepositoryPropertyFile.cxx | 14 +- .../repository/sqlite/SqliteDatabase.cxx | 2 +- .../repository/sqlite/SqliteStatement.cxx | 3 +- src/common/repository/sqlite/StellaDb.cxx | 2 +- src/common/sdl_blitter/BilinearBlitter.cxx | 2 +- src/common/sdl_blitter/QisBlitter.cxx | 2 +- src/common/tv_filters/AtariNTSC.cxx | 43 +++---- src/debugger/CartDebug.cxx | 28 ++-- src/debugger/DebuggerParser.cxx | 10 +- src/debugger/DiStella.cxx | 4 +- src/debugger/RiotDebug.cxx | 4 +- src/debugger/TIADebug.cxx | 25 ++-- src/debugger/TIADebug.hxx | 10 +- src/debugger/gui/AtariVoxWidget.cxx | 6 +- src/debugger/gui/AudioWidget.cxx | 5 +- src/debugger/gui/BoosterWidget.cxx | 6 +- src/debugger/gui/Cart3EPlusWidget.cxx | 33 ++--- src/debugger/gui/Cart3EWidget.cxx | 9 +- src/debugger/gui/CartARMWidget.cxx | 4 +- src/debugger/gui/CartARWidget.cxx | 4 +- src/debugger/gui/CartBUSWidget.cxx | 3 +- src/debugger/gui/CartCDFWidget.cxx | 3 +- src/debugger/gui/CartCMWidget.cxx | 2 +- src/debugger/gui/CartEnhancedWidget.cxx | 12 +- src/debugger/gui/CartFA2Widget.cxx | 2 +- src/debugger/gui/CartRamWidget.cxx | 2 +- src/debugger/gui/CpuWidget.cxx | 4 +- src/debugger/gui/DataGridWidget.cxx | 15 ++- src/debugger/gui/DebuggerDialog.cxx | 38 +++--- src/debugger/gui/Joy2BPlusWidget.cxx | 6 +- src/debugger/gui/PointingDeviceWidget.cxx | 10 +- src/debugger/gui/PromptWidget.cxx | 11 +- src/debugger/gui/RamWidget.cxx | 4 +- src/debugger/gui/RiotRamWidget.cxx | 14 +- src/debugger/gui/RiotWidget.cxx | 4 +- src/debugger/gui/RomListSettings.cxx | 6 +- src/debugger/gui/RomListWidget.cxx | 26 ++-- src/debugger/gui/RomWidget.cxx | 6 +- src/debugger/gui/SaveKeyWidget.cxx | 6 +- src/debugger/gui/TiaInfoWidget.cxx | 4 +- src/debugger/gui/TiaWidget.cxx | 4 +- src/debugger/gui/TiaZoomWidget.cxx | 7 +- src/debugger/gui/TiaZoomWidget.hxx | 2 +- src/debugger/gui/ToggleWidget.cxx | 3 +- src/debugger/yacc/YaccParser.cxx | 6 +- src/emucore/AtariVox.cxx | 2 +- src/emucore/Cart.cxx | 2 +- src/emucore/Cart3EX.cxx | 2 +- src/emucore/CartAR.cxx | 28 ++-- src/emucore/CartAR.hxx | 6 +- src/emucore/CartBUS.cxx | 8 +- src/emucore/CartCDF.cxx | 8 +- src/emucore/CartCTY.cxx | 4 +- src/emucore/CartDPC.cxx | 6 +- src/emucore/CartDPCPlus.cxx | 8 +- src/emucore/CartDetector.cxx | 48 +++---- src/emucore/CartE7.cxx | 15 ++- src/emucore/CartE7.hxx | 7 +- src/emucore/CartEnhanced.cxx | 12 +- src/emucore/CartMVC.cxx | 43 +++---- src/emucore/CartMVC.hxx | 2 +- src/emucore/Console.cxx | 10 +- src/emucore/ControllerDetector.cxx | 120 +++++++++--------- src/emucore/EmulationWorker.cxx | 2 +- src/emucore/EventHandler.cxx | 11 +- src/emucore/FBBackend.hxx | 2 +- src/emucore/FBSurface.cxx | 25 ++-- src/emucore/FrameBuffer.cxx | 8 +- src/emucore/FrameBuffer.hxx | 4 +- src/emucore/GlobalKeyHandler.cxx | 2 +- src/emucore/Keyboard.cxx | 2 +- src/emucore/M6532.cxx | 6 +- src/emucore/MD5.cxx | 12 +- src/emucore/MT24LC256.cxx | 1 + src/emucore/OSystem.cxx | 2 +- src/emucore/OSystemStandalone.cxx | 13 +- src/emucore/Paddles.cxx | 4 +- src/emucore/PlusROM.cxx | 21 +-- src/emucore/Props.cxx | 5 +- src/emucore/PropsSet.cxx | 2 +- src/emucore/SaveKey.cxx | 2 +- src/emucore/Serializer.cxx | 12 +- src/emucore/Settings.cxx | 4 +- src/emucore/TIASurface.cxx | 41 +++--- src/emucore/Thumbulator.cxx | 20 ++- src/emucore/tia/Audio.cxx | 6 +- src/emucore/tia/DelayQueueIteratorImpl.hxx | 2 +- src/emucore/tia/DrawCounterDecodes.cxx | 6 +- src/emucore/tia/Player.cxx | 2 +- src/emucore/tia/TIA.cxx | 21 ++- .../frame-manager/AbstractFrameManager.cxx | 2 +- src/gui/AboutDialog.cxx | 11 +- src/gui/CheckListWidget.cxx | 14 +- src/gui/CommandDialog.cxx | 4 +- src/gui/DeveloperDialog.cxx | 25 ++-- src/gui/Dialog.cxx | 7 +- src/gui/EditTextWidget.cxx | 5 +- src/gui/EmulationDialog.cxx | 6 +- src/gui/EventMappingWidget.cxx | 3 +- src/gui/FavoritesManager.cxx | 4 +- src/gui/FileListWidget.cxx | 2 +- src/gui/FileListWidget.hxx | 2 +- src/gui/GameInfoDialog.cxx | 10 +- src/gui/GlobalPropsDialog.cxx | 4 +- src/gui/HelpDialog.cxx | 5 +- src/gui/HighScoresDialog.cxx | 25 ++-- src/gui/InputDialog.cxx | 18 +-- src/gui/InputTextDialog.cxx | 11 +- src/gui/JoystickDialog.cxx | 2 +- src/gui/LauncherDialog.cxx | 27 ++-- src/gui/ListWidget.cxx | 3 +- src/gui/LoggerDialog.cxx | 7 +- src/gui/MessageBox.cxx | 4 +- src/gui/MinUICommandDialog.cxx | 4 +- src/gui/NavigationWidget.cxx | 9 +- src/gui/OptionsDialog.cxx | 12 +- src/gui/PopUpWidget.cxx | 6 +- src/gui/ProgressDialog.cxx | 6 +- src/gui/R77HelpDialog.cxx | 6 +- src/gui/RadioButtonWidget.cxx | 4 +- src/gui/RomAuditDialog.cxx | 7 +- src/gui/RomImageWidget.cxx | 21 +-- src/gui/RomImageWidget.hxx | 2 +- src/gui/RomInfoWidget.cxx | 3 +- src/gui/RomInfoWidget.hxx | 3 +- src/gui/SnapshotDialog.cxx | 4 +- src/gui/StellaSettingsDialog.cxx | 2 +- src/gui/StringListWidget.cxx | 5 +- src/gui/TabWidget.cxx | 10 +- src/gui/TimeMachineDialog.cxx | 16 +-- src/gui/UIDialog.cxx | 5 +- src/gui/UndoHandler.cxx | 2 +- src/gui/VideoAudioDialog.cxx | 24 ++-- src/gui/Widget.cxx | 2 +- src/lib/sqlite/sqlite3.c | 8 +- src/lib/tinyexif/tinyexif.cxx | 8 +- 166 files changed, 879 insertions(+), 802 deletions(-) diff --git a/src/cheat/CheatCodeDialog.cxx b/src/cheat/CheatCodeDialog.cxx index b9fda176b..8b007825a 100644 --- a/src/cheat/CheatCodeDialog.cxx +++ b/src/cheat/CheatCodeDialog.cxx @@ -111,7 +111,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CheatCodeDialog::~CheatCodeDialog() +CheatCodeDialog::~CheatCodeDialog() // NOLINT (we need an empty d'tor) { } diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index d4aedb440..7bd5b0984 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -93,8 +93,8 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab } // Make sure there are no duplicates - bool found = false; - uInt32 i; + bool found{false}; + uInt32 i{0}; for(i = 0; i < myPerFrameList.size(); ++i) { if(myPerFrameList[i]->code() == cheat->code()) diff --git a/src/common/AudioQueue.cxx b/src/common/AudioQueue.cxx index 68afe1864..6144cae7e 100644 --- a/src/common/AudioQueue.cxx +++ b/src/common/AudioQueue.cxx @@ -29,16 +29,20 @@ AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo) { const uInt8 sampleSize = myIsStereo ? 2 : 1; - myFragmentBuffer = make_unique(myFragmentSize * sampleSize * (capacity + 2)); + myFragmentBuffer = make_unique( + static_cast(myFragmentSize) * sampleSize * (capacity + 2)); for (uInt32 i = 0; i < capacity; ++i) - myFragmentQueue[i] = myAllFragments[i] = myFragmentBuffer.get() + i * sampleSize * myFragmentSize; + myFragmentQueue[i] = myAllFragments[i] = myFragmentBuffer.get() + + static_cast(myFragmentSize) * sampleSize * i; myAllFragments[capacity] = myFirstFragmentForEnqueue = - myFragmentBuffer.get() + capacity * sampleSize * myFragmentSize; + myFragmentBuffer.get() + static_cast(myFragmentSize) * sampleSize * + capacity; myAllFragments[capacity + 1] = myFirstFragmentForDequeue = - myFragmentBuffer.get() + (capacity + 1) * sampleSize * myFragmentSize; + myFragmentBuffer.get() + static_cast(myFragmentSize) * sampleSize * + (capacity + 1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -83,7 +87,7 @@ Int16* AudioQueue::enqueue(Int16* fragment) return newFragment; } - const uInt8 capacity = static_cast(myFragmentQueue.size()); + const auto capacity = static_cast(myFragmentQueue.size()); const uInt8 fragmentIndex = (myNextFragment + mySize) % capacity; newFragment = myFragmentQueue.at(fragmentIndex); diff --git a/src/common/Base.cxx b/src/common/Base.cxx index 2c4430f2a..79f632dc6 100644 --- a/src/common/Base.cxx +++ b/src/common/Base.cxx @@ -47,74 +47,83 @@ string Base::toString(int value, Common::Base::Fmt outputBase) case Base::Fmt::_10: // base 10: 3 or 5 bytes (depending on value) if(value > -0x100 && value < 0x100) - std::snprintf(vToS_buf, 5, "%3d", static_cast(value)); + std::ignore = std::snprintf(vToS_buf, 5, "%3d", static_cast(value)); else - std::snprintf(vToS_buf, 6, "%5d", value); + std::ignore = std::snprintf(vToS_buf, 6, "%5d", value); break; case Base::Fmt::_10_02: // base 10: 2 digits (with leading zero) - std::snprintf(vToS_buf, 3, "%02d", value); + std::ignore = std::snprintf(vToS_buf, 3, "%02d", value); break; case Base::Fmt::_10_3: // base 10: 3 digits - std::snprintf(vToS_buf, 4, "%3d", value); + std::ignore = std::snprintf(vToS_buf, 4, "%3d", value); break; case Base::Fmt::_10_4: // base 10: 4 digits - std::snprintf(vToS_buf, 5, "%4d", value); + std::ignore = std::snprintf(vToS_buf, 5, "%4d", value); break; case Base::Fmt::_10_5: // base 10: 5 digits - std::snprintf(vToS_buf, 6, "%5d", value); + std::ignore = std::snprintf(vToS_buf, 6, "%5d", value); break; case Base::Fmt::_10_6: // base 10: 6 digits - std::snprintf(vToS_buf, 7, "%6d", value); + std::ignore = std::snprintf(vToS_buf, 7, "%6d", value); break; case Base::Fmt::_10_8: // base 10: 8 digits - std::snprintf(vToS_buf, 9, "%8d", value); + std::ignore = std::snprintf(vToS_buf, 9, "%8d", value); break; case Base::Fmt::_16_1: // base 16: 1 byte wide - std::snprintf(vToS_buf, 2, hexUppercase() ? "%1X" : "%1x", value); + std::ignore = std::snprintf( + vToS_buf, 2, hexUppercase() ? "%1X" : "%1x", value); break; case Base::Fmt::_16_2: // base 16: 2 bytes wide - std::snprintf(vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value); + std::ignore = std::snprintf( + vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value); break; case Base::Fmt::_16_2_2: - std::snprintf(vToS_buf, 6, hexUppercase() ? "%02X.%02X" : "%02x.%02x", - value >> 8, value & 0xff ); + std::ignore = std::snprintf( + vToS_buf, 6, hexUppercase() ? "%02X.%02X" : "%02x.%02x", + value >> 8, value & 0xff ); break; case Base::Fmt::_16_3_2: - std::snprintf(vToS_buf, 7, hexUppercase() ? "%03X.%02X" : "%03x.%02x", - value >> 8, value & 0xff ); + std::ignore = std::snprintf( + vToS_buf, 7, hexUppercase() ? "%03X.%02X" : "%03x.%02x", + value >> 8, value & 0xff ); break; case Base::Fmt::_16_4: // base 16: 4 bytes wide - std::snprintf(vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value); + std::ignore = std::snprintf( + vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value); break; case Base::Fmt::_16_8: // base 16: 8 bytes wide - std::snprintf(vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value); + std::ignore = std::snprintf( + vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value); break; case Base::Fmt::_16: // base 16: 2, 4, 8 bytes (depending on value) default: if(value < 0x100) - std::snprintf(vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value); + std::ignore = std::snprintf( + vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value); else if(value < 0x10000) - std::snprintf(vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value); + std::ignore = std::snprintf( + vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value); else - std::snprintf(vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value); + std::ignore = std::snprintf( + vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value); break; } - return string(vToS_buf); + return {vToS_buf}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Base::Fmt Base::myDefaultBase = Base::Fmt::_16; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex; +std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex; // NOLINT } // Namespace Common diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 30b1b7a31..d4d8766cf 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -141,7 +141,7 @@ void EventHandlerSDL2::pollEvent() case SDL_MOUSEWHEEL: { - int x, y; + int x{0}, y{0}; SDL_GetMouseState(&x, &y); // we need mouse position too if(myEvent.wheel.y < 0) handleMouseButtonEvent(MouseButton::WHEELDOWN, true, x, y); diff --git a/src/common/FBBackendSDL2.cxx b/src/common/FBBackendSDL2.cxx index ef35405e7..47b64eeb2 100644 --- a/src/common/FBBackendSDL2.cxx +++ b/src/common/FBBackendSDL2.cxx @@ -174,11 +174,11 @@ void FBBackendSDL2::queryHardware(vector& fullscreenRes, { // Map SDL names into nicer Stella names (if available) bool found = false; - for(size_t j = 0; j < RENDERER_NAMES.size(); ++j) + for(const auto& render: RENDERER_NAMES) { - if(RENDERER_NAMES[j].sdlName == info.name) + if(render.sdlName == info.name) { - VarList::push_back(renderers, RENDERER_NAMES[j].stellaName, info.name); + VarList::push_back(renderers, render.stellaName, info.name); found = true; break; } @@ -284,7 +284,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode, if(myWindow) { const int d = SDL_GetWindowDisplayIndex(myWindow); - int w, h; + int w{0}, h{0}; SDL_GetWindowSize(myWindow, &w, &h); if(d != displayIndex || static_cast(w) != mode.screenS.w || @@ -567,7 +567,7 @@ unique_ptr FBBackendSDL2::createSurface( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBBackendSDL2::readPixels(uInt8* pixels, uInt32 pitch, +void FBBackendSDL2::readPixels(uInt8* pixels, size_t pitch, const Common::Rect& rect) const { ASSERT_MAIN_THREAD; @@ -576,7 +576,7 @@ void FBBackendSDL2::readPixels(uInt8* pixels, uInt32 pitch, r.x = rect.x(); r.y = rect.y(); r.w = rect.w(); r.h = rect.h(); - SDL_RenderReadPixels(myRenderer, &r, 0, pixels, pitch); + SDL_RenderReadPixels(myRenderer, &r, 0, pixels, static_cast(pitch)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/FBBackendSDL2.hxx b/src/common/FBBackendSDL2.hxx index a0c9d7acb..780592fa2 100644 --- a/src/common/FBBackendSDL2.hxx +++ b/src/common/FBBackendSDL2.hxx @@ -121,7 +121,7 @@ class FBBackendSDL2 : public FBBackend @param pitch The pitch (in bytes) for the pixel data @param rect The bounding rectangle for the buffer */ - void readPixels(uInt8* buffer, uInt32 pitch, + void readPixels(uInt8* buffer, size_t pitch, const Common::Rect& rect) const override; /** diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index 89a98df95..6899b982d 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -249,9 +249,10 @@ void FBSurfaceSDL2::createSurface(uInt32 width, uInt32 height, myIsStatic = data != nullptr; if(myIsStatic) - SDL_memcpy(mySurface->pixels, data, mySurface->w * mySurface->h * 4); + SDL_memcpy(mySurface->pixels, data, + static_cast(mySurface->w) * mySurface->h * 4); - reload(); + reload(); // NOLINT } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index 5b7e5ec62..b46cffbff 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -65,9 +65,10 @@ HighScoresManager::HighScoresManager(OSystem& osystem) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void HighScoresManager::setRepository(shared_ptr repo) +void HighScoresManager::setRepository( + shared_ptr repo) { - myHighscoreRepository = repo; + myHighscoreRepository = std::move(repo); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -701,12 +702,12 @@ bool HighScoresManager::load(const json& hsData, ScoresData& data) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void HighScoresManager::clearHighScores(ScoresData& data) { - for(uInt32 r = 0; r < NUM_RANKS; ++r) + for(auto& s: data.scores) { - data.scores[r].score = 0; - data.scores[r].special = 0; - data.scores[r].name = ""; - data.scores[r].date = ""; + s.score = 0; + s.special = 0; + s.name = ""; + s.date = ""; } } diff --git a/src/common/JPGLibrary.cxx b/src/common/JPGLibrary.cxx index 8ed7b9412..175b141d6 100644 --- a/src/common/JPGLibrary.cxx +++ b/src/common/JPGLibrary.cxx @@ -87,7 +87,7 @@ void JPGLibrary::loadImagetoSurface(FBSurface& surface) surface.setSrcSize(iw, ih); // Convert RGB triples into pixels and store in the surface - uInt32* s_buf, s_pitch; + uInt32 *s_buf{nullptr}, s_pitch{0}; surface.basePtr(s_buf, s_pitch); const uInt8* i_buf = myReadInfo.buffer; const uInt32 i_pitch = myReadInfo.pitch; diff --git a/src/common/JPGLibrary.hxx b/src/common/JPGLibrary.hxx index 8fd57eeab..89b805098 100644 --- a/src/common/JPGLibrary.hxx +++ b/src/common/JPGLibrary.hxx @@ -46,7 +46,8 @@ class JPGLibrary runtime_error is thrown containing a more detailed error message. */ - void loadImage(const string& filename, FBSurface& surface, VariantList& metaData); + void loadImage(const string& filename, FBSurface& surface, + VariantList& metaData); private: // Global OSystem object diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index cf7f7cc5e..c5b8f1bd1 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -25,7 +25,7 @@ using json = nlohmann::json; namespace { json serializeModkeyMask(int mask) { - if(mask == StellaMod::KBDM_NONE) return json(nullptr); + if(mask == StellaMod::KBDM_NONE) return {}; json serializedMask = json::array(); diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index 73e06313b..3b3065dcf 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -41,8 +41,10 @@ MouseControl::MouseControl(Console& console, const string& mode) m_mode[0] >= '0' && m_mode[0] <= '8' && m_mode[1] >= '0' && m_mode[1] <= '8') { - const MouseControl::Type xaxis = static_cast(static_cast(m_mode[0]) - '0'); - const MouseControl::Type yaxis = static_cast(static_cast(m_mode[1]) - '0'); + const auto xaxis = static_cast + (static_cast(m_mode[0]) - '0'); + const auto yaxis = static_cast + (static_cast(m_mode[1]) - '0'); ostringstream msg; Controller::Type xtype = Controller::Type::Joystick, ytype = Controller::Type::Joystick; int xid = -1, yid = -1; diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 6873bed78..42350874d 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -149,11 +149,9 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick) // We're potentially swapping out an input device behind the back of // the Event system, so we make sure all Stelladaptor-generated events // are reset - for(int port = 0; port < NUM_PORTS; ++port) - { - for(int axis = 0; axis < NUM_SA_AXIS; ++axis) + for(int port = 0; port < NUM_PORTS; ++port) // NOLINT + for(int axis = 0; axis < NUM_SA_AXIS; ++axis) // NOLINT myEvent.set(SA_Axis[port][axis], 0); - } return stick->ID; } @@ -588,7 +586,7 @@ void PhysicalJoystickHandler::enableCommonMappings() { for (int i = Event::NoType + 1; i < Event::LastType; i++) { - const Event::Type event = static_cast(i); + const auto event = static_cast(i); if(isCommonEvent(event)) enableMapping(event, EventMode::kCommonMode); diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 1bb76a9fa..66a3b4b54 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -219,10 +219,8 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod void PhysicalKeyboardHandler::defineControllerMappings( const Controller::Type type, Controller::Jack port, const Properties& properties) { - - //const string& test = myOSystem.settings().getString("aq"); - // determine controller events to use - switch(type) + // Determine controller events to use + switch(type) // NOLINT (could be written as IF/ELSE) { case Controller::Type::QuadTari: if(port == Controller::Jack::Left) @@ -377,7 +375,7 @@ void PhysicalKeyboardHandler::enableCommonMappings() { for (int i = Event::NoType + 1; i < Event::LastType; i++) { - const Event::Type event = static_cast(i); + const auto event = static_cast(i); if (isCommonEvent(event)) enableMapping(event, EventMode::kCommonMode); diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index d56380453..916d9d6f1 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -135,16 +135,16 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& metaData) fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h()) ); - const png_uint_32 width = rect.w(), height = rect.h(); + const size_t width = rect.w(), height = rect.h(); // Get framebuffer pixel data (we get ABGR format) vector buffer(width * height * 4); - fb.readPixels(buffer.data(), width*4, rect); + fb.readPixels(buffer.data(), width * 4, rect); // Set up pointers into "buffer" byte array vector rows(height); - for(png_uint_32 k = 0; k < height; ++k) - rows[k] = buffer.data() + k*width*4; + for(size_t k = 0; k < height; ++k) + rows[k] = buffer.data() + k * width * 4; // And save the image saveImageToDisk(out, rows, width, height, metaData); @@ -159,7 +159,7 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface, throw runtime_error("ERROR: Couldn't create snapshot file"); // Do we want the entire surface or just a section? - png_uint_32 width = rect.w(), height = rect.h(); + size_t width = rect.w(), height = rect.h(); if(rect.empty()) { width = surface.width(); @@ -168,12 +168,12 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface, // Get the surface pixel data (we get ABGR format) vector buffer(width * height * 4); - surface.readPixels(buffer.data(), width, rect); + surface.readPixels(buffer.data(), static_cast(width), rect); // Set up pointers into "buffer" byte array vector rows(height); - for(png_uint_32 k = 0; k < height; ++k) - rows[k] = buffer.data() + k*width*4; + for(size_t k = 0; k < height; ++k) + rows[k] = buffer.data() + k * width * 4; // And save the image saveImageToDisk(out, rows, width, height, metaData); @@ -181,10 +181,10 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector& rows, - png_uint_32 width, png_uint_32 height, const VariantList& metaData) + size_t width, size_t height, const VariantList& metaData) { - png_structp png_ptr = nullptr; - png_infop info_ptr = nullptr; + png_structp png_ptr{nullptr}; + png_infop info_ptr{nullptr}; const auto saveImageERROR = [&](const char* s) { if(png_ptr) @@ -208,7 +208,8 @@ void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector& ro png_set_write_fn(png_ptr, &out, png_write_data, png_io_flush); // Write PNG header info - png_set_IHDR(png_ptr, info_ptr, width, height, 8, + png_set_IHDR(png_ptr, info_ptr, + static_cast(width), static_cast(height), 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -381,7 +382,7 @@ void PNGLibrary::takeSnapshot(uInt32 number) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h) +bool PNGLibrary::allocateStorage(size_t w, size_t h) { // Create space for the entire image (3 bytes per pixel in RGB format) const size_t req_buffer_size = w * h * 3; @@ -392,9 +393,9 @@ bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h) if(req_row_size > ReadInfo.row_pointers.capacity()) ReadInfo.row_pointers.reserve(req_row_size * 1.5); - ReadInfo.width = w; - ReadInfo.height = h; - ReadInfo.pitch = w * 3; + ReadInfo.width = static_cast(w); + ReadInfo.height = static_cast(h); + ReadInfo.pitch = static_cast(w * 3); return true; } @@ -413,7 +414,7 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface) surface.setSrcSize(iw, ih); // Convert RGB triples into pixels and store in the surface - uInt32 *s_buf, s_pitch; + uInt32 *s_buf{nullptr}, s_pitch{0}; surface.basePtr(s_buf, s_pitch); const uInt8* i_buf = ReadInfo.buffer.data(); const uInt32 i_pitch = ReadInfo.pitch; @@ -429,30 +430,32 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::writeMetaData(const png_structp png_ptr, png_infop info_ptr, - const VariantList& metaData) +void PNGLibrary::writeMetaData( + const png_structp png_ptr, png_infop info_ptr, // NOLINT + const VariantList& metaData) { - const uInt32 numMetaData = static_cast(metaData.size()); + const size_t numMetaData = metaData.size(); if(numMetaData == 0) return; vector text_ptr(numMetaData); - for(uInt32 i = 0; i < numMetaData; ++i) + for(size_t i = 0; i < numMetaData; ++i) { text_ptr[i].key = const_cast(metaData[i].first.c_str()); text_ptr[i].text = const_cast(metaData[i].second.toCString()); text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE; text_ptr[i].text_length = 0; } - png_set_text(png_ptr, info_ptr, text_ptr.data(), numMetaData); + png_set_text(png_ptr, info_ptr, text_ptr.data(), static_cast(numMetaData)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::readMetaData(const png_structp png_ptr, png_infop info_ptr, - VariantList& metaData) +void PNGLibrary::readMetaData( + const png_structp png_ptr, png_infop info_ptr, // NOLINT + VariantList& metaData) { - png_textp text_ptr; - int numMetaData = 0; + png_textp text_ptr{nullptr}; + int numMetaData{0}; png_get_text(png_ptr, info_ptr, &text_ptr, &numMetaData); @@ -464,33 +467,37 @@ void PNGLibrary::readMetaData(const png_structp png_ptr, png_infop info_ptr, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_read_data(const png_structp ctx, png_bytep area, png_size_t size) +void PNGLibrary::png_read_data(const png_structp ctx, // NOLINT + png_bytep area, png_size_t size) { (static_cast(png_get_io_ptr(ctx)))->read( reinterpret_cast(area), size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_write_data(const png_structp ctx, png_bytep area, png_size_t size) +void PNGLibrary::png_write_data(const png_structp ctx, // NOLINT + png_bytep area, png_size_t size) { (static_cast(png_get_io_ptr(ctx)))->write( reinterpret_cast(area), size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_io_flush(const png_structp ctx) +void PNGLibrary::png_io_flush(const png_structp ctx) // NOLINT { (static_cast(png_get_io_ptr(ctx)))->flush(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_user_warn(const png_structp ctx, png_const_charp str) +void PNGLibrary::png_user_warn(const png_structp ctx, // NOLINT + png_const_charp str) { throw runtime_error(string("PNGLibrary warning: ") + str); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PNGLibrary::png_user_error(const png_structp ctx, png_const_charp str) +void PNGLibrary::png_user_error(const png_structp ctx, // NOLINT + png_const_charp str) { throw runtime_error(string("PNGLibrary error: ") + str); } diff --git a/src/common/PNGLibrary.hxx b/src/common/PNGLibrary.hxx index cca961453..1a6dd49e6 100644 --- a/src/common/PNGLibrary.hxx +++ b/src/common/PNGLibrary.hxx @@ -152,7 +152,7 @@ class PNGLibrary @param iwidth The width of the PNG image @param iheight The height of the PNG image */ - bool allocateStorage(png_uint_32 iwidth, png_uint_32 iheight); + bool allocateStorage(size_t iwidth, size_t iheight); /** The actual method which saves a PNG image. @@ -163,7 +163,7 @@ class PNGLibrary @param metaData The meta data to add to the PNG image */ void saveImageToDisk(std::ofstream& out, const vector& rows, - png_uint_32 width, png_uint_32 height, + size_t width, size_t height, const VariantList& metaData); /** diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index 162e8dd71..7fce3905f 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -389,7 +389,7 @@ PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) // Fill the odd numbered palette entries with gray values (calculated // using the standard RGB -> grayscale conversion formula) // Used for PAL color-loss data and 'greying out' the frame in the debugger. - const uInt8 lum = static_cast((r * PR) + (g * PG) + (b * PB)); + const auto lum = static_cast((r * PR) + (g * PG) + (b * PB)); destPalette[i + 1] = (lum << 16) + (lum << 8) + lum; } diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index db35c5257..c1f179259 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -33,7 +33,7 @@ namespace { } EventMode eventModeFromJsonName(const string& name) { - EventMode result; + EventMode result{}; from_json(json(name), result); @@ -120,7 +120,7 @@ json PhysicalJoystick::convertLegacyMapping(const string& mapping, const string& while (getline(buf, map, MODE_DELIM)) { - int mode; + int mode{0}; // Get event mode std::replace(map.begin(), map.end(), '|', ' '); @@ -158,7 +158,7 @@ void PhysicalJoystick::getValues(const string& list, IntArray& map) const map.clear(); istringstream buf(list); - int value; + int value{0}; buf >> value; // we don't need to know the # of items at this point while(buf >> value) map.push_back(value); diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index e6a739799..8383923db 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -146,7 +146,7 @@ bool RewindManager::addState(const string& message, bool timeMachine) uInt32 RewindManager::rewindStates(uInt32 numStates) { const uInt64 startCycles = myOSystem.console().tia().cycles(); - uInt32 i; + uInt32 i{0}; string message; for(i = 0; i < numStates; ++i) @@ -186,7 +186,7 @@ uInt32 RewindManager::rewindStates(uInt32 numStates) uInt32 RewindManager::unwindStates(uInt32 numStates) { const uInt64 startCycles = myOSystem.console().tia().cycles(); - uInt32 i; + uInt32 i{0}; string message; for(i = 0; i < numStates; ++i) @@ -256,7 +256,7 @@ string RewindManager::saveAllStates() { RewindState& state = myStateList.current(); Serializer& s = state.data; - const uInt32 stateSize = static_cast(s.size()); + const auto stateSize = static_cast(s.size()); out.putInt(stateSize); @@ -354,7 +354,7 @@ void RewindManager::compressStates() double maxError = 1.5; uInt32 idx = myStateList.size() - 2; // in case maxError is <= 1.5 remove first state by default: - Common::LinkedObjectPool::const_iter removeIter = myStateList.first(); + auto removeIter = myStateList.first(); /*if(myUncompressed < mySize) // if compression is enabled, the first but one state is removed by default: removeIter++;*/ @@ -406,35 +406,35 @@ string RewindManager::loadState(Int64 startCycles, uInt32 numStates) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string RewindManager::getUnitString(Int64 cycles) { - constexpr Int32 NTSC_FREQ = 1193182; // ~76*262*60 - constexpr Int32 PAL_FREQ = 1182298; // ~76*312*50 - const Int32 scanlines = std::max( + constexpr size_t NTSC_FREQ = 1193182; // ~76*262*60 + constexpr size_t PAL_FREQ = 1182298; // ~76*312*50 + const size_t scanlines = std::max( myOSystem.console().tia().scanlinesLastFrame(), 240); const bool isNTSC = scanlines <= 287; - const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second + const size_t freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second - constexpr Int32 NUM_UNITS = 5; + constexpr size_t NUM_UNITS = 5; const std::array UNIT_NAMES = { "cycle", "scanline", "frame", "second", "minute" }; - const std::array UNIT_CYCLES = { + const std::array UNIT_CYCLES = { 1, 76, 76 * scanlines, freq, freq * 60, Int64{1} << 62 }; stringstream result; - Int32 i = 0; + size_t i = 0; - cycles = std::abs(cycles); + const uInt64 u_cycles = std::abs(cycles); for(i = 0; i < NUM_UNITS - 1; ++i) { // use the lower unit up to twice the nextCycles unit, except for an exact match of the nextCycles unit // TODO: does the latter make sense, e.g. for ROMs with changing scanlines? - if(cycles == 0 || (cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0)) + if(u_cycles == 0 || (u_cycles < UNIT_CYCLES[i + 1] * 2 && u_cycles % UNIT_CYCLES[i + 1] != 0)) break; } - result << (cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i]; - if(cycles / UNIT_CYCLES[i] != 1) + result << (u_cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i]; + if(u_cycles / UNIT_CYCLES[i] != 1) result << "s"; return result.str(); @@ -467,6 +467,7 @@ IntArray RewindManager::cyclesList() const IntArray arr; const uInt64 firstCycle = getFirstCycles(); + // NOLINTNEXTLINE (TODO: convert myStateList to use range-for) for(auto it = myStateList.cbegin(); it != myStateList.cend(); ++it) arr.push_back(uInt32(it->cycles - firstCycle)); diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 4213b121a..6b6e6250f 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -56,7 +56,7 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings) return; } - queryHardware(myDevices); + queryHardware(myDevices); // NOLINT SDL_zero(myHardwareSpec); if(!openDevice()) @@ -387,7 +387,7 @@ void SoundSDL2::initResampler() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SoundSDL2::callback(void* udata, uInt8* stream, int len) { - SoundSDL2* self = static_cast(udata); + auto* self = static_cast(udata); if (self->myAudioQueue) self->processFragment(reinterpret_cast(stream), len >> 2); diff --git a/src/common/StaggeredLogger.cxx b/src/common/StaggeredLogger.cxx index c7fb63c0b..f9243feae 100644 --- a/src/common/StaggeredLogger.cxx +++ b/src/common/StaggeredLogger.cxx @@ -29,7 +29,7 @@ namespace { std::array formattedTime; formattedTime.fill(0); - std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now); + std::ignore = std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now); return formattedTime.data(); } diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index 03cf74514..48a873fbb 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -38,7 +38,7 @@ StateManager::StateManager(OSystem& osystem) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -StateManager::~StateManager() +StateManager::~StateManager() // NOLINT (we need an empty d'tor) { } diff --git a/src/common/TimerManager.cxx b/src/common/TimerManager.cxx index 9836ff38e..1cf19c9e0 100644 --- a/src/common/TimerManager.cxx +++ b/src/common/TimerManager.cxx @@ -66,7 +66,7 @@ TimerManager::TimerId TimerManager::addTimer( Duration(msPeriod), func)); // Insert a reference to the Timer into ordering queue - const Queue::iterator place = queue.emplace(iter.first->second); + const auto place = queue.emplace(iter.first->second); // We need to notify the timer thread only if we inserted // this timer into the front of the timer queue @@ -204,7 +204,7 @@ bool TimerManager::destroy_impl(ScopedLock& lock, TimerMap::iterator i, timer.running = false; // Assign a condition variable to this timer - timer.waitCond.reset(new ConditionVar); + timer.waitCond = std::make_unique(); // Block until the callback is finished if (std::this_thread::get_id() != worker.get_id()) diff --git a/src/common/ZipHandler.cxx b/src/common/ZipHandler.cxx index 6105e710f..461b0f396 100644 --- a/src/common/ZipHandler.cxx +++ b/src/common/ZipHandler.cxx @@ -156,18 +156,18 @@ string ZipHandler::errorMessage(ZipError err) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ZipHandler::ZipFilePtr ZipHandler::findCached(const string& filename) { - for(size_t cachenum = 0; cachenum < myZipCache.size(); ++cachenum) + for(auto& cache: myZipCache) { // If we have a valid entry and it matches our filename, // use it and remove from the cache - if(myZipCache[cachenum] && (filename == myZipCache[cachenum]->myFilename)) + if(cache && (filename == cache->myFilename)) { ZipFilePtr result; - std::swap(myZipCache[cachenum], result); + std::swap(cache, result); return result; } } - return ZipFilePtr(); + return {}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -180,7 +180,7 @@ void ZipHandler::addToCache() myZip->close(); // Find the first nullptr entry in the cache - size_t cachenum; + size_t cachenum{0}; for(cachenum = 0; cachenum < myZipCache.size(); ++cachenum) if(myZipCache[cachenum] == nullptr) break; diff --git a/src/common/audio/LanczosResampler.cxx b/src/common/audio/LanczosResampler.cxx index 02c73a62f..bc83256df 100644 --- a/src/common/audio/LanczosResampler.cxx +++ b/src/common/audio/LanczosResampler.cxx @@ -76,7 +76,8 @@ LanczosResampler::LanczosResampler( myHighPassR{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)}, myHighPass{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)} { - myPrecomputedKernels = make_unique(myPrecomputedKernelCount * myKernelSize); + myPrecomputedKernels = make_unique( + static_cast(myPrecomputedKernelCount) * myKernelSize); if (myFormatFrom.stereo) { @@ -96,7 +97,8 @@ void LanczosResampler::precomputeKernels() uInt32 timeIndex = 0; for (uInt32 i = 0; i < myPrecomputedKernelCount; ++i) { - float* kernel = myPrecomputedKernels.get() + myKernelSize * i; + float* kernel = myPrecomputedKernels.get() + + static_cast(myKernelSize) * i; // The kernel is normalized such to be evaluate on time * formatFrom.sampleRate const float center = static_cast(timeIndex) / static_cast(myFormatTo.sampleRate); @@ -140,10 +142,11 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length) return; } - const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length; + const size_t outputSamples = myFormatTo.stereo ? (length >> 1) : length; - for (uInt32 i = 0; i < outputSamples; ++i) { - const float* kernel = myPrecomputedKernels.get() + (myCurrentKernelIndex * myKernelSize); + for (size_t i = 0; i < outputSamples; ++i) { + const float* kernel = myPrecomputedKernels.get() + + static_cast(myCurrentKernelIndex) * myKernelSize; myCurrentKernelIndex = (myCurrentKernelIndex + 1) % myPrecomputedKernelCount; if (myFormatFrom.stereo) { @@ -180,11 +183,16 @@ inline void LanczosResampler::shiftSamples(uInt32 samplesToShift) { while (samplesToShift-- > 0) { if (myFormatFrom.stereo) { - myBufferL->shift(myHighPassL.apply(myCurrentFragment[2*myFragmentIndex] / static_cast(0x7fff))); - myBufferR->shift(myHighPassR.apply(myCurrentFragment[2*myFragmentIndex + 1] / static_cast(0x7fff))); + myBufferL->shift(myHighPassL.apply( + myCurrentFragment[2 * static_cast(myFragmentIndex)] / + static_cast(0x7fff))); + myBufferR->shift(myHighPassR.apply( + myCurrentFragment[2 * static_cast(myFragmentIndex) + 1] / + static_cast(0x7fff))); } else - myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] / static_cast(0x7fff))); + myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] / + static_cast(0x7fff))); ++myFragmentIndex; diff --git a/src/common/audio/SimpleResampler.cxx b/src/common/audio/SimpleResampler.cxx index 476e71589..c0429ee8f 100644 --- a/src/common/audio/SimpleResampler.cxx +++ b/src/common/audio/SimpleResampler.cxx @@ -44,13 +44,17 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length) return; } - const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length; + const size_t outputSamples = myFormatTo.stereo ? (length >> 1) : length; // For the following math, remember that myTimeIndex = time * myFormatFrom.sampleRate * myFormatTo.sampleRate - for (uInt32 i = 0; i < outputSamples; ++i) { + for (size_t i = 0; i < outputSamples; ++i) { if (myFormatFrom.stereo) { - const float sampleL = static_cast(myCurrentFragment[2*myFragmentIndex]) / static_cast(0x7fff); - const float sampleR = static_cast(myCurrentFragment[2*myFragmentIndex + 1]) / static_cast(0x7fff); + const float sampleL = static_cast( + myCurrentFragment[2*static_cast(myFragmentIndex)]) / + static_cast(0x7fff); + const float sampleR = static_cast( + myCurrentFragment[2*static_cast(myFragmentIndex) + 1]) / + static_cast(0x7fff); if (myFormatTo.stereo) { fragment[2*i] = sampleL; @@ -59,7 +63,8 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length) else fragment[i] = (sampleL + sampleR) / 2.F; } else { - const float sample = static_cast(myCurrentFragment[myFragmentIndex] / static_cast(0x7fff)); + const auto sample = static_cast(myCurrentFragment[myFragmentIndex] / + static_cast(0x7fff)); if (myFormatTo.stereo) fragment[2*i] = fragment[2*i + 1] = sample; diff --git a/src/common/repository/CompositeKVRJsonAdapter.cxx b/src/common/repository/CompositeKVRJsonAdapter.cxx index 9eefe5066..896557dfb 100644 --- a/src/common/repository/CompositeKVRJsonAdapter.cxx +++ b/src/common/repository/CompositeKVRJsonAdapter.cxx @@ -28,7 +28,7 @@ namespace { {} std::map load() override { - if (!myKvr.has(myKey)) return std::map(); + if (!myKvr.has(myKey)) return {}; Variant serialized; myKvr.get(myKey, serialized); diff --git a/src/common/repository/CompositeKeyValueRepository.cxx b/src/common/repository/CompositeKeyValueRepository.cxx index 31eaf3afd..dd63b5360 100644 --- a/src/common/repository/CompositeKeyValueRepository.cxx +++ b/src/common/repository/CompositeKeyValueRepository.cxx @@ -17,7 +17,6 @@ #include "repository/CompositeKeyValueRepository.hxx" - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& key2, Variant& value) { @@ -28,8 +27,7 @@ bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& ke shared_ptr CompositeKeyValueRepositoryAtomic::getAtomic(const string& key) { auto repo = get(key); - - return shared_ptr(repo, repo->atomic()); + return {repo, repo->atomic()}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/repository/KeyValueRepositoryJsonFile.cxx b/src/common/repository/KeyValueRepositoryJsonFile.cxx index 25ef6772c..d047d0f78 100644 --- a/src/common/repository/KeyValueRepositoryJsonFile.cxx +++ b/src/common/repository/KeyValueRepositoryJsonFile.cxx @@ -55,14 +55,16 @@ std::map KeyValueRepositoryJsonFile::load(istream& in) return map; } catch (const json::exception& err) { - Logger::error("KeyValueRepositoryJsonFile: error during deserialization: " + string(err.what())); + Logger::error("KeyValueRepositoryJsonFile: error during deserialization: " + + string(err.what())); - return std::map(); + return {}; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool KeyValueRepositoryJsonFile::save(ostream& out, const std::map& values) +bool KeyValueRepositoryJsonFile::save(ostream& out, + const std::map& values) { try { json serializedJson = json::object(); @@ -75,7 +77,8 @@ bool KeyValueRepositoryJsonFile::save(ostream& out, const std::map KeyValueRepositoryPropertyFile::load(istream& in) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool KeyValueRepositoryPropertyFile::save(ostream& out, const std::map& values) +bool KeyValueRepositoryPropertyFile::save(ostream& out, + const std::map& values) { for (auto& [key, value]: values) { writeQuotedString(out, key); diff --git a/src/common/repository/sqlite/SqliteDatabase.cxx b/src/common/repository/sqlite/SqliteDatabase.cxx index b761a5325..3b86b8976 100644 --- a/src/common/repository/sqlite/SqliteDatabase.cxx +++ b/src/common/repository/sqlite/SqliteDatabase.cxx @@ -51,7 +51,7 @@ void SqliteDatabase::initialize() if (!dbInitialized && tries == 1) { Logger::info("sqlite DB " + myDatabaseFile + " seems to be corrupt, removing and retrying..."); - remove(myDatabaseFile.c_str()); + std::ignore = remove(myDatabaseFile.c_str()); if (myHandle) sqlite3_close_v2(myHandle); } } diff --git a/src/common/repository/sqlite/SqliteStatement.cxx b/src/common/repository/sqlite/SqliteStatement.cxx index fb473571a..30aa630ac 100644 --- a/src/common/repository/sqlite/SqliteStatement.cxx +++ b/src/common/repository/sqlite/SqliteStatement.cxx @@ -44,7 +44,8 @@ SqliteStatement::~SqliteStatement() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SqliteStatement& SqliteStatement::bind(int index, const string& value) { - if (sqlite3_bind_text(myStmt, index, value.c_str(), -1, SQLITE_TRANSIENT) != SQLITE_OK) + if (sqlite3_bind_text(myStmt, index, value.c_str(), -1, + SQLITE_TRANSIENT) != SQLITE_OK) // NOLINT (performance-no-int-to-ptr) throw SqliteError(myHandle); return *this; diff --git a/src/common/repository/sqlite/StellaDb.cxx b/src/common/repository/sqlite/StellaDb.cxx index c9bf2f072..6d3b83b8e 100644 --- a/src/common/repository/sqlite/StellaDb.cxx +++ b/src/common/repository/sqlite/StellaDb.cxx @@ -201,7 +201,7 @@ void StellaDb::importOldPropset(const FSNode& node) void StellaDb::migrate() { const Int32 version = myDb->getUserVersion(); - switch (version) { + switch (version) { // NOLINT (could be written as IF/ELSE) case 1: return; diff --git a/src/common/sdl_blitter/BilinearBlitter.cxx b/src/common/sdl_blitter/BilinearBlitter.cxx index 4434e8b81..da1cea870 100644 --- a/src/common/sdl_blitter/BilinearBlitter.cxx +++ b/src/common/sdl_blitter/BilinearBlitter.cxx @@ -126,7 +126,7 @@ void BilinearBlitter::recreateTexturesIfNecessary() } if (myAttributes.blending) { - const uInt8 blendAlpha = static_cast(myAttributes.blendalpha * 2.55); + const auto blendAlpha = static_cast(myAttributes.blendalpha * 2.55); std::array textures = { myTexture, mySecondaryTexture }; for (SDL_Texture* texture: textures) { diff --git a/src/common/sdl_blitter/QisBlitter.cxx b/src/common/sdl_blitter/QisBlitter.cxx index 7a1dbd635..431ba0707 100644 --- a/src/common/sdl_blitter/QisBlitter.cxx +++ b/src/common/sdl_blitter/QisBlitter.cxx @@ -181,7 +181,7 @@ void QisBlitter::recreateTexturesIfNecessary() } if (myAttributes.blending) { - const uInt8 blendAlpha = static_cast(myAttributes.blendalpha * 2.55); + const auto blendAlpha = static_cast(myAttributes.blendalpha * 2.55); std::array textures = { mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture diff --git a/src/common/tv_filters/AtariNTSC.cxx b/src/common/tv_filters/AtariNTSC.cxx index e2d203485..6990f95af 100644 --- a/src/common/tv_filters/AtariNTSC.cxx +++ b/src/common/tv_filters/AtariNTSC.cxx @@ -42,11 +42,11 @@ void AtariNTSC::initialize(const Setup& setup) void AtariNTSC::setPalette(const PaletteArray& palette) { uInt8* ptr = myRGBPalette.data(); - for(size_t i = 0; i < palette.size(); ++i) + for(auto p: palette) { - *ptr++ = (palette[i] >> 16) & 0xff; - *ptr++ = (palette[i] >> 8) & 0xff; - *ptr++ = palette[i] & 0xff; + *ptr++ = (p >> 16) & 0xff; + *ptr++ = (p >> 8) & 0xff; + *ptr++ = p & 0xff; } generateKernels(); } @@ -60,10 +60,10 @@ void AtariNTSC::generateKernels() const float r = (*ptr++) / 255.F * rgb_unit + rgb_offset, g = (*ptr++) / 255.F * rgb_unit + rgb_offset, b = (*ptr++) / 255.F * rgb_unit + rgb_offset; - float y, i, q; RGB_TO_YIQ( r, g, b, y, i, q ); + float y, i, q; RGB_TO_YIQ( r, g, b, y, i, q ); // NOLINT // Generate kernel - int ir, ig, ib; YIQ_TO_RGB( y, i, q, myImpl.to_rgb.data(), ir, ig, ib ); + int ir, ig, ib; YIQ_TO_RGB( y, i, q, myImpl.to_rgb.data(), ir, ig, ib ); //NOLINT const uInt32 rgb = PACK_RGB( ir, ig, ib ); uInt32* kernel = myColorTable[entry].data(); @@ -123,7 +123,7 @@ void AtariNTSC::render(const uInt8* atari_in, const uInt32 in_width, // Copy phosphor values into out buffer if(rgb_in != nullptr) - memcpy(rgb_out, rgb_in, in_height * out_pitch); + memcpy(rgb_out, rgb_in, static_cast(in_height) * out_pitch); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -134,8 +134,8 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width, // Adapt parameters to thread number const uInt32 yStart = in_height * threadNum / numThreads; const uInt32 yEnd = in_height * (threadNum + 1) / numThreads; - atari_in += in_width * yStart; - rgb_out = static_cast(rgb_out) + out_pitch * yStart; + atari_in += static_cast(in_width) * yStart; + rgb_out = static_cast(rgb_out) + static_cast(out_pitch) * yStart; uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk; @@ -143,7 +143,7 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width, { const uInt8* line_in = atari_in; ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]); - uInt32* restrict line_out = static_cast(rgb_out); + auto* restrict line_out = static_cast(rgb_out); ++line_in; // shift right by 2 pixel @@ -210,8 +210,8 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_ const uInt32 yEnd = in_height * (threadNum + 1) / numThreads; uInt32 bufofs = AtariNTSC::outWidth(in_width) * yStart; const uInt32* out = static_cast(rgb_out); - atari_in += in_width * yStart; - rgb_out = static_cast(rgb_out) + out_pitch * yStart; + atari_in += static_cast(in_width) * yStart; + rgb_out = static_cast(rgb_out) + static_cast(out_pitch) * yStart; uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk; @@ -219,7 +219,7 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_ { const uInt8* line_in = atari_in; ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]); - uInt32* restrict line_out = static_cast(rgb_out); + auto* restrict line_out = static_cast(rgb_out); ++line_in; // shift right by 2 pixel @@ -335,9 +335,8 @@ void AtariNTSC::init(init_t& impl, const Setup& setup) /* setup decoder matricies */ { float* out = impl.to_rgb.data(); - int n; - n = burst_count; + int n = burst_count; do { float const* in = default_decoder.data(); @@ -355,14 +354,14 @@ void AtariNTSC::init(init_t& impl, const Setup& setup) ROTATE_IQ( s, c, 0.866025F, -0.5F ); /* +120 degrees */ #endif } - while ( --n ); + while (--n); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AtariNTSC::initFilters(init_t& impl, const Setup& setup) { - std::array kernels{0}; + std::array(kernel_size) * 2> kernels{0}; /* generate luma (y) filter using sinc kernel */ { @@ -433,12 +432,11 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup) for ( int i = 0; i < 2; i++ ) { float sum = 0; - int x; - for ( x = i; x < kernel_size; x += 2 ) + for ( int x = i; x < kernel_size; x += 2 ) sum += kernels [x]; sum = 1.0F / sum; - for ( x = i; x < kernel_size; x += 2 ) + for ( int x = i; x < kernel_size; x += 2 ) { kernels [x] *= sum; } @@ -506,12 +504,13 @@ void AtariNTSC::genKernel(init_t& impl, float y, float i, float q, uInt32* out) const float fq = k[1]*qc1 + k[3]*qc3; const float fy = k[kernel_size+0]*yc0 + k[kernel_size+1]*yc1 + k[kernel_size+2]*yc2 + k[kernel_size+3]*yc3 + rgb_offset; - if ( k < &impl.kernel [kernel_size * 2 * (rescale_out - 1)] ) + if ( k < &impl.kernel [static_cast(kernel_size) * 2 * + (rescale_out - 1)] ) k += kernel_size * 2 - 1; else k -= kernel_size * 2 * (rescale_out - 1) + 2; { - int r, g, b; YIQ_TO_RGB( fy, fi, fq, to_rgb, r, g, b ); + int r, g, b; YIQ_TO_RGB( fy, fi, fq, to_rgb, r, g, b ); // NOLINT *out++ = PACK_RGB( r, g, b ) - rgb_bias; } } diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 1b9862ca8..47bec83e0 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -140,8 +140,8 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem) const DebuggerState& CartDebug::getState() { myState.ram.clear(); - for(uInt32 i = 0; i < myState.rport.size(); ++i) - myState.ram.push_back(myDebugger.peek(myState.rport[i])); + for(auto addr: myState.rport) + myState.ram.push_back(myDebugger.peek(addr)); if(myDebugWidget) myState.bank = myDebugWidget->bankState(); @@ -153,8 +153,8 @@ const DebuggerState& CartDebug::getState() void CartDebug::saveOldState() { myOldState.ram.clear(); - for(uInt32 i = 0; i < myOldState.rport.size(); ++i) - myOldState.ram.push_back(myDebugger.peek(myOldState.rport[i])); + for(auto addr: myOldState.rport) + myOldState.ram.push_back(myDebugger.peek(addr)); if(myDebugWidget) { @@ -209,8 +209,8 @@ string CartDebug::toString() return DebuggerParser::red("invalid base, this is a BUG"); } - const CartState& state = static_cast(getState()); - const CartState& oldstate = static_cast(getOldState()); + const auto& state = static_cast(getState()); + const auto& oldstate = static_cast(getOldState()); uInt32 curraddr = 0, bytesSoFar = 0; for(uInt32 i = 0; i < state.ram.size(); i += bytesPerLine, bytesSoFar += bytesPerLine) @@ -221,7 +221,7 @@ string CartDebug::toString() if(state.rport[i] - curraddr > bytesPerLine || bytesSoFar >= 256) { char port[37]; // NOLINT (convert to stringstream) - std::snprintf(port, 36, "%04x: (rport = %04x, wport = %04x)\n", + std::ignore = std::snprintf(port, 36, "%04x: (rport = %04x, wport = %04x)\n", state.rport[i], state.rport[i], state.wport[i]); port[2] = port[3] = 'x'; buf << DebuggerParser::red(port); @@ -260,14 +260,10 @@ bool CartDebug::disassembleAddr(uInt16 address, bool force) const int bank = cart.getSegmentBank(seg); Disassembly disassembly; AddrToLineList addrToLineList; - uInt16 segAddress; BankInfo& info = myBankInfo[bank]; info.offset = cart.bankOrigin(bank) | cart.bankSize() * seg; - if(bank == addrBank) - segAddress = address; - else - segAddress = info.offset; + const uInt16 segAddress = bank == addrBank ? address : info.offset; // Disassemble segment const bool newChanged = disassemble(bank, segAddress, disassembly, addrToLineList, force); @@ -388,7 +384,7 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, Disassembly& disassembly, disassembly.fieldwidth = 24 + myLabelLength; // line offset must be set before calling DiStella! - uInt32 lineOfs = static_cast(myDisassembly.list.size()); + auto lineOfs = static_cast(myDisassembly.list.size()); DiStella distella(*this, disassembly.list, info, DiStella::settings, myDisLabels, myDisDirectives, myReserved); @@ -569,7 +565,7 @@ bool CartDebug::addDirective(Device::AccessType type, // Can we also merge with the previous range (if any)? if(i != list.begin()) { - DirectiveList::iterator p = i; + auto p = i; --p; if(p->type == tag.type && p->end + 1 == tag.start) { @@ -1164,9 +1160,9 @@ string CartDebug::saveDisassembly(string path) origin += static_cast(info.size); // Format in 'distella' style - for(uInt32 i = 0; i < disasm.list.size(); ++i) + for(const auto& dt: disasm.list) { - const DisassemblyTag& tag = disasm.list[i]; + const DisassemblyTag& tag = dt; // Add label (if any) if(tag.label != "") diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 41a2a910d..3782fc1b1 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -236,7 +236,7 @@ int DebuggerParser::decipher_arg(const string& str) } // Special cases (registers): - const CpuState& state = static_cast(debugger.cpuDebug().getState()); + const auto& state = static_cast(debugger.cpuDebug().getState()); int result = 0; if(arg == "a" && str != "$a") result = state.A; else if(arg == "x") result = state.X; @@ -488,7 +488,9 @@ bool DebuggerParser::validateArgs(int cmd) if(curArgInt != 2 && curArgInt != 10 && curArgInt != 16 && curArgStr != "hex" && curArgStr != "dec" && curArgStr != "bin") { - commandResult.str(red("invalid base (must be #2, #10, #16, \"bin\", \"dec\", or \"hex\")")); + commandResult.str(red( + R"(invalid base (must be #2, #10, #16, "bin", "dec", or "hex"))" + )); return false; } break; @@ -1640,8 +1642,8 @@ void DebuggerParser::executeListTraps() if (names.size() > 0) { bool trapFound = false, trapifFound = false; - for(uInt32 i = 0; i < names.size(); ++i) - if(names[i] == "") + for(const auto& name: names) + if(name == "") trapFound = true; else trapifFound = true; diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index 5146b802a..805c50451 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -123,7 +123,7 @@ void DiStella::disasm(uInt32 distart, int pass) // and this results into an access at e.g. 0xffff, // we have to fix the consequences here (ugly!). if(myPC == myAppData.end) - goto FIX_LAST; + goto FIX_LAST; // NOLINT if(checkBits(myPC, Device::GFX | Device::PGFX, Device::CODE)) @@ -1038,7 +1038,7 @@ void DiStella::addEntry(Device::AccessType type) // Only include addresses within the requested range if (tag.address < myAppData.start) - goto DONE_WITH_ADD; + goto DONE_WITH_ADD; // NOLINT // Label (a user-defined label always overrides any auto-generated one) myDisasmBuf.seekg(5, std::ios::beg); diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index c8087d6f8..2190f8aa2 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -363,8 +363,8 @@ string RiotDebug::switchesString() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string RiotDebug::toString() { - const RiotState& state = static_cast(getState()); - const RiotState& oldstate = static_cast(getOldState()); + const auto& state = static_cast(getState()); + const auto& oldstate = static_cast(getOldState()); ostringstream buf; buf << "280/SWCHA(R)=" << myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R) diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 15a979fff..0d8e3aa38 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -1037,7 +1037,7 @@ string TIADebug::audFreq(uInt8 dist, uInt8 div) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::stringOnly(string value, bool changed) +string TIADebug::stringOnly(const string& value, bool changed) { ostringstream buf; @@ -1051,7 +1051,8 @@ string TIADebug::stringOnly(string value, bool changed) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 width) +string TIADebug::decWithLabel(const string& label, uInt16 value, + bool changed, uInt16 width) { ostringstream buf; @@ -1068,7 +1069,8 @@ string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 w } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 width) +string TIADebug::hexWithLabel(const string& label, uInt16 value, + bool changed, uInt16 width) { ostringstream buf; @@ -1085,7 +1087,7 @@ string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 w } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::binWithLabel(string label, uInt16 value, bool changed) +string TIADebug::binWithLabel(const string& label, uInt16 value, bool changed) { ostringstream buf; @@ -1102,13 +1104,16 @@ string TIADebug::binWithLabel(string label, uInt16 value, bool changed) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::boolWithLabel(string label, bool value, bool changed) +string TIADebug::boolWithLabel(const string& label, bool value, bool changed) { ostringstream buf; if(value) - buf << "\177" << BSPF::toUpperCase(label) << "\177"; + { + string l = label; + buf << "\177" << BSPF::toUpperCase(l) << "\177"; //return "+" + BSPF::toUpperCase(label); + } else buf << label; //return "-" + BSPF::toLowerCase(label); @@ -1174,11 +1179,11 @@ string TIADebug::toString() // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR RiotDebug& riot = myDebugger.riotDebug(); - const RiotState& riotState = static_cast(riot.getState()); - const RiotState& oldRiotState = static_cast(riot.getOldState()); + const auto& riotState = static_cast(riot.getState()); + const auto& oldRiotState = static_cast(riot.getOldState()); - const TiaState& state = static_cast(getState()); - const TiaState& oldState = static_cast(getOldState()); + const auto& state = static_cast(getState()); + const auto& oldState = static_cast(getOldState()); // build up output, then return it. buf << std::setfill(' ') << std::left diff --git a/src/debugger/TIADebug.hxx b/src/debugger/TIADebug.hxx index 8e9aa3b4b..209c9b079 100644 --- a/src/debugger/TIADebug.hxx +++ b/src/debugger/TIADebug.hxx @@ -188,11 +188,11 @@ class TIADebug : public DebuggerSystem string colorSwatch(uInt8 c) const; string audFreq(uInt8 dist, uInt8 div); - string stringOnly(string value, bool changed = false); - string decWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 3); - string hexWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 2); - string binWithLabel(string label, uInt16 value, bool changed = false); - string boolWithLabel(string label, bool value, bool changed = false); + string stringOnly(const string& value, bool changed = false); + string decWithLabel(const string& label, uInt16 value, bool changed = false, uInt16 width = 3); + string hexWithLabel(const string& label, uInt16 value, bool changed = false, uInt16 width = 2); + string binWithLabel(const string& label, uInt16 value, bool changed = false); + string boolWithLabel(const string& label, bool value, bool changed = false); private: TiaState myState; diff --git a/src/debugger/gui/AtariVoxWidget.cxx b/src/debugger/gui/AtariVoxWidget.cxx index 72ee03692..7a9f60416 100644 --- a/src/debugger/gui/AtariVoxWidget.cxx +++ b/src/debugger/gui/AtariVoxWidget.cxx @@ -30,15 +30,13 @@ AtariVoxWidget::AtariVoxWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AtariVoxWidget::eraseCurrent() { - AtariVox& avox = static_cast(controller()); - + auto& avox = static_cast(controller()); avox.eraseCurrent(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool AtariVoxWidget::isPageUsed(uInt32 page) { - const AtariVox& avox = static_cast(controller()); - + const auto& avox = static_cast(controller()); return avox.isPageUsed(page); } diff --git a/src/debugger/gui/AudioWidget.cxx b/src/debugger/gui/AudioWidget.cxx index 2e305d9ca..e829dee10 100644 --- a/src/debugger/gui/AudioWidget.cxx +++ b/src/debugger/gui/AudioWidget.cxx @@ -23,7 +23,6 @@ #include "TIADebug.hxx" #include "Widget.hxx" #include "Base.hxx" -using Common::Base; #include "AudioWidget.hxx" @@ -102,8 +101,8 @@ void AudioWidget::loadConfig() const Debugger& dbg = instance().debugger(); TIADebug& tia = dbg.tiaDebug(); - const TiaState& state = static_cast(tia.getState()); - const TiaState& oldstate = static_cast(tia.getOldState()); + const auto& state = static_cast(tia.getState()); + const auto& oldstate = static_cast(tia.getOldState()); // AUDF0/1 alist.clear(); vlist.clear(); changed.clear(); diff --git a/src/debugger/gui/BoosterWidget.cxx b/src/debugger/gui/BoosterWidget.cxx index 1dbc8a139..a010492ed 100644 --- a/src/debugger/gui/BoosterWidget.cxx +++ b/src/debugger/gui/BoosterWidget.cxx @@ -26,10 +26,8 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font, const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster)"); - StaticTextWidget* t; - - t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, - fontHeight, label, TextAlign::Left); + auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, + fontHeight, label, TextAlign::Left); xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10; myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", CheckboxWidget::kCheckActionCmd); diff --git a/src/debugger/gui/Cart3EPlusWidget.cxx b/src/debugger/gui/Cart3EPlusWidget.cxx index ca06fdb6f..e9f2e1581 100644 --- a/src/debugger/gui/Cart3EPlusWidget.cxx +++ b/src/debugger/gui/Cart3EPlusWidget.cxx @@ -34,7 +34,7 @@ Cartridge3EPlusWidget::Cartridge3EPlusWidget( string Cartridge3EPlusWidget::description() { ostringstream info; - size_t size; + size_t size{0}; const ByteBuffer& image = myCart.getImage(size); const uInt16 numRomBanks = myCart.romBankCount(); const uInt16 numRamBanks = myCart.ramBankCount(); @@ -59,7 +59,7 @@ string Cartridge3EPlusWidget::description() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge3EPlusWidget::bankSelect(int& ypos) { - size_t size; + size_t size{0}; const ByteBuffer& image = myCart.getImage(size); const int VGAP = myFontHeight / 4; VariantList banktype; @@ -118,22 +118,24 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos) const int addr1 = start + (seg * 0x400), addr2 = addr1 + 0x200; label.str(""); - label << "$" << Common::Base::HEX4 << addr1 << "-$" << Common::Base::HEX4 << (addr1 + 0x1FF); - StaticTextWidget* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); + label << "$" << Common::Base::HEX4 << addr1 << "-$" + << Common::Base::HEX4 << (addr1 + 0x1FF); + auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); const int xoffset = t->getRight() + _font.getMaxCharWidth(); - myBankState[2 * seg] = new EditTextWidget(_boss, _font, xoffset, ypos_s, - _w - xoffset - 10, myLineHeight, ""); - myBankState[2 * seg]->setEditable(false, true); + const size_t bank_off = static_cast(seg) * 2; + myBankState[bank_off] = new EditTextWidget(_boss, _font, xoffset, ypos_s, + _w - xoffset - 10, myLineHeight, ""); + myBankState[bank_off]->setEditable(false, true); ypos_s += myLineHeight + VGAP; label.str(""); label << "$" << Common::Base::HEX4 << addr2 << "-$" << Common::Base::HEX4 << (addr2 + 0x1FF); new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); - myBankState[2 * seg + 1] = new EditTextWidget(_boss, _font, xoffset, ypos_s, - _w - xoffset - 10, myLineHeight, ""); - myBankState[2 * seg + 1]->setEditable(false, true); + myBankState[bank_off + 1] = new EditTextWidget(_boss, _font, + xoffset, ypos_s, _w - xoffset - 10, myLineHeight, ""); + myBankState[bank_off + 1]->setEditable(false, true); ypos += myLineHeight + VGAP * 4; } @@ -198,6 +200,7 @@ void Cartridge3EPlusWidget::updateUIState() for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg) { const uInt16 bank = myCart.getSegmentBank(seg); + const size_t bank_off = static_cast(seg) * 2; ostringstream buf; if(bank >= myCart.romBankCount()) // was RAM mapped here? @@ -205,13 +208,13 @@ void Cartridge3EPlusWidget::updateUIState() const uInt16 ramBank = bank - myCart.romBankCount(); buf << "RAM @ $" << Common::Base::HEX4 - << (ramBank << myCart3EP.myBankShift) << " (R)"; - myBankState[seg * 2]->setText(buf.str()); + << (ramBank << myCart3EP.myBankShift) << " (R)"; + myBankState[bank_off]->setText(buf.str()); buf.str(""); buf << "RAM @ $" << Common::Base::HEX4 << ((ramBank << myCart3EP.myBankShift) + myCart3EP.myBankSize) << " (W)"; - myBankState[seg * 2 + 1]->setText(buf.str()); + myBankState[bank_off + 1]->setText(buf.str()); myBankWidgets[seg]->setSelectedIndex(ramBank); myBankType[seg]->setSelected("RAM"); @@ -220,12 +223,12 @@ void Cartridge3EPlusWidget::updateUIState() { buf << "ROM @ $" << Common::Base::HEX4 << ((bank << myCart3EP.myBankShift)); - myBankState[seg * 2]->setText(buf.str()); + myBankState[bank_off]->setText(buf.str()); buf.str(""); buf << "ROM @ $" << Common::Base::HEX4 << ((bank << myCart3EP.myBankShift) + myCart3EP.myBankSize); - myBankState[seg * 2 + 1]->setText(buf.str()); + myBankState[bank_off + 1]->setText(buf.str()); myBankWidgets[seg]->setSelectedIndex(bank); myBankType[seg]->setSelected("ROM"); diff --git a/src/debugger/gui/Cart3EWidget.cxx b/src/debugger/gui/Cart3EWidget.cxx index 8d4fa8b3c..1098d656f 100644 --- a/src/debugger/gui/Cart3EWidget.cxx +++ b/src/debugger/gui/Cart3EWidget.cxx @@ -32,7 +32,7 @@ Cartridge3EWidget::Cartridge3EWidget( string Cartridge3EWidget::description() { ostringstream info; - size_t size; + size_t size{0}; const ByteBuffer& image = myCart.getImage(size); const uInt16 numRomBanks = myCart.romBankCount(); const uInt16 numRamBanks = myCart.ramBankCount(); @@ -69,9 +69,9 @@ void Cartridge3EWidget::bankList(uInt16 bankCount, int seg, VariantList& items, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge3EWidget::bankSelect(int& ypos) { - int xpos = 2; + int xpos{2}; VariantList items; - int pw; + int pw{0}; myBankWidgets = make_unique(2); @@ -84,7 +84,8 @@ void Cartridge3EWidget::bankSelect(int& ypos) myBankWidgets[0]->setID(0); addFocusWidget(myBankWidgets[0]); - StaticTextWidget* t = new StaticTextWidget(_boss, _font, myBankWidgets[0]->getRight(), ypos - 1, " (ROM)"); + auto* t = new StaticTextWidget(_boss, _font, + myBankWidgets[0]->getRight(), ypos - 1, " (ROM)"); xpos = t->getRight() + 20; items.clear(); diff --git a/src/debugger/gui/CartARMWidget.cxx b/src/debugger/gui/CartARMWidget.cxx index fbcacd7bd..0a43dd488 100644 --- a/src/debugger/gui/CartARMWidget.cxx +++ b/src/debugger/gui/CartARMWidget.cxx @@ -68,8 +68,8 @@ void CartridgeARMWidget::addCycleWidgets(int xpos, int ypos) myThumbCycles->setEditable(false); myThumbCycles->setToolTip("Approximated CPU cycles of last ARM run.\n"); - StaticTextWidget* s = new StaticTextWidget(_boss, _font, myCycleFactor->getLeft(), ypos + 1, - "Instructions #"); + auto* s = new StaticTextWidget(_boss, _font, myCycleFactor->getLeft(), ypos + 1, + "Instructions #"); myPrevThumbInstructions = new DataGridWidget(_boss, _font, s->getRight(), ypos - 1, 1, 1, 6, 32, Common::Base::Fmt::_10_6); diff --git a/src/debugger/gui/CartARWidget.cxx b/src/debugger/gui/CartARWidget.cxx index 28272c0bf..f29ea71f7 100644 --- a/src/debugger/gui/CartARWidget.cxx +++ b/src/debugger/gui/CartARWidget.cxx @@ -83,8 +83,8 @@ CartridgeARWidget::CartridgeARWidget( void CartridgeARWidget::loadConfig() { CartDebug& cart = instance().debugger().cartDebug(); - const CartState& state = static_cast(cart.getState()); - const CartState& oldstate = static_cast(cart.getOldState()); + const auto& state = static_cast(cart.getState()); + const auto& oldstate = static_cast(cart.getOldState()); myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); diff --git a/src/debugger/gui/CartBUSWidget.cxx b/src/debugger/gui/CartBUSWidget.cxx index 45ed3062a..47486de61 100644 --- a/src/debugger/gui/CartBUSWidget.cxx +++ b/src/debugger/gui/CartBUSWidget.cxx @@ -99,8 +99,7 @@ CartridgeBUSWidget::CartridgeBUSWidget( myDatastreamPointers2->setTarget(this); myDatastreamPointers2->setEditable(false); - uInt32 row; - for(row = 0; row < 4; ++row) + for(uInt32 row = 0; row < 4; ++row) { myDatastreamLabels[row] = new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), diff --git a/src/debugger/gui/CartCDFWidget.cxx b/src/debugger/gui/CartCDFWidget.cxx index 91112fe96..f73801350 100644 --- a/src/debugger/gui/CartCDFWidget.cxx +++ b/src/debugger/gui/CartCDFWidget.cxx @@ -111,8 +111,7 @@ CartridgeCDFWidget::CartridgeCDFWidget( myJumpStreamPointers->setTarget(this); myJumpStreamPointers->setEditable(false); - uInt32 row; - for(row = 0; row < 8; ++row) + for(uInt32 row = 0; row < 8; ++row) { myDatastreamLabels[row] = new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), diff --git a/src/debugger/gui/CartCMWidget.cxx b/src/debugger/gui/CartCMWidget.cxx index 36ebf9a62..c9dbe0081 100644 --- a/src/debugger/gui/CartCMWidget.cxx +++ b/src/debugger/gui/CartCMWidget.cxx @@ -166,7 +166,7 @@ void CartridgeCMWidget::loadConfig() myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank); RiotDebug& riot = Debugger::debugger().riotDebug(); - const RiotState& state = static_cast(riot.getState()); + const auto& state = static_cast(riot.getState()); const uInt8 swcha = myCart.mySWCHA; diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index 06fe8ba9b..e16611360 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -49,7 +49,7 @@ int CartridgeEnhancedWidget::initialize() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - size_t CartridgeEnhancedWidget::size() { - size_t size; + size_t size{0}; myCart.getImage(size); @@ -96,7 +96,7 @@ string CartridgeEnhancedWidget::ramDescription() string CartridgeEnhancedWidget::romDescription() { ostringstream info; - size_t size; + size_t size{0}; const ByteBuffer& image = myCart.getImage(size); if(myCart.romBankCount() > 1) @@ -328,15 +328,15 @@ void CartridgeEnhancedWidget::loadConfig() ostringstream buf; ByteArray arr = myCart.myPlusROM->getSend(); - for(size_t i = 0; i < arr.size(); ++i) - buf << Common::Base::HEX2 << int(arr[i]) << " "; + for(auto i: arr) + buf << Common::Base::HEX2 << static_cast(i) << " "; myPlusROMSendWidget->setText(buf.str(), arr != myOldState.send); buf.str(""); arr = myCart.myPlusROM->getReceive(); - for(size_t i = 0; i < arr.size(); ++i) - buf << Common::Base::HEX2 << int(arr[i]) << " "; + for(auto i: arr) + buf << Common::Base::HEX2 << static_cast(i) << " "; myPlusROMReceiveWidget->setText(buf.str(), arr != myOldState.receive); } if(myBankWidgets != nullptr) diff --git a/src/debugger/gui/CartFA2Widget.cxx b/src/debugger/gui/CartFA2Widget.cxx index 92ce9a12b..742b53d34 100644 --- a/src/debugger/gui/CartFA2Widget.cxx +++ b/src/debugger/gui/CartFA2Widget.cxx @@ -30,7 +30,7 @@ CartridgeFA2Widget::CartridgeFA2Widget( const int bwidth = _font.getStringWidth("Erase") + 20; - StaticTextWidget* t = new StaticTextWidget(boss, _font, xpos, ypos, + auto* t = new StaticTextWidget(boss, _font, xpos, ypos, _font.getStringWidth("Harmony flash memory "), myFontHeight, "Harmony flash memory ", TextAlign::Left); diff --git a/src/debugger/gui/CartRamWidget.cxx b/src/debugger/gui/CartRamWidget.cxx index b50ce6624..e792b33ee 100644 --- a/src/debugger/gui/CartRamWidget.cxx +++ b/src/debugger/gui/CartRamWidget.cxx @@ -65,7 +65,7 @@ CartRamWidget::CartRamWidget( constexpr uInt16 maxlines = 6; const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth); const StringList& sl = bs.stringList(); - uInt32 lines = static_cast(sl.size()); + auto lines = static_cast(sl.size()); bool useScrollbar = false; if(lines < 2) lines = 2; diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index f785daf83..d6ad4fe85 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -299,8 +299,8 @@ void CpuWidget::loadConfig() const Debugger& dbg = instance().debugger(); const CartDebug& cart = dbg.cartDebug(); CpuDebug& cpu = dbg.cpuDebug(); - const CpuState& state = static_cast(cpu.getState()); - const CpuState& oldstate = static_cast(cpu.getOldState()); + const auto& state = static_cast(cpu.getState()); + const auto& oldstate = static_cast(cpu.getOldState()); // Add PC to its own DataGridWidget alist.push_back(kPCRegAddr); diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index a18171674..ffd246b49 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -57,7 +57,7 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, _valueList.push_back(0); _valueStringList.push_back(EmptyString); _toolTipList.push_back(EmptyString); - _changedList.push_back(0); + _changedList.push_back(false); _hiliteList.push_back(false); } @@ -259,8 +259,7 @@ void DataGridWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount resetSelection(); // First check whether the selection changed - int newSelectedItem; - newSelectedItem = findItem(x, y); + int newSelectedItem = findItem(x, y); if (newSelectedItem > static_cast(_valueList.size()) - 1) newSelectedItem = -1; @@ -714,11 +713,13 @@ void DataGridWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect DataGridWidget::getEditRect() const { - const int rowoffset = _currentRow * _rowHeight; - const int coloffset = _currentCol * _colWidth + 4; + const uInt32 rowoffset = _currentRow * _rowHeight; + const uInt32 coloffset = _currentCol * _colWidth + 4; - return Common::Rect(1 + coloffset, rowoffset, - _colWidth + coloffset - 5, _rowHeight + rowoffset); + return { + 1 + coloffset, rowoffset, + _colWidth + coloffset - 5, _rowHeight + rowoffset + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 4c0bc0e46..334a71270 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -72,7 +72,7 @@ DebuggerDialog::DebuggerDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -DebuggerDialog::~DebuggerDialog() +DebuggerDialog::~DebuggerDialog() // NOLINT (we need an empty d'tor) { } @@ -475,22 +475,22 @@ void DebuggerDialog::addTabArea() // The TIA tab tabID = myTab->addTab("TIA"); - TiaWidget* tia = new TiaWidget(myTab, *myLFont, *myNFont, - 2, 2, widWidth, widHeight); + auto* tia = new TiaWidget(myTab, *myLFont, *myNFont, + 2, 2, widWidth, widHeight); myTab->setParentWidget(tabID, tia); addToFocusList(tia->getFocusList(), myTab, tabID); // The input/output tab (includes RIOT and INPTx from TIA) tabID = myTab->addTab("I/O"); - RiotWidget* riot = new RiotWidget(myTab, *myLFont, *myNFont, - 2, 2, widWidth, widHeight); + auto* riot = new RiotWidget(myTab, *myLFont, *myNFont, + 2, 2, widWidth, widHeight); myTab->setParentWidget(tabID, riot); addToFocusList(riot->getFocusList(), myTab, tabID); // The Audio tab tabID = myTab->addTab("Audio"); - AudioWidget* aud = new AudioWidget(myTab, *myLFont, *myNFont, - 2, 2, widWidth, widHeight); + auto* aud = new AudioWidget(myTab, *myLFont, *myNFont, + 2, 2, widWidth, widHeight); myTab->setParentWidget(tabID, aud); addToFocusList(aud->getFocusList(), myTab, tabID); @@ -624,7 +624,7 @@ void DebuggerDialog::addRomArea() wid1.push_back(myRewindButton); wid1.push_back(myUnwindButton); - DataGridOpsWidget* ops = new DataGridOpsWidget(this, *myLFont, xpos, ypos); + auto* ops = new DataGridOpsWidget(this, *myLFont, xpos, ypos); const int max_w = xpos - r.x() - 10; xpos = r.x() + 10; ypos = 5; @@ -713,8 +713,10 @@ void DebuggerDialog::addRomArea() Common::Rect DebuggerDialog::getTiaBounds() const { // The area showing the TIA image (NTSC and PAL supported, up to 274 lines without scaling) - return Common::Rect(0, 0, 320, std::max(static_cast(FrameManager::Metrics::baseHeightPAL), - static_cast(_h * 0.35))); + return { + 0, 0, 320, + std::max(FrameManager::Metrics::baseHeightPAL, _h * 0.35) + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -722,7 +724,10 @@ Common::Rect DebuggerDialog::getRomBounds() const { // The ROM area is the full area to the right of the tabs const Common::Rect& status = getStatusBounds(); - return Common::Rect(status.x() + status.w() + 1, 0, _w, _h); + return { + status.x() + status.w() + 1, 0, + static_cast(_w), static_cast(_h) + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -733,11 +738,12 @@ Common::Rect DebuggerDialog::getStatusBounds() const // 30% of any space above 1030 pixels will be allocated to this area const Common::Rect& tia = getTiaBounds(); - return Common::Rect( + return { tia.x() + tia.w() + 1, 0, tia.x() + tia.w() + 225 + (_w > 1030 ? int(0.35 * (_w - 1030)) : 0), - tia.y() + tia.h()); + tia.y() + tia.h() + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -747,6 +753,8 @@ Common::Rect DebuggerDialog::getTabBounds() const const Common::Rect& tia = getTiaBounds(); const Common::Rect& status = getStatusBounds(); - return Common::Rect(0, tia.y() + tia.h() + 1, - status.x() + status.w() + 1, _h); + return { + 0, tia.y() + tia.h() + 1, + status.x() + status.w() + 1, static_cast(_h) + }; } diff --git a/src/debugger/gui/Joy2BPlusWidget.cxx b/src/debugger/gui/Joy2BPlusWidget.cxx index 78775b09d..d9d019727 100644 --- a/src/debugger/gui/Joy2BPlusWidget.cxx +++ b/src/debugger/gui/Joy2BPlusWidget.cxx @@ -26,10 +26,8 @@ Joy2BPlusWidget::Joy2BPlusWidget(GuiObject* boss, const GUI::Font& font, const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Joy 2B+)"); - StaticTextWidget* t; - - t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, - fontHeight, label, TextAlign::Left); + auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, + fontHeight, label, TextAlign::Left); xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10; myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", CheckboxWidget::kCheckActionCmd); diff --git a/src/debugger/gui/PointingDeviceWidget.cxx b/src/debugger/gui/PointingDeviceWidget.cxx index 5b2c7097e..1b33b8ff8 100644 --- a/src/debugger/gui/PointingDeviceWidget.cxx +++ b/src/debugger/gui/PointingDeviceWidget.cxx @@ -87,9 +87,9 @@ void PointingDeviceWidget::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PointingDeviceWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { - // since the PointingDevice uses its own, internal state (not reading the controller), - // we have to communicate directly with it - PointingDevice& pDev = static_cast(controller()); + // Since the PointingDevice uses its own, internal state (not reading the + // controller), we have to communicate directly with it + auto& pDev = static_cast(controller()); switch(cmd) { @@ -124,7 +124,7 @@ void PointingDeviceWidget::handleCommand(CommandSender* sender, int cmd, int dat // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PointingDeviceWidget::setGrayCodeH() { - PointingDevice& pDev = static_cast(controller()); + auto& pDev = static_cast(controller()); pDev.myCountH &= 0b11; setValue(myGrayValueH, pDev.myCountH, pDev.myTrackBallLeft); @@ -133,7 +133,7 @@ void PointingDeviceWidget::setGrayCodeH() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PointingDeviceWidget::setGrayCodeV() { - PointingDevice& pDev = static_cast(controller()); + auto& pDev = static_cast(controller()); pDev.myCountV &= 0b11; setValue(myGrayValueV, pDev.myCountV, !pDev.myTrackBallDown); diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 737f34dcd..1a13c80af 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -382,10 +382,9 @@ void PromptWidget::loadConfig() // fill the history from the saved breaks, traps and watches commands StringList history; print(instance().debugger().autoExec(&history)); - for(uInt32 i = 0; i < history.size(); ++i) - { - addToHistory(history[i].c_str()); - } + for(const auto& h: history) + addToHistory(h.c_str()); + history.clear(); print(instance().debugger().cartDebug().loadConfigFile() + "\n"); print(instance().debugger().cartDebug().loadListFile() + "\n"); @@ -595,11 +594,11 @@ void PromptWidget::addToHistory(const char* str) if(!BSPF::compareIgnoreCase(_history[i], str)) { - int j = i, prevJ; + int j = i; do { - prevJ = j; + int prevJ = j; historyDir(j, +1); _history[prevJ] = _history[j]; } diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 15ef6f314..2d3b92d58 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -121,7 +121,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n TextAlign::Left); } - uInt32 row; + uInt32 row{0}; for(row = 0; row < myNumRows; ++row) { myRamLabels[row] = @@ -190,7 +190,7 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RamWidget::~RamWidget() +RamWidget::~RamWidget() // NOLINT (we need an empty d'tor) { } diff --git a/src/debugger/gui/RiotRamWidget.cxx b/src/debugger/gui/RiotRamWidget.cxx index a186c3a5f..ea97dd5e2 100644 --- a/src/debugger/gui/RiotRamWidget.cxx +++ b/src/debugger/gui/RiotRamWidget.cxx @@ -33,21 +33,21 @@ RiotRamWidget::RiotRamWidget(GuiObject* boss, const GUI::Font& lfont, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 RiotRamWidget::getValue(int addr) const { - const CartState& state = static_cast(myDbg.getState()); + const auto& state = static_cast(myDbg.getState()); return instance().debugger().peek(state.rport[addr]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RiotRamWidget::setValue(int addr, uInt8 value) { - const CartState& state = static_cast(myDbg.getState()); + const auto& state = static_cast(myDbg.getState()); instance().debugger().poke(state.wport[addr], value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string RiotRamWidget::getLabel(int addr) const { - const CartState& state = static_cast(myDbg.getState()); + const auto& state = static_cast(myDbg.getState()); return myDbg.getLabel(state.rport[addr], true); } @@ -55,8 +55,8 @@ string RiotRamWidget::getLabel(int addr) const void RiotRamWidget::fillList(uInt32 start, uInt32 size, IntArray& alist, IntArray& vlist, BoolArray& changed) const { - const CartState& state = static_cast(myDbg.getState()); - const CartState& oldstate = static_cast(myDbg.getOldState()); + const auto& state = static_cast(myDbg.getState()); + const auto& oldstate = static_cast(myDbg.getOldState()); for(uInt32 i = 0; i < size; ++i) { @@ -69,13 +69,13 @@ void RiotRamWidget::fillList(uInt32 start, uInt32 size, IntArray& alist, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 RiotRamWidget::readPort(uInt32 start) const { - const CartState& state = static_cast(myDbg.getState()); + const auto& state = static_cast(myDbg.getState()); return state.rport[start]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const ByteArray& RiotRamWidget::currentRam(uInt32) const { - const CartState& state = static_cast(myDbg.getState()); + const auto& state = static_cast(myDbg.getState()); return state.ram; } diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 9182848ed..0ddb878a4 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -295,8 +295,8 @@ void RiotWidget::loadConfig() // We push the enumerated items as addresses, and deal with the real // address in the callback (handleCommand) RiotDebug& riot = instance().debugger().riotDebug(); - const RiotState& state = static_cast(riot.getState()); - const RiotState& oldstate = static_cast(riot.getOldState()); + const auto& state = static_cast(riot.getState()); + const auto& oldstate = static_cast(riot.getOldState()); // Update the SWCHA register booleans (poke mode) IO_REGS_UPDATE(mySWCHAWriteBits, swchaWriteBits) diff --git a/src/debugger/gui/RomListSettings.cxx b/src/debugger/gui/RomListSettings.cxx index f2db82980..549999950 100644 --- a/src/debugger/gui/RomListSettings.cxx +++ b/src/debugger/gui/RomListSettings.cxx @@ -36,21 +36,21 @@ RomListSettings::RomListSettings(GuiObject* boss, const GUI::Font& font) WidgetArray wid; // Set PC to current line - ButtonWidget* setPC = + auto* setPC = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, "Set PC @ current line", RomListWidget::kSetPCCmd); wid.push_back(setPC); // RunTo PC on current line ypos += buttonHeight + 4; - ButtonWidget* runtoPC = + auto* runtoPC = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, "RunTo PC @ current line", RomListWidget::kRuntoPCCmd); wid.push_back(runtoPC); // Re-disassemble ypos += buttonHeight + 4; - ButtonWidget* disasm = + auto* disasm = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, "Disassemble @ current line", RomListWidget::kDisassembleCmd); wid.push_back(disasm); diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index b045868fe..cecf3911d 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -78,7 +78,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, // Create a CheckboxWidget for each row in the list for(int i = 0; i < _rows; ++i) { - CheckboxWidget* t = new CheckboxWidget(boss, lfont, _x + 2, ypos, "", + auto* t = new CheckboxWidget(boss, lfont, _x + 2, ypos, "", CheckboxWidget::kCheckActionCmd); t->setTarget(this); t->setID(i); @@ -254,8 +254,7 @@ void RomListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) else { // First check whether the selection changed - int newSelectedItem; - newSelectedItem = findItem(x, y); + int newSelectedItem = findItem(x, y); if (newSelectedItem > static_cast(myDisasm->list.size()) - 1) newSelectedItem = -1; @@ -490,7 +489,7 @@ string RomListWidget::getToolTip(const Common::Point& pos) const if(idx.x < 2 || bytes.length() < 8) // 1 or 2 hex bytes, get one hex byte - valStr = bytes.substr((idx.x / 3) * 3, 2); + valStr = bytes.substr((static_cast(idx.x) / 3) * 3, 2); else // 3 hex bytes, get two rightmost hex bytes valStr = bytes.substr(6, 2) + bytes.substr(3, 2); @@ -632,20 +631,25 @@ void RomListWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect RomListWidget::getLineRect() const { - const int yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight), - xoffset = CheckboxWidget::boxSize(_font) + 10; + const uInt32 + yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight), + xoffset = CheckboxWidget::boxSize(_font) + 10; - return Common::Rect(2 + xoffset, 1 + yoffset, - _w - (xoffset - 15), _lineHeight + yoffset); + return { + 2 + xoffset, 1 + yoffset, + _w - (xoffset - 15), _lineHeight + yoffset + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect RomListWidget::getEditRect() const { - const int yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight); + const uInt32 yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight); - return Common::Rect(2 + _w - _bytesWidth, 1 + yoffset + 1, - _w, _lineHeight + yoffset + 1); + return { + static_cast(2 + _w - _bytesWidth), 1 + yoffset + 1, + static_cast(_w), _lineHeight + yoffset + 1 + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 8d4a74433..4f72f4dac 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -40,7 +40,7 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n // Show current bank state int xpos = x, ypos = y + 7; - StaticTextWidget* t = new StaticTextWidget(boss, lfont, xpos, ypos, "Info "); + auto* t = new StaticTextWidget(boss, lfont, xpos, ypos, "Info "); xpos += t->getRight(); myBank = new EditTextWidget(boss, nfont, xpos, ypos-2, @@ -60,8 +60,8 @@ void RomWidget::loadConfig() { const Debugger& dbg = instance().debugger(); CartDebug& cart = dbg.cartDebug(); - const CartState& state = static_cast(cart.getState()); - const CartState& oldstate = static_cast(cart.getOldState()); + const auto& state = static_cast(cart.getState()); + const auto& oldstate = static_cast(cart.getOldState()); // Fill romlist the current bank of source or disassembly myListIsDirty |= cart.disassemblePC(myListIsDirty); diff --git a/src/debugger/gui/SaveKeyWidget.cxx b/src/debugger/gui/SaveKeyWidget.cxx index d6a2e79c5..93d137dc3 100644 --- a/src/debugger/gui/SaveKeyWidget.cxx +++ b/src/debugger/gui/SaveKeyWidget.cxx @@ -29,15 +29,13 @@ SaveKeyWidget::SaveKeyWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SaveKeyWidget::eraseCurrent() { - SaveKey& skey = static_cast(controller()); - + auto& skey = static_cast(controller()); skey.eraseCurrent(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool SaveKeyWidget::isPageUsed(uInt32 page) { - const SaveKey& skey = static_cast(controller()); - + const auto& skey = static_cast(controller()); return skey.isPageUsed(page); } diff --git a/src/debugger/gui/TiaInfoWidget.cxx b/src/debugger/gui/TiaInfoWidget.cxx index 56aef049b..8ac6b6f44 100644 --- a/src/debugger/gui/TiaInfoWidget.cxx +++ b/src/debugger/gui/TiaInfoWidget.cxx @@ -158,9 +158,9 @@ void TiaInfoWidget::loadConfig() { const Debugger& dbg = instance().debugger(); TIADebug& tia = dbg.tiaDebug(); - const TiaState& oldTia = static_cast(tia.getOldState()); + const auto& oldTia = static_cast(tia.getOldState()); RiotDebug& riot = dbg.riotDebug(); - const RiotState& oldRiot = static_cast(riot.getOldState()); + const auto& oldRiot = static_cast(riot.getOldState()); myFrameCount->setText(Common::Base::toString(tia.frameCount(), Common::Base::Fmt::_10_5), tia.frameCount() != oldTia.info[0]); diff --git a/src/debugger/gui/TiaWidget.cxx b/src/debugger/gui/TiaWidget.cxx index 4838f3d8e..5824f68c6 100644 --- a/src/debugger/gui/TiaWidget.cxx +++ b/src/debugger/gui/TiaWidget.cxx @@ -978,8 +978,8 @@ void TiaWidget::loadConfig() BoolArray changed; TIADebug& tia = instance().debugger().tiaDebug(); - const TiaState& state = static_cast(tia.getState()); - const TiaState& oldstate = static_cast(tia.getOldState()); + const auto& state = static_cast(tia.getState()); + const auto& oldstate = static_cast(tia.getOldState()); // Color registers alist.clear(); vlist.clear(); changed.clear(); diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index ff9f75d27..a78665736 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -49,13 +49,8 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, addFocusWidget(this); // Initialize positions - myZoomLevel = 2; myNumCols = (_w - 4) / myZoomLevel; myNumRows = (_h - 4) / myZoomLevel; - myOffX = myOffY = myOffXLo = myOffYLo = 0; - - myMouseMoving = false; - myClickX = myClickY = 0; // Create context menu for zoom levels VariantList l; @@ -351,7 +346,7 @@ void TiaZoomWidget::drawWidget(bool hilite) for(int x = myOffX >> 1, col = 0; x < (myNumCols+myOffX) >> 1; ++x, col += wzoom) { const uInt32 idx = y*width + x; - const ColorId color = static_cast(currentFrame[idx] | (idx > scanoffset ? 1 : 0)); + const auto color = static_cast(currentFrame[idx] | (idx > scanoffset ? 1 : 0)); s.fillRect(_x + col + 1, _y + row + 1, wzoom, hzoom, color); } } diff --git a/src/debugger/gui/TiaZoomWidget.hxx b/src/debugger/gui/TiaZoomWidget.hxx index 63660e099..308db7d9d 100644 --- a/src/debugger/gui/TiaZoomWidget.hxx +++ b/src/debugger/gui/TiaZoomWidget.hxx @@ -61,7 +61,7 @@ class TiaZoomWidget : public Widget, public CommandSender private: unique_ptr myMenu; - int myZoomLevel{0}; + int myZoomLevel{2}; int myNumCols{0}, myNumRows{0}; int myOffX{0}, myOffY{0}; int myOffXLo{0}, myOffYLo{0}; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 8dd37c7f1..e5fece4cc 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -43,8 +43,7 @@ void ToggleWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) return; // First check whether the selection changed - int newSelectedItem; - newSelectedItem = findItem(x, y); + int newSelectedItem = findItem(x, y); if (newSelectedItem > static_cast(_stateList.size()) - 1) newSelectedItem = -1; diff --git a/src/debugger/yacc/YaccParser.cxx b/src/debugger/yacc/YaccParser.cxx index ea75c720e..40fcdb0d5 100644 --- a/src/debugger/yacc/YaccParser.cxx +++ b/src/debugger/yacc/YaccParser.cxx @@ -35,7 +35,7 @@ void yyerror(const char* e); #pragma clang diagnostic ignored "-Wold-style-cast" #pragma clang diagnostic ignored "-Wimplicit-fallthrough" #pragma clang diagnostic ignored "-Wmissing-variable-declarations" - #include "y.tab.c" + #include "y.tab.c" // NOLINT #pragma clang diagnostic pop #else #include "y.tab.c" @@ -279,7 +279,7 @@ TiaMethod getTiaSpecial(char* ch) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int yylex() { static char idbuf[255]; // NOLINT (will be rewritten soon) - char o, p; + char o{0}, p{0}; yylval.val = 0; while(*c != '\0') { switch(state) { @@ -392,7 +392,7 @@ int yylex() { } else if(is_operator(*c)) { state = State::OPERATOR; } else { - yylval.val = *c++; + yylval.val = *c++; // NOLINT return yylval.val; } break; diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx index d8f43cf9e..8d7a2dfa7 100644 --- a/src/emucore/AtariVox.cxx +++ b/src/emucore/AtariVox.cxx @@ -43,7 +43,7 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AtariVox::~AtariVox() +AtariVox::~AtariVox() // NOLINT (we need an empty d'tor) { } diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 7f08c4451..2d2008d34 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -85,7 +85,7 @@ bool Cartridge::bankChanged() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt16 Cartridge::bankSize(uInt16 bank) const { - size_t size; + size_t size{0}; getImage(size); return static_cast( diff --git a/src/emucore/Cart3EX.cxx b/src/emucore/Cart3EX.cxx index 64d0bb14b..7be6c99a8 100644 --- a/src/emucore/Cart3EX.cxx +++ b/src/emucore/Cart3EX.cxx @@ -24,5 +24,5 @@ Cartridge3EX::Cartridge3EX(const ByteBuffer& image, size_t size, { // 0xFFFA contains RAM bank count - 1; myRamBankCount = image[size - 6] + 1; - myRamSize = (myBankSize >> 1) * myRamBankCount; + myRamSize = (myBankSize >> 1) * myRamBankCount; // NOLINT } diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 91e483397..1b78f6a49 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -24,7 +24,7 @@ CartridgeAR::CartridgeAR(const ByteBuffer& image, size_t size, const string& md5, const Settings& settings) : Cartridge(settings, md5), - mySize{std::max(size, LOAD_SIZE)} + mySize{std::max(size, LOAD_SIZE)} { // Create a load image buffer and copy the given image myLoadImages = make_unique(mySize); @@ -291,39 +291,43 @@ uInt8 CartridgeAR::checksum(const uInt8* s, uInt16 length) void CartridgeAR::loadIntoRAM(uInt8 load) { bool success = true; - uInt16 image; // Scan through all of the loads to see if we find the one we're looking for - for(image = 0; image < myNumberOfLoadImages; ++image) + for(uInt16 image = 0; image < myNumberOfLoadImages; ++image) { + const size_t image_off = image * LOAD_SIZE; + // Is this the correct load? - if(myLoadImages[(image * LOAD_SIZE) + myImage.size() + 5] == load) + if(myLoadImages[image_off + myImage.size() + 5] == load) { // Copy the load's header - std::copy_n(myLoadImages.get() + (image * LOAD_SIZE) + myImage.size(), myHeader.size(), myHeader.data()); + std::copy_n(myLoadImages.get() + image_off + myImage.size(), + myHeader.size(), myHeader.data()); // Verify the load's header if(checksum(myHeader.data(), 8) != 0x55) { cerr << "WARNING: The Supercharger header checksum is invalid...\n"; - myMsgCallback("Supercharger load #" + std::to_string(load) + " done with hearder checksum error"); + myMsgCallback("Supercharger load #" + std::to_string(load) + + " done with hearder checksum error"); success = false; } // Load all of the pages from the load bool invalidPageChecksumSeen = false; - for(uInt32 j = 0; j < myHeader[3]; ++j) + for(size_t j = 0; j < myHeader[3]; ++j) { - uInt32 bank = myHeader[16 + j] & 0b00011; - uInt32 page = (myHeader[16 + j] & 0b11100) >> 2; - const uInt8* const src = myLoadImages.get() + (image * LOAD_SIZE) + (j * 256); + const size_t bank = myHeader[16 + j] & 0b00011; + const size_t page = (myHeader[16 + j] & 0b11100) >> 2; + const uInt8* const src = myLoadImages.get() + image_off + j * 256; const uInt8 sum = checksum(src, 256) + myHeader[16 + j] + myHeader[64 + j]; if(!invalidPageChecksumSeen && (sum != 0x55)) { cerr << "WARNING: Some Supercharger page checksums are invalid...\n"; - myMsgCallback("Supercharger load #" + std::to_string(load) + " done with page #" - + std::to_string(j) + " checksum error"); + myMsgCallback("Supercharger load #" + std::to_string(load) + + " done with page #" + std::to_string(j) + + " checksum error"); invalidPageChecksumSeen = true; } diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index 468ebf802..344db15bf 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -44,9 +44,9 @@ class CartridgeAR : public Cartridge friend class CartridgeARWidget; public: - static constexpr uInt32 BANK_SIZE = static_cast(2_KB); - static constexpr uInt32 RAM_SIZE = 3 * BANK_SIZE; - static constexpr uInt32 LOAD_SIZE = 8448; + static constexpr size_t BANK_SIZE = 2_KB; + static constexpr size_t RAM_SIZE = 3 * BANK_SIZE; + static constexpr size_t LOAD_SIZE = 8448; public: /** diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index 57fee6dbc..45c706f20 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -112,7 +112,7 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size, this); } - this->setInitialState(); + this->setInitialState(); // NOLINT myPlusROM = make_unique(mySettings, *this); @@ -190,12 +190,12 @@ void CartridgeBUS::install(System& system) inline void CartridgeBUS::updateMusicModeDataFetchers() { // Calculate the number of cycles since the last update - const uInt32 cycles = static_cast(mySystem->cycles() - myAudioCycles); + const auto cycles = static_cast(mySystem->cycles() - myAudioCycles); myAudioCycles = mySystem->cycles(); // Calculate the number of BUS OSC clocks since the last update const double clocks = ((20000.0 * cycles) / myClockRate) + myFractionalClocks; - uInt32 wholeClocks = static_cast(clocks); + const auto wholeClocks = static_cast(clocks); myFractionalClocks = clocks - static_cast(wholeClocks); // Let's update counters and flags of the music mode data fetchers @@ -214,7 +214,7 @@ inline void CartridgeBUS::callFunction(uInt8 value) // time for Stella as ARM code "runs in zero 6507 cycles". case 255: // call without IRQ driven audio try { - uInt32 cycles = static_cast(mySystem->cycles() - myARMCycles); + auto cycles = static_cast(mySystem->cycles() - myARMCycles); myARMCycles = mySystem->cycles(); myThumbEmulator->run(cycles, value == 254); diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index c462df791..2645630c4 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -111,7 +111,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size, thumulatorConfiguration(myCDFSubtype), this); - this->setInitialState(); + this->setInitialState(); // NOLINT myPlusROM = make_unique(mySettings, *this); @@ -175,12 +175,12 @@ void CartridgeCDF::install(System& system) inline void CartridgeCDF::updateMusicModeDataFetchers() { // Calculate the number of cycles since the last update - const uInt32 cycles = static_cast(mySystem->cycles() - myAudioCycles); + const auto cycles = static_cast(mySystem->cycles() - myAudioCycles); myAudioCycles = mySystem->cycles(); // Calculate the number of CDF OSC clocks since the last update const double clocks = ((20000.0 * cycles) / myClockRate) + myFractionalClocks; - uInt32 wholeClocks = static_cast(clocks); + const auto wholeClocks = static_cast(clocks); myFractionalClocks = clocks - static_cast(wholeClocks); // Let's update counters and flags of the music mode data fetchers @@ -199,7 +199,7 @@ inline void CartridgeCDF::callFunction(uInt8 value) // time for Stella as ARM code "runs in zero 6507 cycles". case 255: // call without IRQ driven audio try { - uInt32 cycles = static_cast(mySystem->cycles() - myARMCycles); + auto cycles = static_cast(mySystem->cycles() - myARMCycles); myARMCycles = mySystem->cycles(); myThumbEmulator->run(cycles, value == 254); diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index fbc685845..1cd7d5b02 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -588,12 +588,12 @@ void CartridgeCTY::wipeAllScores() inline void CartridgeCTY::updateMusicModeDataFetchers() { // Calculate the number of cycles since the last update - const uInt32 cycles = static_cast(mySystem->cycles() - myAudioCycles); + const auto cycles = static_cast(mySystem->cycles() - myAudioCycles); myAudioCycles = mySystem->cycles(); // Calculate the number of CTY OSC clocks since the last update const double clocks = ((20000.0 * cycles) / myClockRate) + myFractionalClocks; - const uInt32 wholeClocks = static_cast(clocks); + const auto wholeClocks = static_cast(clocks); myFractionalClocks = clocks - static_cast(wholeClocks); // Let's update counters and flags of the music mode data fetchers diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index 8c28974c8..b72c67903 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -94,12 +94,12 @@ inline void CartridgeDPC::clockRandomNumberGenerator() inline void CartridgeDPC::updateMusicModeDataFetchers() { // Calculate the number of cycles since the last update - const uInt32 cycles = static_cast(mySystem->cycles() - myAudioCycles); + const auto cycles = static_cast(mySystem->cycles() - myAudioCycles); myAudioCycles = mySystem->cycles(); // Calculate the number of DPC OSC clocks since the last update const double clocks = ((myDpcPitch * cycles) / myClockRate) + myFractionalClocks; - const uInt32 wholeClocks = static_cast(clocks); + const auto wholeClocks = static_cast(clocks); myFractionalClocks = clocks - static_cast(wholeClocks); if(wholeClocks == 0) @@ -112,7 +112,7 @@ inline void CartridgeDPC::updateMusicModeDataFetchers() if(myMusicMode[x - 5]) { const Int32 top = myTops[x] + 1; - Int32 newLow = static_cast(myCounters[x] & 0x00ff); + auto newLow = static_cast(myCounters[x] & 0x00ff); if(myTops[x] != 0) { diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index aeb5d4878..c208664f6 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -78,7 +78,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size, myDriverMD5 == "8dd73b44fd11c488326ce507cbeb19d1" ) myFractionalLowMask = 0x0F0000; - this->setInitialState(); + this->setInitialState(); // NOLINT myPlusROM = make_unique(mySettings, *this); @@ -165,12 +165,12 @@ inline void CartridgeDPCPlus::priorClockRandomNumberGenerator() inline void CartridgeDPCPlus::updateMusicModeDataFetchers() { // Calculate the number of cycles since the last update - const uInt32 cycles = static_cast(mySystem->cycles() - myAudioCycles); + const auto cycles = static_cast(mySystem->cycles() - myAudioCycles); myAudioCycles = mySystem->cycles(); // Calculate the number of DPC+ OSC clocks since the last update const double clocks = ((20000.0 * cycles) / myClockRate) + myFractionalClocks; - const uInt32 wholeClocks = static_cast(clocks); + const auto wholeClocks = static_cast(clocks); myFractionalClocks = clocks - static_cast(wholeClocks); // Let's update counters and flags of the music mode data fetchers @@ -204,7 +204,7 @@ inline void CartridgeDPCPlus::callFunction(uInt8 value) // time for Stella as ARM code "runs in zero 6507 cycles". case 255: // call without IRQ driven audio try { - uInt32 cycles = static_cast(mySystem->cycles() - myARMCycles); + auto cycles = static_cast(mySystem->cycles() - myARMCycles); myARMCycles = mySystem->cycles(); myThumbEmulator->run(cycles, value == 254); diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index 7d11ef634..b14af7f67 100644 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -267,11 +267,11 @@ bool CartDetector::searchForBytes(const uInt8* image, size_t imagesize, const uInt8* signature, uInt32 sigsize, uInt32 minhits) { - uInt32 count = 0; + uInt32 count{0}; for(uInt32 i = 0; i < imagesize - sigsize; ++i) { - uInt32 j; + uInt32 j{0}; for(j = 0; j < sigsize; ++j) { @@ -331,16 +331,16 @@ bool CartDetector::isProbably0840(const ByteBuffer& image, size_t size) { 0xAD, 0x40, 0x08 }, // LDA $0840 { 0x2C, 0x00, 0x08 } // BIT $0800 }; - for(uInt32 i = 0; i < 3; ++i) - if(searchForBytes(image, size, signature1[i], 3, 2)) + for(const auto* const sig: signature1) + if(searchForBytes(image, size, sig, 3, 2)) return true; static constexpr uInt8 signature2[2][4] = { { 0x0C, 0x00, 0x08, 0x4C }, // NOP $0800; JMP ... { 0x0C, 0xFF, 0x0F, 0x4C } // NOP $0FFF; JMP ... }; - for(uInt32 i = 0; i < 2; ++i) - if(searchForBytes(image, size, signature2[i], 4, 2)) + for(const auto* const sig: signature2) + if(searchForBytes(image, size, sig, 4, 2)) return true; return false; @@ -358,8 +358,8 @@ bool CartDetector::isProbably0FA0(const ByteBuffer& image, size_t size) { 0xAD, 0xC0, 0x0F }, // LDA $FC0 (Front Line, Zaxxon) { 0x2C, 0xC0, 0xEF } // BIT $EFC0 (Motocross) }; - for(uInt32 i = 0; i < 4; ++i) - if(searchForBytes(image, size, signature[i], 3)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 3)) return true; return false; @@ -560,8 +560,8 @@ bool CartDetector::isProbablyE0(const ByteBuffer& image, size_t size) { 0xAD, 0xED, 0xFF }, // LDA $FFED { 0xAD, 0xF3, 0xBF } // LDA $BFF3 }; - for(uInt32 i = 0; i < 8; ++i) - if(searchForBytes(image, size, signature[i], 3)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 3)) return true; return false; @@ -585,8 +585,8 @@ bool CartDetector::isProbablyE7(const ByteBuffer& image, size_t size) { 0x8D, 0xE7, 0xFF }, // STA $FFE7 { 0x8D, 0xE7, 0x1F } // STA $1FE7 }; - for(uInt32 i = 0; i < 7; ++i) - if(searchForBytes(image, size, signature[i], 3)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 3)) return true; return false; @@ -604,8 +604,8 @@ bool CartDetector::isProbablyE78K(const ByteBuffer& image, size_t size) { 0xAD, 0xE5, 0xFF }, // LDA $FFE5 { 0xAD, 0xE6, 0xFF }, // LDA $FFE6 }; - for(uInt32 i = 0; i < 3; ++i) - if(searchForBytes(image, size, signature[i], 3)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 3)) return true; return false; @@ -640,9 +640,9 @@ bool CartDetector::isProbablyEF(const ByteBuffer& image, size_t size, { 0x0C, 0xE0, 0x1F }, // NOP $1FE0 { 0xAD, 0xE0, 0x1F } // LDA $1FE0 }; - for(uInt32 i = 0; i < 4; ++i) + for(const auto* const sig: signature) { - if(searchForBytes(image, size, signature[i], 3)) + if(searchForBytes(image, size, sig, 3)) { isEF = true; break; @@ -684,8 +684,8 @@ bool CartDetector::isProbablyFC(const ByteBuffer& image, size_t size) { 0x8d, 0xf8, 0xff, 0x8d, 0xfc, 0xff }, // STA $FFF8, STA $FFFC Surf's Up (4K) { 0x8c, 0xf9, 0xff, 0xad, 0xfc, 0xff } // STY $FFF9, LDA $FFFC 3-D Havoc }; - for(uInt32 i = 0; i < 3; ++i) - if(searchForBytes(image, size, signature[i], 6)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 6)) return true; return false; @@ -703,8 +703,8 @@ bool CartDetector::isProbablyFE(const ByteBuffer& image, size_t size) { 0xD0, 0xFB, 0x20, 0x73, 0xFE }, // BNE $FB; JSR $FE73 { 0x20, 0x00, 0xF0, 0x84, 0xD6 } // JSR $F000; $84, $D6 }; - for(uInt32 i = 0; i < 4; ++i) - if(searchForBytes(image, size, signature[i], 5)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 5)) return true; return false; @@ -787,8 +787,8 @@ bool CartDetector::isProbablyUA(const ByteBuffer& image, size_t size) { 0x8D, 0xC0, 0x02 }, // STA $2C0 (Fathom, Vanguard) { 0xAD, 0xC0, 0x02 }, // LDA $2C0 (Mickey) }; - for(uInt32 i = 0; i < 6; ++i) - if(searchForBytes(image, size, signature[i], 3)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 3)) return true; return false; @@ -816,8 +816,8 @@ bool CartDetector::isProbablyX07(const ByteBuffer& image, size_t size) { 0x0C, 0x1D, 0x08 }, // NOP $081D { 0x0C, 0x2D, 0x08 } // NOP $082D }; - for(uInt32 i = 0; i < 6; ++i) - if(searchForBytes(image, size, signature[i], 3)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, 3)) return true; return false; diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index 5140d1419..3957717c2 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -37,7 +37,10 @@ void CartridgeE7::initialize(const ByteBuffer& image, size_t size) std::copy_n(image.get(), std::min(romSize(), size), myImage.get()); createRomAccessArrays(romSize() + myRAM.size()); - myRAMBank = romBankCount() - 1; + myRAM.fill(0xFF); + myCurrentBank.fill(0); + + myRAMBank = romBankCount() - 1; // NOLINT } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -98,8 +101,10 @@ void CartridgeE7::install(System& system) 0, nullptr, 0x1fc0, System::PA_NONE, 0x1fc0);*/ // Setup the second segment to always point to the last ROM bank + const auto offset = static_cast(myRAMBank * BANK_SIZE); setAccess(0x1A00, 0x1FE0U & (~System::PAGE_MASK - 0x1A00), - myRAMBank * BANK_SIZE, myImage.get(), myRAMBank * BANK_SIZE, System::PageAccessType::READ, BANK_SIZE - 1); + offset, myImage.get(), offset, + System::PageAccessType::READ, static_cast(BANK_SIZE - 1)); myCurrentBank[1] = myRAMBank; // Install some default banks for the RAM and first segment @@ -177,7 +182,7 @@ bool CartridgeE7::poke(uInt16 address, uInt8 value) else { // Writing to the read port should be ignored, but trigger a break if option enabled - uInt8 dummy; + uInt8 dummy{0}; pokeRAM(dummy, pokeAddress, value); myRamWriteAccess = pokeAddress; @@ -197,7 +202,7 @@ bool CartridgeE7::poke(uInt16 address, uInt8 value) else { // Writing to the read port should be ignored, but trigger a break if option enabled - uInt8 dummy; + uInt8 dummy{0}; pokeRAM(dummy, pokeAddress, value); myRamWriteAccess = pokeAddress; @@ -345,5 +350,5 @@ uInt16 CartridgeE7::romBankCount() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt16 CartridgeE7::romSize() const { - return romBankCount() * BANK_SIZE; + return romBankCount() * BANK_SIZE; // NOLINT } diff --git a/src/emucore/CartE7.hxx b/src/emucore/CartE7.hxx index 9db757de5..c4634ca09 100644 --- a/src/emucore/CartE7.hxx +++ b/src/emucore/CartE7.hxx @@ -208,7 +208,7 @@ class CartridgeE7 : public Cartridge void checkSwitchBank(uInt16 address); // Size of a ROM or RAM bank - static constexpr uInt32 BANK_SIZE = 0x800; // 2K + static constexpr size_t BANK_SIZE = 0x800; // 2K private: // Size of RAM in the cart @@ -221,8 +221,9 @@ class CartridgeE7 : public Cartridge */ uInt16 romSize() const; - void setAccess(uInt16 addrFrom, uInt16 size, uInt16 directOffset, uInt8* directData, - uInt16 codeOffset, System::PageAccessType type, uInt16 addrMask = 0); + void setAccess(uInt16 addrFrom, uInt16 size, uInt16 directOffset, + uInt8* directData, uInt16 codeOffset, + System::PageAccessType type, uInt16 addrMask = 0); private: // Pointer to a dynamically allocated ROM image of the cartridge diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index b30f3a64e..f2d191adf 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -100,27 +100,27 @@ void CartridgeEnhanced::install(System& system) // Set the page accessing method for the RAM writing pages // Note: Writes are mapped to poke() (NOT using directPokeBase) to check for read from write port (RWP) access.type = System::PageAccessType::WRITE; - for(uInt16 addr = ROM_OFFSET + myWriteOffset; addr < ROM_OFFSET + myWriteOffset + myRamSize; addr += System::PAGE_SIZE) + for(size_t addr = ROM_OFFSET + myWriteOffset; addr < ROM_OFFSET + myWriteOffset + myRamSize; addr += System::PAGE_SIZE) { const uInt16 offset = addr & myRamMask; access.romAccessBase = &myRomAccessBase[myWriteOffset + offset]; access.romPeekCounter = &myRomAccessCounter[myWriteOffset + offset]; access.romPokeCounter = &myRomAccessCounter[myWriteOffset + offset + myAccessSize]; - mySystem->setPageAccess(addr, access); + mySystem->setPageAccess(static_cast(addr), access); } // Set the page accessing method for the RAM reading pages access.type = System::PageAccessType::READ; - for(uInt16 addr = ROM_OFFSET + myReadOffset; addr < ROM_OFFSET + myReadOffset + myRamSize; addr += System::PAGE_SIZE) + for(size_t addr = ROM_OFFSET + myReadOffset; addr < ROM_OFFSET + myReadOffset + myRamSize; addr += System::PAGE_SIZE) { - const uInt16 offset = addr & myRamMask; + const size_t offset = addr & myRamMask; access.directPeekBase = &myRAM[offset]; access.romAccessBase = &myRomAccessBase[myReadOffset + offset]; access.romPeekCounter = &myRomAccessCounter[myReadOffset + offset]; access.romPokeCounter = &myRomAccessCounter[myReadOffset + offset + myAccessSize]; - mySystem->setPageAccess(addr, access); + mySystem->setPageAccess(static_cast(addr), access); } } @@ -221,7 +221,7 @@ bool CartridgeEnhanced::poke(uInt16 address, uInt8 value) } } // Writing to the read port should be ignored, but trigger a break if option enabled - uInt8 dummy; + uInt8 dummy{0}; pokeRAM(dummy, pokeAddress, value); myRamWriteAccess = pokeAddress; diff --git a/src/emucore/CartMVC.cxx b/src/emucore/CartMVC.cxx index 3fc716772..953507991 100755 --- a/src/emucore/CartMVC.cxx +++ b/src/emucore/CartMVC.cxx @@ -135,7 +135,7 @@ class StreamReader : public Serializable uInt8 readAudio() { return *myAudio++; } - uInt8 peekAudio() const { return *myAudio; } + [[nodiscard]] uInt8 peekAudio() const { return *myAudio; } void startTimeCode() { myGraph = myTimecode; } @@ -744,7 +744,7 @@ class MovieCart : public Serializable bool save(Serializer& out) const override; bool load(Serializer& in) override; - uInt8 readROM(uInt16 address) const { + [[nodiscard]] uInt8 readROM(uInt16 address) const { return myROM[address & 1023]; } @@ -1091,7 +1091,6 @@ void MovieCart::updateTransport() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MovieCart::fill_addr_right_line() { - uint8_t v; writeAudio(addr_set_aud_right + 1); writeGraph(addr_set_gdata5 + 1); @@ -1100,7 +1099,7 @@ void MovieCart::fill_addr_right_line() writeGraph(addr_set_gdata8 + 1); writeGraph(addr_set_gdata9 + 1); - v = myStream.readColor(); + uint8_t v = myStream.readColor(); writeColor(addr_set_gcol5 + 1, v); v = myStream.readColor(); @@ -1118,21 +1117,19 @@ void MovieCart::fill_addr_right_line() // alternate between background color and playfield color if (myForceColor) { - v = 0; - writeROM(addr_set_colubk_r + 1, v); + v = 0; + writeROM(addr_set_colubk_r + 1, v); } else { - v = myStream.readColorBK(); - writeColor(addr_set_colubk_r + 1, v); + v = myStream.readColorBK(); + writeColor(addr_set_colubk_r + 1, v); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MovieCart::fill_addr_left_line(bool again) { - uint8_t v; - writeAudio(addr_set_aud_left + 1); writeGraph(addr_set_gdata0 + 1); @@ -1141,7 +1138,7 @@ void MovieCart::fill_addr_left_line(bool again) writeGraph(addr_set_gdata3 + 1); writeGraph(addr_set_gdata4 + 1); - v = myStream.readColor(); + uint8_t v = myStream.readColor(); writeColor(addr_set_gcol0 + 1, v); v = myStream.readColor(); @@ -1160,13 +1157,13 @@ void MovieCart::fill_addr_left_line(bool again) // alternate between background color and playfield color if (myForceColor) { - v = 0; - writeROM(addr_set_colupf_l + 1, v); + v = 0; + writeROM(addr_set_colupf_l + 1, v); } else { - v = myStream.readColorBK(); - writeColor(addr_set_colupf_l + 1, v); + v = myStream.readColorBK(); + writeColor(addr_set_colupf_l + 1, v); } // addr_pick_line_end @@ -1330,9 +1327,11 @@ void MovieCart::runStateMachine() } if(myOdd) - myStream.overrideGraph(&levelBarsOddData[levelValue * 40]); + myStream.overrideGraph( + &levelBarsOddData[static_cast(levelValue) * 40]); else - myStream.overrideGraph(&levelBarsEvenData[levelValue * 40]); + myStream.overrideGraph( + &levelBarsEvenData[static_cast(levelValue) * 40]); } } @@ -1362,14 +1361,14 @@ void MovieCart::runStateMachine() if(myLines >= 1) { - fill_addr_left_line(1); + fill_addr_left_line(true); myLines -= 1; myState = 1; } else { - fill_addr_left_line(0); + fill_addr_left_line(false); fill_addr_end_lines(); myStream.swapField(myBufferIndex, myOdd); @@ -1411,8 +1410,8 @@ void MovieCart::runStateMachine() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool MovieCart::process(uInt16 address) { - const bool a12 = (address & (1 << 12)) ? 1:0; - const bool a11 = (address & (1 << 11)) ? 1:0; + const bool a12 = (address & (1 << 12)); + const bool a11 = (address & (1 << 11)); // count a10 pulses const bool a10i = (address & (1 << 10)); @@ -1570,7 +1569,7 @@ CartridgeMVC::CartridgeMVC(const string& path, size_t size, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeMVC::~CartridgeMVC() +CartridgeMVC::~CartridgeMVC() // NOLINT (we need an empty d'tor) { } diff --git a/src/emucore/CartMVC.hxx b/src/emucore/CartMVC.hxx index 714a7b6de..07ff0e83c 100644 --- a/src/emucore/CartMVC.hxx +++ b/src/emucore/CartMVC.hxx @@ -36,7 +36,7 @@ class MovieCart; class CartridgeMVC : public Cartridge { public: - static constexpr uInt32 + static constexpr size_t MVC_FIELD_SIZE = 2560, // round field to nearest 512 byte boundary MVC_FIELD_PAD_SIZE = 4096; // round to nearest 4K diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 6dcfbb238..2cf0542de 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -173,7 +173,7 @@ Console::Console(OSystem& osystem, unique_ptr& cart, setControllers(md5); // Mute audio and clear framebuffer while autodetection runs - myOSystem.sound().mute(1); + myOSystem.sound().mute(true); myOSystem.frameBuffer().clear(); if(myDisplayFormat == "AUTO" || myOSystem.settings().getBool("rominfo")) @@ -360,13 +360,13 @@ string Console::formatFromFilename() const // Get filename, and search using regex's above const string& filename = myOSystem.romFile().getName(); - for(size_t i = 0; i < Pattern.size(); ++i) + for(const auto& pat: Pattern) { try { - std::regex rgx(Pattern[i][0], std::regex_constants::icase); + std::regex rgx(pat[0], std::regex_constants::icase); if(std::regex_search(filename, rgx)) - return Pattern[i][1]; + return pat[1]; } catch(...) { @@ -1129,7 +1129,7 @@ void Console::changePaddleAxesRange(int direction) { istringstream m_axis(myProperties.get(PropType::Controller_MouseAxis)); string mode = "AUTO"; - int range; + int range{0}; m_axis >> mode; if(!(m_axis >> range)) diff --git a/src/emucore/ControllerDetector.cxx b/src/emucore/ControllerDetector.cxx index 5bf9b2986..e99a49c7c 100644 --- a/src/emucore/ControllerDetector.cxx +++ b/src/emucore/ControllerDetector.cxx @@ -181,16 +181,16 @@ bool ControllerDetector::usesJoystickButton(const ByteBuffer& image, size_t size { 0xad, 0x0c, 0x00, 0x29, 0x80 } // lda.w INPT4|$30; and #$80 (joystick games only) }; - for(uInt32 i = 0; i < NUM_SIGS_0; ++i) - if(searchForBytes(image, size, signature_0[i], SIG_SIZE_0)) + for(const auto* const sig: signature_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0)) return true; - for(uInt32 i = 0; i < NUM_SIGS_1; ++i) - if(searchForBytes(image, size, signature_1[i], SIG_SIZE_1)) + for(const auto* const sig: signature_1) + if(searchForBytes(image, size, sig, SIG_SIZE_1)) return true; - for(uInt32 i = 0; i < NUM_SIGS_2; ++i) - if(searchForBytes(image, size, signature_2[i], SIG_SIZE_2)) + for(const auto* const sig: signature_2) + if(searchForBytes(image, size, sig, SIG_SIZE_2)) return true; } else if(port == Controller::Jack::Right) @@ -235,16 +235,16 @@ bool ControllerDetector::usesJoystickButton(const ByteBuffer& image, size_t size { 0xad, 0x0d, 0x00, 0x29, 0x80 } // lda.w INPT5|$30; and #$80 (joystick games only) }; - for(uInt32 i = 0; i < NUM_SIGS_0; ++i) - if(searchForBytes(image, size, signature_0[i], SIG_SIZE_0)) + for(const auto* const sig: signature_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0)) return true; - for(uInt32 i = 0; i < NUM_SIGS_1; ++i) - if(searchForBytes(image, size, signature_1[i], SIG_SIZE_1)) + for(const auto* const sig: signature_1) + if(searchForBytes(image, size, sig, SIG_SIZE_1)) return true; - for(uInt32 i = 0; i < NUM_SIGS_2; ++i) - if(searchForBytes(image, size, signature_2[i], SIG_SIZE_2)) + for(const auto* const sig: signature_2) + if(searchForBytes(image, size, sig, SIG_SIZE_2)) return true; } return false; @@ -268,8 +268,8 @@ bool ControllerDetector::usesJoystickDirections(const ByteBuffer& image, size_t { 0xad, 0x88, 0x02 }, // lda SWCHA|8 (Jawbreaker) }; - for(uInt32 i = 0; i < NUM_SIGS; ++i) - if(searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, SIG_SIZE)) return true; return false; @@ -319,29 +319,29 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size, bool found = false; - for(uInt32 i = 0; i < NUM_SIGS_0_0; ++i) - if(searchForBytes(image, size, signature_0_0[i], SIG_SIZE_0_0)) + for(const auto* const sig: signature_0_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0_0)) { found = true; break; } if(!found) - for(uInt32 i = 0; i < NUM_SIGS_0_2; ++i) - if(searchForBytes(image, size, signature_0_2[i], SIG_SIZE_0_2)) + for(const auto* const sig: signature_0_2) + if(searchForBytes(image, size, sig, SIG_SIZE_0_2)) { found = true; break; } if(found) { - for(uInt32 j = 0; j < NUM_SIGS_1_0; ++j) - if(searchForBytes(image, size, signature_1_0[j], SIG_SIZE_1_0)) + for(const auto* const sig: signature_1_0) + if(searchForBytes(image, size, sig, SIG_SIZE_1_0)) { return true; } - for(uInt32 j = 0; j < NUM_SIGS_1_2; ++j) - if(searchForBytes(image, size, signature_1_2[j], SIG_SIZE_1_2)) + for(const auto* const sig: signature_1_2) + if(searchForBytes(image, size, sig, SIG_SIZE_1_2)) { return true; } @@ -384,16 +384,16 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size, bool found = false; - for(uInt32 i = 0; i < NUM_SIGS_0_0; ++i) - if(searchForBytes(image, size, signature_0_0[i], SIG_SIZE_0_0)) + for(const auto* const sig: signature_0_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0_0)) { found = true; break; } if(!found) - for(uInt32 i = 0; i < NUM_SIGS_0_2; ++i) - if(searchForBytes(image, size, signature_0_2[i], SIG_SIZE_0_2)) + for(const auto* const sig: signature_0_2) + if(searchForBytes(image, size, sig, SIG_SIZE_0_2)) { found = true; break; @@ -401,14 +401,14 @@ bool ControllerDetector::usesKeyboard(const ByteBuffer& image, size_t size, if(found) { - for(uInt32 j = 0; j < NUM_SIGS_1_0; ++j) - if(searchForBytes(image, size, signature_1_0[j], SIG_SIZE_1_0)) + for(const auto* const sig: signature_1_0) + if(searchForBytes(image, size, sig, SIG_SIZE_1_0)) { return true; } - for(uInt32 j = 0; j < NUM_SIGS_1_2; ++j) - if(searchForBytes(image, size, signature_1_2[j], SIG_SIZE_1_2)) + for(const auto* const sig: signature_1_2) + if(searchForBytes(image, size, sig, SIG_SIZE_1_2)) { return true; } @@ -448,8 +448,8 @@ bool ControllerDetector::usesGenesisButton(const ByteBuffer& image, size_t size, { 0x25, 0x39, 0x30 }, // and INPT1|$30; bmi (Genesis only) { 0x25, 0x09, 0x10 } // and INPT1; bpl (Genesis only) }; - for(uInt32 i = 0; i < NUM_SIGS_0; ++i) - if(searchForBytes(image, size, signature_0[i], SIG_SIZE_0)) + for(const auto* const sig: signature_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0)) return true; } else if(port == Controller::Jack::Right) @@ -469,8 +469,8 @@ bool ControllerDetector::usesGenesisButton(const ByteBuffer& image, size_t size, { 0xa6, 0x3b, 0x8e }, // ldx INPT3|$30; stx { 0x25, 0x0b, 0x10 } // and INPT3; bpl (Genesis only) }; - for(uInt32 i = 0; i < NUM_SIGS_0; ++i) - if(searchForBytes(image, size, signature_0[i], SIG_SIZE_0)) + for(const auto* const sig: signature_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0)) return true; } return false; @@ -519,16 +519,16 @@ bool ControllerDetector::usesPaddle(const ByteBuffer& image, size_t size, { 0xb1, 0xf2, 0x30, 0x02, 0xe6 } // lda ($f2),y; bmi...; inc (Warplock) }; - for(uInt32 i = 0; i < NUM_SIGS_0; ++i) - if(searchForBytes(image, size, signature_0[i], SIG_SIZE_0)) + for(const auto* const sig: signature_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0)) return true; - for(uInt32 i = 0; i < NUM_SIGS_1; ++i) - if(searchForBytes(image, size, signature_1[i], SIG_SIZE_1)) + for(const auto* const sig: signature_1) + if(searchForBytes(image, size, sig, SIG_SIZE_1)) return true; - for(uInt32 i = 0; i < NUM_SIGS_2; ++i) - if(searchForBytes(image, size, signature_2[i], SIG_SIZE_2)) + for(const auto* const sig: signature_2) + if(searchForBytes(image, size, sig, SIG_SIZE_2)) return true; } else if(port == Controller::Jack::Right) @@ -569,16 +569,16 @@ bool ControllerDetector::usesPaddle(const ByteBuffer& image, size_t size, { 0xb5, 0x38, 0x49, 0xff, 0x0a } // lda INPT0|$30,x; eor #$ff; asl (Blackjack) }; - for(uInt32 i = 0; i < NUM_SIGS_0; ++i) - if(searchForBytes(image, size, signature_0[i], SIG_SIZE_0)) + for(const auto* const sig: signature_0) + if(searchForBytes(image, size, sig, SIG_SIZE_0)) return true; - for(uInt32 i = 0; i < NUM_SIGS_1; ++i) - if(searchForBytes(image, size, signature_1[i], SIG_SIZE_1)) + for(const auto* const sig: signature_1) + if(searchForBytes(image, size, sig, SIG_SIZE_1)) return true; - for(uInt32 i = 0; i < NUM_SIGS_2; ++i) - if(searchForBytes(image, size, signature_2[i], SIG_SIZE_2)) + for(const auto* const sig: signature_2) + if(searchForBytes(image, size, sig, SIG_SIZE_2)) return true; } @@ -597,8 +597,8 @@ bool ControllerDetector::isProbablyTrakBall(const ByteBuffer& image, size_t size { 0x00, 0x01, 0x81, 0x01, 0x82, 0x03 } // .MovementTab_1 (Omegamatrix) }; // all pattern checked, only TrakBall matches - for(uInt32 i = 0; i < NUM_SIGS; ++i) - if(searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, SIG_SIZE)) return true; return false; @@ -616,8 +616,8 @@ bool ControllerDetector::isProbablyAtariMouse(const ByteBuffer& image, size_t si { 0x00, 0x81, 0x01, 0x00, 0x02, 0x83 } // .MovementTab_1 (Omegamatrix) }; // all pattern checked, only Atari Mouse matches - for(uInt32 i = 0; i < NUM_SIGS; ++i) - if(searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, SIG_SIZE)) return true; return false; @@ -636,8 +636,8 @@ bool ControllerDetector::isProbablyAmigaMouse(const ByteBuffer& image, size_t si { 0b100, 0b000, 0b000, 0b000, 0b101, 0b001} // NextTrackTbl (T. Jentzsch, MCTB) }; // all pattern checked, only Amiga Mouse matches - for(uInt32 i = 0; i < NUM_SIGS; ++i) - if(searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, SIG_SIZE)) return true; return false; @@ -680,8 +680,8 @@ bool ControllerDetector::isProbablySaveKey(const ByteBuffer& image, size_t size, } }; - for(uInt32 i = 0; i < NUM_SIGS; ++i) - if(searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if(searchForBytes(image, size, sig, SIG_SIZE)) return true; } @@ -702,8 +702,8 @@ bool ControllerDetector::isProbablyLightGun(const ByteBuffer& image, size_t size { 0xea, 0xea, 0xea, 0x24, 0x3c, 0x10 } }; // all pattern checked, only 'Sentinel' and 'Shooting Arcade' match - for (uInt32 i = 0; i < NUM_SIGS; ++i) - if (searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if (searchForBytes(image, size, sig, SIG_SIZE)) return true; return false; @@ -718,8 +718,8 @@ bool ControllerDetector::isProbablyLightGun(const ByteBuffer& image, size_t size { 0xea, 0xea, 0xea, 0x24, 0x3d, 0x10 } }; // all pattern checked, only 'Bobby is Hungry' matches - for (uInt32 i = 0; i < NUM_SIGS; ++i) - if (searchForBytes(image, size, signature[i], SIG_SIZE)) + for(const auto* const sig: signature) + if (searchForBytes(image, size, sig, SIG_SIZE)) return true; } return false; @@ -737,8 +737,8 @@ bool ControllerDetector::isProbablyQuadTari(const ByteBuffer& image, size_t size { 'Q', 'U', 'A', 'D', 'T', 'A', 'R', 'I' } }; // "QUADTARI" - for(uInt32 i = 0; i < NUM_SIGS; ++i) - if(searchForBytes(image, size, signatureBoth[i], SIG_SIZE)) + for(const auto* const sig: signatureBoth) + if(searchForBytes(image, size, sig, SIG_SIZE)) return true; } diff --git a/src/emucore/EmulationWorker.cxx b/src/emucore/EmulationWorker.cxx index e534ea051..2e59230e1 100644 --- a/src/emucore/EmulationWorker.cxx +++ b/src/emucore/EmulationWorker.cxx @@ -113,7 +113,7 @@ uInt64 EmulationWorker::stop() // See EmulationWorker::start above for the gory details waitUntilPendingSignalHasProcessed(); - uInt64 totalCycles; + uInt64 totalCycles{0}; { std::unique_lock lock(myThreadIsRunningMutex); diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index e3ac95ca8..ef0343779 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -81,7 +81,7 @@ EventHandler::EventHandler(OSystem& osystem) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EventHandler::~EventHandler() +EventHandler::~EventHandler() // NOLINT (we need an empty d'tor) { } @@ -2015,7 +2015,7 @@ json EventHandler::convertLegacyComboMapping(string list) try { - int numCombos; + int numCombos{0}; // Get combo count, which should be the first int in the list // If it isn't, then we treat the entire list as invalid buf >> numCombos; @@ -2028,8 +2028,7 @@ json EventHandler::convertLegacyComboMapping(string list) for(int j = 0; j < EVENTS_PER_COMBO; ++j) { - int event; - + int event{0}; buf >> event; // skip all NoType events if(event != Event::NoType) @@ -2362,10 +2361,10 @@ int EventHandler::getEmulActionListIndex(int idx, const Event::EventSet& events) // ordered by 'ourEmulActionList'! Event::Type event = Event::NoType; - for(uInt32 i = 0; i < ourEmulActionList.size(); ++i) + for(auto& alist: ourEmulActionList) { for(const auto& item : events) - if(EventHandler::ourEmulActionList[i].event == item) + if(alist.event == item) { idx--; if(idx < 0) diff --git a/src/emucore/FBBackend.hxx b/src/emucore/FBBackend.hxx index c3201e111..43c2dc2af 100644 --- a/src/emucore/FBBackend.hxx +++ b/src/emucore/FBBackend.hxx @@ -147,7 +147,7 @@ class FBBackend @param pitch The pitch (in bytes) for the pixel data @param rect The bounding rectangle for the buffer */ - virtual void readPixels(uInt8* buffer, uInt32 pitch, + virtual void readPixels(uInt8* buffer, size_t pitch, const Common::Rect& rect) const = 0; /** diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index 940569371..918ca721e 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -28,7 +28,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const Common::Rect& rect) const { - uInt8* src = reinterpret_cast(myPixels + rect.y() * myPitch + rect.x()); + auto* src = reinterpret_cast(myPixels + + (rect.y() * static_cast(myPitch)) + rect.x()); if(rect.empty()) std::copy_n(src, width() * height() * 4, buffer); @@ -42,8 +43,8 @@ void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const Common::Rect& rect while(h--) { std::copy_n(src, w * 4, dst); - src += myPitch * 4; - dst += pitch * 4; + src += static_cast(myPitch) * 4; + dst += static_cast(pitch) * 4; } } } @@ -52,7 +53,7 @@ void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const Common::Rect& rect void FBSurface::pixel(uInt32 x, uInt32 y, ColorId color) { // Note: checkbounds() must be done in calling method - uInt32* buffer = myPixels + y * myPitch + x; + uInt32* buffer = myPixels + (y * static_cast(myPitch)) + x; *buffer = myPalette[color]; } @@ -125,7 +126,7 @@ void FBSurface::hLine(uInt32 x, uInt32 y, uInt32 x2, ColorId color) if(!checkBounds(x, y) || !checkBounds(x2, 2)) return; - uInt32* buffer = myPixels + y * myPitch + x; + uInt32* buffer = myPixels + (y * static_cast(myPitch)) + x; while(x++ <= x2) *buffer++ = myPalette[color]; } @@ -136,7 +137,7 @@ void FBSurface::vLine(uInt32 x, uInt32 y, uInt32 y2, ColorId color) if(!checkBounds(x, y) || !checkBounds(x, y2)) return; - uInt32* buffer = myPixels + y * myPitch + x; + uInt32* buffer = myPixels + (y * static_cast(myPitch)) + x; while(y++ <= y2) { *buffer = myPalette[color]; @@ -197,7 +198,7 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, return; const uInt16* tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.fbbh)); - uInt32* buffer = myPixels + cy * myPitch + cx; + uInt32* buffer = myPixels + (cy * static_cast(myPitch)) + cx; for(int y = 0; y < bbh; y++) { @@ -227,7 +228,7 @@ void FBSurface::drawBitmap(const uInt32* bitmap, uInt32 tx, uInt32 ty, if(!checkBounds(tx, ty) || !checkBounds(tx + w - 1, ty + h - 1)) return; - uInt32* buffer = myPixels + ty * myPitch + tx; + uInt32* buffer = myPixels + (ty * static_cast(myPitch)) + tx; for(uInt32 y = 0; y < h; ++y) { @@ -246,7 +247,7 @@ void FBSurface::drawPixels(const uInt32* data, uInt32 tx, uInt32 ty, uInt32 nump if(!checkBounds(tx, ty) || !checkBounds(tx + numpixels - 1, ty)) return; - uInt32* buffer = myPixels + ty * myPitch + tx; + uInt32* buffer = myPixels + (ty * static_cast(myPitch)) + tx; for(uInt32 i = 0; i < numpixels; ++i) *buffer++ = data[i]; @@ -401,14 +402,14 @@ void FBSurface::drawString(const GUI::Font& font, const string& s, int w2 = font.getStringWidth(ELLIPSIS); // SLOW algorithm to find the acceptable length. But it is good enough for now. - for(size_t i = 0; i < s.size(); ++i) + for(auto c: s) { - const int charWidth = font.getCharWidth(s[i]); + const int charWidth = font.getCharWidth(c); if(w2 + charWidth > w) break; w2 += charWidth; - str += s[i]; + str += c; } str += ELLIPSIS; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 63648b55c..f389c30dd 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -66,7 +66,7 @@ FrameBuffer::FrameBuffer(OSystem& osystem) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FrameBuffer::~FrameBuffer() +FrameBuffer::~FrameBuffer() // NOLINT (we need an empty d'tor) { } @@ -512,7 +512,7 @@ void FrameBuffer::update(UpdateMode mode) success = r.unwindStates(1); // Determine playback speed, the faster the more the states are apart - const Int64 frameCycles = 76 * std::max(myOSystem.console().tia().scanlinesLastFrame(), 240); + const Int64 frameCycles = static_cast(76) * std::max(myOSystem.console().tia().scanlinesLastFrame(), 240); const Int64 intervalFrames = r.getInterval() / frameCycles; const Int64 stateFrames = (r.getCurrentCycles() - prevCycles) / frameCycles; @@ -616,7 +616,7 @@ void FrameBuffer::createMessage(const string& message, MessagePosition position, const int fontHeight = font().getFontHeight(); const int VBORDER = fontHeight / 4; - myMsg.counter = std::min(uInt32(myOSystem.frameRate()) * 2, 120u); // Show message for 2 seconds + myMsg.counter = std::min(uInt32(myOSystem.frameRate()) * 2, 120U); // Show message for 2 seconds if(myMsg.counter == 0) myMsg.counter = 120; @@ -925,7 +925,7 @@ shared_ptr FrameBuffer::allocateSurface( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::deallocateSurface(shared_ptr surface) +void FrameBuffer::deallocateSurface(const shared_ptr& surface) { if(surface) mySurfaceList.remove(surface); diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index ae4722e8b..627e5b027 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -171,7 +171,7 @@ class FrameBuffer @param surface The surface to remove/deallocate */ - void deallocateSurface(shared_ptr surface); + void deallocateSurface(const shared_ptr& surface); /** Set up the TIA/emulation palette. Due to the way the palette is stored, @@ -370,7 +370,7 @@ class FrameBuffer @param pitch The pitch (in bytes) for the pixel data @param rect The bounding rectangle for the buffer */ - void readPixels(uInt8* buffer, uInt32 pitch, const Common::Rect& rect) const { + void readPixels(uInt8* buffer, size_t pitch, const Common::Rect& rect) const { myBackend->readPixels(buffer, pitch, rect); } diff --git a/src/emucore/GlobalKeyHandler.cxx b/src/emucore/GlobalKeyHandler.cxx index bf640b920..9d05bc887 100644 --- a/src/emucore/GlobalKeyHandler.cxx +++ b/src/emucore/GlobalKeyHandler.cxx @@ -67,7 +67,7 @@ bool GlobalKeyHandler::handleEvent(const Event::Type event, bool pressed, bool r if(pressed && !repeated) { const int direction = (event == Event::PreviousSettingGroup ? -1 : +1); - const Group group = static_cast( + const auto group = static_cast( BSPF::clampw(static_cast(getGroup()) + direction, 0, static_cast(Group::NUM_GROUPS) - 1)); const std::map GroupMap = { diff --git a/src/emucore/Keyboard.cxx b/src/emucore/Keyboard.cxx index d6bff252d..b7a09f6f9 100644 --- a/src/emucore/Keyboard.cxx +++ b/src/emucore/Keyboard.cxx @@ -98,7 +98,7 @@ void Keyboard::write(DigitalPin pin, bool value) const ColumnState stateCol1 = processColumn(col1); const ColumnState stateCol2 = processColumn(col2); - setPin(DigitalPin::Six, stateCol2 == ColumnState::gnd ? 0 : 1); + setPin(DigitalPin::Six, stateCol2 != ColumnState::gnd); setPin(AnalogPin::Five, columnStateToAnalogSignal(stateCol1)); setPin(AnalogPin::Nine, columnStateToAnalogSignal(stateCol0)); } diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index e5a2e7ef0..c23631718 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -51,8 +51,8 @@ void M6532::reset() 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")) - for(size_t t = 0; t < myRAM.size(); ++t) - myRAM[t] = mySystem->randGenerator().next(); + for(auto& ram: myRAM) + ram = mySystem->randGenerator().next(); else myRAM.fill(0); @@ -110,7 +110,7 @@ void M6532::update() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void M6532::updateEmulation() { - uInt32 cycles = static_cast(mySystem->cycles() - myLastCycle); + auto cycles = static_cast(mySystem->cycles() - myLastCycle); const uInt32 subTimer = mySubTimer; // Guard against further state changes if the debugger alread forwarded emulation diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index 92df3e013..615e873a2 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -140,7 +140,7 @@ static void MD5Update(MD5_CTX* context, const uInt8* const input, uInt32 i = 0; /* Compute number of bytes mod 64 */ - uInt32 index = static_cast((context->count[0] >> 3) & 0x3F); + auto index = static_cast((context->count[0] >> 3) & 0x3F); /* Update number of bits */ if ((context->count[0] += (inputLen << 3)) < (inputLen << 3)) @@ -176,7 +176,7 @@ static void MD5Final(uInt8 digest[16], MD5_CTX* context) Encode (bits, context->count, 8); /* Pad out to 56 mod 64. */ - const uInt32 index = static_cast((context->count[0] >> 3) & 0x3f); + const auto index = static_cast((context->count[0] >> 3) & 0x3f); const uInt32 padLen = (index < 56) ? (56 - index) : (120 - index); MD5Update (context, PADDING, padLen); @@ -320,17 +320,17 @@ string hash(const uInt8* buffer, size_t length) static constexpr char hex[] = "0123456789abcdef"; MD5_CTX context{}; uInt8 md5[16] = {0}; - const uInt32 len32 = static_cast(length); // Always use 32-bit for now + const auto len32 = static_cast(length); // Always use 32-bit for now MD5Init(&context); MD5Update(&context, buffer, len32); MD5Final(md5, &context); string result; - for(int t = 0; t < 16; ++t) + for(auto c: md5) { - result += hex[(md5[t] >> 4) & 0x0f]; - result += hex[md5[t] & 0x0f]; + result += hex[(c >> 4) & 0x0f]; + result += hex[c & 0x0f]; } return result; diff --git a/src/emucore/MT24LC256.cxx b/src/emucore/MT24LC256.cxx index 7c254fa59..9993a007b 100644 --- a/src/emucore/MT24LC256.cxx +++ b/src/emucore/MT24LC256.cxx @@ -175,6 +175,7 @@ void MT24LC256::jpee_init() jpee_pagemask = PAGE_SIZE - 1; jpee_smallmode = 0; jpee_logmode = -1; + jpee_packet.fill(0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 61f9c42f7..95e80a5e0 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -941,7 +941,7 @@ void OSystem::mainLoop() virtualTime = high_resolution_clock::now(); } - double timesliceSeconds; + double timesliceSeconds; // NOLINT if (myEventHandler->state() == EventHandlerState::EMULATION) // Dispatch emulation and render frame (if applicable) diff --git a/src/emucore/OSystemStandalone.cxx b/src/emucore/OSystemStandalone.cxx index abce35399..225f434d4 100644 --- a/src/emucore/OSystemStandalone.cxx +++ b/src/emucore/OSystemStandalone.cxx @@ -34,22 +34,23 @@ string OSystemStandalone::describePresistence() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - shared_ptr OSystemStandalone::getSettingsRepository() { - return shared_ptr(myStellaDb, &myStellaDb->settingsRepository()); + return {myStellaDb, &myStellaDb->settingsRepository()}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - shared_ptr OSystemStandalone::getPropertyRepository() { - return shared_ptr(myStellaDb, &myStellaDb->propertyRepository()); + return {myStellaDb, &myStellaDb->propertyRepository()}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - shared_ptr OSystemStandalone::getHighscoreRepository() { - return shared_ptr(myStellaDb, &myStellaDb->highscoreRepository()); + return {myStellaDb, &myStellaDb->highscoreRepository()}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void OSystemStandalone::getBaseDirectories(string& basedir, string& homedir, - bool useappdir, const string& usedir) -{} +void OSystemStandalone::getBaseDirectories( + string& basedir, string& homedir, bool useappdir, const string& usedir) +{ +} diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index e19e39456..16164edc1 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -145,9 +145,7 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::swapEvents(Event::Type& event1, Event::Type& event2) { - Event::Type swappedEvent; - - swappedEvent = event1; + Event::Type swappedEvent = event1; event1 = event2; event2 = swappedEvent; } diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index 0edf4fb90..aff571c12 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -48,14 +48,16 @@ class PlusROMRequest { public: struct Destination { - Destination(string _host, string _path) : host{_host}, path{_path} {} + Destination(const string& _host, const string& _path) + : host{_host}, path{_path} {} string host; string path; }; struct PlusStoreId { - PlusStoreId(string _nick, string _id) : nick{_nick}, id{_id} {} + PlusStoreId(const string& _nick, const string& _id) + : nick{_nick}, id{_id} {} string nick; string id; @@ -70,13 +72,14 @@ class PlusROMRequest { public: - PlusROMRequest(Destination destination, PlusStoreId id, const uInt8* request, - uInt8 requestSize) + PlusROMRequest(const Destination& destination, const PlusStoreId& id, + const uInt8* request, uInt8 requestSize) : myState{State::created}, myDestination{destination}, myId{id}, myRequestSize{requestSize} { memcpy(myRequest.data(), request, myRequestSize); } + ~PlusROMRequest() = default; #if defined(HTTP_LIB_SUPPORT) void execute() { @@ -153,16 +156,16 @@ class PlusROMRequest { myState = State::done; } - State getState() const { + [[nodiscard]] State getState() const { return myState; } - const Destination& getDestination() const + [[nodiscard]] const Destination& getDestination() const { return myDestination; } - const PlusStoreId& getPlusStoreId() const + [[nodiscard]] const PlusStoreId& getPlusStoreId() const { return myId; } @@ -170,10 +173,10 @@ class PlusROMRequest { std::pair getResponse() { if (myState != State::done) throw runtime_error("invalid access to response"); - return std::pair( + return { myResponse.size() - 1, myResponse.size() > 1 ? reinterpret_cast(myResponse.data() + 1) : nullptr - ); + }; } #endif diff --git a/src/emucore/Props.cxx b/src/emucore/Props.cxx index 074d58292..8c5548fe1 100644 --- a/src/emucore/Props.cxx +++ b/src/emucore/Props.cxx @@ -63,7 +63,7 @@ bool Properties::save(KeyValueRepository& repo) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Properties::set(PropType key, const string& value) { - const size_t pos = static_cast(key); + const auto pos = static_cast(key); if(pos < myProperties.size()) { myProperties[pos] = value; @@ -188,8 +188,7 @@ void Properties::print() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Properties::reset(PropType key) { - const size_t pos = static_cast(key); - + const auto pos = static_cast(key); myProperties[pos] = ourDefaultProperties[pos]; } diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index f3e00a921..7445af5b2 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -35,7 +35,7 @@ PropertiesSet::PropertiesSet() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PropertiesSet::setRepository(shared_ptr repository) { - myRepository = repository; + myRepository = std::move(repository); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/SaveKey.cxx b/src/emucore/SaveKey.cxx index f7fcee62b..726ce398d 100644 --- a/src/emucore/SaveKey.cxx +++ b/src/emucore/SaveKey.cxx @@ -39,7 +39,7 @@ SaveKey::SaveKey(Jack jack, const Event& event, const System& system, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SaveKey::~SaveKey() +SaveKey::~SaveKey() // NOLINT (we need an empty d'tor) { } diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index 546379201..c156e7984 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -110,7 +110,7 @@ size_t Serializer::size() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 Serializer::getByte() const { - char buf; + char buf{0}; myStream->read(&buf, 1); return buf; @@ -125,7 +125,7 @@ void Serializer::getByteArray(uInt8* array, size_t size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt16 Serializer::getShort() const { - uInt16 val = 0; + uInt16 val{0}; myStream->read(reinterpret_cast(&val), sizeof(uInt16)); return val; @@ -140,7 +140,7 @@ void Serializer::getShortArray(uInt16* array, size_t size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 Serializer::getInt() const { - uInt32 val = 0; + uInt32 val{0}; myStream->read(reinterpret_cast(&val), sizeof(uInt32)); return val; @@ -155,7 +155,7 @@ void Serializer::getIntArray(uInt32* array, size_t size) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt64 Serializer::getLong() const { - uInt64 val = 0; + uInt64 val{0}; myStream->read(reinterpret_cast(&val), sizeof(uInt64)); return val; @@ -164,7 +164,7 @@ uInt64 Serializer::getLong() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - double Serializer::getDouble() const { - double val = 0.0; + double val{0.0}; myStream->read(reinterpret_cast(&val), sizeof(double)); return val; @@ -238,7 +238,7 @@ void Serializer::putDouble(double value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putString(const string& str) { - const uInt32 len = static_cast(str.length()); + const auto len = static_cast(str.length()); putInt(len); myStream->write(str.data(), len); } diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 757412a80..269f1aab0 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -686,7 +686,7 @@ void Settings::usage() const << " by attempting to use the application directory\n" << " -plusroms.nick Define a nickname for the PlusROMs backends.\n" << " -plusroms.id Define a temporary ID for the PlusROMs backends.\n" - << " -filterbstypes <0|1> Filter bankswitch type list by ROM size.\n" + << " -filterbstypes <0|1> Filter bankswitch type list by ROM size.\n" << " -help Show the text you're now reading\n" #ifdef DEBUGGER_SUPPORT << endl @@ -852,7 +852,7 @@ void Settings::migrateOne() const int version = getInt(SETTINGS_VERSION_KEY); if (version >= SETTINGS_VERSION) return; - switch (version) { + switch (version) { // NOLINT (could be written as IF/ELSE) case 0: #if defined BSPF_MACOS || defined DARWIN setPermanent("video", ""); diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 48679adf7..e9e63320d 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -86,7 +86,7 @@ TIASurface::TIASurface(OSystem& system) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -TIASurface::~TIASurface() +TIASurface::~TIASurface() // NOLINT (we need an empty d'tor) { } @@ -135,11 +135,11 @@ const FBSurface& TIASurface::baseSurface(Common::Rect& rect) const rect.setBounds(0, 0, width, height); // Fill the surface with pixels from the TIA, scaled 2x horizontally - uInt32 *buf_ptr, pitch; + uInt32 *buf_ptr{nullptr}, pitch{0}; myBaseTiaSurface->basePtr(buf_ptr, pitch); - for(uInt32 y = 0; y < height; ++y) - for(uInt32 x = 0; x < width; ++x) + for(size_t y = 0; y < height; ++y) + for(size_t x = 0; x < width; ++x) *buf_ptr++ = myPalette[*(myTIA->frameBuffer() + y * tiaw + x / 2)]; return *myBaseTiaSurface; @@ -201,7 +201,7 @@ void TIASurface::changeNTSC(int direction) void TIASurface::setNTSCAdjustable(int direction) { string text, valueText; - Int32 value; + Int32 value{0}; setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().selectAdjustable(direction, text, valueText, value); @@ -212,7 +212,7 @@ void TIASurface::setNTSCAdjustable(int direction) void TIASurface::changeNTSCAdjustable(int adjustable, int direction) { string text, valueText; - Int32 newValue; + Int32 newValue{0}; setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().changeAdjustable(adjustable, direction, text, valueText, newValue); @@ -224,7 +224,7 @@ void TIASurface::changeNTSCAdjustable(int adjustable, int direction) void TIASurface::changeCurrentNTSCAdjustable(int direction) { string text, valueText; - Int32 newValue; + Int32 newValue{0}; setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().changeCurrentAdjustable(direction, text, valueText, newValue); @@ -410,16 +410,16 @@ void TIASurface::createScanlineSurface() { 0xff000000, 0xff000000, 0xff000000 }, }), }}; - const int mask = static_cast(scanlineMaskType()); - const uInt32 pWidth = static_cast(Patterns[mask].data[0].size()); - const uInt32 pHeight = static_cast(Patterns[mask].data.size() / Patterns[mask].vRepeats); + const auto mask = static_cast(scanlineMaskType()); + const auto pWidth = static_cast(Patterns[mask].data[0].size()); + const auto pHeight = static_cast(Patterns[mask].data.size() / Patterns[mask].vRepeats); const uInt32 vRepeats = Patterns[mask].vRepeats; // Single width pattern need no horizontal repeats const uInt32 width = pWidth > 1 ? TIAConstants::frameBufferWidth * pWidth : 1; // TODO: Idea, alternative mask pattern if destination is scaled smaller than mask height? const uInt32 height = myTIA->height()* pHeight; // vRepeats are not used here // Copy repeated pattern into surface data - std::vectordata(width * height); + std::vector data(static_cast(width) * height); for(uInt32 i = 0; i < width * height; ++i) data[i] = Patterns[mask].data[(i / width) % (pHeight * vRepeats)][i % pWidth]; @@ -498,12 +498,12 @@ inline uInt32 TIASurface::averageBuffers(uInt32 bufOfs) const uInt32 p = myPrevRGBFramebuffer[bufOfs]; // Split into RGB values - const uInt8 rc = static_cast(c >> 16), - gc = static_cast(c >> 8), - bc = static_cast(c), - rp = static_cast(p >> 16), - gp = static_cast(p >> 8), - bp = static_cast(p); + const auto rc = static_cast(c >> 16), + gc = static_cast(c >> 8), + bc = static_cast(c), + rp = static_cast(p >> 16), + gp = static_cast(p >> 8), + bp = static_cast(p); // Mix current calculated buffer with previous calculated buffer (50:50) const uInt8 rn = (rc + rp) / 2; @@ -519,7 +519,7 @@ void TIASurface::render(bool shade) { const uInt32 width = myTIA->width(), height = myTIA->height(); - uInt32 *out, outPitch; + uInt32 *out{nullptr}, outPitch{0}; myTiaSurface->basePtr(out, outPitch); switch(myFilter) @@ -617,9 +617,8 @@ void TIASurface::renderForSnapshot() // is brittle, especially since rendering can happen in a different thread. const uInt32 width = myTIA->width(), height = myTIA->height(); - uInt32 pos = 0; - uInt32 *outPtr, outPitch; - + uInt32 pos{0}; + uInt32 *outPtr{nullptr}, outPitch{0}; myTiaSurface->basePtr(outPtr, outPitch); mySaveSnapFlag = false; diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 2cc25f357..1a3ea6546 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -699,7 +699,7 @@ uInt32 Thumbulator::read32(uInt32 addr) default: #endif { - switch(addr) + switch(addr) // NOLINT (FIXME: missing default) { #ifdef THUMB_CYCLE_COUNT case 0xE01FC000: //MAMCR @@ -717,12 +717,12 @@ uInt32 Thumbulator::read32(uInt32 addr) #ifdef THUMB_CYCLE_COUNT if(T0TCR & 1) // timer is counting - data = T0TC + (tim0Total + (_totalCycles - tim0Start)) * _armCyclesFactor; + data = T0TC + (tim0Total + (_totalCycles - tim0Start)) * _armCyclesFactor; // NOLINT else // timer is disabled - data = T0TC + tim0Total * _armCyclesFactor; + data = T0TC + tim0Total * _armCyclesFactor; // NOLINT #else - data = T0TC; + data = T0TC; // NOLINT #endif break; #endif @@ -832,10 +832,8 @@ void Thumbulator::do_nflag(uInt32 x) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Thumbulator::do_cflag(uInt32 a, uInt32 b, uInt32 c) { - uInt32 rc; - - rc = (a & 0x7FFFFFFF) + (b & 0x7FFFFFFF) + c; //carry in - rc = (rc >> 31) + (a >> 31) + (b >> 31); //carry out + uInt32 rc = (a & 0x7FFFFFFF) + (b & 0x7FFFFFFF) + c; //carry in + rc = (rc >> 31) + (a >> 31) + (b >> 31); //carry out if(rc & 2) cpsr |= CPSR_C; else @@ -1095,9 +1093,9 @@ Thumbulator::Op Thumbulator::decodeInstructionWord(uint16_t inst) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int Thumbulator::execute() { - uInt32 pc, sp, inst, ra, rb, rc, rm, rd, rn, rs, op; + uInt32 sp, inst, ra, rb, rc, rm, rd, rn, rs, op; // NOLINT - pc = read_register(15); + uInt32 pc = read_register(15); const uInt32 instructionPtr = pc - 2; inst = fetch16(instructionPtr); @@ -1110,7 +1108,7 @@ int Thumbulator::execute() ++_stats.instructions; #endif - Op decodedOp; + Op decodedOp{}; #ifndef UNSAFE_OPTIMIZATIONS if ((instructionPtr & 0xF0000000) == 0 && instructionPtr < romSize) decodedOp = decodedRom[instructionPtr >> 1]; diff --git a/src/emucore/tia/Audio.cxx b/src/emucore/tia/Audio.cxx index b96e06584..bb97c5eb6 100644 --- a/src/emucore/tia/Audio.cxx +++ b/src/emucore/tia/Audio.cxx @@ -102,8 +102,10 @@ void Audio::addSample(uInt8 sample0, uInt8 sample1) if(!myAudioQueue) return; if(myAudioQueue->isStereo()) { - myCurrentFragment[2 * mySampleIndex] = myMixingTableIndividual[sample0]; - myCurrentFragment[2 * mySampleIndex + 1] = myMixingTableIndividual[sample1]; + myCurrentFragment[static_cast(2 * mySampleIndex)] = + myMixingTableIndividual[sample0]; + myCurrentFragment[static_cast(2 * mySampleIndex + 1)] = + myMixingTableIndividual[sample1]; } else { myCurrentFragment[mySampleIndex] = myMixingTableSum[sample0 + sample1]; diff --git a/src/emucore/tia/DelayQueueIteratorImpl.hxx b/src/emucore/tia/DelayQueueIteratorImpl.hxx index 4526aed6b..a3c923b5c 100644 --- a/src/emucore/tia/DelayQueueIteratorImpl.hxx +++ b/src/emucore/tia/DelayQueueIteratorImpl.hxx @@ -60,7 +60,7 @@ DelayQueueIteratorImpl::DelayQueueIteratorImpl( ) : myDelayQueue(delayQueue) { - while (myDelayQueue.myMembers[currentIndex()].mySize == 0 && isValid()) + while (myDelayQueue.myMembers[currentIndex()].mySize == 0 && isValid()) // NOLINT myDelayCycle++; } diff --git a/src/emucore/tia/DrawCounterDecodes.cxx b/src/emucore/tia/DrawCounterDecodes.cxx index e0b89c7c1..65a0c40b6 100644 --- a/src/emucore/tia/DrawCounterDecodes.cxx +++ b/src/emucore/tia/DrawCounterDecodes.cxx @@ -38,9 +38,11 @@ DrawCounterDecodes& DrawCounterDecodes::DrawCounterDecodes::get() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DrawCounterDecodes::DrawCounterDecodes() { - uInt8 *decodeTables[] = {myDecodes0, myDecodes1, myDecodes2, myDecodes3, myDecodes4, myDecodes6}; + uInt8* decodeTables[] = { + myDecodes0, myDecodes1, myDecodes2, myDecodes3, myDecodes4, myDecodes6 + }; - for (auto decodes: decodeTables) + for (auto* decodes: decodeTables) { std::fill_n(decodes, 160, 0); // TJ: magic number 160 = pixel/scanline decodes[156] = 1; // TJ: set for all copy pattern (first copy) diff --git a/src/emucore/tia/Player.cxx b/src/emucore/tia/Player.cxx index af6978b9f..8559db9f6 100644 --- a/src/emucore/tia/Player.cxx +++ b/src/emucore/tia/Player.cxx @@ -37,7 +37,7 @@ void Player::reset() myCopy = 1; myPatternOld = 0; myPatternNew = 0; - myIsReflected = 0; + myIsReflected = false; myIsDelaying = false; myColor = myObjectColor = myDebugColor = 0; myDebugEnabled = false; diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 5b94814a0..cde71f2dd 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -1393,7 +1393,9 @@ void TIA::onFrameComplete() // Blank out any extra lines not drawn this frame const Int32 missingScanlines = myFrameManager->missingScanlines(); if (missingScanlines > 0) - std::fill_n(myBackBuffer.begin() + TIAConstants::H_PIXEL * myFrameManager->getY(), missingScanlines * TIAConstants::H_PIXEL, 0); + std::fill_n(myBackBuffer.begin() + + static_cast(TIAConstants::H_PIXEL * myFrameManager->getY()), + missingScanlines * TIAConstants::H_PIXEL, 0); myFrontBuffer = myBackBuffer; @@ -1521,11 +1523,14 @@ void TIA::tickHframe() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::applyRsync() { - const uInt32 x = myHctr > TIAConstants::H_BLANK_CLOCKS ? myHctr - TIAConstants::H_BLANK_CLOCKS : 0; + const uInt32 x = myHctr > TIAConstants::H_BLANK_CLOCKS + ? myHctr - TIAConstants::H_BLANK_CLOCKS : 0; myHctrDelta = TIAConstants::H_CLOCKS - 3 - myHctr; if (myFrameManager->isRendering()) - std::fill_n(myBackBuffer.begin() + myFrameManager->getY() * TIAConstants::H_PIXEL + x, TIAConstants::H_PIXEL - x, 0); + std::fill_n(myBackBuffer.begin() + + static_cast(myFrameManager->getY() * TIAConstants::H_PIXEL + x), + TIAConstants::H_PIXEL - x, 0); myHctr = TIAConstants::H_CLOCKS - 3; } @@ -1568,12 +1573,12 @@ void TIA::cloneLastLine() } else { - const auto y = myFrameManager->getY(); + const size_t y = myFrameManager->getY(); if(!myFrameManager->isRendering() || y == 0) return; - std::copy_n(myBackBuffer.begin() + (y - 1) * TIAConstants::H_PIXEL, TIAConstants::H_PIXEL, - myBackBuffer.begin() + y * TIAConstants::H_PIXEL); + std::copy_n(myBackBuffer.begin() + (y - 1) * TIAConstants::H_PIXEL, + TIAConstants::H_PIXEL, myBackBuffer.begin() + y * TIAConstants::H_PIXEL); } } @@ -1679,7 +1684,9 @@ void TIA::flushLineCache() void TIA::clearHmoveComb() { if (myFrameManager->isRendering() && myHstate == HState::blank) - std::fill_n(myBackBuffer.begin() + myFrameManager->getY() * TIAConstants::H_PIXEL, 8, myColorHBlank); + std::fill_n(myBackBuffer.begin() + + static_cast(myFrameManager->getY() * TIAConstants::H_PIXEL), + 8, myColorHBlank); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/frame-manager/AbstractFrameManager.cxx b/src/emucore/tia/frame-manager/AbstractFrameManager.cxx index 92dacfb55..d69476dd8 100644 --- a/src/emucore/tia/frame-manager/AbstractFrameManager.cxx +++ b/src/emucore/tia/frame-manager/AbstractFrameManager.cxx @@ -105,7 +105,7 @@ void AbstractFrameManager::layout(FrameLayout layout) myLayout = layout; - onLayoutChange(); + onLayoutChange(); // NOLINT } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index a330b3720..3d7dc8726 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -59,9 +59,8 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, wid.push_back(myNextButton); xpos = _w - buttonWidth - HBORDER; - ButtonWidget* b = - new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, - "Close", GuiObject::kCloseCmd); + auto* b = new ButtonWidget(this, font, xpos, ypos, + buttonWidth, buttonHeight, "Close", GuiObject::kCloseCmd); wid.push_back(b); addCancelWidget(b); @@ -80,8 +79,8 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, xpos = HBORDER * 2; ypos += lineHeight + VGAP * 2; for(int i = 0; i < myLinesPerPage; i++) { - StaticTextWidget* s = new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2, - fontHeight, "", TextAlign::Left, kNone); + auto* s = new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2, + fontHeight, "", TextAlign::Left, kNone); s->setID(i); myDesc.push_back(s); myDescStr.emplace_back(""); @@ -94,7 +93,7 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AboutDialog::~AboutDialog() +AboutDialog::~AboutDialog() // NOLINT (we need an empty d'tor) { } diff --git a/src/gui/CheckListWidget.cxx b/src/gui/CheckListWidget.cxx index 20c57c8ec..58968ea58 100644 --- a/src/gui/CheckListWidget.cxx +++ b/src/gui/CheckListWidget.cxx @@ -35,8 +35,8 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, // Create a CheckboxWidget for each row in the list for(int i = 0; i < _rows; ++i) { - CheckboxWidget* t = new CheckboxWidget(boss, font, _x + 2, ypos, "", - CheckboxWidget::kCheckActionCmd); + auto* t = new CheckboxWidget(boss, font, _x + 2, ypos, "", + CheckboxWidget::kCheckActionCmd); t->setTextColor(kTextColor); t->setTarget(this); t->setID(i); @@ -135,11 +135,13 @@ void CheckListWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect CheckListWidget::getEditRect() const { - const int yoffset = (_selectedItem - _currentPos) * _lineHeight, - xoffset = CheckboxWidget::boxSize(_font) + 10; + const uInt32 yoffset = (_selectedItem - _currentPos) * _lineHeight, + xoffset = CheckboxWidget::boxSize(_font) + 10; - return Common::Rect(2 + xoffset, 1 + yoffset, - _w - (xoffset - 15), _lineHeight + yoffset); + return { + 2 + xoffset, 1 + yoffset, + _w - (xoffset - 15), _lineHeight + yoffset + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/CommandDialog.cxx b/src/gui/CommandDialog.cxx index e19b286c5..90f0a8bb2 100644 --- a/src/gui/CommandDialog.cxx +++ b/src/gui/CommandDialog.cxx @@ -52,8 +52,8 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent) const auto ADD_CD_BUTTON = [&](const string& label, int cmd, Event::Type event1 = Event::NoType, Event::Type event2 = Event::NoType) { - ButtonWidget* b = new ButtonWidget(this, _font, xoffset, yoffset, - buttonWidth, buttonHeight, label, cmd); + auto* b = new ButtonWidget(this, _font, xoffset, yoffset, + buttonWidth, buttonHeight, label, cmd); b->setToolTip(event1, event2); yoffset += buttonHeight + VGAP; return b; diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 3e1d5e975..f15c4a960 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -103,8 +103,9 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) // settings set mySettingsGroupEmulation = new RadioButtonGroup(); - RadioButtonWidget* r = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, - "Player settings", mySettingsGroupEmulation, kPlrSettings); + auto* r = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, + "Player settings", mySettingsGroupEmulation, + kPlrSettings); r->setToolTip(Event::ToggleDeveloperSet); wid.push_back(r); ypos += lineHeight + VGAP; @@ -241,8 +242,9 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font) // settings set mySettingsGroupTia = new RadioButtonGroup(); - RadioButtonWidget* r = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, - "Player settings", mySettingsGroupTia, kPlrSettings); + auto* r = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, + "Player settings", mySettingsGroupTia, + kPlrSettings); r->setToolTip(Event::ToggleDeveloperSet); wid.push_back(r); ypos += lineHeight + VGAP; @@ -359,8 +361,9 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font) // settings set mySettingsGroupVideo = new RadioButtonGroup(); - RadioButtonWidget* r = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, - "Player settings", mySettingsGroupVideo, kPlrSettings); + auto* r = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, + "Player settings", mySettingsGroupVideo, + kPlrSettings); r->setToolTip(Event::ToggleDeveloperSet); wid.push_back(r); ypos += lineHeight + VGAP; @@ -518,8 +521,9 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) // settings set mySettingsGroupTM = new RadioButtonGroup(); - RadioButtonWidget* r = new RadioButtonWidget(myTab, font, xpos, ypos + 1, - "Player settings", mySettingsGroupTM, kPlrSettings); + auto* r = new RadioButtonWidget(myTab, font, xpos, ypos + 1, + "Player settings", mySettingsGroupTM, + kPlrSettings); r->setToolTip(Event::ToggleDeveloperSet); wid.push_back(r); ypos += lineHeight + VGAP; @@ -899,7 +903,8 @@ void DeveloperDialog::saveConfig() void DeveloperDialog::setDefaults() { const bool devSettings = mySettings; - const SettingsSet set = static_cast(mySettingsGroupEmulation->getSelected()); + const auto set = static_cast + (mySettingsGroupEmulation->getSelected()); switch(myTab->getActiveTab()) { @@ -1369,7 +1374,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color) myDbgColour[idx]->setSelectedIndex(color); // make sure the selected debug colors are all different - std::array usedCol = {0}; + std::array usedCol = {false}; // identify used colors for(int i = 0; i < DEBUG_COLORS; ++i) diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 652cf281c..0a84c1696 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -169,9 +169,10 @@ void Dialog::initHelp() { string key = instance().eventHandler().getMappingDesc(Event::UIHelp, EventMode::kMenuMode); - _helpWidget = new ButtonWidget(this, _font, _w - _font.getMaxCharWidth() * 3.5, 0, - _font.getMaxCharWidth() * 3.5 + 0.5, buttonHeight(), "?", - kHelpCmd); + _helpWidget = new ButtonWidget(this, _font, + _w - _font.getMaxCharWidth() * 3.5, 0, + _font.getMaxCharWidth() * 3.5 + 0.5, buttonHeight(), "?", // NOLINT + kHelpCmd); _helpWidget->setBGColor(kColorTitleBar); _helpWidget->setTextColor(kColorTitleText); _helpWidget->setToolTip("Click or press " + key + " for help."); diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index f7924dd01..de3bdb61b 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -98,7 +98,10 @@ void EditTextWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect EditTextWidget::getEditRect() const { - return Common::Rect(_textOfs, 1, _w - _textOfs, _h); + return { + static_cast(_textOfs), 1, + static_cast(_w - _textOfs), static_cast(_h) + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/EmulationDialog.cxx b/src/gui/EmulationDialog.cxx index 753504977..ec25db59a 100644 --- a/src/gui/EmulationDialog.cxx +++ b/src/gui/EmulationDialog.cxx @@ -140,9 +140,8 @@ EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, "When entering/exiting emulation:"); ypos += lineHeight + VGAP; mySaveOnExitGroup = new RadioButtonGroup(); - RadioButtonWidget* r; - r = new RadioButtonWidget(this, font, xpos, ypos + 1, - "Do nothing", mySaveOnExitGroup); + auto* r = new RadioButtonWidget(this, font, xpos, ypos + 1, + "Do nothing", mySaveOnExitGroup); wid.push_back(r); ypos += lineHeight + VGAP; r = new RadioButtonWidget(this, font, xpos, ypos + 1, @@ -159,7 +158,6 @@ EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, myAutoSlotWidget = new CheckboxWidget(this, font, xpos, ypos + 1, "Automatically change save state slots"); myAutoSlotWidget->setToolTip("Cycle to next state slot after saving.", Event::ToggleAutoSlot); wid.push_back(myAutoSlotWidget); - ypos += lineHeight + VGAP; // Add Defaults, OK and Cancel buttons addDefaultsOKCancelBGroup(wid, font); diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index 38b5e5644..fe06f38af 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -128,8 +128,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font, // Show message for currently selected event xpos = HBORDER; ypos = myActionsList->getBottom() + VGAP * 2; - StaticTextWidget* t; - t = new StaticTextWidget(boss, font, xpos, ypos+2, "Action"); + auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, "Action"); myKeyMapping = new EditTextWidget(boss, font, xpos + t->getWidth() + fontWidth, ypos, _w - xpos - t->getWidth() - fontWidth - HBORDER + 2, diff --git a/src/gui/FavoritesManager.cxx b/src/gui/FavoritesManager.cxx index 90ad44513..bebbf6fe0 100644 --- a/src/gui/FavoritesManager.cxx +++ b/src/gui/FavoritesManager.cxx @@ -289,9 +289,9 @@ void FavoritesManager::incPopular(const string& path) if(myPopularMap.size() >= max_popular) { PopularList sortedList = sortedPopularList(); // sorted by frequency! - for(auto item = sortedList.cbegin(); item != sortedList.cend(); ++item) + for(const auto& item: sortedList) { - const auto entry = myPopularMap.find(item->first); + const auto entry = myPopularMap.find(item.first); if(entry != myPopularMap.end()) { if(entry->second >= scale * (1.0 - factor)) diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 020923df8..3f5f99a83 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -76,7 +76,7 @@ void FileListWidget::setDirectory(const FSNode& node, const string& select) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FileListWidget::setLocation(const FSNode& node, const string select) +void FileListWidget::setLocation(const FSNode& node, const string& select) { progress().resetProgress(); progress().open(); diff --git a/src/gui/FileListWidget.hxx b/src/gui/FileListWidget.hxx index 7cca110cf..e39cec905 100644 --- a/src/gui/FileListWidget.hxx +++ b/src/gui/FileListWidget.hxx @@ -137,7 +137,7 @@ class FileListWidget : public StringListWidget protected: /** Very similar to setDirectory(), but also updates the history */ - void setLocation(const FSNode& node, const string select); + void setLocation(const FSNode& node, const string& select); /** Select to home directory */ void selectHomeDir(); /** Select previous directory in history (if applicable) */ diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index d545d56ae..4133b0be2 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -217,8 +217,8 @@ void GameInfoDialog::addConsoleTab() new StaticTextWidget(myTab, _font, xpos, ypos + 1, "TV type"); myTVTypeGroup = new RadioButtonGroup(); - RadioButtonWidget* r = new RadioButtonWidget(myTab, _font, xpos + lwidth, ypos + 1, - "Color", myTVTypeGroup); + auto* r = new RadioButtonWidget(myTab, _font, xpos + lwidth, ypos + 1, + "Color", myTVTypeGroup); r->setToolTip(Event::ConsoleColor, Event::ConsoleColorToggle); wid.push_back(r); ypos += lineHeight; @@ -686,7 +686,7 @@ void GameInfoDialog::addHighScoresTab() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -GameInfoDialog::~GameInfoDialog() +GameInfoDialog::~GameInfoDialog() // NOLINT (we need an empty d'tor) { } @@ -1307,14 +1307,14 @@ void GameInfoDialog::eraseEEPROM() if(lport.type() == Controller::Type::SaveKey || lport.type() == Controller::Type::AtariVox) { - SaveKey& skey = static_cast(lport); + auto& skey = static_cast(lport); skey.eraseCurrent(); } if(rport.type() == Controller::Type::SaveKey || rport.type() == Controller::Type::AtariVox) { - SaveKey& skey = static_cast(rport); + auto& skey = static_cast(rport); skey.eraseCurrent(); } } diff --git a/src/gui/GlobalPropsDialog.cxx b/src/gui/GlobalPropsDialog.cxx index 9dfd54549..1ca293d15 100644 --- a/src/gui/GlobalPropsDialog.cxx +++ b/src/gui/GlobalPropsDialog.cxx @@ -114,7 +114,7 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font) // Start with console joystick direction/buttons held down xpos = fontWidth * 4; ypos += infofont.getLineHeight() + VGAP * 2; - ypos = addHoldWidgets(font, xpos, ypos, wid); + addHoldWidgets(font, xpos, ypos, wid); // Add message concerning usage xpos = HBORDER; @@ -143,7 +143,7 @@ int GlobalPropsDialog::addHoldWidgets(const GUI::Font& font, int x, int y, const int xdiff = CheckboxWidget::boxSize(font) - 9; // Left joystick - StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos + 2, "Left joy"); + auto* t = new StaticTextWidget(this, font, xpos, ypos + 2, "Left joy"); xpos += t->getWidth()/2 - xdiff - 2; ypos += t->getHeight() + VGAP; myJoy[kJ0Up] = new CheckboxWidget(this, font, xpos, ypos, "", kJ0Up); ypos += myJoy[kJ0Up]->getHeight() * 2 + VGAP * 2; diff --git a/src/gui/HelpDialog.cxx b/src/gui/HelpDialog.cxx index 569a0fd6b..fcd994162 100644 --- a/src/gui/HelpDialog.cxx +++ b/src/gui/HelpDialog.cxx @@ -67,9 +67,8 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent, wid.push_back(myUpdateButton); xpos = _w - closeButtonWidth - HBORDER; - ButtonWidget* b = - new ButtonWidget(this, font, xpos, ypos, closeButtonWidth, buttonHeight, - "Close", GuiObject::kCloseCmd); + auto* b = new ButtonWidget(this, font, xpos, ypos, closeButtonWidth, + buttonHeight, "Close", GuiObject::kCloseCmd); wid.push_back(b); addCancelWidget(b); diff --git a/src/gui/HighScoresDialog.cxx b/src/gui/HighScoresDialog.cxx index 3debb94b4..27f038469 100644 --- a/src/gui/HighScoresDialog.cxx +++ b/src/gui/HighScoresDialog.cxx @@ -132,21 +132,22 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent, int ypos = VBORDER + _th; ypos += lineHeight + VGAP * 2; // space for game name - StaticTextWidget* s = new StaticTextWidget(this, _font, xpos, ypos + 1, "Variation "); + auto* s = new StaticTextWidget(this, _font, xpos, ypos + 1, "Variation "); myVariationPopup = new PopUpWidget(this, _font, s->getRight(), ypos, - _font.getStringWidth("256"), lineHeight, items, "", 0, - kVariationChanged); + _font.getStringWidth("256"), lineHeight, items, "", 0, kVariationChanged); wid.push_back(myVariationPopup); const int bWidth = fontWidth * 5; - myPrevVarButton = new ButtonWidget(this, _font, xposDelete + fontWidth * 2 - bWidth * 2 - BUTTON_GAP, ypos - 1, - bWidth, myVariationPopup->getHeight(), - smallFont ? PREV_GFX.data() : PREV_GFX_LARGE.data(), - buttonSize, buttonSize, kPrevVariation); + myPrevVarButton = new ButtonWidget(this, _font, + xposDelete + fontWidth * 2 - bWidth * 2 - BUTTON_GAP, ypos - 1, + bWidth, myVariationPopup->getHeight(), + smallFont ? PREV_GFX.data() : PREV_GFX_LARGE.data(), + buttonSize, buttonSize, kPrevVariation); wid.push_back(myPrevVarButton); - myNextVarButton = new ButtonWidget(this, _font, xposDelete + fontHeight - bWidth, ypos - 1, - bWidth, myVariationPopup->getHeight(), - smallFont ? NEXT_GFX.data() : NEXT_GFX_LARGE.data(), - buttonSize, buttonSize, kNextVariation); + myNextVarButton = new ButtonWidget(this, _font, + xposDelete + fontHeight - bWidth, ypos - 1, + bWidth, myVariationPopup->getHeight(), + smallFont ? NEXT_GFX.data() : NEXT_GFX_LARGE.data(), + buttonSize, buttonSize, kNextVariation); wid.push_back(myNextVarButton); ypos += lineHeight + VGAP * 4; @@ -211,7 +212,7 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -HighScoresDialog::~HighScoresDialog() +HighScoresDialog::~HighScoresDialog() // NOLINT (we need an empty d'tor) { } diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index f34830c77..1ac29702d 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -93,7 +93,7 @@ InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -InputDialog::~InputDialog() +InputDialog::~InputDialog() // NOLINT (we need an empty d'tor) { } @@ -696,13 +696,13 @@ void InputDialog::eraseEEPROM() if(lport.type() == Controller::Type::SaveKey || lport.type() == Controller::Type::AtariVox) { - SaveKey& skey = static_cast(lport); + auto& skey = static_cast(lport); skey.eraseCurrent(); } if(rport.type() == Controller::Type::SaveKey || rport.type() == Controller::Type::AtariVox) { - SaveKey& skey = static_cast(rport); + auto& skey = static_cast(rport); skey.eraseCurrent(); } } @@ -728,18 +728,20 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd, break; case kDDeadzoneChanged: - myDigitalDeadzone->setValueLabel(std::round(Controller::digitalDeadZoneValue(myDigitalDeadzone->getValue()) * 100.f / - (Paddles::ANALOG_RANGE / 2))); + myDigitalDeadzone->setValueLabel(std::round( + Controller::digitalDeadZoneValue(myDigitalDeadzone->getValue()) * + 100.F / (Paddles::ANALOG_RANGE / 2))); // NOLINT break; case kADeadzoneChanged: - myAnalogDeadzone->setValueLabel(std::round(Controller::analogDeadZoneValue(myAnalogDeadzone->getValue()) * 100.f / - (Paddles::ANALOG_RANGE / 2))); + myAnalogDeadzone->setValueLabel(std::round( + Controller::analogDeadZoneValue(myAnalogDeadzone->getValue()) * + 100.F / (Paddles::ANALOG_RANGE / 2))); // NOLINT break; case kPSpeedChanged: myPaddleSpeed->setValueLabel(std::round(Paddles::setAnalogSensitivity( - myPaddleSpeed->getValue()) * 100.F)); + myPaddleSpeed->getValue()) * 100.F)); break; case kDejitterAvChanged: diff --git a/src/gui/InputTextDialog.cxx b/src/gui/InputTextDialog.cxx index 0cc57915b..6ed3cf415 100644 --- a/src/gui/InputTextDialog.cxx +++ b/src/gui/InputTextDialog.cxx @@ -94,17 +94,16 @@ void InputTextDialog::initialize(const GUI::Font& lfont, const GUI::Font& nfont, // Create editboxes for all labels int ypos = VBORDER + _th; - for(size_t i = 0; i < labels.size(); ++i) + for(const auto& label: labels) { xpos = HBORDER; - StaticTextWidget* s = new StaticTextWidget(this, lfont, xpos, ypos + 2, - lwidth, fontHeight, - labels[i]); + auto* s = new StaticTextWidget(this, lfont, xpos, ypos + 2, + lwidth, fontHeight, label); myLabel.push_back(s); xpos += lwidth + fontWidth; - EditTextWidget* w = new EditTextWidget(this, nfont, xpos, ypos, - _w - xpos - HBORDER, lineHeight, ""); + auto* w = new EditTextWidget(this, nfont, xpos, ypos, + _w - xpos - HBORDER, lineHeight, ""); if(numInput) w->setMaxLen(numInput); wid.push_back(w); diff --git a/src/gui/JoystickDialog.cxx b/src/gui/JoystickDialog.cxx index 3448417f1..a1322f950 100644 --- a/src/gui/JoystickDialog.cxx +++ b/src/gui/JoystickDialog.cxx @@ -47,7 +47,7 @@ JoystickDialog::JoystickDialog(GuiObject* boss, const GUI::Font& font, // Joystick ID ypos = _h - VBORDER - (buttonHeight + lineHeight) / 2; - StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos+2, "Controller ID "); + auto* t = new StaticTextWidget(this, font, xpos, ypos+2, "Controller ID "); xpos += t->getWidth(); myJoyText = new EditTextWidget(this, font, xpos, ypos, font.getStringWidth("Unplugged "), font.getLineHeight(), ""); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 11e10fad7..0d70b4706 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -268,8 +268,8 @@ void LauncherDialog::addPathWidgets(int& ypos) myRomCount = new StaticTextWidget(this, _font, xpos, ypos, lwFound, fontHeight, "", TextAlign::Right); - EditTextWidget* e = new EditTextWidget(this, _font, myNavigationBar->getRight() - 1, ypos - btnYOfs, - lwFound + LBL_GAP + 1, buttonHeight - 2, ""); + auto* e = new EditTextWidget(this, _font, myNavigationBar->getRight() - 1, + ypos - btnYOfs, lwFound + LBL_GAP + 1, buttonHeight - 2, ""); e->setEditable(false); e->setEnabled(false); } else { @@ -652,16 +652,16 @@ void LauncherDialog::setRomInfoFont(const Common::Size& area) }; // Try to pick a font that works best, based on the available area - for(size_t i = 0; i < sizeof(FONTS) / sizeof(FontDesc); ++i) + for(const auto& font: FONTS) { // only use fonts <= launcher fonts - if(Dialog::fontHeight() >= FONTS[i].height) + if(Dialog::fontHeight() >= font.height) { - if(area.h >= static_cast(MIN_ROMINFO_ROWS * FONTS[i].height + 2 - + MIN_ROMINFO_LINES * FONTS[i].height) - && area.w >= static_cast(MIN_ROMINFO_CHARS * FONTS[i].maxwidth)) + if(area.h >= static_cast(MIN_ROMINFO_ROWS * font.height + 2 + + MIN_ROMINFO_LINES * font.height) + && area.w >= static_cast(MIN_ROMINFO_CHARS * font.maxwidth)) { - myROMInfoFont = make_unique(FONTS[i]); + myROMInfoFont = make_unique(font); return; } } @@ -701,7 +701,7 @@ void LauncherDialog::loadRomInfo() } } -// -------------------------------------- +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherDialog::loadPendingRomInfo() { myPendingRomInfo = false; @@ -1146,11 +1146,12 @@ void LauncherDialog::openContextMenu(int x, int y) string label; string shortcut; string key; - explicit ContextItem(const string _label, const string _shortcut, const string _key) - : label{ _label }, shortcut{ _shortcut }, key{ _key } {} + explicit ContextItem(const string& _label, const string& _shortcut, + const string& _key) + : label{_label}, shortcut{_shortcut}, key{_key} {} // No shortcuts displayed in minimal UI - ContextItem(const string _label, const string _key) - : label{ _label }, key{ _key } {} + ContextItem(const string& _label, const string& _key) + : label{_label}, key{_key} {} }; using ContextList = std::vector; ContextList items; diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index 476e3e570..fddb8e043 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -222,8 +222,7 @@ void ListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) resetSelection(); // First check whether the selection changed - int newSelectedItem; - newSelectedItem = findItem(x, y); + 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 f05382191..c57a5178d 100644 --- a/src/gui/LoggerDialog.cxx +++ b/src/gui/LoggerDialog.cxx @@ -76,10 +76,9 @@ LoggerDialog::LoggerDialog(OSystem& osystem, DialogContainer& parent, wid.push_back(myLogToConsole); // Add Save, OK and Cancel buttons - ButtonWidget* b; - b = new ButtonWidget(this, font, HBORDER, _h - buttonHeight - VBORDER, - buttonWidth, buttonHeight, "Save log to disk" + ELLIPSIS, - GuiObject::kDefaultsCmd); + auto* b = new ButtonWidget(this, font, HBORDER, _h - buttonHeight - VBORDER, + buttonWidth, buttonHeight, "Save log to disk" + ELLIPSIS, + GuiObject::kDefaultsCmd); wid.push_back(b); addOKCancelBGroup(wid, font); diff --git a/src/gui/MessageBox.cxx b/src/gui/MessageBox.cxx index 1dfb2cff6..e249c47ec 100644 --- a/src/gui/MessageBox.cxx +++ b/src/gui/MessageBox.cxx @@ -87,9 +87,9 @@ void MessageBox::addText(const GUI::Font& font, const StringList& text) int str_w = 0; for(const auto& s: text) - str_w = std::max(int(s.length()), str_w); + str_w = std::max(static_cast(s.length()), str_w); _w = std::min(str_w * fontWidth + HBORDER * 2, _w); - _h = std::min(uInt32((text.size() + 2) * fontHeight + VBORDER * 2 + _th), uInt32(_h)); + _h = std::min((static_cast(text.size()) + 2) * fontHeight + VBORDER * 2 + _th, _h); const int xpos = HBORDER; int ypos = VBORDER + _th; diff --git a/src/gui/MinUICommandDialog.cxx b/src/gui/MinUICommandDialog.cxx index f911babac..2520cb4e3 100644 --- a/src/gui/MinUICommandDialog.cxx +++ b/src/gui/MinUICommandDialog.cxx @@ -55,8 +55,8 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent const auto ADD_CD_BUTTON = [&](const string& label, int cmd) { - ButtonWidget* b = new ButtonWidget(this, _font, xoffset, yoffset, - buttonWidth, buttonHeight, label, cmd); + auto* b = new ButtonWidget(this, _font, xoffset, yoffset, + buttonWidth, buttonHeight, label, cmd); yoffset += buttonHeight + VGAP; return b; }; diff --git a/src/gui/NavigationWidget.cxx b/src/gui/NavigationWidget.cxx index cccdda33f..bb222420b 100644 --- a/src/gui/NavigationWidget.cxx +++ b/src/gui/NavigationWidget.cxx @@ -127,9 +127,10 @@ void NavigationWidget::updateUI() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NavigationWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) +void NavigationWidget::handleCommand(CommandSender* sender, int cmd, int data, + int id) { - switch(cmd) + switch(cmd) // NOLINT (could be written as IF/ELSE) { case kFolderClicked: { @@ -212,8 +213,8 @@ void NavigationWidget::PathWidget::setPath(const string& path) else { // Add new widget to list - FolderLinkWidget* s = new FolderLinkWidget(_boss, _font, x, _y, - width, _h, name, curPath); + auto* s = new FolderLinkWidget(_boss, _font, x, _y, + width, _h, name, curPath); s->setID(static_cast(idx)); s->setTarget(myTarget); myFolderList.push_back(s); diff --git a/src/gui/OptionsDialog.cxx b/src/gui/OptionsDialog.cxx index 967e1bafc..d607fccd4 100644 --- a/src/gui/OptionsDialog.cxx +++ b/src/gui/OptionsDialog.cxx @@ -66,12 +66,12 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, int xoffset = HBORDER, yoffset = VBORDER + _th; WidgetArray wid; - ButtonWidget* b = nullptr; + ButtonWidget* b{nullptr}; if (minSettings) { - ButtonWidget* bw = new ButtonWidget(this, _font, xoffset, yoffset, - _w - HBORDER * 2, buttonHeight, "Use Basic Settings", kBasSetCmd); + auto* bw = new ButtonWidget(this, _font, xoffset, yoffset, + _w - HBORDER * 2, buttonHeight, "Use Basic Settings", kBasSetCmd); wid.push_back(bw); yoffset += rowHeight + VGAP * 2; _h += rowHeight + VGAP * 2; @@ -79,8 +79,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, const auto ADD_OD_BUTTON = [&](const string& label, int cmd) { - ButtonWidget* bw = new ButtonWidget(this, _font, xoffset, yoffset, - buttonWidth, buttonHeight, label, cmd); + auto* bw = new ButtonWidget(this, _font, xoffset, yoffset, + buttonWidth, buttonHeight, label, cmd); yoffset += rowHeight; return bw; }; @@ -151,7 +151,7 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -OptionsDialog::~OptionsDialog() +OptionsDialog::~OptionsDialog() // NOLINT (we need an empty d'tor) { } diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 0fbe6def2..26a427209 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -300,7 +300,11 @@ void PopUpWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect PopUpWidget::getEditRect() const { - return Common::Rect(_labelWidth + _textOfs, 1, _w - _textOfs - dropDownWidth(_font), _h); + return { + static_cast(_labelWidth + _textOfs), 1, + static_cast(_w - _textOfs - dropDownWidth(_font)), + static_cast(_h) + }; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ProgressDialog.cxx b/src/gui/ProgressDialog.cxx index acd2cd6d9..9d3aff65d 100644 --- a/src/gui/ProgressDialog.cxx +++ b/src/gui/ProgressDialog.cxx @@ -58,9 +58,9 @@ ProgressDialog::ProgressDialog(GuiObject* boss, const GUI::Font& font, mySlider->setMaxValue(100); ypos += lineHeight + VGAP * 4; - ButtonWidget* b = new ButtonWidget(this, font, (_w - buttonWidth) / 2, ypos, - buttonWidth, buttonHeight, "Cancel", - Event::UICancel); + auto* b = new ButtonWidget(this, font, (_w - buttonWidth) / 2, ypos, + buttonWidth, buttonHeight, "Cancel", + Event::UICancel); wid.push_back(b); addCancelWidget(b); addToFocusList(wid); diff --git a/src/gui/R77HelpDialog.cxx b/src/gui/R77HelpDialog.cxx index 6b5f1c723..c8eb015c0 100644 --- a/src/gui/R77HelpDialog.cxx +++ b/src/gui/R77HelpDialog.cxx @@ -56,9 +56,9 @@ R77HelpDialog::R77HelpDialog(OSystem& osystem, DialogContainer& parent, wid.push_back(myNextButton); xpos = _w - buttonWidth - HBORDER; - ButtonWidget* b = - new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, - "Close", GuiObject::kCloseCmd); + auto* b = new ButtonWidget(this, font, xpos, ypos, + buttonWidth, buttonHeight, + "Close", GuiObject::kCloseCmd); wid.push_back(b); addCancelWidget(b); diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index cf9e0f0a2..67b34221a 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -253,7 +253,7 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font, else // center text _textY = (_buttonSize - _font.getFontHeight()) / 2; - setFill(CheckboxWidget::FillType::Normal); + setFill(CheckboxWidget::FillType::Normal); // NOLINT myGroup->addWidget(this); } @@ -328,7 +328,7 @@ void RadioButtonGroup::addWidget(RadioButtonWidget* widget) { myWidgets.push_back(widget); // set first button as default - widget->setState(myWidgets.size() == 1, false); + widget->setState(myWidgets.size() == 1, false); // NOLINT mySelected = 0; } diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index fc6f857e3..f20266a1e 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -57,9 +57,8 @@ RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent, _h = _th + VBORDER * 2 + buttonHeight * 2 + lineHeight * 3 + VGAP * 10; // Audit path - ButtonWidget* romButton = - new ButtonWidget(this, font, HBORDER, ypos, buttonWidth, buttonHeight, - "Audit path" + ELLIPSIS, kChooseAuditDirCmd); + auto* romButton = new ButtonWidget(this, font, HBORDER, ypos, + buttonWidth, buttonHeight, "Audit path" + ELLIPSIS, kChooseAuditDirCmd); wid.push_back(romButton); myRomPath = new EditTextWidget(this, font, xpos, ypos + (buttonHeight - lineHeight) / 2 - 1, _w - xpos - HBORDER, lineHeight); @@ -88,7 +87,7 @@ RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -RomAuditDialog::~RomAuditDialog() +RomAuditDialog::~RomAuditDialog() // NOLINT (we need an empty d'tor) { } diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 2d34821dd..1b96f4ba5 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -40,7 +40,8 @@ RomImageWidget::RomImageWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomImageWidget::setProperties(const FSNode& node, const Properties properties, bool full) +void RomImageWidget::setProperties(const FSNode& node, + const Properties& properties, bool full) { myHaveProperties = true; myProperties = properties; @@ -176,7 +177,7 @@ void RomImageWidget::parseProperties(const FSNode& node, bool full) // Update maximum load time myMaxLoadTime = std::min( - static_cast(500ull / timeFactor), + static_cast(500ULL / timeFactor), std::max(myMaxLoadTime, TimerManager::getTicks() / 1000 - startTime)); } @@ -286,15 +287,15 @@ bool RomImageWidget::loadPng(const string& fileName) // Retrieve label for loaded image myLabel.clear(); - for(auto data = metaData.begin(); data != metaData.end(); ++data) + for(const auto& data: metaData) { - if(data->first == "Title") + if(data.first == "Title") { - myLabel = data->second.toString(); + myLabel = data.second.toString(); break; } - if(data->first == "Software" - && data->second.toString().find("Stella") == 0) + if(data.first == "Software" + && data.second.toString().find("Stella") == 0) myLabel = "Snapshot"; // default for Stella snapshots with missing "Title" meta data } return true; @@ -316,11 +317,11 @@ bool RomImageWidget::loadJpg(const string& fileName) // Retrieve label for loaded image myLabel.clear(); - for(auto data = metaData.begin(); data != metaData.end(); ++data) + for(const auto& data: metaData) { - if(data->first == "ImageDescription") + if(data.first == "ImageDescription") { - myLabel = data->second.toString(); + myLabel = data.second.toString(); break; } } diff --git a/src/gui/RomImageWidget.hxx b/src/gui/RomImageWidget.hxx index cee58b41c..b05ba3ca4 100644 --- a/src/gui/RomImageWidget.hxx +++ b/src/gui/RomImageWidget.hxx @@ -35,7 +35,7 @@ class RomImageWidget : public Widget return font.getFontHeight() * 9 / 8; } - void setProperties(const FSNode& node, const Properties properties, + void setProperties(const FSNode& node, const Properties& properties, bool full = true); void clearProperties(); void reloadProperties(const FSNode& node); diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index c5d0ad80d..3f892ddba 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -39,7 +39,8 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomInfoWidget::setProperties(const FSNode& node, const Properties properties, bool full) +void RomInfoWidget::setProperties(const FSNode& node, + const Properties& properties, bool full) { myHaveProperties = true; myProperties = properties; diff --git a/src/gui/RomInfoWidget.hxx b/src/gui/RomInfoWidget.hxx index 861139838..df3874d19 100644 --- a/src/gui/RomInfoWidget.hxx +++ b/src/gui/RomInfoWidget.hxx @@ -35,7 +35,8 @@ class RomInfoWidget : public Widget, public CommandSender int x, int y, int w, int h); ~RomInfoWidget() override = default; - void setProperties(const FSNode& node, const Properties properties, bool full = true); + void setProperties(const FSNode& node, const Properties& properties, + bool full = true); void clearProperties(); void reloadProperties(const FSNode& node); diff --git a/src/gui/SnapshotDialog.cxx b/src/gui/SnapshotDialog.cxx index 629ccbe8b..d9950cb37 100644 --- a/src/gui/SnapshotDialog.cxx +++ b/src/gui/SnapshotDialog.cxx @@ -45,8 +45,8 @@ SnapshotDialog::SnapshotDialog(OSystem& osystem, DialogContainer& parent, int xpos = HBORDER, ypos = VBORDER + _th; // Snapshot path (save files) - ButtonWidget* b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, - "Save path" + ELLIPSIS, kChooseSnapSaveDirCmd); + auto* b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, + "Save path" + ELLIPSIS, kChooseSnapSaveDirCmd); wid.push_back(b); xpos += buttonWidth + fontWidth; mySnapSavePath = new EditTextWidget(this, font, xpos, ypos + (buttonHeight - lineHeight) / 2 - 1, diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index 550777c43..e29eff46a 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -88,7 +88,7 @@ StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& pa } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -StellaSettingsDialog::~StellaSettingsDialog() +StellaSettingsDialog::~StellaSettingsDialog() // NOLINT (we need an empty d'tor) { } diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index e3855bb1b..333408ad8 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -141,5 +141,8 @@ void StringListWidget::drawWidget(bool hilite) Common::Rect StringListWidget::getEditRect() const { const int offset = std::max(0, (_selectedItem - _currentPos) * _lineHeight); - return Common::Rect(_textOfs, 1 + offset, _w - _textOfs, _lineHeight + offset); + return { + static_cast(_textOfs), static_cast(1 + offset), + static_cast(_w - _textOfs), static_cast(_lineHeight + offset) + }; } diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index 66c604f2a..0c43bc7e3 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -73,11 +73,11 @@ int TabWidget::addTab(const string& title, int tabWidth) // Determine the new tab width int fixedWidth = 0, fixedTabs = 0; - for(int i = 0; i < static_cast(_tabs.size()); ++i) + for(const auto& tab: _tabs) { - if(_tabs[i].tabWidth != NO_WIDTH) + if(tab.tabWidth != NO_WIDTH) { - fixedWidth += _tabs[i].tabWidth; + fixedWidth += tab.tabWidth; fixedTabs++; } } @@ -196,8 +196,8 @@ Widget* TabWidget::parentWidget(int tabID) if(!_tabs[tabID].parentWidget) { - // create dummy widget if not existing - Widget* w = new Widget(_boss, _font, 0, 0, 0, 0); + // Create dummy widget if not existing + auto* w = new Widget(_boss, _font, 0, 0, 0, 0); setParentWidget(tabID, w); } diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index cb486384e..a8f1eada9 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -33,7 +33,6 @@ #include "TimeMachineDialog.hxx" #include "Base.hxx" -using Common::Base; static constexpr int BUTTON_W = 14, BUTTON_H = 14; @@ -498,17 +497,18 @@ void TimeMachineDialog::initBar() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string TimeMachineDialog::getTimeString(uInt64 cycles) const { - const Int32 scanlines = std::max(instance().console().tia().scanlinesLastFrame(), 240); + const size_t scanlines = + std::max(instance().console().tia().scanlinesLastFrame(), 240); const bool isNTSC = scanlines <= 287; - constexpr Int32 NTSC_FREQ = 1193182; // ~76*262*60 - constexpr Int32 PAL_FREQ = 1182298; // ~76*312*50 - const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second + constexpr size_t NTSC_FREQ = 1193182; // ~76*262*60 + constexpr size_t PAL_FREQ = 1182298; // ~76*312*50 + const size_t freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second - const uInt32 minutes = static_cast(cycles / (freq * 60)); + const auto minutes = static_cast(cycles / (freq * 60)); cycles -= minutes * (freq * 60); - const uInt32 seconds = static_cast(cycles / freq); + const auto seconds = static_cast(cycles / freq); cycles -= seconds * freq; - const uInt32 frames = static_cast(cycles / (scanlines * 76)); + const auto frames = static_cast(cycles / (scanlines * 76)); stringstream time; time << Common::Base::toString(minutes, Common::Base::Fmt::_10_02) << ":"; diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 3d771bff9..7e6896bb2 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -205,9 +205,8 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent, // ROM path int bwidth = font.getStringWidth("ROM path" + ELLIPSIS) + 20 + 1; - ButtonWidget* romButton = - new ButtonWidget(myTab, font, xpos, ypos, bwidth, buttonHeight, - "ROM path" + ELLIPSIS, kChooseRomDirCmd); + auto* romButton = new ButtonWidget(myTab, font, xpos, ypos, bwidth, + buttonHeight, "ROM path" + ELLIPSIS, kChooseRomDirCmd); wid.push_back(romButton); xpos = romButton->getRight() + fontWidth; myRomPath = new EditTextWidget(myTab, font, xpos, ypos + (buttonHeight - lineHeight) / 2 - 1, diff --git a/src/gui/UndoHandler.cxx b/src/gui/UndoHandler.cxx index 19226610d..e5d3cd398 100644 --- a/src/gui/UndoHandler.cxx +++ b/src/gui/UndoHandler.cxx @@ -93,7 +93,7 @@ bool UndoHandler::redo(string& text) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 UndoHandler::lastDiff(const string& text, const string& oldText) const { - uInt32 pos = static_cast(text.size()); + auto pos = static_cast(text.size()); for(auto itn = text.crbegin(), ito = oldText.crbegin(); itn != text.crend() && ito != oldText.crend(); ++itn, ++ito) diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index 9b0fe23f1..af6f5bda4 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -313,7 +313,7 @@ void VideoAudioDialog::addPaletteTab() CREATE_CUSTOM_SLIDERS(Gamma, "Gamma ", kPaletteUpdated) ypos += VGAP; - StaticTextWidget* s = new StaticTextWidget(myTab, _font, xpos, ypos + 1, "Autodetection"); + auto* s = new StaticTextWidget(myTab, _font, xpos, ypos + 1, "Autodetection"); myDetectPal60 = new CheckboxWidget(myTab, _font, s->getRight() + fontWidth * 2, ypos + 1, "PAL-60"); myDetectPal60 ->setToolTip("Enable autodetection of PAL-60 based on colors used."); @@ -842,13 +842,15 @@ void VideoAudioDialog::saveConfig() // DPC Pitch audioSettings.setDpcPitch(myDpcPitch->getValue()); // update if current cart is Pitfall II - if (instance().hasConsole() && instance().console().cartridge().name() == "CartridgeDPC") + if (instance().hasConsole() && + instance().console().cartridge().name() == "CartridgeDPC") { - CartridgeDPC& cart = static_cast(instance().console().cartridge()); + auto& cart = static_cast(instance().console().cartridge()); cart.setDpcPitch(myDpcPitch->getValue()); } - const AudioSettings::Preset preset = static_cast(myModePopup->getSelectedTag().toInt()); + const auto preset = static_cast + (myModePopup->getSelectedTag().toInt()); audioSettings.setPreset(preset); if (preset == AudioSettings::Preset::custom) { @@ -1063,8 +1065,8 @@ void VideoAudioDialog::handlePaletteUpdate() constexpr int NUM_LUMA = 8; constexpr int NUM_CHROMA = 16; - for(int idx = 0; idx < NUM_CHROMA; ++idx) - for(int lum = 0; lum < NUM_LUMA; ++lum) + for(int idx = 0; idx < NUM_CHROMA; ++idx) // NOLINT + for(int lum = 0; lum < NUM_LUMA; ++lum) // NOLINT myColor[idx][lum]->setDirty(); } } @@ -1294,8 +1296,8 @@ void VideoAudioDialog::colorPalette() } else // disable palette - for(int idx = 0; idx < NUM_CHROMA; ++idx) - for(int lum = 0; lum < NUM_LUMA; ++lum) + for(int idx = 0; idx < NUM_CHROMA; ++idx) // NOLINT + for(int lum = 0; lum < NUM_LUMA; ++lum) // NOLINT myColor[idx][lum]->setEnabled(false); } @@ -1303,7 +1305,8 @@ void VideoAudioDialog::colorPalette() void VideoAudioDialog::updateEnabledState() { const bool active = mySoundEnableCheckbox->getState(); - const AudioSettings::Preset preset = static_cast(myModePopup->getSelectedTag().toInt()); + const auto preset = static_cast + (myModePopup->getSelectedTag().toInt()); const bool userMode = preset == AudioSettings::Preset::custom; myVolumeSlider->setEnabled(active); @@ -1323,7 +1326,8 @@ void VideoAudioDialog::updateEnabledState() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoAudioDialog::updatePreset() { - const AudioSettings::Preset preset = static_cast(myModePopup->getSelectedTag().toInt()); + const auto preset = static_cast + (myModePopup->getSelectedTag().toInt()); // Make a copy that does not affect the actual settings... AudioSettings audioSettings = instance().audioSettings(); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index e42db913a..52ed2b603 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -877,7 +877,7 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font, else // center text _textY = (_boxSize - _font.getFontHeight()) / 2; - setFill(CheckboxWidget::FillType::Normal); + setFill(CheckboxWidget::FillType::Normal); // NOLINT } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/lib/sqlite/sqlite3.c b/src/lib/sqlite/sqlite3.c index a615745bb..6709ca504 100644 --- a/src/lib/sqlite/sqlite3.c +++ b/src/lib/sqlite/sqlite3.c @@ -24,18 +24,18 @@ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" - #include "source/sqlite3.c" + #include "source/sqlite3.c" // NOLINT #pragma clang diagnostic pop #elif defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wcast-function-type" - #include "source/sqlite3.c" + #include "source/sqlite3.c" // NOLINT #pragma GCC diagnostic pop #elif defined(BSPF_WINDOWS) #pragma warning(push, 0) - #include "source/sqlite3.c" + #include "source/sqlite3.c" // NOLINT #pragma warning(pop) #else - #include "source/sqlite3.c" + #include "source/sqlite3.c" // NOLINT #endif diff --git a/src/lib/tinyexif/tinyexif.cxx b/src/lib/tinyexif/tinyexif.cxx index d0315d13e..86a94dd26 100644 --- a/src/lib/tinyexif/tinyexif.cxx +++ b/src/lib/tinyexif/tinyexif.cxx @@ -22,7 +22,7 @@ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" - #include "source/TinyEXIF.cpp" + #include "source/TinyEXIF.cpp" // NOLINT #pragma clang diagnostic pop #elif defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push @@ -30,13 +30,13 @@ #pragma GCC diagnostic ignored "-Wcast-function-type" #pragma GCC diagnostic ignored "-Wshift-negative-value" #pragma GCC diagnostic ignored "-Wregister" - #include "source/TinyEXIF.cpp" + #include "source/TinyEXIF.cpp" // NOLINT #pragma GCC diagnostic pop #elif defined(BSPF_WINDOWS) #pragma warning(push, 0) #pragma warning(disable : 4505) - #include "source/TinyEXIF.cpp" + #include "source/TinyEXIF.cpp" // NOLINT #pragma warning(pop) #else - #include "source/TinyEXIF.cpp" + #include "source/TinyEXIF.cpp" // NOLINT #endif