PowerPC frequency determined by board stepping, config option is now just an override

This commit is contained in:
Bart Trzynadlowski 2024-01-28 21:08:12 -08:00
parent 620a581227
commit e59ecea32d
2 changed files with 30 additions and 10 deletions

View file

@ -2041,21 +2041,42 @@ ThreadError:
m_multiThreaded = false; m_multiThreaded = false;
} }
static unsigned GetCPUClockFrequencyInHz(const Game &game, Util::Config::Node &config)
{
unsigned mhz = config["PowerPCFrequency"].ValueAsDefault<unsigned>(0);
if (!mhz)
{
if (game.stepping == "1.0")
{
mhz = 66;
}
else if (game.stepping == "1.5")
{
mhz = 100;
}
else // 2.x
{
mhz = 166;
}
}
return mhz * 1000000;
}
void CModel3::RunMainBoardFrame(void) void CModel3::RunMainBoardFrame(void)
{ {
UINT32 start = CThread::GetTicks(); UINT32 start = CThread::GetTicks();
/* /*
* Compute display timings. Refresh rate is 57.524160 Hz and we assume frame timing is the same as System 24: * Compute display timings. Refresh rate is 57.524160 Hz and we assume frame timing is the same as System 24:
*
* - 25 scanlines from /VSYNC high to /BLANK high (top border)
* - 384 scanlines from /BLANK high to /BLANK low (active display)
* - 11 scanlines from /BLANK low to /VSYNC low (bottom border)
* - 4 scanlines from /VSYNC low to /VSYNC high (vertical sync. pulse)
* *
* - 25 scanlines from /VSYNC high to /BLANK high (top border) * 424 lines total: 384 display and 40 blanking/vsync.
* - 384 scanlines from /BLANK high to /BLANK low (active display)
* - 11 scanlines from /BLANK low to /VSYNC low (bottom border)
* - 4 scanlines from /VSYNC low to /VSYNC high (vertical sync. pulse)
*
* 424 lines total: 384 display and 40 blanking/vsync.
*/ */
unsigned ppcCycles = m_config["PowerPCFrequency"].ValueAs<unsigned>() * 1000000; unsigned ppcCycles = GetCPUClockFrequencyInHz(m_game, m_config);
unsigned frameCycles = (unsigned)((float)ppcCycles / 57.524160f); unsigned frameCycles = (unsigned)((float)ppcCycles / 57.524160f);
unsigned lineCycles = frameCycles / 424; unsigned lineCycles = frameCycles / 424;
unsigned dispCycles = lineCycles * (TileGen.ReadRegister(0x08) + 40); unsigned dispCycles = lineCycles * (TileGen.ReadRegister(0x08) + 40);

View file

@ -1456,7 +1456,6 @@ static Util::Config::Node DefaultConfig()
// CModel3 // CModel3
config.Set("MultiThreaded", true); config.Set("MultiThreaded", true);
config.Set("GPUMultiThreaded", true); config.Set("GPUMultiThreaded", true);
config.Set("PowerPCFrequency", "50");
// 2D and 3D graphics engines // 2D and 3D graphics engines
config.Set("MultiTexture", false); config.Set("MultiTexture", false);
config.Set("VertexShader", ""); config.Set("VertexShader", "");
@ -1561,7 +1560,7 @@ static void Help(void)
puts(" -log-level=<level> Logging threshold [Default: info]"); puts(" -log-level=<level> Logging threshold [Default: info]");
puts(""); puts("");
puts("Core Options:"); puts("Core Options:");
printf(" -ppc-frequency=<freq> PowerPC frequency in MHz [Default: %d]\n", defaultConfig["PowerPCFrequency"].ValueAs<unsigned>()); puts(" -ppc-frequency=<mhz> PowerPC frequency (default varies by stepping)");
puts(" -no-threads Disable multi-threading entirely"); puts(" -no-threads Disable multi-threading entirely");
puts(" -gpu-multi-threaded Run graphics rendering in separate thread [Default]"); puts(" -gpu-multi-threaded Run graphics rendering in separate thread [Default]");
puts(" -no-gpu-thread Run graphics rendering in main thread"); puts(" -no-gpu-thread Run graphics rendering in main thread");