diff --git a/src/cheat/BankRomCheat.cxx b/src/cheat/BankRomCheat.cxx index 8c2c677be..16c3a9dbb 100644 --- a/src/cheat/BankRomCheat.cxx +++ b/src/cheat/BankRomCheat.cxx @@ -33,7 +33,7 @@ BankRomCheat::BankRomCheat(OSystem& os, string_view name, string_view code) count = static_cast(BSPF::stoi<16>(myCode.substr(7, 1)) + 1); // Back up original data; we need this if the cheat is ever disabled - for(int i = 0; i < count; ++i) + for(int i = 0; std::cmp_less(i, count); ++i) savedRom[i] = myOSystem.console().cartridge().peek(address + i); } @@ -50,7 +50,7 @@ bool BankRomCheat::disable() const int oldBank = myOSystem.console().cartridge().getBank(address); myOSystem.console().cartridge().bank(bank); - for(int i = 0; i < count; ++i) + for(int i = 0; std::cmp_less(i, count); ++i) myOSystem.console().cartridge().patch(address + i, savedRom[i]); myOSystem.console().cartridge().bank(oldBank); @@ -66,7 +66,7 @@ void BankRomCheat::evaluate() const int oldBank = myOSystem.console().cartridge().getBank(address); myOSystem.console().cartridge().bank(bank); - for(int i = 0; i < count; ++i) + for(int i = 0; std::cmp_less(i, count); ++i) myOSystem.console().cartridge().patch(address + i, value); myOSystem.console().cartridge().bank(oldBank); diff --git a/src/cheat/CheetahCheat.cxx b/src/cheat/CheetahCheat.cxx index 33f6316d8..cbc1395f3 100644 --- a/src/cheat/CheetahCheat.cxx +++ b/src/cheat/CheetahCheat.cxx @@ -28,7 +28,7 @@ CheetahCheat::CheetahCheat(OSystem& os, string_view name, string_view code) count{static_cast(BSPF::stoi<16>(code.substr(5, 1)) + 1)} { // Back up original data; we need this if the cheat is ever disabled - for(int i = 0; i < count; ++i) + for(uInt8 i = 0; i < count; ++i) savedRom[i] = myOSystem.console().cartridge().peek(address + i); } @@ -42,7 +42,7 @@ bool CheetahCheat::enable() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CheetahCheat::disable() { - for(int i = 0; i < count; ++i) + for(uInt8 i = 0; i < count; ++i) myOSystem.console().cartridge().patch(address + i, savedRom[i]); return myEnabled = false; @@ -53,7 +53,7 @@ void CheetahCheat::evaluate() { if(!myEnabled) { - for(int i = 0; i < count; ++i) + for(uInt8 i = 0; i < count; ++i) myOSystem.console().cartridge().patch(address + i, value); myEnabled = true; diff --git a/src/common/FBBackendSDL2.cxx b/src/common/FBBackendSDL2.cxx index 58900018f..2cd96312b 100644 --- a/src/common/FBBackendSDL2.cxx +++ b/src/common/FBBackendSDL2.cxx @@ -287,8 +287,9 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode, int w{0}, h{0}; SDL_GetWindowSize(myWindow, &w, &h); - if(d != displayIndex || static_cast(w) != mode.screenS.w || - static_cast(h) != mode.screenS.h || adaptRefresh) + if(d != displayIndex || + std::cmp_not_equal(w, mode.screenS.w) || + std::cmp_not_equal(h, mode.screenS.h) || adaptRefresh) { // Renderer has to be destroyed *before* the window gets destroyed to avoid memory leaks SDL_DestroyRenderer(myRenderer); diff --git a/src/common/FBSurfaceSDL2.hxx b/src/common/FBSurfaceSDL2.hxx index c53ed44b6..c601c914d 100644 --- a/src/common/FBSurfaceSDL2.hxx +++ b/src/common/FBSurfaceSDL2.hxx @@ -70,7 +70,7 @@ class FBSurfaceSDL2 : public FBSurface private: bool setSrcPosInternal(uInt32 x, uInt32 y) { - if(x != static_cast(mySrcR.x) || y != static_cast(mySrcR.y)) + if(std::cmp_not_equal(x, mySrcR.x) || std::cmp_not_equal(y, mySrcR.y)) { mySrcR.x = x; mySrcR.y = y; mySrcGUIR.moveTo(x, y); @@ -79,7 +79,7 @@ class FBSurfaceSDL2 : public FBSurface return false; } bool setSrcSizeInternal(uInt32 w, uInt32 h) { - if(w != static_cast(mySrcR.w) || h != static_cast(mySrcR.h)) + if(std::cmp_not_equal(w, mySrcR.w) || std::cmp_not_equal(h, mySrcR.h)) { mySrcR.w = w; mySrcR.h = h; mySrcGUIR.setWidth(w); mySrcGUIR.setHeight(h); @@ -88,7 +88,7 @@ class FBSurfaceSDL2 : public FBSurface return false; } bool setDstPosInternal(uInt32 x, uInt32 y) { - if(x != static_cast(myDstR.x) || y != static_cast(myDstR.y)) + if(std::cmp_not_equal(x, myDstR.x) || std::cmp_not_equal(y, myDstR.y)) { myDstR.x = x; myDstR.y = y; myDstGUIR.moveTo(x, y); @@ -97,7 +97,7 @@ class FBSurfaceSDL2 : public FBSurface return false; } bool setDstSizeInternal(uInt32 w, uInt32 h) { - if(w != static_cast(myDstR.w) || h != static_cast(myDstR.h)) + if(std::cmp_not_equal(w, myDstR.w) || std::cmp_not_equal(h, myDstR.h)) { myDstR.w = w; myDstR.h = h; myDstGUIR.setWidth(w); myDstGUIR.setHeight(h); diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index ebdb6d2c5..f1d4e438a 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -488,8 +488,7 @@ void SoundSDL2::WavHandlerSDL2::processWav(uInt8* stream, uInt32 len) SDL_assert(cvt.needed); // Obviously, this one is always needed. cvt.len = len * mySpec.channels; // Mono 8 bit sample frames - if(!myCvtBuffer || - myCvtBufferSize < static_cast(cvt.len * cvt.len_mult)) + if(!myCvtBuffer || std::cmp_less(myCvtBufferSize, cvt.len * cvt.len_mult)) { myCvtBufferSize = cvt.len * cvt.len_mult; myCvtBuffer = make_unique(myCvtBufferSize); diff --git a/src/common/StaggeredLogger.cxx b/src/common/StaggeredLogger.cxx index 966710ca8..41aff6371 100644 --- a/src/common/StaggeredLogger.cxx +++ b/src/common/StaggeredLogger.cxx @@ -116,7 +116,9 @@ void StaggeredLogger::startInterval() Int64 msecSinceLastIntervalEnd = duration_cast>(now - myLastIntervalEndTimestamp).count(); - while (msecSinceLastIntervalEnd > myCooldownTime && myCurrentIntervalFactor > 1) { + while (std::cmp_greater(msecSinceLastIntervalEnd, myCooldownTime) && + myCurrentIntervalFactor > 1) + { msecSinceLastIntervalEnd -= myCooldownTime; decreaseInterval(); } diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 0f4ab5a60..6dc65c52d 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -634,6 +634,7 @@ string CartDebug::uniqueLabel(const string& label) string uniqueLabel = label; int count = 0; + // TODO: does find return multiple items?? while(myUserAddresses.find(uniqueLabel) != myUserAddresses.end()) uniqueLabel = label + "." + std::to_string(++count); @@ -1113,7 +1114,7 @@ string CartDebug::saveDisassembly(string path) // prepare for switching banks uInt32 origin = 0; - for(int bank = 0; bank < romBankCount; ++bank) + for(int bank = 0; std::cmp_less(bank, romBankCount); ++bank) { // TODO: not every CartDebugWidget does it like that, we need a method cart.unlockHotspots(); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index f263ea855..fe89a6419 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -107,7 +107,7 @@ string DebuggerParser::run(string_view command) getArgs(command, verb); commandResult.str(""); - for(int i = 0; i < static_cast(commands.size()); ++i) + for(int i = 0; std::cmp_less(i, commands.size()); ++i) { if(BSPF::equalsIgnoreCase(verb, commands[i].cmdString)) { @@ -205,31 +205,31 @@ int DebuggerParser::decipher_arg(string_view str) bin=false; dec=false; } - if(arg.substr(0, 1) == "*") { + if(arg.starts_with("*")) { derefByte = true; arg.erase(0, 1); - } else if(arg.substr(0, 1) == "@") { + } else if(arg.starts_with("@")) { derefWord = true; arg.erase(0, 1); } - if(arg.substr(0, 1) == "<") { + if(arg.starts_with("<")) { lobyte = true; arg.erase(0, 1); - } else if(arg.substr(0, 1) == ">") { + } else if(arg.starts_with(">")) { hibyte = true; arg.erase(0, 1); } - if(arg.substr(0, 1) == "\\") { + if(arg.starts_with("\\")) { dec = false; bin = true; arg.erase(0, 1); - } else if(arg.substr(0, 1) == "#") { + } else if(arg.starts_with("#")) { dec = true; bin = false; arg.erase(0, 1); - } else if(arg.substr(0, 1) == "$") { + } else if(arg.starts_with("$")) { dec = false; bin = false; arg.erase(0, 1); @@ -1212,7 +1212,7 @@ void DebuggerParser::executeDelTrap() void DebuggerParser::executeDelWatch() { const int which = args[0] - 1; - if(which >= 0 && which < static_cast(myWatches.size())) + if(which >= 0 && std::cmp_less(which, myWatches.size())) { Vec::removeAt(myWatches, which); commandResult << "removed watch"; @@ -2028,7 +2028,7 @@ void DebuggerParser::executeRunToPc() // Update romlist to point to current PC const int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc()); - done = (pcline >= 0) && (list[pcline].address == args[0]); + done = (pcline >= 0) && std::cmp_equal(list[pcline].address, args[0]); progress.incProgress(); ++count; } while(!done && !progress.isCancelled()); @@ -2365,7 +2365,7 @@ void DebuggerParser::executeTimer() for(uInt32 i = 0; i < argCount; ++i) { - if(static_cast(args[i]) >= std::max(0x80U, romBankCount - 1)) + if(std::cmp_greater_equal(args[i], std::max(0x80U, romBankCount - 1))) { if(numAddrs == 2) { @@ -2381,7 +2381,7 @@ void DebuggerParser::executeTimer() outputCommandError("too many bank arguments", myCommand); return; } - if(static_cast(args[i]) >= romBankCount) + if(std::cmp_greater_equal(args[i], romBankCount)) { commandResult << red("invalid bank"); return; diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index ba1d5b27e..e979cc5eb 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -73,7 +73,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // Add reserved line equates ostringstream reservedLabel; - for (int k = 0; k <= myAppData.end; k++) { + for (int k = 0; std::cmp_less_equal(k, myAppData.end); k++) { if ((myLabels[k] & (Device::REFERENCED | Device::VALID_ENTRY)) == Device::REFERENCED) { // If we have a piece of code referenced somewhere else, but cannot // locate the label in code (i.e because the address is inside of a @@ -718,7 +718,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses) // Stella itself can provide hints on whether an address has ever // been referenced as CODE - while (myAddressQueue.empty() && codeAccessPoint <= myAppData.end) { + while (myAddressQueue.empty() && std::cmp_less_equal(codeAccessPoint, myAppData.end)) { if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & Device::CODE) && !(myLabels[codeAccessPoint & myAppData.end] & Device::CODE)) { myAddressQueue.push(codeAccessPoint + myOffset); @@ -730,7 +730,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses) duplicateFound = !myAddressQueue.empty() && (myAddressQueue.front() == lastPC); // TODO: check! } // while - for (int k = 0; k <= myAppData.end; k++) { + for (int k = 0; std::cmp_less_equal(k, myAppData.end); k++) { // Let the emulation core know about tentative code if (checkBit(k, Device::CODE) && !(Debugger::debugger().getAccessFlags(k + myOffset) & Device::CODE) @@ -938,8 +938,8 @@ DiStella::AddressType DiStella::mark(uInt32 address, uInt16 mask, bool directive else if(type == CartDebug::AddrType::ZPRAM && myOffset != 0) { return AddressType::ZP_RAM; } - else if(address >= static_cast(myOffset) && - address <= static_cast(myAppData.end + myOffset)) { + else if(std::cmp_greater_equal(address, myOffset) && + std::cmp_less_equal(address, myAppData.end + myOffset)) { myLabels[address - myOffset] = myLabels[address - myOffset] | mask; if(directive) myDirectives[address - myOffset] = mask; diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 48e4c37ba..4a6e9d9d2 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -1190,7 +1190,7 @@ string TIADebug::toString() // build up output, then return it. buf << std::setfill(' ') << std::left << decWithLabel("scanline", myTIA.scanlines(), - static_cast(myTIA.scanlines()) != oldState.info[4]) << " " + std::cmp_not_equal(myTIA.scanlines(), oldState.info[4])) << " " << boolWithLabel("vsync", vsync(), state.vsb[0] != oldState.vsb[0]) << " " << boolWithLabel("vblank", vblank(), diff --git a/src/debugger/gui/Cart3EPlusWidget.cxx b/src/debugger/gui/Cart3EPlusWidget.cxx index 1dc465f62..c45fface3 100644 --- a/src/debugger/gui/Cart3EPlusWidget.cxx +++ b/src/debugger/gui/Cart3EPlusWidget.cxx @@ -162,8 +162,9 @@ void Cartridge3EPlusWidget::handleCommand(CommandSender* sender, const bool isROM = myBankType[segment]->getSelectedTag() == "ROM"; const int bank = myBankWidgets[segment]->getSelected(); - myBankCommit[segment]->setEnabled((isROM && bank < myCart.romBankCount()) - || (!isROM && bank < myCart.ramBankCount())); + myBankCommit[segment]->setEnabled( + (isROM && std::cmp_less(bank, myCart.romBankCount())) || + (!isROM && std::cmp_less(bank, myCart.ramBankCount()))); break; } case kChangeBank: @@ -197,7 +198,7 @@ void Cartridge3EPlusWidget::updateUIState() { // Set description for each 1K segment state (@ each index) // Set contents for actual banks number and type (@ each even index) - for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg) + for(int seg = 0; std::cmp_less(seg, myCart3EP.myBankSegs); ++seg) { const uInt16 bank = myCart.getSegmentBank(seg); const size_t bank_off = static_cast(seg) * 2; diff --git a/src/debugger/gui/CartBUSWidget.cxx b/src/debugger/gui/CartBUSWidget.cxx index 4c234be16..699cb43ab 100644 --- a/src/debugger/gui/CartBUSWidget.cxx +++ b/src/debugger/gui/CartBUSWidget.cxx @@ -367,8 +367,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); - changed.push_back(myCart.myMusicCounters[i] != - static_cast(myOldState.mcounters[i])); + changed.push_back(std::cmp_not_equal(myCart.myMusicCounters[i], + myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -376,8 +376,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); - changed.push_back(myCart.myMusicFrequencies[i] != - static_cast(myOldState.mfreqs[i])); + changed.push_back(std::cmp_not_equal(myCart.myMusicFrequencies[i], + myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); @@ -385,8 +385,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); - changed.push_back((myCart.getWaveform(i) >> 5) != - static_cast(myOldState.mwaves[i])); + changed.push_back(std::cmp_not_equal(myCart.getWaveform(i) >> 5, + myOldState.mwaves[i])); } myMusicWaveforms->setList(alist, vlist, changed); @@ -394,8 +394,8 @@ void CartridgeBUSWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); - changed.push_back((myCart.getWaveformSize(i)) != - static_cast(myOldState.mwavesizes[i])); + changed.push_back(std::cmp_not_equal(myCart.getWaveformSize(i), + myOldState.mwavesizes[i])); } myMusicWaveformSizes->setList(alist, vlist, changed); @@ -403,8 +403,8 @@ void CartridgeBUSWidget::loadConfig() { alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.getSample()); - changed.push_back((myCart.getSample()) != - static_cast(myOldState.samplepointer[0])); + changed.push_back(std::cmp_not_equal(myCart.getSample(), + myOldState.samplepointer[0])); mySamplePointer->setList(alist, vlist, changed); } diff --git a/src/debugger/gui/CartCDFWidget.cxx b/src/debugger/gui/CartCDFWidget.cxx index ad0c58b98..056917d40 100644 --- a/src/debugger/gui/CartCDFWidget.cxx +++ b/src/debugger/gui/CartCDFWidget.cxx @@ -234,7 +234,7 @@ void CartridgeCDFWidget::saveOldState() if (isCDFJplus()) myOldState.fastfetchoffset.push_back(myCart.myRAM[myCart.myFastFetcherOffset]); - for(uInt32 i = 0; i < static_cast((isCDFJ() || isCDFJplus()) ? 35 : 34); ++i) + for(uInt32 i = 0; i < (isCDFJ() || isCDFJplus() ? 35U : 34U); ++i) { // Pointers are stored as: // PPPFF--- @@ -319,7 +319,7 @@ void CartridgeCDFWidget::loadConfig() alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.getDatastreamPointer(0x20) >> ds_shift); - changed.push_back(static_cast(myCart.getDatastreamPointer(0x20)) != myOldState.datastreampointers[0x20]); + changed.push_back(std::cmp_not_equal(myCart.getDatastreamPointer(0x20), myOldState.datastreampointers[0x20])); myCommandStreamPointer->setList(alist, vlist, changed); alist.clear(); vlist.clear(); changed.clear(); @@ -343,7 +343,7 @@ void CartridgeCDFWidget::loadConfig() alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.getDatastreamIncrement(0x20)); - changed.push_back(static_cast(myCart.getDatastreamIncrement(0x20)) != myOldState.datastreamincrements[0x20]); + changed.push_back(std::cmp_not_equal(myCart.getDatastreamIncrement(0x20), myOldState.datastreamincrements[0x20])); myCommandStreamIncrement->setList(alist, vlist, changed); alist.clear(); vlist.clear(); changed.clear(); @@ -359,8 +359,8 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); - changed.push_back(myCart.myMusicCounters[i] != - static_cast(myOldState.mcounters[i])); + changed.push_back(std::cmp_not_equal(myCart.myMusicCounters[i], + myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -368,8 +368,8 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); - changed.push_back(myCart.myMusicFrequencies[i] != - static_cast(myOldState.mfreqs[i])); + changed.push_back(std::cmp_not_equal(myCart.myMusicFrequencies[i], + myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); @@ -377,8 +377,8 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); - changed.push_back((myCart.getWaveform(i) >> 5) != - static_cast(myOldState.mwaves[i])); + changed.push_back(std::cmp_not_equal(myCart.getWaveform(i) >> 5, + myOldState.mwaves[i])); } myMusicWaveforms->setList(alist, vlist, changed); @@ -386,15 +386,15 @@ void CartridgeCDFWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); - changed.push_back((myCart.getWaveformSize(i)) != - static_cast(myOldState.mwavesizes[i])); + changed.push_back(std::cmp_not_equal(myCart.getWaveformSize(i), + myOldState.mwavesizes[i])); } myMusicWaveformSizes->setList(alist, vlist, changed); alist.clear(); vlist.clear(); changed.clear(); alist.push_back(0); vlist.push_back(myCart.getSample()); - changed.push_back((myCart.getSample()) != - static_cast(myOldState.samplepointer[0])); + changed.push_back(std::cmp_not_equal(myCart.getSample(), + myOldState.samplepointer[0])); mySamplePointer->setList(alist, vlist, changed); myFastFetch->setState((myCart.myMode & 0x0f) == 0); diff --git a/src/debugger/gui/CartDPCPlusWidget.cxx b/src/debugger/gui/CartDPCPlusWidget.cxx index b18b51888..e2c12aa2f 100644 --- a/src/debugger/gui/CartDPCPlusWidget.cxx +++ b/src/debugger/gui/CartDPCPlusWidget.cxx @@ -253,7 +253,7 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myCounters[i]); - changed.push_back(myCart.myCounters[i] != myOldState.counters[i]); + changed.push_back(std::cmp_not_equal(myCart.myCounters[i], myOldState.counters[i])); } myCounters->setList(alist, vlist, changed); @@ -261,8 +261,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]); - changed.push_back(myCart.myFractionalCounters[i] != - static_cast(myOldState.fraccounters[i])); + changed.push_back(std::cmp_not_equal(myCart.myFractionalCounters[i], + myOldState.fraccounters[i])); } myFracCounters->setList(alist, vlist, changed); @@ -286,8 +286,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); - changed.push_back(myCart.myMusicCounters[i] != - static_cast(myOldState.mcounters[i])); + changed.push_back(std::cmp_not_equal(myCart.myMusicCounters[i], + myOldState.mcounters[i])); } myMusicCounters->setList(alist, vlist, changed); @@ -295,8 +295,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); - changed.push_back(myCart.myMusicFrequencies[i] != - static_cast(myOldState.mfreqs[i])); + changed.push_back(std::cmp_not_equal(myCart.myMusicFrequencies[i], + myOldState.mfreqs[i])); } myMusicFrequencies->setList(alist, vlist, changed); @@ -304,7 +304,8 @@ void CartridgeDPCPlusWidget::loadConfig() for(int i = 0; i < 3; ++i) { alist.push_back(0); vlist.push_back(myCart.myMusicWaveforms[i]); - changed.push_back(myCart.myMusicWaveforms[i] != myOldState.mwaves[i]); + changed.push_back(std::cmp_not_equal(myCart.myMusicWaveforms[i], + myOldState.mwaves[i])); } myMusicWaveforms->setList(alist, vlist, changed); diff --git a/src/debugger/gui/CartDPCWidget.cxx b/src/debugger/gui/CartDPCWidget.cxx index 1122eb770..7b29a1519 100644 --- a/src/debugger/gui/CartDPCWidget.cxx +++ b/src/debugger/gui/CartDPCWidget.cxx @@ -169,7 +169,8 @@ void CartridgeDPCWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myTops[i]); - changed.push_back(myCart.myTops[i] != myOldState.tops[i]); + changed.push_back(std::cmp_not_equal(myCart.myTops[i], + myOldState.tops[i])); } myTops->setList(alist, vlist, changed); @@ -177,7 +178,8 @@ void CartridgeDPCWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myBottoms[i]); - changed.push_back(myCart.myBottoms[i] != myOldState.bottoms[i]); + changed.push_back(std::cmp_not_equal(myCart.myBottoms[i], + myOldState.bottoms[i])); } myBottoms->setList(alist, vlist, changed); @@ -185,7 +187,8 @@ void CartridgeDPCWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myCounters[i]); - changed.push_back(myCart.myCounters[i] != myOldState.counters[i]); + changed.push_back(std::cmp_not_equal(myCart.myCounters[i], + myOldState.counters[i])); } myCounters->setList(alist, vlist, changed); @@ -193,7 +196,8 @@ void CartridgeDPCWidget::loadConfig() for(int i = 0; i < 8; ++i) { alist.push_back(0); vlist.push_back(myCart.myFlags[i]); - changed.push_back(myCart.myFlags[i] != myOldState.flags[i]); + changed.push_back(std::cmp_not_equal(myCart.myFlags[i], + myOldState.flags[i])); } myFlags->setList(alist, vlist, changed); diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index ae4750a90..d338ba201 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -69,7 +69,7 @@ void CartridgeE7Widget::initialize(GuiObject* boss, int ypos = addBaseInformation(size, "M Network", info.view(), 15) + myLineHeight; VariantList items0, items1; - for(int i = 0; i < cart.romBankCount(); ++i) + for(int i = 0; std::cmp_less(i, cart.romBankCount()); ++i) VarList::push_back(items0, getSpotLower(i, myCart.romBankCount())); for(int i = 0; i < 4; ++i) VarList::push_back(items1, getSpotUpper(i)); diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index 9f9bc550e..075c91527 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -101,7 +101,8 @@ string CartridgeEnhancedWidget::romDescription() if(myCart.romBankCount() > 1) { - for(int bank = 0, offset = 0xFFC; bank < myCart.romBankCount(); ++bank, offset += 0x1000) + for(int bank = 0, offset = 0xFFC; std::cmp_less(bank, myCart.romBankCount()); + ++bank, offset += 0x1000) { uInt16 start = (image[offset + 1] << 8) | image[offset]; start -= start % 0x1000; @@ -183,10 +184,10 @@ void CartridgeEnhancedWidget::bankList(uInt16 bankCount, int seg, VariantList& i const bool hasRamBanks = myCart.myRamBankCount > 0; - for(int bank = 0; bank < bankCount; ++bank) + for(int bank = 0; std::cmp_less(bank, bankCount); ++bank) { ostringstream buf; - const bool isRamBank = (bank >= myCart.romBankCount()); + const bool isRamBank = std::cmp_greater_equal(bank, myCart.romBankCount()); const int bankNum = (bank - (isRamBank ? myCart.romBankCount() : 0)); buf << std::setw(bankNum < 10 ? 2 : 1) << "#" << std::dec << bankNum; @@ -211,7 +212,7 @@ void CartridgeEnhancedWidget::bankSelect(int& ypos) myBankWidgets = make_unique(bankSegs()); - for(int seg = 0; seg < bankSegs(); ++seg) + for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg) { // fill bank and hotspot list VariantList items; @@ -253,10 +254,10 @@ string CartridgeEnhancedWidget::bankState() { buf << "Segments: "; - for(int seg = 0; seg < bankSegs(); ++seg) + for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg) { const int bank = myCart.getSegmentBank(seg); - const bool isRamBank = (bank >= myCart.romBankCount()); + const bool isRamBank = std::cmp_greater_equal(bank, myCart.romBankCount()); if(seg > 0) buf << " / "; @@ -321,8 +322,8 @@ void CartridgeEnhancedWidget::saveOldState() } myOldState.banks.clear(); - if (bankSegs() > 1) - for(int seg = 0; seg < bankSegs(); ++seg) + if(bankSegs() > 1) + for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg) myOldState.banks.push_back(myCart.getSegmentBank(seg)); else myOldState.banks.push_back(myCart.getBank()); @@ -350,7 +351,7 @@ void CartridgeEnhancedWidget::loadConfig() if(myBankWidgets != nullptr) { if(bankSegs() > 1) - for(int seg = 0; seg < bankSegs(); ++seg) + for(int seg = 0; std::cmp_less(seg, bankSegs()); ++seg) myBankWidgets[seg]->setSelectedIndex(myCart.getSegmentBank(seg), myCart.getSegmentBank(seg) != myOldState.banks[seg]); else diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index c095bf27f..ff8800220 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -225,7 +225,7 @@ void DataGridWidget::setValueInternal(int position, int value, bool changed) void DataGridWidget::setValue(int position, int value, bool changed, bool emitSignal) { - if(position >= 0 && position < static_cast(_valueList.size())) + if(position >= 0 && std::cmp_less(position, _valueList.size())) { // Correctly format the data for viewing editString() = Common::Base::toString(value, _base); diff --git a/src/debugger/gui/FlashWidget.cxx b/src/debugger/gui/FlashWidget.cxx index 67fcf48a8..6f4976408 100644 --- a/src/debugger/gui/FlashWidget.cxx +++ b/src/debugger/gui/FlashWidget.cxx @@ -108,7 +108,7 @@ void FlashWidget::loadConfig() myPage[useCount]->setLabel(label.view()); startPage = -1; - if(++useCount == MAX_PAGES) + if(std::cmp_equal(++useCount, MAX_PAGES)) break; } } diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index ecd686026..41cabcc80 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -580,7 +580,7 @@ int PromptWidget::historyDir(int& index, int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptWidget::historyAdd(string_view entry) { - if(_historyIndex >= static_cast(_history.size())) + if(std::cmp_greater_equal(_historyIndex, _history.size())) _history.emplace_back(entry); else _history[_historyIndex] = entry; diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index a9d88a732..64719c3f6 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -501,7 +501,7 @@ string RamWidget::doCompare(string_view str) } const int addr = mySearchAddr[i]; - if(ram[addr] == searchVal) + if(std::cmp_equal(ram[addr], searchVal)) { tempAddrList.push_back(addr); tempValueList.push_back(searchVal); diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index d85000705..a690251f7 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -126,7 +126,7 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm) myCheckList[i]->setFlags(Widget::FLAG_ENABLED); // Then turn off any extras - if(static_cast(myDisasm->list.size()) < _rows) + if(std::cmp_less(myDisasm->list.size(), _rows)) for(int i = static_cast(myDisasm->list.size()); i < _rows; ++i) myCheckList[i]->clearFlags(Widget::FLAG_ENABLED); @@ -152,7 +152,7 @@ void RomListWidget::setSelected(int item) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::setHighlighted(int item) { - if(item < -1 || item >= static_cast(myDisasm->list.size())) + if(item < -1 || std::cmp_greater_equal(item, myDisasm->list.size())) return; if(isEnabled()) diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 0b1afa23b..2ad2e4af0 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -257,7 +257,7 @@ uInt16 RomWidget::getAddress(int disasm_line) const CartDebug::DisassemblyList& list = instance().debugger().cartDebug().disassembly().list; - if (disasm_line < static_cast(list.size()) && list[disasm_line].address != 0) + if (std::cmp_less(disasm_line, list.size()) && list[disasm_line].address != 0) return list[disasm_line].address; else return 0; diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 23607c4bf..44fddc310 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -87,9 +87,9 @@ string ToggleBitWidget::getToolTip(const Common::Point& pos) const string tip = ToggleWidget::getToolTip(pos); - if(idx.x < static_cast(_labelList.size())) + if(std::cmp_less(idx.x, _labelList.size())) { - const string label = _labelList[idx.x]; + const string& label = _labelList[idx.x]; if(!label.empty()) return tip + "\n" + label; diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index f126d365a..1dd53852d 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -124,9 +124,9 @@ FORCE_INLINE void CartridgeDPC::updateMusicModeDataFetchers() newLow = 0; // Update flag register for this data fetcher - if(newLow <= myBottoms[x]) + if(std::cmp_less_equal(newLow, myBottoms[x])) myFlags[x] = 0x00; - else if(newLow <= myTops[x]) + else if(std::cmp_less_equal(newLow, myTops[x])) myFlags[x] = 0xff; myCounters[x] = (myCounters[x] & 0x0700) | static_cast(newLow); diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 3a613c0ea..a65f9633a 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -190,12 +190,12 @@ inline void CartridgeDPCPlus::callFunction(uInt8 value) myParameterPointer = 0; break; case 1: // Copy ROM to fetcher - for(int i = 0; i < myParameter[3]; ++i) + for(int i = 0; std::cmp_less(i, myParameter[3]); ++i) myDisplayImage[myCounters[myParameter[2] & 0x7]+i] = myProgramImage[ROMdata+i]; myParameterPointer = 0; break; case 2: // Copy value to fetcher - for(int i = 0; i < myParameter[3]; ++i) + for(int i = 0; std::cmp_less(i, myParameter[3]); ++i) myDisplayImage[myCounters[myParameter[2]]+i] = myParameter[0]; myParameterPointer = 0; break; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 05c33352b..a6b2a2cc6 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -2442,14 +2442,14 @@ Event::Type EventHandler::eventAtIndex(int idx, Event::Group group) if(group == Event::Group::Menu) { - if(index < 0 || index >= static_cast(ourMenuActionList.size())) + if(index < 0 || std::cmp_greater_equal(index, ourMenuActionList.size())) return Event::NoType; else return ourMenuActionList[index].event; } else { - if(index < 0 || index >= static_cast(ourEmulActionList.size())) + if(index < 0 || std::cmp_greater_equal(index, ourEmulActionList.size())) return Event::NoType; else return ourEmulActionList[index].event; @@ -2463,14 +2463,14 @@ string EventHandler::actionAtIndex(int idx, Event::Group group) if(group == Event::Group::Menu) { - if(index < 0 || index >= static_cast(ourMenuActionList.size())) + if(index < 0 || std::cmp_greater_equal(index, ourMenuActionList.size())) return EmptyString; else return ourMenuActionList[index].action; } else { - if(index < 0 || index >= static_cast(ourEmulActionList.size())) + if(index < 0 || std::cmp_greater_equal(index, ourEmulActionList.size())) return EmptyString; else return ourEmulActionList[index].action; @@ -2484,14 +2484,14 @@ string EventHandler::keyAtIndex(int idx, Event::Group group) if(group == Event::Group::Menu) { - if(index < 0 || index >= static_cast(ourMenuActionList.size())) + if(index < 0 || std::cmp_greater_equal(index, ourMenuActionList.size())) return EmptyString; else return ourMenuActionList[index].key; } else { - if(index < 0 || index >= static_cast(ourEmulActionList.size())) + if(index < 0 || std::cmp_greater_equal(index, ourEmulActionList.size())) return EmptyString; else return ourEmulActionList[index].key; diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index a7eba43f2..7c7a1e4bb 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -167,7 +167,7 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr, const FontDesc& desc = font.desc(); // If this character is not included in the font, use the default char. - if(chr < desc.firstchar || chr >= desc.firstchar + desc.size) + if(std::cmp_less(chr, desc.firstchar) || chr >= desc.firstchar + desc.size) { if (chr == ' ') return; chr = desc.defaultchar; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 9ab033987..a71b31067 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -532,7 +532,7 @@ void FrameBuffer::update(UpdateMode mode) // Pause sound if saved states were removed or states are too far apart myOSystem.sound().pause(stateFrames > intervalFrames || - frames > static_cast(myOSystem.audioSettings().bufferSize() / 2 + 1)); + std::cmp_greater(frames, myOSystem.audioSettings().bufferSize() / 2 + 1)); } redraw |= success; if(redraw) diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index 200077345..d32652d15 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -501,7 +501,7 @@ ByteArray PlusROM::getSend() const ByteArray arr; const uInt8 txPos = myTxPos != 0 ? myTxPos : myLastTxPos; - for(int i = 0; i < txPos; ++i) + for(int i = 0; std::cmp_less(i, txPos); ++i) arr.push_back(myTxBuffer[i]); return arr; diff --git a/src/emucore/tia/Ball.hxx b/src/emucore/tia/Ball.hxx index e18ea3adb..8cef6670e 100644 --- a/src/emucore/tia/Ball.hxx +++ b/src/emucore/tia/Ball.hxx @@ -409,7 +409,8 @@ void Ball::tick(bool isReceivingRegularClock) break; } - } else if (myIsRendering && ++myRenderCounter >= (starfieldEffect ? myEffectiveWidth : myWidth)) + } else if (myIsRendering && std::cmp_greater_equal(++myRenderCounter, + starfieldEffect ? myEffectiveWidth : myWidth)) myIsRendering = false; if (++myCounter >= TIAConstants::H_PIXEL) diff --git a/src/emucore/tia/Missile.cxx b/src/emucore/tia/Missile.cxx index 3772782a6..573ad9aa7 100644 --- a/src/emucore/tia/Missile.cxx +++ b/src/emucore/tia/Missile.cxx @@ -145,7 +145,7 @@ void Missile::nusiz(uInt8 value) myWidth = ourWidths[(value & 0x30) >> 4]; myDecodes = DrawCounterDecodes::get().missileDecodes()[myDecodesOffset]; - if (myIsRendering && myRenderCounter >= myWidth) + if (myIsRendering && std::cmp_greater_equal(myRenderCounter, myWidth)) myIsRendering = false; } diff --git a/src/emucore/tia/Missile.hxx b/src/emucore/tia/Missile.hxx index 755925108..8e24600ae 100644 --- a/src/emucore/tia/Missile.hxx +++ b/src/emucore/tia/Missile.hxx @@ -210,7 +210,8 @@ void Missile::tick(uInt8 hclock, bool isReceivingMclock) } } - if (++myRenderCounter >= (isMoving ? myEffectiveWidth : myWidth)) myIsRendering = false; + if (std::cmp_greater_equal(++myRenderCounter, isMoving ? myEffectiveWidth : myWidth)) + myIsRendering = false; } if (++myCounter >= TIAConstants::H_PIXEL) myCounter = 0; diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index fb19a32a3..40afc4c14 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -126,11 +126,11 @@ void BrowserDialog::show(Dialog* parent, const GUI::Font& font, h = FBMinimum::Height; } - if(w > static_cast(font.getMaxCharWidth() * 80)) + if(std::cmp_greater(w, font.getMaxCharWidth() * 80)) w = font.getMaxCharWidth() * 80; - if(ourBrowser == nullptr || &ourBrowser->parent() != &parent->parent() - || ourBrowser->_w > static_cast(w) || ourBrowser->_h > static_cast(h)) + if(ourBrowser == nullptr || &ourBrowser->parent() != &parent->parent() || + std::cmp_greater(ourBrowser->_w, w) || std::cmp_greater(ourBrowser->_h, h)) { ourBrowser = make_unique(parent, font, w, h); } diff --git a/src/gui/CheckListWidget.cxx b/src/gui/CheckListWidget.cxx index 476a86ae9..0ef2ff466 100644 --- a/src/gui/CheckListWidget.cxx +++ b/src/gui/CheckListWidget.cxx @@ -59,7 +59,7 @@ void CheckListWidget::setList(const StringList& list, const BoolArray& state) _checkList[i]->setFlags(Widget::FLAG_ENABLED); // Then turn off any extras - if(static_cast(_stateList.size()) < _rows) + if(std::cmp_less(_stateList.size(), _rows)) for(int i = static_cast(_stateList.size()); i < _rows; ++i) _checkList[i]->clearFlags(Widget::FLAG_ENABLED); @@ -69,7 +69,7 @@ void CheckListWidget::setList(const StringList& list, const BoolArray& state) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheckListWidget::setLine(int line, string_view str, const bool& state) { - if(line >= static_cast(_list.size())) + if(std::cmp_greater_equal(line, _list.size())) return; _list[line] = str; @@ -147,7 +147,7 @@ Common::Rect CheckListWidget::getEditRect() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CheckListWidget::getState(int line) const { - if(line >= 0 && line < static_cast(_stateList.size())) + if(line >= 0 && std::cmp_less(line, _stateList.size())) return _stateList[line]; else return false; diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index 748b950e7..6e1ffb4bf 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -114,7 +114,7 @@ void ContextMenu::recalc(const Common::Rect& image) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::setSelectedIndex(int idx) { - if(idx >= 0 && idx < static_cast(_entries.size())) + if(idx >= 0 && std::cmp_less(idx, _entries.size())) _selectedItem = idx; else _selectedItem = -1; @@ -423,12 +423,12 @@ void ContextMenu::moveDown() // Otherwise, the offset should increase by 1 if(_selectedOffset == _numEntries) scrollDown(); - else if(_selectedOffset < static_cast(_entries.size())) + else if(std::cmp_less(_selectedOffset, _entries.size())) drawCurrentSelection(_selectedOffset+1); } else { - if(_selectedOffset < static_cast(_entries.size()) - 1) + if(std::cmp_less(_selectedOffset, _entries.size() - 1)) drawCurrentSelection(_selectedOffset+1); } } @@ -445,7 +445,7 @@ void ContextMenu::movePgUp() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::movePgDown() { - if(_firstEntry == static_cast(_entries.size() - _numEntries)) + if(std::cmp_equal(_firstEntry, _entries.size() - _numEntries)) moveToLast(); else scrollDown(_numEntries); @@ -474,7 +474,7 @@ void ContextMenu::moveToLast() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::moveToSelected() { - if(_selectedItem < 0 || _selectedItem >= static_cast(_entries.size())) + if(_selectedItem < 0 || std::cmp_greater_equal(_selectedItem, _entries.size())) return; // First jump immediately to the item diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index a3fe69b8a..14b67cfa3 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -1489,7 +1489,7 @@ void DeveloperDialog::handleDebugColours(int idx, int color) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleDebugColours(string_view colors) { - for(int i = 0; i < DEBUG_COLORS && i < static_cast(colors.length()); ++i) + for(int i = 0; i < DEBUG_COLORS && std::cmp_less(i, colors.length()); ++i) { switch(colors[i]) { @@ -1531,11 +1531,11 @@ void DeveloperDialog::handleFontSize() minH = std::min(size.h, minH); myDebuggerWidthSlider->setMinValue(minW); - if(minW > static_cast(myDebuggerWidthSlider->getValue())) + if(std::cmp_greater(minW, myDebuggerWidthSlider->getValue())) myDebuggerWidthSlider->setValue(minW); myDebuggerHeightSlider->setMinValue(minH); - if(minH > static_cast(myDebuggerHeightSlider->getValue())) + if(std::cmp_greater(minH, myDebuggerHeightSlider->getValue())) myDebuggerHeightSlider->setValue(minH); #endif } diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index fbaeb3756..bc81a0a4e 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -208,7 +208,7 @@ string Dialog::getHelpURL() const if(_focusedWidget && _focusedWidget->hasHelp()) return _focusedWidget->getHelpURL(); - if(_tabID < static_cast(_myTabList.size())) + if(std::cmp_less(_tabID, _myTabList.size())) { TabWidget* activeTabGroup = _myTabList[_tabID].widget; @@ -490,7 +490,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 < static_cast(_myTabList.size())) + if(tabID >= 0 && std::cmp_less(tabID, _myTabList.size())) { // Save focus in previously selected tab column, // and get focus for new tab column @@ -937,7 +937,7 @@ void Dialog::getTabIdForWidget(const Widget* w) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Dialog::cycleTab(int direction) { - if(_tabID >= 0 && _tabID < static_cast(_myTabList.size())) + if(_tabID >= 0 && std::cmp_less(_tabID, _myTabList.size())) { _myTabList[_tabID].widget->cycleTab(direction); return true; @@ -1086,12 +1086,12 @@ void Dialog::addDefaultsExtraOKCancelBGroup( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::TabFocus::appendFocusList(WidgetArray& list) +void Dialog::TabFocus::appendFocusList(WidgetArray& lst) { const int active = widget->getActiveTab(); - if(active >= 0 && active < static_cast(focus.size())) - Vec::append(list, focus[active].list); + if(active >= 0 && std::cmp_less(active, focus.size())) + Vec::append(lst, focus[active].list); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1146,7 +1146,7 @@ bool Dialog::shouldResize(uInt32& w, uInt32& h) const // returns true if the current size is larger than the allowed size or // if the current size is smaller than the allowed and wanted size - return (static_cast(_w) > w || static_cast(_h) > h || - (static_cast(_w) < w && static_cast(_w) < _max_w) || - (static_cast(_h) < h && static_cast(_h) < _max_h)); + return (std::cmp_greater(_w, w) || std::cmp_greater(_h, h) || + (std::cmp_less(_w, w) && std::cmp_less(_w, _max_w)) || + (std::cmp_less(_h, h) && std::cmp_less(_h, _max_h))); } diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index cbdbbd066..bf7cce3f9 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -256,7 +256,7 @@ class Dialog : public GuiObject explicit TabFocus(TabWidget* w = nullptr) : widget{w} { } - void appendFocusList(WidgetArray& list); + void appendFocusList(WidgetArray& lst); void saveCurrentFocus(Widget* w); Widget* getNewFocus(); }; diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 9e24757c4..a63cb808b 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -127,7 +127,7 @@ int EditableWidget::toCaretPos(int x) const int i = 0; x += caretOfs(); - for(i = 0; i < static_cast(_editString.size()); ++i) + for(i = 0; std::cmp_less(i, _editString.size()); ++i) { x -= _font.getCharWidth(_editString[i]); if(x <= 0) @@ -248,7 +248,7 @@ bool EditableWidget::tryInsertChar(char c, int pos) if(_selectSize < 0) // left to right selection pos += _selectSize; // adjust to new position after removing selected text killSelectedText(); - if(!_maxLen || static_cast(_editString.length()) < _maxLen) + if(!_maxLen || std::cmp_less(_editString.length(), _maxLen)) { myUndoHandler->doChar(); // aggregate single chars _editString.insert(pos, 1, c); @@ -296,7 +296,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod) case Event::MoveRightChar: if(_selectSize) handled = setCaretPos(selectEndPos()); - else if(_caretPos < static_cast(_editString.size())) + else if(std::cmp_less(_caretPos, _editString.size())) handled = setCaretPos(_caretPos + 1); _selectSize = 0; break; @@ -327,7 +327,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod) break; case Event::SelectRightChar: - if(_caretPos < static_cast(_editString.size())) + if(std::cmp_less(_caretPos, _editString.size())) handled = moveCaretPos(+1); break; @@ -532,7 +532,7 @@ void EditableWidget::drawCaretSelection() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EditableWidget::setCaretPos(int newPos) { - assert(newPos >= 0 && newPos <= int(_editString.size())); + assert(newPos >= 0 && std::cmp_less_equal(newPos, _editString.size())); _caretPos = newPos; _caretTimer = 0; @@ -612,7 +612,7 @@ bool EditableWidget::killChar(int direction, bool addEdit) } else if(direction == 1) // Delete next character (delete) { - if(_caretPos < static_cast(_editString.size())) + if(std::cmp_less(_caretPos, _editString.size())) { if(_selectSize > 0) _selectSize--; @@ -679,7 +679,7 @@ bool EditableWidget::killWord(int direction) } else if(direction == +1) // move to first character of next word { - while(currentPos < static_cast(_editString.size())) + while(std::cmp_less(currentPos, _editString.size())) { if(currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1])) { @@ -715,11 +715,11 @@ bool EditableWidget::moveWord(int direction, bool select) if(direction == -1) // move to first character of previous word { - while (currentPos > 0) + while(currentPos > 0) { - if (BSPF::isWhiteSpace(_editString[currentPos - 1])) + if(BSPF::isWhiteSpace(_editString[currentPos - 1])) { - if (!space) + if(!space) break; } else @@ -734,11 +734,11 @@ bool EditableWidget::moveWord(int direction, bool select) } else if(direction == +1) // move to first character of next word { - while (currentPos < static_cast(_editString.size())) + while(std::cmp_less(currentPos, _editString.size())) { - if (currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1])) + if(currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1])) { - if (!space) + if(!space) break; } else @@ -798,19 +798,13 @@ string EditableWidget::selectString() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int EditableWidget::selectStartPos() const { - if(_selectSize < 0) - return _caretPos + _selectSize; - else - return _caretPos; + return (_selectSize < 0) ? _caretPos + _selectSize : _caretPos; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int EditableWidget::selectEndPos() const { - if(_selectSize > 0) - return _caretPos + _selectSize; - else - return _caretPos; + return (_selectSize > 0) ? _caretPos + _selectSize : _caretPos; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 39cb61395..5aa3d8141 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -717,7 +717,7 @@ string FileListWidget::getToolTip(const Common::Point& pos) const if(idx < 0) return EmptyString; - if(_includeSubDirs && static_cast(_dirList.size()) > idx) + if(_includeSubDirs && std::cmp_greater(_dirList.size(), idx)) return _toolTipText + _dirList[idx]; const string value = _list[idx]; diff --git a/src/gui/Font.cxx b/src/gui/Font.cxx index 0a7b47f35..b908ec4a4 100644 --- a/src/gui/Font.cxx +++ b/src/gui/Font.cxx @@ -38,7 +38,7 @@ int Font::getCharWidth(uInt8 chr) const return myFontDesc.maxwidth; // If this character is not included in the font, use the default char. - if(chr < myFontDesc.firstchar || myFontDesc.firstchar + myFontDesc.size < chr) + if(std::cmp_less(chr, myFontDesc.firstchar) || myFontDesc.firstchar + myFontDesc.size < chr) { if(chr == ' ') return myFontDesc.maxwidth / 2; diff --git a/src/gui/HighScoresDialog.cxx b/src/gui/HighScoresDialog.cxx index 0b8617190..94dc02d6c 100644 --- a/src/gui/HighScoresDialog.cxx +++ b/src/gui/HighScoresDialog.cxx @@ -409,7 +409,7 @@ void HighScoresDialog::updateWidgets(bool init) myNameWidgets[r]->setLabel(myScores.scores[r].name); myDateWidgets[r]->setLabel(myScores.scores[r].date); - if (static_cast(r) == myEditRank) + if (std::cmp_equal(r, myEditRank)) { myNameWidgets[r]->setFlags(EditTextWidget::FLAG_INVISIBLE); myEditNameWidgets[r]->clearFlags(EditTextWidget::FLAG_INVISIBLE); @@ -440,7 +440,7 @@ void HighScoresDialog::handlePlayedVariation() const Int32 newSpecial = instance().highScores().special(); const bool scoreInvert = instance().highScores().scoreInvert(); - for (myHighScoreRank = 0; myHighScoreRank < static_cast(NUM_RANKS); ++myHighScoreRank) + for (myHighScoreRank = 0; std::cmp_less(myHighScoreRank, NUM_RANKS); ++myHighScoreRank) { const Int32 highScore = myScores.scores[myHighScoreRank].score; @@ -452,10 +452,10 @@ void HighScoresDialog::handlePlayedVariation() break; } - if (myHighScoreRank < static_cast(NUM_RANKS)) + if (std::cmp_less(myHighScoreRank, NUM_RANKS)) { myEditRank = myHighScoreRank; - for (uInt32 r = NUM_RANKS - 1; static_cast(r) > myHighScoreRank; --r) + for (uInt32 r = NUM_RANKS - 1; std::cmp_greater(r, myHighScoreRank); --r) { myScores.scores[r].score = myScores.scores[r - 1].score; myScores.scores[r].special = myScores.scores[r - 1].special; diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 73a8e575c..6ee66b44f 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -657,9 +657,9 @@ void LauncherDialog::setRomInfoFont(const Common::Size& area) // only use fonts <= launcher fonts if(Dialog::fontHeight() >= font.height) { - if(area.h >= static_cast(MIN_ROMINFO_ROWS * font.height + 2 - + MIN_ROMINFO_LINES * font.height) - && area.w >= static_cast(MIN_ROMINFO_CHARS * font.maxwidth)) + if(std::cmp_greater_equal(area.h, + MIN_ROMINFO_ROWS * font.height + 2 + MIN_ROMINFO_LINES * font.height) + && std::cmp_greater_equal(area.w, MIN_ROMINFO_CHARS * font.maxwidth)) { myROMInfoFont = make_unique(font); return; diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index c96256b5d..706ad0ab0 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -71,7 +71,7 @@ void ListWidget::setSelected(int item) { setDirty(); - if(item < 0 || item >= static_cast(_list.size())) + if(item < 0 || std::cmp_greater_equal(item, _list.size())) return; if(isEnabled()) @@ -117,7 +117,7 @@ void ListWidget::setSelected(string_view item) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ListWidget::setHighlighted(int item) { - if(item < -1 || item >= static_cast(_list.size())) + if(item < -1 || std::cmp_greater_equal(item, _list.size())) return; if(isEnabled()) @@ -140,7 +140,7 @@ void ListWidget::setHighlighted(int item) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const string& ListWidget::getSelectedString() const { - return (_selectedItem >= 0 && _selectedItem < static_cast(_list.size())) + return (_selectedItem >= 0 && std::cmp_less(_selectedItem, _list.size())) ? _list[_selectedItem] : EmptyString; } @@ -207,18 +207,18 @@ void ListWidget::scrollBarRecalc() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { - if (!isEnabled()) + if(!isEnabled()) return; resetSelection(); // First check whether the selection changed const int newSelectedItem = findItem(x, y); - if (newSelectedItem >= static_cast(_list.size())) + if(std::cmp_greater_equal(newSelectedItem, _list.size())) return; - if (_selectedItem != newSelectedItem) + if(_selectedItem != newSelectedItem) { - if (_editMode) + if(_editMode) abortEditMode(); _selectedItem = newSelectedItem; sendCommand(ListWidget::kSelectionChangedCmd, _selectedItem, _id); @@ -234,7 +234,7 @@ void ListWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount) { // If this was a double click and the mouse is still over the selected item, // send the double click command - if (clickCount == 2 && (_selectedItem == findItem(x, y))) + if(clickCount == 2 && (_selectedItem == findItem(x, y))) { sendCommand(ListWidget::kDoubleClickedCmd, _selectedItem, _id); @@ -420,7 +420,7 @@ void ListWidget::scrollToCurrent(int item) _currentPos = item - _rows + 1; } - if (_currentPos < 0 || _rows > static_cast(_list.size())) + if (_currentPos < 0 || std::cmp_greater_equal(_rows, _list.size())) _currentPos = 0; else if (_currentPos + _rows > static_cast(_list.size())) _currentPos = static_cast(_list.size()) - _rows; diff --git a/src/gui/RadioButtonWidget.cxx b/src/gui/RadioButtonWidget.cxx index 0fb995211..dee5b0e5d 100644 --- a/src/gui/RadioButtonWidget.cxx +++ b/src/gui/RadioButtonWidget.cxx @@ -249,9 +249,9 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font, // Depending on font size, either the font or box will need to be // centered vertically - if(_h > static_cast(_buttonSize)) // center box + if(std::cmp_greater(_h, _buttonSize)) // center box _boxY = (_h - _buttonSize) / 2; - else // center text + else // center text _textY = (_buttonSize - _font.getFontHeight()) / 2; setFill(CheckboxWidget::FillType::Normal); // NOLINT diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index 0b42829b5..80b3f9bc2 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -496,7 +496,7 @@ int StellaSettingsDialog::valueToLevel(int value) for (int i = NUM_LEVELS - 1; i > 0; --i) { - if (value >= values[i]) + if (std::cmp_greater_equal(value, values[i])) return i; } return 0; diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index abe07f16b..9f39f28d8 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -54,10 +54,7 @@ int StringListWidget::getToolTipIndex(const Common::Point& pos) const { const int idx = (pos.y - getAbsY()) / _lineHeight + _currentPos; - if(idx >= static_cast(_list.size())) - return -1; - else - return idx; + return std::cmp_greater_equal(idx, _list.size()) ? -1 : idx; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index a128b64e8..2da3f5177 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -98,7 +98,7 @@ int TabWidget::addTab(string_view title, int tabWidth) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::setActiveTab(int tabID, bool show) { - assert(0 <= tabID && tabID < int(_tabs.size())); + assert(0 <= tabID && std::cmp_less(tabID, _tabs.size())); if (_activeTab != -1) { @@ -120,7 +120,7 @@ void TabWidget::setActiveTab(int tabID, bool show) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::enableTab(int tabID, bool enable) { - assert(0 <= tabID && tabID < int(_tabs.size())); + assert(0 <= tabID && std::cmp_less(tabID, _tabs.size())); _tabs[tabID].enabled = enable; // Note: We do not have to disable the widgets because the tab is disabled @@ -168,7 +168,7 @@ void TabWidget::cycleTab(int direction) { do { tabID++; - if(tabID == static_cast(_tabs.size())) + if(std::cmp_equal(tabID, _tabs.size())) tabID = 0; } while(!_tabs[tabID].enabled); } @@ -181,14 +181,14 @@ void TabWidget::cycleTab(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::setParentWidget(int tabID, Widget* parent) { - assert(0 <= tabID && tabID < static_cast(_tabs.size())); + assert(0 <= tabID && std::cmp_less(tabID, _tabs.size())); _tabs[tabID].parentWidget = parent; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Widget* TabWidget::parentWidget(int tabID) { - assert(0 <= tabID && tabID < int(_tabs.size())); + assert(0 <= tabID && std::cmp_less(tabID, _tabs.size())); if(!_tabs[tabID].parentWidget) { @@ -209,7 +209,7 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) int tabID = -1; x -= kTabLeftOffset; - for(int i = 0; i < static_cast(_tabs.size()); ++i) + for(int i = 0; std::cmp_less(i, _tabs.size()); ++i) { const int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth; if(x >= 0 && x < tabWidth) @@ -283,7 +283,7 @@ void TabWidget::drawWidget(bool hilite) // Iterate over all tabs and draw them int x = _x + kTabLeftOffset; - for(int i = 0; i < static_cast(_tabs.size()); ++i) + for(int i = 0; std::cmp_less(i, _tabs.size()); ++i) { const int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth; const ColorId fontcolor = _tabs[i].enabled ? kTextColor : kColor; diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index e378c5be5..b7d084b61 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -101,7 +101,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TimeLineWidget::handleMouseMoved(int x, int y) { - if(isEnabled() && _isDragging && x >= static_cast(_labelWidth)) + if(isEnabled() && _isDragging && std::cmp_greater_equal(x, _labelWidth)) setValue(posToValue(x - _labelWidth)); } diff --git a/src/gui/WhatsNewDialog.cxx b/src/gui/WhatsNewDialog.cxx index 433d44cf9..525279921 100644 --- a/src/gui/WhatsNewDialog.cxx +++ b/src/gui/WhatsNewDialog.cxx @@ -78,7 +78,7 @@ WhatsNewDialog::WhatsNewDialog(OSystem& osystem, DialogContainer& parent, // Set needed dimensions ypos += VGAP * 2 + buttonHeight + VBORDER; - assert(ypos <= int(FBMinimum::Height)); // minimal launcher height + assert(std::cmp_less_equal(ypos, FBMinimum::Height)); // minimal launcher height setSize(MAX_CHARS * fontWidth + HBORDER * 2, ypos, max_w, max_h); WidgetArray wid; diff --git a/src/tools/TIDY b/src/tools/TIDY index e004cfaff..0e2929c28 100755 --- a/src/tools/TIDY +++ b/src/tools/TIDY @@ -1,6 +1,6 @@ #!/usr/bin/env bash -run-clang-tidy-19 -header-filter=\(.*\.hxx\) \ +run-clang-tidy-20 -header-filter=\(.*\.hxx\) \ -checks=*,\ -abseil*,\ -altera*,\