added VSYNC warning to console info overlay in developer mode

This commit is contained in:
Thomas Jentzsch 2022-10-20 12:48:51 +02:00
parent 7a8845548d
commit 6cbb06b10a
8 changed files with 50 additions and 14 deletions

View File

@ -367,6 +367,11 @@ class Console : public Serializable, public ConsoleIO
*/
void changeJitterRecovery(int direction = +1) const;
/**
Return whether vertical sync length is according to spec.
*/
bool vsyncCorrect() const { return myFrameManager->vsyncCorrect(); }
/**
* Update vcenter
*/

View File

@ -374,11 +374,11 @@ int FBSurface::drawString(const GUI::Font& font, const string& s,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::drawString(const GUI::Font& font, const string& s,
int x, int y, int w,
ColorId color, TextAlign align,
int deltax, bool useEllipsis, ColorId shadowColor,
size_t linkStart, size_t linkLen, bool underline)
int FBSurface::drawString(const GUI::Font& font, const string& s,
int x, int y, int w,
ColorId color, TextAlign align,
int deltax, bool useEllipsis, ColorId shadowColor,
size_t linkStart, size_t linkLen, bool underline)
{
#ifdef GUI_SUPPORT
const string ELLIPSIS = "\x1d"; // "..."
@ -443,6 +443,7 @@ void FBSurface::drawString(const GUI::Font& font, const string& s,
hLine(x0, y + font.getFontHeight() - 1, x1, kTextColorLink);
#endif
return x;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -251,12 +251,14 @@ class FBSurface
@param linkLen The length of a link in drawn string
@param underline Whether to underline the link
@return x coordinate of end of string
*/
virtual void drawString(const GUI::Font& font, const string& s, int x, int y, int w,
ColorId color, TextAlign align = TextAlign::Left,
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone,
size_t linkStart = string::npos, size_t linkLen = string::npos,
bool underline = false);
virtual int drawString(const GUI::Font& font, const string& s, int x, int y, int w,
ColorId color, TextAlign align = TextAlign::Left,
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone,
size_t linkStart = string::npos, size_t linkLen = string::npos,
bool underline = false);
/**
Splits a given string to a given width considering whitespaces.

View File

@ -701,7 +701,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond)
myStatsMsg.surface->invalidate();
// draw scanlines
const ColorId color = myOSystem.console().tia().frameBufferScanlinesLastFrame() !=
ColorId color = myOSystem.console().tia().frameBufferScanlinesLastFrame() !=
myLastScanlines ? kDbgColorRed : myStatsMsg.color;
ss
@ -734,10 +734,26 @@ void FrameBuffer::drawFrameStats(float framesPerSecond)
ss.str("");
ss << info.BankSwitch;
if (myOSystem.settings().getBool("dev.settings")) ss << "| Developer";
int xPosEnd =
myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos,
myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor);
myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos,
myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor);
if(myOSystem.settings().getBool("dev.settings"))
{
xPosEnd = myStatsMsg.surface->drawString(f, "| ", xPosEnd, yPos,
myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor);
ss.str("");
color = myStatsMsg.color;
if(myOSystem.console().vsyncCorrect())
ss << "Developer";
else
{
color = kDbgColorRed;
ss << "VSYNC!";
}
myStatsMsg.surface->drawString(f, ss.str(), xPosEnd, yPos,
myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor);
}
myStatsMsg.surface->setDstPos(imageRect().x() + 10, imageRect().y() + 8);
myStatsMsg.surface->setDstSize(myStatsMsg.w * hidpiScaleFactor(),

View File

@ -148,6 +148,11 @@ class AbstractFrameManager : public Serializable
*/
virtual void enableJitter(bool enabled) {}
/**
* Is vsync according to spec?
*/
virtual bool vsyncCorrect() const { return true; }
/**
* The scanline difference between the last two frames. Used in the TIA to
* clear any scanlines that were not repainted.

View File

@ -55,6 +55,8 @@ class FrameManager: public AbstractFrameManager {
void enableJitter(bool enabled) override { myJitterEnabled = enabled; }
bool vsyncCorrect() const override { return !myJitterEnabled || myJitterEmulation.vsyncCorrect(); }
uInt32 height() const override { return myHeight; }
uInt32 getY() const override { return myY; }

View File

@ -76,6 +76,8 @@ void JitterEmulation::frameComplete(Int32 scanlineCount, Int32 vsyncCycles)
const bool vsyncLinesStable = abs(vsyncCycles - myLastFrameVsyncCycles) < myVsyncDelta1;
#endif
myVsyncCorrect = abs(vsyncCycles - 76 * 3) <= 3; // 3 cycles tolerance
if(!scanlinesStable || !vsyncCyclesStable || !vsyncLinesStable)
{
if(++myUnstableCount >= myUnstableFrames)

View File

@ -50,6 +50,8 @@ class JitterEmulation : public Serializable
void frameComplete(Int32 scanlineCount, Int32 vsyncCycles);
Int32 jitter() const { return myJitter; }
bool vsyncCorrect() const { return myVsyncCorrect; }
/**
* Save state.
*/
@ -101,6 +103,7 @@ class JitterEmulation : public Serializable
Int32 myUnstableFrames{MAX_UNSTABLE_FRAMES};
Int32 myJitterLines{MIN_JITTER_LINES};
Int32 myVsyncLines{MIN_VSYNC_LINES};
bool myVsyncCorrect{true};
private:
JitterEmulation(const JitterEmulation&) = delete;