diff --git a/Makefile b/Makefile index f80e68eb9..2b0c212c8 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ CXXFLAGS+= -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers ifdef HAVE_GCC CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 endif -ifdef HAVE_CLANG +ifdef CLANG_WARNINGS CXXFLAGS+= -Weverything -Wno-c++17-extensions -Wno-c++98-compat -Wno-c++98-compat-pedantic \ -Wno-double-promotion -Wno-switch-enum -Wno-conversion -Wno-covered-switch-default \ -Wno-inconsistent-missing-destructor-override \ diff --git a/configure b/configure index 648452860..169657f2b 100755 --- a/configure +++ b/configure @@ -414,12 +414,16 @@ if test "$have_clang" = yes; then cxx_version="$cxx_version, bad" cxx_verc_fail=yes fi + + # Only clang >= 5.0 supports extra warnings + if [ $clang_major -ge 5 ]; then + _make_def_CLANG_WARNINGS='CLANG_WARNINGS = 1' + fi fi CXXFLAGS="$CXXFLAGS" _make_def_HAVE_GCC3='HAVE_GCC3 = 1' add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP' _make_def_HAVE_GCC='HAVE_GCC = 1' - _make_def_HAVE_CLANG='HAVE_CLANG = 1' echo "$cxx_version" elif test "$have_gcc" = yes; then @@ -817,7 +821,7 @@ PROFILE := $_build_profile $_make_def_HAVE_GCC $_make_def_HAVE_GCC3 -$_make_def_HAVE_CLANG +$_make_def_CLANG_WARNINGS INCLUDES += $INCLUDES OBJS += $OBJS diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index e921567e2..4ce11a951 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -28,7 +28,7 @@ #include "StateManager.hxx" -#define STATE_HEADER "05000303state" +#define STATE_HEADER "05000304state" // #define MOVIE_HEADER "03030000movie" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index c62666827..033f0b459 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -244,7 +244,7 @@ void Console::autodetectYStart() YStartDetector ystartDetector; ystartDetector.setLayout(myDisplayFormat == "PAL" ? FrameLayout::pal : FrameLayout::ntsc); myTIA->setFrameManager(&ystartDetector); - mySystem->reset(); + mySystem->reset(true); for (int i = 0; i < 80; i++) myTIA->update(); diff --git a/src/emucore/tia/PaddleReader.cxx b/src/emucore/tia/PaddleReader.cxx index 93d27b6ae..461bd6f77 100644 --- a/src/emucore/tia/PaddleReader.cxx +++ b/src/emucore/tia/PaddleReader.cxx @@ -69,7 +69,7 @@ void PaddleReader::update(double value, double timestamp, ConsoleTiming consoleT setConsoleTiming(consoleTiming); } - if (value != myValue) { // FIXME - warning on 'no-float-equal' + if (value != myValue) { myValue = value; if (myValue < 0) { diff --git a/src/emucore/tia/frame-manager/FrameManager.cxx b/src/emucore/tia/frame-manager/FrameManager.cxx index 40629f152..6d2b407f8 100644 --- a/src/emucore/tia/frame-manager/FrameManager.cxx +++ b/src/emucore/tia/frame-manager/FrameManager.cxx @@ -162,7 +162,6 @@ void FrameManager::setState(FrameManager::State state) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: kill this with fire once frame manager refactoring is complete void FrameManager::onLayoutChange() { switch (layout()) diff --git a/src/emucore/tia/frame-manager/JitterEmulation.cxx b/src/emucore/tia/frame-manager/JitterEmulation.cxx index db6c48372..c815b0701 100644 --- a/src/emucore/tia/frame-manager/JitterEmulation.cxx +++ b/src/emucore/tia/frame-manager/JitterEmulation.cxx @@ -18,9 +18,10 @@ #include "JitterEmulation.hxx" enum Metrics: uInt32 { - framesForStableHeight = 2, - minDeltaForJitter = 3, - maxJitter = 50 + framesForStableHeight = 2, + framesUntilDestabilization = 10, + minDeltaForJitter = 3, + maxJitter = 50 }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -32,27 +33,32 @@ JitterEmulation::JitterEmulation() : void JitterEmulation::reset() { myLastFrameScanlines = 0; - myStableFrameFinalLines = 0; + myStableFrameFinalLines = -1; myStableFrames = 0; myStabilizationCounter = 0; + myDestabilizationCounter = 0; myJitter = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void JitterEmulation::frameComplete(uInt32 scanlineCount) { - if (scanlineCount != myStableFrameFinalLines) { + if (Int32(scanlineCount) != myStableFrameFinalLines) { + if (myDestabilizationCounter++ > Metrics::framesUntilDestabilization) myStableFrameFinalLines = -1; + if (scanlineCount == myLastFrameScanlines) { if (++myStabilizationCounter >= Metrics::framesForStableHeight) { if (myStableFrameFinalLines > 0) updateJitter(scanlineCount - myStableFrameFinalLines); myStableFrameFinalLines = scanlineCount; + myDestabilizationCounter = 0; } } else myStabilizationCounter = 0; } + else myDestabilizationCounter = 0; myLastFrameScanlines = scanlineCount; @@ -65,7 +71,7 @@ void JitterEmulation::updateJitter(Int32 scanlineDifference) { if (uInt32(abs(scanlineDifference)) < Metrics::minDeltaForJitter) return; - Int32 jitter = std::min(jitter, Metrics::maxJitter); + Int32 jitter = std::min(scanlineDifference, Metrics::maxJitter); jitter = std::max(jitter, -myYStart); if (jitter > 0) jitter += myJitterFactor; @@ -84,6 +90,7 @@ bool JitterEmulation::save(Serializer& out) const out.putInt(myStableFrameFinalLines); out.putInt(myStableFrames); out.putInt(myStabilizationCounter); + out.putInt(myDestabilizationCounter); out.putInt(myJitter); out.putInt(myJitterFactor); out.putInt(myYStart); @@ -108,6 +115,7 @@ bool JitterEmulation::load(Serializer& in) myStableFrameFinalLines = in.getInt(); myStableFrames = in.getInt(); myStabilizationCounter = in.getInt(); + myDestabilizationCounter = in.getInt(); myJitter = in.getInt(); myJitterFactor = in.getInt(); myYStart = in.getInt(); diff --git a/src/emucore/tia/frame-manager/JitterEmulation.hxx b/src/emucore/tia/frame-manager/JitterEmulation.hxx index 6e67eb62c..5c0f47ea3 100644 --- a/src/emucore/tia/frame-manager/JitterEmulation.hxx +++ b/src/emucore/tia/frame-manager/JitterEmulation.hxx @@ -58,12 +58,14 @@ class JitterEmulation: public Serializable { uInt32 myLastFrameScanlines; - uInt32 myStableFrameFinalLines; + Int32 myStableFrameFinalLines; uInt32 myStableFrames; uInt32 myStabilizationCounter; + uInt32 myDestabilizationCounter; + Int32 myJitter; Int32 myJitterFactor;