Added scanline and framerate counter during emulation mode, similar to

the one in z26 with the '-n' option.  This is activated with the new
'-stats' commandline argument as well as dynamically during emulation
with the 'Alt-l' key combo.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1521 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-05-20 13:42:50 +00:00
parent bd0393352e
commit f12a1a658c
7 changed files with 77 additions and 17 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Snapshot.cxx,v 1.19 2008-03-30 15:01:38 stephena Exp $
// $Id: Snapshot.cxx,v 1.20 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#include <zlib.h>
@ -38,7 +38,7 @@ void Snapshot::savePNG(FrameBuffer& framebuffer, const Properties& props,
try
{
// Make sure we have a 'clean' image, with no onscreen messages
framebuffer.hideMessage();
framebuffer.enableMessages(false);
// Get actual image dimensions. which are not always the same
// as the framebuffer dimensions
@ -105,6 +105,8 @@ void Snapshot::savePNG(FrameBuffer& framebuffer, const Properties& props,
if(compmem) delete[] compmem;
out.close();
// Re-enabled old messages
framebuffer.enableMessages(true);
framebuffer.showMessage("Snapshot saved");
}
catch(const char *msg)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.cxx,v 1.223 2008-05-16 12:17:22 stephena Exp $
// $Id: EventHandler.cxx,v 1.224 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#include <sstream>
@ -428,6 +428,9 @@ void EventHandler::poll(uInt32 time)
myOSystem->console().togglePhosphor();
break;
case SDLK_l:
myOSystem->frameBuffer().toggleFrameStats();
break;
#if 0
// FIXME - these will be removed when a UI is added for event recording
case SDLK_e: // Alt-e starts/stops event recording

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.cxx,v 1.128 2008-05-19 21:16:58 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.129 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#include <sstream>
@ -45,7 +45,8 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
myUsePhosphor(false),
myPhosphorBlend(77),
myInitializedCount(0),
myPausedCount(0)
myPausedCount(0),
myFrameStatsEnabled(false)
{
}
@ -124,6 +125,18 @@ void FrameBuffer::update()
// And update the screen
drawMediaSource();
// Show frame statistics
if(myFrameStatsEnabled)
{
// FIXME - sizes hardcoded for now; fix during UI refactoring
uInt32 scanlines = myOSystem->console().mediaSource().scanlines();
float fps = (scanlines <= 285 ? 15720.0 : 15600.0) / scanlines;
char msg[30];
sprintf(msg, "%u LINES %2.2f FPS", scanlines, fps);
fillRect(3, 3, 95, 9, kBGColor);
drawString(&myOSystem->font(), msg, 3, 3, 95, kBtnTextColor, kTextAlignCenter);
}
break; // S_EMULATE
}
@ -261,12 +274,36 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::hideMessage()
void FrameBuffer::toggleFrameStats()
{
// Erase old messages on the screen
if(myMessage.counter > 0)
showFrameStats(!myOSystem->settings().getBool("stats"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showFrameStats(bool enable)
{
myOSystem->settings().setBool("stats", enable);
myFrameStatsEnabled = enable;
myOSystem->eventHandler().refreshDisplay(true); // Do this twice for
myOSystem->eventHandler().refreshDisplay(true); // double-buffered modes
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::enableMessages(bool enable)
{
if(enable)
{
// Only re-anable frame stats if they were already enabled before
myFrameStatsEnabled = myOSystem->settings().getBool("stats");
}
else
{
// Temporarily disable frame stats
myFrameStatsEnabled = false;
// Erase old messages on the screen
myMessage.counter = 0;
myOSystem->eventHandler().refreshDisplay(true); // Do this twice for
myOSystem->eventHandler().refreshDisplay(true); // double-buffered modes
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.hxx,v 1.94 2008-03-13 22:58:06 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.95 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -101,7 +101,7 @@ enum {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.94 2008-03-13 22:58:06 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.95 2008-05-20 13:42:50 stephena Exp $
*/
class FrameBuffer
{
@ -146,9 +146,20 @@ class FrameBuffer
int color = kTextColorHi);
/**
Hides any onscreen messages.
Toggles showing or hiding framerate statistics.
*/
void hideMessage();
void toggleFrameStats();
/**
Shows a message containing frame statistics for the current frame.
*/
void showFrameStats(bool enable);
/**
Enable/disable any pending messages. Disabled messages aren't removed
from the message queue; they're just not redrawn into the framebuffer.
*/
void enableMessages(bool enable);
/**
Returns the current width of the framebuffer *before* any scaling.
@ -520,7 +531,7 @@ class FrameBuffer
void setWindowIcon();
/**
Set the icon for the main SDL window.
Draw pending messages.
*/
void drawMessage();
@ -570,6 +581,10 @@ class FrameBuffer
};
Message myMessage;
// Used to show frame statistics (scanline count and framerate)
Message myFrameStats;
bool myFrameStatsEnabled;
// The list of all available video modes for this framebuffer
VideoModeList myWindowedModeList;
VideoModeList myFullscreenModeList;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OSystem.cxx,v 1.126 2008-05-19 21:16:58 stephena Exp $
// $Id: OSystem.cxx,v 1.127 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#include <cassert>
@ -358,6 +358,7 @@ bool OSystem::createFrameBuffer(bool showmessage)
break;
}
}
myFrameBuffer->showFrameStats(mySettings->getBool("stats"));
return true;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.cxx,v 1.144 2008-05-16 12:04:34 stephena Exp $
// $Id: Settings.cxx,v 1.145 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#include <cassert>
@ -101,6 +101,7 @@ Settings::Settings(OSystem* osystem)
setInternal("showinfo", "false");
setInternal("tiafloat", "true");
setInternal("avoxport", "");
setInternal("stats", "false");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -327,6 +328,7 @@ void Settings::usage()
<< " -autoslot <1|0> Automatically switch to next save slot when state saving\n"
<< " -ssdir <path> The directory to save snapshot files to\n"
<< " -sssingle <1|0> Generate single snapshot instead of many\n"
<< " -stats <1|0> Show scanline and framerate info during emulation\n"
<< endl
<< " -listrominfo Display contents of stella.pro, one line per ROM entry\n"
<< " -rominfo <rom> Display detailed information for the given ROM\n"

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DialogContainer.cxx,v 1.42 2008-05-11 21:18:35 stephena Exp $
// $Id: DialogContainer.cxx,v 1.43 2008-05-20 13:42:50 stephena Exp $
//============================================================================
#include "OSystem.hxx"
@ -137,7 +137,7 @@ void DialogContainer::reStack()
addDialog(myBaseDialog);
// Erase any previous messages
myOSystem->frameBuffer().hideMessage();
myOSystem->frameBuffer().enableMessages(false);
// Reset all continuous events
reset();