Merge pull request #42 from alphanu1/alphanu1-patch-41

Linux / windows hz bug fix
This commit is contained in:
alphanu1 2018-04-30 16:41:04 +01:00 committed by GitHub
commit 3edd7a6ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 6 deletions

View File

@ -48,6 +48,24 @@ static void crt_check_first_run(void)
first_run = false; first_run = false;
} }
static void switch_crt_hz(void)
{
if (ra_core_hz == ra_tmp_core_hz)
return;
/* set hz float to an int for windows switching */
if (ra_core_hz < 53)
ra_set_core_hz = 50;
if (ra_core_hz >= 53 && ra_core_hz < 57)
ra_set_core_hz = 55;
if (ra_core_hz >= 57)
ra_set_core_hz = 60;
video_monitor_set_refresh_rate(ra_set_core_hz);
ra_tmp_core_hz = ra_core_hz;
}
static void crt_aspect_ratio_switch(unsigned width, unsigned height) static void crt_aspect_ratio_switch(unsigned width, unsigned height)
{ {
/* send aspect float to videeo_driver */ /* send aspect float to videeo_driver */
@ -60,7 +78,7 @@ static void switch_res_crt(unsigned width, unsigned height)
if (height > 100) if (height > 100)
{ {
video_display_server_switch_resolution(width, height, video_display_server_switch_resolution(width, height,
0, ra_core_hz); ra_set_core_hz, ra_core_hz);
video_driver_apply_state_changes(); video_driver_apply_state_changes();
} }
} }
@ -69,6 +87,7 @@ static void switch_res_crt(unsigned width, unsigned height)
static void crt_screen_setup_aspect(unsigned width, unsigned height) static void crt_screen_setup_aspect(unsigned width, unsigned height)
{ {
switch_crt_hz();
/* get original resolution of core */ /* get original resolution of core */
if (height == 4) if (height == 4)
{ {

View File

@ -84,9 +84,9 @@ bool video_display_server_set_window_decorations(bool on)
bool video_display_server_switch_resolution(unsigned width, unsigned height, bool video_display_server_switch_resolution(unsigned width, unsigned height,
int f_restore, float hz) int win_hz, float hz)
{ {
if (current_display_server && current_display_server->switch_resolution) if (current_display_server && current_display_server->switch_resolution)
return current_display_server->switch_resolution(current_display_server_data, width, height, f_restore, hz); return current_display_server->switch_resolution(current_display_server_data, width, height, win_hz, hz);
return false; return false;
} }

View File

@ -31,7 +31,7 @@ typedef struct video_display_server
bool (*set_window_progress)(void *data, int progress, bool finished); bool (*set_window_progress)(void *data, int progress, bool finished);
bool (*set_window_decorations)(void *data, bool on); bool (*set_window_decorations)(void *data, bool on);
bool (*switch_resolution)(void *data, unsigned width, bool (*switch_resolution)(void *data, unsigned width,
unsigned height, int f_restore, float hz); unsigned height, int win_hz, float hz);
const char *ident; const char *ident;
} video_display_server_t; } video_display_server_t;
@ -47,7 +47,7 @@ bool video_display_server_set_window_decorations(bool on);
bool video_display_server_switch_resolution( bool video_display_server_switch_resolution(
unsigned width, unsigned height, unsigned width, unsigned height,
int f_restore, float hz); int win_hz, float hz);
extern const video_display_server_t dispserv_win32; extern const video_display_server_t dispserv_win32;
extern const video_display_server_t dispserv_x11; extern const video_display_server_t dispserv_x11;