diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index dd37f5d2b..1f3ab423f 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -74,7 +74,7 @@ bool CheatManager::add(const string& name, const string& code, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheatManager::remove(int idx) { - if((uInt32)idx < myCheatList.size()) + if(uInt32(idx) < myCheatList.size()) { // This will also remove it from the per-frame list (if applicable) myCheatList[idx]->disable(); @@ -343,6 +343,6 @@ bool CheatManager::isValidCode(const string& code) const if(!isxdigit(c)) return false; - uInt32 length = (uInt32)code.length(); + uInt32 length = uInt32(code.length()); return (length == 4 || length == 6 || length == 8); } diff --git a/src/cheat/RamCheat.cxx b/src/cheat/RamCheat.cxx index 532d955f3..ba7cac1b6 100644 --- a/src/cheat/RamCheat.cxx +++ b/src/cheat/RamCheat.cxx @@ -28,8 +28,8 @@ RamCheat::RamCheat(OSystem& os, const string& name, const string& code) : Cheat(os, name, code) { - address = (uInt16) unhex(myCode.substr(0, 2)); - value = (uInt8) unhex(myCode.substr(2, 2)); + address = uInt16(unhex(myCode.substr(0, 2))); + value = uInt8(unhex(myCode.substr(2, 2))); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/Base.cxx b/src/common/Base.cxx index 07773ca81..e093cef55 100644 --- a/src/common/Base.cxx +++ b/src/common/Base.cxx @@ -44,6 +44,7 @@ string Base::toString(int value, Common::Base::Format outputBase) if(outputBase == Base::F_DEFAULT) outputBase = myDefaultBase; + // Note: generates warnings about 'nonliteral' format switch(outputBase) { case Base::F_2: // base 2: 8 or 16 bits (depending on value) diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index f21a26095..87a98f3ac 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -90,7 +90,6 @@ MouseControl::MouseControl(Console& console, const string& mode) xid = 1; msg << "MindLink 1"; break; - default: break; } msg << ", Y-axis is "; switch(yaxis) @@ -138,7 +137,6 @@ MouseControl::MouseControl(Console& console, const string& mode) yid = 1; msg << "MindLink 1"; break; - default: break; } myModeList.push_back(MouseMode(xtype, xid, ytype, yid, msg.str())); } diff --git a/src/common/PNGLibrary.hxx b/src/common/PNGLibrary.hxx index 0e04c5a89..882292a65 100644 --- a/src/common/PNGLibrary.hxx +++ b/src/common/PNGLibrary.hxx @@ -146,8 +146,8 @@ class PNGLibrary static void png_read_data(png_structp ctx, png_bytep area, png_size_t size); static void png_write_data(png_structp ctx, png_bytep area, png_size_t size); static void png_io_flush(png_structp ctx); - static void png_user_warn(png_structp ctx, png_const_charp str); - static void png_user_error(png_structp ctx, png_const_charp str); + static void png_user_warn[[noreturn]] (png_structp ctx, png_const_charp str); + static void png_user_error[[noreturn]] (png_structp ctx, png_const_charp str); private: // Following constructors and assignment operators not supported diff --git a/src/common/tv_filters/atari_ntsc_impl.hxx b/src/common/tv_filters/atari_ntsc_impl.hxx index 148042800..d1a4a0649 100644 --- a/src/common/tv_filters/atari_ntsc_impl.hxx +++ b/src/common/tv_filters/atari_ntsc_impl.hxx @@ -21,7 +21,6 @@ /* Common implementation of NTSC filters */ -#include #include /* Copyright (C) 2006-2009 Shay Green. This module is free software; you @@ -140,7 +139,6 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup ) { int x = kernel_size * 3 / 2 - kernel_half + i; kernels [x] *= sum; - assert( kernels [x] == kernels [x] ); /* catch numerical instability */ } } @@ -175,7 +173,6 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup ) for ( x = i; x < kernel_size; x += 2 ) { kernels [x] *= sum; - assert( kernels [x] == kernels [x] ); /* catch numerical instability */ } } } diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 95fe50a05..778347c07 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -189,8 +189,8 @@ string CartDebug::toString() return DebuggerParser::red("invalid base, this is a BUG"); } - const CartState& state = (CartState&) getState(); - const CartState& oldstate = (CartState&) getOldState(); + const CartState& state = static_cast(getState()); + const CartState& oldstate = static_cast(getOldState()); uInt32 curraddr = 0, bytesSoFar = 0; for(uInt32 i = 0; i < state.ram.size(); i += bytesPerLine, bytesSoFar += bytesPerLine) diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index c585c1c6f..e53451258 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -148,10 +148,10 @@ void Debugger::initialize() // The debugger dialog is resizable, within certain bounds // We check those bounds now - myWidth = BSPF_max(myWidth, (uInt32)DebuggerDialog::kSmallFontMinW); - myHeight = BSPF_max(myHeight, (uInt32)DebuggerDialog::kSmallFontMinH); - myWidth = BSPF_min(myWidth, (uInt32)d.w); - myHeight = BSPF_min(myHeight, (uInt32)d.h); + myWidth = BSPF_max(myWidth, uInt32(DebuggerDialog::kSmallFontMinW)); + myHeight = BSPF_max(myHeight, uInt32(DebuggerDialog::kSmallFontMinH)); + myWidth = BSPF_min(myWidth, uInt32(d.w)); + myHeight = BSPF_min(myHeight, uInt32(d.h)); myOSystem.settings().setValue("dbg.res", GUI::Size(myWidth, myHeight)); @@ -271,7 +271,7 @@ string Debugger::setRAM(IntArray& args) { ostringstream buf; - int count = (int)args.size(); + int count = int(args.size()); int address = args[0]; for(int i = 1; i < count; ++i) mySystem.poke(address++, args[i]); diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 905ffce31..8d1d1decb 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -196,7 +196,7 @@ class Debugger : public DialogContainer bits.push_back(false); } } - static uInt8 get_bits(BoolArray& bits) + static uInt8 get_bits(const BoolArray& bits) { uInt8 result = 0x0; for(int i = 0; i < 8; ++i) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index ed6e37b8b..e68705290 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -222,7 +222,7 @@ int DebuggerParser::decipher_arg(const string& str) if(bin && dec) return -1; // Special cases (registers): - CpuState& state = (CpuState&) debugger.cpuDebug().getState(); + const CpuState& state = static_cast(debugger.cpuDebug().getState()); if(arg == "a") result = state.A; else if(arg == "x") result = state.X; else if(arg == "y") result = state.Y; @@ -318,7 +318,7 @@ string DebuggerParser::showWatches() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DebuggerParser::getArgs(const string& command, string& verb) { - int state = kIN_COMMAND, i = 0, length = (int)command.length(); + int state = kIN_COMMAND, i = 0, length = int(command.length()); string curArg = ""; verb = ""; @@ -375,7 +375,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb) if(curArg != "") argStrings.push_back(curArg); - argCount = (int)argStrings.size(); + argCount = int(argStrings.size()); /* cerr << "verb = " << verb << endl; cerr << "arguments (" << argCount << "):\n"; @@ -630,7 +630,7 @@ bool DebuggerParser::saveScriptFile(string file) // "a" void DebuggerParser::executeA() { - debugger.cpuDebug().setA((uInt8)args[0]); + debugger.cpuDebug().setA(uInt8(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -871,7 +871,7 @@ void DebuggerParser::executeDelfunction() void DebuggerParser::executeDelwatch() { int which = args[0] - 1; - if(which >= 0 && which < (int)watches.size()) + if(which >= 0 && which < int(watches.size())) { Vec::removeAt(watches, which); commandResult << "removed watch"; @@ -1275,7 +1275,7 @@ void DebuggerParser::executeRunTo() const CartDebug& cartdbg = debugger.cartDebug(); const CartDebug::DisassemblyList& list = cartdbg.disassembly().list; - uInt32 count = 0, max_iterations = (uInt32)list.size(); + uInt32 count = 0, max_iterations = list.size(); // Create a progress dialog box to show the progress searching through the // disassembly, since this may be a time-consuming operation @@ -1343,7 +1343,7 @@ void DebuggerParser::executeRunToPc() // "s" void DebuggerParser::executeS() { - debugger.cpuDebug().setSP((uInt8)args[0]); + debugger.cpuDebug().setSP(uInt8(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1546,14 +1546,14 @@ void DebuggerParser::executeWatch() // "x" void DebuggerParser::executeX() { - debugger.cpuDebug().setX((uInt8)args[0]); + debugger.cpuDebug().setX(uInt8(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "y" void DebuggerParser::executeY() { - debugger.cpuDebug().setY((uInt8)args[0]); + debugger.cpuDebug().setY(uInt8(args[0])); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/DebuggerSystem.hxx b/src/debugger/DebuggerSystem.hxx index 3fbafcb1f..da6746d26 100644 --- a/src/debugger/DebuggerSystem.hxx +++ b/src/debugger/DebuggerSystem.hxx @@ -34,6 +34,11 @@ class DebuggerState public: DebuggerState() { } ~DebuggerState() { } + + DebuggerState(const DebuggerState&) = default; + DebuggerState(DebuggerState&&) = delete; + DebuggerState& operator=(const DebuggerState&) = default; + DebuggerState& operator=(DebuggerState&&) = delete; }; /** diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index 9ef429940..16895e1dc 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -733,7 +733,7 @@ void DiStella::disasm(uInt32 distart, int pass) // where wraparound occurred on a 32-bit int, and subsequent // indexing into the labels array caused a crash d1 = Debugger::debugger().peek(myPC+myOffset); myPC++; - ad = ((myPC + (Int8)d1) & 0xfff) + myOffset; + ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; labfound = mark(ad, CartDebug::REFERENCED); if (pass == 1) diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index a3571dfb1..bf8dd1ba6 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -310,8 +310,8 @@ string RiotDebug::switchesString() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string RiotDebug::toString() { - const RiotState& state = (RiotState&) getState(); - const RiotState& oldstate = (RiotState&) getOldState(); + const RiotState& state = static_cast(getState()); + const RiotState& 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 bb5468cf8..f25f12736 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -749,8 +749,7 @@ string TIADebug::toString() // TODO: inverse video for changed regs. Core needs to track this. // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR - const TiaState& state = (TiaState&) getState(); -// const TiaState& oldstate = (TiaState&) getOldState(); + const TiaState& state = static_cast(getState()); // build up output, then return it. buf << "scanline " << dec << myTIA.scanlines() << " " diff --git a/src/debugger/gui/AtariVoxWidget.cxx b/src/debugger/gui/AtariVoxWidget.cxx index a96081dc9..078a00231 100644 --- a/src/debugger/gui/AtariVoxWidget.cxx +++ b/src/debugger/gui/AtariVoxWidget.cxx @@ -66,7 +66,7 @@ void AtariVoxWidget::handleCommand(CommandSender*, int cmd, int, int) { if(cmd == kEEPROMErase) { - AtariVox& avox = (AtariVox&)myController; + AtariVox& avox = static_cast(myController); avox.myEEPROM->erase(); } } diff --git a/src/debugger/gui/AudioWidget.cxx b/src/debugger/gui/AudioWidget.cxx index 0f570bf36..480fba37d 100644 --- a/src/debugger/gui/AudioWidget.cxx +++ b/src/debugger/gui/AudioWidget.cxx @@ -103,8 +103,8 @@ void AudioWidget::loadConfig() Debugger& dbg = instance().debugger(); TIADebug& tia = dbg.tiaDebug(); - TiaState state = (TiaState&) tia.getState(); - TiaState oldstate = (TiaState&) tia.getOldState(); + const TiaState& state = static_cast(tia.getState()); + const TiaState& oldstate = static_cast(tia.getOldState()); // AUDF0/1 alist.clear(); vlist.clear(); changed.clear(); diff --git a/src/debugger/gui/Cart3EWidget.cxx b/src/debugger/gui/Cart3EWidget.cxx index e6be5976d..3f3cd811c 100644 --- a/src/debugger/gui/Cart3EWidget.cxx +++ b/src/debugger/gui/Cart3EWidget.cxx @@ -123,7 +123,7 @@ void Cartridge3EWidget::handleCommand(CommandSender* sender, if(cmd == kROMBankChanged) { - if(myROMBank->getSelected() < (int)myNumRomBanks) + if(myROMBank->getSelected() < int(myNumRomBanks)) { bank = myROMBank->getSelected(); myRAMBank->setSelectedMax(); @@ -136,7 +136,7 @@ void Cartridge3EWidget::handleCommand(CommandSender* sender, } else if(cmd == kRAMBankChanged) { - if(myRAMBank->getSelected() < (int)myNumRamBanks) + if(myRAMBank->getSelected() < int(myNumRamBanks)) { myROMBank->setSelectedMax(); bank = myRAMBank->getSelected() + 256; diff --git a/src/debugger/gui/CartCMWidget.cxx b/src/debugger/gui/CartCMWidget.cxx index c17fd47be..0448d3624 100644 --- a/src/debugger/gui/CartCMWidget.cxx +++ b/src/debugger/gui/CartCMWidget.cxx @@ -166,7 +166,7 @@ void CartridgeCMWidget::loadConfig() myBank->setSelectedIndex(myCart.myCurrentBank); RiotDebug& riot = Debugger::debugger().riotDebug(); - const RiotState& state = (RiotState&) riot.getState(); + const RiotState& state = static_cast(riot.getState()); uInt8 swcha = myCart.mySWCHA; diff --git a/src/debugger/gui/CartDPCPlusWidget.cxx b/src/debugger/gui/CartDPCPlusWidget.cxx index 6fc0ecb05..b8dba7e55 100644 --- a/src/debugger/gui/CartDPCPlusWidget.cxx +++ b/src/debugger/gui/CartDPCPlusWidget.cxx @@ -255,7 +255,7 @@ 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] != uInt32(myOldState.fraccounters[i])); } myFracCounters->setList(alist, vlist, changed); @@ -279,7 +279,7 @@ 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] != uInt32(myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -287,7 +287,7 @@ 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] != uInt32(myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); diff --git a/src/debugger/gui/CartRamWidget.cxx b/src/debugger/gui/CartRamWidget.cxx index 5ad55abe8..ad7184d7f 100644 --- a/src/debugger/gui/CartRamWidget.cxx +++ b/src/debugger/gui/CartRamWidget.cxx @@ -63,7 +63,7 @@ CartRamWidget::CartRamWidget( const uInt16 maxlines = 6; StringParser bs(desc, (fwidth - kScrollBarWidth) / myFontWidth); const StringList& sl = bs.stringList(); - uInt32 lines = (int)sl.size(); + uInt32 lines = sl.size(); if(lines < 3) lines = 3; if(lines > maxlines) lines = maxlines; diff --git a/src/debugger/gui/ControllerWidget.hxx b/src/debugger/gui/ControllerWidget.hxx index a7f07ec1b..e4a7d13ec 100644 --- a/src/debugger/gui/ControllerWidget.hxx +++ b/src/debugger/gui/ControllerWidget.hxx @@ -39,15 +39,15 @@ class ControllerWidget : public Widget, public CommandSender _h = 8 * font.getLineHeight(); } - virtual ~ControllerWidget() { }; + virtual ~ControllerWidget() { } - virtual void loadConfig() override { }; + virtual void loadConfig() override { } protected: Controller& myController; private: - virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }; + virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { } // Following constructors and assignment operators not supported ControllerWidget() = delete; diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index a3e9beab9..6cf0fa561 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -270,8 +270,8 @@ void CpuWidget::loadConfig() Debugger& dbg = instance().debugger(); CartDebug& cart = dbg.cartDebug(); CpuDebug& cpu = dbg.cpuDebug(); - const CpuState& state = (CpuState&) cpu.getState(); - const CpuState& oldstate = (CpuState&) cpu.getOldState(); + const CpuState& state = static_cast(cpu.getState()); + const CpuState& 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 a389e9a3a..b235e05c5 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -126,7 +126,7 @@ cerr << "alist.size() = " << alist.size() << ", changed.size() = " << changed.size() << ", _rows*_cols = " << _rows * _cols << endl << endl; */ - int size = (int)vlist.size(); // assume the alist is the same size + int size = int(vlist.size()); // assume the alist is the same size assert(size == _rows * _cols); _addrList.clear(); @@ -256,7 +256,7 @@ void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount) // First check whether the selection changed int newSelectedItem; newSelectedItem = findItem(x, y); - if (newSelectedItem > (int)_valueList.size() - 1) + if (newSelectedItem > int(_valueList.size()) - 1) newSelectedItem = -1; if (_selectedItem != newSelectedItem) @@ -370,12 +370,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_DOWN: - if (_currentRow < (int) _rows - 1) + if (_currentRow < int(_rows) - 1) { _currentRow++; dirty = true; } - else if(_currentCol < (int) _cols - 1) + else if(_currentCol < int(_cols) - 1) { _currentRow = 0; _currentCol++; @@ -398,12 +398,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_RIGHT: - if (_currentCol < (int) _cols - 1) + if (_currentCol < int(_cols) - 1) { _currentCol++; dirty = true; } - else if(_currentRow < (int) _rows - 1) + else if(_currentRow < int(_rows) - 1) { _currentCol = 0; _currentRow++; @@ -424,7 +424,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) case KBDK_PAGEDOWN: if(instance().eventHandler().kbdShift(mod) && _scrollBar) handleMouseWheel(0, 0, +1); - else if (_currentRow < (int) _rows - 1) + else if (_currentRow < int(_rows) - 1) { _currentRow = _rows - 1; dirty = true; @@ -440,7 +440,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_END: - if (_currentCol < (int) _cols - 1) + if (_currentCol < int(_cols) - 1) { _currentCol = _cols - 1; dirty = true; diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 80ffa0304..debb98fe7 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -453,7 +453,7 @@ void DebuggerDialog::addRomArea() GUI::Rect DebuggerDialog::getTiaBounds() const { // The area showing the TIA image (NTSC and PAL supported, up to 260 lines) - GUI::Rect r(0, 0, 320, BSPF_max(260, (int)(_h * 0.35))); + GUI::Rect r(0, 0, 320, BSPF_max(260, int(_h * 0.35))); return r; } @@ -477,7 +477,7 @@ GUI::Rect DebuggerDialog::getStatusBounds() const int x1 = tia.right + 1; int y1 = 0; - int x2 = tia.right + 225 + (_w > 1030 ? (int) (0.35 * (_w - 1030)) : 0); + int x2 = tia.right + 225 + (_w > 1030 ? int(0.35 * (_w - 1030)) : 0); int y2 = tia.bottom; GUI::Rect r(x1, y1, x2, y2); diff --git a/src/debugger/gui/NullControlWidget.hxx b/src/debugger/gui/NullControlWidget.hxx index 5f01939bc..580fd9328 100644 --- a/src/debugger/gui/NullControlWidget.hxx +++ b/src/debugger/gui/NullControlWidget.hxx @@ -48,7 +48,7 @@ class NullControlWidget : public ControllerWidget kTextAlignCenter); } - virtual ~NullControlWidget() { }; + virtual ~NullControlWidget() { } private: // Following constructors and assignment operators not supported diff --git a/src/debugger/gui/PaddleWidget.cxx b/src/debugger/gui/PaddleWidget.cxx index 611404355..bdc83ab4e 100644 --- a/src/debugger/gui/PaddleWidget.cxx +++ b/src/debugger/gui/PaddleWidget.cxx @@ -75,8 +75,8 @@ PaddleWidget::~PaddleWidget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PaddleWidget::loadConfig() { - myP0Resistance->setValue(1400000 - (Int32)myController.read(Controller::Nine)); - myP1Resistance->setValue(1400000 - (Int32)myController.read(Controller::Five)); + myP0Resistance->setValue(1400000 - Int32(myController.read(Controller::Nine))); + myP1Resistance->setValue(1400000 - Int32(myController.read(Controller::Five))); myP0Fire->setState(!myController.read(Controller::Four)); myP1Fire->setState(!myController.read(Controller::Three)); } diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index b44e68ecc..c6ec3ea00 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -474,7 +474,7 @@ void PromptWidget::handleCommand(CommandSender* sender, int cmd, switch (cmd) { case kSetPositionCmd: - int newPos = (int)data + _linesPerPage - 1 + _firstLineInBuffer; + int newPos = int(data) + _linesPerPage - 1 + _firstLineInBuffer; if (newPos != _scrollLine) { _scrollLine = newPos; @@ -765,7 +765,7 @@ int PromptWidget::printf(const char* format, ...) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int PromptWidget::vprintf(const char* format, va_list argptr) { - char buf[2048]; + char buf[2048]; // Note: generates warnings about 'nonliteral' format int count = BSPF_vsnprintf(buf, sizeof(buf), format, argptr); print(buf); diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index b9e552dc3..dbdf53c97 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -170,7 +170,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) // We simply change the values in the DataGridWidget // It will then send the 'kDGItemDataChangedCmd' signal to change the actual // memory location - int addr, value; + int addr = 0, value = 0; switch(cmd) { diff --git a/src/debugger/gui/RiotRamWidget.cxx b/src/debugger/gui/RiotRamWidget.cxx index 894cffac0..d32c3a202 100644 --- a/src/debugger/gui/RiotRamWidget.cxx +++ b/src/debugger/gui/RiotRamWidget.cxx @@ -38,21 +38,21 @@ RiotRamWidget::~RiotRamWidget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 RiotRamWidget::getValue(int addr) const { - const CartState& state = (CartState&) myDbg.getState(); + const CartState& state = static_cast(myDbg.getState()); return myDbg.peek(state.rport[addr]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RiotRamWidget::setValue(int addr, uInt8 value) { - const CartState& state = (CartState&) myDbg.getState(); + const CartState& state = static_cast(myDbg.getState()); myDbg.poke(state.wport[addr], value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string RiotRamWidget::getLabel(int addr) const { - const CartState& state = (CartState&) myDbg.getState(); + const CartState& state = static_cast(myDbg.getState()); return myDbg.getLabel(state.rport[addr], true); } @@ -60,8 +60,8 @@ string RiotRamWidget::getLabel(int addr) const void RiotRamWidget::fillList(uInt32 start, uInt32 size, IntArray& alist, IntArray& vlist, BoolArray& changed) const { - const CartState& state = (CartState&) myDbg.getState(); - const CartState& oldstate = (CartState&) myDbg.getOldState(); + const CartState& state = static_cast(myDbg.getState()); + const CartState& oldstate = static_cast(myDbg.getOldState()); for(uInt32 i = 0; i < size; i++) { @@ -74,13 +74,13 @@ void RiotRamWidget::fillList(uInt32 start, uInt32 size, IntArray& alist, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 RiotRamWidget::readPort(uInt32 start) const { - const CartState& state = (CartState&) myDbg.getState(); + const CartState& state = static_cast(myDbg.getState()); return state.rport[start]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const ByteArray& RiotRamWidget::currentRam(uInt32) const { - const CartState& state = (CartState&) myDbg.getState(); + const CartState& state = static_cast(myDbg.getState()); return state.ram; } diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 9e59e182c..74abe355c 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -266,8 +266,8 @@ void RiotWidget::loadConfig() // address in the callback (handleCommand) Debugger& dbg = instance().debugger(); RiotDebug& riot = dbg.riotDebug(); - const RiotState& state = (RiotState&) riot.getState(); - const RiotState& oldstate = (RiotState&) riot.getOldState(); + const RiotState& state = static_cast(riot.getState()); + const RiotState& oldstate = static_cast(riot.getOldState()); // Update the SWCHA register booleans (poke mode) IO_REGS_UPDATE(mySWCHAWriteBits, swchaWriteBits); @@ -335,9 +335,9 @@ void RiotWidget::loadConfig() // Console switches (inverted, since 'selected' in the UI // means 'grounded' in the system) - myP0Diff->setSelectedIndex((int)riot.diffP0()); - myP1Diff->setSelectedIndex((int)riot.diffP1()); - myTVType->setSelectedIndex((int)riot.tvType()); + myP0Diff->setSelectedIndex(riot.diffP0()); + myP1Diff->setSelectedIndex(riot.diffP1()); + myTVType->setSelectedIndex(riot.tvType()); mySelect->setState(!riot.select()); myReset->setState(!riot.reset()); @@ -387,19 +387,19 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) switch(id) { case kSWCHABitsID: - value = Debugger::get_bits((BoolArray&)mySWCHAWriteBits->getState()); + value = Debugger::get_bits(mySWCHAWriteBits->getState()); riot.swcha(value & 0xff); break; case kSWACNTBitsID: - value = Debugger::get_bits((BoolArray&)mySWACNTBits->getState()); + value = Debugger::get_bits(mySWACNTBits->getState()); riot.swacnt(value & 0xff); break; case kSWCHBBitsID: - value = Debugger::get_bits((BoolArray&)mySWCHBWriteBits->getState()); + value = Debugger::get_bits(mySWCHBWriteBits->getState()); riot.swchb(value & 0xff); break; case kSWBCNTBitsID: - value = Debugger::get_bits((BoolArray&)mySWBCNTBits->getState()); + value = Debugger::get_bits(mySWBCNTBits->getState()); riot.swbcnt(value & 0xff); break; } @@ -432,7 +432,7 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) break; case kTVTypeChanged: - riot.tvType((bool)myTVType->getSelected()); + riot.tvType(myTVType->getSelected()); break; } } diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index b468a12cd..c787eb2d4 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -134,8 +134,8 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm, myCheckList[i]->setFlags(WIDGET_ENABLED); // Then turn off any extras - if((int)myDisasm->list.size() < _rows) - for(int i = (int)myDisasm->list.size(); i < _rows; ++i) + if(int(myDisasm->list.size()) < _rows) + for(int i = int(myDisasm->list.size()); i < _rows; ++i) myCheckList[i]->clearFlags(WIDGET_ENABLED); recalc(); @@ -144,7 +144,7 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::setSelected(int item) { - if(item < -1 || item >= (int)myDisasm->list.size()) + if(item < -1 || item >= int(myDisasm->list.size())) return; if(isEnabled()) @@ -160,7 +160,7 @@ void RomListWidget::setSelected(int item) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::setHighlighted(int item) { - if(item < -1 || item >= (int)myDisasm->list.size()) + if(item < -1 || item >= int(myDisasm->list.size())) return; if(isEnabled()) @@ -189,7 +189,7 @@ int RomListWidget::findItem(int x, int y) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::recalc() { - int size = (int)myDisasm->list.size(); + int size = int(myDisasm->list.size()); if (_currentPos >= size) _currentPos = size - 1; @@ -201,7 +201,7 @@ void RomListWidget::recalc() _editMode = false; - myScrollBar->_numEntries = (int)myDisasm->list.size(); + myScrollBar->_numEntries = int(myDisasm->list.size()); myScrollBar->_entriesPerPage = _rows; // Reset to normal data entry @@ -225,10 +225,11 @@ void RomListWidget::scrollToCurrent(int item) _currentPos = item - _rows + 1; } - if (_currentPos < 0 || _rows > (int)myDisasm->list.size()) + int size = myDisasm->list.size(); + if (_currentPos < 0 || _rows > size) _currentPos = 0; - else if (_currentPos + _rows > (int)myDisasm->list.size()) - _currentPos = (int)myDisasm->list.size() - _rows; + else if (_currentPos + _rows > size) + _currentPos = size - _rows; myScrollBar->_currentPos = _currentPos; myScrollBar->recalc(); @@ -255,7 +256,7 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount) // First check whether the selection changed int newSelectedItem; newSelectedItem = findItem(x, y); - if (newSelectedItem > (int)myDisasm->list.size() - 1) + if (newSelectedItem > int(myDisasm->list.size()) - 1) newSelectedItem = -1; if (_selectedItem != newSelectedItem) @@ -374,7 +375,7 @@ bool RomListWidget::handleEvent(Event::Type e) break; case Event::UIDown: - if (_selectedItem < (int)myDisasm->list.size() - 1) + if (_selectedItem < int(myDisasm->list.size()) - 1) _selectedItem++; break; @@ -386,8 +387,8 @@ bool RomListWidget::handleEvent(Event::Type e) case Event::UIPgDown: _selectedItem += _rows - 1; - if (_selectedItem >= (int)myDisasm->list.size()) - _selectedItem = (int)myDisasm->list.size() - 1; + if (_selectedItem >= int(myDisasm->list.size())) + _selectedItem = int(myDisasm->list.size()) - 1; break; case Event::UIHome: @@ -395,7 +396,7 @@ bool RomListWidget::handleEvent(Event::Type e) break; case Event::UIEnd: - _selectedItem = (int)myDisasm->list.size() - 1; + _selectedItem = int(myDisasm->list.size()) - 1; break; default: @@ -424,7 +425,7 @@ void RomListWidget::handleCommand(CommandSender* sender, int cmd, int data, int break; case kSetPositionCmd: - if (_currentPos != (int)data) + if (_currentPos != data) { _currentPos = data; setDirty(); @@ -451,7 +452,7 @@ void RomListWidget::drawWidget(bool hilite) { FBSurface& s = _boss->dialog().surface(); const CartDebug::DisassemblyList& dlist = myDisasm->list; - int i, pos, xpos, ypos, len = (int)dlist.size(); + int i, pos, xpos, ypos, len = int(dlist.size()); const GUI::Rect& r = getEditRect(); const GUI::Rect& l = getLineRect(); diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index f19e90929..9d3c4f7d2 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -71,8 +71,8 @@ void RomWidget::loadConfig() { Debugger& dbg = instance().debugger(); CartDebug& cart = dbg.cartDebug(); - const CartState& state = (CartState&) cart.getState(); - const CartState& oldstate = (CartState&) cart.getOldState(); + const CartState& state = static_cast(cart.getState()); + const CartState& oldstate = static_cast(cart.getOldState()); // Fill romlist the current bank of source or disassembly myListIsDirty |= cart.disassemble(myListIsDirty); @@ -109,7 +109,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case RomListWidget::kRomChangedCmd: // 'data' is the line in the disassemblylist to be accessed // 'id' is the base to use for the data to be changed - patchROM(data, myRomList->getText(), (Common::Base::Format)id); + patchROM(data, myRomList->getText(), Common::Base::Format(id)); break; case RomListWidget::kSetPCCmd: @@ -174,7 +174,7 @@ void RomWidget::setBreak(int disasm_line, bool state) { const CartDebug::DisassemblyList& list = instance().debugger().cartDebug().disassembly().list; - if(disasm_line >= (int)list.size()) return; + if(disasm_line >= int(list.size())) return; if(list[disasm_line].address != 0 && list[disasm_line].bytes != "") instance().debugger().setBreakPoint(list[disasm_line].address, state); @@ -185,7 +185,7 @@ void RomWidget::setPC(int disasm_line) { const CartDebug::DisassemblyList& list = instance().debugger().cartDebug().disassembly().list; - if(disasm_line >= (int)list.size()) return; + if(disasm_line >= int(list.size())) return; if(list[disasm_line].address != 0) { @@ -200,7 +200,7 @@ void RomWidget::runtoPC(int disasm_line) { const CartDebug::DisassemblyList& list = instance().debugger().cartDebug().disassembly().list; - if(disasm_line >= (int)list.size()) return; + if(disasm_line >= int(list.size())) return; if(list[disasm_line].address != 0) { @@ -216,7 +216,7 @@ void RomWidget::patchROM(int disasm_line, const string& bytes, { const CartDebug::DisassemblyList& list = instance().debugger().cartDebug().disassembly().list; - if(disasm_line >= (int)list.size()) return; + if(disasm_line >= int(list.size())) return; if(list[disasm_line].address != 0) { diff --git a/src/debugger/gui/SaveKeyWidget.cxx b/src/debugger/gui/SaveKeyWidget.cxx index 09419a15c..c9fbc3bf8 100644 --- a/src/debugger/gui/SaveKeyWidget.cxx +++ b/src/debugger/gui/SaveKeyWidget.cxx @@ -66,7 +66,7 @@ void SaveKeyWidget::handleCommand(CommandSender*, int cmd, int, int) { if(cmd == kEEPROMErase) { - SaveKey& skey = (SaveKey&)myController; + SaveKey& skey = static_cast(myController); skey.myEEPROM->erase(); } } diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index f2b37e5ae..d700dad2a 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -66,7 +66,7 @@ void TiaOutputWidget::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::saveSnapshot() { - int number = (int)(instance().getTicks() / 1000); + int number = int(instance().getTicks() / 1000); ostringstream sspath; sspath << instance().snapshotSaveDir() << instance().console().properties().get(Cartridge_Name) diff --git a/src/debugger/gui/TiaWidget.cxx b/src/debugger/gui/TiaWidget.cxx index 4df94b458..6b5f2c5e4 100644 --- a/src/debugger/gui/TiaWidget.cxx +++ b/src/debugger/gui/TiaWidget.cxx @@ -809,8 +809,8 @@ void TiaWidget::loadConfig() Debugger& dbg = instance().debugger(); TIADebug& tia = dbg.tiaDebug(); - TiaState& state = (TiaState&) tia.getState(); - TiaState& oldstate = (TiaState&) tia.getOldState(); + const TiaState& state = static_cast(tia.getState()); + const TiaState& oldstate = static_cast(tia.getOldState()); // Color registers alist.clear(); vlist.clear(); changed.clear(); diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 05e871553..6d7342e02 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -60,8 +60,7 @@ void ToggleBitWidget::setList(const StringList& off, const StringList& on) _onList.clear(); _onList = on; - int size = (int)_offList.size(); // assume _onList is the same size - assert(size == _rows * _cols); + assert(int(_offList.size()) == _rows * _cols); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/TogglePixelWidget.cxx b/src/debugger/gui/TogglePixelWidget.cxx index 97de2f788..c92dd2b8d 100644 --- a/src/debugger/gui/TogglePixelWidget.cxx +++ b/src/debugger/gui/TogglePixelWidget.cxx @@ -39,7 +39,7 @@ TogglePixelWidget::TogglePixelWidget(GuiObject* boss, const GUI::Font& font, _h = _rowHeight * rows + 1; // Changed state isn't used, but we still need to fill it - while((int)_changedList.size() < rows * cols) + while(int(_changedList.size()) < rows * cols) _changedList.push_back(false); } @@ -92,7 +92,7 @@ void TogglePixelWidget::setIntState(int value, bool swap) int TogglePixelWidget::getIntState() { // Construct int based on current state and swap - uInt32 value = 0, size = (int)_stateList.size(); + uInt32 value = 0, size = _stateList.size(); for(uInt32 i = 0; i < size; ++i) { diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 9d50d250e..b805ba72e 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -53,7 +53,7 @@ void ToggleWidget::handleMouseDown(int x, int y, int button, int clickCount) // First check whether the selection changed int newSelectedItem; newSelectedItem = findItem(x, y); - if (newSelectedItem > (int)_stateList.size() - 1) + if (newSelectedItem > int(_stateList.size()) - 1) newSelectedItem = -1; if (_selectedItem != newSelectedItem) @@ -125,7 +125,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_DOWN: - if (_currentRow < (int) _rows - 1) + if (_currentRow < int(_rows) - 1) { _currentRow++; dirty = true; @@ -141,7 +141,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_RIGHT: - if (_currentCol < (int) _cols - 1) + if (_currentCol < int(_cols) - 1) { _currentCol++; dirty = true; @@ -157,7 +157,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_PAGEDOWN: - if (_currentRow < (int) _rows - 1) + if (_currentRow < int(_rows) - 1) { _currentRow = _rows - 1; dirty = true; @@ -173,7 +173,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_END: - if (_currentCol < (int) _cols - 1) + if (_currentCol < int(_cols) - 1) { _currentCol = _cols - 1; dirty = true; @@ -208,7 +208,7 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd, switch (cmd) { case kSetPositionCmd: - if (_selectedItem != (int)data) + if (_selectedItem != data) { _selectedItem = data; setDirty(); diff --git a/src/emucore/AtariVox.cxx b/src/emucore/AtariVox.cxx index ff92ef0f2..e72048867 100644 --- a/src/emucore/AtariVox.cxx +++ b/src/emucore/AtariVox.cxx @@ -27,7 +27,7 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const SerialPort& port, const string& portname, const string& eepromfile) : Controller(jack, event, system, Controller::AtariVox), - mySerialPort((SerialPort&)port), + mySerialPort(const_cast(port)), myShiftCount(0), myShiftRegister(0), myLastDataWriteCycle(0) diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 4923a77b4..193b69c84 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -327,7 +327,7 @@ bool Cartridge::saveROM(ofstream& out) return false; } - out.write((const char*)image, size); + out.write(reinterpret_cast(image), size); return true; } diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 93f3d3950..6485e8f16 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -156,7 +156,7 @@ bool Cartridge3E::bank(uInt16 bank) if(bank < 256) { // Make sure the bank they're asking for is reasonable - if(((uInt32)bank << 11) < uInt32(mySize)) + if((uInt32(bank) << 11) < mySize) { myCurrentBank = bank; } diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index adaaa218d..9e31888a0 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -122,7 +122,7 @@ bool Cartridge3F::bank(uInt16 bank) if(bankLocked()) return false; // Make sure the bank they're asking for is reasonable - if(((uInt32)bank << 11) < mySize) + if((uInt32(bank) << 11) < mySize) { myCurrentBank = bank; } diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 24a2411d1..c028a7f50 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -533,7 +533,7 @@ bool CartridgeAR::load(Serializer& in) myPower = in.getBool(); // Indicates when the power was last turned on - myPowerRomCycle = (Int32) in.getInt(); + myPowerRomCycle = in.getInt(); // Data hold register used for writing myDataHoldRegister = in.getByte(); diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 165faa87a..6c646527b 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -309,7 +309,7 @@ bool CartridgeCTY::save(Serializer& out) const out.putBool(myLDAimmediate); out.putInt(myRandomNumber); out.putInt(mySystemCycles); - out.putInt((uInt32)(myFractionalClocks * 100000000.0)); + out.putInt(uInt32(myFractionalClocks * 100000000.0)); } catch(...) @@ -337,8 +337,8 @@ bool CartridgeCTY::load(Serializer& in) myCounter = in.getShort(); myLDAimmediate = in.getBool(); myRandomNumber = in.getInt(); - mySystemCycles = (Int32)in.getInt(); - myFractionalClocks = (double)in.getInt() / 100000000.0; + mySystemCycles = in.getInt(); + myFractionalClocks = double(in.getInt()) / 100000000.0; } catch(...) { @@ -495,7 +495,7 @@ void CartridgeCTY::saveScore(uInt8 index) catch(...) { // Maybe add logging here that save failed? - cerr << name() << ": ERROR saving score table " << (int)index << endl; + cerr << name() << ": ERROR saving score table " << int(index) << endl; } } } @@ -530,8 +530,8 @@ inline void CartridgeCTY::updateMusicModeDataFetchers() // Calculate the number of DPC OSC clocks since the last update double clocks = ((20000.0 * cycles) / 1193191.66666667) + myFractionalClocks; - Int32 wholeClocks = (Int32)clocks; - myFractionalClocks = clocks - (double)wholeClocks; + Int32 wholeClocks = Int32(clocks); + myFractionalClocks = clocks - double(wholeClocks); if(wholeClocks <= 0) return; diff --git a/src/emucore/CartDASH.cxx b/src/emucore/CartDASH.cxx index 312593f58..b9d492347 100644 --- a/src/emucore/CartDASH.cxx +++ b/src/emucore/CartDASH.cxx @@ -189,12 +189,12 @@ void CartridgeDASH::bankRAMSlot(uInt16 bank) { if (upper) { // We're mapping the write port - bankInUse[bankNumber + 4] = (Int16) bank; + bankInUse[bankNumber + 4] = Int16(bank); access.type = System::PA_WRITE; } else { // We're mapping the read port - bankInUse[bankNumber] = (Int16) bank; + bankInUse[bankNumber] = Int16(bank); access.type = System::PA_READ; } @@ -238,7 +238,7 @@ void CartridgeDASH::bankROMSlot(uInt16 bank) { uInt16 currentBank = bank & BIT_BANK_MASK; // Wrap around/restrict to valid range bool upper = bank & BITMASK_LOWERUPPER; // is this the lower or upper 512b - bankInUse[bankNumber * 2 + (upper ? 1 : 0)] = (Int16) bank; // Record which bank switched in (as ROM) + bankInUse[bankNumber * 2 + (upper ? 1 : 0)] = Int16(bank); // Record which bank switched in (as ROM) uInt32 startCurrentBank = currentBank << ROM_BANK_TO_POWER; // Effectively *1K diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index 09997a9f6..1297a9078 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -118,8 +118,8 @@ inline void CartridgeDPC::updateMusicModeDataFetchers() // Calculate the number of DPC OSC clocks since the last update double clocks = ((20000.0 * cycles) / 1193191.66666667) + myFractionalClocks; - Int32 wholeClocks = (Int32)clocks; - myFractionalClocks = clocks - (double)wholeClocks; + Int32 wholeClocks = Int32(clocks); + myFractionalClocks = clocks - double(wholeClocks); if(wholeClocks <= 0) { @@ -133,7 +133,7 @@ inline void CartridgeDPC::updateMusicModeDataFetchers() if(myMusicMode[x - 5]) { Int32 top = myTops[x] + 1; - Int32 newLow = (Int32)(myCounters[x] & 0x00ff); + Int32 newLow = Int32(myCounters[x] & 0x00ff); if(myTops[x] != 0) { @@ -158,7 +158,7 @@ inline void CartridgeDPC::updateMusicModeDataFetchers() myFlags[x] = 0xff; } - myCounters[x] = (myCounters[x] & 0x0700) | (uInt16)newLow; + myCounters[x] = (myCounters[x] & 0x0700) | uInt16(newLow); } } } @@ -332,14 +332,14 @@ bool CartridgeDPC::poke(uInt16 address, uInt8 value) // Data fetcher is in music mode so its low counter value // should be loaded from the top register not the poked value myCounters[index] = (myCounters[index] & 0x0700) | - (uInt16)myTops[index]; + uInt16(myTops[index]); } else { // Data fetcher is either not a music mode data fetcher or it // isn't in music mode so it's low counter value should be loaded // with the poked value - myCounters[index] = (myCounters[index] & 0x0700) | (uInt16)value; + myCounters[index] = (myCounters[index] & 0x0700) | uInt16(value); } break; } @@ -347,7 +347,7 @@ bool CartridgeDPC::poke(uInt16 address, uInt8 value) // DFx counter high case 0x03: { - myCounters[index] = (((uInt16)value & 0x07) << 8) | + myCounters[index] = ((uInt16(value) & 0x07) << 8) | (myCounters[index] & 0x00ff); // Execute special code for music mode data fetchers @@ -491,7 +491,7 @@ bool CartridgeDPC::save(Serializer& out) const out.putByte(myRandomNumber); out.putInt(mySystemCycles); - out.putInt((uInt32)(myFractionalClocks * 100000000.0)); + out.putInt(uInt32(myFractionalClocks * 100000000.0)); } catch(...) { @@ -533,8 +533,8 @@ bool CartridgeDPC::load(Serializer& in) myRandomNumber = in.getByte(); // Get system cycles and fractional clocks - mySystemCycles = (Int32)in.getInt(); - myFractionalClocks = (double)in.getInt() / 100000000.0; + mySystemCycles = Int32(in.getInt()); + myFractionalClocks = double(in.getInt()) / 100000000.0; } catch(...) { diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index d6d24650d..1d8e217b2 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -61,7 +61,8 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size, #ifdef THUMB_SUPPORT // Create Thumbulator ARM emulator myThumbEmulator = make_ptr - ((uInt16*)(myProgramImage-0xC00), (uInt16*)myDPCRAM, + (reinterpret_cast(myProgramImage-0xC00), + reinterpret_cast(myDPCRAM), settings.getBool("thumb.trapfatal")); #endif setInitialState(); @@ -157,8 +158,8 @@ inline void CartridgeDPCPlus::updateMusicModeDataFetchers() // Calculate the number of DPC OSC clocks since the last update double clocks = ((20000.0 * cycles) / 1193191.66666667) + myFractionalClocks; - Int32 wholeClocks = (Int32)clocks; - myFractionalClocks = clocks - (double)wholeClocks; + Int32 wholeClocks = Int32(clocks); + myFractionalClocks = clocks - double(wholeClocks); if(wholeClocks <= 0) { @@ -287,7 +288,7 @@ uInt8 CartridgeDPCPlus::peek(uInt16 address) myDisplayImage[(myMusicWaveforms[1] << 5) + (myMusicCounters[1] >> 27)] + myDisplayImage[(myMusicWaveforms[2] << 5) + (myMusicCounters[2] >> 27)]; - result = (uInt8)i; + result = uInt8(i); break; } @@ -412,12 +413,12 @@ bool CartridgeDPCPlus::poke(uInt16 address, uInt8 value) { //DFxFRACLOW - fractional data pointer low byte case 0x00: - myFractionalCounters[index] = (myFractionalCounters[index] & 0x0F00FF) | ((uInt16)value << 8); + myFractionalCounters[index] = (myFractionalCounters[index] & 0x0F00FF) | (uInt16(value) << 8); break; // DFxFRACHI - fractional data pointer high byte case 0x01: - myFractionalCounters[index] = (((uInt16)value & 0x0F) << 16) | (myFractionalCounters[index] & 0x00ffff); + myFractionalCounters[index] = ((uInt16(value) & 0x0F) << 16) | (myFractionalCounters[index] & 0x00ffff); break; //DFxFRACINC - Fractional Increment amount @@ -481,7 +482,7 @@ bool CartridgeDPCPlus::poke(uInt16 address, uInt8 value) // DFxHI - data pointer high byte case 0x08: { - myCounters[index] = (((uInt16)value & 0x0F) << 8) | (myCounters[index] & 0x00ff); + myCounters[index] = ((uInt16(value) & 0x0F) << 8) | (myCounters[index] & 0x00ff); break; } @@ -690,7 +691,7 @@ bool CartridgeDPCPlus::save(Serializer& out) const out.putInt(myRandomNumber); out.putInt(mySystemCycles); - out.putInt((uInt32)(myFractionalClocks * 100000000.0)); + out.putInt(uInt32(myFractionalClocks * 100000000.0)); } catch(...) { @@ -750,8 +751,8 @@ bool CartridgeDPCPlus::load(Serializer& in) myRandomNumber = in.getInt(); // Get system cycles and fractional clocks - mySystemCycles = (Int32)in.getInt(); - myFractionalClocks = (double)in.getInt() / 100000000.0; + mySystemCycles = in.getInt(); + myFractionalClocks = double(in.getInt()) / 100000000.0; } catch(...) { diff --git a/src/emucore/CartMC.cxx b/src/emucore/CartMC.cxx index 4293b95ca..a6e1e110e 100644 --- a/src/emucore/CartMC.cxx +++ b/src/emucore/CartMC.cxx @@ -134,7 +134,7 @@ uInt8 CartridgeMC::peek(uInt16 address) if(block & 0x80) { // ROM access - return myImage[(uInt32)((block & 0x7F) << 10) + (address & 0x03FF)]; + return myImage[uInt32((block & 0x7F) << 10) + (address & 0x03FF)]; } else { @@ -142,7 +142,7 @@ uInt8 CartridgeMC::peek(uInt16 address) if(address & 0x0200) { // Reading from the read port of the RAM block - return myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)]; + return myRAM[uInt32((block & 0x3F) << 9) + (address & 0x01FF)]; } else { @@ -155,7 +155,7 @@ uInt8 CartridgeMC::peek(uInt16 address) else { triggerReadFromWritePort(peekAddress); - return myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = value; + return myRAM[uInt32((block & 0x3F) << 9) + (address & 0x01FF)] = value; } } } @@ -202,7 +202,7 @@ bool CartridgeMC::poke(uInt16 address, uInt8 value) if(!(block & 0x80) && !(address & 0x0200)) { // Handle the write to RAM - myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = value; + myRAM[uInt32((block & 0x3F) << 9) + (address & 0x01FF)] = value; return true; } } diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index ad8d5b536..9ea865995 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -461,7 +461,7 @@ void Console::initializeAudio() void Console::fry() const { for(int ZPmem = 0; ZPmem < 0x100; ZPmem += rand() % 4) - mySystem->poke(ZPmem, mySystem->peek(ZPmem) & (uInt8)rand() % 256); + mySystem->poke(ZPmem, mySystem->peek(ZPmem) & uInt8(rand()) % 256); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -767,22 +767,22 @@ void Console::loadUserPalette() for(int i = 0; i < 128; i++) // NTSC palette { - in.read((char*)pixbuf, 3); - uInt32 pixel = ((int)pixbuf[0] << 16) + ((int)pixbuf[1] << 8) + (int)pixbuf[2]; + in.read(reinterpret_cast(pixbuf), 3); + uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); ourUserNTSCPalette[(i<<1)] = pixel; } for(int i = 0; i < 128; i++) // PAL palette { - in.read((char*)pixbuf, 3); - uInt32 pixel = ((int)pixbuf[0] << 16) + ((int)pixbuf[1] << 8) + (int)pixbuf[2]; + in.read(reinterpret_cast(pixbuf), 3); + uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); ourUserPALPalette[(i<<1)] = pixel; } uInt32 secam[16]; // All 8 24-bit pixels, plus 8 colorloss pixels for(int i = 0; i < 8; i++) // SECAM palette { - in.read((char*)pixbuf, 3); - uInt32 pixel = ((int)pixbuf[0] << 16) + ((int)pixbuf[1] << 8) + (int)pixbuf[2]; + in.read(reinterpret_cast(pixbuf), 3); + uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); secam[(i<<1)] = pixel; secam[(i<<1)+1] = 0; } @@ -827,9 +827,7 @@ void Console::generateColorLossPalette() uInt8 r = (pixel >> 16) & 0xff; uInt8 g = (pixel >> 8) & 0xff; uInt8 b = (pixel >> 0) & 0xff; - uInt8 sum = (uInt8) (((float)r * 0.2989) + - ((float)g * 0.5870) + - ((float)b * 0.1140)); + uInt8 sum = uInt8((r * 0.2989) + (g * 0.5870) + (b * 0.1140)); palette[i][(j<<1)+1] = (sum << 16) + (sum << 8) + sum; } } diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index e468d3ece..d637c5c56 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -163,8 +163,8 @@ bool Controller::load(Serializer& in) myDigitalPinState[Six] = in.getBool(); // Input the analog pins - myAnalogPinValue[Five] = (Int32) in.getInt(); - myAnalogPinValue[Nine] = (Int32) in.getInt(); + myAnalogPinValue[Five] = in.getInt(); + myAnalogPinValue[Nine] = in.getInt(); } catch(...) { diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 6c82ac372..e9a2337ef 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -227,7 +227,7 @@ void EventHandler::poll(uInt64 time) // Handle continuous snapshots if(myContSnapshotInterval > 0 && (++myContSnapshotCounter % myContSnapshotInterval == 0)) - takeSnapshot((uInt32)time >> 10); // not quite milliseconds, but close enough + takeSnapshot(uInt32(time) >> 10); // not quite milliseconds, but close enough } } else if(myOverlay) @@ -441,7 +441,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state) else { buf << "Enabling shotshots in " << interval << " second intervals"; - interval *= (uInt32) myOSystem.frameRate(); + interval *= uInt32(myOSystem.frameRate()); } myOSystem.frameBuffer().showMessage(buf.str()); setContinuousSnapshots(interval); @@ -691,7 +691,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value) // Check for analog events, which are handled differently // We'll pass them off as Stelladaptor events, and let the controllers // handle it - switch((int)eventAxisNeg) + switch(int(eventAxisNeg)) { case Event::PaddleZeroAnalog: myEvent.set(Event::SALeftAxis0Value, value); @@ -1157,9 +1157,9 @@ void EventHandler::setActionMappings(EventMode mode) if(myKeyTable[j][mode] == event) { if(key == "") - key = key + nameForKey((StellaKey)j); + key = key + nameForKey(StellaKey(j)); else - key = key + ", " + nameForKey((StellaKey)j); + key = key + ", " + nameForKey(StellaKey(j)); } } @@ -1279,7 +1279,7 @@ void EventHandler::setKeymap() // Get event count, which should be the first int in the list buf >> value; - event = (Event::Type) value; + event = Event::Type(value); if(event == Event::LastType) while(buf >> value) map.push_back(value); @@ -1291,7 +1291,7 @@ void EventHandler::setKeymap() auto e = map.begin(); for(int mode = 0; mode < kNumModes; ++mode) for(int i = 0; i < KBDK_LAST; ++i) - myKeyTable[i][mode] = (Event::Type) *e++; + myKeyTable[i][mode] = Event::Type(*e++); } else { @@ -1326,7 +1326,7 @@ void EventHandler::setComboMap() int eventcount = 0; while(buf2 >> key && eventcount < kEventsPerCombo) { - myComboTable[combocount][eventcount] = (Event::Type) atoi(key.c_str()); + myComboTable[combocount][eventcount] = Event::Type(atoi(key.c_str())); ++eventcount; } ++combocount; diff --git a/src/emucore/EventJoyHandler.cxx b/src/emucore/EventJoyHandler.cxx index 21181975d..eedff9c0f 100644 --- a/src/emucore/EventJoyHandler.cxx +++ b/src/emucore/EventJoyHandler.cxx @@ -137,31 +137,31 @@ bool EventHandler::StellaJoystick::setMap(const string& mapString) // Parse axis/button/hat values getValues(items[1], map); - if((int)map.size() == numAxes * 2 * kNumModes) + if(int(map.size()) == numAxes * 2 * kNumModes) { // Fill the axes table with events auto event = map.begin(); for(int m = 0; m < kNumModes; ++m) for(int a = 0; a < numAxes; ++a) for(int k = 0; k < 2; ++k) - axisTable[a][k][m] = (Event::Type) *event++; + axisTable[a][k][m] = Event::Type(*event++); } getValues(items[2], map); - if((int)map.size() == numButtons * kNumModes) + if(int(map.size()) == numButtons * kNumModes) { auto event = map.begin(); for(int m = 0; m < kNumModes; ++m) for(int b = 0; b < numButtons; ++b) - btnTable[b][m] = (Event::Type) *event++; + btnTable[b][m] = Event::Type(*event++); } getValues(items[3], map); - if((int)map.size() == numHats * 4 * kNumModes) + if(int(map.size()) == numHats * 4 * kNumModes) { auto event = map.begin(); for(int m = 0; m < kNumModes; ++m) for(int h = 0; h < numHats; ++h) for(int k = 0; k < 4; ++k) - hatTable[h][k][m] = (Event::Type) *event++; + hatTable[h][k][m] = Event::Type(*event++); } return true; diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index e99b645c1..9af37a568 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -37,7 +37,7 @@ FBSurface::FBSurface() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const GUI::Rect& rect) const { - uInt8* src = (uInt8*) myPixels + rect.y() * myPitch + rect.x(); + uInt8* src = reinterpret_cast(myPixels + rect.y() * myPitch + rect.x()); if(rect.empty()) memcpy(buffer, src, width() * height() * 4); @@ -62,16 +62,16 @@ void FBSurface::hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color) { uInt32* buffer = myPixels + y * myPitch + x; while(x++ <= x2) - *buffer++ = (uInt32) myPalette[color]; + *buffer++ = uInt32(myPalette[color]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurface::vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color) { - uInt32* buffer = (uInt32*) myPixels + y * myPitch + x; + uInt32* buffer = static_cast(myPixels + y * myPitch + x); while(y++ <= y2) { - *buffer = (uInt32) myPalette[color]; + *buffer = uInt32(myPalette[color]); buffer += myPitch; } } @@ -124,7 +124,7 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, for(int x = 0; x < bbw; x++, mask >>= 1) if(ptr & mask) - buffer[x] = (uInt32) myPalette[color]; + buffer[x] = uInt32(myPalette[color]); buffer += myPitch; } @@ -141,7 +141,7 @@ void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, uInt32 mask = 0xF0000000; for(uInt32 x = 0; x < 8; ++x, mask >>= 4) if(bitmap[y] & mask) - buffer[x] = (uInt32) myPalette[color]; + buffer[x] = uInt32(myPalette[color]); buffer += myPitch; } @@ -153,7 +153,7 @@ void FBSurface::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels) uInt32* buffer = myPixels + ty * myPitch + tx; for(uInt32 i = 0; i < numpixels; ++i) - *buffer++ = (uInt32) data[i]; + *buffer++ = data[i]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index 8b4712128..ba9ff5eb2 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -95,6 +95,14 @@ class FilesystemNode virtual ~FilesystemNode() { } + /** + * Assignment operators. + */ + FilesystemNode(const FilesystemNode&) = default; + FilesystemNode(FilesystemNode&&) = default; + FilesystemNode& operator=(const FilesystemNode&) = default; + FilesystemNode& operator=(FilesystemNode&&) = default; + /** * Compare the name of this node to the name of another. Directories * go before normal files. @@ -271,6 +279,15 @@ class AbstractFSNode using ListMode = FilesystemNode::ListMode; public: + /** + * Assignment operators. + */ + AbstractFSNode() = default; + AbstractFSNode(const AbstractFSNode&) = default; + AbstractFSNode(AbstractFSNode&&) = default; + AbstractFSNode& operator=(const AbstractFSNode&) = default; + AbstractFSNode& operator=(AbstractFSNode&&) = default; + /** * Destructor. */ diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 3dd65139d..c5046333e 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -76,8 +76,8 @@ bool FrameBuffer::initialize() query_h = s.h; } // Various parts of the codebase assume a minimum screen size - myDesktopSize.w = BSPF_max(query_w, (uInt32)kFBMinW); - myDesktopSize.h = BSPF_max(query_h, (uInt32)kFBMinH); + myDesktopSize.w = BSPF_max(query_w, uInt32(kFBMinW)); + myDesktopSize.h = BSPF_max(query_h, uInt32(kFBMinH)); //////////////////////////////////////////////////////////////////// // Create fonts to draw text @@ -121,7 +121,7 @@ bool FrameBuffer::initialize() myLauncherFont = make_ptr(GUI::stellaDesc); // Determine possible TIA windowed zoom levels - uInt32 maxZoom = maxWindowSizeForScreen((uInt32)kTIAMinW, (uInt32)kTIAMinH, + uInt32 maxZoom = maxWindowSizeForScreen(uInt32(kTIAMinW), uInt32(kTIAMinH), myDesktopSize.w, myDesktopSize.h); // Figure our the smallest zoom level we can use @@ -194,7 +194,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, // Initialize video subsystem (make sure we get a valid mode) string pre_about = about(); const VideoMode& mode = getSavedVidMode(useFullscreen); - if(width <= (uInt32)mode.screen.w && height <= (uInt32)mode.screen.h) + if(width <= mode.screen.w && height <= mode.screen.h) { if(setVideoMode(myScreenTitle, mode)) { @@ -232,7 +232,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, myStatsMsg.surface = allocateSurface(myStatsMsg.w, myStatsMsg.h); if(!myMsg.surface) - myMsg.surface = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10); + myMsg.surface = allocateSurface(kFBMinW, font().getFontHeight()+10); // Print initial usage message, but only print it later if the status has changed if(myInitializedCount == 1) @@ -747,8 +747,8 @@ VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, zoom(z), description(desc) { - sw = BSPF_max(sw, (uInt32)FrameBuffer::kTIAMinW); - sh = BSPF_max(sh, (uInt32)FrameBuffer::kTIAMinH); + sw = BSPF_max(sw, uInt32(FrameBuffer::kTIAMinW)); + sh = BSPF_max(sh, uInt32(FrameBuffer::kTIAMinH)); iw = BSPF_min(iw, sw); ih = BSPF_min(ih, sh); int ix = (sw - iw) >> 1; @@ -761,7 +761,7 @@ VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, void VideoMode::applyAspectCorrection(uInt32 aspect, bool stretch) { // Width is modified by aspect ratio; other factors may be applied below - uInt32 iw = (uInt32)(float(image.width() * aspect) / 100.0); + uInt32 iw = uInt32(float(image.width() * aspect) / 100.0); uInt32 ih = image.height(); if(fsIndex != -1) @@ -794,8 +794,8 @@ void VideoMode::applyAspectCorrection(uInt32 aspect, bool stretch) stretchFactor = float(int(screen.h / bh) * bh) / ih; } } - iw = (uInt32) (stretchFactor * iw); - ih = (uInt32) (stretchFactor * ih); + iw = uInt32(stretchFactor * iw); + ih = uInt32(stretchFactor * ih); } else { @@ -805,8 +805,8 @@ void VideoMode::applyAspectCorrection(uInt32 aspect, bool stretch) } // Now re-calculate the dimensions - iw = BSPF_min(iw, (uInt32)screen.w); - ih = BSPF_min(ih, (uInt32)screen.h); + iw = BSPF_min(iw, screen.w); + ih = BSPF_min(ih, screen.h); image.moveTo((screen.w - iw) >> 1, (screen.h - ih) >> 1); image.setWidth(iw); @@ -850,14 +850,14 @@ bool FrameBuffer::VideoModeList::empty() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 FrameBuffer::VideoModeList::size() const { - return (uInt32)myModeList.size(); + return myModeList.size(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::VideoModeList::previous() { --myIdx; - if(myIdx < 0) myIdx = (int)myModeList.size() - 1; + if(myIdx < 0) myIdx = int(myModeList.size()) - 1; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index a2b1e7e57..b8d0f45aa 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -449,6 +449,11 @@ class FrameBuffer VideoModeList(); ~VideoModeList(); + VideoModeList(const VideoModeList&) = default; + VideoModeList(VideoModeList&&) = default; + VideoModeList& operator=(const VideoModeList&) = default; + VideoModeList& operator=(VideoModeList&&) = default; + void add(const VideoMode& mode); void clear(); diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 7d575b836..e6357d9c5 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -64,7 +64,7 @@ OSystem::OSystem() myQuitLoop(false) { // Calculate startup time - myMillisAtStart = (uInt32)(time(NULL) * 1000); + myMillisAtStart = uInt32(time(NULL) * 1000); // Get built-in features #ifdef SOUND_SUPPORT @@ -85,8 +85,8 @@ OSystem::OSystem() SDL_version ver; SDL_GetVersion(&ver); - info << "Build " << STELLA_BUILD << ", using SDL " << (int)ver.major - << "." << (int)ver.minor << "."<< (int)ver.patch + info << "Build " << STELLA_BUILD << ", using SDL " << int(ver.major) + << "." << int(ver.minor) << "."<< int(ver.patch) << " [" << BSPF_ARCH << "]"; myBuildInfo = info.str(); @@ -236,7 +236,7 @@ void OSystem::setFramerate(float framerate) if(framerate > 0.0) { myDisplayFrameRate = framerate; - myTimePerFrame = (uInt32)(1000000.0 / myDisplayFrameRate); + myTimePerFrame = uInt32(1000000.0 / myDisplayFrameRate); } } @@ -458,7 +458,7 @@ void OSystem::logMessage(const string& message, uInt8 level) cout << message << endl << flush; myLogMessages += message + "\n"; } - else if(level <= (uInt8)mySettings->getInt("loglevel")) + else if(level <= uInt8(mySettings->getInt("loglevel"))) { if(mySettings->getBool("logtoconsole")) cout << message << endl << flush; diff --git a/src/emucore/Paddles.cxx b/src/emucore/Paddles.cxx index 2a8f830a6..e7f21916f 100644 --- a/src/emucore/Paddles.cxx +++ b/src/emucore/Paddles.cxx @@ -269,14 +269,12 @@ void Paddles::update() int sa_yaxis = myEvent.get(myP1AxisValue); if(abs(myLastAxisX - sa_xaxis) > 10) { - myAnalogPinValue[Nine] = (Int32)(1400000 * - (float)(32767 - (Int16)sa_xaxis) / 65536.0); + myAnalogPinValue[Nine] = Int32(1400000 * (32767 - Int16(sa_xaxis)) / 65536.0); sa_changed = true; } if(abs(myLastAxisY - sa_yaxis) > 10) { - myAnalogPinValue[Five] = (Int32)(1400000 * - (float)(32767 - (Int16)sa_yaxis) / 65536.0); + myAnalogPinValue[Five] = Int32(1400000 * (32767 - Int16(sa_yaxis)) / 65536.0); sa_changed = true; } myLastAxisX = sa_xaxis; @@ -373,10 +371,10 @@ void Paddles::update() // Only change state if the charge has actually changed if(myCharge[1] != myLastCharge[1]) myAnalogPinValue[Five] = - (Int32)(1400000 * (myCharge[1] / float(TRIGRANGE))); + Int32(1400000 * (myCharge[1] / float(TRIGRANGE))); if(myCharge[0] != myLastCharge[0]) myAnalogPinValue[Nine] = - (Int32)(1400000 * (myCharge[0] / float(TRIGRANGE))); + Int32(1400000 * (myCharge[0] / float(TRIGRANGE))); myLastCharge[1] = myCharge[1]; myLastCharge[0] = myCharge[0]; diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index 7b2197517..771523bc6 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -119,7 +119,7 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties, { for(int p = 0; p < LastPropType; ++p) if(DefProps[i][p][0] != 0) - properties.set((PropertyType)p, DefProps[i][p]); + properties.set(PropertyType(p), DefProps[i][p]); found = true; break; @@ -207,7 +207,7 @@ void PropertiesSet::print() const properties.setDefaults(); for(int p = 0; p < LastPropType; ++p) if(DefProps[i][p][0] != 0) - properties.set((PropertyType)p, DefProps[i][p]); + properties.set(PropertyType(p), DefProps[i][p]); list.insert(make_pair(DefProps[i][Cartridge_MD5], properties)); } diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index fc5c9f59a..7486c61c4 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -99,14 +99,14 @@ uInt8 Serializer::getByte() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::getByteArray(uInt8* array, uInt32 size) const { - myStream->read((char*)array, size); + myStream->read(reinterpret_cast(array), size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt16 Serializer::getShort() const { uInt16 val = 0; - myStream->read((char*)&val, sizeof(uInt16)); + myStream->read(reinterpret_cast(&val), sizeof(uInt16)); return val; } @@ -114,14 +114,14 @@ uInt16 Serializer::getShort() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::getShortArray(uInt16* array, uInt32 size) const { - myStream->read((char*)array, sizeof(uInt16)*size); + myStream->read(reinterpret_cast(array), sizeof(uInt16)*size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 Serializer::getInt() const { uInt32 val = 0; - myStream->read((char*)&val, sizeof(uInt32)); + myStream->read(reinterpret_cast(&val), sizeof(uInt32)); return val; } @@ -129,7 +129,7 @@ uInt32 Serializer::getInt() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::getIntArray(uInt32* array, uInt32 size) const { - myStream->read((char*)array, sizeof(uInt32)*size); + myStream->read(reinterpret_cast(array), sizeof(uInt32)*size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -152,43 +152,43 @@ bool Serializer::getBool() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putByte(uInt8 value) { - myStream->write((char*)&value, 1); + myStream->write(reinterpret_cast(&value), 1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putByteArray(const uInt8* array, uInt32 size) { - myStream->write((char*)array, size); + myStream->write(reinterpret_cast(array), size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putShort(uInt16 value) { - myStream->write((char*)&value, sizeof(uInt16)); + myStream->write(reinterpret_cast(&value), sizeof(uInt16)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putShortArray(const uInt16* array, uInt32 size) { - myStream->write((char*)array, sizeof(uInt16)*size); + myStream->write(reinterpret_cast(array), sizeof(uInt16)*size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putInt(uInt32 value) { - myStream->write((char*)&value, sizeof(uInt32)); + myStream->write(reinterpret_cast(&value), sizeof(uInt32)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putIntArray(const uInt32* array, uInt32 size) { - myStream->write((char*)array, sizeof(uInt32)*size); + myStream->write(reinterpret_cast(array), sizeof(uInt32)*size); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putString(const string& str) { - int len = (int)str.length(); + int len = int(str.length()); putInt(len); myStream->write(str.data(), len); } diff --git a/src/emucore/Sound.hxx b/src/emucore/Sound.hxx index cf86af06e..d0468acaa 100644 --- a/src/emucore/Sound.hxx +++ b/src/emucore/Sound.hxx @@ -44,7 +44,7 @@ class Sound : public Serializable /** Destructor */ - virtual ~Sound() { }; + virtual ~Sound() { } public: /** diff --git a/src/gui/ComboDialog.cxx b/src/gui/ComboDialog.cxx index d62d94e3b..9f6a42061 100644 --- a/src/gui/ComboDialog.cxx +++ b/src/gui/ComboDialog.cxx @@ -114,13 +114,13 @@ void ComboDialog::loadConfig() { StringList events = instance().eventHandler().getComboListForEvent(myComboEvent); - int size = BSPF_min((int)events.size(), 8); - for(int i = 0; i < size; ++i) + uInt32 size = BSPF_min(uInt32(events.size()), 8u); + for(uInt32 i = 0; i < size; ++i) myEvents[i]->setSelected("", events[i]); // Fill any remaining items to 'None' if(size < 8) - for(int i = size; i < 8; ++i) + for(uInt32 i = size; i < 8; ++i) myEvents[i]->setSelected("None", "-1"); } diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index 951f5e02b..fb9ffb310 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -67,7 +67,7 @@ void ContextMenu::addItems(const VariantList& items) _h = 1; // recalculate this in ::recalc() _scrollUpColor = _firstEntry > 0 ? kScrollColor : kColor; - _scrollDnColor = (_firstEntry + _numEntries < (int)_entries.size()) ? + _scrollDnColor = (_firstEntry + _numEntries < int(_entries.size())) ? kScrollColor : kColor; } @@ -115,8 +115,8 @@ void ContextMenu::recalc(const GUI::Rect& image) } else { - _numEntries = (int)_entries.size(); - _h = (int)_entries.size() * _rowHeight + 4; + _numEntries = int(_entries.size()); + _h = int(_entries.size()) * _rowHeight + 4; _showScroll = false; } _isScrolling = false; @@ -125,7 +125,7 @@ void ContextMenu::recalc(const GUI::Rect& image) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::setSelectedIndex(int idx) { - if(idx >= 0 && idx < (int)_entries.size()) + if(idx >= 0 && idx < int(_entries.size())) _selectedItem = idx; else _selectedItem = -1; @@ -160,7 +160,7 @@ void ContextMenu::setSelected(const Variant& tag, const Variant& defaultTag) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::setSelectedMax() { - setSelectedIndex((int)_entries.size() - 1); + setSelectedIndex(int(_entries.size()) - 1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -201,7 +201,7 @@ bool ContextMenu::sendSelectionUp() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool ContextMenu::sendSelectionDown() { - if(isVisible() || _selectedItem >= (int)_entries.size() - 1) + if(isVisible() || _selectedItem >= int(_entries.size()) - 1) return false; _selectedItem++; @@ -226,7 +226,7 @@ bool ContextMenu::sendSelectionLast() if(isVisible()) return false; - _selectedItem = (int)_entries.size() - 1; + _selectedItem = int(_entries.size()) - 1; sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); return true; } @@ -421,12 +421,12 @@ void ContextMenu::moveDown() // Otherwise, the offset should increase by 1 if(_selectedOffset == _numEntries) scrollDown(); - else if(_selectedOffset < (int)_entries.size()) + else if(_selectedOffset < int(_entries.size())) drawCurrentSelection(_selectedOffset+1); } else { - if(_selectedOffset < (int)_entries.size() - 1) + if(_selectedOffset < int(_entries.size()) - 1) drawCurrentSelection(_selectedOffset+1); } } @@ -443,7 +443,7 @@ void ContextMenu::movePgUp() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::movePgDown() { - if(_firstEntry == (int)(_entries.size() - _numEntries)) + if(_firstEntry == int(_entries.size() - _numEntries)) moveToLast(); else scrollDown(_numEntries); @@ -462,7 +462,7 @@ void ContextMenu::moveToFirst() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::moveToLast() { - _firstEntry = (int)_entries.size() - _numEntries; + _firstEntry = int(_entries.size()) - _numEntries; _scrollUpColor = kScrollColor; _scrollDnColor = kColor; @@ -472,7 +472,7 @@ void ContextMenu::moveToLast() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::moveToSelected() { - if(_selectedItem < 0 || _selectedItem >= (int)_entries.size()) + if(_selectedItem < 0 || _selectedItem >= int(_entries.size())) return; // First jump immediately to the item @@ -481,7 +481,7 @@ void ContextMenu::moveToSelected() // Now check if we've gone past the current 'window' size, and scale // back accordingly - int max_offset = (int)_entries.size() - _numEntries; + int max_offset = int(_entries.size()) - _numEntries; if(_firstEntry > max_offset) { offset = _firstEntry - max_offset; @@ -510,7 +510,7 @@ void ContextMenu::scrollUp(int distance) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::scrollDown(int distance) { - int max_offset = (int)_entries.size() - _numEntries; + int max_offset = int(_entries.size()) - _numEntries; if(_firstEntry == max_offset) return; diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 288818873..6daccca50 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -153,7 +153,7 @@ void Dialog::addToFocusList(WidgetArray& list) void Dialog::addToFocusList(WidgetArray& list, TabWidget* w, int tabId) { // Only add the list if the tab actually exists - if(!w || w->getID() < 0 || (uInt32)w->getID() >= _myTabList.size()) + if(!w || w->getID() < 0 || uInt32(w->getID()) >= _myTabList.size()) return; assert(w == _myTabList[w->getID()].widget); @@ -221,7 +221,7 @@ void Dialog::buildCurrentFocusList(int tabID) // Remember which tab item previously had focus, if applicable // This only applies if this method was called for a tab change Widget* tabFocusWidget = nullptr; - if(tabID >= 0 && tabID < (int)_myTabList.size()) + if(tabID >= 0 && tabID < int(_myTabList.size())) { // Save focus in previously selected tab column, // and get focus for new tab column @@ -611,7 +611,7 @@ void Dialog::getTabIdForWidget(Widget* w) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Dialog::cycleTab(int direction) { - if(_tabID >= 0 && _tabID < (int)_myTabList.size()) + if(_tabID >= 0 && _tabID < int(_myTabList.size())) { _myTabList[_tabID].widget->cycleTab(direction); return true; @@ -708,7 +708,7 @@ void Dialog::TabFocus::appendFocusList(WidgetArray& list) { int active = widget->getActiveTab(); - if(active >= 0 && active < (int)focus.size()) + if(active >= 0 && active < int(focus.size())) Vec::append(list, focus[active].list); } diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 71174d1cb..044ebae2a 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -132,6 +132,11 @@ class Dialog : public GuiObject Focus(Widget* w = nullptr); virtual ~Focus(); + + Focus(const Focus&) = default; + Focus(Focus&&) = default; + Focus& operator=(const Focus&) = default; + Focus& operator=(Focus&&) = default; }; using FocusList = vector; @@ -143,6 +148,11 @@ class Dialog : public GuiObject TabFocus(TabWidget* w = nullptr); virtual ~TabFocus(); + TabFocus(const TabFocus&) = default; + TabFocus(TabFocus&&) = default; + TabFocus& operator=(const TabFocus&) = default; + TabFocus& operator=(TabFocus&&) = default; + void appendFocusList(WidgetArray& list); void saveCurrentFocus(Widget* w); Widget* getNewFocus(); diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 7e6d2bc96..f3b464b17 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -59,7 +59,7 @@ void EditableWidget::setText(const string& str, bool) if(_filter(tolower(c))) _editString.push_back(c); - _caretPos = (int)_editString.size(); + _caretPos = _editString.size(); _editScrollOffset = (_font.getStringWidth(_editString) - (getEditRect().width())); if (_editScrollOffset < 0) @@ -153,7 +153,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod) case KBDK_RIGHT: if(instance().eventHandler().kbdControl(mod)) dirty = specialKeys(key); - else if(_caretPos < (int)_editString.size()) + else if(_caretPos < int(_editString.size())) dirty = setCaretPos(_caretPos + 1); break; @@ -162,7 +162,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case KBDK_END: - dirty = setCaretPos((int)_editString.size()); + dirty = setCaretPos(int(_editString.size())); break; default: @@ -215,7 +215,7 @@ void EditableWidget::drawCaret() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EditableWidget::setCaretPos(int newPos) { - assert(newPos >= 0 && newPos <= (int)_editString.size()); + assert(newPos >= 0 && newPos <= int(_editString.size())); _caretPos = newPos; return adjustOffset(); @@ -275,7 +275,7 @@ bool EditableWidget::specialKeys(StellaKey key) break; case KBDK_E: - setCaretPos((int)_editString.size()); + setCaretPos(_editString.size()); break; case KBDK_D: @@ -359,7 +359,7 @@ bool EditableWidget::killLine(int direction) } else if(direction == 1) // erase from current position to end of line { - int count = (int)_editString.size() - _caretPos; + int count = int(_editString.size()) - _caretPos; if(count > 0) { for (int i = 0; i < count; i++) @@ -429,7 +429,7 @@ bool EditableWidget::moveWord(int direction) } else if(direction == +1) // move to first character of next word { - while (currentPos < (int)_editString.size()) + while (currentPos < int(_editString.size())) { if (_editString[currentPos - 1] == ' ') { diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 7b6aa11fd..f1fa7668a 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -78,7 +78,7 @@ void FileListWidget::setLocation(const FilesystemNode& node, string select) // Now fill the list widget with the contents of the GameList StringList l; - for(int i = 0; i < (int) _gameList.size(); ++i) + for(uInt32 i = 0; i < _gameList.size(); ++i) l.push_back(_gameList.name(i)); setList(l); diff --git a/src/gui/Font.cxx b/src/gui/Font.cxx index a9a013d9b..66c47fed1 100644 --- a/src/gui/Font.cxx +++ b/src/gui/Font.cxx @@ -53,7 +53,7 @@ int Font::getStringWidth(const string& str) const { // If no width table is specified, use the maximum width if(!myFontDesc.width) - return (int)(myFontDesc.maxwidth * str.size()); + return myFontDesc.maxwidth * str.size(); else { int space = 0; diff --git a/src/gui/GameList.hxx b/src/gui/GameList.hxx index 7a9a1aa11..4b392211c 100644 --- a/src/gui/GameList.hxx +++ b/src/gui/GameList.hxx @@ -45,13 +45,13 @@ class GameList void setMd5(uInt32 i, const string& md5) { myArray[i]._md5 = md5; } - uInt32 size() const { return (uInt32)myArray.size(); } + uInt32 size() const { return myArray.size(); } void clear() { myArray.clear(); } void appendGame(const string& name, const string& path, const string& md5, bool isDir = false) { myArray.emplace_back(name, path, md5, isDir); - }; + } void sortByName(); private: diff --git a/src/gui/Rect.hxx b/src/gui/Rect.hxx index 336559668..447a47cce 100644 --- a/src/gui/Rect.hxx +++ b/src/gui/Rect.hxx @@ -114,6 +114,7 @@ struct Rect Rect() : top(0), left(0), bottom(0), right(0) { } Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) { } + Rect& operator=(const Rect&) = default; Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) { } Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) { } Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2)