mirror of https://github.com/stella-emu/stella.git
Changed framerate timing to be based on the number of scanlines found
in auto-detect mode. This fixes an issue with the latest JunoFirst beta, which had sound skipping because it has 266 scanlines but ran at 60fps (when it should have been ~59.09 fps or so). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1520 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
b270f7f231
commit
bd0393352e
|
@ -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: SoundNull.hxx,v 1.7 2008-02-06 13:45:19 stephena Exp $
|
||||
// $Id: SoundNull.hxx,v 1.8 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUND_NULL_HXX
|
||||
|
@ -31,7 +31,7 @@ class Deserializer;
|
|||
is completely disabled.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: SoundNull.hxx,v 1.7 2008-02-06 13:45:19 stephena Exp $
|
||||
@version $Id: SoundNull.hxx,v 1.8 2008-05-19 21:16:58 stephena Exp $
|
||||
*/
|
||||
class SoundNull : public Sound
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ class SoundNull : public Sound
|
|||
|
||||
@param framerate The base framerate depending on NTSC or PAL ROM
|
||||
*/
|
||||
void setFrameRate(uInt32 framerate) { }
|
||||
void setFrameRate(float framerate) { }
|
||||
|
||||
/**
|
||||
Initializes the sound device. This must be called before any
|
||||
|
|
|
@ -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: SoundSDL.cxx,v 1.42 2008-03-31 00:59:30 stephena Exp $
|
||||
// $Id: SoundSDL.cxx,v 1.43 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifdef SOUND_SUPPORT
|
||||
|
@ -45,7 +45,7 @@ SoundSDL::SoundSDL(OSystem* osystem)
|
|||
myIsEnabled(osystem->settings().getBool("sound")),
|
||||
myIsInitializedFlag(false),
|
||||
myLastRegisterSetCycle(0),
|
||||
myDisplayFrameRate(60),
|
||||
myDisplayFrameRate(60.0),
|
||||
myNumChannels(1),
|
||||
myFragmentSizeLogBase2(0),
|
||||
myIsMuted(false),
|
||||
|
@ -281,7 +281,7 @@ void SoundSDL::setChannels(uInt32 channels)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundSDL::setFrameRate(uInt32 framerate)
|
||||
void SoundSDL::setFrameRate(float framerate)
|
||||
{
|
||||
// FIXME, we should clear out the queue or adjust the values in it
|
||||
myDisplayFrameRate = framerate;
|
||||
|
|
|
@ -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: SoundSDL.hxx,v 1.19 2008-02-06 13:45:19 stephena Exp $
|
||||
// $Id: SoundSDL.hxx,v 1.20 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUND_SDL_HXX
|
||||
|
@ -34,7 +34,7 @@ class OSystem;
|
|||
This class implements the sound API for SDL.
|
||||
|
||||
@author Stephen Anthony and Bradford W. Mott
|
||||
@version $Id: SoundSDL.hxx,v 1.19 2008-02-06 13:45:19 stephena Exp $
|
||||
@version $Id: SoundSDL.hxx,v 1.20 2008-05-19 21:16:58 stephena Exp $
|
||||
*/
|
||||
class SoundSDL : public Sound
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ class SoundSDL : public Sound
|
|||
|
||||
@param framerate The base framerate depending on NTSC or PAL ROM
|
||||
*/
|
||||
void setFrameRate(uInt32 framerate);
|
||||
void setFrameRate(float framerate);
|
||||
|
||||
/**
|
||||
Initializes the sound device. This must be called before any
|
||||
|
@ -253,7 +253,7 @@ class SoundSDL : public Sound
|
|||
Int32 myLastRegisterSetCycle;
|
||||
|
||||
// Indicates the base framerate depending on if the ROM is NTSC or PAL
|
||||
uInt32 myDisplayFrameRate;
|
||||
float myDisplayFrameRate;
|
||||
|
||||
// Indicates the number of channels (mono or stereo)
|
||||
uInt32 myNumChannels;
|
||||
|
|
|
@ -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: Console.cxx,v 1.143 2008-05-19 02:53:57 stephena Exp $
|
||||
// $Id: Console.cxx,v 1.144 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -66,7 +66,7 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
myProperties(props),
|
||||
myAVox(0),
|
||||
myDisplayFormat("NTSC"),
|
||||
myFramerate(60),
|
||||
myFramerate(60.0),
|
||||
myUserPaletteDefined(false)
|
||||
{
|
||||
myControllers[0] = 0;
|
||||
|
@ -126,6 +126,7 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
|
||||
// Auto-detect NTSC/PAL mode if it's requested
|
||||
myDisplayFormat = myProperties.get(Display_Format);
|
||||
float avgScanlineCount = 0.0;
|
||||
vidinfo << " Display Format: " << myDisplayFormat;
|
||||
if(myDisplayFormat == "AUTO-DETECT" ||
|
||||
myOSystem->settings().getBool("rominfo"))
|
||||
|
@ -136,14 +137,18 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
// Unfortunately, this means we have to always enable 'fastscbios',
|
||||
// since otherwise the BIOS loading will take over 250 frames!
|
||||
mySystem->reset();
|
||||
int palCount = 0;
|
||||
int palCount = 0, scanlineCount = 0;
|
||||
for(int i = 0; i < 60; ++i)
|
||||
{
|
||||
myMediaSource->update();
|
||||
if(i >= 30 && myMediaSource->scanlines() > 285)
|
||||
++palCount;
|
||||
if(i >= 30)
|
||||
{
|
||||
if(myMediaSource->scanlines() > 285)
|
||||
++palCount;
|
||||
scanlineCount += myMediaSource->scanlines();
|
||||
}
|
||||
}
|
||||
|
||||
avgScanlineCount = scanlineCount / 30.0;
|
||||
myDisplayFormat = (palCount >= 15) ? "PAL" : "NTSC";
|
||||
if(myProperties.get(Display_Format) == "AUTO-DETECT")
|
||||
vidinfo << " ==> " << myDisplayFormat;
|
||||
|
@ -156,13 +161,23 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
if(myDisplayFormat == "NTSC" || myDisplayFormat == "PAL60" ||
|
||||
myDisplayFormat == "SECAM60")
|
||||
{
|
||||
// Assume we've got ~262 scanlines (NTSC-like format)
|
||||
myFramerate = 60;
|
||||
// Try to be as accurate as possible with the framerate
|
||||
// Use the scanline count if available, otherwise assume we've got
|
||||
// ~262 scanlines (NTSC-like format)
|
||||
if(avgScanlineCount > 0.0)
|
||||
myFramerate = 15720.0 / avgScanlineCount;
|
||||
else
|
||||
myFramerate = 60.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume we've got ~312 scanlines (PAL-like format)
|
||||
myFramerate = 50;
|
||||
// Try to be as accurate as possible with the framerate
|
||||
// Use the scanline count if available, otherwise assume we've got
|
||||
// ~312 scanlines (PAL-like format)
|
||||
if(avgScanlineCount > 0.0)
|
||||
myFramerate = 15600.0 / avgScanlineCount;
|
||||
else
|
||||
myFramerate = 50.0;
|
||||
|
||||
if(myProperties.get(Display_Height) == "210")
|
||||
myProperties.set(Display_Height, "250");
|
||||
|
@ -262,7 +277,7 @@ void Console::toggleFormat()
|
|||
|
||||
if(myDisplayFormat.compare(0, 4, "NTSC") == 0)
|
||||
{
|
||||
if(myFramerate == 60)
|
||||
if(myFramerate > 55.0)
|
||||
{
|
||||
format = "PAL60";
|
||||
message = "PAL palette (PAL60)";
|
||||
|
@ -275,7 +290,7 @@ void Console::toggleFormat()
|
|||
}
|
||||
else if(myDisplayFormat.compare(0, 3, "PAL") == 0)
|
||||
{
|
||||
if(myFramerate == 60)
|
||||
if(myFramerate > 55.0)
|
||||
{
|
||||
format = "SECAM";
|
||||
message = "SECAM palette (SECAM60)";
|
||||
|
@ -288,7 +303,7 @@ void Console::toggleFormat()
|
|||
}
|
||||
else if(myDisplayFormat.compare(0, 5, "SECAM") == 0)
|
||||
{
|
||||
if(myFramerate == 60)
|
||||
if(myFramerate > 55.0)
|
||||
{
|
||||
format = "NTSC";
|
||||
message = "NTSC palette (NTSC)";
|
||||
|
@ -795,14 +810,14 @@ void Console::setColorLossPalette(bool loss)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 Console::getFramerate() const
|
||||
float Console::getFramerate() const
|
||||
{
|
||||
// Set the correct framerate based on the format of the ROM
|
||||
// This can be overridden by changing the framerate in the
|
||||
// VideoDialog box or on the commandline, but it can't be saved
|
||||
// (ie, framerate is now solely determined based on ROM format).
|
||||
int framerate = myOSystem->settings().getInt("framerate");
|
||||
return framerate == -1 ? myFramerate : framerate;
|
||||
return (float) framerate == -1 ? myFramerate : framerate;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: Console.hxx,v 1.66 2008-05-08 20:23:31 stephena Exp $
|
||||
// $Id: Console.hxx,v 1.67 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CONSOLE_HXX
|
||||
|
@ -39,7 +39,7 @@ class System;
|
|||
This class represents the entire game console.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Console.hxx,v 1.66 2008-05-08 20:23:31 stephena Exp $
|
||||
@version $Id: Console.hxx,v 1.67 2008-05-19 21:16:58 stephena Exp $
|
||||
*/
|
||||
class Console : public Serializable
|
||||
{
|
||||
|
@ -229,7 +229,7 @@ class Console : public Serializable
|
|||
Returns the framerate based on a number of factors
|
||||
(whether 'framerate' is set, what display format is in use, etc)
|
||||
*/
|
||||
uInt32 getFramerate() const;
|
||||
float getFramerate() const;
|
||||
|
||||
/**
|
||||
Toggles the TIA bit specified in the method name.
|
||||
|
@ -306,7 +306,7 @@ class Console : public Serializable
|
|||
string myDisplayFormat;
|
||||
|
||||
// The currently defined display framerate
|
||||
uInt32 myFramerate;
|
||||
float myFramerate;
|
||||
|
||||
// Indicates whether an external palette was found and
|
||||
// successfully loaded
|
||||
|
|
|
@ -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.127 2008-04-02 21:22:16 stephena Exp $
|
||||
// $Id: FrameBuffer.cxx,v 1.128 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -205,7 +205,7 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position,
|
|||
|
||||
// Precompute the message coordinates
|
||||
myMessage.text = message;
|
||||
myMessage.counter = myOSystem->frameRate() << 1; // Show message for 2 seconds
|
||||
myMessage.counter = uInt32(myOSystem->frameRate()) << 1; // Show message for 2 seconds
|
||||
myMessage.color = color;
|
||||
|
||||
myMessage.w = myOSystem->font().getStringWidth(myMessage.text) + 10;
|
||||
|
|
|
@ -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.125 2008-05-16 23:56:30 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.126 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -287,10 +287,10 @@ void OSystem::setBaseDir(const string& basedir)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystem::setFramerate(uInt32 framerate)
|
||||
void OSystem::setFramerate(float framerate)
|
||||
{
|
||||
myDisplayFrameRate = framerate;
|
||||
myTimePerFrame = (uInt32)(1000000.0 / (double)myDisplayFrameRate);
|
||||
myTimePerFrame = (uInt32)(1000000.0 / myDisplayFrameRate);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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.hxx,v 1.65 2008-05-16 23:56:30 stephena Exp $
|
||||
// $Id: OSystem.hxx,v 1.66 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef OSYSTEM_HXX
|
||||
|
@ -56,7 +56,7 @@ typedef Common::Array<Resolution> ResolutionList;
|
|||
other objects belong.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: OSystem.hxx,v 1.65 2008-05-16 23:56:30 stephena Exp $
|
||||
@version $Id: OSystem.hxx,v 1.66 2008-05-19 21:16:58 stephena Exp $
|
||||
*/
|
||||
class OSystem
|
||||
{
|
||||
|
@ -209,7 +209,7 @@ class OSystem
|
|||
|
||||
@param framerate The video framerate to use
|
||||
*/
|
||||
virtual void setFramerate(uInt32 framerate);
|
||||
virtual void setFramerate(float framerate);
|
||||
|
||||
/**
|
||||
Set all config file paths for the OSystem.
|
||||
|
@ -226,7 +226,7 @@ class OSystem
|
|||
|
||||
@return The video framerate currently in use
|
||||
*/
|
||||
inline uInt32 frameRate() const { return myDisplayFrameRate; }
|
||||
inline float frameRate() const { return myDisplayFrameRate; }
|
||||
|
||||
/**
|
||||
Get the maximum dimensions of a window for the video hardware.
|
||||
|
@ -492,7 +492,7 @@ class OSystem
|
|||
ResolutionList myResolutions;
|
||||
|
||||
// Number of times per second to iterate through the main loop
|
||||
uInt32 myDisplayFrameRate;
|
||||
float myDisplayFrameRate;
|
||||
|
||||
// Time per frame for a video update, based on the current framerate
|
||||
uInt32 myTimePerFrame;
|
||||
|
|
|
@ -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: Sound.hxx,v 1.24 2008-02-06 13:45:22 stephena Exp $
|
||||
// $Id: Sound.hxx,v 1.25 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUND_HXX
|
||||
|
@ -30,7 +30,7 @@ class Deserializer;
|
|||
It has no functionality whatsoever.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Sound.hxx,v 1.24 2008-02-06 13:45:22 stephena Exp $
|
||||
@version $Id: Sound.hxx,v 1.25 2008-05-19 21:16:58 stephena Exp $
|
||||
*/
|
||||
class Sound
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ class Sound
|
|||
|
||||
@param framerate The base framerate depending on NTSC or PAL ROM
|
||||
*/
|
||||
virtual void setFrameRate(uInt32 framerate) = 0;
|
||||
virtual void setFrameRate(float framerate) = 0;
|
||||
|
||||
/**
|
||||
Initializes the sound device. This must be called before any
|
||||
|
|
|
@ -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: TIA.cxx,v 1.91 2008-05-18 20:04:30 stephena Exp $
|
||||
// $Id: TIA.cxx,v 1.92 2008-05-19 21:16:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
//#define DEBUG_HMOVE
|
||||
|
@ -195,7 +195,7 @@ void TIA::reset()
|
|||
|
||||
myFloatTIAOutputPins = mySettings.getBool("tiafloat");
|
||||
|
||||
if(myConsole.getFramerate() > 55) // NTSC
|
||||
if(myConsole.getFramerate() > 55.0) // NTSC
|
||||
{
|
||||
myColorLossEnabled = false;
|
||||
myMaximumNumberOfScanlines = 290;
|
||||
|
|
Loading…
Reference in New Issue