mirror of https://github.com/stella-emu/stella.git
More timing improvements.
This commit is contained in:
parent
621e0d9d79
commit
f728a32731
|
@ -742,6 +742,7 @@ void Console::setTIAProperties()
|
||||||
myTIA->setHeight(height);
|
myTIA->setHeight(height);
|
||||||
|
|
||||||
myEmulationTiming.updateFrameLayout(myTIA->frameLayout());
|
myEmulationTiming.updateFrameLayout(myTIA->frameLayout());
|
||||||
|
myEmulationTiming.updateConsoleTiming(myConsoleTiming);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -39,6 +39,7 @@ class AudioSettings;
|
||||||
#include "EventHandlerConstants.hxx"
|
#include "EventHandlerConstants.hxx"
|
||||||
#include "NTSCFilter.hxx"
|
#include "NTSCFilter.hxx"
|
||||||
#include "EmulationTiming.hxx"
|
#include "EmulationTiming.hxx"
|
||||||
|
#include "ConsoleTiming.hxx"
|
||||||
#include "frame-manager/AbstractFrameManager.hxx"
|
#include "frame-manager/AbstractFrameManager.hxx"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,16 +55,6 @@ struct ConsoleInfo
|
||||||
string DisplayFormat;
|
string DisplayFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
Contains timing information about the specified console.
|
|
||||||
*/
|
|
||||||
enum class ConsoleTiming
|
|
||||||
{
|
|
||||||
ntsc, // console with CPU running at 1.193182 MHz, NTSC colours
|
|
||||||
pal, // console with CPU running at 1.182298 MHz, PAL colours
|
|
||||||
secam // console with CPU running at 1.187500 MHz, SECAM colours
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents the entire game console.
|
This class represents the entire game console.
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,9 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
EmulationTiming::EmulationTiming(FrameLayout frameLayout) :
|
EmulationTiming::EmulationTiming(FrameLayout frameLayout, ConsoleTiming consoleTiming) :
|
||||||
myFrameLayout(frameLayout),
|
myFrameLayout(frameLayout),
|
||||||
|
myConsoleTiming(consoleTiming),
|
||||||
myPlaybackRate(44100),
|
myPlaybackRate(44100),
|
||||||
myPlaybackPeriod(512),
|
myPlaybackPeriod(512),
|
||||||
myAudioQueueExtraFragments(1),
|
myAudioQueueExtraFragments(1),
|
||||||
|
@ -49,6 +50,15 @@ EmulationTiming& EmulationTiming::updateFrameLayout(FrameLayout frameLayout)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
EmulationTiming& EmulationTiming::updateConsoleTiming(ConsoleTiming consoleTiming)
|
||||||
|
{
|
||||||
|
myConsoleTiming = consoleTiming;
|
||||||
|
recalculate();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
EmulationTiming& EmulationTiming::updatePlaybackRate(uInt32 playbackRate)
|
EmulationTiming& EmulationTiming::updatePlaybackRate(uInt32 playbackRate)
|
||||||
{
|
{
|
||||||
|
@ -164,26 +174,26 @@ void EmulationTiming::recalculate()
|
||||||
throw runtime_error("invalid frame layout");
|
throw runtime_error("invalid frame layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
float framesPerSecond;
|
switch (myConsoleTiming) {
|
||||||
switch (myFrameLayout) {
|
case ConsoleTiming::ntsc:
|
||||||
case FrameLayout::ntsc:
|
myAudioSampleRate = round(mySpeedFactor * 262 * 76 * 60) / 38;
|
||||||
framesPerSecond = mySpeedFactor * 60;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FrameLayout::pal:
|
case ConsoleTiming::pal:
|
||||||
framesPerSecond = mySpeedFactor * 50;
|
case ConsoleTiming::secam:
|
||||||
|
myCyclesPerSecond = round(mySpeedFactor * 312 * 76 * 50) / 38;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw runtime_error("invalid frame layout");
|
throw runtime_error("invalid console timing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myCyclesPerSecond = myAudioSampleRate * 38;
|
||||||
|
|
||||||
myCyclesPerFrame = 76 * myLinesPerFrame;
|
myCyclesPerFrame = 76 * myLinesPerFrame;
|
||||||
myMaxCyclesPerTimeslice = round(mySpeedFactor * myCyclesPerFrame * 2);
|
myMaxCyclesPerTimeslice = round(mySpeedFactor * myCyclesPerFrame * 2);
|
||||||
myMinCyclesPerTimeslice = round(mySpeedFactor * myCyclesPerFrame / 2);
|
myMinCyclesPerTimeslice = round(mySpeedFactor * myCyclesPerFrame / 2);
|
||||||
myCyclesPerSecond = (round(myCyclesPerFrame * framesPerSecond) / 38) * 38;
|
|
||||||
myAudioFragmentSize = round(mySpeedFactor * AUDIO_HALF_FRAMES_PER_FRAGMENT * myLinesPerFrame);
|
myAudioFragmentSize = round(mySpeedFactor * AUDIO_HALF_FRAMES_PER_FRAGMENT * myLinesPerFrame);
|
||||||
myAudioSampleRate = myCyclesPerSecond / 38;
|
|
||||||
|
|
||||||
myPrebufferFragmentCount = discreteDivCeil(
|
myPrebufferFragmentCount = discreteDivCeil(
|
||||||
myPlaybackPeriod * myAudioSampleRate,
|
myPlaybackPeriod * myAudioSampleRate,
|
||||||
|
|
|
@ -20,14 +20,17 @@
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "FrameLayout.hxx"
|
#include "FrameLayout.hxx"
|
||||||
|
#include "ConsoleTiming.hxx"
|
||||||
|
|
||||||
class EmulationTiming {
|
class EmulationTiming {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EmulationTiming(FrameLayout frameLayout = FrameLayout::ntsc);
|
EmulationTiming(FrameLayout frameLayout = FrameLayout::ntsc, ConsoleTiming consoleTiming = ConsoleTiming::ntsc);
|
||||||
|
|
||||||
EmulationTiming& updateFrameLayout(FrameLayout frameLayout);
|
EmulationTiming& updateFrameLayout(FrameLayout frameLayout);
|
||||||
|
|
||||||
|
EmulationTiming& updateConsoleTiming(ConsoleTiming consoleTiming);
|
||||||
|
|
||||||
EmulationTiming& updatePlaybackRate(uInt32 playbackRate);
|
EmulationTiming& updatePlaybackRate(uInt32 playbackRate);
|
||||||
|
|
||||||
EmulationTiming& updatePlaybackPeriod(uInt32 period);
|
EmulationTiming& updatePlaybackPeriod(uInt32 period);
|
||||||
|
@ -63,6 +66,7 @@ class EmulationTiming {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
FrameLayout myFrameLayout;
|
FrameLayout myFrameLayout;
|
||||||
|
ConsoleTiming myConsoleTiming;
|
||||||
|
|
||||||
uInt32 myPlaybackRate;
|
uInt32 myPlaybackRate;
|
||||||
uInt32 myPlaybackPeriod;
|
uInt32 myPlaybackPeriod;
|
||||||
|
|
Loading…
Reference in New Issue