mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
(VIDEOCRT SWITCH) move global state to rarch_state
This commit is contained in:
parent
e04bce7dd0
commit
bc24092374
@ -33,36 +33,10 @@
|
|||||||
static void crt_rpi_switch(int width, int height, float hz, int xoffset);
|
static void crt_rpi_switch(int width, int height, float hz, int xoffset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct videocrt_switch
|
static void switch_crt_hz(videocrt_switch_t *p_switch)
|
||||||
{
|
{
|
||||||
int center_adjust;
|
|
||||||
int tmp_center_adjust;
|
|
||||||
unsigned ra_core_width;
|
|
||||||
unsigned ra_core_height;
|
|
||||||
unsigned ra_tmp_width;
|
|
||||||
unsigned ra_tmp_height;
|
|
||||||
unsigned ra_set_core_hz;
|
|
||||||
unsigned index;
|
|
||||||
|
|
||||||
float ra_core_hz;
|
|
||||||
float ra_tmp_core_hz;
|
|
||||||
float fly_aspect;
|
|
||||||
|
|
||||||
double p_clock;
|
|
||||||
} videocrt_switch_t;
|
|
||||||
|
|
||||||
/* TODO/FIXME - globals */
|
|
||||||
static videocrt_switch_t crt_switch_st;
|
|
||||||
|
|
||||||
static void switch_crt_hz(void)
|
|
||||||
{
|
|
||||||
videocrt_switch_t *p_switch = &crt_switch_st;
|
|
||||||
|
|
||||||
float ra_core_hz = p_switch->ra_core_hz;
|
float ra_core_hz = p_switch->ra_core_hz;
|
||||||
|
|
||||||
if (ra_core_hz == p_switch->ra_tmp_core_hz)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* set hz float to an int for windows switching */
|
/* set hz float to an int for windows switching */
|
||||||
if (ra_core_hz < 100)
|
if (ra_core_hz < 100)
|
||||||
{
|
{
|
||||||
@ -89,18 +63,19 @@ static void switch_crt_hz(void)
|
|||||||
p_switch->ra_tmp_core_hz = ra_core_hz;
|
p_switch->ra_tmp_core_hz = ra_core_hz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void crt_aspect_ratio_switch(unsigned width, unsigned height)
|
static void crt_aspect_ratio_switch(
|
||||||
|
videocrt_switch_t *p_switch,
|
||||||
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
videocrt_switch_t *p_switch = &crt_switch_st;
|
|
||||||
/* send aspect float to video_driver */
|
/* send aspect float to video_driver */
|
||||||
p_switch->fly_aspect = (float)width / height;
|
p_switch->fly_aspect = (float)width / height;
|
||||||
video_driver_set_aspect_ratio_value((float)p_switch->fly_aspect);
|
video_driver_set_aspect_ratio_value((float)p_switch->fly_aspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void switch_res_crt(unsigned width, unsigned height)
|
static void switch_res_crt(
|
||||||
|
videocrt_switch_t *p_switch,
|
||||||
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
videocrt_switch_t *p_switch = &crt_switch_st;
|
|
||||||
|
|
||||||
video_display_server_set_resolution(width, height,
|
video_display_server_set_resolution(width, height,
|
||||||
p_switch->ra_set_core_hz,
|
p_switch->ra_set_core_hz,
|
||||||
p_switch->ra_core_hz,
|
p_switch->ra_core_hz,
|
||||||
@ -120,15 +95,17 @@ static void switch_res_crt(unsigned width, unsigned height)
|
|||||||
|
|
||||||
/* Create correct aspect to fit video
|
/* Create correct aspect to fit video
|
||||||
* if resolution does not exist */
|
* if resolution does not exist */
|
||||||
static void crt_screen_setup_aspect(unsigned width, unsigned height)
|
static void crt_screen_setup_aspect(
|
||||||
|
videocrt_switch_t *p_switch,
|
||||||
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
videocrt_switch_t *p_switch = &crt_switch_st;
|
|
||||||
#if defined(HAVE_VIDEOCORE)
|
#if defined(HAVE_VIDEOCORE)
|
||||||
if (height > 300)
|
if (height > 300)
|
||||||
height = height/2;
|
height = height/2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch_crt_hz();
|
if (p_switch->ra_core_hz != p_switch->ra_tmp_core_hz)
|
||||||
|
switch_crt_hz(p_switch);
|
||||||
|
|
||||||
/* Get original resolution of core */
|
/* Get original resolution of core */
|
||||||
if (height == 4)
|
if (height == 4)
|
||||||
@ -139,63 +116,88 @@ static void crt_screen_setup_aspect(unsigned width, unsigned height)
|
|||||||
|
|
||||||
height = 240;
|
height = 240;
|
||||||
|
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height < 200 && height != 144)
|
if (height < 200 && height != 144)
|
||||||
{
|
{
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
height = 200;
|
height = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > 200)
|
if (height > 200)
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
|
|
||||||
if (height == 144 && p_switch->ra_set_core_hz == 50)
|
if (height == 144 && p_switch->ra_set_core_hz == 50)
|
||||||
{
|
{
|
||||||
height = 288;
|
height = 288;
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > 200 && height < 224)
|
if (height > 200 && height < 224)
|
||||||
{
|
{
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
height = 224;
|
height = 224;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > 224 && height < 240)
|
if (height > 224 && height < 240)
|
||||||
{
|
{
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
height = 240;
|
height = 240;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > 240 && height < 255)
|
if (height > 240 && height < 255)
|
||||||
{
|
{
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
height = 254;
|
height = 254;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height == 528 && p_switch->ra_set_core_hz == 60)
|
if (height == 528 && p_switch->ra_set_core_hz == 60)
|
||||||
{
|
{
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
height = 480;
|
height = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height >= 240 && height < 255 && p_switch->ra_set_core_hz == 55)
|
if (height >= 240 && height < 255 && p_switch->ra_set_core_hz == 55)
|
||||||
{
|
{
|
||||||
crt_aspect_ratio_switch(width, height);
|
crt_aspect_ratio_switch(p_switch, width, height);
|
||||||
height = 254;
|
height = 254;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_res_crt(width, height);
|
switch_res_crt(p_switch, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void crt_switch_res_core(unsigned width, unsigned height,
|
static int crt_compute_dynamic_width(
|
||||||
float hz, unsigned crt_mode,
|
videocrt_switch_t *p_switch,
|
||||||
int crt_switch_center_adjust, int monitor_index, bool dynamic)
|
int width)
|
||||||
{
|
{
|
||||||
videocrt_switch_t *p_switch = &crt_switch_st;
|
unsigned i;
|
||||||
|
int dynamic_width = 0;
|
||||||
|
unsigned min_height = 261;
|
||||||
|
|
||||||
|
#if defined(HAVE_VIDEOCORE)
|
||||||
|
p_switch->p_clock = 32000000;
|
||||||
|
#else
|
||||||
|
p_switch->p_clock = 21000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
dynamic_width = width * i;
|
||||||
|
if ((dynamic_width * min_height * p_switch->ra_core_hz)
|
||||||
|
> p_switch->p_clock)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return dynamic_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void crt_switch_res_core(
|
||||||
|
videocrt_switch_t *p_switch,
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
float hz, unsigned crt_mode,
|
||||||
|
int crt_switch_center_adjust,
|
||||||
|
int monitor_index, bool dynamic)
|
||||||
|
{
|
||||||
/* ra_core_hz float passed from within
|
/* ra_core_hz float passed from within
|
||||||
* video_driver_monitor_adjust_system_rates() */
|
* video_driver_monitor_adjust_system_rates() */
|
||||||
if (width == 4)
|
if (width == 4)
|
||||||
@ -208,7 +210,7 @@ void crt_switch_res_core(unsigned width, unsigned height,
|
|||||||
p_switch->ra_core_hz = hz;
|
p_switch->ra_core_hz = hz;
|
||||||
|
|
||||||
if (dynamic)
|
if (dynamic)
|
||||||
p_switch->ra_core_width = crt_compute_dynamic_width(width);
|
p_switch->ra_core_width = crt_compute_dynamic_width(p_switch, width);
|
||||||
else
|
else
|
||||||
p_switch->ra_core_width = width;
|
p_switch->ra_core_width = width;
|
||||||
|
|
||||||
@ -230,6 +232,7 @@ void crt_switch_res_core(unsigned width, unsigned height,
|
|||||||
(p_switch->center_adjust != p_switch->tmp_center_adjust)
|
(p_switch->center_adjust != p_switch->tmp_center_adjust)
|
||||||
)
|
)
|
||||||
crt_screen_setup_aspect(
|
crt_screen_setup_aspect(
|
||||||
|
p_switch,
|
||||||
p_switch->ra_core_width,
|
p_switch->ra_core_width,
|
||||||
p_switch->ra_core_height);
|
p_switch->ra_core_height);
|
||||||
|
|
||||||
@ -245,29 +248,6 @@ void crt_switch_res_core(unsigned width, unsigned height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int crt_compute_dynamic_width(int width)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
int dynamic_width = 0;
|
|
||||||
unsigned min_height = 261;
|
|
||||||
videocrt_switch_t *p_switch = &crt_switch_st;
|
|
||||||
|
|
||||||
#if defined(HAVE_VIDEOCORE)
|
|
||||||
p_switch->p_clock = 32000000;
|
|
||||||
#else
|
|
||||||
p_switch->p_clock = 21000000;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
dynamic_width = width * i;
|
|
||||||
if ((dynamic_width * min_height * p_switch->ra_core_hz)
|
|
||||||
> p_switch->p_clock)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return dynamic_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(HAVE_VIDEOCORE)
|
#if defined(HAVE_VIDEOCORE)
|
||||||
static void crt_rpi_switch(int width, int height, float hz, int xoffset)
|
static void crt_rpi_switch(int width, int height, float hz, int xoffset)
|
||||||
{
|
{
|
||||||
|
@ -27,11 +27,33 @@
|
|||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, int monitor_index, bool dynamic);
|
typedef struct videocrt_switch
|
||||||
|
{
|
||||||
|
int center_adjust;
|
||||||
|
int tmp_center_adjust;
|
||||||
|
unsigned ra_core_width;
|
||||||
|
unsigned ra_core_height;
|
||||||
|
unsigned ra_tmp_width;
|
||||||
|
unsigned ra_tmp_height;
|
||||||
|
unsigned ra_set_core_hz;
|
||||||
|
unsigned index;
|
||||||
|
|
||||||
void crt_aspect_ratio_switch(unsigned width, unsigned height);
|
float ra_core_hz;
|
||||||
|
float ra_tmp_core_hz;
|
||||||
|
float fly_aspect;
|
||||||
|
|
||||||
int crt_compute_dynamic_width(int width);
|
double p_clock;
|
||||||
|
} videocrt_switch_t;
|
||||||
|
|
||||||
|
void crt_switch_res_core(
|
||||||
|
videocrt_switch_t *p_switch,
|
||||||
|
unsigned width,
|
||||||
|
unsigned height,
|
||||||
|
float hz,
|
||||||
|
unsigned crt_mode,
|
||||||
|
int crt_switch_center_adjust,
|
||||||
|
int monitor_index,
|
||||||
|
bool dynamic);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
|
@ -2146,6 +2146,8 @@ struct rarch_state
|
|||||||
dispgfx_widget_t dispwidget_st;
|
dispgfx_widget_t dispwidget_st;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
videocrt_switch_t crt_switch_st;
|
||||||
|
|
||||||
gfx_thumbnail_state_t gfx_thumb_state;
|
gfx_thumbnail_state_t gfx_thumb_state;
|
||||||
|
|
||||||
input_keyboard_press_t keyboard_press_cb;
|
input_keyboard_press_t keyboard_press_cb;
|
||||||
@ -30677,6 +30679,7 @@ static void video_driver_frame(const void *data, unsigned width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
crt_switch_res_core(
|
crt_switch_res_core(
|
||||||
|
&p_rarch->crt_switch_st,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
p_rarch->video_driver_core_hz,
|
p_rarch->video_driver_core_hz,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user