From 27c694ac0e189012c9882dab8b969f6e8e394629 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Fri, 19 Aug 2022 10:23:34 +0200 Subject: [PATCH 01/11] made image area in Launcher a square to allow better display of vertical oriented images (e.g. boxes) changed unused image area background to black --- src/gui/FileListWidget.cxx | 3 --- src/gui/LauncherDialog.cxx | 8 ++++---- src/gui/RomImageWidget.cxx | 23 ++++++++++++++--------- src/gui/RomInfoWidget.cxx | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 92e9c4cb0..020923df8 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -322,9 +322,6 @@ bool FileListWidget::handleKeyDown(StellaKey key, StellaMod mod) if(StellaModTest::isAlt(mod)) { handled = true; -#ifdef DEBUG_BUILD - cerr << " FileListWidget::handleKeyDown " << mod << ", " << key << endl; -#endif switch(key) { case KBDK_HOME: diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 20df8a76f..11e10fad7 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -323,11 +323,11 @@ void LauncherDialog::addRomWidgets(int ypos) { xpos += myList->getWidth() + fontWidth; - // Initial surface size is the same as the viewable area + // Initial surface size is the viewable area's width squared const Common::Size imgSize(TIAConstants::viewableWidth * imgZoom, - TIAConstants::viewableHeight * imgZoom); - // Calculate font area, and in the process the font that can be used + TIAConstants::viewableWidth * imgZoom); + // Calculate font area, and in the process the font that can be used // Infofont is unknown yet, but used in image label too. Assuming maximum font height. int imageHeight = imgSize.h + RomImageWidget::labelHeight(_font); @@ -340,7 +340,7 @@ void LauncherDialog::addRomWidgets(int ypos) myRomImageWidget = new RomImageWidget(this, *myROMInfoFont, xpos, ypos, imageWidth, imageHeight); - const int yofs = imageHeight + VGAP * 2; + const int yofs = imageHeight + myROMInfoFont->getFontHeight() / 2; myRomInfoWidget = new RomInfoWidget(this, *myROMInfoFont, xpos, ypos + yofs, imageWidth, myList->getHeight() - yofs); } diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index a4ecca302..2d34821dd 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -48,13 +48,13 @@ void RomImageWidget::setProperties(const FSNode& node, const Properties properti // Decide whether the information should be shown immediately if(instance().eventHandler().state() == EventHandlerState::LAUNCHER) parseProperties(node, full); +#ifdef DEBUGGER_SUPPORT else { -#ifdef DEBUGGER_SUPPORT cerr << "RomImageWidget::setProperties: else!" << endl; Logger::debug("RomImageWidget::setProperties: else!"); -#endif } +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -67,13 +67,13 @@ void RomImageWidget::clearProperties() // Decide whether the information should be shown immediately if(instance().eventHandler().state() == EventHandlerState::LAUNCHER) setDirty(); +#ifdef DEBUGGER_SUPPORT else { -#ifdef DEBUGGER_SUPPORT cerr << "RomImageWidget::clearProperties: else!" << endl; Logger::debug("RomImageWidget::clearProperties: else!"); -#endif } +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -127,6 +127,7 @@ void RomImageWidget::parseProperties(const FSNode& node, bool full) { myImageIdx = 0; myImageList.clear(); + myLabel.clear(); // Get a valid filename representing a snapshot file for this rom and load the snapshot const string& path = instance().snapshotLoadDir().getPath(); @@ -352,10 +353,12 @@ void RomImageWidget::handleMouseMoved(int x, int y) void RomImageWidget::drawWidget(bool hilite) { FBSurface& s = dialog().surface(); - const int yoff = myImageHeight; - s.fillRect(_x, _y + 1, _w, _h - 1, _bgcolor); - s.frameRect(_x, _y, _w, myImageHeight, kColor); + if(!myHaveProperties || !mySurfaceIsValid || !mySurfaceErrorMsg.empty()) + { + s.fillRect(_x, _y + 1, _w, _h - 1, _bgcolor); + s.frameRect(_x, _y, _w, myImageHeight, kColor); + } if(!myHaveProperties) { @@ -370,6 +373,7 @@ void RomImageWidget::drawWidget(bool hilite) const uInt32 x = _x * scale + ((_w * scale - dst.w()) >> 1); const uInt32 y = _y * scale + ((myImageHeight * scale - dst.h()) >> 1); + s.fillRect(_x, _y, _w, myImageHeight, 0); // Make sure when positioning the snapshot surface that we take // the dialog surface position into account const Common::Rect& s_dst = s.dstRect(); @@ -379,7 +383,7 @@ void RomImageWidget::drawWidget(bool hilite) else if(!mySurfaceErrorMsg.empty()) { const uInt32 x = _x + ((_w - _font.getStringWidth(mySurfaceErrorMsg)) >> 1); - const uInt32 y = _y + ((yoff - _font.getLineHeight()) >> 1); + const uInt32 y = _y + ((myImageHeight - _font.getLineHeight()) >> 1); s.drawString(_font, mySurfaceErrorMsg, x, y, _w - 10, _textcolor); } // Draw the image label and counter @@ -388,6 +392,7 @@ void RomImageWidget::drawWidget(bool hilite) const int yText = _y + myImageHeight + _font.getFontHeight() / 8; const int wText = _font.getStringWidth(buf.str()); + s.fillRect(_x, yText, _w, _font.getFontHeight(), _bgcolor); if(myLabel.length()) s.drawString(_font, myLabel, _x, yText, _w - wText - _font.getMaxCharWidth() * 2, _textcolor); if(myImageList.size()) @@ -396,7 +401,7 @@ void RomImageWidget::drawWidget(bool hilite) // Draw the navigation arrows myNavSurface->invalidate(); if(isHighlighted() && - ((myMouseLeft && myImageIdx) || (!myMouseLeft && myImageIdx < myImageList.size() - 1))) + ((myMouseLeft && myImageIdx) || (!myMouseLeft && myImageIdx + 1 < myImageList.size()))) { const int w = _w / 64; const int w2 = 1; // w / 2; diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 2cc4c0542..c5d0ad80d 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -47,6 +47,13 @@ void RomInfoWidget::setProperties(const FSNode& node, const Properties propertie // Decide whether the information should be shown immediately if(instance().eventHandler().state() == EventHandlerState::LAUNCHER) parseProperties(node, full); +#ifdef DEBUGGER_SUPPORT + else + { + cerr << "RomInfoWidget::setProperties: else!" << endl; + Logger::debug("RomInfoWidget::setProperties: else!"); + } +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -57,6 +64,13 @@ void RomInfoWidget::clearProperties() // Decide whether the information should be shown immediately if(instance().eventHandler().state() == EventHandlerState::LAUNCHER) setDirty(); +#ifdef DEBUGGER_SUPPORT + else + { + cerr << "RomInfoWidget::clearProperties: else!" << endl; + Logger::debug("RomInfoWidget::clearProperties: else!"); + } +#endif myUrl.clear(); } From 08a2c63a0bb2b086bd65fd4e2af1f2e1d580a7a6 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Fri, 19 Aug 2022 15:26:17 -0230 Subject: [PATCH 02/11] Update .gitignore for recent directory changes. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e211ea503..219830d89 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ project.xcworkspace/ xcuserdata/ .DS_Store build/ -src/macosx/M6502.ins +src/os/macos/M6502.ins *.dSYM .vscode/c_cpp_properties.json .vscode/settings.json From e67b88d35f5f2b2ef2cd846ee4e86f4b6ad9840d Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Fri, 19 Aug 2022 16:05:55 -0230 Subject: [PATCH 03/11] libretro: Attempt to fix Android build script. --- src/os/libretro/jni/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/libretro/jni/Android.mk b/src/os/libretro/jni/Android.mk index a43b28239..0ef54796c 100644 --- a/src/os/libretro/jni/Android.mk +++ b/src/os/libretro/jni/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir) CORE_DIR := $(LOCAL_PATH)/../.. -include $(CORE_DIR)/os/libretro/Makefile.common +include $(LOCAL_PATH)/../Makefile.common COREFLAGS := -DANDROID -D__LIB_RETRO__ -DHAVE_STRINGS_H -DSOUND_SUPPORT $(INCFLAGS) From 6215829efa4248746f50f41c060b11f477a83bde Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Fri, 19 Aug 2022 18:40:42 -0230 Subject: [PATCH 04/11] libretro: Second pass at fixing Android builds. --- src/os/libretro/jni/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/libretro/jni/Android.mk b/src/os/libretro/jni/Android.mk index 0ef54796c..644f983ae 100644 --- a/src/os/libretro/jni/Android.mk +++ b/src/os/libretro/jni/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir) CORE_DIR := $(LOCAL_PATH)/../.. -include $(LOCAL_PATH)/../Makefile.common +include $(CORE_DIR)/libretro/Makefile.common COREFLAGS := -DANDROID -D__LIB_RETRO__ -DHAVE_STRINGS_H -DSOUND_SUPPORT $(INCFLAGS) From ea0561940245628c39fe1ae496abeafcf2f2fa07 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sat, 20 Aug 2022 20:00:03 +0200 Subject: [PATCH 05/11] added "swchb" command to debugger --- docs/debugger.html | 1 + src/debugger/DebuggerParser.cxx | 22 ++++++++++++++++++++-- src/debugger/DebuggerParser.hxx | 3 ++- src/debugger/RiotDebug.cxx | 10 ++++++++++ src/debugger/RiotDebug.hxx | 1 + 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/debugger.html b/docs/debugger.html index 90a221cf9..206a7bc2a 100644 --- a/docs/debugger.html +++ b/docs/debugger.html @@ -1017,6 +1017,7 @@ clearSaveStateIfs - Clear all saveState points scanLine - Advance emulation by <xx> scanlines (default=1) step - Single step CPU [with count xx] stepWhile - Single step CPU while <condition> is true + swchb - Set SWCHB to value xx tia - Show TIA state trace - Single step CPU over subroutines [with count xx] trap - Trap read/write access to address(es) xx [yy] diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 41a2a910d..1982abd1a 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -148,7 +148,9 @@ string DebuggerParser::exec(const FSNode& file, StringList* history) if(!getline(in, command)) break; + ++execDepth; run(command); + --execDepth; if (history != nullptr) history->push_back(command); count++; @@ -1315,9 +1317,7 @@ void DebuggerParser::executeExec() // make sure the commands are added to prompt history StringList history; - ++execDepth; commandResult << exec(node, &history); - --execDepth; for(const auto& item: history) debugger.prompt().addToHistory(item.c_str()); @@ -2159,6 +2159,14 @@ void DebuggerParser::executeStepWhile() commandResult << "executed " << ncycles << " cycles"; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// "swchb" +void DebuggerParser::executeSwchb() +{ + debugger.riotDebug().switches(args[0]); + commandResult << "SWCHB set to " << std::hex << std::setw(2) << std::setfill('0') << args[0]; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "tia" void DebuggerParser::executeTia() @@ -3381,6 +3389,16 @@ DebuggerParser::CommandArray DebuggerParser::commands = { { std::mem_fn(&DebuggerParser::executeStepWhile) }, + { + "swchb", + "Set SWCHB to xx", + "Example: swchb fe", + true, + true, + { Parameters::ARG_WORD, Parameters::ARG_END_ARGS }, + std::mem_fn(&DebuggerParser::executeSwchb) + }, + { "tia", "Show TIA state", diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index dbfa4408c..bd8394e4f 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -101,7 +101,7 @@ class DebuggerParser std::array parms; std::function executor; }; - using CommandArray = std::array; + using CommandArray = std::array; static CommandArray commands; struct Trap @@ -234,6 +234,7 @@ class DebuggerParser void executeScanLine(); void executeStep(); void executeStepWhile(); + void executeSwchb(); void executeTia(); void executeTrace(); void executeTrap(); diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index c8087d6f8..e3868d75b 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -257,6 +257,16 @@ int RiotDebug::timReadCycles() const return mySystem.m6532().myTimReadCycles; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool RiotDebug::switches(int newVal) +{ + uInt8& switches = myConsole.switches().mySwitches; + if(newVal > -1) + switches = newVal; + + return switches; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool RiotDebug::diffP0(int newVal) { diff --git a/src/debugger/RiotDebug.hxx b/src/debugger/RiotDebug.hxx index 2aa43bf84..ef90ec4db 100644 --- a/src/debugger/RiotDebug.hxx +++ b/src/debugger/RiotDebug.hxx @@ -89,6 +89,7 @@ class RiotDebug : public DebuggerSystem int intimAsInt() const { return static_cast(intim()); } // so we can use _inTim pseudo-register /* Console switches */ + bool switches(int newVal = -1); bool diffP0(int newVal = -1); bool diffP1(int newVal = -1); bool tvType(int newVal = -1); From f987c3f72cf79b918a9e1c41f3139ba785a4cdeb Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 20 Aug 2022 15:32:15 -0230 Subject: [PATCH 06/11] 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 From faf7e8b775a3433ab1a2304379efcf92c372015b Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sun, 21 Aug 2022 12:49:13 +0200 Subject: [PATCH 07/11] added alternative debugger snapshot naming option --- src/debugger/DebuggerParser.cxx | 2 +- src/debugger/gui/TiaOutputWidget.cxx | 40 +++++++++++++++++++++++----- src/debugger/gui/TiaOutputWidget.hxx | 3 ++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 94ef3d9a4..6c73d713e 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -2063,7 +2063,7 @@ void DebuggerParser::executeSaveSes() // "saveSnap" void DebuggerParser::executeSaveSnap() { - debugger.tiaOutput().saveSnapshot(execDepth, execPrefix); + debugger.tiaOutput().saveSnapshot(execDepth, execPrefix, argCount == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 4c1144914..553041465 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -63,7 +63,8 @@ void TiaOutputWidget::loadConfig() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) +void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix, + bool mark) { #ifdef IMAGE_SUPPORT if(execDepth > 0) @@ -72,12 +73,39 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) ostringstream sspath; sspath << instance().snapshotSaveDir() << instance().console().properties().get(PropType::Cart_Name); - sspath << "_dbg_"; - if (execDepth > 0 && !execPrefix.empty()) { - sspath << execPrefix << "_"; + + if(mark) + { + sspath << "_dbg_"; + if(execDepth > 0 && !execPrefix.empty()) { + sspath << execPrefix << "_"; + } + sspath << std::hex << std::setw(8) << std::setfill('0') + << static_cast(TimerManager::getTicks() / 1000); } - sspath << std::hex << std::setw(8) << std::setfill('0') - << static_cast(TimerManager::getTicks()/1000) << ".png"; + else + { + // Determine if the file already exists, checking each successive filename + // until one doesn't exist + FSNode node(sspath.str() + ".png"); + if(node.exists()) + { + ostringstream suffix; + ostringstream buf; + for(uInt32 i = 1; ; ++i) + { + buf.str(""); + suffix.str(""); + suffix << "_" << i; + buf << sspath.str() << suffix.str() << ".png"; + FSNode next(buf.str()); + if(!next.exists()) + break; + } + sspath << suffix.str(); + } + } + sspath << ".png"; const uInt32 width = instance().console().tia().width(), height = instance().console().tia().height(); diff --git a/src/debugger/gui/TiaOutputWidget.hxx b/src/debugger/gui/TiaOutputWidget.hxx index 1a7621c33..cd42d277b 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -36,7 +36,8 @@ class TiaOutputWidget : public Widget, public CommandSender void loadConfig() override; void setZoomWidget(TiaZoomWidget* w) { myZoom = w; } - void saveSnapshot(int execDepth = 0, const string& execPrefix = ""); + void saveSnapshot(int execDepth = 0, const string& execPrefix = EmptyString, + bool mark = true); // Eventually, these methods will enable access to the onscreen TIA image // For example, clicking an area may cause an action From fc0a8c91a85f23b5a7d90d1d09f0eb7d09b7d8db Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 21 Aug 2022 13:53:52 -0230 Subject: [PATCH 08/11] Second pass at fixes for suggestions from clang-tidy. --- src/cheat/BankRomCheat.cxx | 2 +- src/cheat/CheatCodeDialog.cxx | 10 +-- src/cheat/CheatManager.cxx | 8 +- src/cheat/CheatManager.hxx | 2 +- src/common/FBBackendSDL2.cxx | 9 +-- src/common/FSNodeZIP.cxx | 22 +++--- src/common/FSNodeZIP.hxx | 4 +- src/common/HighScoresManager.cxx | 69 ++++++++-------- src/common/HighScoresManager.hxx | 78 ++++++++++--------- src/common/JPGLibrary.hxx | 2 +- src/common/JoyMap.cxx | 34 ++++---- src/common/JoyMap.hxx | 4 +- src/common/KeyMap.cxx | 8 +- src/common/KeyMap.hxx | 6 +- src/common/MouseControl.cxx | 2 +- src/common/MouseControl.hxx | 2 +- src/common/PJoystickHandler.cxx | 26 +++---- src/common/PJoystickHandler.hxx | 16 ++-- src/common/PKeyboardHandler.cxx | 17 ++-- src/common/PKeyboardHandler.hxx | 22 +++--- src/common/PNGLibrary.cxx | 12 +-- src/common/PNGLibrary.hxx | 41 +++++----- src/common/PaletteHandler.cxx | 14 ++-- src/common/PaletteHandler.hxx | 16 ++-- src/common/PhysicalJoystick.cxx | 7 +- src/common/PhysicalJoystick.hxx | 2 +- src/common/SoundSDL2.cxx | 8 +- src/common/StaggeredLogger.hxx | 9 ++- src/common/ThreadDebugging.hxx | 2 +- src/common/TimerManager.cxx | 3 +- src/common/main.cxx | 10 +-- .../KeyValueRepositoryConfigfile.hxx | 2 +- .../KeyValueRepositoryPropertyFile.cxx | 4 +- .../CompositeKeyValueRepositorySqlite.cxx | 24 +++--- .../sqlite/KeyValueRepositorySqlite.cxx | 10 +-- .../repository/sqlite/SqliteDatabase.cxx | 2 +- .../repository/sqlite/SqliteDatabase.hxx | 2 +- src/common/repository/sqlite/StellaDb.cxx | 9 ++- src/common/repository/sqlite/StellaDb.hxx | 17 ++-- src/common/tv_filters/AtariNTSC.hxx | 6 +- src/common/tv_filters/NTSCFilter.cxx | 6 +- src/common/tv_filters/NTSCFilter.hxx | 12 +-- src/debugger/BreakpointMap.cxx | 3 +- src/debugger/BreakpointMap.hxx | 2 +- src/debugger/CartDebug.cxx | 22 +++--- src/debugger/CartDebug.hxx | 10 +-- src/debugger/Debugger.cxx | 38 ++++----- src/debugger/Debugger.hxx | 40 +++++----- src/debugger/DebuggerParser.cxx | 72 +++++++++-------- src/debugger/DebuggerParser.hxx | 6 +- src/debugger/DiStella.cxx | 18 ++--- src/debugger/RiotDebug.cxx | 30 +++---- src/debugger/TIADebug.cxx | 6 +- src/debugger/TIADebug.hxx | 20 +++-- src/debugger/gui/BoosterWidget.cxx | 3 - src/debugger/gui/CartE7Widget.cxx | 4 +- src/debugger/gui/CartE7Widget.hxx | 5 +- src/debugger/gui/CartEnhancedWidget.cxx | 2 +- src/debugger/gui/CartRamWidget.hxx | 2 +- src/debugger/gui/CartWDWidget.cxx | 5 +- src/debugger/gui/CartWDWidget.hxx | 3 - src/debugger/gui/DataGridRamWidget.hxx | 2 +- src/debugger/gui/DataGridWidget.cxx | 6 +- src/debugger/gui/DataGridWidget.hxx | 4 +- src/debugger/gui/DelayQueueWidget.cxx | 5 +- src/debugger/gui/Joy2BPlusWidget.cxx | 3 - src/debugger/gui/PointingDeviceWidget.cxx | 3 +- src/debugger/gui/PointingDeviceWidget.hxx | 2 +- src/debugger/gui/PromptWidget.cxx | 12 +-- src/debugger/gui/RamWidget.cxx | 6 +- src/debugger/gui/RiotWidget.cxx | 5 +- src/debugger/gui/RiotWidget.hxx | 3 +- src/debugger/gui/RomListWidget.cxx | 2 +- src/debugger/gui/TiaOutputWidget.cxx | 2 +- src/debugger/gui/ToggleWidget.cxx | 2 +- src/debugger/gui/ToggleWidget.hxx | 2 +- src/debugger/yacc/YaccParser.cxx | 8 +- src/debugger/yacc/YaccParser.hxx | 8 +- src/emucore/CartAR.cxx | 11 --- src/emucore/CartAR.hxx | 8 +- src/emucore/CartCreator.cxx | 4 +- src/emucore/CartDetector.cxx | 10 +-- src/emucore/CartMVC.cxx | 14 ++-- src/emucore/Console.cxx | 10 +-- src/emucore/ControllerDetector.cxx | 4 +- src/emucore/ControllerDetector.hxx | 12 +-- src/emucore/EmulationWorker.hxx | 2 +- src/emucore/EventHandler.cxx | 46 +++++------ src/emucore/EventHandler.hxx | 32 ++++---- src/emucore/FBSurface.cxx | 8 +- src/emucore/FBSurface.hxx | 8 +- src/emucore/FrameBuffer.cxx | 2 +- src/emucore/FrameBuffer.hxx | 2 +- src/emucore/GlobalKeyHandler.cxx | 8 +- src/emucore/GlobalKeyHandler.hxx | 16 ++-- src/emucore/Keyboard.cxx | 10 ++- src/emucore/Keyboard.hxx | 2 +- src/emucore/KidVid.cxx | 2 +- src/emucore/M6502.cxx | 17 ++-- src/emucore/M6502.hxx | 8 +- src/emucore/M6532.hxx | 4 +- src/emucore/MD5.cxx | 6 +- src/emucore/OSystem.cxx | 18 ++--- src/emucore/OSystem.hxx | 8 +- src/emucore/Paddles.cxx | 23 ++---- src/emucore/Paddles.hxx | 8 +- src/emucore/PlusROM.cxx | 8 +- src/emucore/PlusROM.hxx | 4 +- src/emucore/ProfilingRunner.cxx | 5 +- src/emucore/PropsSet.cxx | 4 +- src/emucore/Serializer.cxx | 2 +- src/emucore/Settings.cxx | 2 +- src/emucore/Settings.hxx | 2 +- src/emucore/Switches.cxx | 8 +- src/emucore/Switches.hxx | 5 +- src/emucore/System.cxx | 5 +- src/emucore/System.hxx | 4 +- src/emucore/TIASurface.cxx | 8 +- src/emucore/Thumbulator.cxx | 8 +- src/emucore/Thumbulator.hxx | 6 +- src/emucore/tia/Player.hxx | 2 +- src/emucore/tia/TIA.cxx | 6 +- .../tia/frame-manager/FrameLayoutDetector.cxx | 3 +- .../tia/frame-manager/FrameLayoutDetector.hxx | 3 +- src/gui/AboutDialog.cxx | 10 +-- src/gui/AboutDialog.hxx | 2 +- src/gui/BrowserDialog.cxx | 3 +- src/gui/ContextMenu.hxx | 2 +- src/gui/DeveloperDialog.cxx | 39 +++++----- src/gui/DeveloperDialog.hxx | 4 +- src/gui/Dialog.cxx | 14 ++-- src/gui/Dialog.hxx | 2 +- src/gui/EditableWidget.cxx | 8 +- src/gui/EditableWidget.hxx | 8 +- src/gui/EventMappingWidget.cxx | 35 +++++---- src/gui/FileListWidget.cxx | 4 +- src/gui/FileListWidget.hxx | 2 +- src/gui/GameInfoDialog.cxx | 14 ++-- src/gui/GuiObject.hxx | 2 +- src/gui/HighScoresDialog.cxx | 2 +- src/gui/HighScoresDialog.hxx | 2 +- src/gui/InputDialog.cxx | 2 +- src/gui/InputTextDialog.cxx | 2 +- src/gui/JoystickDialog.cxx | 2 +- src/gui/LauncherDialog.cxx | 9 ++- src/gui/LauncherDialog.hxx | 3 +- src/gui/LauncherFileListWidget.cxx | 12 +-- src/gui/ListWidget.cxx | 2 +- src/gui/MessageDialog.cxx | 11 +-- src/gui/MessageDialog.hxx | 6 +- src/gui/MessageMenu.cxx | 11 +-- src/gui/MessageMenu.hxx | 6 +- src/gui/OptionsDialog.cxx | 2 +- src/gui/PopUpWidget.cxx | 5 +- src/gui/ProgressDialog.hxx | 2 +- src/gui/R77HelpDialog.hxx | 2 +- src/gui/RadioButtonWidget.cxx | 2 +- src/gui/RomAuditDialog.cxx | 6 +- src/gui/RomImageWidget.cxx | 9 ++- src/gui/RomInfoWidget.cxx | 6 +- src/gui/StellaSettingsDialog.cxx | 4 +- src/gui/StellaSettingsDialog.hxx | 4 +- src/gui/TimeLineWidget.cxx | 2 +- src/gui/UIDialog.cxx | 12 ++- src/gui/UndoHandler.cxx | 2 +- src/gui/UndoHandler.hxx | 2 +- src/gui/VideoAudioDialog.cxx | 8 +- src/gui/Widget.cxx | 35 +++++---- src/gui/Widget.hxx | 2 +- src/os/libretro/FBBackendLIBRETRO.hxx | 2 +- src/os/unix/FSNodePOSIX.cxx | 2 +- src/os/unix/OSystemUNIX.cxx | 2 +- src/os/unix/SerialPortUNIX.cxx | 7 -- src/os/unix/SerialPortUNIX.hxx | 2 +- 174 files changed, 825 insertions(+), 829 deletions(-) diff --git a/src/cheat/BankRomCheat.cxx b/src/cheat/BankRomCheat.cxx index 360c3f47d..5e37258fc 100644 --- a/src/cheat/BankRomCheat.cxx +++ b/src/cheat/BankRomCheat.cxx @@ -51,7 +51,7 @@ bool BankRomCheat::disable() myOSystem.console().cartridge().bank(bank); for(int i = 0; i < count; ++i) - myOSystem.console().cartridge().patch(address + i, savedRom[i]); + myOSystem.console().cartridge().patch(address + i, savedRom[i]); myOSystem.console().cartridge().bank(oldBank); diff --git a/src/cheat/CheatCodeDialog.cxx b/src/cheat/CheatCodeDialog.cxx index 8b007825a..bbb3c2a2a 100644 --- a/src/cheat/CheatCodeDialog.cxx +++ b/src/cheat/CheatCodeDialog.cxx @@ -133,9 +133,9 @@ void CheatCodeDialog::loadConfig() myCheatList->setList(l, b); // Redraw the list, auto-selecting the first item if possible - myCheatList->setSelected(l.size() > 0 ? 0 : -1); + myCheatList->setSelected(!l.empty() ? 0 : -1); - const bool enabled = (list.size() > 0); + const bool enabled = !list.empty(); myEditButton->setEnabled(enabled); myRemoveButton->setEnabled(enabled); } @@ -233,7 +233,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd, { const string& name = myCheatInput->getResult(0); const string& code = myCheatInput->getResult(1); - if(instance().cheat().isValidCode(code)) + if(CheatManager::isValidCode(code)) { myCheatInput->close(); instance().cheat().add(name, code); @@ -250,7 +250,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd, const string& code = myCheatInput->getResult(1); const bool enable = myCheatList->getSelectedState(); const int idx = myCheatList->getSelected(); - if(instance().cheat().isValidCode(code)) + if(CheatManager::isValidCode(code)) { myCheatInput->close(); instance().cheat().add(name, code, enable, idx); @@ -273,7 +273,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd, { const string& name = myCheatInput->getResult(0); const string& code = myCheatInput->getResult(1); - if(instance().cheat().isValidCode(code)) + if(CheatManager::isValidCode(code)) { myCheatInput->close(); instance().cheat().addOneShot(name, code); diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index 7bd5b0984..e3d462031 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -272,11 +272,11 @@ void CheatManager::loadCheats(const string& md5sum) // Set up any cheatcodes that was on the command line // (and remove the key from the settings, so they won't get set again) const string& cheats = myOSystem.settings().getString("cheat"); - if(cheats != "") + if(!cheats.empty()) myOSystem.settings().setValue("cheat", ""); const auto& iter = myCheatMap.find(md5sum); - if(iter == myCheatMap.end() && cheats == "") + if(iter == myCheatMap.end() && cheats.empty()) return; // Remember the cheats for this ROM @@ -311,7 +311,7 @@ void CheatManager::saveCheats(const string& md5sum) myCheatMap.erase(iter); // Add new entry only if there are any cheats defined - if(cheats.str() != "") + if(!cheats.str().empty()) myCheatMap.emplace(md5sum, cheats.str()); } @@ -322,7 +322,7 @@ void CheatManager::saveCheats(const string& md5sum) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CheatManager::isValidCode(const string& code) const +bool CheatManager::isValidCode(const string& code) { for(const auto c: code) if(!isxdigit(c)) diff --git a/src/cheat/CheatManager.hxx b/src/cheat/CheatManager.hxx index ba2e269fd..0e1eea5cc 100644 --- a/src/cheat/CheatManager.hxx +++ b/src/cheat/CheatManager.hxx @@ -121,7 +121,7 @@ class CheatManager /** Checks if a code is valid. */ - bool isValidCode(const string& code) const; + static bool isValidCode(const string& code); private: /** diff --git a/src/common/FBBackendSDL2.cxx b/src/common/FBBackendSDL2.cxx index 47b64eeb2..dec71cadc 100644 --- a/src/common/FBBackendSDL2.cxx +++ b/src/common/FBBackendSDL2.cxx @@ -97,8 +97,7 @@ void FBBackendSDL2::queryHardware(vector& fullscreenRes, s << "Supported video modes (" << numModes << ") for display " << i << " (" << SDL_GetDisplayName(i) << "):"; - string lastRes = ""; - + string lastRes; for(int m = 0; m < numModes; ++m) { SDL_DisplayMode mode; @@ -428,7 +427,7 @@ bool FBBackendSDL2::createRenderer() if(myRenderer) SDL_DestroyRenderer(myRenderer); - if(video != "") + if(!video.empty()) SDL_SetHint(SDL_HINT_RENDER_DRIVER, video.c_str()); myRenderer = SDL_CreateRenderer(myWindow, -1, renderFlags); @@ -567,7 +566,7 @@ unique_ptr FBBackendSDL2::createSurface( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBBackendSDL2::readPixels(uInt8* pixels, size_t pitch, +void FBBackendSDL2::readPixels(uInt8* buffer, size_t pitch, const Common::Rect& rect) const { ASSERT_MAIN_THREAD; @@ -576,7 +575,7 @@ void FBBackendSDL2::readPixels(uInt8* pixels, size_t pitch, r.x = rect.x(); r.y = rect.y(); r.w = rect.w(); r.h = rect.h(); - SDL_RenderReadPixels(myRenderer, &r, 0, pixels, static_cast(pitch)); + SDL_RenderReadPixels(myRenderer, &r, 0, buffer, static_cast(pitch)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/FSNodeZIP.cxx b/src/common/FSNodeZIP.cxx index aa0cb75d3..65dc0a82b 100644 --- a/src/common/FSNodeZIP.cxx +++ b/src/common/FSNodeZIP.cxx @@ -131,7 +131,7 @@ void FSNodeZIP::setFlags(const string& zipfile, const string& virtualpath, _shortPath = _realNode->getShortPath(); // Is a file component present? - if(_virtualPath.size() != 0) + if(!_virtualPath.empty()) { _path += ("/" + _virtualPath); _shortPath += ("/" + _virtualPath); @@ -190,7 +190,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const { // First strip off the leading directory const string& curr = name.substr( - _virtualPath == "" ? 0 : _virtualPath.size()+1); + _virtualPath.empty() ? 0 : _virtualPath.size()+1); // cerr << " curr: " << curr << endl; // Only add sub-directory entries once const auto pos = curr.find_first_of("/\\"); @@ -203,7 +203,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const for(const auto& dir: dirs) { // Prepend previous path - const string& vpath = _virtualPath != "" ? _virtualPath + "/" + dir : dir; + const string& vpath = !_virtualPath.empty() ? _virtualPath + "/" + dir : dir; myList.emplace_back(new FSNodeZIP(_zipFile, vpath, _realNode, 0, true)); } @@ -215,7 +215,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodeZIP::read(ByteBuffer& image, size_t) const +size_t FSNodeZIP::read(ByteBuffer& buffer, size_t) const { switch(_error) { @@ -234,24 +234,24 @@ size_t FSNodeZIP::read(ByteBuffer& image, size_t) const found = name == _virtualPath; } - return found ? myZipHandler->decompress(image) : 0; + return found ? myZipHandler->decompress(buffer) : 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodeZIP::read(stringstream& image) const +size_t FSNodeZIP::read(stringstream& buffer) const { // For now, we just read into a buffer and store in the stream // TODO: maybe there's a more efficient way to do this? - ByteBuffer buffer; - const size_t size = read(buffer, 0); + ByteBuffer read_buf; + const size_t size = read(read_buf, 0); if(size > 0) - image.write(reinterpret_cast(buffer.get()), size); + buffer.write(reinterpret_cast(read_buf.get()), size); return size; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodeZIP::write(const ByteBuffer& buffer, size_t size) const +size_t FSNodeZIP::write(const ByteBuffer& buffer, size_t) const { // TODO: Not yet implemented throw runtime_error("ZIP file not writable"); @@ -267,7 +267,7 @@ size_t FSNodeZIP::write(const stringstream& buffer) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AbstractFSNodePtr FSNodeZIP::getParent() const { - if(_virtualPath == "") + if(_virtualPath.empty()) return _realNode ? _realNode->getParent() : nullptr; const char* start = _path.c_str(); diff --git a/src/common/FSNodeZIP.hxx b/src/common/FSNodeZIP.hxx index 1ff9f110b..643b59c84 100644 --- a/src/common/FSNodeZIP.hxx +++ b/src/common/FSNodeZIP.hxx @@ -63,9 +63,9 @@ class FSNodeZIP : public AbstractFSNode bool getChildren(AbstractFSList& list, ListMode mode) const override; AbstractFSNodePtr getParent() const override; - size_t read(ByteBuffer& buffer, size_t size) const override; + size_t read(ByteBuffer& buffer, size_t) const override; size_t read(stringstream& buffer) const override; - size_t write(const ByteBuffer& buffer, size_t size) const override; + size_t write(const ByteBuffer& buffer, size_t) const override; size_t write(const stringstream& buffer) const override; private: diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index b46cffbff..f3e085888 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -85,7 +85,7 @@ Int16 HighScoresManager::peek(uInt16 addr) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const json HighScoresManager::properties(const Properties& props) const +json HighScoresManager::properties(const Properties& props) { const string& property = props.get(PropType::Cart_Highscore); @@ -95,7 +95,6 @@ const json HighScoresManager::properties(const Properties& props) const return json::parse(property); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - json HighScoresManager::properties(json& jprops) const { @@ -114,7 +113,6 @@ json HighScoresManager::properties(json& jprops) const return jprops = properties(props); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool HighScoresManager::enabled() const { @@ -124,12 +122,11 @@ bool HighScoresManager::enabled() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoresManager::numVariations(const json& jprops) const +uInt32 HighScoresManager::numVariations(const json& jprops) { return min(getPropInt(jprops, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR, ScoresProps& info) const @@ -159,7 +156,7 @@ bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void HighScoresManager::set(Properties& props, uInt32 numVariations, - const ScoresProps& info) const + const ScoresProps& info) { json jprops = json::object(); @@ -207,85 +204,79 @@ void HighScoresManager::set(Properties& props, uInt32 numVariations, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoresManager::numDigits(const json& jprops) const +uInt32 HighScoresManager::numDigits(const json& jprops) { return min(getPropInt(jprops, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoresManager::trailingZeroes(const json& jprops) const +uInt32 HighScoresManager::trailingZeroes(const json& jprops) { return min(getPropInt(jprops, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoresManager::scoreBCD(const json& jprops) const +bool HighScoresManager::scoreBCD(const json& jprops) { return getPropBool(jprops, SCORE_BCD, DEFAULT_SCORE_BCD); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoresManager::scoreInvert(const json& jprops) const +bool HighScoresManager::scoreInvert(const json& jprops) { return getPropBool(jprops, SCORE_INVERTED, DEFAULT_SCORE_REVERSED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoresManager::varBCD(const json& jprops) const +bool HighScoresManager::varBCD(const json& jprops) { return getPropBool(jprops, VARIATIONS_BCD, DEFAULT_VARS_BCD); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoresManager::varZeroBased(const json& jprops) const +bool HighScoresManager::varZeroBased(const json& jprops) { return getPropBool(jprops, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string HighScoresManager::specialLabel(const json& jprops) const +string HighScoresManager::specialLabel(const json& jprops) { return getPropStr(jprops, SPECIAL_LABEL); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoresManager::specialBCD(const json& jprops) const +bool HighScoresManager::specialBCD(const json& jprops) { return getPropBool(jprops, SPECIAL_BCD, DEFAULT_SPECIAL_BCD); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoresManager::specialZeroBased(const json& jprops) const +bool HighScoresManager::specialZeroBased(const json& jprops) { return getPropBool(jprops, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string HighScoresManager::notes(const json& jprops) const +string HighScoresManager::notes(const json& jprops) { return getPropStr(jprops, NOTES); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt16 HighScoresManager::varAddress(const json& jprops) const +uInt16 HighScoresManager::varAddress(const json& jprops) { return getPropAddr(jprops, VARIATIONS_ADDRESS, DEFAULT_ADDRESS); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt16 HighScoresManager::specialAddress(const json& jprops) const +uInt16 HighScoresManager::specialAddress(const json& jprops) { return getPropAddr(jprops, SPECIAL_ADDRESS, DEFAULT_ADDRESS); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoresManager::numAddrBytes(Int32 digits, Int32 trailing) const -{ - return (digits - trailing + 1) / 2; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoresManager::numAddrBytes(const json& jprops) const +uInt32 HighScoresManager::numAddrBytes(const json& jprops) { return numAddrBytes(numDigits(jprops), trailingZeroes(jprops)); } @@ -299,7 +290,7 @@ Int32 HighScoresManager::numVariations() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string HighScoresManager::specialLabel() const +string HighScoresManager::specialLabel() const { json jprops; @@ -379,7 +370,7 @@ Int32 HighScoresManager::score() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string HighScoresManager::formattedScore(Int32 score, Int32 width) const +string HighScoresManager::formattedScore(Int32 score, Int32 width) const { if(score <= 0) return ""; @@ -403,6 +394,7 @@ const string HighScoresManager::formattedScore(Int32 score, Int32 width) const return buf.str(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string HighScoresManager::md5Props() const { json jprops; @@ -425,6 +417,7 @@ string HighScoresManager::md5Props() const return MD5::hash(buf.str()); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool HighScoresManager::scoreInvert() const { json jprops; @@ -455,7 +448,7 @@ Int32 HighScoresManager::special() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string HighScoresManager::notes() const +string HighScoresManager::notes() const { json jprops; @@ -463,7 +456,8 @@ const string HighScoresManager::notes() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const +Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, + bool zeroBased) { //maxVal += zeroBased ? 0 : 1; maxVal -= zeroBased ? 1 : 0; @@ -487,29 +481,28 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zero // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool HighScoresManager::getPropBool(const json& jprops, const string& key, - bool defVal) const + bool defVal) { return jprops.contains(key) ? jprops.at(key).get() : defVal; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 HighScoresManager::getPropInt(const json& jprops, const string& key, - uInt32 defVal) const + uInt32 defVal) { return jprops.contains(key) ? jprops.at(key).get() : defVal; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string HighScoresManager::getPropStr(const json& jprops, const string& key, - const string& defVal) const +string HighScoresManager::getPropStr(const json& jprops, const string& key, + const string& defVal) { return jprops.contains(key) ? jprops.at(key).get() : defVal; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key, - uInt16 defVal) const + uInt16 defVal) { const string str = getPropStr(jprops, key); @@ -517,7 +510,7 @@ uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops) const +HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops) { ScoreAddresses scoreAddr{}; @@ -544,7 +537,7 @@ const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt16 HighScoresManager::fromHexStr(const string& addr) const +uInt16 HighScoresManager::fromHexStr(const string& addr) { string naked = addr; @@ -555,7 +548,7 @@ uInt16 HighScoresManager::fromHexStr(const string& addr) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Int32 HighScoresManager::fromBCD(uInt8 bcd) const +Int32 HighScoresManager::fromBCD(uInt8 bcd) { // verify if score is legit if ((bcd & 0xF0) >= 0xA0 || (bcd & 0xF) >= 0xA) diff --git a/src/common/HighScoresManager.hxx b/src/common/HighScoresManager.hxx index 813ecc73a..2af491eb4 100644 --- a/src/common/HighScoresManager.hxx +++ b/src/common/HighScoresManager.hxx @@ -112,8 +112,8 @@ class HighScoresManager /** Set the highscore data of game's properties */ - void set(Properties& props, uInt32 numVariations, - const HSM::ScoresProps& info) const; + static void set(Properties& props, uInt32 numVariations, + const HSM::ScoresProps& info); /** Calculate the score from given parameters @@ -125,24 +125,26 @@ class HighScoresManager // Convert the given value, using only the maximum bits required by maxVal // and adjusted for BCD and zero based data - Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const; + static Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased); /** Calculate the number of bytes for one player's score from given parameters @return The number of score address bytes */ - uInt32 numAddrBytes(Int32 digits, Int32 trailing) const; + static uInt32 numAddrBytes(Int32 digits, Int32 trailing) { + return (digits - trailing + 1) / 2; + } // Retrieve current values (using game's properties) Int32 numVariations() const; - const string specialLabel() const; + string specialLabel() const; Int32 variation() const; Int32 score() const; - const string formattedScore(Int32 score, Int32 width = -1) const; + string formattedScore(Int32 score, Int32 width = -1) const; bool scoreInvert() const; Int32 special() const; - const string notes() const; + string notes() const; // Get md5 property definition checksum string md5Props() const; @@ -150,8 +152,8 @@ class HighScoresManager // Peek into memory Int16 peek(uInt16 addr) const; - void loadHighScores(HSM::ScoresData& scores); - void saveHighScores(HSM::ScoresData& scores) const; + void loadHighScores(HSM::ScoresData& data); + void saveHighScores(HSM::ScoresData& data) const; private: static const string VARIATIONS_COUNT; @@ -198,53 +200,53 @@ class HighScoresManager Int32 variation(uInt16 addr, bool varBCD, bool zeroBased, uInt32 numVariations) const; // Get individual highscore info from properties - uInt32 numVariations(const json& jprops) const; - uInt16 varAddress(const json& jprops) const; - uInt16 specialAddress(const json& jprops) const; - uInt32 numDigits(const json& jprops) const; - uInt32 trailingZeroes(const json& jprops) const; - bool scoreBCD(const json& jprops) const; - bool scoreInvert(const json& jprops) const; - bool varBCD(const json& jprops) const; - bool varZeroBased(const json& jprops) const; - const string specialLabel(const json& jprops) const; - bool specialBCD(const json& jprops) const; - bool specialZeroBased(const json& jprops) const; - const string notes(const json& jprops) const; + static uInt32 numVariations(const json& jprops); + static uInt16 varAddress(const json& jprops); + static uInt16 specialAddress(const json& jprops); + static uInt32 numDigits(const json& jprops); + static uInt32 trailingZeroes(const json& jprops); + static bool scoreBCD(const json& jprops); + static bool scoreInvert(const json& jprops); + static bool varBCD(const json& jprops); + static bool varZeroBased(const json& jprops); + static string specialLabel(const json& jprops); + static bool specialBCD(const json& jprops); + static bool specialZeroBased(const json& jprops); + static string notes(const json& jprops); // Calculate the number of bytes for one player's score from property parameters - uInt32 numAddrBytes(const json& jprops) const; + static uInt32 numAddrBytes(const json& jprops); // Get properties - const json properties(const Properties& props) const; + static json properties(const Properties& props); json properties(json& jprops) const; // Get value from highscore properties for given key - bool getPropBool(const json& jprops, const string& key, - bool defVal = false) const; - uInt32 getPropInt(const json& jprops, const string& key, - uInt32 defVal = 0) const; - const string getPropStr(const json& jprops, const string& key, - const string& defVal = "") const; - uInt16 getPropAddr(const json& jprops, const string& key, - uInt16 defVal = 0) const; - const HSM::ScoreAddresses getPropScoreAddr(const json& jprops) const; + static bool getPropBool(const json& jprops, const string& key, + bool defVal = false); + static uInt32 getPropInt(const json& jprops, const string& key, + uInt32 defVal = 0); + static string getPropStr(const json& jprops, const string& key, + const string& defVal = ""); + static uInt16 getPropAddr(const json& jprops, const string& key, + uInt16 defVal = 0); + static HSM::ScoreAddresses getPropScoreAddr(const json& jprops); - uInt16 fromHexStr(const string& addr) const; - Int32 fromBCD(uInt8 bcd) const; + static uInt16 fromHexStr(const string& addr); + static Int32 fromBCD(uInt8 bcd); string hash(const HSM::ScoresData& data) const; /** Loads the current high scores for this game and variation from the given JSON object. @param hsData The JSON to parse - @param scores The loaded high score data + @param data The loaded high score data @return The result of the load. True on success, false on failure. */ - bool load(const json& hsData, HSM::ScoresData& scores); + static bool load(const json& hsData, HSM::ScoresData& data); - void clearHighScores(HSM::ScoresData& data); + static void clearHighScores(HSM::ScoresData& data); private: // Reference to the osystem object diff --git a/src/common/JPGLibrary.hxx b/src/common/JPGLibrary.hxx index 89b805098..028a4c0f6 100644 --- a/src/common/JPGLibrary.hxx +++ b/src/common/JPGLibrary.hxx @@ -77,7 +77,7 @@ class JPGLibrary @param filename The filename to load the JPG image @param metaData The meta data of the JPG image */ - void readMetaData(const string& filename, VariantList& metaData); + static void readMetaData(const string& filename, VariantList& metaData); private: // Following constructors and assignment operators not supported diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index 648d9a3d0..d6ef88aca 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -112,7 +112,7 @@ bool JoyMap::check(const EventMode mode, const int button, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) const +string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) { ostringstream buf; @@ -166,7 +166,7 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve { if (_event == event && _mapping.mode == mode) { - if(buf.str() != "") + if(!buf.str().empty()) buf << ", "; buf << "C" << stick << getDesc(event, _mapping); } @@ -193,26 +193,26 @@ json JoyMap::saveMapping(const EventMode mode) const std::vector sortedMap(myMap.begin(), myMap.end()); std::sort(sortedMap.begin(), sortedMap.end(), - [](const MapType& a, const MapType& b) - { - // Event::Type first - if(a.first.button != b.first.button) - return a.first.button < b.first.button; + [](const MapType& a, const MapType& b) + { + // Event::Type first + if(a.first.button != b.first.button) + return a.first.button < b.first.button; - if(a.first.axis != b.first.axis) - return a.first.axis < b.first.axis; + if(a.first.axis != b.first.axis) + return a.first.axis < b.first.axis; - if(a.first.adir != b.first.adir) - return a.first.adir < b.first.adir; + if(a.first.adir != b.first.adir) + return a.first.adir < b.first.adir; - if(a.first.hat != b.first.hat) - return a.first.hat < b.first.hat; + if(a.first.hat != b.first.hat) + return a.first.hat < b.first.hat; - if(a.first.hdir != b.first.hdir) - return a.first.hdir < b.first.hdir; + if(a.first.hdir != b.first.hdir) + return a.first.hdir < b.first.hdir; - return a.second < b.second; - } + return a.second < b.second; + } ); json eventMappings = json::array(); diff --git a/src/common/JoyMap.hxx b/src/common/JoyMap.hxx index 993548911..934d058fb 100644 --- a/src/common/JoyMap.hxx +++ b/src/common/JoyMap.hxx @@ -122,10 +122,10 @@ class JoyMap void eraseEvent(const Event::Type event, const EventMode mode); /** clear all mappings for a modes */ // void clear() { myMap.clear(); } - size_t size() { return myMap.size(); } + size_t size() const { return myMap.size(); } private: - string getDesc(const Event::Type event, const JoyMapping& mapping) const; + static string getDesc(const Event::Type event, const JoyMapping& mapping); struct JoyHash { size_t operator()(const JoyMapping& m)const { diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index c5b8f1bd1..496448af9 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -135,7 +135,7 @@ bool KeyMap::check(const EventMode mode, const int key, const int mod) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string KeyMap::getDesc(const Mapping& mapping) const +string KeyMap::getDesc(const Mapping& mapping) { ostringstream buf; #if defined(BSPF_MACOS) || defined(MACOS_KEYS) @@ -184,7 +184,7 @@ string KeyMap::getDesc(const Mapping& mapping) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string KeyMap::getDesc(const EventMode mode, const int key, const int mod) const +string KeyMap::getDesc(const EventMode mode, const int key, const int mod) { return getDesc(Mapping(mode, key, mod)); } @@ -198,7 +198,7 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode { if (_event == event && _mapping.mode == mode) { - if(buf.str() != "") + if(!buf.str().empty()) buf << ", "; buf << getDesc(_mapping); } @@ -336,7 +336,7 @@ void KeyMap::eraseEvent(const Event::Type event, const EventMode mode) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const +KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) { Mapping m = mapping; diff --git a/src/common/KeyMap.hxx b/src/common/KeyMap.hxx index a6fef3d5f..a7a80d642 100644 --- a/src/common/KeyMap.hxx +++ b/src/common/KeyMap.hxx @@ -79,8 +79,8 @@ class KeyMap bool check(const EventMode mode, const int key, const int mod) const; /** Get mapping description */ - string getDesc(const Mapping& mapping) const; - string getDesc(const EventMode mode, const int key, const int mod) const; + static string getDesc(const Mapping& mapping); + static string getDesc(const EventMode mode, const int key, const int mod); /** Get the mapping description(s) for given event and mode */ string getEventMappingDesc(const Event::Type event, const EventMode mode) const; @@ -104,7 +104,7 @@ class KeyMap private: //** Convert modifiers */ - Mapping convertMod(const Mapping& mapping) const; + static Mapping convertMod(const Mapping& mapping); struct KeyHash { size_t operator()(const Mapping& m) const { diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index 3b3065dcf..e04828f3a 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -129,7 +129,7 @@ MouseControl::MouseControl(Console& console, const string& mode) Paddles::setDigitalPaddleRange(m_range); // If the mouse isn't used at all, we still need one item in the list - if(myModeList.size() == 0) + if(myModeList.empty()) myModeList.emplace_back("Mouse not used for current controllers"); #if 0 diff --git a/src/common/MouseControl.hxx b/src/common/MouseControl.hxx index 203c5e404..ea0cfb145 100644 --- a/src/common/MouseControl.hxx +++ b/src/common/MouseControl.hxx @@ -73,7 +73,7 @@ class MouseControl void addLeftControllerModes(bool noswap); void addRightControllerModes(bool noswap); void addPaddleModes(int lport, int rport, int lname, int rname); - bool controllerSupportsMouse(Controller& controller); + static bool controllerSupportsMouse(Controller& controller); private: const Properties& myProps; diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 42350874d..efb4c4d68 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -15,7 +15,6 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "Logger.hxx" #include "OSystem.hxx" #include "Console.hxx" #include "Joystick.hxx" @@ -298,7 +297,7 @@ bool PhysicalJoystickHandler::mapStelladaptors(const string& saport, int ID) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool PhysicalJoystickHandler::hasStelladaptors() const { - for(auto& [_id, _joyptr] : mySticks) + for(const auto& [_id, _joyptr] : mySticks) { // remove previously added emulated ports const size_t pos = _joyptr->name.find(" (emulates "); @@ -332,7 +331,7 @@ void PhysicalJoystickHandler::setDefaultAction(int stick, { // if there is no existing mapping for the event and // the default mapping for the event is unused, set default key for event - if(j->joyMap.getEventMapping(map.event, mode).size() == 0 && + if(j->joyMap.getEventMapping(map.event, mode).empty() && !j->joyMap.check(mode, map.button, map.axis, map.adir, map.hat, map.hdir)) { if (map.hat == JOY_CTRL_NONE) @@ -353,8 +352,8 @@ void PhysicalJoystickHandler::setDefaultAction(int stick, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PhysicalJoystickHandler::setStickDefaultMapping(int stick, Event::Type event, - EventMode mode, bool updateDefaults) +void PhysicalJoystickHandler::setStickDefaultMapping( + int stick, Event::Type event, EventMode mode, bool updateDefaults) { const PhysicalJoystickPtr j = joy(stick); @@ -617,7 +616,8 @@ void PhysicalJoystickHandler::enableMapping(const Event::Type event, EventMode m } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, const EventMode mode) const +EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, + const EventMode mode) { if(mode == EventMode::kEmulationMode) { @@ -641,35 +641,35 @@ EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, const E } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event) const +bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event) { return LeftJoystickEvents.find(event) != LeftJoystickEvents.end() || RightJoystickEvents.find(event) != RightJoystickEvents.end(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event) const +bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event) { return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end() || RightPaddlesEvents.find(event) != RightPaddlesEvents.end(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event) const +bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event) { return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end() || RightKeyboardEvents.find(event) != RightKeyboardEvents.end(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event) const +bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event) { return LeftDrivingEvents.find(event) != LeftDrivingEvents.end() || RightDrivingEvents.find(event) != RightDrivingEvents.end(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event) const +bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event) { return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event) || isDrivingEvent(event)); } @@ -732,9 +732,9 @@ string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode if(_joyptr) { //Joystick mapping / labeling - if(_joyptr->joyMap.getEventMapping(event, evMode).size()) + if(!_joyptr->joyMap.getEventMapping(event, evMode).empty()) { - if(buf.str() != "") + if(!buf.str().empty()) buf << ", "; buf << _joyptr->joyMap.getEventMappingDesc(_id, event, evMode); } diff --git a/src/common/PJoystickHandler.hxx b/src/common/PJoystickHandler.hxx index afbdbed9b..730422dd4 100644 --- a/src/common/PJoystickHandler.hxx +++ b/src/common/PJoystickHandler.hxx @@ -76,7 +76,7 @@ class PhysicalJoystickHandler bool remove(const string& name); bool mapStelladaptors(const string& saport, int ID = -1); bool hasStelladaptors() const; - void setDefaultMapping(Event::Type type, EventMode mode); + void setDefaultMapping(Event::Type event, EventMode mode); /** define mappings for current controllers */ void defineControllerMappings(const Controller::Type type, Controller::Jack port); @@ -150,7 +150,7 @@ class PhysicalJoystickHandler void addToDatabase(const PhysicalJoystickPtr& stick); // Set default mapping for given joystick when no mappings already exist - void setStickDefaultMapping(int stick, Event::Type type, EventMode mode, + void setStickDefaultMapping(int stick, Event::Type event, EventMode mode, bool updateDefaults = false); friend ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh); @@ -180,13 +180,13 @@ class PhysicalJoystickHandler bool updateDefaults = false); /** returns the event's controller mode */ - EventMode getEventMode(const Event::Type event, const EventMode mode) const; + static EventMode getEventMode(const Event::Type event, const EventMode mode); /** Checks event type. */ - bool isJoystickEvent(const Event::Type event) const; - bool isPaddleEvent(const Event::Type event) const; - bool isKeyboardEvent(const Event::Type event) const; - bool isDrivingEvent(const Event::Type event) const; - bool isCommonEvent(const Event::Type event) const; + static bool isJoystickEvent(const Event::Type event); + static bool isPaddleEvent(const Event::Type event); + static bool isKeyboardEvent(const Event::Type event); + static bool isDrivingEvent(const Event::Type event); + static bool isCommonEvent(const Event::Type event); void enableCommonMappings(); diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 66a3b4b54..4c45d3b49 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -145,7 +145,7 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event, { // if there is no existing mapping for the event and // the default mapping for the event is unused, set default key for event - if (myKeyMap.getEventMapping(map.event, mode).size() == 0 && + if (myKeyMap.getEventMapping(map.event, mode).empty() && !isMappingUsed(mode, map)) { addMapping(map.event, mode, map.key, static_cast(map.mod)); @@ -249,7 +249,8 @@ void PhysicalKeyboardHandler::defineControllerMappings( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EventMode PhysicalKeyboardHandler::getMode(const Properties& properties, const PropType propType) +EventMode PhysicalKeyboardHandler::getMode(const Properties& properties, + const PropType propType) { const string& propName = properties.get(propType); @@ -403,7 +404,7 @@ void PhysicalKeyboardHandler::enableMapping(const Event::Type event, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event, - const EventMode mode) const + const EventMode mode) { if (mode == EventMode::kEmulationMode) { @@ -427,7 +428,7 @@ EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const +bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) { return LeftJoystickEvents.find(event) != LeftJoystickEvents.end() || QTJoystick3Events.find(event) != QTJoystick3Events.end() @@ -436,7 +437,7 @@ bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const +bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) { return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end() || QTPaddles3Events.find(event) != QTPaddles3Events.end() @@ -445,21 +446,21 @@ bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event) const +bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event) { return LeftDrivingEvents.find(event) != LeftDrivingEvents.end() || RightDrivingEvents.find(event) != RightDrivingEvents.end(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event) const +bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event) { return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end() || RightKeyboardEvents.find(event) != RightKeyboardEvents.end(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event) const +bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event) { return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event)); } diff --git a/src/common/PKeyboardHandler.hxx b/src/common/PKeyboardHandler.hxx index 98e3abdb1..4e455ef12 100644 --- a/src/common/PKeyboardHandler.hxx +++ b/src/common/PKeyboardHandler.hxx @@ -48,10 +48,12 @@ class PhysicalKeyboardHandler void loadSerializedMappings(const string& serializedMappings, EventMode mode); - void setDefaultMapping(Event::Type type, EventMode mode, bool updateDefaults = false); + void setDefaultMapping(Event::Type event, EventMode mode, + bool updateDefaults = false); /** define mappings for current controllers */ - void defineControllerMappings(const Controller::Type type, Controller::Jack port, + void defineControllerMappings(const Controller::Type type, + Controller::Jack port, const Properties& properties); /** enable mappings for emulation mode */ void enableEmulationMappings(); @@ -100,13 +102,13 @@ class PhysicalKeyboardHandler EventMode mode = EventMode::kEmulationMode, bool updateDefaults = false); /** returns the event's controller mode */ - EventMode getEventMode(const Event::Type event, const EventMode mode) const; + static EventMode getEventMode(const Event::Type event, const EventMode mode); /** Checks event type. */ - bool isJoystickEvent(const Event::Type event) const; - bool isPaddleEvent(const Event::Type event) const; - bool isKeyboardEvent(const Event::Type event) const; - bool isDrivingEvent(const Event::Type event) const; - bool isCommonEvent(const Event::Type event) const; + static bool isJoystickEvent(const Event::Type event); + static bool isPaddleEvent(const Event::Type event); + static bool isKeyboardEvent(const Event::Type event); + static bool isDrivingEvent(const Event::Type event); + static bool isCommonEvent(const Event::Type event); void enableCommonMappings(); @@ -114,9 +116,9 @@ class PhysicalKeyboardHandler void enableMapping(const Event::Type event, EventMode mode); /** return event mode for given property */ - EventMode getMode(const Properties& properties, const PropType propType); + static EventMode getMode(const Properties& properties, const PropType propType); /** return event mode for given controller type */ - EventMode getMode(const Controller::Type type); + static EventMode getMode(const Controller::Type type); private: OSystem& myOSystem; diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index 916d9d6f1..ffedcf6d4 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -382,20 +382,20 @@ void PNGLibrary::takeSnapshot(uInt32 number) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PNGLibrary::allocateStorage(size_t w, size_t h) +bool PNGLibrary::allocateStorage(size_t width, size_t height) { // Create space for the entire image (3 bytes per pixel in RGB format) - const size_t req_buffer_size = w * h * 3; + const size_t req_buffer_size = width * height * 3; if(req_buffer_size > ReadInfo.buffer.capacity()) ReadInfo.buffer.reserve(req_buffer_size * 1.5); - const size_t req_row_size = h; + const size_t req_row_size = height; if(req_row_size > ReadInfo.row_pointers.capacity()) ReadInfo.row_pointers.reserve(req_row_size * 1.5); - ReadInfo.width = static_cast(w); - ReadInfo.height = static_cast(h); - ReadInfo.pitch = static_cast(w * 3); + ReadInfo.width = static_cast(width); + ReadInfo.height = static_cast(height); + ReadInfo.pitch = static_cast(width * 3); return true; } diff --git a/src/common/PNGLibrary.hxx b/src/common/PNGLibrary.hxx index 1a6dd49e6..b944e7fec 100644 --- a/src/common/PNGLibrary.hxx +++ b/src/common/PNGLibrary.hxx @@ -49,7 +49,8 @@ class PNGLibrary 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); /** Save the current FrameBuffer image to a PNG file. Note that in most @@ -78,9 +79,9 @@ class PNGLibrary otherwise a runtime_error is thrown containing a more detailed error message. */ - void saveImage(const string& filename, const FBSurface& surface, - const Common::Rect& rect = Common::Rect{}, - const VariantList& metaData = VariantList{}); + static void saveImage(const string& filename, const FBSurface& surface, + const Common::Rect& rect = Common::Rect{}, + const VariantList& metaData = VariantList{}); /** Called at regular intervals, and used to determine whether a @@ -149,10 +150,10 @@ class PNGLibrary dependent on the given dimensions. If memory has been previously allocated and it can accommodate the given dimensions, it is used directly. - @param iwidth The width of the PNG image - @param iheight The height of the PNG image + @param width The width of the PNG image + @param height The height of the PNG image */ - bool allocateStorage(size_t iwidth, size_t iheight); + static bool allocateStorage(size_t width, size_t height); /** The actual method which saves a PNG image. @@ -162,9 +163,9 @@ class PNGLibrary @param height The height of the PNG image @param metaData The meta data to add to the PNG image */ - void saveImageToDisk(std::ofstream& out, const vector& rows, - size_t width, size_t height, - const VariantList& metaData); + static void saveImageToDisk(std::ofstream& out, const vector& rows, + size_t width, size_t height, + const VariantList& metaData); /** Load the PNG data from 'ReadInfo' into the FBSurface. The surface @@ -177,21 +178,25 @@ class PNGLibrary /** Write PNG tEXt chunks to the image. */ - void writeMetaData(const png_structp png_ptr, png_infop info_ptr, - const VariantList& metaData); + static void writeMetaData(const png_structp png_ptr, png_infop info_ptr, + const VariantList& metaData); /** Read PNG tEXt chunks from the image. */ - void readMetaData(const png_structp png_ptr, png_infop info_ptr, - VariantList& metaData); + static void readMetaData(const png_structp png_ptr, png_infop info_ptr, + VariantList& metaData); /** PNG library callback functions */ - static void png_read_data(const png_structp ctx, png_bytep area, png_size_t size); - static void png_write_data(const png_structp ctx, png_bytep area, png_size_t size); + static void png_read_data(const png_structp ctx, png_bytep area, + png_size_t size); + static void png_write_data(const png_structp ctx, png_bytep area, + png_size_t size); static void png_io_flush(const png_structp ctx); - [[noreturn]] static void png_user_warn(const png_structp ctx, png_const_charp str); - [[noreturn]] static void png_user_error(const png_structp ctx, png_const_charp str); + [[noreturn]] static void png_user_warn(const png_structp ctx, + png_const_charp str); + [[noreturn]] static void png_user_error(const png_structp ctx, + png_const_charp str); private: // Following constructors and assignment operators not supported diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index 7fce3905f..d0d809ffd 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -44,7 +44,7 @@ PaletteHandler::PaletteType PaletteHandler::toPaletteType(const string& name) co } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string PaletteHandler::toPaletteName(PaletteType type) const +string PaletteHandler::toPaletteName(PaletteType type) { const string SETTING_NAMES[int(PaletteType::NumTypes)] = { SETTING_STANDARD, SETTING_Z26, SETTING_USER, SETTING_CUSTOM @@ -341,7 +341,7 @@ void PaletteHandler::setPalette() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) +PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) const { PaletteArray destPalette{0}; // Constants for saturation and gray scale calculation @@ -443,7 +443,7 @@ void PaletteHandler::loadUserPalette() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PaletteHandler::generateCustomPalette(ConsoleTiming timing) +void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const { constexpr int NUM_CHROMA = 16; constexpr int NUM_LUMA = 8; @@ -572,7 +572,8 @@ void PaletteHandler::adjustHueSaturation(int& R, int& G, int& B, float H, float } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PaletteHandler::vector2d PaletteHandler::rotate(const PaletteHandler::vector2d& vec, float angle) const +PaletteHandler::vector2d +PaletteHandler::rotate(const PaletteHandler::vector2d& vec, float angle) { const float r = angle * BSPF::PI_f / 180; @@ -581,14 +582,15 @@ PaletteHandler::vector2d PaletteHandler::rotate(const PaletteHandler::vector2d& } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PaletteHandler::vector2d PaletteHandler::scale(const PaletteHandler::vector2d& vec, float factor) const +PaletteHandler::vector2d +PaletteHandler::scale(const PaletteHandler::vector2d& vec, float factor) { return PaletteHandler::vector2d(vec.x * factor, vec.y * factor); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - float PaletteHandler::dotProduct(const PaletteHandler::vector2d& vec1, - const PaletteHandler::vector2d& vec2) const + const PaletteHandler::vector2d& vec2) { return vec1.x * vec2.x + vec1.y * vec2.y; } diff --git a/src/common/PaletteHandler.hxx b/src/common/PaletteHandler.hxx index 87e83acfd..ada3f1f48 100644 --- a/src/common/PaletteHandler.hxx +++ b/src/common/PaletteHandler.hxx @@ -187,7 +187,7 @@ class PaletteHandler @return The palette's settings name */ - string toPaletteName(PaletteType type) const; + static string toPaletteName(PaletteType type); /** Display current adjustable with gauge bar message @@ -208,16 +208,16 @@ class PaletteHandler @param timing Use NTSC or PAL phase shift and generate according palette */ - void generateCustomPalette(ConsoleTiming timing); + void generateCustomPalette(ConsoleTiming timing) const; /** Create new palette by applying palette adjustments on given palette. - @param source The palette which should be adjusted + @param palette The palette which should be adjusted @return An adjusted palette */ - PaletteArray adjustedPalette(const PaletteArray& source); + PaletteArray adjustedPalette(const PaletteArray& palette) const; /** Adjust hue and saturation for given RGB values. @@ -228,22 +228,22 @@ class PaletteHandler @param H The hue adjustment value @param S The saturation */ - void adjustHueSaturation(int& R, int& G, int& B, float H, float S); + static void adjustHueSaturation(int& R, int& G, int& B, float H, float S); /** Rotate a 2D vector. */ - vector2d rotate(const vector2d& vec, float angle) const; + static vector2d rotate(const vector2d& vec, float angle); /** Scale a 2D vector. */ - vector2d scale(const vector2d& vec, float factor) const; + static vector2d scale(const vector2d& vec, float factor); /** Get the dot product of two 2D vectors. */ - float dotProduct(const vector2d& vec1, const vector2d& vec2) const; + static float dotProduct(const vector2d& vec1, const vector2d& vec2); /** Loads a user-defined palette file (from OSystem::paletteFile), filling the diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index c1f179259..78ccac8fa 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -70,9 +70,8 @@ json PhysicalJoystick::getMap() const mapping["name"] = name; - for (auto& mode: { - EventMode::kMenuMode, EventMode::kJoystickMode, EventMode::kPaddlesMode, EventMode::kKeyboardMode, - EventMode::kDrivingMode, EventMode::kCommonMode + for (const auto& mode: { + EventMode::kMenuMode, EventMode::kJoystickMode, EventMode::kPaddlesMode, EventMode::kKeyboardMode, EventMode::kDrivingMode, EventMode::kCommonMode }) mapping[jsonName(mode)] = joyMap.saveMapping(mode); @@ -153,7 +152,7 @@ void PhysicalJoystick::eraseEvent(Event::Type event, EventMode mode) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PhysicalJoystick::getValues(const string& list, IntArray& map) const +void PhysicalJoystick::getValues(const string& list, IntArray& map) { map.clear(); istringstream buf(list); diff --git a/src/common/PhysicalJoystick.hxx b/src/common/PhysicalJoystick.hxx index 571fd868d..2e1505618 100644 --- a/src/common/PhysicalJoystick.hxx +++ b/src/common/PhysicalJoystick.hxx @@ -76,7 +76,7 @@ class PhysicalJoystick JoyMap joyMap; private: - void getValues(const string& list, IntArray& map) const; + static void getValues(const string& list, IntArray& map); friend ostream& operator<<(ostream& os, const PhysicalJoystick& s) { os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 6b6e6250f..2a7e9a61f 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -137,12 +137,12 @@ bool SoundSDL2::openDevice() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void SoundSDL2::setEnabled(bool state) +void SoundSDL2::setEnabled(bool enable) { - myAudioSettings.setEnabled(state); - if (myAudioQueue) myAudioQueue->ignoreOverflows(!state); + myAudioSettings.setEnabled(enable); + if (myAudioQueue) myAudioQueue->ignoreOverflows(!enable); - Logger::debug(state ? "SoundSDL2::setEnabled(true)" : + Logger::debug(enable ? "SoundSDL2::setEnabled(true)" : "SoundSDL2::setEnabled(false)"); } diff --git a/src/common/StaggeredLogger.hxx b/src/common/StaggeredLogger.hxx index 2a42c91af..76de24349 100644 --- a/src/common/StaggeredLogger.hxx +++ b/src/common/StaggeredLogger.hxx @@ -28,9 +28,10 @@ #include "Logger.hxx" /** - * This class buffers log events and logs them after a certain time window has expired. - * The timout increases after every log line by a factor of two until a maximum is reached. - * If no events are reported, the window size decreases again. + * This class buffers log events and logs them after a certain time window has + * expired. The timout increases after every log line by a factor of two until + * a maximum is reached. If no events are reported, the window size decreases + * again. */ class StaggeredLogger @@ -46,7 +47,7 @@ class StaggeredLogger void _log(); - void onTimerExpired(uInt32 timerId); + void onTimerExpired(uInt32 timerCallbackId); void startInterval(); diff --git a/src/common/ThreadDebugging.hxx b/src/common/ThreadDebugging.hxx index 05f127469..dbfd42edd 100644 --- a/src/common/ThreadDebugging.hxx +++ b/src/common/ThreadDebugging.hxx @@ -46,7 +46,7 @@ class ThreadDebuggingHelper { private: - [[noreturn]] void fail(const string& message); + [[noreturn]] static void fail(const string& message); ThreadDebuggingHelper() = default; diff --git a/src/common/TimerManager.cxx b/src/common/TimerManager.cxx index 1cf19c9e0..b0ffdd34d 100644 --- a/src/common/TimerManager.cxx +++ b/src/common/TimerManager.cxx @@ -20,8 +20,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TimerManager::TimerManager() - : nextId{no_timer + 1}, - queue() + : nextId{no_timer + 1} { } diff --git a/src/common/main.cxx b/src/common/main.cxx index b2ebb5e58..61f8b5f3f 100644 --- a/src/common/main.cxx +++ b/src/common/main.cxx @@ -281,7 +281,7 @@ int main(int ac, char* av[]) { attachConsole(); Logger::debug("Displaying usage"); - theOSystem->settings().usage(); + Settings::usage(); freeConsole(); return Cleanup(); } @@ -294,15 +294,15 @@ int main(int ac, char* av[]) // If not, use the built-in ROM launcher. In this case, we enter 'launcher' // mode and let the main event loop take care of opening a new console/ROM. FSNode romnode(romfile); - if(romfile == "" || romnode.isDirectory()) + if(romfile.empty() || romnode.isDirectory()) { Logger::debug("Attempting to use ROM launcher ..."); - bool launcherOpened = romfile != "" ? + bool launcherOpened = !romfile.empty() ? theOSystem->createLauncher(romnode.getPath()) : theOSystem->createLauncher(); if(!launcherOpened) { Logger::debug("Launcher could not be started, showing usage"); - theOSystem->settings().usage(); + Settings::usage(); return Cleanup(); } } @@ -333,7 +333,7 @@ int main(int ac, char* av[]) #ifdef DEBUGGER_SUPPORT // Set up any breakpoint that was on the command line - if(localOpts["break"].toString() != "") + if(!localOpts["break"].toString().empty()) { Debugger& dbg = theOSystem->debugger(); uInt16 bp = uInt16(dbg.stringToValue(localOpts["break"].toString())); diff --git a/src/common/repository/KeyValueRepositoryConfigfile.hxx b/src/common/repository/KeyValueRepositoryConfigfile.hxx index 14859153b..a787f66ef 100644 --- a/src/common/repository/KeyValueRepositoryConfigfile.hxx +++ b/src/common/repository/KeyValueRepositoryConfigfile.hxx @@ -27,7 +27,7 @@ class KeyValueRepositoryConfigfile : public KeyValueRepositoryFile::load; using KeyValueRepositoryFile::save; - explicit KeyValueRepositoryConfigfile(const FSNode& node); + explicit KeyValueRepositoryConfigfile(const FSNode& file); static std::map load(istream& in); diff --git a/src/common/repository/KeyValueRepositoryPropertyFile.cxx b/src/common/repository/KeyValueRepositoryPropertyFile.cxx index a75b318fe..141a23642 100644 --- a/src/common/repository/KeyValueRepositoryPropertyFile.cxx +++ b/src/common/repository/KeyValueRepositoryPropertyFile.cxx @@ -91,7 +91,7 @@ std::map KeyValueRepositoryPropertyFile::load(istream& in) if(!in) return map; // A null key signifies the end of the property list - if(key == "") + if(key.empty()) break; // Get the value associated with this property @@ -111,7 +111,7 @@ std::map KeyValueRepositoryPropertyFile::load(istream& in) bool KeyValueRepositoryPropertyFile::save(ostream& out, const std::map& values) { - for (auto& [key, value]: values) { + for (const auto& [key, value]: values) { writeQuotedString(out, key); out.put(' '); writeQuotedString(out, value.toString()); diff --git a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx index 87eeada71..cd668541a 100644 --- a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx @@ -45,7 +45,7 @@ bool CompositeKeyValueRepositorySqlite::has(const string& key) try { (*myStmtCountSet) .reset() - .bind(1, key.c_str()); + .bind(1, key); if (!myStmtCountSet->step()) throw SqliteError("count failed"); @@ -68,7 +68,7 @@ void CompositeKeyValueRepositorySqlite::remove(const string& key) try { (*myStmtDeleteSet) .reset() - .bind(1, key.c_str()) + .bind(1, key) .step(); myStmtDelete->reset(); @@ -153,9 +153,9 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtInsert( ) { return (*myRepo.myStmtInsert) .reset() - .bind(1, myKey.c_str()) - .bind(2, key.c_str()) - .bind(3, value.c_str()); + .bind(1, myKey) + .bind(2, key) + .bind(3, value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -163,7 +163,7 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtSelect( { return (*myRepo.myStmtSelect) .reset() - .bind(1, myKey.c_str()); + .bind(1, myKey); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -172,8 +172,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtDelete( myRepo.myStmtDelete->reset(); return (*myRepo.myStmtDelete) - .bind(1, myKey.c_str()) - .bind(2, key.c_str()); + .bind(1, myKey) + .bind(2, key); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -181,8 +181,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtSelectO { return (*myRepo.myStmtSelectOne) .reset() - .bind(1, myKey.c_str()) - .bind(2, key.c_str()); + .bind(1, myKey) + .bind(2, key); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -190,8 +190,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtCount(c { return (*myRepo.myStmtCount) .reset() - .bind(1, myKey.c_str()) - .bind(2, key.c_str()); + .bind(1, myKey) + .bind(2, key); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx index 52c599076..43c570a4e 100644 --- a/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx @@ -34,8 +34,8 @@ SqliteStatement& KeyValueRepositorySqlite::stmtInsert(const string& key, const s { return (*myStmtInsert) .reset() - .bind(1, key.c_str()) - .bind(2, value.c_str()); + .bind(1, key) + .bind(2, value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -50,7 +50,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtDelete(const string& key) { return (*myStmtDelete) .reset() - .bind(1, key.c_str()); + .bind(1, key); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -58,7 +58,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtCount(const string& key) { return (*myStmtCount) .reset() - .bind(1, key.c_str()); + .bind(1, key); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -66,7 +66,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtSelectOne(const string& key) { return (*myStmtSelectOne) .reset() - .bind(1, key.c_str()); + .bind(1, key); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/repository/sqlite/SqliteDatabase.cxx b/src/common/repository/sqlite/SqliteDatabase.cxx index 3b86b8976..749ca0b27 100644 --- a/src/common/repository/sqlite/SqliteDatabase.cxx +++ b/src/common/repository/sqlite/SqliteDatabase.cxx @@ -105,7 +105,7 @@ Int32 SqliteDatabase::getUserVersion() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void SqliteDatabase::setUserVersion(Int32 version) +void SqliteDatabase::setUserVersion(Int32 version) const { SqliteStatement(*this, "PRAGMA user_version = %i", static_cast(version)) .step(); diff --git a/src/common/repository/sqlite/SqliteDatabase.hxx b/src/common/repository/sqlite/SqliteDatabase.hxx index 994d5c9bf..607a378bd 100644 --- a/src/common/repository/sqlite/SqliteDatabase.hxx +++ b/src/common/repository/sqlite/SqliteDatabase.hxx @@ -42,7 +42,7 @@ class SqliteDatabase void exec(const string& sql, T arg1, Ts... args); Int32 getUserVersion() const; - void setUserVersion(Int32 version); + void setUserVersion(Int32 version) const; private: diff --git a/src/common/repository/sqlite/StellaDb.cxx b/src/common/repository/sqlite/StellaDb.cxx index 6d3b83b8e..b632bd330 100644 --- a/src/common/repository/sqlite/StellaDb.cxx +++ b/src/common/repository/sqlite/StellaDb.cxx @@ -85,7 +85,7 @@ void StellaDb::initialize() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string StellaDb::databaseFileName() const +string StellaDb::databaseFileName() const { return myDb ? FSNode(myDb->fileName()).getShortPath() : "[failed]"; } @@ -190,8 +190,11 @@ void StellaDb::importOldPropset(const FSNode& node) while (true) { auto props = KeyValueRepositoryPropertyFile::load(in); - if (props.size() == 0) break; - if ((props.find("Cart.MD5") == props.end()) || props["Cart.MD5"].toString() == "") continue; + if (props.empty()) + break; + if ((props.find("Cart.MD5") == props.end()) || + props["Cart.MD5"].toString().empty()) + continue; myPropertyRepository->get(props["Cart.MD5"].toString())->save(props); } diff --git a/src/common/repository/sqlite/StellaDb.hxx b/src/common/repository/sqlite/StellaDb.hxx index d744eda1c..33252a752 100644 --- a/src/common/repository/sqlite/StellaDb.hxx +++ b/src/common/repository/sqlite/StellaDb.hxx @@ -27,21 +27,25 @@ class StellaDb { public: - StellaDb(const string& databaseDirectory, const string& databaseName); void initialize(); - KeyValueRepositoryAtomic& settingsRepository() const { return *mySettingsRepository; } - CompositeKeyValueRepository& propertyRepository() const { return *myPropertyRepository; } - CompositeKeyValueRepositoryAtomic& highscoreRepository() const { return *myHighscoreRepository; } + KeyValueRepositoryAtomic& settingsRepository() const { + return *mySettingsRepository; + } + CompositeKeyValueRepository& propertyRepository() const { + return *myPropertyRepository; + } + CompositeKeyValueRepositoryAtomic& highscoreRepository() const { + return *myHighscoreRepository; + } - const string databaseFileName() const; + string databaseFileName() const; bool isValid() const; private: - void initializeDb(); void importOldSettings(); void importStellarc(const FSNode& node); @@ -51,7 +55,6 @@ class StellaDb void migrate(); private: - string myDatabaseDirectory; string myDatabaseName; diff --git a/src/common/tv_filters/AtariNTSC.hxx b/src/common/tv_filters/AtariNTSC.hxx index 14828d139..df9a217ed 100644 --- a/src/common/tv_filters/AtariNTSC.hxx +++ b/src/common/tv_filters/AtariNTSC.hxx @@ -187,10 +187,10 @@ class AtariNTSC 0.9563F, 0.6210F, -0.2721F, -0.6474F, -1.1070F, 1.7046F }; - void init(init_t& impl, const Setup& setup); - void initFilters(init_t& impl, const Setup& setup); + static void init(init_t& impl, const Setup& setup); + static void initFilters(init_t& impl, const Setup& setup); // Generate pixel at all burst phases and column alignments - void genKernel(init_t& impl, float y, float i, float q, uInt32* out); + static void genKernel(init_t& impl, float y, float i, float q, uInt32* out); // Begins outputting row and starts two pixels. First pixel will be cut // off a bit. Use atari_ntsc_black for unused pixels. diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index d6daf8a0d..c1b6e61e3 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -139,7 +139,7 @@ void NTSCFilter::loadConfig(const Settings& settings) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NTSCFilter::saveConfig(Settings& settings) const +void NTSCFilter::saveConfig(Settings& settings) { // Save adjustables for custom mode settings.setValue("tv.sharpness", myCustomSetup.sharpness); @@ -150,7 +150,7 @@ void NTSCFilter::saveConfig(Settings& settings) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset) const +void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset) { switch(preset) { @@ -181,7 +181,7 @@ void NTSCFilter::setCustomAdjustables(const Adjustable& adjustable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void NTSCFilter::convertToAdjustable(Adjustable& adjustable, - const AtariNTSC::Setup& setup) const + const AtariNTSC::Setup& setup) { adjustable.sharpness = scaleTo100(setup.sharpness); adjustable.resolution = scaleTo100(setup.resolution); diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index 4d526cfd4..dcd59925d 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -80,12 +80,12 @@ class NTSCFilter // Get adjustables for the given preset // Values will be scaled to 0 - 100 range, independent of how // they're actually stored internally - void getAdjustables(Adjustable& adjustable, Preset preset) const; + static void getAdjustables(Adjustable& adjustable, Preset preset); // Set custom adjustables to given values // Values will be scaled to 0 - 100 range, independent of how // they're actually stored internally - void setCustomAdjustables(const Adjustable& adjustable); + static void setCustomAdjustables(const Adjustable& adjustable); // The following methods cycle through each custom adjustable // They are used in conjunction with the increase/decrease @@ -101,8 +101,8 @@ class NTSCFilter string& text, string& valueText, Int32& newValue); // Load and save NTSC-related settings - void loadConfig(const Settings& settings); - void saveConfig(Settings& settings) const; + static void loadConfig(const Settings& settings); + static void saveConfig(Settings& settings); // Perform Blargg filtering on input buffer, place results in // output buffer @@ -125,8 +125,8 @@ class NTSCFilter private: // Convert from atari_ntsc_setup_t values to equivalent adjustables - void convertToAdjustable(Adjustable& adjustable, - const AtariNTSC::Setup& setup) const; + static void convertToAdjustable(Adjustable& adjustable, + const AtariNTSC::Setup& setup); private: // The NTSC object diff --git a/src/debugger/BreakpointMap.cxx b/src/debugger/BreakpointMap.cxx index ad59d314b..ece14d4f2 100644 --- a/src/debugger/BreakpointMap.cxx +++ b/src/debugger/BreakpointMap.cxx @@ -110,7 +110,8 @@ BreakpointMap::BreakpointList BreakpointMap::getBreakpoints() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -BreakpointMap::Breakpoint BreakpointMap::convertBreakpoint(const Breakpoint& breakpoint) +BreakpointMap::Breakpoint BreakpointMap::convertBreakpoint( + const Breakpoint& breakpoint) { if(breakpoint.bank == ANY_BANK) return Breakpoint(breakpoint.addr, ANY_BANK); diff --git a/src/debugger/BreakpointMap.hxx b/src/debugger/BreakpointMap.hxx index ad2d3b073..6155e63c7 100644 --- a/src/debugger/BreakpointMap.hxx +++ b/src/debugger/BreakpointMap.hxx @@ -90,7 +90,7 @@ class BreakpointMap size_t size() const { return myMap.size(); } private: - Breakpoint convertBreakpoint(const Breakpoint& breakpoint); + static Breakpoint convertBreakpoint(const Breakpoint& breakpoint); struct BreakpointHash { size_t operator()(const Breakpoint& bp) const { diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 47bec83e0..4c730b04d 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -232,7 +232,7 @@ string CartDebug::toString() for(uInt32 j = 0; j < bytesPerLine; ++j) { - buf << myDebugger.invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " "; + buf << Debugger::invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " "; if(j == 0x07) buf << " "; } @@ -379,7 +379,7 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, Disassembly& disassembly, disassembly.list.clear(); addrToLineList.clear(); // An empty address list means that DiStella can't do a disassembly - if(info.addressList.size() == 0) + if(info.addressList.empty()) return false; disassembly.fieldwidth = 24 + myLabelLength; @@ -832,7 +832,7 @@ string CartDebug::loadListFile() getline(in, line); - if(!in.good() || line == "" || line[0] == '-') + if(!in.good() || line.empty() || line[0] == '-') continue; else // Search for constants { @@ -1133,7 +1133,7 @@ string CartDebug::saveDisassembly(string path) disassembleBank(bank); // An empty address list means that DiStella can't do a disassembly - if(info.addressList.size() == 0) + if(info.addressList.empty()) continue; buf << "\n\n;***********************************************************\n" @@ -1165,7 +1165,7 @@ string CartDebug::saveDisassembly(string path) const DisassemblyTag& tag = dt; // Add label (if any) - if(tag.label != "") + if(!tag.label.empty()) buf << ALIGN(4) << (tag.label) << "\n"; buf << " "; @@ -1377,7 +1377,7 @@ string CartDebug::saveDisassembly(string path) } } - if(myReserved.Label.size() > 0) + if(!myReserved.Label.empty()) { out << "\n\n;-----------------------------------------------------------\n" << "; Non Locatable Labels\n" @@ -1386,7 +1386,7 @@ string CartDebug::saveDisassembly(string path) out << ALIGN(16) << iter.second << "= $" << iter.first << "\n"; } - if(myUserLabels.size() > 0) + if(!myUserLabels.empty()) { out << "\n\n;-----------------------------------------------------------\n" << "; User Defined Labels\n" @@ -1561,7 +1561,7 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartDebug::AddrType CartDebug::addressType(uInt16 addr) const +CartDebug::AddrType CartDebug::addressType(uInt16 addr) { // Determine the type of address to access the correct list // These addresses were based on (and checked against) Kroko's 2600 memory @@ -1643,7 +1643,7 @@ void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) const +Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) { if(flags & Device::CODE) return Device::CODE; @@ -1670,7 +1670,7 @@ Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) cons } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const +void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) { switch(type) { @@ -1689,7 +1689,7 @@ void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const +void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags) { if(flags) { diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index da8f4b450..edf2a817b 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -66,7 +66,7 @@ class CartDebug : public DebuggerSystem // Determine 'type' of address (ie, what part of the system accessed) enum class AddrType { TIA, IO, ZPRAM, ROM }; - AddrType addressType(uInt16 addr) const; + static AddrType addressType(uInt16 addr); public: CartDebug(Debugger& dbg, Console& console, const OSystem& osystem); @@ -260,13 +260,13 @@ class CartDebug : public DebuggerSystem Methods used by the command parser for tab-completion In this case, return completions from the equate list(s) */ - void getCompletions(const char* in, StringList& list) const; + void getCompletions(const char* in, StringList& completions) const; // Convert given address to corresponding access type and append to buf void accessTypeAsString(ostream& buf, uInt16 addr) const; // Convert access enum type to corresponding string and append to buf - void AccessTypeAsString(ostream& buf, Device::AccessType type) const; + static void AccessTypeAsString(ostream& buf, Device::AccessType type); private: using AddrToLineList = std::map; @@ -330,11 +330,11 @@ class CartDebug : public DebuggerSystem void getBankDirectives(ostream& buf, const BankInfo& info) const; // Get access enum type from 'flags', taking precendence into account - Device::AccessType accessTypeAbsolute(Device::AccessFlags flags) const; + static Device::AccessType accessTypeAbsolute(Device::AccessFlags flags); // Convert all access types in 'flags' to corresponding string and // append to buf - void AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const; + static void AccessTypeAsString(ostream& buf, Device::AccessFlags flags); private: const OSystem& myOSystem; diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index c9b777d79..0f99bf825 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -218,13 +218,13 @@ TrapArray& Debugger::writeTraps() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Debugger::run(const string& command) +string Debugger::run(const string& command) { return myParser->run(command); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Debugger::invIfChanged(int reg, int oldReg) +string Debugger::invIfChanged(int reg, int oldReg) { string ret; @@ -361,7 +361,7 @@ int Debugger::trace() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) +bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) const { if(checkBreakPoint(addr, bank)) return false; @@ -371,7 +371,7 @@ bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) +bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) const { if(!checkBreakPoint(addr, bank)) return false; @@ -381,13 +381,13 @@ bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::checkBreakPoint(uInt16 addr, uInt8 bank) +bool Debugger::checkBreakPoint(uInt16 addr, uInt8 bank) const { return breakPoints().check(addr, bank); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank) +bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank) const { if(checkBreakPoint(addr, bank)) clearBreakPoint(addr, bank); @@ -398,53 +398,53 @@ bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::addReadTrap(uInt16 t) +void Debugger::addReadTrap(uInt16 t) const { readTraps().initialize(); readTraps().add(t); } -void Debugger::addWriteTrap(uInt16 t) +void Debugger::addWriteTrap(uInt16 t) const { writeTraps().initialize(); writeTraps().add(t); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::addTrap(uInt16 t) +void Debugger::addTrap(uInt16 t) const { addReadTrap(t); addWriteTrap(t); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::removeReadTrap(uInt16 t) +void Debugger::removeReadTrap(uInt16 t) const { readTraps().initialize(); readTraps().remove(t); } -void Debugger::removeWriteTrap(uInt16 t) +void Debugger::removeWriteTrap(uInt16 t) const { writeTraps().initialize(); writeTraps().remove(t); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::removeTrap(uInt16 t) +void Debugger::removeTrap(uInt16 t) const { removeReadTrap(t); removeWriteTrap(t); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::readTrap(uInt16 t) +bool Debugger::readTrap(uInt16 t) const { return readTraps().isInitialized() && readTraps().isSet(t); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::writeTrap(uInt16 t) +bool Debugger::writeTrap(uInt16 t) const { return writeTraps().isInitialized() && writeTraps().isSet(t); } @@ -700,13 +700,13 @@ uInt16 Debugger::unwindStates(const uInt16 numStates, string& message) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::clearAllBreakPoints() +void Debugger::clearAllBreakPoints() const { breakPoints().clear(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::clearAllTraps() +void Debugger::clearAllTraps() const { readTraps().clearAll(); writeTraps().clearAll(); @@ -829,7 +829,7 @@ bool Debugger::delFunction(const string& name) const Expression& Debugger::getFunction(const string& name) const { const auto& iter = myFunctions.find(name); - return iter != myFunctions.end() ? *(iter->second.get()) : EmptyExpression; + return iter != myFunctions.end() ? *(iter->second) : EmptyExpression; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -840,13 +840,13 @@ const string& Debugger::getFunctionDef(const string& name) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const Debugger::FunctionDefMap Debugger::getFunctionDefMap() const +Debugger::FunctionDefMap Debugger::getFunctionDefMap() const { return myFunctionDefs; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string Debugger::builtinHelp() const +string Debugger::builtinHelp() { ostringstream buf; size_t c_maxlen = 0, i_maxlen = 0; diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index a2301986e..7944fb96b 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -111,13 +111,13 @@ class Debugger : public DialogContainer bool addFunction(const string& name, const string& def, Expression* exp, bool builtin = false); - bool isBuiltinFunction(const string& name); + static bool isBuiltinFunction(const string& name); bool delFunction(const string& name); const Expression& getFunction(const string& name) const; const string& getFunctionDef(const string& name) const; - const FunctionDefMap getFunctionDefMap() const; - string builtinHelp() const; + FunctionDefMap getFunctionDefMap() const; + static string builtinHelp(); /** Methods used by the command parser for tab-completion @@ -168,33 +168,33 @@ class Debugger : public DialogContainer Returns true if successfully set */ bool setBreakPoint(uInt16 addr, uInt8 bank = ANY_BANK, - uInt32 flags = 0); + uInt32 flags = 0) const; /** Clears a breakpoint. Returns true if successfully cleared */ - bool clearBreakPoint(uInt16 addr, uInt8 bank); + bool clearBreakPoint(uInt16 addr, uInt8 bank) const; /** Toggles a breakpoint Returns new state of breakpoint */ - bool toggleBreakPoint(uInt16 addr, uInt8 bank); + bool toggleBreakPoint(uInt16 addr, uInt8 bank) const; /** Checks for a breakpoint. Returns true if existing, else false */ - bool checkBreakPoint(uInt16 addr, uInt8 bank); + bool checkBreakPoint(uInt16 addr, uInt8 bank) const; /** Run the debugger command and return the result. */ - const string run(const string& command); + string run(const string& command); string autoExec(StringList* history); @@ -235,7 +235,7 @@ class Debugger : public DialogContainer } /** Invert given input if it differs from its previous value */ - const string invIfChanged(int reg, int oldReg); + static string invIfChanged(int reg, int oldReg); /** This is used when we want the debugger from a class that can't @@ -261,7 +261,7 @@ class Debugger : public DialogContainer Device::AccessFlags getAccessFlags(uInt16 addr) const; void setAccessFlags(uInt16 addr, Device::AccessFlags flags); - uInt32 getBaseAddress(uInt32 addr, bool read); + static uInt32 getBaseAddress(uInt32 addr, bool read); bool patchROM(uInt16 addr, uInt8 value); @@ -315,17 +315,17 @@ class Debugger : public DialogContainer uInt16 rewindStates(const uInt16 numStates, string& message); uInt16 unwindStates(const uInt16 numStates, string& message); - void clearAllBreakPoints(); + void clearAllBreakPoints() const; - void addReadTrap(uInt16 t); - void addWriteTrap(uInt16 t); - void addTrap(uInt16 t); - void removeReadTrap(uInt16 t); - void removeWriteTrap(uInt16 t); - void removeTrap(uInt16 t); - bool readTrap(uInt16 t); - bool writeTrap(uInt16 t); - void clearAllTraps(); + void addReadTrap(uInt16 t) const; + void addWriteTrap(uInt16 t) const; + void addTrap(uInt16 t) const; + void removeReadTrap(uInt16 t) const; + void removeWriteTrap(uInt16 t) const; + void removeTrap(uInt16 t) const; + bool readTrap(uInt16 t) const; + bool writeTrap(uInt16 t) const; + void clearAllTraps() const; void log(const string& triggerMsg); // Set a bunch of RAM locations at once diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 6c73d713e..95acc5b63 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -25,9 +25,7 @@ #include "ControlLowLevel.hxx" #include "TIADebug.hxx" #include "TiaOutputWidget.hxx" -#include "DebuggerParser.hxx" #include "YaccParser.hxx" -#include "M6502.hxx" #include "Expression.hxx" #include "FSNode.hxx" #include "OSystem.hxx" @@ -177,7 +175,7 @@ void DebuggerParser::outputCommandError(const string& errorMsg, int command) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Completion-related stuff: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerParser::getCompletions(const char* in, StringList& completions) const +void DebuggerParser::getCompletions(const char* in, StringList& completions) { // cerr << "Attempting to complete \"" << in << "\"" << endl; for(const auto& c: commands) @@ -309,7 +307,7 @@ string DebuggerParser::showWatches() ostringstream buf; for(uInt32 i = 0; i < myWatches.size(); ++i) { - if(myWatches[i] != "") + if(!myWatches[i].empty()) { // Clear the args, since we're going to pass them to eval() argStrings.clear(); @@ -337,7 +335,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb) ParseState state = ParseState::IN_COMMAND; size_t i = 0; const size_t length = command.length(); - string curArg = ""; + string curArg; verb = ""; argStrings.clear(); @@ -390,14 +388,14 @@ bool DebuggerParser::getArgs(const string& command, string& verb) while(i < length); // Take care of the last argument, if there is one - if(curArg != "") + if(!curArg.empty()) argStrings.push_back(curArg); argCount = static_cast(argStrings.size()); for(uInt32 arg = 0; arg < argCount; ++arg) { - if(!YaccParser::parse(argStrings[arg].c_str())) + if(!YaccParser::parse(argStrings[arg])) { unique_ptr expr(YaccParser::getResult()); args.push_back(expr->evaluate()); @@ -545,8 +543,8 @@ string DebuggerParser::eval() { string rlabel = debugger.cartDebug().getLabel(args[i], true); string wlabel = debugger.cartDebug().getLabel(args[i], false); - const bool validR = rlabel != "" && rlabel[0] != '$', - validW = wlabel != "" && wlabel[0] != '$'; + const bool validR = !rlabel.empty() && rlabel[0] != '$', + validW = !wlabel.empty() && wlabel[0] != '$'; if(validR && validW) { if(rlabel == wlabel) @@ -587,7 +585,7 @@ void DebuggerParser::listTraps(bool listCond) commandResult << (listCond ? "trapifs:" : "traps:") << endl; for(uInt32 i = 0; i < names.size(); ++i) { - const bool hasCond = names[i] != ""; + const bool hasCond = !names[i].empty(); if(hasCond == listCond) { commandResult << Base::toString(i) << ": "; @@ -619,23 +617,23 @@ string DebuggerParser::trapStatus(const Trap& trap) string lblb = debugger.cartDebug().getLabel(trap.begin, !trap.write); string lble = debugger.cartDebug().getLabel(trap.end, !trap.write); - if(lblb != "") { + if(!lblb.empty()) { result << " ("; result << lblb; } if(trap.begin != trap.end) { - if(lble != "") + if(!lble.empty()) { - if (lblb != "") + if(!lblb.empty()) result << " "; else result << " ("; result << lble; } } - if (lblb != "" || lble != "") + if(!lblb.empty() || !lble.empty()) result << ")"; return result.str(); @@ -647,7 +645,7 @@ string DebuggerParser::saveScriptFile(string file) stringstream out; Debugger::FunctionDefMap funcs = debugger.getFunctionDefMap(); for(const auto& [name, cmd]: funcs) - if (!debugger.isBuiltinFunction(name)) + if (!Debugger::isBuiltinFunction(name)) out << "function " << name << " {" << cmd << "}" << endl; for(const auto& w: myWatches) @@ -669,7 +667,7 @@ string DebuggerParser::saveScriptFile(string file) { const bool read = myTraps[i]->read, write = myTraps[i]->write, - hasCond = names[i] != ""; + hasCond = !names[i].empty(); if(read && write) out << "trap"; @@ -744,7 +742,7 @@ void DebuggerParser::executeDirective(Device::AccessType type) const bool result = debugger.cartDebug().addDirective(type, args[0], args[1]); commandResult << (result ? "added " : "removed "); - debugger.cartDebug().AccessTypeAsString(commandResult, type); + CartDebug::AccessTypeAsString(commandResult, type); commandResult << " directive on range $" << hex << args[0] << " $" << hex << args[1]; debugger.rom().invalidate(); @@ -873,7 +871,7 @@ void DebuggerParser::executeBreak() // "breakIf" void DebuggerParser::executeBreakIf() { - int res = YaccParser::parse(argStrings[0].c_str()); + int res = YaccParser::parse(argStrings[0]); if(res == 0) { string condition = argStrings[0]; @@ -1273,7 +1271,7 @@ void DebuggerParser::executeDump() DebuggerDialog* dlg = debugger.myDialog; BrowserDialog::show(dlg, "Save Dump as", path.str(), BrowserDialog::Mode::FileSave, - [this, dlg, outStr, resultStr] + [dlg, outStr, resultStr] (bool OK, const FSNode& node) { if(OK) @@ -1352,7 +1350,7 @@ void DebuggerParser::executeFunction() return; } - int res = YaccParser::parse(argStrings[1].c_str()); + int res = YaccParser::parse(argStrings[1]); if(res == 0) { debugger.addFunction(argStrings[0], argStrings[1], YaccParser::getResult()); @@ -1388,7 +1386,7 @@ void DebuggerParser::executeHelp() commandResult << setw(static_cast(clen)) << right << c.cmdString << " - " << c.description << endl; - commandResult << debugger.builtinHelp(); + commandResult << Debugger::builtinHelp(); } else // get help for specific command { @@ -1567,7 +1565,7 @@ void DebuggerParser::executeListBreaks() StringList conds = debugger.m6502().getCondBreakNames(); - if(conds.size() > 0) + if(!conds.empty()) { if(count) commandResult << endl; @@ -1579,7 +1577,7 @@ void DebuggerParser::executeListBreaks() } } - if(commandResult.str() == "") + if(commandResult.str().empty()) commandResult << "no breakpoints set"; } @@ -1599,7 +1597,7 @@ void DebuggerParser::executeListFunctions() { const Debugger::FunctionDefMap& functions = debugger.getFunctionDefMap(); - if(functions.size() > 0) + if(!functions.empty()) for(const auto& [name, cmd]: functions) commandResult << name << " -> " << cmd << endl; else @@ -1613,7 +1611,7 @@ void DebuggerParser::executeListSaveStateIfs() ostringstream buf; StringList conds = debugger.m6502().getCondSaveStateNames(); - if(conds.size() > 0) + if(!conds.empty()) { commandResult << "saveStateIf:" << endl; for(uInt32 i = 0; i < conds.size(); ++i) @@ -1623,7 +1621,7 @@ void DebuggerParser::executeListSaveStateIfs() } } - if(commandResult.str() == "") + if(commandResult.str().empty()) commandResult << "no savestateifs defined"; } @@ -1639,11 +1637,11 @@ void DebuggerParser::executeListTraps() return; } - if (names.size() > 0) + if(!names.empty()) { bool trapFound = false, trapifFound = false; for(const auto& name: names) - if(name == "") + if(name.empty()) trapFound = true; else trapifFound = true; @@ -1705,7 +1703,7 @@ void DebuggerParser::executeN() // "palette" void DebuggerParser::executePalette() { - commandResult << debugger.tiaDebug().palette(); + commandResult << TIADebug::palette(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2087,7 +2085,7 @@ void DebuggerParser::executeSaveState() // "saveStateIf" void DebuggerParser::executeSaveStateIf() { - int res = YaccParser::parse(argStrings[0].c_str()); + int res = YaccParser::parse(argStrings[0]); if(res == 0) { string condition = argStrings[0]; @@ -2130,7 +2128,7 @@ void DebuggerParser::executeStep() // "stepWhile" void DebuggerParser::executeStepWhile() { - int res = YaccParser::parse(argStrings[0].c_str()); + int res = YaccParser::parse(argStrings[0]); if(res != 0) { commandResult << red("invalid expression"); return; @@ -2256,10 +2254,10 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command, } // base addresses of mirrors - const uInt32 beginRead = debugger.getBaseAddress(begin, true); - const uInt32 endRead = debugger.getBaseAddress(end, true); - const uInt32 beginWrite = debugger.getBaseAddress(begin, false); - const uInt32 endWrite = debugger.getBaseAddress(end, false); + const uInt32 beginRead = Debugger::getBaseAddress(begin, true); + const uInt32 endRead = Debugger::getBaseAddress(end, true); + const uInt32 beginWrite = Debugger::getBaseAddress(begin, false); + const uInt32 endWrite = Debugger::getBaseAddress(end, false); stringstream conditionBuf; // parenthesize provided and address range condition(s) (begin) @@ -2289,7 +2287,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command, const string condition = conditionBuf.str(); - int res = YaccParser::parse(condition.c_str()); + int res = YaccParser::parse(condition); if(res == 0) { // duplicates will remove each other @@ -2334,7 +2332,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command, // wrapper function for trap(if)/trapRead(if)/trapWrite(if) commands void DebuggerParser::executeTrapRW(uInt32 addr, bool read, bool write, bool add) { - switch(debugger.cartDebug().addressType(addr)) + switch(CartDebug::addressType(addr)) { case CartDebug::AddrType::TIA: { diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index bd8394e4f..9cd114ac8 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -42,7 +42,7 @@ class DebuggerParser /** Given a substring, determine matching substrings from the list of available commands. Used in the debugger prompt for tab-completion */ - void getCompletions(const char* in, StringList& list) const; + static void getCompletions(const char* in, StringList& completions); /** Evaluate the given expression using operators, current base, etc */ int decipher_arg(const string& str); @@ -65,8 +65,8 @@ class DebuggerParser bool validateArgs(int cmd); string eval(); string saveScriptFile(string file); - void saveDump(const FSNode& node, const stringstream& out, - ostringstream& result); + static void saveDump(const FSNode& node, const stringstream& out, + ostringstream& result); const string& cartName() const; private: diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index 805c50451..f0eea7bf9 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -80,7 +80,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // multi-byte instruction, then we make note of that address for reference // // However, we only do this for labels pointing to ROM (above $1000) - if (myDbg.addressType(k + myOffset) == CartDebug::AddrType::ROM) { + if (CartDebug::addressType(k + myOffset) == CartDebug::AddrType::ROM) { reservedLabel.str(""); reservedLabel << "L" << Base::HEX4 << (k + myOffset); myReserved.Label.emplace(k + myOffset, reservedLabel.str()); @@ -944,7 +944,7 @@ DiStella::AddressType DiStella::mark(uInt32 address, uInt16 mask, bool directive // Check for equates before ROM/ZP-RAM accesses, because the original logic // of Distella assumed either equates or ROM; it didn't take ZP-RAM into account - const CartDebug::AddrType type = myDbg.addressType(address); + const CartDebug::AddrType type = CartDebug::addressType(address); if(type == CartDebug::AddrType::TIA) { return AddressType::TIA; } @@ -1003,18 +1003,18 @@ bool DiStella::checkBits(uInt16 address, uInt16 mask, uInt16 notMask, bool useDe } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DiStella::check_range(uInt16 beg, uInt16 end) const +bool DiStella::check_range(uInt16 start, uInt16 end) const { - if (beg > end) { - cerr << "Beginning of range greater than end: start = " << std::hex << beg + if (start > end) { + cerr << "Beginning of range greater than end: start = " << std::hex << start << ", end = " << std::hex << end << endl; return false; - } else if (beg > myAppData.end + myOffset) { - cerr << "Beginning of range out of range: start = " << std::hex << beg + } else if (start > myAppData.end + myOffset) { + cerr << "Beginning of range out of range: start = " << std::hex << start << ", range = " << std::hex << (myAppData.end + myOffset) << endl; return false; - } else if (beg < myOffset) { - cerr << "Beginning of range out of range: start = " << std::hex << beg + } else if (start < myOffset) { + cerr << "Beginning of range out of range: start = " << std::hex << start << ", offset = " << std::hex << myOffset << endl; return false; } diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index 491372b91..72ea6d484 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -377,29 +377,29 @@ string RiotDebug::toString() const auto& oldstate = static_cast(getOldState()); ostringstream buf; - buf << "280/SWCHA(R)=" << myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R) - << " 280/SWCHA(W)=" << myDebugger.invIfChanged(state.SWCHA_W, oldstate.SWCHA_W) - << " 281/SWACNT=" << myDebugger.invIfChanged(state.SWACNT, oldstate.SWACNT) + buf << "280/SWCHA(R)=" << Debugger::invIfChanged(state.SWCHA_R, oldstate.SWCHA_R) + << " 280/SWCHA(W)=" << Debugger::invIfChanged(state.SWCHA_W, oldstate.SWCHA_W) + << " 281/SWACNT=" << Debugger::invIfChanged(state.SWACNT, oldstate.SWACNT) << endl - << "282/SWCHB(R)=" << myDebugger.invIfChanged(state.SWCHB_R, oldstate.SWCHB_R) - << " 282/SWCHB(W)=" << myDebugger.invIfChanged(state.SWCHB_W, oldstate.SWCHB_W) - << " 283/SWBCNT=" << myDebugger.invIfChanged(state.SWBCNT, oldstate.SWBCNT) + << "282/SWCHB(R)=" << Debugger::invIfChanged(state.SWCHB_R, oldstate.SWCHB_R) + << " 282/SWCHB(W)=" << Debugger::invIfChanged(state.SWCHB_W, oldstate.SWCHB_W) + << " 283/SWBCNT=" << Debugger::invIfChanged(state.SWBCNT, oldstate.SWBCNT) << endl // These are squirrely: some symbol files will define these as // 0x284-0x287. Doesn't actually matter, these registers repeat // every 16 bytes. - << "294/TIM1T=" << myDebugger.invIfChanged(state.TIM1T, oldstate.TIM1T) - << " 295/TIM8T=" << myDebugger.invIfChanged(state.TIM8T, oldstate.TIM8T) - << " 296/TIM64T=" << myDebugger.invIfChanged(state.TIM64T, oldstate.TIM64T) - << " 297/T1024T=" << myDebugger.invIfChanged(state.T1024T, oldstate.T1024T) + << "294/TIM1T=" << Debugger::invIfChanged(state.TIM1T, oldstate.TIM1T) + << " 295/TIM8T=" << Debugger::invIfChanged(state.TIM8T, oldstate.TIM8T) + << " 296/TIM64T=" << Debugger::invIfChanged(state.TIM64T, oldstate.TIM64T) + << " 297/T1024T=" << Debugger::invIfChanged(state.T1024T, oldstate.T1024T) << endl - << "0x284/INTIM=" << myDebugger.invIfChanged(state.INTIM, oldstate.INTIM) - << " 285/TIMINT=" << myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT) - << " Timer_Clocks=" << myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS) - << " INTIM_Clocks=" << myDebugger.invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS) - << " Divider=" << myDebugger.invIfChanged(state.TIMDIV, oldstate.TIMDIV) + << "0x284/INTIM=" << Debugger::invIfChanged(state.INTIM, oldstate.INTIM) + << " 285/TIMINT=" << Debugger::invIfChanged(state.TIMINT, oldstate.TIMINT) + << " Timer_Clocks=" << Debugger::invIfChanged(state.TIMCLKS, oldstate.TIMCLKS) + << " INTIM_Clocks=" << Debugger::invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS) + << " Divider=" << Debugger::invIfChanged(state.TIMDIV, oldstate.TIMDIV) << endl << "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP1String() diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 0d8e3aa38..17fc528a3 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -995,7 +995,7 @@ shared_ptr TIADebug::delayQueueIterator() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::colorSwatch(uInt8 c) const +string TIADebug::colorSwatch(uInt8 c) { string ret; @@ -1019,7 +1019,7 @@ string TIADebug::audFreq1() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::audFreq(uInt8 dist, uInt8 div) +string TIADebug::audFreq(uInt8 dist, uInt8 div) const { static constexpr uInt16 dist_div[16] = { 1, 15, 465, 465, 2, 2, 31, 31, @@ -1154,7 +1154,7 @@ string TIADebug::debugColors() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::palette() const +string TIADebug::palette() { ostringstream buf; diff --git a/src/debugger/TIADebug.hxx b/src/debugger/TIADebug.hxx index 209c9b079..472350231 100644 --- a/src/debugger/TIADebug.hxx +++ b/src/debugger/TIADebug.hxx @@ -63,7 +63,7 @@ class TIADebug : public DebuggerSystem void saveOldState() override; string toString() override; string debugColors() const; - string palette() const; + static string palette(); // TIA byte (or part of a byte) registers uInt8 nusiz0(int newVal = -1); @@ -185,14 +185,18 @@ class TIADebug : public DebuggerSystem private: /** Display a color patch for color at given index in the palette */ - string colorSwatch(uInt8 c) const; + static string colorSwatch(uInt8 c); - string audFreq(uInt8 dist, uInt8 div); - 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); + string audFreq(uInt8 dist, uInt8 div) const; + static string stringOnly(const string& value, bool changed = false); + static string decWithLabel(const string& label, uInt16 value, + bool changed = false, uInt16 width = 3); + static string hexWithLabel(const string& label, uInt16 value, + bool changed = false, uInt16 width = 2); + static string binWithLabel(const string& label, uInt16 value, + bool changed = false); + static string boolWithLabel(const string& label, bool value, + bool changed = false); private: TiaState myState; diff --git a/src/debugger/gui/BoosterWidget.cxx b/src/debugger/gui/BoosterWidget.cxx index a010492ed..f14f870f1 100644 --- a/src/debugger/gui/BoosterWidget.cxx +++ b/src/debugger/gui/BoosterWidget.cxx @@ -126,6 +126,3 @@ void BoosterWidget::handleCommand( } } } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -constexpr std::array BoosterWidget::ourPinNo; diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index a4b0780e9..19c0e53db 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -63,7 +63,7 @@ CartridgeE7Widget::CartridgeE7Widget( void CartridgeE7Widget::initialize(GuiObject* boss, const CartridgeE7& cart, const ostringstream& info) { - const uInt32 size = cart.romBankCount() * cart.BANK_SIZE; + const uInt32 size = cart.romBankCount() * CartridgeE7::BANK_SIZE; constexpr int xpos = 2; int ypos = addBaseInformation(size, "M Network", info.str(), 15) + myLineHeight; @@ -148,7 +148,7 @@ string CartridgeE7Widget::bankState() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 CartridgeE7Widget::internalRamSize() { - return myCart.RAM_SIZE; + return CartridgeE7::RAM_SIZE; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/CartE7Widget.hxx b/src/debugger/gui/CartE7Widget.hxx index b826508de..fe7f760c6 100644 --- a/src/debugger/gui/CartE7Widget.hxx +++ b/src/debugger/gui/CartE7Widget.hxx @@ -52,9 +52,10 @@ class CartridgeE7Widget : public CartDebugWidget }; protected: - void initialize(GuiObject* boss, const CartridgeE7& cart, const ostringstream& info); + void initialize(GuiObject* boss, const CartridgeE7& cart, + const ostringstream& info); const char* getSpotLower(int idx); - const char* getSpotUpper(int idx); + static const char* getSpotUpper(int idx); private: void saveOldState() override; diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index e16611360..7e3f90703 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -384,7 +384,7 @@ uInt32 CartridgeEnhancedWidget::internalRamRPort(int start) string CartridgeEnhancedWidget::internalRamDescription() { ostringstream desc; - string indent = ""; + string indent; if(myCart.ramBankCount()) { diff --git a/src/debugger/gui/CartRamWidget.hxx b/src/debugger/gui/CartRamWidget.hxx index b8d54a97c..4eedecc80 100644 --- a/src/debugger/gui/CartRamWidget.hxx +++ b/src/debugger/gui/CartRamWidget.hxx @@ -65,7 +65,7 @@ class CartRamWidget : public Widget, public CommandSender InternalRamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h, - CartDebugWidget& cartDebug); + CartDebugWidget& dbg); ~InternalRamWidget() override = default; string getLabel(int addr) const override; diff --git a/src/debugger/gui/CartWDWidget.cxx b/src/debugger/gui/CartWDWidget.cxx index f877f21e9..da89f3f21 100644 --- a/src/debugger/gui/CartWDWidget.cxx +++ b/src/debugger/gui/CartWDWidget.cxx @@ -22,8 +22,7 @@ CartridgeWDWidget::CartridgeWDWidget( GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h, CartridgeWD& cart) - : CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart), - myCartWD{cart} + : CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart) { initialize(); } @@ -46,7 +45,7 @@ string CartridgeWDWidget::description() string CartridgeWDWidget::hotspotStr(int bank, int segment, bool prefix) { ostringstream info; - const CartridgeWD::BankOrg banks = myCartWD.ourBankOrg[bank]; + const CartridgeWD::BankOrg banks = CartridgeWD::ourBankOrg[bank]; info << "(" << (prefix ? "hotspot " : "") << "$" << Common::Base::HEX1 << (myCart.hotspot() + bank) << ") [" diff --git a/src/debugger/gui/CartWDWidget.hxx b/src/debugger/gui/CartWDWidget.hxx index a985d18a7..0c8224517 100644 --- a/src/debugger/gui/CartWDWidget.hxx +++ b/src/debugger/gui/CartWDWidget.hxx @@ -31,9 +31,6 @@ class CartridgeWDWidget : public CartridgeEnhancedWidget CartridgeWD& cart); ~CartridgeWDWidget() override = default; - private: - CartridgeWD& myCartWD; - private: string manufacturer() override { return "Wickstead Design"; } diff --git a/src/debugger/gui/DataGridRamWidget.hxx b/src/debugger/gui/DataGridRamWidget.hxx index c0d8f6f01..808e9c40c 100644 --- a/src/debugger/gui/DataGridRamWidget.hxx +++ b/src/debugger/gui/DataGridRamWidget.hxx @@ -30,7 +30,7 @@ class DataGridRamWidget : public DataGridWidget const GUI::Font& font, int x, int y, int cols, int rows, int colchars, int bits, - Common::Base::Fmt format = Common::Base::Fmt::_DEFAULT, + Common::Base::Fmt base = Common::Base::Fmt::_DEFAULT, bool useScrollbar = false); ~DataGridRamWidget() override = default; diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index ffd246b49..943c9e23e 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -308,7 +308,7 @@ void DataGridWidget::handleMouseWheel(int x, int y, int direction) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int DataGridWidget::findItem(int x, int y) +int DataGridWidget::findItem(int x, int y) const { int row = (y - 1) / _rowHeight; if(row >= _rows) row = _rows - 1; @@ -759,8 +759,8 @@ void DataGridWidget::endEditMode() enableEditMode(false); // Update the both the string representation and the real data - if(editString().size() > 0 && !(editString()[0] == '$' || - editString()[0] == '#' || editString()[0] == '\\')) + if(!editString().empty() && !(editString()[0] == '$' || + editString()[0] == '#' || editString()[0] == '\\')) { switch(_base) { diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 4cabfb14a..a7c868d0b 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -43,7 +43,7 @@ class DataGridWidget : public EditableWidget DataGridWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int cols, int rows, int colchars, int bits, - Common::Base::Fmt format = Common::Base::Fmt::_DEFAULT, + Common::Base::Fmt base = Common::Base::Fmt::_DEFAULT, bool useScrollbar = false); ~DataGridWidget() override = default; @@ -92,7 +92,7 @@ class DataGridWidget : public EditableWidget protected: void drawWidget(bool hilite) override; - int findItem(int x, int y); + int findItem(int x, int y) const; void startEditMode() override; void endEditMode() override; diff --git a/src/debugger/gui/DelayQueueWidget.cxx b/src/debugger/gui/DelayQueueWidget.cxx index e871f99cf..80e262862 100644 --- a/src/debugger/gui/DelayQueueWidget.cxx +++ b/src/debugger/gui/DelayQueueWidget.cxx @@ -39,7 +39,8 @@ DelayQueueWidget::DelayQueueWidget( _w = 20 * font.getMaxCharWidth() + 6; _h = static_cast(myLines.size() * font.getLineHeight() + 6); - for (auto&& line : myLines) line = ""; + for (auto&& line : myLines) + line = ""; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -50,7 +51,7 @@ void DelayQueueWidget::loadConfig() { using Common::Base; for (auto&& line : myLines) { if (!delayQueueIterator->isValid()) { - if(line != "") + if(!line.empty()) { setDirty(); line = ""; diff --git a/src/debugger/gui/Joy2BPlusWidget.cxx b/src/debugger/gui/Joy2BPlusWidget.cxx index d9d019727..db00dbf0d 100644 --- a/src/debugger/gui/Joy2BPlusWidget.cxx +++ b/src/debugger/gui/Joy2BPlusWidget.cxx @@ -126,6 +126,3 @@ void Joy2BPlusWidget::handleCommand( } } } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -constexpr std::array Joy2BPlusWidget::ourPinNo; diff --git a/src/debugger/gui/PointingDeviceWidget.cxx b/src/debugger/gui/PointingDeviceWidget.cxx index 1b33b8ff8..659c8d9fa 100644 --- a/src/debugger/gui/PointingDeviceWidget.cxx +++ b/src/debugger/gui/PointingDeviceWidget.cxx @@ -140,7 +140,8 @@ void PointingDeviceWidget::setGrayCodeV() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PointingDeviceWidget::setValue(DataGridWidget* grayValue, const int index, const int direction) +void PointingDeviceWidget::setValue(DataGridWidget* grayValue, + const int index, const int direction) { const uInt8 grayCode = getGrayCodeTable(index, direction); diff --git a/src/debugger/gui/PointingDeviceWidget.hxx b/src/debugger/gui/PointingDeviceWidget.hxx index 0c2490439..3078440bc 100644 --- a/src/debugger/gui/PointingDeviceWidget.hxx +++ b/src/debugger/gui/PointingDeviceWidget.hxx @@ -52,7 +52,7 @@ class PointingDeviceWidget : public ControllerWidget void setGrayCodeH(); void setGrayCodeV(); - void setValue(DataGridWidget* greyValue, const int index, const int direction); + void setValue(DataGridWidget* grayValue, const int index, const int direction); // Following constructors and assignment operators not supported PointingDeviceWidget() = delete; diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 1a13c80af..b8947fb59 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -583,7 +583,7 @@ void PromptWidget::historyAdd(const string& entry) void PromptWidget::addToHistory(const char* str) { // Do not add duplicates, remove old duplicate - if(_history.size()) + if(!_history.empty()) { int i = _historyIndex; const int historyEnd = _historyIndex % _history.size(); @@ -618,7 +618,7 @@ void PromptWidget::addToHistory(const char* str) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool PromptWidget::historyScroll(int direction) { - if(_history.size() == 0) + if(_history.empty()) return false; // add current input temporarily to history @@ -695,7 +695,7 @@ bool PromptWidget::execute() } else if(result == "_NO_PROMPT") return true; - else if(result != "") + else if(!result.empty()) print(result + "\n"); } return false; @@ -741,7 +741,7 @@ bool PromptWidget::autoComplete(int direction) if(lastDelimPos == -1) // no delimiters, do only command completion: - instance().debugger().parser().getCompletions(_inputStr, list); + DebuggerParser::getCompletions(_inputStr, list); else { const size_t strLen = len - lastDelimPos - 1; @@ -750,7 +750,7 @@ bool PromptWidget::autoComplete(int direction) { // Special case for 'help' command if(BSPF::startsWithIgnoreCase(_inputStr, "help")) - instance().debugger().parser().getCompletions(_inputStr + lastDelimPos + 1, list); + DebuggerParser::getCompletions(_inputStr + lastDelimPos + 1, list); else { // we got a delimiter, so this must be a label or a function @@ -762,7 +762,7 @@ bool PromptWidget::autoComplete(int direction) } } - if(list.size() < 1) + if(list.empty()) return false; sort(list.begin(), list.end()); diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 2d3b92d58..4eeac582c 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -288,7 +288,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kSValEntered: { const string& result = doSearch(myInputBox->getResult()); - if(result != "") + if(!result.empty()) myInputBox->setMessage(result); else myInputBox->close(); @@ -298,7 +298,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kCValEntered: { const string& result = doCompare(myInputBox->getResult()); - if(result != "") + if(!result.empty()) myInputBox->setMessage(result); else myInputBox->close(); @@ -543,7 +543,7 @@ void RamWidget::showSearchResults() // Only update the search results for the bank currently being shown BoolArray temp; const uInt32 start = myCurrentRamBank * myPageSize; - if(mySearchState.size() == 0 || start > mySearchState.size()) + if(mySearchState.empty() || start > mySearchState.size()) { for(uInt32 i = 0; i < myPageSize; ++i) temp.push_back(false); diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 0ddb878a4..42890ffc7 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -521,8 +521,9 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ControllerWidget* RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, Controller& controller) +ControllerWidget* +RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, Controller& controller) { switch(controller.type()) { diff --git a/src/debugger/gui/RiotWidget.hxx b/src/debugger/gui/RiotWidget.hxx index 20cb11328..6a1a8f99e 100644 --- a/src/debugger/gui/RiotWidget.hxx +++ b/src/debugger/gui/RiotWidget.hxx @@ -37,7 +37,8 @@ class RiotWidget : public Widget, public CommandSender ~RiotWidget() override = default; private: - ControllerWidget* addControlWidget(GuiObject* boss, const GUI::Font& font, + static ControllerWidget* addControlWidget( + GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller); void handleConsole(); diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index cecf3911d..8fe4dc132 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -658,7 +658,7 @@ void RomListWidget::startEditMode() if (isEditable() && !_editMode && _selectedItem >= 0) { // Does this line represent an editable area? - if(myDisasm->list[_selectedItem].bytes == "") + if(myDisasm->list[_selectedItem].bytes.empty()) return; _editMode = true; diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 553041465..1e1dbc416 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -117,7 +117,7 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix, string message = "Snapshot saved"; try { - instance().png().saveImage(sspath.str(), s, rect); + PNGLibrary::saveImage(sspath.str(), s, rect); } catch(const runtime_error& e) { diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index e5fece4cc..eabb7603d 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -75,7 +75,7 @@ void ToggleWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int ToggleWidget::findItem(int x, int y) +int ToggleWidget::findItem(int x, int y) const { int row = (y - 1) / _rowHeight; if(row >= _rows) row = _rows - 1; diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 6f983161a..fd77b161b 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -70,7 +70,7 @@ class ToggleWidget : public Widget, public CommandSender private: void drawWidget(bool hilite) override = 0; - int findItem(int x, int y); + int findItem(int x, int y) const; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; diff --git a/src/debugger/yacc/YaccParser.cxx b/src/debugger/yacc/YaccParser.cxx index 40fcdb0d5..2c1a11d21 100644 --- a/src/debugger/yacc/YaccParser.cxx +++ b/src/debugger/yacc/YaccParser.cxx @@ -177,7 +177,7 @@ int const_to_int(char* ch) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // special methods that get Cart RAM/ROM internal state -CartMethod getCartSpecial(char* ch) +CartMethod getCartSpecial(const char* ch) { if(BSPF::equalsIgnoreCase(ch, "_bank")) return &CartDebug::getPCBank; @@ -196,7 +196,7 @@ CartMethod getCartSpecial(char* ch) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // special methods that get e.g. CPU registers -CpuMethod getCpuSpecial(char* ch) +CpuMethod getCpuSpecial(const char* ch) { if(BSPF::equalsIgnoreCase(ch, "a")) return &CpuDebug::a; @@ -230,7 +230,7 @@ CpuMethod getCpuSpecial(char* ch) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // special methods that get RIOT internal state -RiotMethod getRiotSpecial(char* ch) +RiotMethod getRiotSpecial(const char* ch) { if(BSPF::equalsIgnoreCase(ch, "_timWrapRead")) return &RiotDebug::timWrappedOnRead; @@ -248,7 +248,7 @@ RiotMethod getRiotSpecial(char* ch) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // special methods that get TIA internal state -TiaMethod getTiaSpecial(char* ch) +TiaMethod getTiaSpecial(const char* ch) { if(BSPF::equalsIgnoreCase(ch, "_scan")) return &TIADebug::scanlines; diff --git a/src/debugger/yacc/YaccParser.hxx b/src/debugger/yacc/YaccParser.hxx index 9940b6aaa..3f4efee72 100644 --- a/src/debugger/yacc/YaccParser.hxx +++ b/src/debugger/yacc/YaccParser.hxx @@ -36,10 +36,10 @@ namespace YaccParser int parse(const string& in); int const_to_int(char* ch); - CartMethod getCartSpecial(char* ch); - CpuMethod getCpuSpecial(char* ch); - RiotMethod getRiotSpecial(char* ch); - TiaMethod getTiaSpecial(char* ch); + CartMethod getCartSpecial(const char* ch); + CpuMethod getCpuSpecial(const char* ch); + RiotMethod getRiotSpecial(const char* ch); + TiaMethod getTiaSpecial(const char* ch); } #endif diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 1b78f6a49..126315c70 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -276,17 +276,6 @@ void CartridgeAR::initializeROM() myImage[(RAM_SIZE) + BANK_SIZE - 1] = 0xF8; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 CartridgeAR::checksum(const uInt8* s, uInt16 length) -{ - uInt8 sum = 0; - - for(uInt32 i = 0; i < length; ++i) - sum += s[i]; - - return sum; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeAR::loadIntoRAM(uInt8 load) { diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index 344db15bf..130e2ad7b 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -187,7 +187,13 @@ class CartridgeAR : public Cartridge bool bankConfiguration(uInt8 configuration); // Compute the sum of the array of bytes - uInt8 checksum(const uInt8* s, uInt16 length); + static uInt8 checksum(const uInt8* s, uInt16 length) { + uInt8 sum = 0; + for(uInt32 i = 0; i < length; ++i) + sum += s[i]; + + return sum; + } // Load the specified load into SC RAM void loadIntoRAM(uInt8 load); diff --git a/src/emucore/CartCreator.cxx b/src/emucore/CartCreator.cxx index 8deab775f..57ccae82f 100644 --- a/src/emucore/CartCreator.cxx +++ b/src/emucore/CartCreator.cxx @@ -72,10 +72,10 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr CartCreator::create(const FSNode& file, const ByteBuffer& image, size_t size, string& md5, - const string& propertiesType, Settings& settings) + const string& dtype, Settings& settings) { unique_ptr cartridge; - Bankswitch::Type type = Bankswitch::nameToType(propertiesType), + Bankswitch::Type type = Bankswitch::nameToType(dtype), detectedType = type; string id; diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index b14af7f67..1f6a50841 100644 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -430,16 +430,12 @@ bool CartDetector::isProbably4KSC(const ByteBuffer& image, size_t size) { // We check if the first 256 bytes are identical *and* if there's // an "SC" signature for one of our larger SC types at 1FFA. - const uInt8 first = image[0]; for(uInt32 i = 1; i < 256; ++i) - if(image[i] != first) - return false; + if(image[i] != first) + return false; - if((image[size-6]=='S') && (image[size-5]=='C')) - return true; - - return false; + return (image[size-6] == 'S') && (image[size-5] == 'C'); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartMVC.cxx b/src/emucore/CartMVC.cxx index 953507991..fe9914f27 100755 --- a/src/emucore/CartMVC.cxx +++ b/src/emucore/CartMVC.cxx @@ -31,20 +31,20 @@ */ namespace { - static constexpr uInt8 LO_JUMP_BYTE(uInt16 b) { + constexpr uInt8 LO_JUMP_BYTE(uInt16 b) { return b & 0xff; } - static constexpr uInt8 HI_JUMP_BYTE(uInt16 b) { + constexpr uInt8 HI_JUMP_BYTE(uInt16 b) { return ((b & 0xff00) >> 8) | 0x10; } - static constexpr uInt8 COLOR_BLUE = 0x9A; - // static constexpr uInt8 COLOR_WHITE = 0x0E; + constexpr uInt8 COLOR_BLUE = 0x9A; + // constexpr uInt8 COLOR_WHITE = 0x0E; - static constexpr uInt8 OSD_FRAMES = 180; - static constexpr int BACK_SECONDS = 10; + constexpr uInt8 OSD_FRAMES = 180; + constexpr int BACK_SECONDS = 10; - static constexpr int TITLE_CYCLES = 1000000; + constexpr int TITLE_CYCLES = 1000000; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 2cf0542de..2a1081a2d 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -23,7 +23,6 @@ #include "Booster.hxx" #include "Cart.hxx" #include "Control.hxx" -#include "Cart.hxx" #include "CartCM.hxx" #include "Driving.hxx" #include "Event.hxx" @@ -161,7 +160,7 @@ Console::Console(OSystem& osystem, unique_ptr& cart, myDevSettingsHandler = make_unique(myOSystem); // Auto-detect NTSC/PAL mode if it's requested - string autodetected = ""; + string autodetected; myDisplayFormat = myProperties.get(PropType::Display_Format); if (myDisplayFormat == "AUTO") @@ -296,9 +295,9 @@ void Console::autodetectFrameLayout(bool reset) for(int i = 0; i < 20; ++i) myTIA->update(); - frameLayoutDetector.simulateInput(*myRiot, myOSystem.eventHandler(), true); + FrameLayoutDetector::simulateInput(*myRiot, myOSystem.eventHandler(), true); myTIA->update(); - frameLayoutDetector.simulateInput(*myRiot, myOSystem.eventHandler(), false); + FrameLayoutDetector::simulateInput(*myRiot, myOSystem.eventHandler(), false); for(int i = 0; i < 40; ++i) myTIA->update(); @@ -441,8 +440,7 @@ void Console::setFormat(uInt32 format, bool force) if(!force && myCurrentFormat == format) return; - string saveformat, message; - string autodetected = ""; + string saveformat, message, autodetected; myCurrentFormat = format; switch(myCurrentFormat) diff --git a/src/emucore/ControllerDetector.cxx b/src/emucore/ControllerDetector.cxx index e99a49c7c..f836dbf68 100644 --- a/src/emucore/ControllerDetector.cxx +++ b/src/emucore/ControllerDetector.cxx @@ -45,10 +45,10 @@ Controller::Type ControllerDetector::detectType( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string ControllerDetector::detectName(const ByteBuffer& image, size_t size, - const Controller::Type controller, const Controller::Jack port, + const Controller::Type type, const Controller::Jack port, const Settings& settings) { - return Controller::getName(detectType(image, size, controller, port, settings)); + return Controller::getName(detectType(image, size, type, port, settings)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/ControllerDetector.hxx b/src/emucore/ControllerDetector.hxx index 8c7634674..8bd2b6653 100644 --- a/src/emucore/ControllerDetector.hxx +++ b/src/emucore/ControllerDetector.hxx @@ -34,15 +34,15 @@ class ControllerDetector /** Detects the controller type at the given port if no controller is provided. - @param image A reference to the ROM image - @param size The size of the ROM image - @param controller The provided controller type of the ROM image - @param port The port to be checked - @param settings A reference to the various settings (read-only) + @param image A reference to the ROM image + @param size The size of the ROM image + @param type The provided controller type of the ROM image + @param port The port to be checked + @param settings A reference to the various settings (read-only) @return The detected controller type */ static Controller::Type detectType(const ByteBuffer& image, size_t size, - const Controller::Type controller, const Controller::Jack port, + const Controller::Type type, const Controller::Jack port, const Settings& settings); /** diff --git a/src/emucore/EmulationWorker.hxx b/src/emucore/EmulationWorker.hxx index 0ba2cdf44..c2e38624d 100644 --- a/src/emucore/EmulationWorker.hxx +++ b/src/emucore/EmulationWorker.hxx @@ -128,7 +128,7 @@ class EmulationWorker /** Log a fatal error to cerr and throw a runtime exception. */ - [[noreturn]] void fatal(const string& message); + [[noreturn]] static void fatal(const string& message); private: /** diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index ef0343779..f676c9a92 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -270,7 +270,7 @@ void EventHandler::poll(uInt64 time) myOSystem.state().update(); #ifdef CHEATCODE_SUPPORT - for(auto& cheat: myOSystem.cheat().perFrame()) + for(const auto& cheat: myOSystem.cheat().perFrame()) cheat->evaluate(); #endif @@ -392,6 +392,7 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// NOLINTNEXTLINE (readability-function-size) void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { // Take care of special events that aren't part of the emulation core @@ -1548,7 +1549,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) msg.push_back(""); msg.push_back("You will lose all your progress."); } - myOSystem.messageMenu().setMessage("Exit Emulation", msg, true); + MessageMenu::setMessage("Exit Emulation", msg, true); enterMenuMode(EventHandlerState::MESSAGEMENU); } else @@ -1913,15 +1914,15 @@ void EventHandler::setActionMappings(EventMode mode) #ifdef JOYSTICK_SUPPORT const string joydesc = myPJoyHandler->getMappingDesc(event, mode); - if(joydesc != "") + if(!joydesc.empty()) { - if(key != "") + if(!key.empty()) key += ", "; key += joydesc; } #endif - if(key != "") + if(!key.empty()) item.key = key; } break; @@ -1935,15 +1936,15 @@ void EventHandler::setActionMappings(EventMode mode) #ifdef JOYSTICK_SUPPORT const string joydesc = myPJoyHandler->getMappingDesc(event, mode); - if(joydesc != "") + if(!joydesc.empty()) { - if(key != "") + if(!key.empty()) key += ", "; key += joydesc; } #endif - if(key != "") + if(!key.empty()) item.key = key; } break; @@ -2035,7 +2036,7 @@ json EventHandler::convertLegacyComboMapping(string list) events.push_back(Event::Type(event)); } // only store if there are any NoType events - if(events.size()) + if(!events.empty()) { json combo; @@ -2173,7 +2174,7 @@ void EventHandler::saveComboMapping() events.push_back(Event::Type(event)); } // only store if there are any NoType events - if(events.size()) + if(!events.empty()) { json combo; @@ -2186,7 +2187,7 @@ void EventHandler::saveComboMapping() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -StringList EventHandler::getActionList(EventMode mode) const +StringList EventHandler::getActionList(EventMode mode) { StringList l; switch(mode) @@ -2206,10 +2207,8 @@ StringList EventHandler::getActionList(EventMode mode) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -StringList EventHandler::getActionList(Event::Group group) const +StringList EventHandler::getActionList(Event::Group group) { - StringList l; - switch(group) { case Event::Group::Menu: @@ -2252,12 +2251,13 @@ StringList EventHandler::getActionList(Event::Group group) const return getActionList(ComboEvents); default: - return l; // ToDo + return {}; // ToDo } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -StringList EventHandler::getActionList(const Event::EventSet& events, EventMode mode) const +StringList EventHandler::getActionList(const Event::EventSet& events, + EventMode mode) { StringList l; @@ -2286,7 +2286,7 @@ StringList EventHandler::getActionList(const Event::EventSet& events, EventMode } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -VariantList EventHandler::getComboList() const +VariantList EventHandler::getComboList() { // For now, this only works in emulation mode VariantList l; @@ -2355,7 +2355,7 @@ void EventHandler::setComboListForEvent(Event::Type event, const StringList& eve } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int EventHandler::getEmulActionListIndex(int idx, const Event::EventSet& events) const +int EventHandler::getEmulActionListIndex(int idx, const Event::EventSet& events) { // idx = index into intersection set of 'events' and 'ourEmulActionList' // ordered by 'ourEmulActionList'! @@ -2383,7 +2383,7 @@ int EventHandler::getEmulActionListIndex(int idx, const Event::EventSet& events) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int EventHandler::getActionListIndex(int idx, Event::Group group) const +int EventHandler::getActionListIndex(int idx, Event::Group group) { switch(group) { @@ -2432,7 +2432,7 @@ int EventHandler::getActionListIndex(int idx, Event::Group group) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Event::Type EventHandler::eventAtIndex(int idx, Event::Group group) const +Event::Type EventHandler::eventAtIndex(int idx, Event::Group group) { const int index = getActionListIndex(idx, group); @@ -2453,7 +2453,7 @@ Event::Type EventHandler::eventAtIndex(int idx, Event::Group group) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string EventHandler::actionAtIndex(int idx, Event::Group group) const +string EventHandler::actionAtIndex(int idx, Event::Group group) { const int index = getActionListIndex(idx, group); @@ -2474,7 +2474,7 @@ string EventHandler::actionAtIndex(int idx, Event::Group group) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string EventHandler::keyAtIndex(int idx, Event::Group group) const +string EventHandler::keyAtIndex(int idx, Event::Group group) { const int index = getActionListIndex(idx, group); @@ -2527,7 +2527,7 @@ void EventHandler::changeMouseControllerMode(int direction) string usemouse = myOSystem.settings().getString("usemouse"); int i = 0; - for(auto& mode : MODES) + for(const auto& mode : MODES) { if(mode == usemouse) { diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 9a389f5ae..050e88912 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -160,11 +160,11 @@ class EventHandler Send an event directly to the event handler. These events cannot be remapped. - @param type The event + @param event The event @param value The value to use for the event @param repeated Repeated key (true) or first press/release (false) */ - void handleEvent(Event::Type type, Int32 value = 1, bool repeated = false); + void handleEvent(Event::Type event, Int32 value = 1, bool repeated = false); /** Handle events that must be processed each time a new console is @@ -174,8 +174,8 @@ class EventHandler bool frying() const { return myFryingFlag; } - StringList getActionList(Event::Group group) const; - VariantList getComboList() const; + static StringList getActionList(Event::Group group); + static VariantList getComboList(); /** Used to access the list of events assigned to a specific combo event. */ StringList getComboListForEvent(Event::Type event) const; @@ -205,9 +205,9 @@ class EventHandler return myPKeyHandler->getMappingDesc(event, mode); } - Event::Type eventAtIndex(int idx, Event::Group group) const; - string actionAtIndex(int idx, Event::Group group) const; - string keyAtIndex(int idx, Event::Group group) const; + static Event::Type eventAtIndex(int idx, Event::Group group); + static string actionAtIndex(int idx, Event::Group group); + static string keyAtIndex(int idx, Event::Group group); /** Bind a key to an event/action and regenerate the mapping array(s). @@ -427,14 +427,15 @@ class EventHandler void handleSystemEvent(SystemEvent e, int data1 = 0, int data2 = 0); /** - Add the given joystick to the list of physical joysticks available to the handler. + Add the given joystick to the list of physical joysticks available to + the handler. */ - void addPhysicalJoystick(const PhysicalJoystickPtr& stick); + void addPhysicalJoystick(const PhysicalJoystickPtr& joy); /** - Remove physical joystick at the current index. + Remove physical joystick with the givem id. */ - void removePhysicalJoystick(int index); + void removePhysicalJoystick(int id); private: // Define event groups @@ -459,11 +460,12 @@ class EventHandler static nlohmann::json convertLegacyComboMapping(string list); void saveComboMapping(); - StringList getActionList(EventMode mode) const; - StringList getActionList(const Event::EventSet& events, EventMode mode = EventMode::kEmulationMode) const; + static StringList getActionList(EventMode mode); + static StringList getActionList(const Event::EventSet& events, + EventMode mode = EventMode::kEmulationMode); // returns the action array index of the index in the provided group - int getEmulActionListIndex(int idx, const Event::EventSet& events) const; - int getActionListIndex(int idx, Event::Group group) const; + static int getEmulActionListIndex(int idx, const Event::EventSet& events); + static int getActionListIndex(int idx, Event::Group group); private: // Structure used for action menu items diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index 918ca721e..d451ff7f2 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -298,7 +298,7 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::splitString(const GUI::Font& font, const string& s, int w, - string& left, string& right) const + string& left, string& right) { #ifdef GUI_SUPPORT uInt32 pos = 0; @@ -334,12 +334,6 @@ void FBSurface::splitString(const GUI::Font& font, const string& s, int w, #endif } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FBSurface::isWhiteSpace(const char c) const -{ - return string(" ,.;:+-*/\\'([\n").find(c) != string::npos; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int FBSurface::drawString(const GUI::Font& font, const string& s, int x, int y, int w, int h, diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index d4906d1c7..5643798d6 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -267,8 +267,8 @@ class FBSurface @param left The left part of the split string @param right The right part of the split string */ - void splitString(const GUI::Font& font, const string& s, int w, - string& left, string& right) const; + static void splitString(const GUI::Font& font, const string& s, int w, + string& left, string& right); /** The rendering attributes that can be modified for this texture. @@ -403,7 +403,9 @@ class FBSurface @param c Character to check @return True if whitespace character */ - bool isWhiteSpace(const char c) const; + static bool isWhiteSpace(const char c) { + return string(" ,.;:+-*/\\'([\n").find(c) != string::npos; + } protected: uInt32* myPixels{nullptr}; // NOTE: MUST be set in child classes diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index f389c30dd..f3f47cedd 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -206,7 +206,7 @@ void FrameBuffer::setupFonts() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FontDesc FrameBuffer::getFontDesc(const string& name) const +FontDesc FrameBuffer::getFontDesc(const string& name) { if(name == "small") return GUI::consoleDesc; // 8x13 diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 627e5b027..7863b3895 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -324,7 +324,7 @@ class FrameBuffer @return The description of the font */ - FontDesc getFontDesc(const string& name) const; + static FontDesc getFontDesc(const string& name); #endif /** diff --git a/src/emucore/GlobalKeyHandler.cxx b/src/emucore/GlobalKeyHandler.cxx index 9d05bc887..04b87f360 100644 --- a/src/emucore/GlobalKeyHandler.cxx +++ b/src/emucore/GlobalKeyHandler.cxx @@ -164,7 +164,7 @@ GlobalKeyHandler::Group GlobalKeyHandler::getGroup() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool GlobalKeyHandler::isJoystick(const Controller& controller) const +bool GlobalKeyHandler::isJoystick(const Controller& controller) { return controller.type() == Controller::Type::Joystick || controller.type() == Controller::Type::BoosterGrip @@ -175,7 +175,7 @@ bool GlobalKeyHandler::isJoystick(const Controller& controller) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool GlobalKeyHandler::isPaddle(const Controller& controller) const +bool GlobalKeyHandler::isPaddle(const Controller& controller) { return controller.type() == Controller::Type::Paddles || controller.type() == Controller::Type::PaddlesIAxDr @@ -186,7 +186,7 @@ bool GlobalKeyHandler::isPaddle(const Controller& controller) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool GlobalKeyHandler::isTrackball(const Controller& controller) const +bool GlobalKeyHandler::isTrackball(const Controller& controller) { return controller.type() == Controller::Type::AmigaMouse || controller.type() == Controller::Type::AtariMouse @@ -283,7 +283,7 @@ bool GlobalKeyHandler::skipDebugSetting() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const GlobalKeyHandler::Function GlobalKeyHandler::cycleSetting(int direction) +GlobalKeyHandler::Function GlobalKeyHandler::cycleSetting(int direction) { bool skip = false; diff --git a/src/emucore/GlobalKeyHandler.hxx b/src/emucore/GlobalKeyHandler.hxx index 69615e17f..6b89734d3 100644 --- a/src/emucore/GlobalKeyHandler.hxx +++ b/src/emucore/GlobalKeyHandler.hxx @@ -167,17 +167,21 @@ class GlobalKeyHandler // Get group based on given setting Group getGroup() const; // Cycle settings using given direction (can be 0) - const Function cycleSetting(int direction); + Function cycleSetting(int direction); // Get adjustment function and if it is repeated SettingData getSettingData(const Setting setting) const; - PhysicalJoystickHandler& joyHandler() const { return myOSystem.eventHandler().joyHandler(); } - PhysicalKeyboardHandler& keyHandler() const { return myOSystem.eventHandler().keyHandler(); } + PhysicalJoystickHandler& joyHandler() const { + return myOSystem.eventHandler().joyHandler(); + } + PhysicalKeyboardHandler& keyHandler() const { + return myOSystem.eventHandler().keyHandler(); + } // Check if controller type is used (skips related input settings if not) - bool isJoystick(const Controller& controller) const; - bool isPaddle(const Controller& controller) const; - bool isTrackball(const Controller& controller) const; + static bool isJoystick(const Controller& controller); + static bool isPaddle(const Controller& controller); + static bool isTrackball(const Controller& controller); // Check if a currently non-relevant adjustment can be skipped bool skipAVSetting() const; diff --git a/src/emucore/Keyboard.cxx b/src/emucore/Keyboard.cxx index b7a09f6f9..dc11fdfba 100644 --- a/src/emucore/Keyboard.cxx +++ b/src/emucore/Keyboard.cxx @@ -55,7 +55,8 @@ Keyboard::Keyboard(Jack jack, const Event& event, const System& system) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Keyboard::ColumnState Keyboard::processColumn(const Event::Type buttons[]) { +Keyboard::ColumnState Keyboard::processColumn(const Event::Type buttons[]) +{ static constexpr DigitalPin signals[] = {DigitalPin::One, DigitalPin::Two, DigitalPin::Three, DigitalPin::Four}; @@ -69,8 +70,11 @@ Keyboard::ColumnState Keyboard::processColumn(const Event::Type buttons[]) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AnalogReadout::Connection Keyboard::columnStateToAnalogSignal(ColumnState state) const { - switch (state) { +AnalogReadout::Connection +Keyboard::columnStateToAnalogSignal(ColumnState state) +{ + switch (state) + { case ColumnState::gnd: return AnalogReadout::connectToGround(); diff --git a/src/emucore/Keyboard.hxx b/src/emucore/Keyboard.hxx index 0bb15264a..5658aebad 100644 --- a/src/emucore/Keyboard.hxx +++ b/src/emucore/Keyboard.hxx @@ -70,7 +70,7 @@ class Keyboard : public Controller private: ColumnState processColumn(const Event::Type buttons[]); - AnalogReadout::Connection columnStateToAnalogSignal(ColumnState state) const; + static AnalogReadout::Connection columnStateToAnalogSignal(ColumnState state); private: // Pre-compute the events we care about based on given port diff --git a/src/emucore/KidVid.cxx b/src/emucore/KidVid.cxx index abf8f5ca2..248841f31 100644 --- a/src/emucore/KidVid.cxx +++ b/src/emucore/KidVid.cxx @@ -210,7 +210,7 @@ void KidVid::setNextSong() { if(myFileOpened) { - myBeep = (ourSongPositions[myFilePointer] & 0x80) ? false : true; + myBeep = (ourSongPositions[myFilePointer] & 0x80) == 0; const uInt8 temp = ourSongPositions[myFilePointer] & 0x7f; mySharedData = (temp < 10); diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index abf913adf..257a65f8e 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -121,7 +121,7 @@ inline uInt8 M6502::peek(uInt16 address, Device::AccessFlags flags) if(myReadTraps.isInitialized() && myReadTraps.isSet(address) && (myGhostReadsTrap || flags != DISASM_NONE)) { - myLastPeekBaseAddress = myDebugger->getBaseAddress(myLastPeekAddress, true); // mirror handling + myLastPeekBaseAddress = Debugger::getBaseAddress(myLastPeekAddress, true); // mirror handling const int cond = evalCondTraps(); if(cond > -1) { @@ -157,7 +157,7 @@ inline void M6502::poke(uInt16 address, uInt8 value, Device::AccessFlags flags) #ifdef DEBUGGER_SUPPORT if(myWriteTraps.isInitialized() && myWriteTraps.isSet(address)) { - myLastPokeBaseAddress = myDebugger->getBaseAddress(myLastPokeAddress, false); // mirror handling + myLastPokeBaseAddress = Debugger::getBaseAddress(myLastPokeAddress, false); // mirror handling const int cond = evalCondTraps(); if(cond > -1) { @@ -188,9 +188,9 @@ inline void M6502::handleHalt() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void M6502::execute(uInt64 number, DispatchResult& result) +void M6502::execute(uInt64 cycles, DispatchResult& result) { - _execute(number, result); + _execute(cycles, result); #ifdef DEBUGGER_SUPPORT // Debugger hack: this ensures that stepping a "STA WSYNC" will actually end at the @@ -208,16 +208,17 @@ void M6502::execute(uInt64 number, DispatchResult& result) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool M6502::execute(uInt64 number) +bool M6502::execute(uInt64 cycles) { DispatchResult result; - execute(number, result); + execute(cycles, result); return result.isSuccess(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// NOLINTNEXTLINE (readability-function-size) inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { myExecutionStatus = 0; @@ -682,7 +683,7 @@ const StringList& M6502::getCondTrapNames() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void M6502::updateStepStateByInstruction() { - myStepStateByInstruction = myCondBreaks.size() || myCondSaveStates.size() || - myTrapConds.size(); + myStepStateByInstruction = + !myCondBreaks.empty() || !myCondSaveStates.empty() || !myTrapConds.empty(); } #endif // DEBUGGER_SUPPORT diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index e396316e1..53c509cee 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -114,10 +114,10 @@ class M6502 : public Serializable is executed, someone stops execution, or an error occurs. Answers true iff execution stops normally. - @param cycles Indicates the number of cycles to execute. Not that the actual - granularity of the CPU is instructions, so this is only accurate up to - a couple of cycles - @param result A DispatchResult object that will transport the result + @param cycles Indicates the number of cycles to execute. Not that the + actual granularity of the CPU is instructions, so this + is only accurate up to a couple of cycles + @param result A DispatchResult object that will transport the result */ void execute(uInt64 cycles, DispatchResult& result); diff --git a/src/emucore/M6532.hxx b/src/emucore/M6532.hxx index 06615a2e3..56b964b8a 100644 --- a/src/emucore/M6532.hxx +++ b/src/emucore/M6532.hxx @@ -146,8 +146,8 @@ class M6532 : public Device private: - void setTimerRegister(uInt8 data, uInt8 interval); - void setPinState(bool shcha); + void setTimerRegister(uInt8 value, uInt8 interval); + void setPinState(bool swcha); #ifdef DEBUGGER_SUPPORT // The following are used by the debugger to read INTIM/TIMINT diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index 615e873a2..81bac4fa8 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -76,11 +76,11 @@ struct MD5_CTX #define S44 21 static void MD5Init(MD5_CTX*); -static void MD5Update(MD5_CTX*, const uInt8* const, uInt32); +static void MD5Update(MD5_CTX*, const uInt8*, uInt32); static void MD5Final(uInt8[16], MD5_CTX*); static void MD5Transform(uInt32[4], const uInt8[64]); -static void Encode(uInt8*, const uInt32* const, uInt32); -static void Decode(uInt32*, const uInt8* const, uInt32); +static void Encode(uInt8*, const uInt32*, uInt32); +static void Decode(uInt32*, const uInt8*, uInt32); static uInt8 PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 95e80a5e0..3d7393ec2 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -210,7 +210,7 @@ bool OSystem::initialize(const Settings::Options& options) const string& avoxport = mySettings->getString("avoxport"); const StringList ports = MediaFactory::createSerialPort()->portNames(); - if(avoxport.empty() && ports.size() > 0) + if(avoxport.empty() && !ports.empty()) mySettings->setValue("avoxport", ports[0]); return true; @@ -484,7 +484,7 @@ string OSystem::createConsole(const FSNode& rom, const string& md5sum, if(showmessage) { const string& id = myConsole->cartridge().multiCartID(); - if(id == "") + if(id.empty()) myFrameBuffer->showTextMessage("New console created"); else myFrameBuffer->showTextMessage("Multicart " + @@ -655,7 +655,7 @@ unique_ptr OSystem::openConsole(const FSNode& romfile, string& md5) const auto CMDLINE_PROPS_UPDATE = [&](const string& name, PropType prop) { const string& s = mySettings->getString(name); - if(s != "") props.set(prop, s); + if(!s.empty()) props.set(prop, s); }; CMDLINE_PROPS_UPDATE("bs", PropType::Cart_Type); @@ -702,12 +702,12 @@ unique_ptr OSystem::openConsole(const FSNode& romfile, string& md5) CMDLINE_PROPS_UPDATE("rq1", PropType::Controller_Right1); CMDLINE_PROPS_UPDATE("rq2", PropType::Controller_Right2); const string& bc = mySettings->getString("bc"); - if(bc != "") { + if(!bc.empty()) { props.set(PropType::Controller_Left, bc); props.set(PropType::Controller_Right, bc); } const string& aq = mySettings->getString("aq"); - if(aq != "") + if(!aq.empty()) { props.set(PropType::Controller_Left1, aq); props.set(PropType::Controller_Left2, aq); @@ -762,7 +762,7 @@ ByteBuffer OSystem::openROM(const FSNode& rom, string& md5, size_t& size) // If we get to this point, we know we have a valid file to open // Now we make sure that the file has a valid properties entry // To save time, only generate an MD5 if we really need one - if(md5 == "") + if(md5.empty()) md5 = MD5::hash(image, size); // Make sure to load a per-ROM properties entry, if one exists @@ -773,7 +773,7 @@ ByteBuffer OSystem::openROM(const FSNode& rom, string& md5, size_t& size) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string OSystem::getROMMD5(const FSNode& rom) const +string OSystem::getROMMD5(const FSNode& rom) { size_t size = 0; const ByteBuffer image = openROM(rom, size, false); // ignore error message @@ -783,7 +783,7 @@ string OSystem::getROMMD5(const FSNode& rom) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ByteBuffer OSystem::openROM(const FSNode& rom, size_t& size, - bool showErrorMessage) const + bool showErrorMessage) { // First check if this is a valid ROM filename const bool isValidROM = rom.isFile() && Bankswitch::isValidRomName(rom); @@ -991,5 +991,5 @@ void OSystem::mainLoop() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string OSystem::ourOverrideBaseDir = ""; +string OSystem::ourOverrideBaseDir; bool OSystem::ourOverrideBaseDirWithApp = false; diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index 692482ebe..d9de8e9ff 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -353,7 +353,7 @@ class OSystem @return MD5 of the ROM image (if valid), otherwise EmptyString */ - string getROMMD5(const FSNode& rom) const; + static string getROMMD5(const FSNode& rom); /** Creates a new game console from the specified romfile, and correctly @@ -639,8 +639,8 @@ class OSystem @return Unique pointer to the array, otherwise nullptr */ - ByteBuffer openROM(const FSNode& romfile, size_t& size, - bool showErrorMessage) const; + static ByteBuffer openROM(const FSNode& romfile, size_t& size, + bool showErrorMessage); /** Creates an actual Console object based on the given info. @@ -663,7 +663,7 @@ class OSystem @param console The console to use @return Some information about this console */ - string getROMInfo(const Console& console); + static string getROMInfo(const Console& console); double dispatchEmulation(EmulationWorker& emulationWorker); diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 16164edc1..21eff5ecd 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -104,10 +104,10 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, if(swappaddle) { // First paddle is right A|B, second is left A|B - swapEvents(myAAxisValue, myBAxisValue); - swapEvents(myLeftAFireEvent, myLeftBFireEvent); - swapEvents(myLeftADecEvent, myLeftBDecEvent); - swapEvents(myLeftAIncEvent, myLeftBIncEvent); + std::swap(myAAxisValue, myBAxisValue); + std::swap(myLeftAFireEvent, myLeftBFireEvent); + std::swap(myLeftADecEvent, myLeftBDecEvent); + std::swap(myLeftAIncEvent, myLeftBIncEvent); } // Direction of movement can be swapped @@ -115,8 +115,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, // result in either increasing or decreasing paddle movement if(swapdir) { - swapEvents(myLeftADecEvent, myLeftAIncEvent); - swapEvents(myLeftBDecEvent, myLeftBIncEvent); + std::swap(myLeftADecEvent, myLeftAIncEvent); + std::swap(myLeftBDecEvent, myLeftBIncEvent); } // The following are independent of whether or not the port @@ -142,14 +142,6 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, setPin(DigitalPin::Six, true); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Paddles::swapEvents(Event::Type& event1, Event::Type& event2) -{ - Event::Type swappedEvent = event1; - event1 = event2; - event2 = swappedEvent; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::update() { @@ -193,7 +185,8 @@ void Paddles::updateA() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AnalogReadout::Connection Paddles::getReadOut(int lastAxis, int& newAxis, int center) +AnalogReadout::Connection +Paddles::getReadOut(int lastAxis,int& newAxis, int center) { const float range = ANALOG_RANGE - analogDeadZone() * 2; diff --git a/src/emucore/Paddles.hxx b/src/emucore/Paddles.hxx index e689cc4de..d87dca12a 100644 --- a/src/emucore/Paddles.hxx +++ b/src/emucore/Paddles.hxx @@ -199,12 +199,8 @@ class Paddles : public Controller static int DIGITAL_SENSITIVITY, DIGITAL_DISTANCE; static int DEJITTER_BASE, DEJITTER_DIFF; - /** - Swap two events. - */ - void swapEvents(Event::Type& event1, Event::Type& event2); - - AnalogReadout::Connection getReadOut(int lastAxis, int& newAxis, int center); + static AnalogReadout::Connection getReadOut(int lastAxis, + int& newAxis, int center); void updateA(); void updateB(); diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index aff571c12..07313faa0 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -46,7 +46,6 @@ using std::chrono::milliseconds; class PlusROMRequest { public: - struct Destination { Destination(const string& _host, const string& _path) : host{_host}, path{_path} {} @@ -71,7 +70,6 @@ class PlusROMRequest { }; public: - PlusROMRequest(const Destination& destination, const PlusStoreId& id, const uInt8* request, uInt8 requestSize) : myState{State::created}, myDestination{destination}, @@ -141,7 +139,7 @@ class PlusROMRequest { return; } - if (response->body.size() < 1 || static_cast(response->body[0]) != (response->body.size() - 1)) { + if (response->body.empty() || static_cast(response->body[0]) != (response->body.size() - 1)) { ostringstream ss; ss << "PlusCart: request to " << myDestination.host << "/" << myDestination.path << ": invalid response"; @@ -371,7 +369,7 @@ void PlusROM::reset() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PlusROM::isValidHost(const string& host) const +bool PlusROM::isValidHost(const string& host) { // TODO: This isn't 100% either, as we're supposed to check for the length // of each part between '.' in the range 1 .. 63 @@ -383,7 +381,7 @@ bool PlusROM::isValidHost(const string& host) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool PlusROM::isValidPath(const string& path) const +bool PlusROM::isValidPath(const string& path) { // TODO: This isn't 100% // Perhaps a better function will be included with whatever network diff --git a/src/emucore/PlusROM.hxx b/src/emucore/PlusROM.hxx index 43a1da6e4..bf1cc6696 100644 --- a/src/emucore/PlusROM.hxx +++ b/src/emucore/PlusROM.hxx @@ -157,8 +157,8 @@ class PlusROM : public Serializable } private: - bool isValidHost(const string& host) const; - bool isValidPath(const string& path) const; + static bool isValidHost(const string& host); + static bool isValidPath(const string& path); /** Receive data from all requests that have completed. diff --git a/src/emucore/ProfilingRunner.cxx b/src/emucore/ProfilingRunner.cxx index b64b80845..82835ed2b 100644 --- a/src/emucore/ProfilingRunner.cxx +++ b/src/emucore/ProfilingRunner.cxx @@ -31,7 +31,6 @@ #include "FrameManager.hxx" #include "FrameLayoutDetector.hxx" #include "EmulationTiming.hxx" -#include "ConsoleTiming.hxx" #include "System.hxx" #include "Joystick.hxx" #include "Random.hxx" @@ -40,7 +39,7 @@ using namespace std::chrono; namespace { - static constexpr uInt32 RUNTIME_DEFAULT = 60; + constexpr uInt32 RUNTIME_DEFAULT = 60; void updateProgress(uInt32 from, uInt32 to) { while (from < to) { @@ -111,7 +110,7 @@ bool ProfilingRunner::runOne(const ProfilingRun& run) } string md5 = MD5::hash(image, size); - string type = ""; + string type; unique_ptr cartridge = CartCreator::create( imageFile, image, size, md5, type, mySettings); diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index 7445af5b2..e52401e74 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -116,7 +116,7 @@ void PropertiesSet::insert(const Properties& properties, bool save) // Since the PropSet is keyed by md5, we can't insert without a valid one const string& md5 = properties.get(PropType::Cart_MD5); - if(md5 == "") + if(md5.empty()) return; // Make sure the exact entry isn't already in any list @@ -134,7 +134,7 @@ void PropertiesSet::insert(const Properties& properties, bool save) properties.save(*myRepository->get(md5)); } else { const auto ret = myTempProps.emplace(md5, properties); - if(ret.second == false) + if(!ret.second) { // Remove old item and insert again myTempProps.erase(ret.first); diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index c156e7984..50ba83f98 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -176,7 +176,7 @@ string Serializer::getString() const const int len = getInt(); string str; str.resize(len); - myStream->read(&str[0], len); + myStream->read(str.data(), len); return str; } diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 269f1aab0..670aa626d 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -477,7 +477,7 @@ void Settings::validate() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Settings::usage() const +void Settings::usage() { cout << endl << "Stella version " << STELLA_VERSION << endl diff --git a/src/emucore/Settings.hxx b/src/emucore/Settings.hxx index 30bd58056..55258794b 100644 --- a/src/emucore/Settings.hxx +++ b/src/emucore/Settings.hxx @@ -58,7 +58,7 @@ class Settings /** This method should be called to display usage information. */ - void usage() const; + static void usage(); void setRepository(shared_ptr repository); diff --git a/src/emucore/Switches.cxx b/src/emucore/Switches.cxx index ec1325c42..1a42bb4e8 100644 --- a/src/emucore/Switches.cxx +++ b/src/emucore/Switches.cxx @@ -21,11 +21,11 @@ #include "Switches.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Switches::Switches(const Event& event, const Properties& properties, +Switches::Switches(const Event& event, const Properties& props, const Settings& settings) : myEvent{event} { - if(properties.get(PropType::Console_RightDiff) == "B") + if(props.get(PropType::Console_RightDiff) == "B") { mySwitches &= ~0x80; } @@ -34,7 +34,7 @@ Switches::Switches(const Event& event, const Properties& properties, mySwitches |= 0x80; } - if(properties.get(PropType::Console_LeftDiff) == "B") + if(props.get(PropType::Console_LeftDiff) == "B") { mySwitches &= ~0x40; } @@ -43,7 +43,7 @@ Switches::Switches(const Event& event, const Properties& properties, mySwitches |= 0x40; } - if(properties.get(PropType::Console_TVType) == "COLOR") + if(props.get(PropType::Console_TVType) == "COLOR") { mySwitches |= 0x08; } diff --git a/src/emucore/Switches.hxx b/src/emucore/Switches.hxx index 76fbfa4ee..efdf065eb 100644 --- a/src/emucore/Switches.hxx +++ b/src/emucore/Switches.hxx @@ -100,7 +100,7 @@ class Switches : public Serializable /** Sets 'Console_LeftDifficulty' switches bit. */ - void setLeftDifficultyA(bool setA); + void setLeftDifficultyA(bool setToA); /** Query the 'Console_RightDifficulty' switches bit. @@ -112,8 +112,7 @@ class Switches : public Serializable /** Sets 'Console_LeftDifficulty' switches bit. */ - void setRightDifficultyA(bool setA); - + void setRightDifficultyA(bool setToA); /** Toggle between 2600 and 7800 mode depending on settings. diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index 595964a3b..56de8299d 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -186,7 +186,7 @@ Device::AccessFlags System::getAccessFlags(uInt16 addr) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void System::setAccessFlags(uInt16 addr, Device::AccessFlags flags) +void System::setAccessFlags(uInt16 addr, Device::AccessFlags flags) const { const PageAccess& access = getPageAccess(addr); @@ -197,11 +197,10 @@ void System::setAccessFlags(uInt16 addr, Device::AccessFlags flags) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void System::increaseAccessCounter(uInt16 addr, bool isWrite) +void System::increaseAccessCounter(uInt16 addr, bool isWrite) const { const PageAccess& access = getPageAccess(addr); - if(isWrite) { if(access.romPokeCounter) diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index 70349180e..cce967b29 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -215,14 +215,14 @@ class System : public Serializable only really acts on CODE/GFX/PGFX/COL/PCOL/BCOL/AUD/DATA/ROW. */ Device::AccessFlags getAccessFlags(uInt16 address) const; - void setAccessFlags(uInt16 address, Device::AccessFlags flags); + void setAccessFlags(uInt16 address, Device::AccessFlags flags) const; /** Increase the given address's access counter @param address The address to modify */ - void increaseAccessCounter(uInt16 address, bool isWrite); + void increaseAccessCounter(uInt16 address, bool isWrite) const; #endif public: diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index e9e63320d..db6909ce7 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -50,7 +50,7 @@ TIASurface::TIASurface(OSystem& system) myFB{system.frameBuffer()} { // Load NTSC filter settings - myNTSCFilter.loadConfig(myOSystem.settings()); + NTSCFilter::loadConfig(myOSystem.settings()); // Create a surface for the TIA image and scanlines; we'll need them eventually myTiaSurface = myFB.allocateSurface( @@ -216,7 +216,7 @@ void TIASurface::changeNTSCAdjustable(int adjustable, int direction) setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().changeAdjustable(adjustable, direction, text, valueText, newValue); - ntsc().saveConfig(myOSystem.settings()); + NTSCFilter::saveConfig(myOSystem.settings()); myOSystem.frameBuffer().showGaugeMessage(text, valueText, newValue); } @@ -228,7 +228,7 @@ void TIASurface::changeCurrentNTSCAdjustable(int direction) setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().changeCurrentAdjustable(direction, text, valueText, newValue); - ntsc().saveConfig(myOSystem.settings()); + NTSCFilter::saveConfig(myOSystem.settings()); myOSystem.frameBuffer().showGaugeMessage(text, valueText, newValue); } @@ -267,7 +267,7 @@ TIASurface::ScanlineMask TIASurface::scanlineMaskType(int direction) int i = 0; const string& name = myOSystem.settings().getString("tv.scanmask"); - for(auto& mask : Masks) + for(const auto& mask: Masks) { if(mask == name) { diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 1a3ea6546..e6c48ca4d 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -255,7 +255,7 @@ inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Thumbulator::dump_counters() +void Thumbulator::dump_counters() const { cout << endl << endl << "instructions " << _stats.instructions << endl; @@ -548,7 +548,7 @@ void Thumbulator::write32(uInt32 addr, uInt32 data) #ifndef UNSAFE_OPTIMIZATIONS // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Thumbulator::isInvalidROM(uInt32 addr) +bool Thumbulator::isInvalidROM(uInt32 addr) const { const uInt32 romStart = configuration == ConfigureFor::DPCplus ? 0xc00 : 0x750; // was 0x800 @@ -556,7 +556,7 @@ bool Thumbulator::isInvalidROM(uInt32 addr) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Thumbulator::isInvalidRAM(uInt32 addr) +bool Thumbulator::isInvalidRAM(uInt32 addr) const { // Note: addr is already checked for RAM (0x4xxxxxxx) switch(romSize) // CDFJ+ allows more than 8 KB RAM depending on ROM sizes @@ -1091,7 +1091,7 @@ Thumbulator::Op Thumbulator::decodeInstructionWord(uint16_t inst) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int Thumbulator::execute() +int Thumbulator::execute() // NOLINT (readability-function-size) { uInt32 sp, inst, ra, rb, rc, rm, rd, rn, rs, op; // NOLINT diff --git a/src/emucore/Thumbulator.hxx b/src/emucore/Thumbulator.hxx index 6496bcbd6..7b4fccc43 100644 --- a/src/emucore/Thumbulator.hxx +++ b/src/emucore/Thumbulator.hxx @@ -228,8 +228,8 @@ class Thumbulator uInt32 read16(uInt32 addr); uInt32 read32(uInt32 addr); #ifndef UNSAFE_OPTIMIZATIONS - bool isInvalidROM(uInt32 addr); - bool isInvalidRAM(uInt32 addr); + bool isInvalidROM(uInt32 addr) const; + bool isInvalidRAM(uInt32 addr) const; bool isProtectedRAM(uInt32 addr); #endif void write16(uInt32 addr, uInt32 data); @@ -252,7 +252,7 @@ class Thumbulator int fatalError(const char* opcode, uInt32 v1, const char* msg); int fatalError(const char* opcode, uInt32 v1, uInt32 v2, const char* msg); - void dump_counters(); + void dump_counters() const; void dump_regs(); #endif int execute(); diff --git a/src/emucore/tia/Player.hxx b/src/emucore/tia/Player.hxx index f16a9b28b..cbff8968e 100644 --- a/src/emucore/tia/Player.hxx +++ b/src/emucore/tia/Player.hxx @@ -35,7 +35,7 @@ class Player : public Serializable void reset(); - void grp(uInt8 value); + void grp(uInt8 pattern); void hmp(uInt8 value); diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index cde71f2dd..198516949 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -1441,9 +1441,9 @@ void TIA::cycle(uInt32 colorClocks) if (++myHctr >= TIAConstants::H_CLOCKS) nextLine(); - #ifdef SOUND_SUPPORT - myAudio.tick(); - #endif + #ifdef SOUND_SUPPORT + myAudio.tick(); + #endif ++myTimestamp; } diff --git a/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx b/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx index ba5c3f45f..6f1916794 100644 --- a/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx +++ b/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx @@ -22,7 +22,8 @@ #include "FrameLayoutDetector.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameLayoutDetector::simulateInput(M6532& riot, EventHandler& eventHandler, bool pressed) const +void FrameLayoutDetector::simulateInput( + M6532& riot, EventHandler& eventHandler, bool pressed) { // Console eventHandler.handleEvent(Event::ConsoleSelect, pressed); diff --git a/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx b/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx index 368086709..dd337d2a8 100644 --- a/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx +++ b/src/emucore/tia/frame-manager/FrameLayoutDetector.hxx @@ -46,7 +46,8 @@ class FrameLayoutDetector: public AbstractFrameManager /** * Simulate some input to pass a potential title screen. */ - void simulateInput(M6532& riot, EventHandler& eventHandler, bool pressed) const; + static void simulateInput(M6532& riot, EventHandler& eventHandler, + bool pressed); protected: diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index 3d7dc8726..9444b0452 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -313,15 +313,15 @@ void AboutDialog::handleCommand(CommandSender* sender, int cmd, int data, int id } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string AboutDialog::getUrl(const string& str) const +string AboutDialog::getUrl(const string& text) { bool isUrl = false; size_t start = 0, len = 0; - for(size_t i = 0; i < str.size(); ++i) + for(size_t i = 0; i < text.size(); ++i) { - string remainder = str.substr(i); - const char ch = str[i]; + string remainder = text.substr(i); + const char ch = text[i]; if(!isUrl && (BSPF::startsWithIgnoreCase(remainder, "http://") @@ -342,7 +342,7 @@ const string AboutDialog::getUrl(const string& str) const } } if(len) - return str.substr(start, len); + return text.substr(start, len); else return EmptyString; } diff --git a/src/gui/AboutDialog.hxx b/src/gui/AboutDialog.hxx index 200d4bbaf..64c184c6c 100644 --- a/src/gui/AboutDialog.hxx +++ b/src/gui/AboutDialog.hxx @@ -38,7 +38,7 @@ class AboutDialog : public Dialog void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void updateStrings(int page, int lines, string& title); void displayInfo(); - const string getUrl(const string& text) const; + static string getUrl(const string& text); void loadConfig() override { displayInfo(); } diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 3d00b5d34..311f4a76b 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -334,7 +334,8 @@ void BrowserDialog::updateUI(bool fileSelected) enable = !_selected->getText().empty(); _okWidget->setEnabled(enable); - if(fileSelected && _fileList->getList().size() && !_fileList->selected().isDirectory()) + if(fileSelected && !_fileList->getList().empty() && + !_fileList->selected().isDirectory()) _selected->setText(_fileList->getSelectedString()); } diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 1e73a717d..583bccdfe 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -96,7 +96,7 @@ class ContextMenu : public Dialog, public CommandSender void handleKeyDown(StellaKey key, StellaMod mod, bool repeated) override; void handleJoyUp(int stick, int button) override; void handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int button) override; - bool handleJoyHat(int stick, int hat, JoyHatDir vahdirlue, int button) override; + bool handleJoyHat(int stick, int hat, JoyHatDir hdir, int button) override; void handleEvent(Event::Type e); void setArrows(); diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index f15c4a960..391071fda 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -34,7 +34,6 @@ #include "Console.hxx" #include "TIA.hxx" #include "JitterEmulation.hxx" -#include "OSystem.hxx" #include "EventHandler.hxx" #include "StateManager.hxx" #include "RewindManager.hxx" @@ -909,25 +908,25 @@ void DeveloperDialog::setDefaults() switch(myTab->getActiveTab()) { case 0: // Emulation - myFrameStats[set] = devSettings ? true : false; - myDetectedInfo[set] = devSettings ? true : false; + myFrameStats[set] = devSettings; + myDetectedInfo[set] = devSettings; // AtariVox/SaveKey/PlusROM access - myExternAccess[set] = devSettings ? true : false; + myExternAccess[set] = devSettings; myConsole[set] = 0; // Randomization - myRandomBank[set] = devSettings ? true : false; - myRandomizeTIA[set] = devSettings ? true : false; + myRandomBank[set] = devSettings; + myRandomizeTIA[set] = devSettings; myRandomizeRAM[set] = true; myRandomizeCPU[set] = devSettings ? "SAXYP" : "AXYP"; // Undriven TIA pins - myUndrivenPins[set] = devSettings ? true : false; + myUndrivenPins[set] = devSettings; #ifdef DEBUGGER_SUPPORT // Reads from write ports - myRWPortBreak[set] = devSettings ? true : false; - myWRPortBreak[set] = devSettings ? true : false; + myRWPortBreak[set] = devSettings; + myWRPortBreak[set] = devSettings; #endif // Thumb ARM emulation exception - myThumbException[set] = devSettings ? true : false; + myThumbException[set] = devSettings; setWidgetStates(set); break; @@ -935,15 +934,15 @@ void DeveloperDialog::setDefaults() case 1: // TIA myTIAType[set] = "standard"; // reset "custom" mode - myPlInvPhase[set] = devSettings ? true : false; - myMsInvPhase[set] = devSettings ? true : false; - myBlInvPhase[set] = devSettings ? true : false; - myPFBits[set] = devSettings ? true : false; - myPFColor[set] = devSettings ? true : false; - myPFScore[set] = devSettings ? true : false; - myBKColor[set] = devSettings ? true : false; - myPlSwap[set] = devSettings ? true : false; - myBlSwap[set] = devSettings ? true : false; + myPlInvPhase[set] = devSettings; + myMsInvPhase[set] = devSettings; + myBlInvPhase[set] = devSettings; + myPFBits[set] = devSettings; + myPFColor[set] = devSettings; + myPFScore[set] = devSettings; + myBKColor[set] = devSettings; + myPlSwap[set] = devSettings; + myBlSwap[set] = devSettings; setWidgetStates(set); break; @@ -956,7 +955,7 @@ void DeveloperDialog::setDefaults() : JitterEmulation::PLR_SENSITIVITY; myTVJitterRec[set] = devSettings ? 2 : 10; // PAL color-loss effect - myColorLoss[set] = devSettings ? true : false; + myColorLoss[set] = devSettings; // Debug colors myDebugColors[set] = false; handleDebugColours("roygpb"); diff --git a/src/gui/DeveloperDialog.hxx b/src/gui/DeveloperDialog.hxx index eec830596..71966d017 100644 --- a/src/gui/DeveloperDialog.hxx +++ b/src/gui/DeveloperDialog.hxx @@ -146,7 +146,7 @@ class DeveloperDialog : public Dialog, DevSettingsHandler CheckboxWidget* myGhostReadsTrapWidget{nullptr}; #endif - bool mySettings{false}; + bool mySettings{false}; private: void addEmulationTab(const GUI::Font& font); @@ -164,7 +164,7 @@ class DeveloperDialog : public Dialog, DevSettingsHandler void handleTia(); - void handleDebugColours(int cmd, int color); + void handleDebugColours(int idx, int color); void handleDebugColours(const string& colors); void handleTimeMachine(); diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 0a84c1696..792237cea 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -112,7 +112,7 @@ void Dialog::open() setPosition(); - if(_myTabList.size()) + if(!_myTabList.empty()) // (Re)-build the focus list to use for all widgets of all tabs for(auto& tabfocus : _myTabList) buildCurrentFocusList(tabfocus.widget->getID()); @@ -204,7 +204,7 @@ void Dialog::setHelpURL(const string& helpURL) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Dialog::getHelpURL() const +string Dialog::getHelpURL() const { // 1. check individual widget if(_focusedWidget && _focusedWidget->hasHelp()) @@ -412,7 +412,7 @@ void Dialog::addToFocusList(const WidgetArray& list) Vec::append(_myFocus.list, list); _focusList = _myFocus.list; - if(list.size() > 0) + if(!list.empty()) _myFocus.widget = list[0]; } @@ -445,7 +445,7 @@ void Dialog::addToFocusList(const WidgetArray& list, const TabWidget* w, int tab Vec::append(focus[id].list, list); } - if(list.size() > 0) + if(!list.empty()) focus[id].widget = list[0]; } @@ -509,14 +509,14 @@ void Dialog::buildCurrentFocusList(int tabID) // Add button group at end of current focus list // We do it this way for TabWidget, so that buttons are scanned // *after* the widgets in the current tab - if(_buttonGroup.size() > 0) + if(!_buttonGroup.empty()) Vec::append(_focusList, _buttonGroup); // Finally, the moment we've all been waiting for :) // Set the actual focus widget if(tabFocusWidget) _focusedWidget = tabFocusWidget; - else if(!_focusedWidget && _focusList.size() > 0) + else if(!_focusedWidget && !_focusList.empty()) _focusedWidget = _focusList[0]; } @@ -919,7 +919,7 @@ bool Dialog::handleNavEvent(Event::Type e, bool repeated) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::getTabIdForWidget(const Widget* w) { - if(_myTabList.size() == 0 || !w) + if(_myTabList.empty() || !w) return; for(uInt32 id = 0; id < _myTabList.size(); ++id) diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 34c823bd1..b3411ba9b 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -213,7 +213,7 @@ class Dialog : public GuiObject bool handleNavEvent(Event::Type e, bool repeated = false); void getTabIdForWidget(const Widget* w); bool cycleTab(int direction); - const string getHelpURL() const override; + string getHelpURL() const override; bool hasHelp() const override { return !getHelpURL().empty(); } void openHelp(); diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 67855823b..08ed17bda 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -593,7 +593,7 @@ bool EditableWidget::adjustOffset() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int EditableWidget::scrollOffset() +int EditableWidget::scrollOffset() const { return _editable ? -_editScrollOffset : 0; } @@ -781,7 +781,7 @@ bool EditableWidget::markWord() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string EditableWidget::selectString() const +string EditableWidget::selectString() const { if(_selectSize) { @@ -799,7 +799,7 @@ const string EditableWidget::selectString() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int EditableWidget::selectStartPos() +int EditableWidget::selectStartPos() const { if(_selectSize < 0) return _caretPos + _selectSize; @@ -808,7 +808,7 @@ int EditableWidget::selectStartPos() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int EditableWidget::selectEndPos() +int EditableWidget::selectEndPos() const { if(_selectSize > 0) return _caretPos + _selectSize; diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 0e6fbcfc7..c354213aa 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -104,9 +104,9 @@ class EditableWidget : public Widget, public CommandSender // access/edit the internal buffer string& editString() { return _editString; } string& backupString() { return _backupString; } - const string selectString() const; + string selectString() const; void resetSelection() { _selectSize = 0; } - int scrollOffset(); + int scrollOffset() const; private: // Line editing @@ -117,8 +117,8 @@ class EditableWidget : public Widget, public CommandSender bool markWord(); bool killSelectedText(bool addEdit = true); - int selectStartPos(); - int selectEndPos(); + int selectStartPos() const; + int selectEndPos() const; // Clipboard bool cutSelectedText(); bool copySelectedText(); diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index fe06f38af..d2f7e6e25 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -25,7 +25,6 @@ #include "FrameBuffer.hxx" #include "EventHandler.hxx" #include "Event.hxx" -#include "OSystem.hxx" #include "EditTextWidget.hxx" #include "StringListWidget.hxx" #include "Widget.hxx" @@ -122,7 +121,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font, myComboButton->setTarget(this); addFocusWidget(myComboButton); - VariantList combolist = instance().eventHandler().getComboList(); + VariantList combolist = EventHandler::getComboList(); myComboDialog = make_unique(boss, font, combolist); // Show message for currently selected event @@ -167,7 +166,7 @@ void EventMappingWidget::updateActions() ? EventMode::kMenuMode : EventMode::kEmulationMode; - StringList actions = instance().eventHandler().getActionList(myEventGroup); + StringList actions = EventHandler::getActionList(myEventGroup); myActionsList->setList(actions); myActionSelected = myActionsList->getSelected(); @@ -208,7 +207,7 @@ void EventMappingWidget::startRemapping() // And show a message indicating which key is being remapped ostringstream buf; buf << "Select action for '" - << instance().eventHandler().actionAtIndex(myActionSelected, myEventGroup) + << EventHandler::actionAtIndex(myActionSelected, myEventGroup) << "' event"; myKeyMapping->setTextColor(kTextColorEm); myKeyMapping->setText(buf.str()); @@ -225,7 +224,7 @@ void EventMappingWidget::eraseRemapping() return; const Event::Type event = - instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup); + EventHandler::eventAtIndex(myActionSelected, myEventGroup); instance().eventHandler().eraseMapping(event, myEventMode); drawKeyMapping(); @@ -238,7 +237,7 @@ void EventMappingWidget::resetRemapping() return; const Event::Type event = - instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup); + EventHandler::eventAtIndex(myActionSelected, myEventGroup); instance().eventHandler().setDefaultMapping(event, myEventMode); drawKeyMapping(); @@ -274,7 +273,7 @@ void EventMappingWidget::drawKeyMapping() if(myActionSelected >= 0) { myKeyMapping->setTextColor(kTextColor); - myKeyMapping->setText(instance().eventHandler().keyAtIndex(myActionSelected, myEventGroup)); + myKeyMapping->setText(EventHandler::keyAtIndex(myActionSelected, myEventGroup)); } } @@ -287,8 +286,7 @@ void EventMappingWidget::enableButtons(bool state) myEraseButton->setEnabled(state); myResetButton->setEnabled(state); - const Event::Type e = - instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup); + const Event::Type e = EventHandler::eventAtIndex(myActionSelected, myEventGroup); myComboButton->setEnabled(state && e >= Event::Combo1 && e <= Event::Combo16); } @@ -318,7 +316,7 @@ bool EventMappingWidget::handleKeyUp(StellaKey key, StellaMod mod) && (mod & (KBDM_CTRL | KBDM_SHIFT | KBDM_ALT | KBDM_GUI)) == 0) { const Event::Type event = - instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup); + EventHandler::eventAtIndex(myActionSelected, myEventGroup); // if not pressed alone, map left and right modifier keys if(myLastKey < KBDK_LCTRL || myLastKey > KBDK_RGUI) @@ -358,7 +356,8 @@ void EventMappingWidget::handleJoyUp(int stick, int button) if (myLastStick == stick && myLastButton == button) { EventHandler& eh = instance().eventHandler(); - const Event::Type event = eh.eventAtIndex(myActionSelected, myEventGroup); + const Event::Type event = + EventHandler::eventAtIndex(myActionSelected, myEventGroup); // map either button/hat, solo button or button/axis combinations if(myLastHat != -1) @@ -394,9 +393,10 @@ void EventMappingWidget::handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int else if(myLastStick == stick && axis == myLastAxis && adir == JoyDir::NONE) { EventHandler& eh = instance().eventHandler(); - const Event::Type event = eh.eventAtIndex(myActionSelected, myEventGroup); + const Event::Type event = + EventHandler::eventAtIndex(myActionSelected, myEventGroup); - if (eh.addJoyMapping(event, myEventMode, stick, myLastButton, axis, myLastDir)) + if(eh.addJoyMapping(event, myEventMode, stick, myLastButton, axis, myLastDir)) stopRemapping(); } } @@ -425,9 +425,10 @@ bool EventMappingWidget::handleJoyHat(int stick, int hat, JoyHatDir hdir, int bu else if(myLastStick == stick && hat == myLastHat && hdir == JoyHatDir::CENTER) { EventHandler& eh = instance().eventHandler(); - const Event::Type event = eh.eventAtIndex(myActionSelected, myEventGroup); + const Event::Type event = + EventHandler::eventAtIndex(myActionSelected, myEventGroup); - if (eh.addJoyHatMapping(event, myEventMode, stick, myLastButton, hat, myLastHatDir)) + if(eh.addJoyHatMapping(event, myEventMode, stick, myLastButton, hat, myLastHatDir)) { stopRemapping(); return true; @@ -484,8 +485,8 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd, case kComboCmd: if(myComboDialog) myComboDialog->show( - instance().eventHandler().eventAtIndex(myActionSelected, myEventGroup), - instance().eventHandler().actionAtIndex(myActionSelected, myEventGroup)); + EventHandler::eventAtIndex(myActionSelected, myEventGroup), + EventHandler::actionAtIndex(myActionSelected, myEventGroup)); break; default: diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 3f5f99a83..78f9a59e3 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -257,7 +257,7 @@ string& FileListWidget::fixPath(string& path) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FileListWidget::addHistory(const FSNode& node) { - if (_history.size() > 0) { + if (!_history.empty()) { while(_currentHistory != std::prev(_history.end(), 1)) _history.pop_back(); @@ -284,7 +284,7 @@ void FileListWidget::reload() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const FSNode& FileListWidget::selected() { - if(_fileList.size() > 0) + if(!_fileList.empty()) { _selected = BSPF::clamp(_selected, 0U, static_cast(_fileList.size()-1)); return _fileList[_selected]; diff --git a/src/gui/FileListWidget.hxx b/src/gui/FileListWidget.hxx index e39cec905..17aa4e07f 100644 --- a/src/gui/FileListWidget.hxx +++ b/src/gui/FileListWidget.hxx @@ -151,7 +151,7 @@ class FileListWidget : public StringListWidget virtual const Icon* getIcon(int i) const; int iconWidth() const; virtual bool fullPathToolTip() const { return false; } - string& fixPath(string& path); + static string& fixPath(string& path); void addHistory(const FSNode& node); protected: diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 4133b0be2..d40ff20fc 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -726,7 +726,7 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props) updateBSTypes(); VariantList items; - string bsDetected = ""; + string bsDetected; myBSType->setSelected(props.get(PropType::Cart_Type), "AUTO"); if(myBSType->getSelectedTag().toString() == "AUTO") @@ -915,7 +915,7 @@ void GameInfoDialog::loadHighScoresProperties(const Properties& props) for (uInt32 a = 0; a < HSM::MAX_SCORE_ADDR; ++a) { ss.str(""); - if(a < instance().highScores().numAddrBytes(info.numDigits, info.trailingZeroes)) + if(a < HighScoresManager::numAddrBytes(info.numDigits, info.trailingZeroes)) { ss << hex << right // << setw(HSM::MAX_ADDR_CHARS) << setfill(' ') << uppercase << info.scoreAddr[a]; @@ -1075,8 +1075,8 @@ void GameInfoDialog::saveHighScoresProperties() string strVars = myVariations->getText(); - instance().highScores().set(myGameProperties, stringToInt(strVars, HSM::DEFAULT_VARIATION), - info); + HighScoresManager::set(myGameProperties, stringToInt(strVars, + HSM::DEFAULT_VARIATION), info); } else { @@ -1198,7 +1198,7 @@ void GameInfoDialog::updateControllerStates() autoDetect = node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr; } - string label = ""; + string label; Controller::Type type = Controller::getType(myLeftPort->getSelectedTag().toString()); if(type == Controller::Type::Unknown) @@ -1337,7 +1337,7 @@ void GameInfoDialog::updateHighScoresWidgets() const bool enableVars = enable && myVariations->getText() > "1"; const bool enableSpecial = enable && !mySpecialName->getText().empty(); const bool enableConsole = instance().hasConsole(); - const uInt32 numAddr = instance().highScores().numAddrBytes( + const uInt32 numAddr = HighScoresManager::numAddrBytes( myScoreDigits->getSelected() + 1, myTrailingZeroes->getSelected()); // enable widgets @@ -1431,7 +1431,7 @@ void GameInfoDialog::setAddressVal(const EditTextWidget* addressWidget, EditText // convert to number and read from memory const uInt16 addr = stringToIntBase16(strAddr, HSM::DEFAULT_ADDRESS); uInt8 val = instance().highScores().peek(addr); - val = instance().highScores().convert(val, maxVal, isBCD, zeroBased); + val = HighScoresManager::convert(val, maxVal, isBCD, zeroBased); // format output and display in value widget // if (isBCD) diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 21a05844b..3f28d5e83 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -147,7 +147,7 @@ class GuiObject : public CommandReceiver virtual void draw() = 0; virtual void drawChain() = 0; - virtual const string getHelpURL() const = 0; + virtual string getHelpURL() const = 0; virtual bool hasHelp() const = 0; private: diff --git a/src/gui/HighScoresDialog.cxx b/src/gui/HighScoresDialog.cxx index 27f038469..3e33b99f1 100644 --- a/src/gui/HighScoresDialog.cxx +++ b/src/gui/HighScoresDialog.cxx @@ -540,7 +540,7 @@ string HighScoresDialog::cartName() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string HighScoresDialog::now() const +string HighScoresDialog::now() { std::tm now = BSPF::localTime(); ostringstream ss; diff --git a/src/gui/HighScoresDialog.hxx b/src/gui/HighScoresDialog.hxx index 55aaf0e3f..ceb99ff61 100644 --- a/src/gui/HighScoresDialog.hxx +++ b/src/gui/HighScoresDialog.hxx @@ -63,7 +63,7 @@ class HighScoresDialog : public Dialog bool handleDirty(); string cartName() const; - string now() const; + static string now(); enum { kVariationChanged = 'Vach', diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 1ac29702d..5ddf5ff09 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -418,7 +418,7 @@ void InputDialog::loadConfig() VarList::push_back(items, port, port); if(avoxport != EmptyString && !BSPF::contains(ports, avoxport)) VarList::push_back(items, avoxport, avoxport); - if(items.size() == 0) + if(items.empty()) VarList::push_back(items, "None detected"); myAVoxPort->addItems(items); diff --git a/src/gui/InputTextDialog.cxx b/src/gui/InputTextDialog.cxx index 6ed3cf415..fd2c4a810 100644 --- a/src/gui/InputTextDialog.cxx +++ b/src/gui/InputTextDialog.cxx @@ -89,7 +89,7 @@ void InputTextDialog::initialize(const GUI::Font& lfont, const GUI::Font& nfont, maxIdx = i; } } - if(labels.size()) + if(!labels.empty()) lwidth = lfont.getStringWidth(labels[maxIdx]); // Create editboxes for all labels diff --git a/src/gui/JoystickDialog.cxx b/src/gui/JoystickDialog.cxx index a1322f950..efe719d94 100644 --- a/src/gui/JoystickDialog.cxx +++ b/src/gui/JoystickDialog.cxx @@ -84,7 +84,7 @@ void JoystickDialog::loadConfig() } myJoyList->setList(sticks); myJoyList->setSelected(0); - if(sticks.size() == 0) + if(sticks.empty()) { myRemoveBtn->setEnabled(false); myJoyText->setText(""); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 0d70b4706..6dea60de0 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -427,7 +427,7 @@ const string& LauncherDialog::selectedRomMD5() // Lookup MD5, and if not present, cache it const auto iter = myMD5List.find(currentNode().getPath()); if(iter == myMD5List.end()) - myMD5List[currentNode().getPath()] = instance().getROMMD5(currentNode()); + myMD5List[currentNode().getPath()] = OSystem::getROMMD5(currentNode()); return myMD5List[currentNode().getPath()]; } @@ -506,7 +506,7 @@ void LauncherDialog::loadConfig() // has been called (and we should reload the list) if(myList->getList().empty()) { - FSNode node(romdir == "" ? "~" : romdir); + FSNode node(romdir.empty() ? "~" : romdir); if(!myList->isDirectory(node)) node = FSNode("~"); @@ -564,7 +564,8 @@ string LauncherDialog::getRomDir() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool LauncherDialog::matchWithWildcardsIgnoreCase(const string& str, const string& pattern) +bool LauncherDialog::matchWithWildcardsIgnoreCase( + const string& str, const string& pattern) { string in = str; string pat = pattern; @@ -591,7 +592,7 @@ void LauncherDialog::applyFiltering() return false; // Skip over files that don't match the pattern in the 'pattern' textbox - if(myPattern && myPattern->getText() != "" && + if(myPattern && !myPattern->getText().empty() && !matchWithWildcardsIgnoreCase(node.getName(), myPattern->getText())) return false; } diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index 09e6e14f1..e16fde73c 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -139,7 +139,8 @@ class LauncherDialog : public Dialog, CommandSender @return True if pattern was found. */ - bool matchWithWildcardsIgnoreCase(const string& str, const string& pattern); + static bool matchWithWildcardsIgnoreCase(const string& str, + const string& pattern); void applyFiltering(); diff --git a/src/gui/LauncherFileListWidget.cxx b/src/gui/LauncherFileListWidget.cxx index 39faa6cdc..1b0848cf6 100644 --- a/src/gui/LauncherFileListWidget.cxx +++ b/src/gui/LauncherFileListWidget.cxx @@ -68,7 +68,7 @@ void LauncherFileListWidget::getChildren(const FSNode::CancelCheck& isCancelled) if(myVirtualDir == user_name) { - for(auto& item : myFavorites->userList()) + for(const auto& item : myFavorites->userList()) { FSNode node(item); string name = node.getName(); @@ -84,7 +84,7 @@ void LauncherFileListWidget::getChildren(const FSNode::CancelCheck& isCancelled) } else if(myVirtualDir == popular_name) { - for(auto& item : myFavorites->popularList()) + for(const auto& item : myFavorites->popularList()) { FSNode node(item.first); if(_filter(node)) @@ -93,7 +93,7 @@ void LauncherFileListWidget::getChildren(const FSNode::CancelCheck& isCancelled) } else if(myVirtualDir == recent_name) { - for(auto& item : myFavorites->recentList()) + for(const auto& item : myFavorites->recentList()) { FSNode node(item); if(_filter(node)) @@ -142,11 +142,11 @@ void LauncherFileListWidget::extendLists(StringList& list) // Add virtual directories behind ".." int offset = _fileList.begin()->getName() == ".." ? 1 : 0; - if(myFavorites->userList().size()) + if(!myFavorites->userList().empty()) addFolder(list, offset, user_name, IconType::userdir); - if(myFavorites->popularList().size()) + if(!myFavorites->popularList().empty()) addFolder(list, offset, popular_name, IconType::popdir); - if(myFavorites->recentList().size()) + if(!myFavorites->recentList().empty()) addFolder(list, offset, recent_name, IconType::recentdir); } } diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index fddb8e043..3b8f02c61 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -94,7 +94,7 @@ void ListWidget::setSelected(const string& item) int selected = -1; if(!_list.empty()) { - if(item == "") + if(item.empty()) selected = 0; else { diff --git a/src/gui/MessageDialog.cxx b/src/gui/MessageDialog.cxx index 4304a67d9..1ad61a015 100644 --- a/src/gui/MessageDialog.cxx +++ b/src/gui/MessageDialog.cxx @@ -42,8 +42,7 @@ MessageDialog::~MessageDialog() void MessageDialog::loadConfig() { // ugly, but I can't do better - if (myMsg != nullptr) - delete myMsg; + delete myMsg; myMsg = new GUI::MessageBox(this, _font, myText, FBMinimum::Width, FBMinimum::Height, kOKCmd, kCloseCmd, @@ -69,7 +68,8 @@ void MessageDialog::handleCommand(CommandSender* sender, int cmd, int data, int } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void MessageDialog::setMessage(const string& title, const StringList& text, bool yesNo) +void MessageDialog::setMessage(const string& title, const StringList& text, + bool yesNo) { myTitle = title; myText = text; @@ -77,13 +77,14 @@ void MessageDialog::setMessage(const string& title, const StringList& text, bool } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void MessageDialog::setMessage(const string& title, const string& text, bool yesNo) +void MessageDialog::setMessage(const string& title, const string& text, + bool yesNo) { setMessage(title, StringParser(text).stringList(), yesNo); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string MessageDialog::myTitle = ""; +string MessageDialog::myTitle; StringList MessageDialog::myText; bool MessageDialog::myYesNo = false; bool MessageDialog::myConfirmed = false; diff --git a/src/gui/MessageDialog.hxx b/src/gui/MessageDialog.hxx index 19e23e381..3ead58fda 100644 --- a/src/gui/MessageDialog.hxx +++ b/src/gui/MessageDialog.hxx @@ -32,8 +32,10 @@ class MessageDialog : public Dialog ~MessageDialog() override; // Define the message displayed - void setMessage(const string& title, const string& text, bool yesNo = false); - void setMessage(const string& title, const StringList& text, bool yesNo = false); + static void setMessage(const string& title, const string& text, + bool yesNo = false); + static void setMessage(const string& title, const StringList& text, + bool yesNo = false); bool confirmed() { return myConfirmed; } protected: diff --git a/src/gui/MessageMenu.cxx b/src/gui/MessageMenu.cxx index 7ecec7512..4e6560e9c 100644 --- a/src/gui/MessageMenu.cxx +++ b/src/gui/MessageMenu.cxx @@ -37,22 +37,23 @@ MessageMenu::~MessageMenu() Dialog* MessageMenu::baseDialog() { if (myMessageDialog == nullptr) - myMessageDialog = new MessageDialog(myOSystem, *this, myOSystem.frameBuffer().font(), - FBMinimum::Width, FBMinimum::Height); + myMessageDialog = new MessageDialog(myOSystem, *this, + myOSystem.frameBuffer().font(), FBMinimum::Width, FBMinimum::Height); return myMessageDialog; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void MessageMenu::setMessage(const string& title, const StringList& text, bool yesNo) +void MessageMenu::setMessage(const string& title, const StringList& text, + bool yesNo) { - myMessageDialog->setMessage(title, text, yesNo); + MessageDialog::setMessage(title, text, yesNo); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MessageMenu::setMessage(const string& title, const string& text, bool yesNo) { - myMessageDialog->setMessage(title, text, yesNo); + MessageDialog::setMessage(title, text, yesNo); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/MessageMenu.hxx b/src/gui/MessageMenu.hxx index 163980faa..a7d817f81 100644 --- a/src/gui/MessageMenu.hxx +++ b/src/gui/MessageMenu.hxx @@ -37,8 +37,10 @@ class MessageMenu : public DialogContainer explicit MessageMenu(OSystem& osystem); ~MessageMenu() override; - void setMessage(const string& title, const string& text, bool yesNo = false); - void setMessage(const string& title, const StringList& text, bool yesNo = false); + static void setMessage(const string& title, const string& text, + bool yesNo = false); + static void setMessage(const string& title, const StringList& text, + bool yesNo = false); bool confirmed(); private: diff --git a/src/gui/OptionsDialog.cxx b/src/gui/OptionsDialog.cxx index d607fccd4..f487f5f72 100644 --- a/src/gui/OptionsDialog.cxx +++ b/src/gui/OptionsDialog.cxx @@ -167,7 +167,7 @@ void OptionsDialog::loadConfig() myGameInfoButton->setFlags(Widget::FLAG_ENABLED); break; case EventHandlerState::LAUNCHER: - if(instance().launcher().selectedRomMD5() != "") + if(!instance().launcher().selectedRomMD5().empty()) myGameInfoButton->setFlags(Widget::FLAG_ENABLED); else myGameInfoButton->clearFlags(Widget::FLAG_ENABLED); diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 26a427209..c52751408 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -26,7 +26,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int w, int h, const VariantList& list, + int x, int y, int w, int h, const VariantList& items, const string& label, int labelWidth, int cmd) : EditableWidget(boss, font, x, y - 1, w, h + 2), _label{label}, @@ -55,7 +55,8 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, myTextY = (_h - _font.getFontHeight()) / 2; myArrowsY = (_h - _arrowHeight) / 2; - myMenu = make_unique(this, font, list, cmd, w + dropDownWidth(font)); + myMenu = make_unique(this, font, items, cmd, + w + dropDownWidth(font)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ProgressDialog.hxx b/src/gui/ProgressDialog.hxx index edb3f4fdb..45fdddab9 100644 --- a/src/gui/ProgressDialog.hxx +++ b/src/gui/ProgressDialog.hxx @@ -34,7 +34,7 @@ class ProgressDialog : public Dialog ~ProgressDialog() override = default; void setMessage(const string& message); - void setRange(int begin, int end, int step); + void setRange(int start, int finish, int step); void resetProgress(); void setProgress(int progress); void incProgress(); diff --git a/src/gui/R77HelpDialog.hxx b/src/gui/R77HelpDialog.hxx index e03a8bb7c..20835f7f6 100644 --- a/src/gui/R77HelpDialog.hxx +++ b/src/gui/R77HelpDialog.hxx @@ -37,7 +37,7 @@ class R77HelpDialog : public Dialog void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void updateStrings(uInt8 page, uInt8 lines, string& title); void displayInfo(); - void formatWidget(const string& label, StaticTextWidget* widget); + static void formatWidget(const string& label, StaticTextWidget* widget); void loadConfig() override; private: diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index 67b34221a..30ec2bfc5 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -240,7 +240,7 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font, _innerCircle = radio_img_innercircle_large.data(); } - if(label == "") + if(label.empty()) _w = _buttonSize; else _w = font.getStringWidth(label) + _buttonSize + font.getMaxCharWidth() * 0.75; diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index f20266a1e..346c57d43 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -96,7 +96,7 @@ void RomAuditDialog::loadConfig() { const string& currentdir = instance().launcher().currentDir().getShortPath(); - const string& path = currentdir == "" ? + const string& path = currentdir.empty() ? instance().settings().getString("romdir") : currentdir; myRomPath->setText(path); @@ -138,13 +138,13 @@ void RomAuditDialog::auditRoms() // Calculate the MD5 so we can get the rest of the info // from the PropertiesSet (stella.pro) - const string& md5 = instance().getROMMD5(files[idx]); + const string& md5 = OSystem::getROMMD5(files[idx]); if(instance().propSet().getMD5(md5, props)) { const string& name = props.get(PropType::Cart_Name); // Only rename the file if we found a valid properties entry - if(name != "" && name != files[idx].getName()) + if(!name.empty() && name != files[idx].getName()) { string newfile = node.getPath(); newfile.append(name).append(".").append(extension); diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 1b96f4ba5..9562b3fd7 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -153,7 +153,8 @@ void RomImageWidget::parseProperties(const FSNode& node, bool full) } else { - const string oldFileName = myImageList.size() ? myImageList[0].getPath() : EmptyString; + const string oldFileName = !myImageList.empty() + ? myImageList[0].getPath() : EmptyString; // Try to find all snapshots by property and ROM file name myImageList.clear(); @@ -162,7 +163,7 @@ void RomImageWidget::parseProperties(const FSNode& node, bool full) // The first file found before must not be the first file now, if files by // property *and* ROM name are found (TODO: fix that!) - if(myImageList.size() && myImageList[0].getPath() != oldFileName) + if(!myImageList.empty() && myImageList[0].getPath() != oldFileName) loadImage(myImageList[0].getPath()); else setDirty(); // update the counter display @@ -230,7 +231,7 @@ bool RomImageWidget::getImageList(const string& propName, const string& romName, node1.getName() == oldFileName; } ); - return myImageList.size() > 0; + return !myImageList.empty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -396,7 +397,7 @@ void RomImageWidget::drawWidget(bool hilite) s.fillRect(_x, yText, _w, _font.getFontHeight(), _bgcolor); if(myLabel.length()) s.drawString(_font, myLabel, _x, yText, _w - wText - _font.getMaxCharWidth() * 2, _textcolor); - if(myImageList.size()) + if(!myImageList.empty()) s.drawString(_font, buf.str(), _x + _w - wText, yText, wText, _textcolor); // Draw the navigation arrows diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 3f892ddba..f89cecd67 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -122,7 +122,7 @@ void RomInfoWidget::parseProperties(const FSNode& node, bool full) try { ByteBuffer image; - string md5 = ""; + string md5; if(node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr) @@ -146,10 +146,10 @@ void RomInfoWidget::parseProperties(const FSNode& node, bool full) // failed for any reason left = right = ""; } - if(left != "" && right != "") + if(!left.empty() && !right.empty()) myRomInfo.push_back("Controllers: " + (left + " (left), " + right + " (right)")); - if(bsDetected != "") + if(!bsDetected.empty()) { ostringstream buf; diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index e29eff46a..68b717fd8 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -446,7 +446,7 @@ void StellaSettingsDialog::loadControllerProperties(const Properties& props) enable = true; break; case EventHandlerState::LAUNCHER: - enable = (instance().launcher().selectedRomMD5() != ""); + enable = !instance().launcher().selectedRomMD5().empty(); break; default: break; @@ -533,7 +533,7 @@ void StellaSettingsDialog::updateControllerStates() autoDetect = node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr; } - string label = ""; + string label; Controller::Type type = Controller::getType(myLeftPort->getSelectedTag().toString()); if(type == Controller::Type::Unknown) diff --git a/src/gui/StellaSettingsDialog.hxx b/src/gui/StellaSettingsDialog.hxx index 2b768ffcb..73d03f0e9 100644 --- a/src/gui/StellaSettingsDialog.hxx +++ b/src/gui/StellaSettingsDialog.hxx @@ -61,8 +61,8 @@ class StellaSettingsDialog : public Dialog void loadControllerProperties(const Properties& props); // convert internal setting values to user friendly levels - int levelToValue(int level); - int valueToLevel(int value); + static int levelToValue(int level); + static int valueToLevel(int value); void openHelp(); diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index f6cc6e947..30508965e 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -80,7 +80,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) _stepValue.clear(); // If no steps are defined, just use the maximum value - if(steps.size() > 0) + if(!steps.empty()) { // Try to allocate as infrequently as possible if(steps.size() > _stepValue.capacity()) diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 7e6896bb2..e3f0e3d9a 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -662,10 +662,14 @@ void UIDialog::handleLauncherSize() { // Determine minimal launcher sizebased on the default font // So what fits with default font should fit for any font. - const FontDesc fd = instance().frameBuffer().getFontDesc(myDialogFontPopup->getSelectedTag().toString()); - const int w = std::max(FBMinimum::Width, FBMinimum::Width * fd.maxwidth / GUI::stellaMediumDesc.maxwidth); - const int h = std::max(FBMinimum::Height, FBMinimum::Height * fd.height / GUI::stellaMediumDesc.height); - const Common::Size& ds = instance().frameBuffer().desktopSize(BufferType::Launcher); + const FontDesc& fd = FrameBuffer::getFontDesc( + myDialogFontPopup->getSelectedTag().toString()); + const int w = std::max(FBMinimum::Width, FBMinimum::Width * + fd.maxwidth / GUI::stellaMediumDesc.maxwidth); + const int h = std::max(FBMinimum::Height, FBMinimum::Height * + fd.height / GUI::stellaMediumDesc.height); + const Common::Size& ds = + instance().frameBuffer().desktopSize(BufferType::Launcher); myLauncherWidthSlider->setMinValue(w); if(myLauncherWidthSlider->getValue() < myLauncherWidthSlider->getMinValue()) diff --git a/src/gui/UndoHandler.cxx b/src/gui/UndoHandler.cxx index e5d3cd398..8c2e9882b 100644 --- a/src/gui/UndoHandler.cxx +++ b/src/gui/UndoHandler.cxx @@ -91,7 +91,7 @@ bool UndoHandler::redo(string& text) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 UndoHandler::lastDiff(const string& text, const string& oldText) const +uInt32 UndoHandler::lastDiff(const string& text, const string& oldText) { auto pos = static_cast(text.size()); diff --git a/src/gui/UndoHandler.hxx b/src/gui/UndoHandler.hxx index d219f441c..c1a964739 100644 --- a/src/gui/UndoHandler.hxx +++ b/src/gui/UndoHandler.hxx @@ -49,7 +49,7 @@ class UndoHandler bool endChars(const string& text); // Get index into text of last different character - uInt32 lastDiff(const string& text, const string& oldText) const; + static uInt32 lastDiff(const string& text, const string& oldText); private: std::deque myBuffer; diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index af6f5bda4..d1a9a0cb1 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -788,11 +788,10 @@ void VideoAudioDialog::saveConfig() ntscAdj.artifacts = myTVArtifacts->getValue(); ntscAdj.fringing = myTVFringe->getValue(); ntscAdj.bleed = myTVBleed->getValue(); - instance().frameBuffer().tiaSurface().ntsc().setCustomAdjustables(ntscAdj); + NTSCFilter::setCustomAdjustables(ntscAdj); Logger::debug("Saving TV effects options ..."); - instance().frameBuffer().tiaSurface().ntsc().saveConfig(settings); - + NTSCFilter::saveConfig(settings); // TV phosphor mode & blend settings.setValue("tv.phosphor", @@ -983,8 +982,7 @@ void VideoAudioDialog::handleTVModeChange(NTSCFilter::Preset preset) void VideoAudioDialog::loadTVAdjustables(NTSCFilter::Preset preset) { NTSCFilter::Adjustable adj; - instance().frameBuffer().tiaSurface().ntsc().getAdjustables( - adj, NTSCFilter::Preset(preset)); + NTSCFilter::getAdjustables(adj, NTSCFilter::Preset(preset)); myTVSharp->setValue(adj.sharpness); myTVRes->setValue(adj.resolution); myTVArtifacts->setValue(adj.artifacts); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 52ed2b603..3b849ce39 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -139,7 +139,7 @@ void Widget::draw() } // Now perform the actual widget draw - drawWidget((_flags & Widget::FLAG_HILITED) ? true : false); + drawWidget((_flags & Widget::FLAG_HILITED) != 0); // Restore w/hy if(hasBorder()) @@ -365,7 +365,7 @@ void Widget::setHelpURL(const string& helpURL) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string Widget::getHelpURL() const +string Widget::getHelpURL() const { if(!_helpURL.empty()) return _helpURL; @@ -377,35 +377,36 @@ const string Widget::getHelpURL() const else return "https://stella-emu.github.io/docs/index.html#" + _helpAnchor; } - return EmptyString; + return {}; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Widget* Widget::findWidgetInChain(Widget* w, int x, int y) +Widget* Widget::findWidgetInChain(Widget* start, int x, int y) { - while(w) + while(start) { - // Stop as soon as we find a widget that contains the point (x,y) - if(x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h) + // Stop as soon as starte find a startidget that contains the point (x,y) + if(x >= start->_x && x < start->_x + start->_w && + y >= start->_y && y < start->_y + start->_h) break; - w = w->_next; + start = start->_next; } - if(w) - w = w->findWidget(x - w->_x, y - w->_y); + if(start) + start = start->findWidget(x - start->_x, y - start->_y); - return w; + return start; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Widget::isWidgetInChain(Widget* w, const Widget* find) +bool Widget::isWidgetInChain(Widget* start, const Widget* find) { - while(w) + while(start) { - // Stop as soon as we find the widget - if(w == find) return true; - w = w->_next; + // Stop as soon as starte find the startidget + if(start == find) return true; + start = start->_next; } return false; } @@ -864,7 +865,7 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font, _editable = true; _boxSize = boxSize(font); - if(label == "") + if(label.empty()) _w = _boxSize; else _w = font.getStringWidth(label) + _boxSize + font.getMaxCharWidth() * 0.75; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 7be3ac0d9..9b7c21ae9 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -147,7 +147,7 @@ class Widget : public GuiObject void handleCommand(CommandSender* sender, int cmd, int data, int id) override { assert(_boss); _boss->handleCommand(sender, cmd, data, id); } - const string getHelpURL() const override; + string getHelpURL() const override; bool hasHelp() const override { return !getHelpURL().empty(); } protected: diff --git a/src/os/libretro/FBBackendLIBRETRO.hxx b/src/os/libretro/FBBackendLIBRETRO.hxx index 1079560a3..8b05cae87 100644 --- a/src/os/libretro/FBBackendLIBRETRO.hxx +++ b/src/os/libretro/FBBackendLIBRETRO.hxx @@ -97,7 +97,7 @@ class FBBackendLIBRETRO : public FBBackend void showCursor(bool) override { } bool fullScreen() const override { return true; } void getRGB(uInt32, uInt8*, uInt8*, uInt8*) const override { } - void readPixels(uInt8*, uInt32, const Common::Rect&) const override { } + void readPixels(uInt8*, size_t, const Common::Rect&) const override { } bool isCurrentWindowPositioned() const override { return true; } Common::Point getCurrentWindowPos() const override { return Common::Point{}; } Int32 getCurrentDisplayIndex() const override { return 0; } diff --git a/src/os/unix/FSNodePOSIX.cxx b/src/os/unix/FSNodePOSIX.cxx index 990d50cd7..bee29cc89 100644 --- a/src/os/unix/FSNodePOSIX.cxx +++ b/src/os/unix/FSNodePOSIX.cxx @@ -97,7 +97,7 @@ string FSNodePOSIX::getShortPath() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FSNodePOSIX::hasParent() const { - return _path != "" && _path != ROOT_DIR; + return !_path.empty() && _path != ROOT_DIR; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/os/unix/OSystemUNIX.cxx b/src/os/unix/OSystemUNIX.cxx index b3ebef4c4..5192e3531 100644 --- a/src/os/unix/OSystemUNIX.cxx +++ b/src/os/unix/OSystemUNIX.cxx @@ -34,6 +34,6 @@ void OSystemUNIX::getBaseDirectories(string& basedir, string& homedir, // Check to see if basedir overrides are active if(useappdir) cout << "ERROR: base dir in app folder not supported" << endl; - else if(usedir != "") + else if(!usedir.empty()) basedir = FSNode(usedir).getPath(); } diff --git a/src/os/unix/SerialPortUNIX.cxx b/src/os/unix/SerialPortUNIX.cxx index 82b8dfddd..a47280542 100644 --- a/src/os/unix/SerialPortUNIX.cxx +++ b/src/os/unix/SerialPortUNIX.cxx @@ -20,19 +20,12 @@ #include #include #include -#include #include #include #include "FSNode.hxx" #include "SerialPortUNIX.hxx" -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -SerialPortUNIX::SerialPortUNIX() - : SerialPort() -{ -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SerialPortUNIX::~SerialPortUNIX() { diff --git a/src/os/unix/SerialPortUNIX.hxx b/src/os/unix/SerialPortUNIX.hxx index 820a2d6af..8aee12ec6 100644 --- a/src/os/unix/SerialPortUNIX.hxx +++ b/src/os/unix/SerialPortUNIX.hxx @@ -29,7 +29,7 @@ class SerialPortUNIX : public SerialPort { public: - SerialPortUNIX(); + SerialPortUNIX() = default; ~SerialPortUNIX() override; /** From c64277346a0718370ee4b768edabea43bcab7b1c Mon Sep 17 00:00:00 2001 From: webgeek1234 Date: Sun, 21 Aug 2022 14:14:15 -0500 Subject: [PATCH 09/11] libretro: android: Fix jni source paths (#921) Change-Id: Ic580fee9833b4110ddcead0033e8106871b22241 --- src/os/libretro/jni/Android.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/os/libretro/jni/Android.mk b/src/os/libretro/jni/Android.mk index 644f983ae..b420f3fc4 100644 --- a/src/os/libretro/jni/Android.mk +++ b/src/os/libretro/jni/Android.mk @@ -1,8 +1,8 @@ LOCAL_PATH := $(call my-dir) -CORE_DIR := $(LOCAL_PATH)/../.. +CORE_DIR := $(LOCAL_PATH)/../../.. -include $(CORE_DIR)/libretro/Makefile.common +include $(CORE_DIR)/os/libretro/Makefile.common COREFLAGS := -DANDROID -D__LIB_RETRO__ -DHAVE_STRINGS_H -DSOUND_SUPPORT $(INCFLAGS) @@ -15,5 +15,5 @@ include $(CLEAR_VARS) LOCAL_MODULE := retro LOCAL_SRC_FILES := $(SOURCES_CXX) $(SOURCES_C) LOCAL_CXXFLAGS := $(COREFLAGS) -std=c++17 -LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/libretro/link.T +LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/os/libretro/link.T include $(BUILD_SHARED_LIBRARY) From 19da02fb9c8dc48f4f9634e4a5e9ed02ab395a60 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 21 Aug 2022 19:33:08 -0230 Subject: [PATCH 10/11] Final batch of fixes from clang-tidy (for now). --- src/cheat/CheatCodeDialog.cxx | 2 +- src/common/AudioSettings.cxx | 2 +- src/common/Base.cxx | 2 +- src/common/EventHandlerSDL2.cxx | 3 ++- src/common/FBBackendSDL2.cxx | 9 +++++---- src/common/FBSurfaceSDL2.cxx | 2 +- src/common/FSNodeZIP.cxx | 2 +- src/common/HighScoresManager.hxx | 1 + src/common/JoyMap.cxx | 8 ++++---- src/common/KeyMap.cxx | 10 +++++----- src/common/LinkedObjectPool.hxx | 2 +- src/common/PaletteHandler.cxx | 7 ++++--- src/common/PhysicalJoystick.cxx | 2 +- src/common/Rect.hxx | 2 +- src/common/RewindManager.cxx | 2 +- src/common/Stack.hxx | 2 +- src/common/StaggeredLogger.cxx | 2 +- src/common/Vec.hxx | 2 +- src/common/audio/LanczosResampler.cxx | 8 ++++---- .../repository/CompositeKVRJsonAdapter.cxx | 5 +++-- .../repository/KeyValueRepositoryJsonFile.cxx | 2 +- .../KeyValueRepositoryPropertyFile.cxx | 2 +- src/common/repository/sqlite/StellaDb.cxx | 2 +- src/common/sdl_blitter/QisBlitter.hxx | 2 +- src/common/tv_filters/NTSCFilter.cxx | 9 --------- src/common/tv_filters/NTSCFilter.hxx | 9 ++++++++- src/debugger/CartDebug.cxx | 9 +++++---- src/debugger/DebuggerParser.cxx | 10 +++++----- src/debugger/TIADebug.cxx | 20 +++++++++---------- src/debugger/gui/CartARMWidget.cxx | 13 +++++++----- src/debugger/gui/CartBUSWidget.cxx | 15 +++++++++----- src/debugger/gui/CartCDFWidget.cxx | 18 +++++++++++------ src/debugger/gui/CartDPCPlusWidget.cxx | 9 ++++++--- src/debugger/gui/CartEnhancedWidget.cxx | 2 +- src/debugger/gui/DataGridWidget.cxx | 12 +++++------ src/debugger/gui/DebuggerDialog.cxx | 2 +- src/debugger/gui/RiotWidget.cxx | 20 +++++++++---------- src/debugger/gui/RomListWidget.cxx | 2 +- src/debugger/gui/TiaWidget.cxx | 4 ++-- src/debugger/gui/ToggleWidget.cxx | 8 ++++---- src/emucore/Cart.cxx | 2 +- src/emucore/Cart0840.cxx | 4 ++-- src/emucore/Cart0840.hxx | 2 +- src/emucore/Cart0FA0.cxx | 4 ++-- src/emucore/Cart0FA0.hxx | 2 +- src/emucore/Cart2K.hxx | 2 +- src/emucore/Cart4K.hxx | 2 +- src/emucore/CartBF.hxx | 2 +- src/emucore/CartCDF.cxx | 2 +- src/emucore/CartCV.hxx | 2 +- src/emucore/CartDF.hxx | 2 +- src/emucore/CartE0.hxx | 2 +- src/emucore/CartEF.hxx | 2 +- src/emucore/CartEnhanced.cxx | 17 +++++++++------- src/emucore/CartEnhanced.hxx | 2 +- src/emucore/CartF0.hxx | 2 +- src/emucore/CartF4.hxx | 2 +- src/emucore/CartF6.hxx | 2 +- src/emucore/CartF8.hxx | 2 +- src/emucore/CartFA.hxx | 2 +- src/emucore/CartFA2.hxx | 2 +- src/emucore/CartFC.cxx | 2 +- src/emucore/CartFC.hxx | 2 +- src/emucore/CartMDM.cxx | 4 ++-- src/emucore/CartMDM.hxx | 2 +- src/emucore/CartMVC.cxx | 10 +++++----- src/emucore/CartSB.cxx | 4 ++-- src/emucore/CartSB.hxx | 2 +- src/emucore/CartTVBoy.hxx | 2 +- src/emucore/CartUA.cxx | 4 ++-- src/emucore/CartUA.hxx | 2 +- src/emucore/CartWD.hxx | 2 +- src/emucore/CartX07.cxx | 4 ++-- src/emucore/CartX07.hxx | 2 +- src/emucore/Console.cxx | 10 +++++----- src/emucore/Control.cxx | 3 ++- src/emucore/EmulationTiming.cxx | 2 +- src/emucore/EventHandler.cxx | 8 ++++---- src/emucore/FBSurface.cxx | 2 +- src/emucore/FrameBuffer.cxx | 3 ++- src/emucore/MD5.cxx | 8 ++++---- src/emucore/MD5.hxx | 2 +- src/emucore/MT24LC256.cxx | 6 +++--- src/emucore/OSystem.cxx | 2 +- src/emucore/PlusROM.cxx | 2 +- src/emucore/ProfilingRunner.cxx | 5 +++-- src/emucore/Settings.cxx | 4 ++-- src/emucore/TIASurface.cxx | 18 ++++++++++------- src/emucore/Thumbulator.cxx | 10 +++++----- src/emucore/tia/AnalogReadout.cxx | 2 +- src/emucore/tia/Audio.cxx | 2 +- src/emucore/tia/Playfield.cxx | 2 +- src/emucore/tia/TIA.cxx | 6 +++--- .../frame-manager/AbstractFrameManager.cxx | 2 +- .../tia/frame-manager/FrameManager.cxx | 2 +- src/gui/DeveloperDialog.cxx | 4 ++-- src/gui/EmulationDialog.cxx | 9 +++++---- src/gui/EventMappingWidget.cxx | 3 ++- src/gui/FileListWidget.cxx | 9 +++++---- src/gui/Font.cxx | 2 +- src/gui/Font.hxx | 2 +- src/gui/Icon.hxx | 2 +- src/gui/Icons.hxx | 2 +- src/gui/Launcher.cxx | 4 ++-- src/gui/LauncherFileListWidget.cxx | 18 ++++++++++------- src/gui/MessageBox.cxx | 2 +- src/gui/MessageBox.hxx | 2 +- src/gui/RadioButtonWidget.cxx | 5 +++-- src/gui/RomImageWidget.cxx | 6 ++++-- src/gui/TimeLineWidget.cxx | 4 ++-- src/gui/ToolTip.cxx | 4 ++-- src/gui/VideoAudioDialog.cxx | 2 +- src/os/unix/FSNodePOSIX.cxx | 8 ++++---- src/os/unix/OSystemUNIX.cxx | 2 +- 114 files changed, 290 insertions(+), 249 deletions(-) diff --git a/src/cheat/CheatCodeDialog.cxx b/src/cheat/CheatCodeDialog.cxx index bbb3c2a2a..bcb5c8f89 100644 --- a/src/cheat/CheatCodeDialog.cxx +++ b/src/cheat/CheatCodeDialog.cxx @@ -128,7 +128,7 @@ void CheatCodeDialog::loadConfig() for(const auto& c: list) { l.push_back(c->name()); - b.push_back(bool(c->enabled())); + b.push_back(c->enabled()); } myCheatList->setList(l, b); diff --git a/src/common/AudioSettings.cxx b/src/common/AudioSettings.cxx index c0f7eb961..5a28d0df1 100644 --- a/src/common/AudioSettings.cxx +++ b/src/common/AudioSettings.cxx @@ -39,7 +39,7 @@ namespace { numericResamplingQuality <= static_cast(AudioSettings::ResamplingQuality::lanczos_3) ) ? static_cast(numericResamplingQuality) : AudioSettings::DEFAULT_RESAMPLING_QUALITY; } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AudioSettings::AudioSettings(Settings& settings) diff --git a/src/common/Base.cxx b/src/common/Base.cxx index 79f632dc6..333050d91 100644 --- a/src/common/Base.cxx +++ b/src/common/Base.cxx @@ -126,4 +126,4 @@ Base::Fmt Base::myDefaultBase = Base::Fmt::_16; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex; // NOLINT -} // Namespace Common +} // namespace Common diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index d4d8766cf..e4d148fb9 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -30,7 +30,8 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem) #ifdef GUI_SUPPORT { ostringstream buf; - myQwertz = int{'y'} == static_cast(SDL_GetKeyFromScancode(SDL_Scancode(KBDK_Z))); + myQwertz = int{'y'} == static_cast + (SDL_GetKeyFromScancode(static_cast(KBDK_Z))); buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY"); Logger::debug(buf.str()); } diff --git a/src/common/FBBackendSDL2.cxx b/src/common/FBBackendSDL2.cxx index dec71cadc..117c6c551 100644 --- a/src/common/FBBackendSDL2.cxx +++ b/src/common/FBBackendSDL2.cxx @@ -357,8 +357,8 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex, const int wantedRefreshRate = myOSystem.hasConsole() ? myOSystem.console().gameRefreshRate() : 0; // Take care of rounded refresh rates (e.g. 59.94 Hz) - float factor = std::min(float(currentRefreshRate) / wantedRefreshRate, - float(currentRefreshRate) / (wantedRefreshRate - 1)); + float factor = std::min( + static_cast(currentRefreshRate) / wantedRefreshRate, static_cast(currentRefreshRate) / (wantedRefreshRate - 1)); // Calculate difference taking care of integer factors (e.g. 100/120) float bestDiff = std::abs(factor - std::round(factor)) / factor; bool adapt = false; @@ -377,8 +377,9 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex, Logger::error("ERROR: Closest display mode could not be retrieved"); return adapt; } - factor = std::min(float(sdlMode.refresh_rate) / sdlMode.refresh_rate, - float(sdlMode.refresh_rate) / (sdlMode.refresh_rate - 1)); + factor = std::min( + static_cast(sdlMode.refresh_rate) / sdlMode.refresh_rate, + static_cast(sdlMode.refresh_rate) / (sdlMode.refresh_rate - 1)); const float diff = std::abs(factor - std::round(factor)) / factor; if(diff < bestDiff) { diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index 6899b982d..749c93bf0 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -38,7 +38,7 @@ namespace { throw runtime_error("unreachable"); } } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FBSurfaceSDL2::FBSurfaceSDL2(FBBackendSDL2& backend, diff --git a/src/common/FSNodeZIP.cxx b/src/common/FSNodeZIP.cxx index 65dc0a82b..acbc1fc3c 100644 --- a/src/common/FSNodeZIP.cxx +++ b/src/common/FSNodeZIP.cxx @@ -39,7 +39,7 @@ FSNodeZIP::FSNodeZIP(const string& p) if (_zipFile[0] == '~') { #if defined(BSPF_UNIX) || defined(BSPF_MACOS) - const char* home = std::getenv("HOME"); + const char* home = std::getenv("HOME"); // NOLINT (not thread safe) if (home != nullptr) _zipFile.replace(0, 1, home); #elif defined(BSPF_WINDOWS) diff --git a/src/common/HighScoresManager.hxx b/src/common/HighScoresManager.hxx index 2af491eb4..9b1e18c6a 100644 --- a/src/common/HighScoresManager.hxx +++ b/src/common/HighScoresManager.hxx @@ -263,4 +263,5 @@ class HighScoresManager HighScoresManager& operator=(const HighScoresManager&) = delete; HighScoresManager& operator=(HighScoresManager&&) = delete; }; + #endif diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index d6ef88aca..6f679f040 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -298,18 +298,18 @@ json JoyMap::convertLegacyMapping(string list) { json eventMapping = json::object(); - eventMapping["event"] = Event::Type(event); + eventMapping["event"] = static_cast(event); if(button != JOY_CTRL_NONE) eventMapping["button"] = button; if(static_cast(axis) != JoyAxis::NONE) { - eventMapping["axis"] = JoyAxis(axis); - eventMapping["axisDirection"] = JoyDir(adir); + eventMapping["axis"] = static_cast(axis); + eventMapping["axisDirection"] = static_cast(adir); } if(hat != -1) { eventMapping["hat"] = hat; - eventMapping["hatDirection"] = JoyHatDir(hdir); + eventMapping["hatDirection"] = static_cast(hdir); } eventMappings.push_back(eventMapping); diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index 496448af9..e05e90f02 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -66,7 +66,7 @@ namespace { return mask; } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void KeyMap::add(const Event::Type event, const Mapping& mapping) @@ -301,11 +301,11 @@ json KeyMap::convertLegacyMapping(string list) { json mapping = json::object(); - mapping["event"] = Event::Type(event); - mapping["key"] = StellaKey(key); + mapping["event"] = static_cast(event); + mapping["key"] = static_cast(key); - if(StellaMod(mod) != StellaMod::KBDM_NONE) - mapping["mod"] = serializeModkeyMask(StellaMod(mod)); + if(static_cast(mod) != StellaMod::KBDM_NONE) + mapping["mod"] = serializeModkeyMask(static_cast(mod)); convertedMapping.push_back(mapping); } diff --git a/src/common/LinkedObjectPool.hxx b/src/common/LinkedObjectPool.hxx index ec50ab32f..6ff9cd476 100644 --- a/src/common/LinkedObjectPool.hxx +++ b/src/common/LinkedObjectPool.hxx @@ -287,6 +287,6 @@ class LinkedObjectPool LinkedObjectPool& operator=(LinkedObjectPool&&) = delete; }; -} // Namespace Common +} // namespace Common #endif diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index d0d809ffd..c8a9987e5 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -46,7 +46,7 @@ PaletteHandler::PaletteType PaletteHandler::toPaletteType(const string& name) co // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string PaletteHandler::toPaletteName(PaletteType type) { - const string SETTING_NAMES[int(PaletteType::NumTypes)] = { + const string SETTING_NAMES[static_cast(PaletteType::NumTypes)] = { SETTING_STANDARD, SETTING_Z26, SETTING_USER, SETTING_CUSTOM }; @@ -321,12 +321,13 @@ void PaletteHandler::setPalette() // Look at all the palettes, since we don't know which one is // currently active - static constexpr BSPF::array2D palettes = {{ + static constexpr BSPF::array2D(ConsoleTiming::numTimings)> palettes = {{ { &ourNTSCPalette, &ourPALPalette, &ourSECAMPalette }, { &ourNTSCPaletteZ26, &ourPALPaletteZ26, &ourSECAMPaletteZ26 }, { &ourUserNTSCPalette, &ourUserPALPalette, &ourUserSECAMPalette }, { &ourCustomNTSCPalette, &ourCustomPALPalette, &ourSECAMPalette } - }}; + }}; // See which format we should be using const ConsoleTiming timing = myOSystem.console().timing(); const PaletteType paletteType = toPaletteType(name); diff --git a/src/common/PhysicalJoystick.cxx b/src/common/PhysicalJoystick.cxx index 78ccac8fa..0e747917e 100644 --- a/src/common/PhysicalJoystick.cxx +++ b/src/common/PhysicalJoystick.cxx @@ -39,7 +39,7 @@ namespace { return result; } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PhysicalJoystick::initialize(int index, const string& desc, diff --git a/src/common/Rect.hxx b/src/common/Rect.hxx index 36bb12359..24653aec5 100644 --- a/src/common/Rect.hxx +++ b/src/common/Rect.hxx @@ -186,6 +186,6 @@ public: } }; -} // End of namespace Common +} // namespace Common #endif diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 8383923db..9053fcae3 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -469,7 +469,7 @@ IntArray RewindManager::cyclesList() const 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)); + arr.push_back(static_cast(it->cycles - firstCycle)); return arr; } diff --git a/src/common/Stack.hxx b/src/common/Stack.hxx index 4329ecab1..c755a5b73 100644 --- a/src/common/Stack.hxx +++ b/src/common/Stack.hxx @@ -79,6 +79,6 @@ class FixedStack FixedStack& operator=(FixedStack&&) = delete; }; -} // Namespace Common +} // namespace Common #endif diff --git a/src/common/StaggeredLogger.cxx b/src/common/StaggeredLogger.cxx index f9243feae..62210c287 100644 --- a/src/common/StaggeredLogger.cxx +++ b/src/common/StaggeredLogger.cxx @@ -33,7 +33,7 @@ namespace { return formattedTime.data(); } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StaggeredLogger::StaggeredLogger(const string& message, Logger::Level level) diff --git a/src/common/Vec.hxx b/src/common/Vec.hxx index 8e4de470c..d9dff2fae 100644 --- a/src/common/Vec.hxx +++ b/src/common/Vec.hxx @@ -40,6 +40,6 @@ void removeAt(vector& dst, uInt32 idx) dst.erase(dst.cbegin()+idx); } -} // Namespace Vec +} // namespace Vec #endif diff --git a/src/common/audio/LanczosResampler.cxx b/src/common/audio/LanczosResampler.cxx index bc83256df..4134fefce 100644 --- a/src/common/audio/LanczosResampler.cxx +++ b/src/common/audio/LanczosResampler.cxx @@ -50,7 +50,7 @@ namespace { return sinc(x) * sinc(x / static_cast(a)); } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LanczosResampler::LanczosResampler( @@ -72,9 +72,9 @@ LanczosResampler::LanczosResampler( myPrecomputedKernelCount{reducedDenominator(formatFrom.sampleRate, formatTo.sampleRate)}, myKernelSize{2 * kernelParameter}, myKernelParameter{kernelParameter}, - myHighPassL{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)}, - myHighPassR{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)}, - myHighPass{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)} + myHighPassL{HIGH_PASS_CUT_OFF, static_cast(formatFrom.sampleRate)}, + myHighPassR{HIGH_PASS_CUT_OFF, static_cast(formatFrom.sampleRate)}, + myHighPass{HIGH_PASS_CUT_OFF, static_cast(formatFrom.sampleRate)} { myPrecomputedKernels = make_unique( static_cast(myPrecomputedKernelCount) * myKernelSize); diff --git a/src/common/repository/CompositeKVRJsonAdapter.cxx b/src/common/repository/CompositeKVRJsonAdapter.cxx index 896557dfb..3c2c8699f 100644 --- a/src/common/repository/CompositeKVRJsonAdapter.cxx +++ b/src/common/repository/CompositeKVRJsonAdapter.cxx @@ -51,12 +51,13 @@ namespace { KeyValueRepositoryAtomic& myKvr; const string& myKey; }; -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CompositeKVRJsonAdapter::CompositeKVRJsonAdapter(KeyValueRepositoryAtomic& kvr) : myKvr{kvr} -{} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - shared_ptr CompositeKVRJsonAdapter::get(const string& key) diff --git a/src/common/repository/KeyValueRepositoryJsonFile.cxx b/src/common/repository/KeyValueRepositoryJsonFile.cxx index d047d0f78..a49e9afe9 100644 --- a/src/common/repository/KeyValueRepositoryJsonFile.cxx +++ b/src/common/repository/KeyValueRepositoryJsonFile.cxx @@ -27,7 +27,7 @@ namespace { return parsed.is_discarded() ? json(s) : parsed; } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - KeyValueRepositoryJsonFile::KeyValueRepositoryJsonFile(const FSNode& node) diff --git a/src/common/repository/KeyValueRepositoryPropertyFile.cxx b/src/common/repository/KeyValueRepositoryPropertyFile.cxx index 141a23642..ff582663d 100644 --- a/src/common/repository/KeyValueRepositoryPropertyFile.cxx +++ b/src/common/repository/KeyValueRepositoryPropertyFile.cxx @@ -66,7 +66,7 @@ namespace { } out.put('"'); } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - KeyValueRepositoryPropertyFile::KeyValueRepositoryPropertyFile( diff --git a/src/common/repository/sqlite/StellaDb.cxx b/src/common/repository/sqlite/StellaDb.cxx index b632bd330..e36319c2d 100644 --- a/src/common/repository/sqlite/StellaDb.cxx +++ b/src/common/repository/sqlite/StellaDb.cxx @@ -36,7 +36,7 @@ namespace { constexpr Int32 CURRENT_VERSION = 1; -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - StellaDb::StellaDb(const string& databaseDirectory, const string& databaseName) diff --git a/src/common/sdl_blitter/QisBlitter.hxx b/src/common/sdl_blitter/QisBlitter.hxx index 92e31f139..b682ed7b5 100644 --- a/src/common/sdl_blitter/QisBlitter.hxx +++ b/src/common/sdl_blitter/QisBlitter.hxx @@ -37,7 +37,7 @@ class QisBlitter : public Blitter { SDL_Rect srcRect, SDL_Rect destRect, FBSurface::Attributes attributes, - SDL_Surface* staticData = nullptr + SDL_Surface* staticData ) override; void blit(SDL_Surface& surface) override; diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index c1b6e61e3..00af294ee 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -192,12 +192,3 @@ void NTSCFilter::convertToAdjustable(Adjustable& adjustable, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AtariNTSC::Setup NTSCFilter::myCustomSetup = AtariNTSC::TV_Composite; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const std::array NTSCFilter::ourCustomAdjustables = { { - { "sharpness", &myCustomSetup.sharpness }, - { "resolution", &myCustomSetup.resolution }, - { "artifacts", &myCustomSetup.artifacts }, - { "fringing", &myCustomSetup.fringing }, - { "bleeding", &myCustomSetup.bleed } -} }; diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index dcd59925d..aec8454c2 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -148,7 +148,14 @@ class NTSCFilter float* value{nullptr}; }; uInt32 myCurrentAdjustable{0}; - static const std::array ourCustomAdjustables; + + static constexpr std::array ourCustomAdjustables = {{ + { "sharpness", &myCustomSetup.sharpness }, + { "resolution", &myCustomSetup.resolution }, + { "artifacts", &myCustomSetup.artifacts }, + { "fringing", &myCustomSetup.fringing }, + { "bleeding", &myCustomSetup.bleed } + }}; private: // Following constructors and assignment operators not supported diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 4c730b04d..22561c378 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -248,7 +248,8 @@ bool CartDebug::disassembleAddr(uInt16 address, bool force) const Cartridge& cart = myConsole.cartridge(); const int segCount = cart.segmentCount(); // ROM/RAM bank or ZP-RAM? - const int addrBank = (address & 0x1000) ? getBank(address) : int(myBankInfo.size()) - 1; + const int addrBank = (address & 0x1000) + ? getBank(address) : static_cast(myBankInfo.size()) - 1; if(segCount > 1) { @@ -476,7 +477,7 @@ bool CartDebug::addDirective(Device::AccessType type, if(bank < 0) // Do we want the current bank or ZP RAM? bank = (myDebugger.cpuDebug().pc() & 0x1000) ? - getBank(myDebugger.cpuDebug().pc()) : int(myBankInfo.size())-1; + getBank(myDebugger.cpuDebug().pc()) : static_cast(myBankInfo.size())-1; bank = std::min(bank, romBankCount()); BankInfo& info = myBankInfo[bank]; @@ -628,7 +629,7 @@ bool CartDebug::addLabel(const string& label, uInt16 address) removeLabel(label); myUserAddresses.emplace(label, address); myUserLabels.emplace(address, label); - myLabelLength = std::max(myLabelLength, uInt16(label.size())); + myLabelLength = std::max(myLabelLength, static_cast(label.size())); mySystem.setDirtyPage(address); return true; } @@ -1393,7 +1394,7 @@ string CartDebug::saveDisassembly(string path) << ";-----------------------------------------------------------\n\n"; int max_len = 16; for(const auto& iter: myUserLabels) - max_len = std::max(max_len, int(iter.second.size())); + max_len = std::max(max_len, static_cast(iter.second.size())); for(const auto& iter: myUserLabels) out << ALIGN(max_len) << iter.second << "= $" << iter.first << "\n"; } diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 95acc5b63..7f27b5eab 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -563,7 +563,7 @@ string DebuggerParser::eval() if(args[i] < 0x10000) buf << " %" << Base::toString(args[i], Base::Fmt::_2); - buf << " #" << int(args[i]); + buf << " #" << static_cast(args[i]); if(i != argCount - 1) buf << endl; } @@ -756,7 +756,7 @@ void DebuggerParser::executeDirective(Device::AccessType type) // "a" void DebuggerParser::executeA() { - debugger.cpuDebug().setA(uInt8(args[0])); + debugger.cpuDebug().setA(static_cast(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1909,7 +1909,7 @@ void DebuggerParser::executeRunToPc() // "s" void DebuggerParser::executeS() { - debugger.cpuDebug().setSP(uInt8(args[0])); + debugger.cpuDebug().setSP(static_cast(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2488,14 +2488,14 @@ void DebuggerParser::executeWinds(bool unwind) // "x" void DebuggerParser::executeX() { - debugger.cpuDebug().setX(uInt8(args[0])); + debugger.cpuDebug().setX(static_cast(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "y" void DebuggerParser::executeY() { - debugger.cpuDebug().setY(uInt8(args[0])); + debugger.cpuDebug().setY(static_cast(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 17fc528a3..1fb34cee3 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -293,7 +293,7 @@ void TIADebug::saveOldState() bool TIADebug::vdelP0(int newVal) { if(newVal > -1) - mySystem.poke(VDELP0, bool(newVal)); + mySystem.poke(VDELP0, static_cast(newVal)); return myTIA.registerValue(VDELP0) & 0x01; } @@ -302,7 +302,7 @@ bool TIADebug::vdelP0(int newVal) bool TIADebug::vdelP1(int newVal) { if(newVal > -1) - mySystem.poke(VDELP1, bool(newVal)); + mySystem.poke(VDELP1, static_cast(newVal)); return myTIA.registerValue(VDELP1) & 0x01; } @@ -311,7 +311,7 @@ bool TIADebug::vdelP1(int newVal) bool TIADebug::vdelBL(int newVal) { if(newVal > -1) - mySystem.poke(VDELBL, bool(newVal)); + mySystem.poke(VDELBL, static_cast(newVal)); return myTIA.registerValue(VDELBL) & 0x01; } @@ -320,7 +320,7 @@ bool TIADebug::vdelBL(int newVal) bool TIADebug::enaM0(int newVal) { if(newVal > -1) - mySystem.poke(ENAM0, bool(newVal) << 1); + mySystem.poke(ENAM0, static_cast(newVal) << 1); return myTIA.registerValue(ENAM0) & 0x02; } @@ -329,7 +329,7 @@ bool TIADebug::enaM0(int newVal) bool TIADebug::enaM1(int newVal) { if(newVal > -1) - mySystem.poke(ENAM1, bool(newVal) << 1); + mySystem.poke(ENAM1, static_cast(newVal) << 1); return myTIA.registerValue(ENAM1) & 0x02; } @@ -338,7 +338,7 @@ bool TIADebug::enaM1(int newVal) bool TIADebug::enaBL(int newVal) { if(newVal > -1) - mySystem.poke(ENABL, bool(newVal) << 1); + mySystem.poke(ENABL, static_cast(newVal) << 1); return myTIA.registerValue(ENABL) & 0x02; } @@ -347,7 +347,7 @@ bool TIADebug::enaBL(int newVal) bool TIADebug::resMP0(int newVal) { if(newVal > -1) - mySystem.poke(RESMP0, bool(newVal) << 1); + mySystem.poke(RESMP0, static_cast(newVal) << 1); return myTIA.registerValue(RESMP0) & 0x02; } @@ -356,7 +356,7 @@ bool TIADebug::resMP0(int newVal) bool TIADebug::resMP1(int newVal) { if(newVal > -1) - mySystem.poke(RESMP1, bool(newVal) << 1); + mySystem.poke(RESMP1, static_cast(newVal) << 1); return myTIA.registerValue(RESMP1) & 0x02; } @@ -365,7 +365,7 @@ bool TIADebug::resMP1(int newVal) bool TIADebug::refP0(int newVal) { if(newVal > -1) - mySystem.poke(REFP0, bool(newVal) << 3); + mySystem.poke(REFP0, static_cast(newVal) << 3); return myTIA.registerValue(REFP0) & 0x08; } @@ -374,7 +374,7 @@ bool TIADebug::refP0(int newVal) bool TIADebug::refP1(int newVal) { if(newVal > -1) - mySystem.poke(REFP1, bool(newVal) << 3); + mySystem.poke(REFP1, static_cast(newVal) << 3); return myTIA.registerValue(REFP1) & 0x08; } diff --git a/src/debugger/gui/CartARMWidget.cxx b/src/debugger/gui/CartARMWidget.cxx index 0a43dd488..3361e9ce7 100644 --- a/src/debugger/gui/CartARMWidget.cxx +++ b/src/debugger/gui/CartARMWidget.cxx @@ -162,23 +162,26 @@ void CartridgeARMWidget::loadConfig() alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.prevCycles()); - changed.push_back(myCart.prevCycles() != uInt32(myOldState.armPrevRun[0])); + changed.push_back(myCart.prevCycles() != + static_cast(myOldState.armPrevRun[0])); myPrevThumbCycles->setList(alist, vlist, changed); alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.prevStats().instructions); - changed.push_back(myCart.prevStats().instructions != uInt32(myOldState.armPrevRun[1])); + changed.push_back(myCart.prevStats().instructions != + static_cast(myOldState.armPrevRun[1])); myPrevThumbInstructions->setList(alist, vlist, changed); alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.cycles()); - changed.push_back(myCart.cycles() != uInt32(myOldState.armRun[0])); + changed.push_back(myCart.cycles() != + static_cast(myOldState.armRun[0])); myThumbCycles->setList(alist, vlist, changed); - alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.stats().instructions); - changed.push_back(myCart.stats().instructions != uInt32(myOldState.armRun[1])); + changed.push_back(myCart.stats().instructions != + static_cast(myOldState.armRun[1])); myThumbInstructions->setList(alist, vlist, changed); CartDebugWidget::loadConfig(); diff --git a/src/debugger/gui/CartBUSWidget.cxx b/src/debugger/gui/CartBUSWidget.cxx index 47486de61..38095001c 100644 --- a/src/debugger/gui/CartBUSWidget.cxx +++ b/src/debugger/gui/CartBUSWidget.cxx @@ -368,7 +368,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); - changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i])); + changed.push_back(myCart.myMusicCounters[i] != + static_cast(myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -376,7 +377,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); - changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i])); + changed.push_back(myCart.myMusicFrequencies[i] != + static_cast(myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); @@ -384,7 +386,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); - changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i])); + changed.push_back((myCart.getWaveform(i) >> 5) != + static_cast(myOldState.mwaves[i])); } myMusicWaveforms->setList(alist, vlist, changed); @@ -392,7 +395,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); - changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i])); + changed.push_back((myCart.getWaveformSize(i)) != + static_cast(myOldState.mwavesizes[i])); } myMusicWaveformSizes->setList(alist, vlist, changed); @@ -400,7 +404,8 @@ void CartridgeBUSWidget::loadConfig() { alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.getSample()); - changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0])); + changed.push_back((myCart.getSample()) != + static_cast(myOldState.samplepointer[0])); mySamplePointer->setList(alist, vlist, changed); } diff --git a/src/debugger/gui/CartCDFWidget.cxx b/src/debugger/gui/CartCDFWidget.cxx index f73801350..21d2dbb6c 100644 --- a/src/debugger/gui/CartCDFWidget.cxx +++ b/src/debugger/gui/CartCDFWidget.cxx @@ -285,7 +285,8 @@ void CartridgeCDFWidget::loadConfig() { alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.myRAM[myCart.myFastFetcherOffset]); - changed.push_back((myCart.myRAM[myCart.myFastFetcherOffset]) != uInt32(myOldState.fastfetchoffset[0])); + changed.push_back((myCart.myRAM[myCart.myFastFetcherOffset]) != + static_cast(myOldState.fastfetchoffset[0])); myFastFetcherOffset->setList(alist, vlist, changed); } @@ -360,7 +361,8 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); - changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i])); + changed.push_back(myCart.myMusicCounters[i] != + static_cast(myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -368,7 +370,8 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); - changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i])); + changed.push_back(myCart.myMusicFrequencies[i] != + static_cast(myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); @@ -376,7 +379,8 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); - changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i])); + changed.push_back((myCart.getWaveform(i) >> 5) != + static_cast(myOldState.mwaves[i])); } myMusicWaveforms->setList(alist, vlist, changed); @@ -384,13 +388,15 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); - changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i])); + changed.push_back((myCart.getWaveformSize(i)) != + static_cast(myOldState.mwavesizes[i])); } myMusicWaveformSizes->setList(alist, vlist, changed); alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.getSample()); - changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0])); + changed.push_back((myCart.getSample()) != + static_cast(myOldState.samplepointer[0])); mySamplePointer->setList(alist, vlist, changed); myFastFetch->setState((myCart.myMode & 0x0f) == 0); diff --git a/src/debugger/gui/CartDPCPlusWidget.cxx b/src/debugger/gui/CartDPCPlusWidget.cxx index 424558aff..889cfe93b 100644 --- a/src/debugger/gui/CartDPCPlusWidget.cxx +++ b/src/debugger/gui/CartDPCPlusWidget.cxx @@ -262,7 +262,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]); - changed.push_back(myCart.myFractionalCounters[i] != uInt32(myOldState.fraccounters[i])); + changed.push_back(myCart.myFractionalCounters[i] != + static_cast(myOldState.fraccounters[i])); } myFracCounters->setList(alist, vlist, changed); @@ -286,7 +287,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); - changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i])); + changed.push_back(myCart.myMusicCounters[i] != + static_cast(myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -294,7 +296,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); - changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i])); + changed.push_back(myCart.myMusicFrequencies[i] != + static_cast(myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index 7e3f90703..6508e33ec 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -123,7 +123,7 @@ string CartridgeEnhancedWidget::romDescription() else { uInt16 start = (image[myCart.mySize - 3] << 8) | image[myCart.mySize - 4]; - start -= start % std::min(int(size), 0x1000); + start -= start % std::min(static_cast(size), 0x1000); const uInt16 end = start + static_cast(myCart.mySize) - 1; // special check for ROMs where the extra RAM is not included in the image (e.g. CV). if((start & 0xFFFU) < size) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 943c9e23e..25f7c3900 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -374,12 +374,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_DOWN: - if (_currentRow < int(_rows) - 1) + if (_currentRow < _rows - 1) { _currentRow++; dirty = true; } - else if(_currentCol < int(_cols) - 1) + else if(_currentCol < _cols - 1) { _currentRow = 0; _currentCol++; @@ -402,12 +402,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_RIGHT: - if (_currentCol < int(_cols) - 1) + if (_currentCol < _cols - 1) { _currentCol++; dirty = true; } - else if(_currentRow < int(_rows) - 1) + else if(_currentRow < _rows - 1) { _currentCol = 0; _currentRow++; @@ -428,7 +428,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) case KBDK_PAGEDOWN: if(StellaModTest::isShift(mod) && _scrollBar) handleMouseWheel(0, 0, +1); - else if (_currentRow < int(_rows) - 1) + else if (_currentRow < _rows - 1) { _currentRow = _rows - 1; dirty = true; @@ -444,7 +444,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_END: - if (_currentCol < int(_cols) - 1) + if (_currentCol < _cols - 1) { _currentCol = _cols - 1; dirty = true; diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 334a71270..cf751e81d 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -741,7 +741,7 @@ Common::Rect DebuggerDialog::getStatusBounds() const return { tia.x() + tia.w() + 1, 0, - tia.x() + tia.w() + 225 + (_w > 1030 ? int(0.35 * (_w - 1030)) : 0), + tia.x() + tia.w() + 225 + (_w > 1030 ? static_cast(0.35 * (_w - 1030)) : 0), tia.y() + tia.h() }; } diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 42890ffc7..469f4525a 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -69,15 +69,15 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, StringList labels; -#define CREATE_IO_REGS(desc, bits, bitsID, editable) \ - t = new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,\ - desc); \ - xpos += t->getWidth() + 5; \ - bits = new ToggleBitWidget(boss, nfont, xpos, ypos, 8, 1, 1, labels); \ - bits->setTarget(this); \ - bits->setID(bitsID); \ - if(editable) addFocusWidget(bits); else bits->setEditable(false); \ - bits->setList(off, on); +#define CREATE_IO_REGS(desc, bits, bitsID, editable) \ + t = new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight, \ + desc); \ + xpos += t->getWidth() + 5; \ + (bits) = new ToggleBitWidget(boss, nfont, xpos, ypos, 8, 1, 1, labels); \ + (bits)->setTarget(this); \ + (bits)->setID(bitsID); \ + if(editable) addFocusWidget(bits); else (bits)->setEditable(false); \ + (bits)->setList(off, on); // SWCHA bits in 'poke' mode labels.clear(); @@ -286,7 +286,7 @@ void RiotWidget::loadConfig() changed.clear(); \ for(uInt32 i = 0; i < state.s_bits.size(); ++i) \ changed.push_back(state.s_bits[i] != oldstate.s_bits[i]); \ - bits->setState(state.s_bits, changed); + (bits)->setState(state.s_bits, changed); IntArray alist; IntArray vlist; diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 8fe4dc132..d3260dcb0 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -63,7 +63,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, const int fontWidth = lfont.getMaxCharWidth(), numchars = w / fontWidth; - _labelWidth = std::max(14, int(0.45 * (numchars - 8 - 8 - 9 - 2))) * fontWidth - 1; + _labelWidth = std::max(14, static_cast(0.45 * (numchars - 8 - 8 - 9 - 2))) * fontWidth - 1; _bytesWidth = 9 * fontWidth; /////////////////////////////////////////////////////// diff --git a/src/debugger/gui/TiaWidget.cxx b/src/debugger/gui/TiaWidget.cxx index 5824f68c6..27e7a7fc8 100644 --- a/src/debugger/gui/TiaWidget.cxx +++ b/src/debugger/gui/TiaWidget.cxx @@ -115,7 +115,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont, t = new StaticTextWidget(boss, lfont, xpos, ypos + 2, 2*fontWidth, fontHeight, dbgLabels[row], TextAlign::Left); myFixedColors[row] = new ColorWidget(boss, nfont, xpos + 2 + t->getWidth() + 4, - ypos + 2, uInt32(1.5*lineHeight), lineHeight - 4); + ypos + 2, static_cast(1.5*lineHeight), lineHeight - 4); myFixedColors[row]->setTarget(this); } xpos += t->getWidth() + myFixedColors[0]->getWidth() + 24; @@ -126,7 +126,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont, t = new StaticTextWidget(boss, lfont, xpos, ypos + 2, 2*fontWidth, fontHeight, dbgLabels[row], TextAlign::Left); myFixedColors[row] = new ColorWidget(boss, nfont, xpos + 2 + t->getWidth() + 4, - ypos + 2, uInt32(1.5*lineHeight), lineHeight - 4); + ypos + 2, static_cast(1.5*lineHeight), lineHeight - 4); myFixedColors[row]->setTarget(this); } diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index eabb7603d..d9a5d808d 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -116,7 +116,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_DOWN: - if (_currentRow < int(_rows) - 1) + if (_currentRow < _rows - 1) { _currentRow++; dirty = true; @@ -132,7 +132,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_RIGHT: - if (_currentCol < int(_cols) - 1) + if (_currentCol < _cols - 1) { _currentCol++; dirty = true; @@ -148,7 +148,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_PAGEDOWN: - if (_currentRow < int(_rows) - 1) + if (_currentRow < _rows - 1) { _currentRow = _rows - 1; dirty = true; @@ -164,7 +164,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_END: - if (_currentCol < int(_cols) - 1) + if (_currentCol < _cols - 1) { _currentCol = _cols - 1; dirty = true; diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 2d2008d34..2aa3ee034 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -31,7 +31,7 @@ Cartridge::Cartridge(const Settings& settings, const string& md5) : mySettings{settings} { const auto to_uInt32 = [](const string& s, uInt32 pos) { - return uInt32(std::stoul(s.substr(pos, 8), nullptr, 16)); + return static_cast(std::stoul(s.substr(pos, 8), nullptr, 16)); }; const uInt32 seed = to_uInt32(md5, 0) ^ to_uInt32(md5, 8) ^ diff --git a/src/emucore/Cart0840.cxx b/src/emucore/Cart0840.cxx index f85c73157..da43fba28 100644 --- a/src/emucore/Cart0840.cxx +++ b/src/emucore/Cart0840.cxx @@ -73,7 +73,7 @@ bool Cartridge0840::checkSwitchBank(uInt16 address, uInt8) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 Cartridge0840::peek(uInt16 address) { - checkSwitchBank(address); + checkSwitchBank(address, 0); // Because of the way we've set up accessing above, we can only // get here when the addresses are from 0x800 - 0xFFF @@ -84,7 +84,7 @@ uInt8 Cartridge0840::peek(uInt16 address) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Cartridge0840::poke(uInt16 address, uInt8 value) { - checkSwitchBank(address); + checkSwitchBank(address, 0); // Because of the way accessing is set up, we will may get here by // doing a write to 0x800 - 0xFFF or cart; we ignore the cart write diff --git a/src/emucore/Cart0840.hxx b/src/emucore/Cart0840.hxx index b882679bf..05fd1e611 100644 --- a/src/emucore/Cart0840.hxx +++ b/src/emucore/Cart0840.hxx @@ -96,7 +96,7 @@ class Cartridge0840 : public CartridgeEnhanced bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x0840; } diff --git a/src/emucore/Cart0FA0.cxx b/src/emucore/Cart0FA0.cxx index 8c97768a0..fe4ef2555 100644 --- a/src/emucore/Cart0FA0.cxx +++ b/src/emucore/Cart0FA0.cxx @@ -81,7 +81,7 @@ uInt8 Cartridge0FA0::peek(uInt16 address) { address &= myBankMask; - checkSwitchBank(address); + checkSwitchBank(address, 0); // Because of the way accessing is set up, we will only get here // when doing a TIA read @@ -93,7 +93,7 @@ bool Cartridge0FA0::poke(uInt16 address, uInt8 value) { address &= myBankMask; - checkSwitchBank(address); + checkSwitchBank(address, 0); // Because of the way accessing is set up, we will may get here by // doing a write to TIA or cart; we ignore the cart write diff --git a/src/emucore/Cart0FA0.hxx b/src/emucore/Cart0FA0.hxx index 1bac20a4b..701efd5ea 100644 --- a/src/emucore/Cart0FA0.hxx +++ b/src/emucore/Cart0FA0.hxx @@ -105,7 +105,7 @@ class Cartridge0FA0 : public CartridgeEnhanced */ bool randomStartBank() const override { return false; } - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x06a0; } diff --git a/src/emucore/Cart2K.hxx b/src/emucore/Cart2K.hxx index 09d9a1f37..c936bcec2 100644 --- a/src/emucore/Cart2K.hxx +++ b/src/emucore/Cart2K.hxx @@ -74,7 +74,7 @@ class Cartridge2K : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override { return false; } + bool checkSwitchBank(uInt16, uInt8) override { return false; } private: // Following constructors and assignment operators not supported diff --git a/src/emucore/Cart4K.hxx b/src/emucore/Cart4K.hxx index ab31d314d..9264a596b 100644 --- a/src/emucore/Cart4K.hxx +++ b/src/emucore/Cart4K.hxx @@ -71,7 +71,7 @@ class Cartridge4K : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override { return false; } + bool checkSwitchBank(uInt16, uInt8) override { return false; } private: // Following constructors and assignment operators not supported diff --git a/src/emucore/CartBF.hxx b/src/emucore/CartBF.hxx index e362570a6..b6743e0d6 100644 --- a/src/emucore/CartBF.hxx +++ b/src/emucore/CartBF.hxx @@ -72,7 +72,7 @@ class CartridgeBF : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1F80; } diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index 2645630c4..a835162e0 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -58,7 +58,7 @@ namespace { throw runtime_error("unreachable"); } } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size, diff --git a/src/emucore/CartCV.hxx b/src/emucore/CartCV.hxx index 2feb4ddfd..25d660c1b 100644 --- a/src/emucore/CartCV.hxx +++ b/src/emucore/CartCV.hxx @@ -79,7 +79,7 @@ class CartridgeCV : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16, uInt8 = 0) override { return false; } + bool checkSwitchBank(uInt16, uInt8) override { return false; } protected: // Initial RAM data from the cart (doesn't always exist) diff --git a/src/emucore/CartDF.hxx b/src/emucore/CartDF.hxx index f184f179e..fd7e81673 100644 --- a/src/emucore/CartDF.hxx +++ b/src/emucore/CartDF.hxx @@ -72,7 +72,7 @@ class CartridgeDF : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1FC0; } diff --git a/src/emucore/CartE0.hxx b/src/emucore/CartE0.hxx index 6498469b4..fc94d12ef 100644 --- a/src/emucore/CartE0.hxx +++ b/src/emucore/CartE0.hxx @@ -85,7 +85,7 @@ class CartridgeE0 : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1FE0; } diff --git a/src/emucore/CartEF.hxx b/src/emucore/CartEF.hxx index 9ed15f546..623dff8e7 100644 --- a/src/emucore/CartEF.hxx +++ b/src/emucore/CartEF.hxx @@ -72,7 +72,7 @@ class CartridgeEF : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1FE0; } diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index f2d191adf..3ed2a3702 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -66,7 +66,8 @@ CartridgeEnhanced::CartridgeEnhanced(const ByteBuffer& image, size_t size, void CartridgeEnhanced::install(System& system) { // limit banked RAM size to the size of one RAM bank - const uInt16 ramSize = myRamBankCount > 0 ? 1 << (myBankShift - 1) : uInt16(myRamSize); + const uInt16 ramSize = myRamBankCount > 0 ? 1 << (myBankShift - 1) : + static_cast(myRamSize); // calculate bank switching and RAM sizes and masks myBankSize = 1 << myBankShift; // e.g. = 2 ^ 12 = 4K = 0x1000 @@ -74,7 +75,7 @@ void CartridgeEnhanced::install(System& system) // Either the bankswitching supports multiple segments // or the ROM is < 4K (-> 1 segment) myBankSegs = std::min(1 << (MAX_BANK_SHIFT - myBankShift), - int(mySize) / myBankSize); // e.g. = 1 + static_cast(mySize) / myBankSize); // e.g. = 1 // ROM has an offset if RAM inside a bank (e.g. for F8SC) myRomOffset = myRamBankCount > 0U ? 0U : static_cast(myRamSize * 2); myRamMask = ramSize - 1; // e.g. = 0xFFFF (doesn't matter for RAM size 0) @@ -160,7 +161,7 @@ uInt8 CartridgeEnhanced::peek(uInt16 address) // hotspots in TIA range are reacting to pokes only if (hotspot() >= 0x80) - checkSwitchBank(address & ADDR_MASK); + checkSwitchBank(address & ADDR_MASK, 0); if(isRamBank(address)) { @@ -202,7 +203,7 @@ bool CartridgeEnhanced::poke(uInt16 address, uInt8 value) if(isRamBank(address)) { - if(bool(address & (myBankSize >> 1)) == myRamWpHigh) + if(static_cast(address & (myBankSize >> 1)) == myRamWpHigh) { address &= myRamMask; // The RAM banks follow the ROM banks and are half the size of a ROM bank @@ -214,7 +215,7 @@ bool CartridgeEnhanced::poke(uInt16 address, uInt8 value) else { //address &= myBankMask; - if(bool(address & myRamSize) == myRamWpHigh) + if(static_cast(address & myRamSize) == myRamWpHigh) { pokeRAM(myRAM[address & myRamMask], pokeAddress, value); return true; @@ -272,10 +273,12 @@ bool CartridgeEnhanced::bank(uInt16 bank, uInt16 segment) // Setup RAM bank const uInt16 ramBank = (bank - romBankCount()) % myRamBankCount; // The RAM banks follow the ROM banks and are half the size of a ROM bank - const uInt32 bankOffset = uInt32(mySize) + (ramBank << (myBankShift - 1)); + const uInt32 bankOffset = static_cast(mySize) + + (ramBank << (myBankShift - 1)); // Remember what bank is in this segment - myCurrentSegOffset[segment] = uInt32(mySize) + (ramBank << myBankShift); + myCurrentSegOffset[segment] = static_cast(mySize) + + (ramBank << myBankShift); // 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) diff --git a/src/emucore/CartEnhanced.hxx b/src/emucore/CartEnhanced.hxx index 79a00d678..1558a967b 100644 --- a/src/emucore/CartEnhanced.hxx +++ b/src/emucore/CartEnhanced.hxx @@ -286,7 +286,7 @@ class CartridgeEnhanced : public Cartridge @return True if a bank switch happened. */ - virtual bool checkSwitchBank(uInt16 address, uInt8 value = 0) = 0; + virtual bool checkSwitchBank(uInt16 address, uInt8 value) = 0; private: /** diff --git a/src/emucore/CartF0.hxx b/src/emucore/CartF0.hxx index 44d4f12c4..53a8d24f7 100644 --- a/src/emucore/CartF0.hxx +++ b/src/emucore/CartF0.hxx @@ -69,7 +69,7 @@ class CartridgeF0 : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8 value) override; uInt16 hotspot() const override { return 0x1FF0; } diff --git a/src/emucore/CartF4.hxx b/src/emucore/CartF4.hxx index 14388ed48..22238315f 100644 --- a/src/emucore/CartF4.hxx +++ b/src/emucore/CartF4.hxx @@ -68,7 +68,7 @@ class CartridgeF4 : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1FF4; } diff --git a/src/emucore/CartF6.hxx b/src/emucore/CartF6.hxx index 03c025439..3a3520862 100644 --- a/src/emucore/CartF6.hxx +++ b/src/emucore/CartF6.hxx @@ -68,7 +68,7 @@ class CartridgeF6 : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8 value) override; uInt16 hotspot() const override { return 0x1FF6; } diff --git a/src/emucore/CartF8.hxx b/src/emucore/CartF8.hxx index 432dcbe15..b2aa7235e 100644 --- a/src/emucore/CartF8.hxx +++ b/src/emucore/CartF8.hxx @@ -68,7 +68,7 @@ class CartridgeF8 : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8 value) override; uInt16 hotspot() const override { return 0x1FF8; } diff --git a/src/emucore/CartFA.hxx b/src/emucore/CartFA.hxx index d64a98d56..903db002c 100644 --- a/src/emucore/CartFA.hxx +++ b/src/emucore/CartFA.hxx @@ -72,7 +72,7 @@ class CartridgeFA : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1FF8; } diff --git a/src/emucore/CartFA2.hxx b/src/emucore/CartFA2.hxx index c0e595d23..bfa373945 100644 --- a/src/emucore/CartFA2.hxx +++ b/src/emucore/CartFA2.hxx @@ -109,7 +109,7 @@ class CartridgeFA2 : public CartridgeFA bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8 value) override; uInt16 hotspot() const override { return 0x1FF5; } diff --git a/src/emucore/CartFC.cxx b/src/emucore/CartFC.cxx index e594a448f..5eac6a792 100644 --- a/src/emucore/CartFC.cxx +++ b/src/emucore/CartFC.cxx @@ -74,7 +74,7 @@ bool CartridgeFC::poke(uInt16 address, uInt8 value) break; default: - checkSwitchBank(address); + checkSwitchBank(address, 0); } return false; } diff --git a/src/emucore/CartFC.hxx b/src/emucore/CartFC.hxx index 94d13c6ae..d234eb4cf 100644 --- a/src/emucore/CartFC.hxx +++ b/src/emucore/CartFC.hxx @@ -90,7 +90,7 @@ class CartridgeFC : public CartridgeEnhanced bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x1FF8; } diff --git a/src/emucore/CartMDM.cxx b/src/emucore/CartMDM.cxx index 258d3b34d..c116b4829 100644 --- a/src/emucore/CartMDM.cxx +++ b/src/emucore/CartMDM.cxx @@ -67,7 +67,7 @@ uInt8 CartridgeMDM::peek(uInt16 address) // Because of the way we've set up accessing above, we can only // get here when the addresses are from 0x800 - 0xBFF - checkSwitchBank(address); + checkSwitchBank(address, 0); const int hotspot = ((address & 0x0F00) >> 8) - 8; return myHotSpotPageAccess[hotspot].device->peek(address); @@ -80,7 +80,7 @@ bool CartridgeMDM::poke(uInt16 address, uInt8 value) // about those below $1000 if(!(address & 0x1000)) { - checkSwitchBank(address); + checkSwitchBank(address, 0); const int hotspot = ((address & 0x0F00) >> 8) - 8; myHotSpotPageAccess[hotspot].device->poke(address, value); diff --git a/src/emucore/CartMDM.hxx b/src/emucore/CartMDM.hxx index d116d3e37..a8c39f833 100644 --- a/src/emucore/CartMDM.hxx +++ b/src/emucore/CartMDM.hxx @@ -137,7 +137,7 @@ class CartridgeMDM : public CartridgeEnhanced bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; private: // Previous Device's page access diff --git a/src/emucore/CartMVC.cxx b/src/emucore/CartMVC.cxx index fe9914f27..8c5d75d48 100755 --- a/src/emucore/CartMVC.cxx +++ b/src/emucore/CartMVC.cxx @@ -22,9 +22,9 @@ /** Implementation of MovieCart. - 1K of memory is presented on the bus, but is repeated to fill the 4K image space. - Contents are dynamically altered with streaming image and audio content as specific - 128-byte regions are entered. + 1K of memory is presented on the bus, but is repeated to fill the 4K image + space. Contents are dynamically altered with streaming image and audio content + as specific 128-byte regions are entered. Original implementation: github.com/lodefmode/moviecart @author Rob Bairos @@ -45,7 +45,7 @@ namespace { constexpr int BACK_SECONDS = 10; constexpr int TITLE_CYCLES = 1000000; -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -61,7 +61,7 @@ class StreamReader : public Serializable if(myFile) myFileSize = myFile.size(); - return bool(myFile); + return static_cast(myFile); } void blankPartialLines(bool index) { diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index 80e90cbcb..8a55eae4d 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -66,7 +66,7 @@ uInt8 CartridgeSB::peek(uInt16 address) { address &= (0x17FF + romBankCount()); - checkSwitchBank(address); + checkSwitchBank(address, 0); if(!(address & 0x1000)) { @@ -84,7 +84,7 @@ bool CartridgeSB::poke(uInt16 address, uInt8 value) { address &= (0x17FF + romBankCount()); - checkSwitchBank(address); + checkSwitchBank(address, 0); if(!(address & 0x1000)) { diff --git a/src/emucore/CartSB.hxx b/src/emucore/CartSB.hxx index 9d726e316..3e9de0795 100644 --- a/src/emucore/CartSB.hxx +++ b/src/emucore/CartSB.hxx @@ -98,7 +98,7 @@ class CartridgeSB : public CartridgeEnhanced bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x0800; } diff --git a/src/emucore/CartTVBoy.hxx b/src/emucore/CartTVBoy.hxx index 3764daa3e..2658b583b 100644 --- a/src/emucore/CartTVBoy.hxx +++ b/src/emucore/CartTVBoy.hxx @@ -97,7 +97,7 @@ class CartridgeTVBoy : public CartridgeEnhanced #endif private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8 value) override; uInt16 hotspot() const override { return 0x1800; } diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index ba2aca628..8d9523f36 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -85,7 +85,7 @@ uInt8 CartridgeUA::peek(uInt16 address) { address &= myBankMask; - checkSwitchBank(address); + checkSwitchBank(address, 0); // Because of the way accessing is set up, we will only get here // when doing a TIA read @@ -98,7 +98,7 @@ bool CartridgeUA::poke(uInt16 address, uInt8 value) { address &= myBankMask; - checkSwitchBank(address); + checkSwitchBank(address, 0); // Because of the way accessing is set up, we will may get here by // doing a write to TIA or cart; we ignore the cart write diff --git a/src/emucore/CartUA.hxx b/src/emucore/CartUA.hxx index fb0434bac..6b99fefc4 100644 --- a/src/emucore/CartUA.hxx +++ b/src/emucore/CartUA.hxx @@ -99,7 +99,7 @@ class CartridgeUA : public CartridgeEnhanced bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; uInt16 hotspot() const override { return 0x0220; } diff --git a/src/emucore/CartWD.hxx b/src/emucore/CartWD.hxx index 292944d22..2ae2be696 100644 --- a/src/emucore/CartWD.hxx +++ b/src/emucore/CartWD.hxx @@ -158,7 +158,7 @@ class CartridgeWD : public CartridgeEnhanced */ bool randomStartBank() const override { return false; } - bool checkSwitchBank(uInt16, uInt8 = 0) override { return false; } + bool checkSwitchBank(uInt16, uInt8) override { return false; } uInt16 hotspot() const override { return 0x0030; } diff --git a/src/emucore/CartX07.cxx b/src/emucore/CartX07.cxx index 686a089f0..bec63de9b 100644 --- a/src/emucore/CartX07.cxx +++ b/src/emucore/CartX07.cxx @@ -74,7 +74,7 @@ uInt8 CartridgeX07::peek(uInt16 address) else if(!(lowAddress & 0x200)) value = mySystem->tia().peek(address); - checkSwitchBank(address); + checkSwitchBank(address, 0); return value; } @@ -90,7 +90,7 @@ bool CartridgeX07::poke(uInt16 address, uInt8 value) else if(!(lowAddress & 0x200)) mySystem->tia().poke(address, value); - checkSwitchBank(address); + checkSwitchBank(address, 0); return false; } diff --git a/src/emucore/CartX07.hxx b/src/emucore/CartX07.hxx index 8fc7304f7..b40583f3e 100644 --- a/src/emucore/CartX07.hxx +++ b/src/emucore/CartX07.hxx @@ -106,7 +106,7 @@ class CartridgeX07 : public CartridgeEnhanced bool poke(uInt16 address, uInt8 value) override; private: - bool checkSwitchBank(uInt16 address, uInt8 value = 0) override; + bool checkSwitchBank(uInt16 address, uInt8) override; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 2a1081a2d..8273adfff 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -77,9 +77,10 @@ #include "Console.hxx" namespace { - // Emulation speed is a positive float that multiplies the framerate. However, the UI controls - // adjust speed in terms of a speedup factor (1/10, 1/9 .. 1/2, 1, 2, 3, .., 10). The following - // mapping and formatting functions implement this conversion. The speedup factor is represented + // Emulation speed is a positive float that multiplies the framerate. However, + // the UI controls adjust speed in terms of a speedup factor (1/10, + // 1/9 .. 1/2, 1, 2, 3, .., 10). The following mapping and formatting + // functions implement this conversion. The speedup factor is represented // by an integer value between -900 and 900 (0 means no speedup). constexpr int MAX_SPEED = 900; @@ -112,8 +113,7 @@ namespace { return ss.str(); } -} - +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Console::Console(OSystem& osystem, unique_ptr& cart, diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index 7ffc779be..da1864111 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -120,7 +120,8 @@ string Controller::getName(const Type type) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Controller::getPropName(const Type type) { - static constexpr std::array PROP_NAMES = + static constexpr std::array(Controller::Type::LastType)> PROP_NAMES = { "AUTO", "AMIGAMOUSE", "ATARIMOUSE", "ATARIVOX", "BOOSTERGRIP", "COMPUMATE", diff --git a/src/emucore/EmulationTiming.cxx b/src/emucore/EmulationTiming.cxx index 57928bae4..1d98183c8 100644 --- a/src/emucore/EmulationTiming.cxx +++ b/src/emucore/EmulationTiming.cxx @@ -26,7 +26,7 @@ namespace { { return n / d + ((n % d == 0) ? 0 : 1); } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EmulationTiming::EmulationTiming(FrameLayout frameLayout, ConsoleTiming consoleTiming) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index f676c9a92..aa4213ea2 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -2033,14 +2033,14 @@ json EventHandler::convertLegacyComboMapping(string list) buf >> event; // skip all NoType events if(event != Event::NoType) - events.push_back(Event::Type(event)); + events.push_back(static_cast(event)); } // only store if there are any NoType events if(!events.empty()) { json combo; - combo["combo"] = Event::Type(Event::Combo1 + i); + combo["combo"] = static_cast(Event::Combo1 + i); combo["events"] = events; convertedMapping.push_back(combo); } @@ -2171,14 +2171,14 @@ void EventHandler::saveComboMapping() // skip all NoType events if(event != Event::NoType) - events.push_back(Event::Type(event)); + events.push_back(static_cast(event)); } // only store if there are any NoType events if(!events.empty()) { json combo; - combo["combo"] = Event::Type(Event::Combo1 + i); + combo["combo"] = static_cast(Event::Combo1 + i); combo["events"] = events; mapping.push_back(combo); } diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index d451ff7f2..596bb4578 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -356,7 +356,7 @@ int FBSurface::drawString(const GUI::Font& font, const string& s, drawString(font, leftStr, x, y, w, color, align, deltax, false, shadowColor, linkStart, linkLen, underline); if(linkStart != string::npos) - linkStart = std::max(0, int(linkStart - leftStr.length())); + linkStart = std::max(0, static_cast(linkStart - leftStr.length())); h -= font.getFontHeight(); y += font.getFontHeight(); diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index f3f47cedd..11cfedec2 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -616,7 +616,8 @@ 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 + // Show message for 2 seconds + myMsg.counter = std::min(static_cast(myOSystem.frameRate()) * 2, 120U); if(myMsg.counter == 0) myMsg.counter = 120; diff --git a/src/emucore/MD5.cxx b/src/emucore/MD5.cxx index 81bac4fa8..9ea48666c 100644 --- a/src/emucore/MD5.cxx +++ b/src/emucore/MD5.cxx @@ -89,10 +89,10 @@ static uInt8 PADDING[64] = { }; // F, G, H and I are basic MD5 functions. -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define F(x, y, z) (((x) & (y)) | ((~(x)) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~(z)))) #define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) +#define I(x, y, z) ((y) ^ ((x) | (~(z)))) // ROTATE_LEFT rotates x left n bits. #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) @@ -336,4 +336,4 @@ string hash(const uInt8* buffer, size_t length) return result; } -} // Namespace MD5 +} // namespace MD5 diff --git a/src/emucore/MD5.hxx b/src/emucore/MD5.hxx index 8b99d243e..748da758b 100644 --- a/src/emucore/MD5.hxx +++ b/src/emucore/MD5.hxx @@ -49,6 +49,6 @@ namespace MD5 { */ string hash(const string& buffer); -} // Namespace MD5 +} // namespace MD5 #endif diff --git a/src/emucore/MT24LC256.cxx b/src/emucore/MT24LC256.cxx index 9993a007b..da37be523 100644 --- a/src/emucore/MT24LC256.cxx +++ b/src/emucore/MT24LC256.cxx @@ -262,7 +262,7 @@ void MT24LC256::jpee_clock_fall() { if (!jpee_pptr) { - jpee_packet[0] = uInt8(jpee_nb); + jpee_packet[0] = static_cast(jpee_nb); if (jpee_smallmode && ((jpee_nb & 0xF0) == 0xA0)) { jpee_packet[1] = (jpee_nb >> 1) & 7; @@ -307,7 +307,7 @@ void MT24LC256::jpee_clock_fall() { if (!jpee_pptr) { - jpee_packet[0] = uInt8(jpee_nb); + jpee_packet[0] = static_cast(jpee_nb); if (jpee_smallmode) jpee_pptr=2; else @@ -316,7 +316,7 @@ void MT24LC256::jpee_clock_fall() else if (jpee_pptr < 70) { JPEE_LOG1("I2C_SENT(%02X)",jpee_nb & 0xFF) - jpee_packet[jpee_pptr++] = uInt8(jpee_nb); + jpee_packet[jpee_pptr++] = static_cast(jpee_nb); jpee_address = (jpee_packet[1] << 8) | jpee_packet[2]; if (jpee_pptr > 2) jpee_ad_known = 1; diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 3d7393ec2..faf367a5e 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -176,7 +176,7 @@ bool OSystem::initialize(const Settings::Options& options) createSound(); // Create random number generator - myRandom = make_unique(uInt32(TimerManager::getTicks())); + myRandom = make_unique(static_cast(TimerManager::getTicks())); #ifdef CHEATCODE_SUPPORT myCheatManager = make_unique(*this); diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index 07313faa0..9a76cb2e0 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -39,7 +39,7 @@ namespace { constexpr uInt16 WRITE_SEND_BUFFER = 0x1FF1; constexpr uInt16 RECEIVE_BUFFER = 0x1FF2; constexpr uInt16 RECEIVE_BUFFER_SIZE = 0x1FF3; -} +} // namespace #endif using std::chrono::milliseconds; diff --git a/src/emucore/ProfilingRunner.cxx b/src/emucore/ProfilingRunner.cxx index 82835ed2b..58af4eb84 100644 --- a/src/emucore/ProfilingRunner.cxx +++ b/src/emucore/ProfilingRunner.cxx @@ -51,7 +51,7 @@ namespace { from++; } } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ProfilingRunner::ProfilingRunner(int argc, char* argv[]) @@ -187,7 +187,8 @@ bool ProfilingRunner::runOne(const ProfilingRun& run) if (tia.newFramePending()) tia.renderToFrameBuffer(); - const uInt32 percentNow = uInt32(std::min((100 * cycles) / cyclesTarget, static_cast(100))); + const uInt32 percentNow = static_cast(std::min((100 * cycles) / + cyclesTarget, static_cast(100))); updateProgress(percent, percentNow); percent = percentNow; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 670aa626d..f351b377c 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -194,7 +194,7 @@ Settings::Settings() // Misc options - setPermanent("loglevel", int(Logger::Level::INFO)); + setPermanent("loglevel", static_cast(Logger::Level::INFO)); setPermanent("logtoconsole", "0"); setPermanent("avoxport", ""); setPermanent("fastscbios", "true"); @@ -473,7 +473,7 @@ void Settings::validate() i = getInt("loglevel"); if(i < static_cast(Logger::Level::MIN) || i > static_cast(Logger::Level::MAX)) - setValue("loglevel", int(Logger::Level::INFO)); + setValue("loglevel", static_cast(Logger::Level::INFO)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index db6909ce7..fa22228b9 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -42,7 +42,7 @@ namespace { ScalingInterpolation::sharp; #endif } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TIASurface::TIASurface(OSystem& system) @@ -257,7 +257,7 @@ void TIASurface::changeScanlineIntensity(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TIASurface::ScanlineMask TIASurface::scanlineMaskType(int direction) { - const string Masks[int(ScanlineMask::NumMasks)] = { + const string Masks[static_cast(ScanlineMask::NumMasks)] = { SETTING_STANDARD, SETTING_THIN, SETTING_PIXELS, @@ -276,7 +276,7 @@ TIASurface::ScanlineMask TIASurface::scanlineMaskType(int direction) i = BSPF::clampw(i + direction, 0, static_cast(ScanlineMask::NumMasks) - 1); myOSystem.settings().setValue("tv.scanmask", Masks[i]); } - return ScanlineMask(i); + return static_cast(i); } ++i; } @@ -286,7 +286,7 @@ TIASurface::ScanlineMask TIASurface::scanlineMaskType(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIASurface::cycleScanlineMask(int direction) { - const string Names[int(ScanlineMask::NumMasks)] = { + const string Names[static_cast(ScanlineMask::NumMasks)] = { "Standard", "Thin lines", "Pixelated", @@ -310,7 +310,9 @@ void TIASurface::enablePhosphor(bool enable, int blend) if(myPhosphorHandler.initialize(enable, blend)) { myPBlend = blend; - myFilter = static_cast(enable ? uInt8(myFilter) | 0x01 : uInt8(myFilter) & 0x10); + myFilter = static_cast( + enable ? static_cast(myFilter) | 0x01 + : static_cast(myFilter) & 0x10); myRGBFramebuffer.fill(0); } } @@ -334,7 +336,7 @@ void TIASurface::createScanlineSurface() : vRepeats(c_vRepeats), data(c_data) {} }; - static std::array Patterns = {{ + static std::array(ScanlineMask::NumMasks)> Patterns = {{ Pattern(1, // standard { { 0x00000000 }, @@ -438,7 +440,9 @@ void TIASurface::createScanlineSurface() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIASurface::enableNTSC(bool enable) { - myFilter = static_cast(enable ? uInt8(myFilter) | 0x10 : uInt8(myFilter) & 0x01); + myFilter = static_cast( + enable ? static_cast(myFilter) | 0x10 + : static_cast(myFilter) & 0x01); const uInt32 surfaceWidth = enable ? AtariNTSC::outWidth(TIAConstants::frameBufferWidth) : TIAConstants::frameBufferWidth; diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index e6c48ca4d..ef0c1cccf 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -45,10 +45,10 @@ using Common::Base; #endif #ifdef __BIG_ENDIAN__ - #define CONV_DATA(d) (((d & 0xFFFF)>>8) | ((d & 0xffff)<<8)) & 0xffff - #define CONV_RAMROM(d) ((d>>8) | (d<<8)) & 0xffff + #define CONV_DATA(d) ((((d) & 0xFFFF)>>8) | (((d) & 0xffff)<<8)) & 0xffff + #define CONV_RAMROM(d) (((d)>>8) | ((d)<<8)) & 0xffff #else - #define CONV_DATA(d) (d & 0xFFFF) + #define CONV_DATA(d) ((d) & 0xFFFF) #define CONV_RAMROM(d) (d) #endif @@ -679,7 +679,7 @@ uInt32 Thumbulator::read32(uInt32 addr) fatalError("read32", addr, "abort - out of range"); #endif data = read16(addr+0); - data |= (uInt32(read16(addr+2))) << 16; + data |= read16(addr+2) << 16; DO_DBUG(statusMsg << "read32(" << Base::HEX8 << addr << ")=" << Base::HEX8 << data << endl); return data; @@ -689,7 +689,7 @@ uInt32 Thumbulator::read32(uInt32 addr) fatalError("read32", addr, "abort - out of range"); #endif data = read16(addr+0); - data |= (static_cast(read16(addr+2))) << 16; + data |= read16(addr+2) << 16; DO_DBUG(statusMsg << "read32(" << Base::HEX8 << addr << ")=" << Base::HEX8 << data << endl); return data; diff --git a/src/emucore/tia/AnalogReadout.cxx b/src/emucore/tia/AnalogReadout.cxx index 64c8d3be7..1e144ae62 100644 --- a/src/emucore/tia/AnalogReadout.cxx +++ b/src/emucore/tia/AnalogReadout.cxx @@ -127,7 +127,7 @@ bool AnalogReadout::save(Serializer& out) const myConnection.save(out); out.putLong(myTimestamp); - out.putInt(int(myConsoleTiming)); + out.putInt(static_cast(myConsoleTiming)); out.putDouble(myClockFreq); out.putBool(myIsDumped); diff --git a/src/emucore/tia/Audio.cxx b/src/emucore/tia/Audio.cxx index bb97c5eb6..493469bd5 100644 --- a/src/emucore/tia/Audio.cxx +++ b/src/emucore/tia/Audio.cxx @@ -31,7 +31,7 @@ namespace { (R_MAX + R * static_cast(vMax)) / (R_MAX + R * static_cast(v))) ); } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Audio::Audio() diff --git a/src/emucore/tia/Playfield.cxx b/src/emucore/tia/Playfield.cxx index 41ef06819..0dd25e60d 100644 --- a/src/emucore/tia/Playfield.cxx +++ b/src/emucore/tia/Playfield.cxx @@ -290,7 +290,7 @@ bool Playfield::save(Serializer& out) const out.putByte(myDebugColor); out.putBool(myDebugEnabled); - out.putByte(uInt8(myColorMode)); + out.putByte(static_cast(myColorMode)); out.putBool(myScoreGlitch); out.putInt(myPattern); diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 198516949..63a9b63f9 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -275,7 +275,7 @@ bool TIA::save(Serializer& out) const if(!myInput0.save(out)) return false; if(!myInput1.save(out)) return false; - out.putInt(int(myHstate)); + out.putInt(static_cast(myHstate)); out.putInt(myHctr); out.putInt(myHctrDelta); @@ -291,7 +291,7 @@ bool TIA::save(Serializer& out) const out.putInt(myLinesSinceChange); - out.putInt(int(myPriority)); + out.putInt(static_cast(myPriority)); out.putByte(mySubClock); out.putLong(myLastCycle); @@ -1251,7 +1251,7 @@ bool TIA::driveUnusedPinsRandom(uInt8 mode) // If mode is 0 or 1, use it as a boolean (off or on) // Otherwise, return the state if (mode == 0 || mode == 1) - myTIAPinsDriven = bool(mode); + myTIAPinsDriven = static_cast(mode); return myTIAPinsDriven; } diff --git a/src/emucore/tia/frame-manager/AbstractFrameManager.cxx b/src/emucore/tia/frame-manager/AbstractFrameManager.cxx index d69476dd8..473e197fa 100644 --- a/src/emucore/tia/frame-manager/AbstractFrameManager.cxx +++ b/src/emucore/tia/frame-manager/AbstractFrameManager.cxx @@ -120,7 +120,7 @@ bool AbstractFrameManager::save(Serializer& out) const out.putInt(myCurrentFrameFinalLines); out.putInt(myPreviousFrameFinalLines); out.putInt(myTotalFrames); - out.putInt(uInt32(myLayout)); + out.putInt(static_cast(myLayout)); return onSave(out); } diff --git a/src/emucore/tia/frame-manager/FrameManager.cxx b/src/emucore/tia/frame-manager/FrameManager.cxx index 7ef7b9cd3..702cfb2be 100644 --- a/src/emucore/tia/frame-manager/FrameManager.cxx +++ b/src/emucore/tia/frame-manager/FrameManager.cxx @@ -175,7 +175,7 @@ bool FrameManager::onSave(Serializer& out) const { if (!myJitterEmulation.save(out)) return false; - out.putInt(uInt32(myState)); + out.putInt(static_cast(myState)); out.putInt(myLineInState); out.putInt(myVsyncLines); out.putInt(myY); diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 391071fda..b6375d19c 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -437,8 +437,8 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font) pwidth, lineHeight, items, desc, lwidth, dbg_cmds[idx]); wid.push_back(myDbgColour[idx]); x += myDbgColour[idx]->getWidth() + fontWidth * 1.25; - myDbgColourSwatch[idx] = new ColorWidget(myTab, font, x, ypos - 1, - uInt32(2 * lineHeight), lineHeight); + myDbgColourSwatch[idx] = new ColorWidget( + myTab, font, x, ypos - 1, static_cast(2 * lineHeight), lineHeight); ypos += lineHeight + VGAP * 1; }; diff --git a/src/gui/EmulationDialog.cxx b/src/gui/EmulationDialog.cxx index ec25db59a..3ea0511f1 100644 --- a/src/gui/EmulationDialog.cxx +++ b/src/gui/EmulationDialog.cxx @@ -24,9 +24,10 @@ #include "EmulationDialog.hxx" namespace { - // Emulation speed is a positive float that multiplies the framerate. However, the UI controls - // adjust speed in terms of a speedup factor (1/10, 1/9 .. 1/2, 1, 2, 3, .., 10). The following - // mapping and formatting functions implement this conversion. The speedup factor is represented + // Emulation speed is a positive float that multiplies the framerate. However, + // the UI controls adjust speed in terms of a speedup factor (1/10, + // 1/9 .. 1/2, 1, 2, 3, .., 10). The following mapping and formatting + // functions implement this conversion. The speedup factor is represented // by an integer value between -900 and 900 (0 means no speedup). constexpr int MAX_SPEED = 900; @@ -59,7 +60,7 @@ namespace { return ss.str(); } -} +} // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index d2f7e6e25..b6377dbb6 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -330,7 +330,8 @@ bool EventMappingWidget::handleKeyUp(StellaKey key, StellaMod mod) if(myMod & KBDM_GUI) myMod |= KBDM_GUI; } - if (instance().eventHandler().addKeyMapping(event, myEventMode, StellaKey(myLastKey), StellaMod(myMod))) + if (instance().eventHandler().addKeyMapping(event, myEventMode, + static_cast(myLastKey), static_cast(myMod))) stopRemapping(); } return true; diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 78f9a59e3..ea99e29d2 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -680,16 +680,17 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const 0b11111111111'11111111110, 0b11111111111'11111111110 }; - static const Icon* small_icons[int(IconType::numTypes)] = { + const int idx = static_cast(IconType::numTypes); + static const Icon* small_icons[idx] = { &unknown_small, &rom_small, &directory_small, &zip_small, &up_small }; - static const Icon* large_icons[int(IconType::numTypes)] = { + static const Icon* large_icons[idx] = { &unknown_large, &rom_large, &directory_large, &zip_large, &up_large, }; const bool smallIcon = iconWidth() < 24; - const int iconType = int(_iconTypeList[i]); + const int iconType = static_cast(_iconTypeList[i]); - assert(iconType < int(IconType::numTypes)); + assert(iconType < idx); return smallIcon ? small_icons[iconType] : large_icons[iconType]; } diff --git a/src/gui/Font.cxx b/src/gui/Font.cxx index b2a47f364..53b2d5a50 100644 --- a/src/gui/Font.cxx +++ b/src/gui/Font.cxx @@ -59,4 +59,4 @@ int Font::getStringWidth(const string& str) const [&](int x, char c) { return x + getCharWidth(c); }); } -} // namespace GUI +} // namespace GUI diff --git a/src/gui/Font.hxx b/src/gui/Font.hxx index a23e5b45d..e451e0ee6 100644 --- a/src/gui/Font.hxx +++ b/src/gui/Font.hxx @@ -79,6 +79,6 @@ class Font Font& operator=(Font&&) = delete; }; -} // namespace GUI +} // namespace GUI #endif diff --git a/src/gui/Icon.hxx b/src/gui/Icon.hxx index 090598ba5..89b4e6192 100644 --- a/src/gui/Icon.hxx +++ b/src/gui/Icon.hxx @@ -57,6 +57,6 @@ class Icon Icon& operator=(Icon&&) = delete; }; -} // namespace GUI +} // namespace GUI #endif diff --git a/src/gui/Icons.hxx b/src/gui/Icons.hxx index bab1f21a6..c0c9193e8 100644 --- a/src/gui/Icons.hxx +++ b/src/gui/Icons.hxx @@ -526,6 +526,6 @@ static const Icon icon_help_large( 0b0000000011100000000 }); -} // namespace GUI +} // namespace GUI #endif diff --git a/src/gui/Launcher.cxx b/src/gui/Launcher.cxx index f05b7258f..bac8a7c00 100644 --- a/src/gui/Launcher.cxx +++ b/src/gui/Launcher.cxx @@ -39,8 +39,8 @@ Launcher::Launcher(OSystem& osystem) // Do not include overscan when launcher saving size myOSystem.settings().setValue("launcherres", mySize); // Now make overscan effective - mySize.w = std::min(mySize.w, uInt32(d.w * overscan)); - mySize.h = std::min(mySize.h, uInt32(d.h * overscan)); + mySize.w = std::min(mySize.w, static_cast(d.w * overscan)); + mySize.h = std::min(mySize.h, static_cast(d.h * overscan)); myBaseDialog = new LauncherDialog(myOSystem, *this, 0, 0, mySize.w, mySize.h); } diff --git a/src/gui/LauncherFileListWidget.cxx b/src/gui/LauncherFileListWidget.cxx index 1b0848cf6..618da666f 100644 --- a/src/gui/LauncherFileListWidget.cxx +++ b/src/gui/LauncherFileListWidget.cxx @@ -508,21 +508,25 @@ const FileListWidget::Icon* LauncherFileListWidget::getIcon(int i) const 0b11111111111'11111111110, 0b11111111111'11111111110 }; - static const Icon* small_icons[int(IconType::numLauncherTypes)] = { - &favrom_small, &favdir_small, &favzip_small, &user_small, &recent_small, &popular_small + static constexpr auto NLT = static_cast(IconType::numLauncherTypes); + static const Icon* small_icons[NLT] = { + &favrom_small, &favdir_small, &favzip_small, + &user_small, &recent_small, &popular_small }; - static const Icon* large_icons[int(IconType::numLauncherTypes)] = { - &favrom_large, &favdir_large, &favzip_large, &user_large, &recent_large, &popular_large + static const Icon* large_icons[NLT] = { + &favrom_large, &favdir_large, &favzip_large, + &user_large, &recent_large, &popular_large }; - if(int(_iconTypeList[i]) < static_cast(IconType::numTypes)) + if(static_cast(_iconTypeList[i]) < static_cast(IconType::numTypes)) return FileListWidget::getIcon(i); const bool smallIcon = iconWidth() < 24; - const int iconType = int(_iconTypeList[i]) - static_cast(IconType::numTypes); + const int iconType = + static_cast(_iconTypeList[i]) - static_cast(IconType::numTypes); - assert(iconType < int(IconType::numLauncherTypes)); + assert(iconType < NLT); return smallIcon ? small_icons[iconType] : large_icons[iconType]; } diff --git a/src/gui/MessageBox.cxx b/src/gui/MessageBox.cxx index e249c47ec..c03262d35 100644 --- a/src/gui/MessageBox.cxx +++ b/src/gui/MessageBox.cxx @@ -125,4 +125,4 @@ void MessageBox::handleCommand(CommandSender* sender, int cmd, int data, int id) Dialog::handleCommand(sender, cmd, data, id); } -} // namespace GUI +} // namespace GUI diff --git a/src/gui/MessageBox.hxx b/src/gui/MessageBox.hxx index 331856ab4..f1e15b8eb 100644 --- a/src/gui/MessageBox.hxx +++ b/src/gui/MessageBox.hxx @@ -76,6 +76,6 @@ class MessageBox : public Dialog, public CommandSender MessageBox& operator=(MessageBox&&) = delete; }; -} // namespace GUI +} // namespace GUI #endif diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index 30ec2bfc5..b568a9af1 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -244,11 +244,12 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font, _w = _buttonSize; else _w = font.getStringWidth(label) + _buttonSize + font.getMaxCharWidth() * 0.75; - _h = font.getFontHeight() < int(_buttonSize) ? _buttonSize : font.getFontHeight(); + _h = font.getFontHeight() < static_cast(_buttonSize) + ? _buttonSize : font.getFontHeight(); // Depending on font size, either the font or box will need to be // centered vertically - if(_h > int(_buttonSize)) // center box + if(_h > static_cast(_buttonSize)) // center box _boxY = (_h - _buttonSize) / 2; else // center text _textY = (_buttonSize - _font.getFontHeight()) / 2; diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 9562b3fd7..166696ece 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -266,8 +266,10 @@ bool RomImageWidget::loadImage(const string& fileName) { // Scale surface to available image area const Common::Rect& src = mySurface->srcRect(); - const float scale = std::min(float(_w) / src.w(), float(myImageHeight) / src.h()) * - instance().frameBuffer().hidpiScaleFactor(); + const float scale = std::min( + static_cast(_w) / src.w(), + static_cast(myImageHeight) / src.h()) * + instance().frameBuffer().hidpiScaleFactor(); mySurface->setDstSize(static_cast(src.w() * scale), static_cast(src.h() * scale)); } diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index 30508965e..dbc30fddc 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -90,7 +90,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) // Skip the very last value; we take care of it outside the end of the loop for(uInt32 i = 0; i < steps.size() - 1; ++i) - _stepValue.push_back(int(steps[i] * scale)); + _stepValue.push_back(static_cast(steps[i] * scale)); // Due to integer <-> double conversion, the last value is sometimes // slightly less than the maximum value; we assign it manually to fix this @@ -103,7 +103,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TimeLineWidget::handleMouseMoved(int x, int y) { - if(isEnabled() && _isDragging && x >= int(_labelWidth)) + if(isEnabled() && _isDragging && x >= static_cast(_labelWidth)) setValue(posToValue(x - _labelWidth)); } diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 80479afe0..0690aa889 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -159,7 +159,7 @@ void ToolTip::show(const string& tip) string leftStr, rightStr; surface()->splitString(*myFont, inStr, maxWidth, leftStr, rightStr); - width = std::max(width, uInt32(myFont->getStringWidth(leftStr))); + width = std::max(width, static_cast(myFont->getStringWidth(leftStr))); inStr = rightStr; } width += myTextXOfs * 2; @@ -174,7 +174,7 @@ void ToolTip::show(const string& tip) // Limit position to app size and adjust accordingly const Int32 xAbs = myTipPos.x + dialogRect.x() / myScale; const uInt32 yAbs = myTipPos.y + dialogRect.y() / myScale; - Int32 x = std::min(xAbs, Int32(imageRect.w() / myScale - width)); + Int32 x = std::min(xAbs, static_cast(imageRect.w() / myScale - width)); const uInt32 y = (yAbs + height + H_CURSOR > imageRect.h() / myScale) ? yAbs - height - V_GAP : yAbs + H_CURSOR / myScale + V_GAP; diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index d1a9a0cb1..94af92af7 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -982,7 +982,7 @@ void VideoAudioDialog::handleTVModeChange(NTSCFilter::Preset preset) void VideoAudioDialog::loadTVAdjustables(NTSCFilter::Preset preset) { NTSCFilter::Adjustable adj; - NTSCFilter::getAdjustables(adj, NTSCFilter::Preset(preset)); + NTSCFilter::getAdjustables(adj, preset); myTVSharp->setValue(adj.sharpness); myTVRes->setValue(adj.resolution); myTVArtifacts->setValue(adj.artifacts); diff --git a/src/os/unix/FSNodePOSIX.cxx b/src/os/unix/FSNodePOSIX.cxx index bee29cc89..ca7ad53b4 100644 --- a/src/os/unix/FSNodePOSIX.cxx +++ b/src/os/unix/FSNodePOSIX.cxx @@ -39,7 +39,7 @@ FSNodePOSIX::FSNodePOSIX(const string& path, bool verify) // Expand '~' to the HOME environment variable if(_path[0] == '~') { - const char* home = std::getenv("HOME"); + const char* home = std::getenv("HOME"); // NOLINT (not thread safe) if (home != nullptr) _path.replace(0, 1, home); } @@ -80,7 +80,7 @@ void FSNodePOSIX::setFlags() string FSNodePOSIX::getShortPath() const { // If the path starts with the home directory, replace it with '~' - const char* env_home = std::getenv("HOME"); + const char* env_home = std::getenv("HOME"); // NOLINT (not thread safe) const string& home = env_home != nullptr ? env_home : EmptyString; if(home != EmptyString && BSPF::startsWithIgnoreCase(_path, home)) @@ -112,7 +112,7 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const // Loop over dir entries using readdir struct dirent* dp = nullptr; - while ((dp = readdir(dirp)) != nullptr) + while ((dp = readdir(dirp)) != nullptr) // NOLINT (not thread safe) { // Ignore all hidden files if (dp->d_name[0] == '.') @@ -236,5 +236,5 @@ AbstractFSNodePtr FSNodePOSIX::getParent() const const char* start = _path.c_str(); const char* end = lastPathComponent(_path); - return make_unique(string(start, size_t(end - start))); + return make_unique(string(start, static_cast(end - start))); } diff --git a/src/os/unix/OSystemUNIX.cxx b/src/os/unix/OSystemUNIX.cxx index 5192e3531..28de8144b 100644 --- a/src/os/unix/OSystemUNIX.cxx +++ b/src/os/unix/OSystemUNIX.cxx @@ -26,7 +26,7 @@ void OSystemUNIX::getBaseDirectories(string& basedir, string& homedir, bool useappdir, const string& usedir) { // Use XDG_CONFIG_HOME if defined, otherwise use the default - const char* cfg_home = std::getenv("XDG_CONFIG_HOME"); + const char* cfg_home = std::getenv("XDG_CONFIG_HOME"); // NOLINT const string& configDir = cfg_home != nullptr ? cfg_home : "~/.config"; basedir = configDir + "/stella"; homedir = "~/"; From 31efb087427c5e44071aa64fcbf61711afaf143c Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 21 Aug 2022 19:42:37 -0230 Subject: [PATCH 11/11] Fix minor warning with g++ and tinyexif. --- src/lib/tinyexif/tinyexif.cxx | 2 +- src/lib/tinyexif/tinyexif_lib.hxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/tinyexif/tinyexif.cxx b/src/lib/tinyexif/tinyexif.cxx index 86a94dd26..e93f6063a 100644 --- a/src/lib/tinyexif/tinyexif.cxx +++ b/src/lib/tinyexif/tinyexif.cxx @@ -29,7 +29,7 @@ #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wcast-function-type" #pragma GCC diagnostic ignored "-Wshift-negative-value" - #pragma GCC diagnostic ignored "-Wregister" + #pragma GCC diagnostic ignored "-Wunused-function" #include "source/TinyEXIF.cpp" // NOLINT #pragma GCC diagnostic pop #elif defined(BSPF_WINDOWS) diff --git a/src/lib/tinyexif/tinyexif_lib.hxx b/src/lib/tinyexif/tinyexif_lib.hxx index 79dc60ede..f7a19eb8e 100644 --- a/src/lib/tinyexif/tinyexif_lib.hxx +++ b/src/lib/tinyexif/tinyexif_lib.hxx @@ -32,7 +32,7 @@ #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wcast-function-type" #pragma GCC diagnostic ignored "-Wshift-negative-value" - #pragma GCC diagnostic ignored "-Wregister" + #pragma GCC diagnostic ignored "-Wunused-function" #include "source/TinyEXIF.h" #pragma GCC diagnostic pop #elif defined(BSPF_WINDOWS)