Add files via upload

Requested changes
This commit is contained in:
alphanu1 2018-03-26 20:22:35 +01:00 committed by GitHub
parent a44f4d1489
commit 3b9036cc79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 127 additions and 88 deletions

View File

@ -25,76 +25,99 @@
#include "video_crt_switch.h" #include "video_crt_switch.h"
int first_run; static int ra_set_core_hz;
float fly_aspect; static float ra_tmp_core_hz;
static int ra_core_width;
static int ra_core_height;
static int ra_tmp_width;
static int ra_tmp_height;
static int orig_width;
static int orig_height;
static int first_run;
static float fly_aspect;
void switch_res_core(int width, int height, float hz){ void switch_res_core(int width, int height, float hz)
{
/* ben_core_hz float passed from with in void video_driver_monitor_adjust_system_rates(void) */ /* ben_core_hz float passed from with in void video_driver_monitor_adjust_system_rates(void) */
ben_core_width = width; ra_core_width = width;
ben_core_height = height; ra_core_height = height;
ben_core_hz = hz; ra_core_hz = hz;
check_first_run(); check_first_run();
if (ben_tmp_height != ben_core_height || ben_core_width != ben_tmp_width){ /* detect resolution change and switch */ if (ra_tmp_height != ra_core_height || ra_core_width != ra_tmp_width)
screen_setup_aspect(width,height); { /* detect resolution change and switch */
} screen_setup_aspect(width,height);
}
if (video_driver_get_aspect_ratio() != fly_aspect){ /* check aspect is correct else change */ if (video_driver_get_aspect_ratio() != fly_aspect)
video_driver_set_aspect_ratio_value((float)fly_aspect); { /* check aspect is correct else change */
ben_poke_video(); video_driver_set_aspect_ratio_value((float)fly_aspect);
} crt_poke_video();
}
} }
void check_first_run(){ /* ruin of first boot to get current display resolution */ void check_first_run()
if (first_run != 1){ { /* ruin of first boot to get current display resolution */
if (first_run != 1)
{
orig_height = GetSystemMetrics(SM_CYSCREEN); orig_height = GetSystemMetrics(SM_CYSCREEN);
orig_width = GetSystemMetrics(SM_CXSCREEN); orig_width = GetSystemMetrics(SM_CXSCREEN);
} }
first_run = 1; first_run = 1;
} }
void screen_setup_aspect(int width, int height){ /* create correct aspect to fit video if resolution does not exist */ void screen_setup_aspect(int width, int height)
{ /* create correct aspect to fit video if resolution does not exist */
switch_crt_hz(); switch_crt_hz();
/* get original resolution of core */ /* get original resolution of core */
if (width >= 1900){ if (width >= 1900)
if (height == 4){ /* detect menu only */ {
if (height == 4)
{ /* detect menu only */
height = 480; height = 480;
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
} }
if (height < 191 && height != 144){ if (height < 191 && height != 144)
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
height = 200; height = 200;
} }
if (height > 191){ if (height > 191)
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
} }
if (height == 144 && set_ben_core_hz == 50){ if (height == 144 && ra_set_core_hz == 50)
{
height = 288; height = 288;
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
} }
if (height > 200 && height < 224){ if (height > 200 && height < 224)
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
ben_core_height = 224; height = 224;
} }
if (height > 224 && height < 240){ if (height > 224 && height < 240)
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
ben_core_height = 240; height = 240;
} }
if (height > 240 && height < 255 ){ if (height > 240 && height < 255 )
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
ben_core_height = 254; height = 254;
} }
if (height == 528 && set_ben_core_hz == 60){ if (height == 528 && ra_set_core_hz == 60)
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
ben_core_height = 480; height = 480;
} }
if (height >= 240 && height < 255 && set_ben_core_hz == 55){ if (height >= 240 && height < 255 && ra_set_core_hz == 55)
{
aspect_ratio_switch(width,height); aspect_ratio_switch(width,height);
ben_core_height = 254; height = 254;
} }
} }
@ -103,42 +126,50 @@ void screen_setup_aspect(int width, int height){ /* create correct aspect to fit
void switch_res_crt(int width, int height){ void switch_res_crt(int width, int height){
if ( height > 100){ if ( height > 100)
{
switch_res(width, height,0); switch_res(width, height,0);
ben_poke_video(); crt_poke_video();
ben_tmp_height = ben_core_height; ra_tmp_height = ra_core_height;
ben_tmp_width = ben_core_width; ra_tmp_width = ra_core_width;
} }
} }
void aspect_ratio_switch(int width,int height){ /* send aspect float to videeo_driver */ void aspect_ratio_switch(int width,int height)
fly_aspect = (float)width/height; { /* send aspect float to videeo_driver */
video_driver_set_aspect_ratio_value((float)fly_aspect); fly_aspect = (float)width/height;
video_driver_set_aspect_ratio_value((float)fly_aspect);
} }
void switch_crt_hz(){ /* set hz float an int for windows switching */ void switch_crt_hz()
{ /* set hz float an int for windows switching */
if (ben_core_hz != ben_tmp_core_hz){ if (ra_core_hz != ra_tmp_core_hz)
if (ben_core_hz < 53 ){ {
set_ben_core_hz = 50; if (ra_core_hz < 53 )
{
ra_set_core_hz = 50;
} }
if (ben_core_hz >= 53 && ben_core_hz < 57){ if (ra_core_hz >= 53 && ra_core_hz < 57)
set_ben_core_hz = 55; {
ra_set_core_hz = 55;
} }
if (ben_core_hz >= 57 ){ if (ra_core_hz >= 57 )
set_ben_core_hz = 60; {
ra_set_core_hz = 60;
} }
video_monitor_set_refresh_rate(ben_core_hz); video_monitor_set_refresh_rate(ra_core_hz);
ben_tmp_core_hz = ben_core_hz; ra_tmp_core_hz = ra_core_hz;
} }
} }
void switch_res(int width, int height, int f_restore){ /* windows function to swith resolutions */ void switch_res(int width, int height, int f_restore)
{ /* windows function to swith resolutions */
DEVMODE curDevmode; DEVMODE curDevmode;
DEVMODE devmode; DEVMODE devmode;
@ -146,49 +177,63 @@ void switch_res(int width, int height, int f_restore){ /* windows function to s
int iModeNum; int iModeNum;
int depth = 0; int depth = 0;
int freq; int freq;
if (f_restore == 0){ if (f_restore == 0)
freq = set_ben_core_hz; {
} else { freq = ra_set_core_hz;
}
else
{
freq = 0; freq = 0;
} }
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode);
if (width == curDevmode.dmPelsWidth){ if (width == curDevmode.dmPelsWidth)
{
width = 0; /* used to stop superresolution bug */ width = 0; /* used to stop superresolution bug */
} }
if (width == 0) { if (width == 0)
{
width = curDevmode.dmPelsWidth; width = curDevmode.dmPelsWidth;
} }
if (height == 0) { if (height == 0)
{
height = curDevmode.dmPelsHeight; height = curDevmode.dmPelsHeight;
} }
if (depth == 0) { if (depth == 0)
{
depth = curDevmode.dmBitsPerPel; depth = curDevmode.dmBitsPerPel;
} }
if (freq == 0) { if (freq == 0)
{
freq = curDevmode.dmDisplayFrequency; freq = curDevmode.dmDisplayFrequency;
} }
for (iModeNum = 0; ; iModeNum++) { for (iModeNum = 0; ; iModeNum++)
if (EnumDisplaySettings(NULL, iModeNum, &devmode)) { {
if (EnumDisplaySettings(NULL, iModeNum, &devmode))
{
if (devmode.dmPelsWidth != width) { if (devmode.dmPelsWidth != width)
{
continue; continue;
} }
if (devmode.dmPelsHeight != height) { if (devmode.dmPelsHeight != height)
{
continue; continue;
} }
if (devmode.dmBitsPerPel != depth) { if (devmode.dmBitsPerPel != depth)
{
continue; continue;
} }
if (devmode.dmDisplayFrequency != freq) { if (devmode.dmDisplayFrequency != freq)
{
continue; continue;
} }
@ -196,10 +241,12 @@ void switch_res(int width, int height, int f_restore){ /* windows function to s
devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
LONG res = ChangeDisplaySettings(&devmode, CDS_TEST); LONG res = ChangeDisplaySettings(&devmode, CDS_TEST);
switch (res) { switch (res)
{
case DISP_CHANGE_SUCCESSFUL: case DISP_CHANGE_SUCCESSFUL:
res = ChangeDisplaySettings(&devmode, flags); res = ChangeDisplaySettings(&devmode, flags);
switch (res) { switch (res)
{
case DISP_CHANGE_SUCCESSFUL: case DISP_CHANGE_SUCCESSFUL:
return; return;
@ -222,15 +269,15 @@ void switch_res(int width, int height, int f_restore){ /* windows function to s
break; break;
} }
} }
else { else
{
break; break;
} }
} }
} }
void video_restore(){ void video_restore()
{
switch_res(orig_width, orig_height,1); switch_res(orig_width, orig_height,1);
} }

View File

@ -17,16 +17,8 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
static int ben_core_width;
static int ben_core_height;
static int ben_tmp_width;
static int ben_tmp_height;
static int orig_width;
static int orig_height;
static float ben_core_hz;
static int set_ben_core_hz;
static float ben_tmp_core_hz;
static float ra_core_hz; /* Shared with video_driver.c */
void switch_res_core(int width, int height, float hz); void switch_res_core(int width, int height, float hz);
void check_first_run(); void check_first_run();

View File

@ -1418,13 +1418,13 @@ void video_driver_monitor_adjust_system_rates(void)
const struct retro_system_timing *info = (const struct retro_system_timing*)&video_driver_av_info.timing; const struct retro_system_timing *info = (const struct retro_system_timing*)&video_driver_av_info.timing;
rarch_ctl(RARCH_CTL_UNSET_NONBLOCK_FORCED, NULL); rarch_ctl(RARCH_CTL_UNSET_NONBLOCK_FORCED, NULL);
ben_core_hz = info->fps; ra_core_hz = info->fps;
if (!info || info->fps <= 0.0) if (!info || info->fps <= 0.0)
return; return;
if (crt_switching_active == true){ if (crt_switching_active == true){
timing_skew = fabs(1.0f - info->fps / ben_core_hz); timing_skew = fabs(1.0f - info->fps / ra_core_hz);
}else { }else {
timing_skew = fabs(1.0f - info->fps / video_refresh_rate); timing_skew = fabs(1.0f - info->fps / video_refresh_rate);
} }
@ -1438,7 +1438,7 @@ void video_driver_monitor_adjust_system_rates(void)
(float)info->fps); (float)info->fps);
if (crt_switching_active == true){ if (crt_switching_active == true){
if (info->fps <= ben_core_hz) if (info->fps <= ra_core_hz)
return; return;
} else { } else {
if (info->fps <= video_refresh_rate) if (info->fps <= video_refresh_rate)
@ -2607,7 +2607,7 @@ void video_driver_frame(const void *data, unsigned width,
if (video_info.crt_switch_resolution_super == 1920){ if (video_info.crt_switch_resolution_super == 1920){
width = 1920; width = 1920;
} }
switch_res_core(width, height, ben_core_hz); switch_res_core(width, height, ra_core_hz);
} else if (video_info.crt_switch_resolution == false){ } else if (video_info.crt_switch_resolution == false){
crt_switching_active = false; crt_switching_active = false;
} }
@ -2616,7 +2616,7 @@ void video_driver_frame(const void *data, unsigned width,
} }
void ben_poke_video(){ void crt_poke_video(){
video_driver_poke->apply_state_changes(video_driver_data); video_driver_poke->apply_state_changes(video_driver_data);
} }

View File

@ -72,7 +72,7 @@ RETRO_BEGIN_DECLS
#define MAX_VARIABLES 64 #define MAX_VARIABLES 64
/* Added for resolution wswitching */ /* Added for resolution wswitching */
void ben_poke_video(); void crt_poke_video();
/* Added for resolution wswitching */ /* Added for resolution wswitching */