diff --git a/src/cheat/CheatCodeDialog.cxx b/src/cheat/CheatCodeDialog.cxx index 4434bfb5d..b9fda176b 100644 --- a/src/cheat/CheatCodeDialog.cxx +++ b/src/cheat/CheatCodeDialog.cxx @@ -44,7 +44,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent, VBORDER = Dialog::vBorder(), HBORDER = Dialog::hBorder(); WidgetArray wid; - ButtonWidget* b; + ButtonWidget* b = nullptr; // Set real dimensions _w = 45 * fontWidth + HBORDER * 2; diff --git a/src/common/Base.cxx b/src/common/Base.cxx index f7d382f7c..2c4430f2a 100644 --- a/src/common/Base.cxx +++ b/src/common/Base.cxx @@ -47,7 +47,7 @@ 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", Int16(value)); + std::snprintf(vToS_buf, 5, "%3d", static_cast(value)); else std::snprintf(vToS_buf, 6, "%5d", value); break; diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index db160a01d..30b1b7a31 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -99,8 +99,8 @@ void EventHandlerSDL2::pollEvent() case SDL_KEYUP: case SDL_KEYDOWN: { - handleKeyEvent(StellaKey(myEvent.key.keysym.scancode), - StellaMod(myEvent.key.keysym.mod), + handleKeyEvent(static_cast(myEvent.key.keysym.scancode), + static_cast(myEvent.key.keysym.mod), myEvent.key.type == SDL_KEYDOWN, myEvent.key.repeat); break; diff --git a/src/common/EventHandlerSDL2.hxx b/src/common/EventHandlerSDL2.hxx index e9ac999d4..f75443bac 100644 --- a/src/common/EventHandlerSDL2.hxx +++ b/src/common/EventHandlerSDL2.hxx @@ -68,6 +68,14 @@ class EventHandlerSDL2 : public EventHandler private: SDL_Joystick* myStick{nullptr}; + + private: + // Following constructors and assignment operators not supported + JoystickSDL2() = delete; + JoystickSDL2(const JoystickSDL2&) = delete; + JoystickSDL2(JoystickSDL2&&) = delete; + JoystickSDL2& operator=(const JoystickSDL2&) = delete; + JoystickSDL2& operator=(JoystickSDL2&&) = delete; }; private: diff --git a/src/common/StaggeredLogger.hxx b/src/common/StaggeredLogger.hxx index 7d32001a1..2a42c91af 100644 --- a/src/common/StaggeredLogger.hxx +++ b/src/common/StaggeredLogger.hxx @@ -38,7 +38,6 @@ class StaggeredLogger public: StaggeredLogger(const string& message, Logger::Level level); - ~StaggeredLogger(); void log(); @@ -83,6 +82,13 @@ class StaggeredLogger // returns. This id is unique per timer and is used to return from the callback // early in case the time is stale. uInt32 myTimerCallbackId{0}; + + private: + // Following constructors and assignment operators not supported + StaggeredLogger(const StaggeredLogger&) = delete; + StaggeredLogger(StaggeredLogger&&) = delete; + StaggeredLogger& operator=(const StaggeredLogger&) = delete; + StaggeredLogger& operator=(StaggeredLogger&&) = delete; }; #endif // STAGGERED_LOGGER diff --git a/src/common/TimerManager.hxx b/src/common/TimerManager.hxx index d2ecd4dcc..3f1d2fb56 100644 --- a/src/common/TimerManager.hxx +++ b/src/common/TimerManager.hxx @@ -146,15 +146,17 @@ class TimerManager struct Timer { - explicit Timer(TimerId tid = 0) : id(tid) { } + explicit Timer(TimerId tid = 0) : id{tid} { } Timer(Timer&& r) noexcept; - Timer& operator=(Timer&& r) noexcept; Timer(TimerId id, Timestamp next, Duration period, const TFunction& func) noexcept; // Never called + Timer() = default; + ~Timer() = default; Timer(Timer const& r) = delete; Timer& operator=(Timer const& r) = delete; + Timer& operator=(Timer&& r) = delete; TimerId id{0}; Timestamp next; @@ -204,6 +206,13 @@ class TimerManager // Valid IDs are guaranteed not to be this value static TimerId constexpr no_timer = TimerId(0); + + private: + // Following constructors and assignment operators not supported + TimerManager(const TimerManager&) = delete; + TimerManager(TimerManager&&) = delete; + TimerManager& operator=(const TimerManager&) = delete; + TimerManager& operator=(TimerManager&&) = delete; }; #endif // TIMERTHREAD_H diff --git a/src/common/ZipHandler.cxx b/src/common/ZipHandler.cxx index 01118f988..3ac21625d 100644 --- a/src/common/ZipHandler.cxx +++ b/src/common/ZipHandler.cxx @@ -113,7 +113,7 @@ uInt64 ZipHandler::decompress(ByteBuffer& image) { if(myZip && myZip->myHeader.uncompressedLength > 0) { - uInt64 length = myZip->myHeader.uncompressedLength; + const uInt64 length = myZip->myHeader.uncompressedLength; image = make_unique(length); if(image == nullptr) throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY)); @@ -247,7 +247,7 @@ void ZipHandler::ZipFile::initialize() // Read the central directory uInt64 read_length = 0; - bool success = readStream(myCd, myEcd.cdStartDiskOffset, myEcd.cdSize, read_length); + const bool success = readStream(myCd, myEcd.cdStartDiskOffset, myEcd.cdSize, read_length); if(!success) throw runtime_error(errorMessage(ZipError::FILE_ERROR)); else if(read_length != myEcd.cdSize) @@ -275,7 +275,7 @@ void ZipHandler::ZipFile::readEcd() // We may need multiple tries while(buflen < 65536) { - uInt64 read_length; + uInt64 read_length = 0; // Max out the buf length at the size of the file if(buflen > myLength) @@ -287,15 +287,15 @@ void ZipHandler::ZipFile::readEcd() throw runtime_error(errorMessage(ZipError::OUT_OF_MEMORY)); // Read in one buffers' worth of data - bool success = readStream(buffer, myLength - buflen, buflen, read_length); + const bool success = readStream(buffer, myLength - buflen, buflen, read_length); if(!success || read_length != buflen) throw runtime_error(errorMessage(ZipError::FILE_ERROR)); // Find the ECD signature - Int32 offset; - for(offset = Int32(buflen - EcdReader::minimumLength()); offset >= 0; --offset) + Int32 offset = 0; + for(offset = static_cast(buflen - EcdReader::minimumLength()); offset >= 0; --offset) { - EcdReader reader(buffer.get() + offset); + const EcdReader reader(buffer.get() + offset); if(reader.signatureCorrect() && ((reader.totalLength() + offset) <= buflen)) break; } @@ -324,7 +324,7 @@ void ZipHandler::ZipFile::readEcd() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool ZipHandler::ZipFile::readStream(ByteBuffer& out, uInt64 offset, +bool ZipHandler::ZipFile::readStream(const ByteBuffer& out, uInt64 offset, uInt64 length, uInt64& actual) { try @@ -368,7 +368,7 @@ const ZipHandler::ZipHeader* ZipHandler::ZipFile::nextFile() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ZipHandler::ZipFile::decompress(ByteBuffer& out, uInt64 length) +void ZipHandler::ZipFile::decompress(const ByteBuffer& out, uInt64 length) { // If we don't have enough buffer, error if(length < myHeader.uncompressedLength) @@ -381,7 +381,7 @@ void ZipHandler::ZipFile::decompress(ByteBuffer& out, uInt64 length) try { // Get the compressed data offset - uInt64 offset = getCompressedDataOffset(); + const uInt64 offset = getCompressedDataOffset(); // Handle compression types switch(myHeader.compression) @@ -420,14 +420,14 @@ uInt64 ZipHandler::ZipFile::getCompressedDataOffset() // Read the fixed-sized part of the local file header uInt64 read_length = 0; - bool success = readStream(myBuffer, myHeader.localHeaderOffset, 0x1e, read_length); + const bool success = readStream(myBuffer, myHeader.localHeaderOffset, 0x1e, read_length); if(!success) throw runtime_error(errorMessage(ZipError::FILE_ERROR)); else if(read_length != LocalFileHeaderReader::minimumLength()) throw runtime_error(errorMessage(ZipError::FILE_TRUNCATED)); // Compute the final offset - LocalFileHeaderReader reader(&myBuffer[0]); + const LocalFileHeaderReader reader(&myBuffer[0]); if(!reader.signatureCorrect()) throw runtime_error(errorMessage(ZipError::BAD_SIGNATURE)); @@ -436,11 +436,11 @@ uInt64 ZipHandler::ZipFile::getCompressedDataOffset() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ZipHandler::ZipFile::decompressDataType0( - uInt64 offset, ByteBuffer& out, uInt64 length) + uInt64 offset, const ByteBuffer& out, uInt64 length) { // The data is uncompressed; just read it uInt64 read_length = 0; - bool success = readStream(out, offset, myHeader.compressedLength, read_length); + const bool success = readStream(out, offset, myHeader.compressedLength, read_length); if(!success) throw runtime_error(errorMessage(ZipError::FILE_ERROR)); else if(read_length != myHeader.compressedLength) @@ -449,18 +449,18 @@ void ZipHandler::ZipFile::decompressDataType0( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ZipHandler::ZipFile::decompressDataType8( - uInt64 offset, ByteBuffer& out, uInt64 length) + uInt64 offset, const ByteBuffer& out, uInt64 length) { uInt64 input_remaining = myHeader.compressedLength; // Reset the stream - z_stream stream; + z_stream stream{}; stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.opaque = Z_NULL; stream.avail_in = 0; stream.next_out = reinterpret_cast(out.get()); - stream.avail_out = uInt32(length); // TODO - use zip64 + stream.avail_out = static_cast(length); // TODO - use zip64 // Initialize the decompressor int zerr = inflateInit2(&stream, -MAX_WBITS); @@ -472,8 +472,8 @@ void ZipHandler::ZipFile::decompressDataType8( { // Read in the next chunk of data uInt64 read_length = 0; - bool success = readStream(myBuffer, offset, - std::min(input_remaining, uInt64(sizeof(myBuffer.get()))), read_length); + const bool success = readStream(myBuffer, offset, + std::min(input_remaining, static_cast(sizeof(myBuffer.get()))), read_length); if(!success) { inflateEnd(&stream); @@ -490,7 +490,7 @@ void ZipHandler::ZipFile::decompressDataType8( // Fill out the input data stream.next_in = myBuffer.get(); - stream.avail_in = uInt32(read_length); // TODO - use zip64 + stream.avail_in = static_cast(read_length); // TODO - use zip64 input_remaining -= read_length; // Add a dummy byte at end of compressed data diff --git a/src/common/ZipHandler.hxx b/src/common/ZipHandler.hxx index 8d248c1fc..21bd8f8f7 100644 --- a/src/common/ZipHandler.hxx +++ b/src/common/ZipHandler.hxx @@ -126,22 +126,22 @@ class ZipHandler void readEcd(); /** Read data from stream */ - bool readStream(ByteBuffer& out, uInt64 offset, uInt64 length, uInt64& actual); + bool readStream(const ByteBuffer& out, uInt64 offset, uInt64 length, uInt64& actual); /** Return the next entry in the ZIP file */ const ZipHeader* nextFile(); /** Decompress the most recently found file in the ZIP into target buffer */ - void decompress(ByteBuffer& out, uInt64 length); + void decompress(const ByteBuffer& out, uInt64 length); /** Return the offset of the compressed data */ uInt64 getCompressedDataOffset(); /** Decompress type 0 data (which is uncompressed) */ - void decompressDataType0(uInt64 offset, ByteBuffer& out, uInt64 length); + void decompressDataType0(uInt64 offset, const ByteBuffer& out, uInt64 length); /** Decompress type 8 data (which is deflated) */ - void decompressDataType8(uInt64 offset, ByteBuffer& out, uInt64 length); + void decompressDataType8(uInt64 offset, const ByteBuffer& out, uInt64 length); }; using ZipFilePtr = unique_ptr; diff --git a/src/common/repository/CompositeKeyValueRepository.hxx b/src/common/repository/CompositeKeyValueRepository.hxx index d2845239e..46cf5ae3e 100644 --- a/src/common/repository/CompositeKeyValueRepository.hxx +++ b/src/common/repository/CompositeKeyValueRepository.hxx @@ -28,6 +28,7 @@ class CompositeKeyValueRepositoryAtomic; class CompositeKeyValueRepository { public: + CompositeKeyValueRepository() = default; virtual ~CompositeKeyValueRepository() = default; @@ -38,6 +39,13 @@ class CompositeKeyValueRepository virtual void remove(const string& key) = 0; virtual CompositeKeyValueRepositoryAtomic* atomic() { return nullptr; } + + private: + // Following constructors and assignment operators not supported + CompositeKeyValueRepository(const CompositeKeyValueRepository&) = delete; + CompositeKeyValueRepository(CompositeKeyValueRepository&&) = delete; + CompositeKeyValueRepository& operator=(const CompositeKeyValueRepository&) = delete; + CompositeKeyValueRepository& operator=(CompositeKeyValueRepository&&) = delete; }; class CompositeKeyValueRepositoryAtomic : public CompositeKeyValueRepository diff --git a/src/common/repository/KeyValueRepositoryConfigfile.cxx b/src/common/repository/KeyValueRepositoryConfigfile.cxx index 422d3398f..c0562f32b 100644 --- a/src/common/repository/KeyValueRepositoryConfigfile.cxx +++ b/src/common/repository/KeyValueRepositoryConfigfile.cxx @@ -21,7 +21,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - KeyValueRepositoryConfigfile::KeyValueRepositoryConfigfile(const FilesystemNode& file) : KeyValueRepositoryFile(file) -{} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::map KeyValueRepositoryConfigfile::load(istream& in) @@ -29,7 +30,7 @@ std::map KeyValueRepositoryConfigfile::load(istream& in) std::map values; string line, key, value; - string::size_type equalPos, garbage; + string::size_type equalPos = 0, garbage = 0; while(getline(in, line)) { diff --git a/src/common/repository/KeyValueRepositoryJsonFile.cxx b/src/common/repository/KeyValueRepositoryJsonFile.cxx index 8cf28ffc8..956f964f1 100644 --- a/src/common/repository/KeyValueRepositoryJsonFile.cxx +++ b/src/common/repository/KeyValueRepositoryJsonFile.cxx @@ -32,7 +32,8 @@ namespace { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - KeyValueRepositoryJsonFile::KeyValueRepositoryJsonFile(const FilesystemNode& node) : KeyValueRepositoryFile(node) -{} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::map KeyValueRepositoryJsonFile::load(istream& in) diff --git a/src/common/repository/KeyValueRepositoryPropertyFile.cxx b/src/common/repository/KeyValueRepositoryPropertyFile.cxx index 1900b88db..cbbfa507b 100644 --- a/src/common/repository/KeyValueRepositoryPropertyFile.cxx +++ b/src/common/repository/KeyValueRepositoryPropertyFile.cxx @@ -72,7 +72,8 @@ namespace { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - KeyValueRepositoryPropertyFile::KeyValueRepositoryPropertyFile(const FilesystemNode& node) : KeyValueRepositoryFile(node) -{} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::map KeyValueRepositoryPropertyFile::load(istream& in) diff --git a/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx index 9899a8047..59a007e3b 100644 --- a/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.cxx @@ -80,7 +80,6 @@ bool AbstractKeyValueRepositorySqlite::get(const string& key, Variant& value) } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool AbstractKeyValueRepositorySqlite::save(const std::map& values) { diff --git a/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.hxx b/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.hxx index 5d3ef5a9f..a4a981d17 100644 --- a/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.hxx +++ b/src/common/repository/sqlite/AbstractKeyValueRepositorySqlite.hxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + #ifndef ABSTRACT_KEY_VALUE_REPOSITORY_SQLITE_HXX #define ABSTRACT_KEY_VALUE_REPOSITORY_SQLITE_HXX diff --git a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx index 6f0f1fe21..87eeada71 100644 --- a/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx +++ b/src/common/repository/sqlite/CompositeKeyValueRepositorySqlite.cxx @@ -50,7 +50,7 @@ bool CompositeKeyValueRepositorySqlite::has(const string& key) if (!myStmtCountSet->step()) throw SqliteError("count failed"); - Int32 rowCount = myStmtCountSet->columnInt(0); + const Int32 rowCount = myStmtCountSet->columnInt(0); myStmtCountSet->reset(); diff --git a/src/common/repository/sqlite/SqliteStatement.cxx b/src/common/repository/sqlite/SqliteStatement.cxx index 0a7d65f48..fb473571a 100644 --- a/src/common/repository/sqlite/SqliteStatement.cxx +++ b/src/common/repository/sqlite/SqliteStatement.cxx @@ -62,7 +62,7 @@ SqliteStatement& SqliteStatement::bind(int index, Int32 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool SqliteStatement::step() { - int result = sqlite3_step(myStmt); + const int result = sqlite3_step(myStmt); if (result == SQLITE_ERROR) throw SqliteError(myHandle); diff --git a/src/common/repository/sqlite/StellaDb.cxx b/src/common/repository/sqlite/StellaDb.cxx index dc19887de..ae7b7414c 100644 --- a/src/common/repository/sqlite/StellaDb.cxx +++ b/src/common/repository/sqlite/StellaDb.cxx @@ -200,7 +200,7 @@ void StellaDb::importOldPropset(const FilesystemNode& node) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StellaDb::migrate() { - Int32 version = myDb->getUserVersion(); + const Int32 version = myDb->getUserVersion(); switch (version) { case 1: return; diff --git a/src/debugger/BreakpointMap.hxx b/src/debugger/BreakpointMap.hxx index b99f232fa..ad2d3b073 100644 --- a/src/debugger/BreakpointMap.hxx +++ b/src/debugger/BreakpointMap.hxx @@ -42,7 +42,7 @@ class BreakpointMap uInt16 addr{0}; uInt8 bank{0}; - explicit Breakpoint(uInt16 c_addr, uInt8 c_bank) : addr(c_addr), bank(c_bank) { } + explicit constexpr Breakpoint(uInt16 c_addr, uInt8 c_bank) : addr{c_addr}, bank{c_bank} { } bool operator==(const Breakpoint& other) const { diff --git a/src/debugger/DebuggerExpressions.hxx b/src/debugger/DebuggerExpressions.hxx index f7d517f93..ff326d397 100644 --- a/src/debugger/DebuggerExpressions.hxx +++ b/src/debugger/DebuggerExpressions.hxx @@ -117,7 +117,7 @@ class DivExpression : public Expression public: DivExpression(Expression* left, Expression* right) : Expression(left, right) { } Int32 evaluate() const override - { int denom = myRHS->evaluate(); + { const int denom = myRHS->evaluate(); return denom == 0 ? 0 : myLHS->evaluate() / denom; } }; @@ -250,7 +250,7 @@ class ModExpression : public Expression public: ModExpression(Expression* left, Expression* right) : Expression(left, right) { } Int32 evaluate() const override - { int rhs = myRHS->evaluate(); + { const int rhs = myRHS->evaluate(); return rhs == 0 ? 0 : myLHS->evaluate() % rhs; } }; diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index 48ef9d333..a4b0780e9 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -61,7 +61,7 @@ CartridgeE7Widget::CartridgeE7Widget( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeE7Widget::initialize(GuiObject* boss, - CartridgeE7& cart, ostringstream& info) + const CartridgeE7& cart, const ostringstream& info) { const uInt32 size = cart.romBankCount() * cart.BANK_SIZE; diff --git a/src/debugger/gui/CartE7Widget.hxx b/src/debugger/gui/CartE7Widget.hxx index 69b5c588a..b826508de 100644 --- a/src/debugger/gui/CartE7Widget.hxx +++ b/src/debugger/gui/CartE7Widget.hxx @@ -52,7 +52,7 @@ class CartridgeE7Widget : public CartDebugWidget }; protected: - void initialize(GuiObject* boss, CartridgeE7& cart, ostringstream& info); + void initialize(GuiObject* boss, const CartridgeE7& cart, const ostringstream& info); const char* getSpotLower(int idx); const char* getSpotUpper(int idx); diff --git a/src/debugger/gui/DrivingWidget.cxx b/src/debugger/gui/DrivingWidget.cxx index da870bdea..cef328448 100644 --- a/src/debugger/gui/DrivingWidget.cxx +++ b/src/debugger/gui/DrivingWidget.cxx @@ -47,8 +47,8 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font, const int lwidth = font.getStringWidth("Right (Driving)"), bWidth = font.getStringWidth("Gray code +") + _fontWidth * 1.25; - StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, - lineHeight, label, TextAlign::Left); + const StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, + lineHeight, label, TextAlign::Left); ypos = t->getBottom() + _lineHeight * 1.334; myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight, @@ -125,10 +125,7 @@ void DrivingWidget::handleCommand( // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DrivingWidget::setValue(int idx) { - int grayCode = ourGrayTable[idx]; + const int grayCode = ourGrayTable[idx]; // FIXME * 8 = a nasty hack, because the DataGridWidget does not support 2 digit binary output myGrayValue->setList(0, (grayCode & 0b01) + (grayCode & 0b10) * 8); } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const std::array DrivingWidget::ourGrayTable = { 0x03, 0x01, 0x00, 0x02 }; diff --git a/src/debugger/gui/DrivingWidget.hxx b/src/debugger/gui/DrivingWidget.hxx index 72bf506b7..93e0bc3fc 100644 --- a/src/debugger/gui/DrivingWidget.hxx +++ b/src/debugger/gui/DrivingWidget.hxx @@ -44,7 +44,9 @@ class DrivingWidget : public ControllerWidget int myGrayIndex{0}; - static const std::array ourGrayTable; + static constexpr std::array ourGrayTable = { + { 0x03, 0x01, 0x00, 0x02 } + }; private: void loadConfig() override; diff --git a/src/debugger/gui/GenesisWidget.cxx b/src/debugger/gui/GenesisWidget.cxx index f032d82ca..d86a51cdc 100644 --- a/src/debugger/gui/GenesisWidget.cxx +++ b/src/debugger/gui/GenesisWidget.cxx @@ -26,10 +26,9 @@ GenesisWidget::GenesisWidget(GuiObject* boss, const GUI::Font& font, const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Genesis)"); - StaticTextWidget* t; - t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, - fontHeight, label, TextAlign::Left); + const StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, + fontHeight, label, TextAlign::Left); xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 20; myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", CheckboxWidget::kCheckActionCmd); @@ -114,6 +113,3 @@ void GenesisWidget::handleCommand( } } } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -constexpr std::array GenesisWidget::ourPinNo; diff --git a/src/debugger/gui/JoystickWidget.cxx b/src/debugger/gui/JoystickWidget.cxx index 8659b7e06..0f528a855 100644 --- a/src/debugger/gui/JoystickWidget.cxx +++ b/src/debugger/gui/JoystickWidget.cxx @@ -30,10 +30,8 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font, { const string& label = getHeader(); const int lwidth = font.getStringWidth("Right (Joystick)"); - StaticTextWidget* t; - - t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, - _lineHeight, label, TextAlign::Left); + const StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, + _lineHeight, label, TextAlign::Left); xpos += t->getWidth() / 2 - 5; ypos = t->getBottom() + fontHeight; } myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", @@ -91,6 +89,3 @@ void JoystickWidget::handleCommand( if(cmd == CheckboxWidget::kCheckActionCmd) setPin(ourPinNo[id], !myPins[id]->getState()); } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -constexpr std::array JoystickWidget::ourPinNo; diff --git a/src/debugger/gui/KeyboardWidget.cxx b/src/debugger/gui/KeyboardWidget.cxx index f3166316d..d77af4b7f 100644 --- a/src/debugger/gui/KeyboardWidget.cxx +++ b/src/debugger/gui/KeyboardWidget.cxx @@ -28,10 +28,8 @@ KeyboardWidget::KeyboardWidget(GuiObject* boss, const GUI::Font& font, const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Keyboard)"); - StaticTextWidget* t; - - t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, - fontHeight, label, TextAlign::Left); + const StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, + fontHeight, label, TextAlign::Left); xpos += 30; ypos += t->getHeight() + 20; @@ -67,7 +65,3 @@ void KeyboardWidget::handleCommand( if(cmd == CheckboxWidget::kCheckActionCmd) instance().eventHandler().handleEvent(myEvent[id], myBox[id]->getState()); } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -constexpr std::array KeyboardWidget::ourLeftEvents; -constexpr std::array KeyboardWidget::ourRightEvents; diff --git a/src/debugger/gui/PointingDeviceWidget.cxx b/src/debugger/gui/PointingDeviceWidget.cxx index ca06d777f..5b2c7097e 100644 --- a/src/debugger/gui/PointingDeviceWidget.cxx +++ b/src/debugger/gui/PointingDeviceWidget.cxx @@ -29,9 +29,8 @@ PointingDeviceWidget::PointingDeviceWidget(GuiObject* boss, const GUI::Font& fon xMid = xLeft + 30, xRight = xLeft + 60, xValue = xLeft + 87; - StaticTextWidget* t; - - t = new StaticTextWidget(boss, font, x, y + 2, getHeader()); + const StaticTextWidget* t = new StaticTextWidget(boss, font, + x, y + 2, getHeader()); ypos += t->getHeight() + 8; // add gray code and up widgets diff --git a/src/debugger/gui/TrakBallWidget.cxx b/src/debugger/gui/TrakBallWidget.cxx index 9a6a2d906..e7a2e9c64 100644 --- a/src/debugger/gui/TrakBallWidget.cxx +++ b/src/debugger/gui/TrakBallWidget.cxx @@ -17,6 +17,7 @@ #include "TrakBallWidget.hxx" +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TrakBallWidget::TrakBallWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : PointingDeviceWidget(boss, font, x, y, controller) diff --git a/src/emucore/Bankswitch.hxx b/src/emucore/Bankswitch.hxx index 9e37a9bf9..4c459fd10 100644 --- a/src/emucore/Bankswitch.hxx +++ b/src/emucore/Bankswitch.hxx @@ -55,8 +55,8 @@ class Bankswitch // Info about the various bankswitch schemes, useful for displaying // in GUI dropdown boxes, etc struct Description { - const char* const name; - const char* const desc; + const char* const name{nullptr}; + const char* const desc{nullptr}; }; static const std::array(Type::NumSchemes)> BSList; diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index 88e78520a..468ebf802 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -44,7 +44,7 @@ class CartridgeAR : public Cartridge friend class CartridgeARWidget; public: - static constexpr uInt32 BANK_SIZE = uInt32(2_KB); + static constexpr uInt32 BANK_SIZE = static_cast(2_KB); static constexpr uInt32 RAM_SIZE = 3 * BANK_SIZE; static constexpr uInt32 LOAD_SIZE = 8448; diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index 1f83b0c22..bf82763e3 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -27,17 +27,18 @@ #include "exception/FatalEmulationError.hxx" // Location of data within the RAM copy of the BUS Driver. -#define DSxPTR 0x06D8 -#define DSxINC 0x0720 -#define DSMAPS 0x0760 -#define WAVEFORM 0x07F4 -#define DSRAM 0x0800 +static constexpr int + DSxPTR = 0x06D8, + DSxINC = 0x0720, + DSMAPS = 0x0760, + WAVEFORM = 0x07F4, + DSRAM = 0x0800, -#define COMMSTREAM 0x10 -#define JUMPSTREAM 0x11 + COMMSTREAM = 0x10, + JUMPSTREAM = 0x11; -#define BUS_STUFF_ON ((myMode & 0x0F) == 0) -#define DIGITAL_AUDIO_ON ((myMode & 0xF0) == 0) +static constexpr bool BUS_STUFF_ON(uInt8 mode) { return (mode & 0x0F) == 0; } +static constexpr bool DIGITAL_AUDIO_ON(uInt8 mode) { return (mode & 0xF0) == 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size, @@ -221,7 +222,7 @@ uInt8 CartridgeBUS::peek(uInt16 address) } // test for JMP FASTJUMP where FASTJUMP = $0000 - if (BUS_STUFF_ON + if (BUS_STUFF_ON(myMode) && peekvalue == 0x4C && myProgramImage[myBankOffset + address+1] == 0 && myProgramImage[myBankOffset + address+2] == 0) @@ -234,7 +235,7 @@ uInt8 CartridgeBUS::peek(uInt16 address) myJMPoperandAddress = 0; // save the STY's zero page address - if (BUS_STUFF_ON && mySTYZeroPageAddress == address) + if (BUS_STUFF_ON(myMode) && mySTYZeroPageAddress == address) myBusOverdriveAddress = peekvalue; mySTYZeroPageAddress = 0; @@ -245,7 +246,7 @@ uInt8 CartridgeBUS::peek(uInt16 address) // Update the music data fetchers (counter & flag) updateMusicModeDataFetchers(); - if DIGITAL_AUDIO_ON + if (DIGITAL_AUDIO_ON(myMode)) { // retrieve packed sample (max size is 2K, or 4K of unpacked data) const uInt32 sampleaddress = getSample() + (myMusicCounters[0] >> 21); @@ -327,7 +328,7 @@ uInt8 CartridgeBUS::peek(uInt16 address) } // this might not work right for STY $84 - if (BUS_STUFF_ON && peekvalue == 0x84) + if (BUS_STUFF_ON(myMode) && peekvalue == 0x84) mySTYZeroPageAddress = address + 1; return peekvalue; diff --git a/src/emucore/CartCreator.cxx b/src/emucore/CartCreator.cxx index fbf601da3..6184d1e65 100644 --- a/src/emucore/CartCreator.cxx +++ b/src/emucore/CartCreator.cxx @@ -236,7 +236,7 @@ CartCreator::createFromMultiCart(const ByteBuffer& image, size_t& size, std::copy_n(image.get()+i*size, size, slice.get()); // We need a new md5 and name - md5 = MD5::hash(slice, uInt32(size)); // FIXME + md5 = MD5::hash(slice, size); ostringstream buf; buf << " [G" << (i+1) << "]"; id = buf.str(); diff --git a/src/emucore/CartWD.cxx b/src/emucore/CartWD.cxx index ea603711b..513bcf25f 100644 --- a/src/emucore/CartWD.cxx +++ b/src/emucore/CartWD.cxx @@ -162,17 +162,3 @@ bool CartridgeWD::load(Serializer& in) return true; } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const std::array CartridgeWD::ourBankOrg = {{ - // 0 1 2 3 4 5 6 7 - { 0, 0, 1, 3 }, // Bank 0, 8 2 1 - 1 - - - - - { 0, 1, 2, 3 }, // Bank 1, 9 1 1 1 1 - - - - - { 4, 5, 6, 7 }, // Bank 2, 10 - - - - 1 1 1 1 - { 7, 4, 2, 3 }, // Bank 3, 11 - - 1 1 1 - - 1 - { 0, 0, 6, 7 }, // Bank 4, 12 2 - - - - - 1 1 - { 0, 1, 7, 6 }, // Bank 5, 13 1 1 - - - - 1 1 - { 2, 3, 4, 5 }, // Bank 6, 14 - - 1 1 1 1 - - - { 6, 0, 5, 1 } // Bank 7, 15 1 1 - - - 1 1 - - // count 7 4 3 4 3 3 4 4 -}}; diff --git a/src/emucore/CartWD.hxx b/src/emucore/CartWD.hxx index 249c0b4c1..292944d22 100644 --- a/src/emucore/CartWD.hxx +++ b/src/emucore/CartWD.hxx @@ -176,7 +176,18 @@ class CartridgeWD : public CartridgeEnhanced struct BankOrg { uInt8 zero{0}, one{0}, two{0}, three{0}; }; - static const std::array ourBankOrg; + static constexpr std::array ourBankOrg = {{ + // 0 1 2 3 4 5 6 7 + { 0, 0, 1, 3 }, // Bank 0, 8 2 1 - 1 - - - - + { 0, 1, 2, 3 }, // Bank 1, 9 1 1 1 1 - - - - + { 4, 5, 6, 7 }, // Bank 2, 10 - - - - 1 1 1 1 + { 7, 4, 2, 3 }, // Bank 3, 11 - - 1 1 1 - - 1 + { 0, 0, 6, 7 }, // Bank 4, 12 2 - - - - - 1 1 + { 0, 1, 7, 6 }, // Bank 5, 13 1 1 - - - - 1 1 + { 2, 3, 4, 5 }, // Bank 6, 14 - - 1 1 1 1 - - + { 6, 0, 5, 1 } // Bank 7, 15 1 1 - - - 1 1 - + // count 7 4 3 4 3 3 4 4 + }}; private: // log(ROM bank segment size) / log(2) diff --git a/src/emucore/DefProps.hxx b/src/emucore/DefProps.hxx index 7f90666c1..b56e681c8 100644 --- a/src/emucore/DefProps.hxx +++ b/src/emucore/DefProps.hxx @@ -27,7 +27,7 @@ static constexpr uInt32 DEF_PROPS_SIZE = 3533; -static const BSPF::array2D DefProps = {{ +static constexpr BSPF::array2D DefProps = {{ { "000509d1ed2b8d30a9d94be1b3b5febb", "Greg Zumwalt", "", "Jungle Jane (2003) (Greg Zumwalt) (Hack)", "Hack of Pitfall!", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "{\"score_addresses\":[\"0xd5\",\"0xd6\",\"0xd7\"],\"score_digits\":6,\"variations_count\":1}", "" }, { "0060a89b4c956b9c703a59b181cb3018", "CommaVid, Irwin Gaines - Ariola", "CM-008 - 712 008-720", "Cakewalk (1983) (CommaVid) (PAL)", "AKA Alarm in der Backstube", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, { "007d18dedc1f0565f09c42aa61a6f585", "CCE", "C-843", "Worm War I (1983) (CCE)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }, diff --git a/src/emucore/Driving.cxx b/src/emucore/Driving.cxx index c3d7be67a..2d9e805d9 100644 --- a/src/emucore/Driving.cxx +++ b/src/emucore/Driving.cxx @@ -25,9 +25,9 @@ Driving::Driving(Jack jack, const Event& event, const System& system, bool altma { if(!altmap) { - myCCWEvent = Event::LeftDrivingCCW; - myCWEvent = Event::LeftDrivingCW; - myFireEvent = Event::LeftDrivingFire; + myCCWEvent = Event::LeftDrivingCCW; + myCWEvent = Event::LeftDrivingCW; + myFireEvent = Event::LeftDrivingFire; myAnalogEvent = Event::LeftDrivingAnalog; } else @@ -43,9 +43,9 @@ Driving::Driving(Jack jack, const Event& event, const System& system, bool altma { if(!altmap) { - myCCWEvent = Event::RightDrivingCCW; - myCWEvent = Event::RightDrivingCW; - myFireEvent = Event::RightDrivingFire; + myCCWEvent = Event::RightDrivingCCW; + myCWEvent = Event::RightDrivingCW; + myFireEvent = Event::RightDrivingFire; myAnalogEvent = Event::RightDrivingAnalog; } else diff --git a/src/emucore/Genesis.cxx b/src/emucore/Genesis.cxx index c7d23cd89..5368ebfca 100644 --- a/src/emucore/Genesis.cxx +++ b/src/emucore/Genesis.cxx @@ -22,9 +22,9 @@ Genesis::Genesis(Jack jack, const Event& event, const System& system) : Joystick(jack, event, system, Controller::Type::Genesis) { if(myJack == Jack::Left) - myButtonCEvent = Event::LeftJoystickFire5; + myButtonCEvent = Event::LeftJoystickFire5; else - myButtonCEvent = Event::RightJoystickFire5; + myButtonCEvent = Event::RightJoystickFire5; setPin(AnalogPin::Five, AnalogReadout::connectToVcc()); setPin(AnalogPin::Nine, AnalogReadout::connectToVcc()); diff --git a/src/emucore/GlobalKeyHandler.hxx b/src/emucore/GlobalKeyHandler.hxx index fb4f789cc..60cc6ab13 100644 --- a/src/emucore/GlobalKeyHandler.hxx +++ b/src/emucore/GlobalKeyHandler.hxx @@ -153,7 +153,7 @@ class GlobalKeyHandler struct GroupData { Setting start{Setting::NONE}; - string name{EmptyString}; + string name; }; struct SettingData diff --git a/src/emucore/Joystick.cxx b/src/emucore/Joystick.cxx index fc702df69..f30b427ff 100644 --- a/src/emucore/Joystick.cxx +++ b/src/emucore/Joystick.cxx @@ -32,38 +32,38 @@ Joystick::Joystick(Jack jack, const Event& event, const System& system, { if(!altmap) { - myUpEvent = Event::LeftJoystickUp; - myDownEvent = Event::LeftJoystickDown; - myLeftEvent = Event::LeftJoystickLeft; + myUpEvent = Event::LeftJoystickUp; + myDownEvent = Event::LeftJoystickDown; + myLeftEvent = Event::LeftJoystickLeft; myRightEvent = Event::LeftJoystickRight; - myFireEvent = Event::LeftJoystickFire; + myFireEvent = Event::LeftJoystickFire; } else { - myUpEvent = Event::QTJoystickThreeUp; - myDownEvent = Event::QTJoystickThreeDown; - myLeftEvent = Event::QTJoystickThreeLeft; + myUpEvent = Event::QTJoystickThreeUp; + myDownEvent = Event::QTJoystickThreeDown; + myLeftEvent = Event::QTJoystickThreeLeft; myRightEvent = Event::QTJoystickThreeRight; - myFireEvent = Event::QTJoystickThreeFire; + myFireEvent = Event::QTJoystickThreeFire; } } else { if(!altmap) { - myUpEvent = Event::RightJoystickUp; - myDownEvent = Event::RightJoystickDown; - myLeftEvent = Event::RightJoystickLeft; + myUpEvent = Event::RightJoystickUp; + myDownEvent = Event::RightJoystickDown; + myLeftEvent = Event::RightJoystickLeft; myRightEvent = Event::RightJoystickRight; - myFireEvent = Event::RightJoystickFire; + myFireEvent = Event::RightJoystickFire; } else { - myUpEvent = Event::QTJoystickFourUp; - myDownEvent = Event::QTJoystickFourDown; - myLeftEvent = Event::QTJoystickFourLeft; + myUpEvent = Event::QTJoystickFourUp; + myDownEvent = Event::QTJoystickFourDown; + myLeftEvent = Event::QTJoystickFourLeft; myRightEvent = Event::QTJoystickFourRight; - myFireEvent = Event::QTJoystickFourFire; + myFireEvent = Event::QTJoystickFourFire; } } } diff --git a/src/emucore/Keyboard.cxx b/src/emucore/Keyboard.cxx index 8911bd71d..d6bff252d 100644 --- a/src/emucore/Keyboard.cxx +++ b/src/emucore/Keyboard.cxx @@ -54,8 +54,9 @@ Keyboard::Keyboard(Jack jack, const Event& event, const System& system) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Keyboard::ColumnState Keyboard::processColumn(const Event::Type buttons[]) { - constexpr DigitalPin signals[] = + static constexpr DigitalPin signals[] = {DigitalPin::One, DigitalPin::Two, DigitalPin::Three, DigitalPin::Four}; for (uInt8 i = 0; i < 4; i++) @@ -67,6 +68,7 @@ Keyboard::ColumnState Keyboard::processColumn(const Event::Type buttons[]) { return ColumnState::notConnected; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AnalogReadout::Connection Keyboard::columnStateToAnalogSignal(ColumnState state) const { switch (state) { case ColumnState::gnd: @@ -83,7 +85,6 @@ AnalogReadout::Connection Keyboard::columnStateToAnalogSignal(ColumnState state) } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Keyboard::write(DigitalPin pin, bool value) { diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 4a9313fe1..3b6a8a8d6 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -50,8 +50,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, if(!altmap) { // First paddle is left A, second is left B - myAAxisValue = Event::LeftPaddleAAnalog; - myBAxisValue = Event::LeftPaddleBAnalog; + myAAxisValue = Event::LeftPaddleAAnalog; + myBAxisValue = Event::LeftPaddleBAnalog; myLeftAFireEvent = Event::LeftPaddleAFire; myLeftBFireEvent = Event::LeftPaddleBFire; @@ -77,8 +77,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system, if(!altmap) { // First paddle is right A, second is right B - myAAxisValue = Event::RightPaddleAAnalog; - myBAxisValue = Event::RightPaddleBAnalog; + myAAxisValue = Event::RightPaddleAAnalog; + myBAxisValue = Event::RightPaddleBAnalog; myLeftAFireEvent = Event::RightPaddleAFire; myLeftBFireEvent = Event::RightPaddleBFire; @@ -159,6 +159,7 @@ void Paddles::update() updateB(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::updateA() { setPin(DigitalPin::Four, true); @@ -274,7 +275,6 @@ bool Paddles::updateAnalogAxesA() return sa_changed; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::updateMouseA(bool& firePressedA) { @@ -342,6 +342,7 @@ void Paddles::updateDigitalAxesA() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Paddles::updateB() { setPin(DigitalPin::Three, true); diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index 5973c9d76..b80c7245c 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -27,7 +27,10 @@ #include "repository/KeyValueRepositoryPropertyFile.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PropertiesSet::PropertiesSet() : myRepository{make_shared()} {} +PropertiesSet::PropertiesSet() + : myRepository{make_shared()} +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PropertiesSet::setRepository(shared_ptr repository) diff --git a/src/emucore/Sound.hxx b/src/emucore/Sound.hxx index bdb94470a..8ddb2dda6 100644 --- a/src/emucore/Sound.hxx +++ b/src/emucore/Sound.hxx @@ -37,7 +37,7 @@ class Sound Create a new sound object. The open method must be invoked before using the object. */ - Sound(OSystem& osystem) : myOSystem(osystem) { } + Sound(OSystem& osystem) : myOSystem{osystem} { } virtual ~Sound() = default; public: diff --git a/src/emucore/tia/AnalogReadout.cxx b/src/emucore/tia/AnalogReadout.cxx index 0cbcd9616..64c8d3be7 100644 --- a/src/emucore/tia/AnalogReadout.cxx +++ b/src/emucore/tia/AnalogReadout.cxx @@ -166,24 +166,6 @@ bool AnalogReadout::load(Serializer& in) return true; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AnalogReadout::Connection AnalogReadout::connectToGround(uInt32 resistance) -{ - return Connection{ConnectionType::ground, resistance}; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AnalogReadout::Connection AnalogReadout::connectToVcc(uInt32 resistance) -{ - return Connection{ConnectionType::vcc, resistance}; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AnalogReadout::Connection AnalogReadout::disconnect() -{ - return Connection{ConnectionType::disconnected, 0}; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool AnalogReadout::Connection::save(Serializer& out) const { diff --git a/src/emucore/tia/AnalogReadout.hxx b/src/emucore/tia/AnalogReadout.hxx index 3de91c7fc..fed6ef3fe 100644 --- a/src/emucore/tia/AnalogReadout.hxx +++ b/src/emucore/tia/AnalogReadout.hxx @@ -31,8 +31,8 @@ class AnalogReadout : public Serializable }; struct Connection { - ConnectionType type; - uInt32 resistance; + ConnectionType type{ConnectionType::ground}; + uInt32 resistance{0}; bool save(Serializer& out) const; bool load(const Serializer& in); @@ -61,11 +61,17 @@ class AnalogReadout : public Serializable public: - static Connection connectToGround(uInt32 resistance = 0); + static constexpr Connection connectToGround(uInt32 resistance = 0) { + return Connection{ConnectionType::ground, resistance}; + } - static Connection connectToVcc(uInt32 resistance = 0); + static constexpr Connection connectToVcc(uInt32 resistance = 0) { + return Connection{ConnectionType::vcc, resistance}; + } - static Connection disconnect(); + static constexpr Connection disconnect() { + return Connection{ConnectionType::disconnected, 0}; + } private: diff --git a/src/emucore/tia/DelayQueue.hxx b/src/emucore/tia/DelayQueue.hxx index 69a9d1ff0..fbcfad120 100644 --- a/src/emucore/tia/DelayQueue.hxx +++ b/src/emucore/tia/DelayQueue.hxx @@ -79,12 +79,12 @@ void DelayQueue::push(uInt8 address, uInt8 value, uInt8 delay) if (delay >= length) throw runtime_error("delay exceeds queue length"); - uInt8 currentIndex = myIndices[address]; + const uInt8 currentIndex = myIndices[address]; if (currentIndex < length) myMembers[currentIndex].remove(address); - uInt8 index = smartmod(myIndex + delay); + const uInt8 index = smartmod(myIndex + delay); myMembers[index].push(address, value); myIndices[address] = index; diff --git a/src/emucore/tia/DelayQueueIterator.hxx b/src/emucore/tia/DelayQueueIterator.hxx index dce184656..bbc09a7c9 100644 --- a/src/emucore/tia/DelayQueueIterator.hxx +++ b/src/emucore/tia/DelayQueueIterator.hxx @@ -23,6 +23,7 @@ class DelayQueueIterator { public: + DelayQueueIterator() = default; virtual ~DelayQueueIterator() = default; public: @@ -35,6 +36,13 @@ class DelayQueueIterator virtual uInt8 value() const = 0; virtual bool next() = 0; + + private: + // Following constructors and assignment operators not supported + DelayQueueIterator(const DelayQueueIterator&) = delete; + DelayQueueIterator(DelayQueueIterator&&) = delete; + DelayQueueIterator& operator=(const DelayQueueIterator&) = delete; + DelayQueueIterator& operator=(DelayQueueIterator&&) = delete; }; #endif // TIA_DELAY_QUEUE_ITERATOR diff --git a/src/emucore/tia/frame-manager/FrameManager.hxx b/src/emucore/tia/frame-manager/FrameManager.hxx index 4fe5fbbf9..f5b8eae4d 100644 --- a/src/emucore/tia/frame-manager/FrameManager.hxx +++ b/src/emucore/tia/frame-manager/FrameManager.hxx @@ -34,7 +34,7 @@ class FrameManager: public AbstractFrameManager { frameSizePAL = 312, baseHeightNTSC = 228, // 217..239 baseHeightPAL = 274, // 260..288 - maxHeight = uInt32(baseHeightPAL * 1.05 + 0.5), // 288 + maxHeight = static_cast(baseHeightPAL * 1.05 + 0.5), // 288 maxLinesVsync = 50, initialGarbageFrames = TIAConstants::initialGarbageFrames, ystartNTSC = 23, diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index ad2af1701..652cf281c 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -463,7 +463,7 @@ void Dialog::addTabWidget(TabWidget* w) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::setFocus(Widget* w) +void Dialog::setFocus(const Widget* w) { // If the click occured inside a widget which is not the currently // focused one, change the focus to that widget. diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 14bc1ba1c..34c823bd1 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -84,7 +84,7 @@ class Dialog : public GuiObject void addExtraWidget(ButtonWidget* w) { _extraWidget = w; } void addOKWidget(ButtonWidget* w) { _okWidget = w; } void addCancelWidget(ButtonWidget* w) { _cancelWidget = w; } - void setFocus(Widget* w); + void setFocus(const Widget* w); /** Returns the base surface associated with this dialog. */ FBSurface& surface() const { return *_surface; } diff --git a/src/gui/FavoritesManager.cxx b/src/gui/FavoritesManager.cxx index 6ec1ed74d..954524d7c 100644 --- a/src/gui/FavoritesManager.cxx +++ b/src/gui/FavoritesManager.cxx @@ -25,7 +25,7 @@ using json = nlohmann::json; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FavoritesManager::FavoritesManager(Settings& settings) - : mySettings(settings) + : mySettings{settings} { } diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 449eb13c5..9c8d831cb 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -30,7 +30,7 @@ FileListWidget::FileListWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h) : StringListWidget(boss, font, x, y, w, h), - _filter{[](const FilesystemNode& node) { return true; }} + _filter{[](const FilesystemNode&) { return true; }} { // This widget is special, in that it catches signals and redirects them setTarget(this); diff --git a/src/gui/HighScoresMenu.cxx b/src/gui/HighScoresMenu.cxx index ca2d97d8b..38199d536 100644 --- a/src/gui/HighScoresMenu.cxx +++ b/src/gui/HighScoresMenu.cxx @@ -22,7 +22,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HighScoresMenu::HighScoresMenu(OSystem& osystem) - : DialogContainer{osystem} + : DialogContainer(osystem) { } diff --git a/src/gui/QuadTariDialog.cxx b/src/gui/QuadTariDialog.cxx index 2106db62e..9a2f23994 100644 --- a/src/gui/QuadTariDialog.cxx +++ b/src/gui/QuadTariDialog.cxx @@ -60,7 +60,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w //VarList::push_back(ctrls, "MindLink", "MINDLINK"); //VarList::push_back(ctrls, "QuadTari", "QUADTARI"); - int pwidth = font.getStringWidth("Joystick12"); // a bit wider looks better overall + const int pwidth = font.getStringWidth("Joystick12"); // a bit wider looks better overall myLeftPortLabel = new StaticTextWidget(this, font, xpos, ypos + 1, "Left port"); diff --git a/src/gui/SnapshotDialog.cxx b/src/gui/SnapshotDialog.cxx index ae04567c2..86cc9050a 100644 --- a/src/gui/SnapshotDialog.cxx +++ b/src/gui/SnapshotDialog.cxx @@ -66,7 +66,7 @@ SnapshotDialog::SnapshotDialog(OSystem& osystem, DialogContainer& parent, wid.push_back(mySnapInterval); // Booleans for saving snapshots - int fwidth = font.getStringWidth("When saving snapshots:"); + const int fwidth = font.getStringWidth("When saving snapshots:"); xpos = HBORDER; ypos += lineHeight + VGAP * 3; new StaticTextWidget(this, font, xpos, ypos, fwidth, lineHeight, "When saving snapshots:", TextAlign::Left); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 3b676a70c..4c398363f 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -316,7 +316,7 @@ string Widget::getToolTip(const Common::Point& pos) const { // Merge hotkeys if they only differ by "+Shift" const string mod = "+Shift"; - size_t p = BSPF::findIgnoreCase(hotkey, mod); + const size_t p = BSPF::findIgnoreCase(hotkey, mod); if(p != string::npos) {