MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / UpdateVSyncRate

Function UpdateVSyncRate

pcsx2/Counters.cpp:334–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334void UpdateVSyncRate(bool force)
335{
336 // Notice: (and I probably repeat this elsewhere, but it's worth repeating)
337 // The PS2's vsync timer is an *independent* crystal that is fixed to either 59.94 (NTSC)
338 // or 50.0 (PAL) Hz. It has *nothing* to do with real TV timings or the real vsync of
339 // the GS's output circuit. It is the same regardless if the GS is outputting interlace
340 // or progressive scan content.
341
342 const double vertical_frequency = GetVerticalFrequency();
343
344 const double frames_per_second = vertical_frequency / 2.0;
345
346 if (vSyncInfo.Framerate != frames_per_second || vSyncInfo.VideoMode != gsVideoMode || force)
347 {
348 u32 total_scanlines = 0;
349 bool custom = false;
350
351 switch (gsVideoMode)
352 {
353 case GS_VideoMode::Uninitialized: // SYSCALL instruction hasn't executed yet, give some temporary values.
354 if (gsIsInterlaced)
355 total_scanlines = SCANLINES_TOTAL_NTSC_I;
356 else
357 total_scanlines = SCANLINES_TOTAL_NTSC_NI;
358 break;
359 case GS_VideoMode::PAL:
360 case GS_VideoMode::DVD_PAL:
361 custom = (EmuConfig.GS.FrameratePAL != Pcsx2Config::GSOptions::DEFAULT_FRAME_RATE_PAL);
362 if (gsIsInterlaced)
363 total_scanlines = SCANLINES_TOTAL_PAL_I;
364 else
365 total_scanlines = SCANLINES_TOTAL_PAL_NI;
366 break;
367 case GS_VideoMode::NTSC:
368 case GS_VideoMode::DVD_NTSC:
369 custom = (EmuConfig.GS.FramerateNTSC != Pcsx2Config::GSOptions::DEFAULT_FRAME_RATE_NTSC);
370 if (gsIsInterlaced)
371 total_scanlines = SCANLINES_TOTAL_NTSC_I;
372 else
373 total_scanlines = SCANLINES_TOTAL_NTSC_NI;
374 break;
375 case GS_VideoMode::SDTV_480P:
376 case GS_VideoMode::SDTV_576P:
377 case GS_VideoMode::HDTV_720P:
378 case GS_VideoMode::VESA:
379 total_scanlines = SCANLINES_TOTAL_NTSC_I;
380 break;
381 case GS_VideoMode::HDTV_1080P:
382 case GS_VideoMode::HDTV_1080I:
383 total_scanlines = SCANLINES_TOTAL_1080;
384 break;
385 case GS_VideoMode::Unknown:
386 default:
387 if (gsIsInterlaced)
388 total_scanlines = SCANLINES_TOTAL_NTSC_I;
389 else
390 total_scanlines = SCANLINES_TOTAL_NTSC_NI;
391 Console.Error("PCSX2-Counters: Unknown video mode detected");

Callers 5

PostLoadPrepFunction · 0.85
gsSetVideoModeFunction · 0.85
gsResetFunction · 0.85
gsWrite64_page_00Function · 0.85

Calls 6

GetVerticalFrequencyFunction · 0.85
vSyncInfoCalcFunction · 0.85
ReportVideoModeFunction · 0.85
cpuRcntSetFunction · 0.85
ErrorMethod · 0.45
WriteLnMethod · 0.45

Tested by

no test coverage detected