Correct refresh rates (game speed)
Created by: Zarkovian
Hi sonninnos,
Thank you for the work on the PUAE libretro implementation, it's great to use and very user friendly.
Below is a request to implement the proper switching between progressive and interlaced refresh rates in the libretro core, plus some background how a similar issue was solved/implemented in the psx_beetle core.
Description of issue:
The hard-coded refresh rate of 49.92Hz leads to incorrect game speed with libretro's default time-stretch settings when interlaced content is run. Solution is to have multiple refresh rates, akin this:
#define FPS_PAL_INTERLACED 50.000 #define FPS_PAL_NONINTERLACED 49.92
In PUAE the incorrect refresh rate for interlaced content is most noticable as audio crackling when interlaced content is played, or when it switches back from interlace to progressive but ends up in short field mode (312 line mode). Both make the audio go out of sync. This can also be seen if you run the "statistics" overlay which shows audio buffer saturation going in underrun/overrun.
Additional information:
The PAL Amiga can run in three rates:
Long field mode (313 lines) is approx 49.92Hz Short field mode (312 lines) is approx 50.08Hz Interlaced mode (alternating long/short field mode, 312.5 lines average) is 50.00Hz
The exact rates for these modes can be found in the WinUAE log when running content that switches between progressive and interlace mode.
Quote from Toni Wilen "PAL non-laced can be 312 or 313 (LOF bit set = 313, not set = 312, KS sets it to 313 by default), in interlaced mode number of lines alternates between 312 and 313." http://eab.abime.net/showthread.php?t=51883
Interlace is enabled with BPLCON0 LACE bit. http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0022.html
The PUAE libretro core could be improved if above refresh rates are correctly set when these modes switch during runtime.
I'm referencing a similar (fixed) issue for the PSX core here, as PSX runs also both pogressive and interlace modes, maybe it can be of help.
https://github.com/libretro/beetle-psx-libretro/issues/509 https://github.com/libretro/beetle-psx-libretro/blob/cd79168f58df84c36e78abba726b913ae5378524/rsx/rsx_intf.h
One of the challenges could be that not all software with interlaced mode on Amiga is set up properly (setting the LACE bit properly), meaning possibly LACE bit is not set but LOF bit is toggled manuallly every other frame.
An additional caveat is that apparently the 3.1 ROM resets the LOF bit to 313 line mode each frame. This can cause weird interlace behaviour even in real Amigas for some software that have setup interlace incorrectly.
Best thing is to use a 3.0 kickstart with testing AND test games/demos that switch from progressive to interlaced and back in a proper manner.
It would be really nice if the proper refresh rates for the different modes could be added to the PUAE core for libretro.