mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 08:37:41 +00:00
Add files via upload
Changed variable names
This commit is contained in:
parent
ff68b9244d
commit
51276a682f
@ -1,3 +1,21 @@
|
|||||||
|
/* CRT SwitchRes Core
|
||||||
|
* Copyright (C) 2018 Ben Templeman.
|
||||||
|
*
|
||||||
|
* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -11,17 +29,17 @@ int first_run;
|
|||||||
float fly_aspect;
|
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;
|
ben_core_width = width;
|
||||||
ben_core_height = height;
|
ben_core_height = height;
|
||||||
ben_core_hz = hz;
|
ben_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 (ben_tmp_height != ben_core_height || ben_core_width != ben_tmp_width){ /* detect resolution change and switch */
|
||||||
screen_setup_aspect(width,height);
|
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){ /* check aspect is correct else change */
|
||||||
video_driver_set_aspect_ratio_value((float)fly_aspect);
|
video_driver_set_aspect_ratio_value((float)fly_aspect);
|
||||||
ben_poke_video();
|
ben_poke_video();
|
||||||
}
|
}
|
||||||
@ -29,7 +47,7 @@ void switch_res_core(int width, int height, float hz){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_first_run(){ // ruin of first boot to get current display resolution
|
void check_first_run(){ /* ruin of first boot to get current display resolution */
|
||||||
if (first_run != 1){
|
if (first_run != 1){
|
||||||
orig_height = GetSystemMetrics(SM_CYSCREEN);
|
orig_height = GetSystemMetrics(SM_CYSCREEN);
|
||||||
orig_width = GetSystemMetrics(SM_CXSCREEN);
|
orig_width = GetSystemMetrics(SM_CXSCREEN);
|
||||||
@ -37,39 +55,39 @@ void check_first_run(){ // ruin of first boot to get current display resolution
|
|||||||
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){ // for low res games to be dran at res but on a 200 eight
|
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){ /// for GBA doubling
|
if (height == 144 && set_ben_core_hz == 50){
|
||||||
height = 288;
|
height = 288;
|
||||||
aspect_ratio_switch(width,height);
|
aspect_ratio_switch(width,height);
|
||||||
}
|
}
|
||||||
if (height > 200 && height < 224){ /// for mame
|
if (height > 200 && height < 224){
|
||||||
aspect_ratio_switch(width,height);
|
aspect_ratio_switch(width,height);
|
||||||
ben_core_height = 224;
|
ben_core_height = 224;
|
||||||
}
|
}
|
||||||
if (height > 224 && height < 240){ /// for mame
|
if (height > 224 && height < 240){
|
||||||
aspect_ratio_switch(width,height);
|
aspect_ratio_switch(width,height);
|
||||||
ben_core_height = 240;
|
ben_core_height = 240;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > 240 && height < 255 ){ /// for mame
|
if (height > 240 && height < 255 ){
|
||||||
aspect_ratio_switch(width,height);
|
aspect_ratio_switch(width,height);
|
||||||
ben_core_height = 254;
|
ben_core_height = 254;
|
||||||
}
|
}
|
||||||
if (height == 528 && set_ben_core_hz == 60){ /// for mame
|
if (height == 528 && set_ben_core_hz == 60){
|
||||||
aspect_ratio_switch(width,height);
|
aspect_ratio_switch(width,height);
|
||||||
ben_core_height = 480;
|
ben_core_height = 480;
|
||||||
}
|
}
|
||||||
@ -96,12 +114,12 @@ void switch_res_crt(int width, int height){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void aspect_ratio_switch(int width,int height){ // send aspect float to videeo_driver
|
void aspect_ratio_switch(int width,int height){ /* send aspect float to videeo_driver */
|
||||||
fly_aspect = (float)width/height;
|
fly_aspect = (float)width/height;
|
||||||
video_driver_set_aspect_ratio_value((float)fly_aspect);
|
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 (ben_core_hz != ben_tmp_core_hz){
|
||||||
if (ben_core_hz < 53 ){
|
if (ben_core_hz < 53 ){
|
||||||
@ -120,7 +138,7 @@ void switch_crt_hz(){ // set hz float an int for windows switching
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -137,7 +155,7 @@ void switch_res(int width, int height, int f_restore){ // windows function to s
|
|||||||
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) {
|
||||||
@ -155,7 +173,7 @@ void switch_res(int width, int height, int f_restore){ // windows function to s
|
|||||||
|
|
||||||
for (iModeNum = 0; ; iModeNum++) {
|
for (iModeNum = 0; ; iModeNum++) {
|
||||||
if (EnumDisplaySettings(NULL, iModeNum, &devmode)) {
|
if (EnumDisplaySettings(NULL, iModeNum, &devmode)) {
|
||||||
// See if this setting has the right width.
|
|
||||||
if (devmode.dmPelsWidth != width) {
|
if (devmode.dmPelsWidth != width) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -164,17 +182,17 @@ void switch_res(int width, int height, int f_restore){ // windows function to s
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if this setting has the right depth.
|
|
||||||
if (devmode.dmBitsPerPel != depth) {
|
if (devmode.dmBitsPerPel != depth) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if this setting has the right frequency.
|
|
||||||
if (devmode.dmDisplayFrequency != freq) {
|
if (devmode.dmDisplayFrequency != freq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This new setting satisfies all the criteria. Try it.
|
|
||||||
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);
|
||||||
|
|
||||||
@ -186,21 +204,21 @@ void switch_res(int width, int height, int f_restore){ // windows function to s
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case DISP_CHANGE_NOTUPDATED:
|
case DISP_CHANGE_NOTUPDATED:
|
||||||
// printf("Settings changed, but not permanently.\n");
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// printf("Something odd happened.\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DISP_CHANGE_RESTART:
|
case DISP_CHANGE_RESTART:
|
||||||
//printf("The computer needs to be restarted to switch to these settings\n");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//printf("Something odd happened.\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +227,7 @@ void switch_res(int width, int height, int f_restore){ // windows function to s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("Couldn't change settings.\n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/* CRT SwitchRes Core
|
||||||
|
* Copyright (C) 2018 Ben Templeman.
|
||||||
|
*
|
||||||
|
* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
static int ben_core_width;
|
static int ben_core_width;
|
||||||
static int ben_core_height;
|
static int ben_core_height;
|
||||||
static int ben_tmp_width;
|
static int ben_tmp_width;
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
#define video_driver_context_unlock() ((void)0)
|
#define video_driver_context_unlock() ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool CRT_Switching_active; //ben
|
bool crt_switching_active;
|
||||||
|
|
||||||
typedef struct video_pixel_scaler
|
typedef struct video_pixel_scaler
|
||||||
{
|
{
|
||||||
@ -1423,7 +1423,7 @@ void video_driver_monitor_adjust_system_rates(void)
|
|||||||
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 / ben_core_hz);
|
||||||
}else {
|
}else {
|
||||||
timing_skew = fabs(1.0f - info->fps / video_refresh_rate);
|
timing_skew = fabs(1.0f - info->fps / video_refresh_rate);
|
||||||
@ -1437,10 +1437,7 @@ void video_driver_monitor_adjust_system_rates(void)
|
|||||||
video_refresh_rate,
|
video_refresh_rate,
|
||||||
(float)info->fps);
|
(float)info->fps);
|
||||||
|
|
||||||
|
if (crt_switching_active == true){
|
||||||
// if (info->fps <= video_refresh_rate) // create options to choose between these!!!!
|
|
||||||
// return;
|
|
||||||
if (CRT_Switching_active == true){
|
|
||||||
if (info->fps <= ben_core_hz)
|
if (info->fps <= ben_core_hz)
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -1574,7 +1571,7 @@ static void video_driver_lock_new(void)
|
|||||||
void video_driver_destroy(void)
|
void video_driver_destroy(void)
|
||||||
{
|
{
|
||||||
video_display_server_destroy();
|
video_display_server_destroy();
|
||||||
video_restore(); //ben
|
video_restore();
|
||||||
video_driver_cb_has_focus = null_driver_has_focus;
|
video_driver_cb_has_focus = null_driver_has_focus;
|
||||||
video_driver_use_rgba = false;
|
video_driver_use_rgba = false;
|
||||||
video_driver_data_own = false;
|
video_driver_data_own = false;
|
||||||
@ -2599,20 +2596,20 @@ void video_driver_frame(const void *data, unsigned width,
|
|||||||
runloop_msg_queue_push(video_info.fps_text, 2, 1, true);
|
runloop_msg_queue_push(video_info.fps_text, 2, 1, true);
|
||||||
|
|
||||||
/* trigger set resolution*/
|
/* trigger set resolution*/
|
||||||
if (video_info.CRT_Switch_Resolution == true){
|
if (video_info.crt_switch_resolution == true){
|
||||||
CRT_Switching_active = true;
|
crt_switching_active = true;
|
||||||
if (video_info.CRT_Switch_Resolution_super == 2560){
|
if (video_info.crt_switch_resolution_super == 2560){
|
||||||
width = 2560;
|
width = 2560;
|
||||||
}
|
}
|
||||||
if (video_info.CRT_Switch_Resolution_super == 3840){
|
if (video_info.crt_switch_resolution_super == 3840){
|
||||||
width = 3840;
|
width = 3840;
|
||||||
}
|
}
|
||||||
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);// ben_core_hz);
|
switch_res_core(width, height, ben_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* trigger set resolution*/
|
/* trigger set resolution*/
|
||||||
@ -2713,8 +2710,8 @@ void video_driver_build_info(video_frame_info_t *video_info)
|
|||||||
settings = config_get_ptr();
|
settings = config_get_ptr();
|
||||||
custom_vp = &settings->video_viewport_custom;
|
custom_vp = &settings->video_viewport_custom;
|
||||||
video_info->refresh_rate = settings->floats.video_refresh_rate;
|
video_info->refresh_rate = settings->floats.video_refresh_rate;
|
||||||
video_info->CRT_Switch_Resolution = settings->bools.CRT_Switch_Resolution; //ben
|
video_info->crt_switch_resolution = settings->bools.crt_switch_resolution;
|
||||||
video_info->CRT_Switch_Resolution_super = settings->uints.CRT_Switch_Resolution_super; //ben
|
video_info->crt_switch_resolution_super = settings->uints.crt_switch_resolution_super;
|
||||||
video_info->black_frame_insertion = settings->bools.video_black_frame_insertion;
|
video_info->black_frame_insertion = settings->bools.video_black_frame_insertion;
|
||||||
video_info->hard_sync = settings->bools.video_hard_sync;
|
video_info->hard_sync = settings->bools.video_hard_sync;
|
||||||
video_info->hard_sync_frames = settings->uints.video_hard_sync_frames;
|
video_info->hard_sync_frames = settings->uints.video_hard_sync_frames;
|
||||||
|
@ -71,9 +71,10 @@ RETRO_BEGIN_DECLS
|
|||||||
|
|
||||||
#define MAX_VARIABLES 64
|
#define MAX_VARIABLES 64
|
||||||
|
|
||||||
// Added for resolution wswitching
|
/* Added for resolution wswitching */
|
||||||
void ben_poke_video();
|
void ben_poke_video();
|
||||||
//Added for resolution wswitching
|
|
||||||
|
/* Added for resolution wswitching */
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -407,7 +408,7 @@ typedef struct video_frame_info
|
|||||||
bool black_frame_insertion;
|
bool black_frame_insertion;
|
||||||
bool hard_sync;
|
bool hard_sync;
|
||||||
bool fps_show;
|
bool fps_show;
|
||||||
bool CRT_Switch_Resolution; //ben
|
bool crt_switch_resolution;
|
||||||
bool statistics_show;
|
bool statistics_show;
|
||||||
bool framecount_show;
|
bool framecount_show;
|
||||||
bool scale_integer;
|
bool scale_integer;
|
||||||
@ -433,7 +434,7 @@ typedef struct video_frame_info
|
|||||||
unsigned aspect_ratio_idx;
|
unsigned aspect_ratio_idx;
|
||||||
unsigned max_swapchain_images;
|
unsigned max_swapchain_images;
|
||||||
unsigned monitor_index;
|
unsigned monitor_index;
|
||||||
unsigned CRT_Switch_Resolution_super; //ben
|
unsigned crt_switch_resolution_super;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned xmb_theme;
|
unsigned xmb_theme;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user