From 9d23af529964c28d4b81cacf9d55f5a6ddfbdda5 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 14:56:23 +0100 Subject: [PATCH 01/46] Add files via upload --- Makefile.common | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index a0931b6a0e..d2569c9ab5 100644 --- a/Makefile.common +++ b/Makefile.common @@ -981,7 +981,8 @@ ifeq ($(HAVE_PARPORT), 1) endif ifneq ($(findstring Win32,$(OS)),) - OBJ += input/drivers/winraw_input.o + OBJ += input/drivers/winraw_input.o \ + gfx/video_crt_switch.o endif # Companion UI From 030b11c372aa542f162b04983b11ec8b6f9eb7e2 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:01:09 +0100 Subject: [PATCH 02/46] CRT SwitchRes --- configuration.c | 2 ++ configuration.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/configuration.c b/configuration.c index 020302be65..a95e8708a8 100644 --- a/configuration.c +++ b/configuration.c @@ -1242,6 +1242,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, vsync, false); SETTING_BOOL("video_hard_sync", &settings->bools.video_hard_sync, true, hard_sync, false); SETTING_BOOL("video_black_frame_insertion", &settings->bools.video_black_frame_insertion, true, black_frame_insertion, false); + SETTING_BOOL("CRT_Switch_Resolution", &settings->bools.CRT_Switch_Resolution, true, CRT_Switch_Resolution, false); //ben SETTING_BOOL("video_disable_composition", &settings->bools.video_disable_composition, true, disable_composition, false); SETTING_BOOL("pause_nonactive", &settings->bools.pause_nonactive, true, pause_nonactive, false); SETTING_BOOL("video_gpu_screenshot", &settings->bools.video_gpu_screenshot, true, gpu_screenshot, false); @@ -1485,6 +1486,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, #endif SETTING_UINT("audio_out_rate", &settings->uints.audio_out_rate, true, out_rate, false); SETTING_UINT("custom_viewport_width", &settings->video_viewport_custom.width, false, 0 /* TODO */, false); + SETTING_UINT("CRT_Switch_Resolution_super", &settings->uints.CRT_Switch_Resolution_super, true, CRT_Switch_Resolution_super, false);//ben SETTING_UINT("custom_viewport_height", &settings->video_viewport_custom.height, false, 0 /* TODO */, false); SETTING_UINT("custom_viewport_x", (unsigned*)&settings->video_viewport_custom.x, false, 0 /* TODO */, false); SETTING_UINT("custom_viewport_y", (unsigned*)&settings->video_viewport_custom.y, false, 0 /* TODO */, false); diff --git a/configuration.h b/configuration.h index 2f3e01eeb1..a0009eae00 100644 --- a/configuration.h +++ b/configuration.h @@ -95,6 +95,7 @@ typedef struct settings bool video_statistics_show; bool video_framecount_show; bool video_msg_bgcolor_enable; + bool CRT_Switch_Resolution; //ben /* Audio */ bool audio_enable; @@ -333,6 +334,7 @@ typedef struct settings unsigned video_window_x; unsigned video_window_y; unsigned video_window_opacity; + unsigned CRT_Switch_Resolution_super; //ben unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; From 635b3b7670b7faee31632e74e6d1f16aeab0718b Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:03:46 +0100 Subject: [PATCH 03/46] CRT SwitchRes --- config.def.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.def.h b/config.def.h index e7c29ab786..da290b1c1b 100644 --- a/config.def.h +++ b/config.def.h @@ -67,6 +67,10 @@ static bool bundle_assets_extract_enable = false; static bool materialui_icons_enable = true; #endif +static const bool CRT_Switch_Resolution = false; //ben +static const int CRT_Switch_Resolution_super = 2560; + + static const bool def_history_list_enable = true; static const bool def_playlist_entry_remove = true; static const bool def_playlist_entry_rename = true; From d207986a74cb0e7294a9d87236d5ec5662c56dff Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:05:12 +0100 Subject: [PATCH 04/46] CRT SwitchRes --- menu/menu_displaylist.c | 6 ++++++ menu/menu_setting.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index bdc3c8df3f..9c1c955b79 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5774,6 +5774,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SCREEN_RESOLUTION, PARSE_ACTION, false); + menu_displaylist_parse_settings_enum(menu, info, //ben + MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, //ben + MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, + PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_PAL60_ENABLE, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6f17dcfeae..4e273cd69e 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3327,6 +3327,34 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + + + CONFIG_BOOL( //ben + list, list_info, + &settings->bools.CRT_Switch_Resolution, + MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, + MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION, + CRT_Switch_Resolution, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + + CONFIG_UINT( + list, list_info, // CRT Menu + &settings->uints.CRT_Switch_Resolution_super, + MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, + MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_SUPER, + CRT_Switch_Resolution_super, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); CONFIG_BOOL( list, list_info, From 99645e2cd76e9886aa8541f4cb84e3b5abaf017c Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:06:39 +0100 Subject: [PATCH 05/46] CRT SwitchRes --- intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.c | 7 +++++++ intl/msg_hash_us.h | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index e914210d27..ba3b624cdb 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1085,6 +1085,10 @@ MSG_HASH(MENU_ENUM_LABEL_USE_THIS_DIRECTORY, "use_this_directory") MSG_HASH(MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE, "video_allow_rotate") +MSG_HASH(MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, + "CRT Switch Resolution") // ben +MSG_HASH(MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, + "CRT_Switch_Resolution_super") // ben MSG_HASH(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO, "video_aspect_ratio") MSG_HASH(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_AUTO, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 264b0a7860..fa86eafc3c 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -888,6 +888,13 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); } break; + + case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION: snprintf(s, len, "SET CRT"); //ben + break; + + case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER: snprintf(s, len, "SET CRT SUPER"); //ben + break; + case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: snprintf(s, len, "Load Shader Preset. \n" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index caca939fe1..d6c535fb1f 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3431,6 +3431,13 @@ MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY, "Lower this value to favor performance/lower latency over audio quality, increase if you want better audio quality at the expense of performance/lower latency.") MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_WATCH_FOR_CHANGES, "Watch shader files for changes") +MSG_HASH(MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION, "CRT SwitchRes") //ben + +MSG_HASH(MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION, "CRT SwitchRes") //ben + +MSG_HASH(MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_SUPER, "CRT Super Resolution") //ben + +MSG_HASH(MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_SUPER, "CRT Super Resolution") //ben MSG_HASH(MENU_ENUM_SUBLABEL_SHADER_WATCH_FOR_CHANGES, "Auto-apply changes made to shader files on disk.") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SHOW_DECORATIONS, From 56bc1757ed9e590fc1f62f784f3b71cbf01f419f Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:07:46 +0100 Subject: [PATCH 06/46] CRT SwitchRes --- msg_hash.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/msg_hash.h b/msg_hash.h index 181814deb1..18e5f6ab9f 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -665,6 +665,8 @@ enum msg_hash_enums MENU_LABEL(INPUT_UNIFIED_MENU_CONTROLS), /* Video */ + MENU_LABEL(CRT_SWITCH_RESOLUTION), //ben + MENU_LABEL(CRT_SWITCH_RESOLUTION_SUPER), MENU_LABEL(VIDEO_FONT_ENABLE), MENU_LABEL(VIDEO_FONT_PATH), MENU_LABEL(VIDEO_FONT_SIZE), From b33cb14ba0ef2a64e3a9aa6a9b4489e27552aa0f Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:35:30 +0100 Subject: [PATCH 07/46] CRT SwitchRes --- gfx/video_driver.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 878aea7bae..bdb2b682e8 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -71,6 +71,11 @@ RETRO_BEGIN_DECLS #define MAX_VARIABLES 64 +// Added for resolution wswitching +void ben_poke_video(); +//Added for resolution wswitching + + enum { TEXTURES = 8, @@ -402,6 +407,7 @@ typedef struct video_frame_info bool black_frame_insertion; bool hard_sync; bool fps_show; + bool CRT_Switch_Resolution; //ben bool statistics_show; bool framecount_show; bool scale_integer; @@ -427,6 +433,7 @@ typedef struct video_frame_info unsigned aspect_ratio_idx; unsigned max_swapchain_images; unsigned monitor_index; + unsigned CRT_Switch_Resolution_super; //ben unsigned width; unsigned height; unsigned xmb_theme; From 2967283b29afa3de50e3ee9e275b6a0592036522 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:36:53 +0100 Subject: [PATCH 08/46] CRT From 71578a43f6eb85732243270c1709d1c68b22bb2b Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:40:17 +0100 Subject: [PATCH 09/46] CRT --- gfx/video_crt_switch.c | 218 +++++++++++++++++++++++++++++++++++++++++ gfx/video_crt_switch.h | 19 ++++ 2 files changed, 237 insertions(+) create mode 100644 gfx/video_crt_switch.c create mode 100644 gfx/video_crt_switch.h diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c new file mode 100644 index 0000000000..17a317cd85 --- /dev/null +++ b/gfx/video_crt_switch.c @@ -0,0 +1,218 @@ +#include +#include +#include +#include + +#include + +#include "video_crt_switch.h" + +int first_run; +float fly_aspect; + +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_width = width; + ben_core_height = height; + ben_core_hz = hz; + check_first_run(); + + if (ben_tmp_height != ben_core_height || ben_core_width != ben_tmp_width){ // detect resolution change and switch + screen_setup_aspect(width,height); + } + + if (video_driver_get_aspect_ratio() != fly_aspect){ //check aspect is correct else change + video_driver_set_aspect_ratio_value((float)fly_aspect); + ben_poke_video(); + } + + +} + +void check_first_run(){ // ruin of first boot to get current display resolution + if (first_run != 1){ + orig_height = GetSystemMetrics(SM_CYSCREEN); + orig_width = GetSystemMetrics(SM_CXSCREEN); + } + first_run = 1; +} + +void screen_setup_aspect(int width, int height){ // create correct aspect to fit video if resolution does not exist + switch_crt_hz(); + /* get original resolution of core */ + if (width >= 1900){ + if (height == 4){ //detect menu only + height = 480; + aspect_ratio_switch(width,height); + } + if (height < 191 && height != 144){ // for low res games to be dran at res but on a 200 eight + aspect_ratio_switch(width,height); + height = 200; + } + if (height > 191){ + aspect_ratio_switch(width,height); + } + if (height == 144 && set_ben_core_hz == 50){ /// for GBA doubling + height = 288; + aspect_ratio_switch(width,height); + } + if (height > 200 && height < 224){ /// for mame + aspect_ratio_switch(width,height); + ben_core_height = 224; + } + if (height > 224 && height < 240){ /// for mame + aspect_ratio_switch(width,height); + ben_core_height = 240; + } + + if (height > 240 && height < 255 ){ /// for mame + aspect_ratio_switch(width,height); + ben_core_height = 254; + } + if (height == 528 && set_ben_core_hz == 60){ /// for mame + aspect_ratio_switch(width,height); + ben_core_height = 480; + } + + if (height >= 240 && height < 255 && set_ben_core_hz == 55){ + aspect_ratio_switch(width,height); + ben_core_height = 254; + } + + } + switch_res_crt(width, height); +} + +void switch_res_crt(int width, int height){ + + if ( height > 100){ + + switch_res(width, height,0); + ben_poke_video(); + ben_tmp_height = ben_core_height; + ben_tmp_width = ben_core_width; + + } + +} + +void aspect_ratio_switch(int width,int height){ // send aspect float to videeo_driver + 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 + + if (ben_core_hz != ben_tmp_core_hz){ + if (ben_core_hz < 53 ){ + set_ben_core_hz = 50; + + } + if (ben_core_hz >= 53 && ben_core_hz < 57){ + set_ben_core_hz = 55; + } + if (ben_core_hz >= 57 ){ + set_ben_core_hz = 60; + } + video_monitor_set_refresh_rate(ben_core_hz); + ben_tmp_core_hz = ben_core_hz; + } + +} + +void switch_res(int width, int height, int f_restore){ // windows function to swith resolutions + + DEVMODE curDevmode; + DEVMODE devmode; + DWORD flags = 0; + int iModeNum; + int depth = 0; + int freq; + if (f_restore == 0){ + freq = set_ben_core_hz; + } else { + freq = 0; + } + + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); + + if (width == curDevmode.dmPelsWidth){ + width = 0; // used to stop superresolution bug + } + + if (width == 0) { + width = curDevmode.dmPelsWidth; + } + if (height == 0) { + height = curDevmode.dmPelsHeight; + } + if (depth == 0) { + depth = curDevmode.dmBitsPerPel; + } + if (freq == 0) { + freq = curDevmode.dmDisplayFrequency; + } + + for (iModeNum = 0; ; iModeNum++) { + if (EnumDisplaySettings(NULL, iModeNum, &devmode)) { + // See if this setting has the right width. + if (devmode.dmPelsWidth != width) { + continue; + } + + if (devmode.dmPelsHeight != height) { + continue; + } + + // See if this setting has the right depth. + if (devmode.dmBitsPerPel != depth) { + continue; + } + + // See if this setting has the right frequency. + if (devmode.dmDisplayFrequency != freq) { + continue; + } + + // This new setting satisfies all the criteria. Try it. + devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + LONG res = ChangeDisplaySettings(&devmode, CDS_TEST); + + switch (res) { + case DISP_CHANGE_SUCCESSFUL: + res = ChangeDisplaySettings(&devmode, flags); + switch (res) { + case DISP_CHANGE_SUCCESSFUL: + return; + + case DISP_CHANGE_NOTUPDATED: + // printf("Settings changed, but not permanently.\n"); + return; + + default: + // printf("Something odd happened.\n"); + break; + } + break; + + case DISP_CHANGE_RESTART: + //printf("The computer needs to be restarted to switch to these settings\n"); + break; + + default: + //printf("Something odd happened.\n"); + break; + } + } + else { + break; + } + } + +// printf("Couldn't change settings.\n"); + +} + +void video_restore(){ + switch_res(orig_width, orig_height,1); +} diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h new file mode 100644 index 0000000000..62b959e4ed --- /dev/null +++ b/gfx/video_crt_switch.h @@ -0,0 +1,19 @@ +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; + + +void switch_res_core(int width, int height, float hz); +void check_first_run(); +void screen_setup_aspect(int width, int height); +void switch_res_crt(int width, int height); +void aspect_ratio_switch(int width,int height); +void switch_crt_hz(); +void switch_res(int width, int height, int f_restore); +void video_restore(); \ No newline at end of file From 670216d0219bf31609a8ca69e11da9c68c4c0112 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:48:53 +0100 Subject: [PATCH 10/46] Update README.md --- README.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/README.md b/README.md index ccf7c912ec..93daeb662d 100644 --- a/README.md +++ b/README.md @@ -144,3 +144,115 @@ To configure joypads, use the built-in menu or the `retroarch-joyconfig` command ## Compiling and installing Instructions for compiling and installing RetroArch can be found in the [Libretro/RetroArch Documentation Center](https://docs.libretro.com/). + +## CRT SwitchRes + +CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. + +Before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimun modelins for all games to switch correctly are: + +- 2560 x 192 @ 60.000000 +- 2560 x 200 @ 60.000000 +- 2560 x 240 @ 60.000000 + -2560 x 224 @ 60.000000 +- 2560 x 237 @ 60.000000 +- 2560 x 256 @ 50.000000 +- 2560 x 254 @ 55.000000 +- 2560 x 448 @ 60.000000 +- 2560 x 480 @ 60.000000 + +Install these modelines replacing 2560 with your desired super resuloution. The above resolutions are NTSC only so if you would be playing any PAL content please add pal modelines: + +- 2560 x 192 @ 50.000000 +- 2560 x 200 @ 50.000000 +- 2560 x 240 @ 50.000000 +- 2560 x 224 @ 50.000000 +- 2560 x 288 @ 50.000000 +- 2560 x 237 @ 50.000000 +- 2560 x 254 @ 55.000000 +- 2560 x 448 @ 50.000000 +- 2560 x 480 @ 50.000000 + +Some games will require heigher PAL resolutions which should also be installed: + +- 2560 x 512 @ 50.000000 +- 2560 x 576 @ 50.000000 + +Idealy install all these modelines and everything will work great. + +## Super Resolutions + +The default super resolution is 2560. It is displayed just under the CRT switch option, which can be found in video settings. This can be changed within the retroarch.cfg. The only compatible resolutions are 1920, 2560 and 3840. Any other resolutions will be ignored and native swithing will be activated. + +## Native Resolutions + +On the if any other number is used for super resolutions the native it activeted. if native is what you want then you will need a whol;e new set of modelines: + +- 512 x 240 @ 50.006977 SNESpal +- 512 x 224 @ 50.006977 SNESpal +- 512 x 448 @ 50.006977 SNESpal +- 512 x 240 @ 60.098812 SNESntsc +- 512 x 224 @ 60.098812 SNESntsc +- 512 x 448 @ 60.098812 SNESntsc +- 256 x 240 @ 50.006977 SNESpal +- 256 x 448 @ 50.006977 SNESpal +- 256 x 240 @ 60.098812 SNESntsc +- 256 x 448 @ 60.098812 SNESntsc +- 320 x 240 @ 59.922745 MDntsc +- 320 x 448 @ 59.922745 MDntp +- 320 x 480 @ 59.922745 MDntsc +- 256 x 192 @ 59.922745 MDntsc +- 320 x 224 @ 59.922745 MDntsc +- 256 x 224 @ 59.922745 MDntsc +- 320 x 288 @ 49.701458 MDpal +- 320 x 576 @ 49.701458 MDpal +- 256 x 192 @ 49.701458 MDpal +- 320 x 224 @ 49.701458 MDpal +- 320 x 240 @ 49.701458 MDpal +- 320 x 448 @ 49.701458 MDpal +- 320 x 480 @ 49.701458 MDpal +- 256 x 224 @ 49.701458 MDpal +- 256 x 288 @ 49.701458 MSYSpal +- 256 x 240 @ 60.098812 NESntsc +- 256 x 240 @ 50.006977 NESpal + +- 640 x 480 @ 60.130001 N64ntsc +- 640 x 237 @ 60.130001 N64ntsc +- 640 x 240 @ 60.130001 N64ntsc +- 640 x 480 @ 50.000000 N64pal +- 640 x 576 @ 50.000000 n64pal +- 640 x 288 @ 50.000000 n64pal + +- 256 x 252 @ 49.759998 PSXpal +- 384 x 252 @ 49.759998 PSXpal +- 640 x 540 @ 49.759998 PSXpal +- 320 x 252 @ 49.759998 PSXpal +- 640 x 252 @ 49.759998 PSXpal + +- 384 x 240 @ 59.941002 PSXntsc +- 256 x 480 @ 59.941002 PSXntsc + +- 352 x 240 @ 59.820000 Saturn/SGFX_NTSCp +- 704 x 240 @ 59.820000 SaturnNTSCp +- 352 x 480 @ 59.820000 SaturnNTSCi +- 704 x 480 @ 59.820000 SaturnNTSCi +- 352 x 288 @ 49.701458 SaturnPALp +- 704 x 288 @ 49.701458 SaturnPALp +- 352 x 576 @ 49.701458 SaturnPALi +- 704 x 576 @ 49.701458 SaturnPALi + +- 240 x 160 @ 59.730000 GBA +- 320 x 200 @ 60.000000 Doom + +// Arcade + +- 400 x 254 @ 54.706841 MK +- 384 x 224 @ 59.637405 CPS1 + +These modelines are more acurate giving exact hz. However, some games may have unwanted results. This is due to mid-scanline resolution chages on the orgiginal hardware. For the best results super resolutions are the way to go. + +## CRT SwitchRes & Mame + +Some arecade resolutions can be alot different. There is rosolution detection to ensure mame games will be diplayed in the closest available resolution but drawn at their native resolution within this resolution. Meaning that the mame game will look just like the original hardware. + +Mame roms that run in a vertical aspect like DoDonPachi need to be roted within mame before rolution swithing and aspect correction will work. Do this before enableing CRT switchRes so that Retroarch will run in your desktop resolution. Once you have roted any games that may need it switch CRT SwitchRes on. From af7f1da9fb0833f659581dbc35a016053ef8d322 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 15:54:23 +0100 Subject: [PATCH 11/46] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 93daeb662d..8cd6fc82f2 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Before enabling the CRT SwitchRes options pleasae make sure you have installed C - 2560 x 192 @ 60.000000 - 2560 x 200 @ 60.000000 - 2560 x 240 @ 60.000000 - -2560 x 224 @ 60.000000 +- 2560 x 224 @ 60.000000 - 2560 x 237 @ 60.000000 - 2560 x 256 @ 50.000000 - 2560 x 254 @ 55.000000 @@ -186,7 +186,7 @@ The default super resolution is 2560. It is displayed just under the CRT switch ## Native Resolutions -On the if any other number is used for super resolutions the native it activeted. if native is what you want then you will need a whol;e new set of modelines: +On the if any other number is used for super resolutions the native it activeted. if native is what you want then you will need a whole new set of modelines: - 512 x 240 @ 50.006977 SNESpal - 512 x 224 @ 50.006977 SNESpal From b30aca2d6d4c615fb75b8349c157550b437749f6 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 16:08:29 +0100 Subject: [PATCH 12/46] CRT --- gfx/video_driver.c | 58 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index e7f8ed667b..11ba7e9924 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -118,6 +120,8 @@ #define video_driver_context_unlock() ((void)0) #endif +bool CRT_Switching_active; //ben + typedef struct video_pixel_scaler { struct scaler_ctx *scaler; @@ -1414,13 +1418,16 @@ void video_driver_monitor_adjust_system_rates(void) const struct retro_system_timing *info = (const struct retro_system_timing*)&video_driver_av_info.timing; rarch_ctl(RARCH_CTL_UNSET_NONBLOCK_FORCED, NULL); - + ben_core_hz = info->fps; if (!info || info->fps <= 0.0) return; - timing_skew = fabs(1.0f - info->fps / video_refresh_rate); - + if (CRT_Switching_active == true){ + timing_skew = fabs(1.0f - info->fps / ben_core_hz); + }else { + timing_skew = fabs(1.0f - info->fps / video_refresh_rate); + } /* We don't want to adjust pitch too much. If we have extreme cases, * just don't readjust at all. */ if (timing_skew <= settings->floats.audio_max_timing_skew) @@ -1429,10 +1436,17 @@ void video_driver_monitor_adjust_system_rates(void) RARCH_LOG("[Video]: Timings deviate too much. Will not adjust. (Display = %.2f Hz, Game = %.2f Hz)\n", video_refresh_rate, (float)info->fps); - - if (info->fps <= video_refresh_rate) - return; - + + + // if (info->fps <= video_refresh_rate) // create options to choose between these!!!! + // return; + if (CRT_Switching_active == true){ + if (info->fps <= ben_core_hz) + return; + } else { + if (info->fps <= video_refresh_rate) + return; + } /* We won't be able to do VSync reliably when game FPS > monitor FPS. */ rarch_ctl(RARCH_CTL_SET_NONBLOCK_FORCED, NULL); RARCH_LOG("[Video]: Game FPS > Monitor FPS. Cannot rely on VSync.\n"); @@ -1560,6 +1574,7 @@ static void video_driver_lock_new(void) void video_driver_destroy(void) { video_display_server_destroy(); + video_restore(); //ben video_driver_cb_has_focus = null_driver_has_focus; video_driver_use_rgba = false; video_driver_data_own = false; @@ -2582,6 +2597,30 @@ void video_driver_frame(const void *data, unsigned width, /* Display the FPS, with a higher priority. */ if (video_info.fps_show) runloop_msg_queue_push(video_info.fps_text, 2, 1, true); + + /* trigger set resolution*/ + if (video_info.CRT_Switch_Resolution == true){ + CRT_Switching_active = true; + if (video_info.CRT_Switch_Resolution_super == 2560){ + width = 2560; + } + if (video_info.CRT_Switch_Resolution_super == 3840){ + width = 3840; + } + if (video_info.CRT_Switch_Resolution_super == 1920){ + width = 1920; + } + switch_res_core(width, height, ben_core_hz);// ben_core_hz); + } else if (video_info.CRT_Switch_Resolution == false){ + CRT_Switching_active = false; + } + + /* trigger set resolution*/ + +} + +void ben_poke_video(){ + video_driver_poke->apply_state_changes(video_driver_data); } void video_driver_display_type_set(enum rarch_display_type type) @@ -2674,8 +2713,9 @@ void video_driver_build_info(video_frame_info_t *video_info) settings = config_get_ptr(); custom_vp = &settings->video_viewport_custom; video_info->refresh_rate = settings->floats.video_refresh_rate; - video_info->black_frame_insertion = - settings->bools.video_black_frame_insertion; + video_info->CRT_Switch_Resolution = settings->bools.CRT_Switch_Resolution; //ben + video_info->CRT_Switch_Resolution_super = settings->uints.CRT_Switch_Resolution_super; //ben + video_info->black_frame_insertion = settings->bools.video_black_frame_insertion; video_info->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; video_info->fps_show = settings->bools.video_fps_show; From 43205baa9a80620eefdad8c88fd86b599f7d2e92 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 16:20:22 +0100 Subject: [PATCH 13/46] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cd6fc82f2..ce75fdf8d9 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Instructions for compiling and installing RetroArch can be found in the [Libretr ## CRT SwitchRes -CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. +CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. With CRT SwitchRes enable Retroarch will start in 2560 @ 480. Before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimun modelins for all games to switch correctly are: From 540b15d6efae5326cae5d2298e275d3e42d904fa Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:17:23 +0100 Subject: [PATCH 14/46] Add files via upload Changed variable names --- config.def.h | 4 ++-- configuration.c | 4 ++-- configuration.h | 4 ++-- msg_hash.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h index da290b1c1b..2aa743544a 100644 --- a/config.def.h +++ b/config.def.h @@ -67,8 +67,8 @@ static bool bundle_assets_extract_enable = false; static bool materialui_icons_enable = true; #endif -static const bool CRT_Switch_Resolution = false; //ben -static const int CRT_Switch_Resolution_super = 2560; +static const bool crt_switch_resolution = false; +static const int crt_switch_resolution_super = 2560; static const bool def_history_list_enable = true; diff --git a/configuration.c b/configuration.c index a95e8708a8..5f4c717609 100644 --- a/configuration.c +++ b/configuration.c @@ -1242,7 +1242,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, vsync, false); SETTING_BOOL("video_hard_sync", &settings->bools.video_hard_sync, true, hard_sync, false); SETTING_BOOL("video_black_frame_insertion", &settings->bools.video_black_frame_insertion, true, black_frame_insertion, false); - SETTING_BOOL("CRT_Switch_Resolution", &settings->bools.CRT_Switch_Resolution, true, CRT_Switch_Resolution, false); //ben + SETTING_BOOL("crt_switch_resolution", &settings->bools.crt_switch_resolution, true, crt_switch_resolution, false); //ben SETTING_BOOL("video_disable_composition", &settings->bools.video_disable_composition, true, disable_composition, false); SETTING_BOOL("pause_nonactive", &settings->bools.pause_nonactive, true, pause_nonactive, false); SETTING_BOOL("video_gpu_screenshot", &settings->bools.video_gpu_screenshot, true, gpu_screenshot, false); @@ -1486,7 +1486,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, #endif SETTING_UINT("audio_out_rate", &settings->uints.audio_out_rate, true, out_rate, false); SETTING_UINT("custom_viewport_width", &settings->video_viewport_custom.width, false, 0 /* TODO */, false); - SETTING_UINT("CRT_Switch_Resolution_super", &settings->uints.CRT_Switch_Resolution_super, true, CRT_Switch_Resolution_super, false);//ben + SETTING_UINT("crt_switch_resolution_super", &settings->uints.crt_switch_resolution_super, true, crt_switch_resolution_super, false); SETTING_UINT("custom_viewport_height", &settings->video_viewport_custom.height, false, 0 /* TODO */, false); SETTING_UINT("custom_viewport_x", (unsigned*)&settings->video_viewport_custom.x, false, 0 /* TODO */, false); SETTING_UINT("custom_viewport_y", (unsigned*)&settings->video_viewport_custom.y, false, 0 /* TODO */, false); diff --git a/configuration.h b/configuration.h index a0009eae00..559aa75ab2 100644 --- a/configuration.h +++ b/configuration.h @@ -95,7 +95,7 @@ typedef struct settings bool video_statistics_show; bool video_framecount_show; bool video_msg_bgcolor_enable; - bool CRT_Switch_Resolution; //ben + bool crt_switch_resolution; //ben /* Audio */ bool audio_enable; @@ -334,7 +334,7 @@ typedef struct settings unsigned video_window_x; unsigned video_window_y; unsigned video_window_opacity; - unsigned CRT_Switch_Resolution_super; //ben + unsigned crt_switch_resolution_super; //ben unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; diff --git a/msg_hash.h b/msg_hash.h index 18e5f6ab9f..1a1c5e07df 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -665,7 +665,7 @@ enum msg_hash_enums MENU_LABEL(INPUT_UNIFIED_MENU_CONTROLS), /* Video */ - MENU_LABEL(CRT_SWITCH_RESOLUTION), //ben + MENU_LABEL(CRT_SWITCH_RESOLUTION), MENU_LABEL(CRT_SWITCH_RESOLUTION_SUPER), MENU_LABEL(VIDEO_FONT_ENABLE), MENU_LABEL(VIDEO_FONT_PATH), From 51276a682f7753a36cba34bebb9b5840811ddb8e Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:18:43 +0100 Subject: [PATCH 15/46] Add files via upload Changed variable names --- gfx/video_crt_switch.c | 68 ++++++++++++++++++++++++++---------------- gfx/video_crt_switch.h | 19 ++++++++++++ gfx/video_driver.c | 31 +++++++++---------- gfx/video_driver.h | 9 +++--- 4 files changed, 81 insertions(+), 46 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 17a317cd85..dd33a79c8e 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -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 . +*/ #include #include #include @@ -11,17 +29,17 @@ int first_run; float fly_aspect; 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_height = height; ben_core_hz = hz; 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); } - 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); 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){ orig_height = GetSystemMetrics(SM_CYSCREEN); 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; } -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(); /* get original resolution of core */ if (width >= 1900){ - if (height == 4){ //detect menu only + if (height == 4){ /* detect menu only */ height = 480; 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); height = 200; } if (height > 191){ 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; aspect_ratio_switch(width,height); } - if (height > 200 && height < 224){ /// for mame + if (height > 200 && height < 224){ aspect_ratio_switch(width,height); ben_core_height = 224; } - if (height > 224 && height < 240){ /// for mame + if (height > 224 && height < 240){ aspect_ratio_switch(width,height); ben_core_height = 240; } - if (height > 240 && height < 255 ){ /// for mame + if (height > 240 && height < 255 ){ aspect_ratio_switch(width,height); 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); 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; 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 < 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 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); if (width == curDevmode.dmPelsWidth){ - width = 0; // used to stop superresolution bug + width = 0; /* used to stop superresolution bug */ } 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++) { if (EnumDisplaySettings(NULL, iModeNum, &devmode)) { - // See if this setting has the right width. + if (devmode.dmPelsWidth != width) { continue; } @@ -164,17 +182,17 @@ void switch_res(int width, int height, int f_restore){ // windows function to s continue; } - // See if this setting has the right depth. + if (devmode.dmBitsPerPel != depth) { continue; } - // See if this setting has the right frequency. + if (devmode.dmDisplayFrequency != freq) { continue; } - // This new setting satisfies all the criteria. Try it. + devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; 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; case DISP_CHANGE_NOTUPDATED: - // printf("Settings changed, but not permanently.\n"); + return; default: - // printf("Something odd happened.\n"); + break; } break; case DISP_CHANGE_RESTART: - //printf("The computer needs to be restarted to switch to these settings\n"); + break; default: - //printf("Something odd happened.\n"); + 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"); + } diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 62b959e4ed..2e39f95ba3 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -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 . +*/ + static int ben_core_width; static int ben_core_height; static int ben_tmp_width; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 11ba7e9924..6ea3de89f8 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -120,7 +120,7 @@ #define video_driver_context_unlock() ((void)0) #endif -bool CRT_Switching_active; //ben +bool crt_switching_active; typedef struct video_pixel_scaler { @@ -1423,7 +1423,7 @@ void video_driver_monitor_adjust_system_rates(void) if (!info || info->fps <= 0.0) return; - if (CRT_Switching_active == true){ + if (crt_switching_active == true){ timing_skew = fabs(1.0f - info->fps / ben_core_hz); }else { 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, (float)info->fps); - - // if (info->fps <= video_refresh_rate) // create options to choose between these!!!! - // return; - if (CRT_Switching_active == true){ + if (crt_switching_active == true){ if (info->fps <= ben_core_hz) return; } else { @@ -1574,7 +1571,7 @@ static void video_driver_lock_new(void) void video_driver_destroy(void) { video_display_server_destroy(); - video_restore(); //ben + video_restore(); video_driver_cb_has_focus = null_driver_has_focus; video_driver_use_rgba = 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); /* trigger set resolution*/ - if (video_info.CRT_Switch_Resolution == true){ - CRT_Switching_active = true; - if (video_info.CRT_Switch_Resolution_super == 2560){ + if (video_info.crt_switch_resolution == true){ + crt_switching_active = true; + if (video_info.crt_switch_resolution_super == 2560){ width = 2560; } - if (video_info.CRT_Switch_Resolution_super == 3840){ + if (video_info.crt_switch_resolution_super == 3840){ width = 3840; } - if (video_info.CRT_Switch_Resolution_super == 1920){ + if (video_info.crt_switch_resolution_super == 1920){ width = 1920; } - switch_res_core(width, height, ben_core_hz);// ben_core_hz); - } else if (video_info.CRT_Switch_Resolution == false){ - CRT_Switching_active = false; + switch_res_core(width, height, ben_core_hz); + } else if (video_info.crt_switch_resolution == false){ + crt_switching_active = false; } /* trigger set resolution*/ @@ -2713,8 +2710,8 @@ void video_driver_build_info(video_frame_info_t *video_info) settings = config_get_ptr(); custom_vp = &settings->video_viewport_custom; 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_super = settings->uints.CRT_Switch_Resolution_super; //ben + video_info->crt_switch_resolution = settings->bools.crt_switch_resolution; + 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->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index bdb2b682e8..46c19a52dc 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -71,9 +71,10 @@ RETRO_BEGIN_DECLS #define MAX_VARIABLES 64 -// Added for resolution wswitching +/* Added for resolution wswitching */ void ben_poke_video(); -//Added for resolution wswitching + +/* Added for resolution wswitching */ enum @@ -407,7 +408,7 @@ typedef struct video_frame_info bool black_frame_insertion; bool hard_sync; bool fps_show; - bool CRT_Switch_Resolution; //ben + bool crt_switch_resolution; bool statistics_show; bool framecount_show; bool scale_integer; @@ -433,7 +434,7 @@ typedef struct video_frame_info unsigned aspect_ratio_idx; unsigned max_swapchain_images; unsigned monitor_index; - unsigned CRT_Switch_Resolution_super; //ben + unsigned crt_switch_resolution_super; unsigned width; unsigned height; unsigned xmb_theme; From dd8beb48b6c2090f846ccc7662671d2bd9b59e39 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:19:35 +0100 Subject: [PATCH 16/46] Add files via upload Changed variable names --- intl/msg_hash_lbl.h | 4 ++-- intl/msg_hash_us.c | 4 ++-- intl/msg_hash_us.h | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index ba3b624cdb..ada305e886 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1086,9 +1086,9 @@ MSG_HASH(MENU_ENUM_LABEL_USE_THIS_DIRECTORY, MSG_HASH(MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE, "video_allow_rotate") MSG_HASH(MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, - "CRT Switch Resolution") // ben + "crt_switch_resolution") MSG_HASH(MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, - "CRT_Switch_Resolution_super") // ben + "crt_switch_resolution_super") MSG_HASH(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO, "video_aspect_ratio") MSG_HASH(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_AUTO, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index fa86eafc3c..21aa5e06ee 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -889,10 +889,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) } break; - case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION: snprintf(s, len, "SET CRT"); //ben + case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION: snprintf(s, len, "SET CRT"); break; - case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER: snprintf(s, len, "SET CRT SUPER"); //ben + case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER: snprintf(s, len, "SET CRT SUPER"); break; case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index d6c535fb1f..bf396393b1 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3431,13 +3431,13 @@ MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY, "Lower this value to favor performance/lower latency over audio quality, increase if you want better audio quality at the expense of performance/lower latency.") MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_WATCH_FOR_CHANGES, "Watch shader files for changes") -MSG_HASH(MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION, "CRT SwitchRes") //ben +MSG_HASH(MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION, "CRT SwitchRes") -MSG_HASH(MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION, "CRT SwitchRes") //ben +MSG_HASH(MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION, "CRT SwitchRes") -MSG_HASH(MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_SUPER, "CRT Super Resolution") //ben +MSG_HASH(MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_SUPER, "CRT Super Resolution") -MSG_HASH(MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_SUPER, "CRT Super Resolution") //ben +MSG_HASH(MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_SUPER, "CRT Super Resolution") MSG_HASH(MENU_ENUM_SUBLABEL_SHADER_WATCH_FOR_CHANGES, "Auto-apply changes made to shader files on disk.") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SHOW_DECORATIONS, From f6ab07f3fc69abce7e3ac69e17fabb450930c958 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:21:37 +0100 Subject: [PATCH 17/46] Add files via upload Changed variable names and comments --- menu/menu_displaylist.c | 4 ++-- menu/menu_setting.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 9c1c955b79..27547051dc 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5774,10 +5774,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SCREEN_RESOLUTION, PARSE_ACTION, false); - menu_displaylist_parse_settings_enum(menu, info, //ben + menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, //ben + menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4e273cd69e..ee0a20a8df 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3329,12 +3329,12 @@ static bool setting_append_list( SD_FLAG_NONE); - CONFIG_BOOL( //ben + CONFIG_BOOL( list, list_info, - &settings->bools.CRT_Switch_Resolution, + &settings->bools.crt_switch_resolution, MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION, - CRT_Switch_Resolution, + crt_switch_resolution, MENU_ENUM_LABEL_VALUE_OFF, MENU_ENUM_LABEL_VALUE_ON, &group_info, @@ -3345,16 +3345,16 @@ static bool setting_append_list( SD_FLAG_NONE); CONFIG_UINT( - list, list_info, // CRT Menu - &settings->uints.CRT_Switch_Resolution_super, - MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, - MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_SUPER, - CRT_Switch_Resolution_super, - &group_info, - &subgroup_info, - parent_group, - general_write_handler, - general_read_handler); + list, list_info, + &settings->uints.crt_switch_resolution_super, + MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, + MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_SUPER, + crt_switch_resolution_super, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); CONFIG_BOOL( list, list_info, From d919e93013c387e271200fb78bf4b034781f1e1f Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:39:51 +0100 Subject: [PATCH 18/46] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce75fdf8d9..fd7bbe9b83 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ Some games will require heigher PAL resolutions which should also be installed: - 2560 x 512 @ 50.000000 - 2560 x 576 @ 50.000000 -Idealy install all these modelines and everything will work great. +Ideally install all these modelines and everything will work great. ## Super Resolutions @@ -186,7 +186,7 @@ The default super resolution is 2560. It is displayed just under the CRT switch ## Native Resolutions -On the if any other number is used for super resolutions the native it activeted. if native is what you want then you will need a whole new set of modelines: +If native reolutions are activeted you will need a whole new set of modelines: - 512 x 240 @ 50.006977 SNESpal - 512 x 224 @ 50.006977 SNESpal From dcc416ca4683e9f5094707ee37871bd35228f50e Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 17:41:09 +0100 Subject: [PATCH 19/46] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd7bbe9b83..1e43a68a15 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ To configure joypads, use the built-in menu or the `retroarch-joyconfig` command Instructions for compiling and installing RetroArch can be found in the [Libretro/RetroArch Documentation Center](https://docs.libretro.com/). -## CRT SwitchRes +## CRT 15Khz Resolution Switching CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. With CRT SwitchRes enable Retroarch will start in 2560 @ 480. From a44f4d1489dbe75bddb91bff472363278d456340 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 18:15:18 +0100 Subject: [PATCH 20/46] Add files via upload Change requests --- configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.h b/configuration.h index 559aa75ab2..a937a5bd87 100644 --- a/configuration.h +++ b/configuration.h @@ -95,7 +95,7 @@ typedef struct settings bool video_statistics_show; bool video_framecount_show; bool video_msg_bgcolor_enable; - bool crt_switch_resolution; //ben + bool crt_switch_resolution; /* Audio */ bool audio_enable; From 3b9036cc7927bf580dd17a58440659e04f9dcfd9 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 20:22:35 +0100 Subject: [PATCH 21/46] Add files via upload Requested changes --- gfx/video_crt_switch.c | 193 +++++++++++++++++++++++++---------------- gfx/video_crt_switch.h | 10 +-- gfx/video_driver.c | 10 +-- gfx/video_driver.h | 2 +- 4 files changed, 127 insertions(+), 88 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index dd33a79c8e..11a731d413 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -25,76 +25,99 @@ #include "video_crt_switch.h" -int first_run; -float fly_aspect; +static int ra_set_core_hz; +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_width = width; - ben_core_height = height; - ben_core_hz = hz; - check_first_run(); + ra_core_width = width; + ra_core_height = height; + ra_core_hz = hz; + check_first_run(); - if (ben_tmp_height != ben_core_height || ben_core_width != ben_tmp_width){ /* detect resolution change and switch */ - screen_setup_aspect(width,height); - } + if (ra_tmp_height != ra_core_height || ra_core_width != ra_tmp_width) + { /* detect resolution change and switch */ + screen_setup_aspect(width,height); + } - if (video_driver_get_aspect_ratio() != fly_aspect){ /* check aspect is correct else change */ - video_driver_set_aspect_ratio_value((float)fly_aspect); - ben_poke_video(); - } - - + if (video_driver_get_aspect_ratio() != fly_aspect) + { /* check aspect is correct else change */ + 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 */ - if (first_run != 1){ +void check_first_run() +{ /* ruin of first boot to get current display resolution */ + if (first_run != 1) + { orig_height = GetSystemMetrics(SM_CYSCREEN); orig_width = GetSystemMetrics(SM_CXSCREEN); } 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(); /* get original resolution of core */ - if (width >= 1900){ - if (height == 4){ /* detect menu only */ + if (width >= 1900) + { + if (height == 4) + { /* detect menu only */ height = 480; aspect_ratio_switch(width,height); } - if (height < 191 && height != 144){ + if (height < 191 && height != 144) + { aspect_ratio_switch(width,height); height = 200; } - if (height > 191){ + if (height > 191) + { aspect_ratio_switch(width,height); } - if (height == 144 && set_ben_core_hz == 50){ + if (height == 144 && ra_set_core_hz == 50) + { height = 288; aspect_ratio_switch(width,height); } - if (height > 200 && height < 224){ + if (height > 200 && height < 224) + { 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); - ben_core_height = 240; + height = 240; } - if (height > 240 && height < 255 ){ + if (height > 240 && height < 255 ) + { 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); - 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); - 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){ - if ( height > 100){ + if ( height > 100) + { - switch_res(width, height,0); - ben_poke_video(); - ben_tmp_height = ben_core_height; - ben_tmp_width = ben_core_width; + switch_res(width, height,0); + crt_poke_video(); + ra_tmp_height = ra_core_height; + ra_tmp_width = ra_core_width; } } -void aspect_ratio_switch(int width,int height){ /* send aspect float to videeo_driver */ - fly_aspect = (float)width/height; - video_driver_set_aspect_ratio_value((float)fly_aspect); +void aspect_ratio_switch(int width,int height) +{ /* send aspect float to videeo_driver */ + 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 (ben_core_hz < 53 ){ - set_ben_core_hz = 50; + if (ra_core_hz != ra_tmp_core_hz) + { + if (ra_core_hz < 53 ) + { + ra_set_core_hz = 50; } - if (ben_core_hz >= 53 && ben_core_hz < 57){ - set_ben_core_hz = 55; + if (ra_core_hz >= 53 && ra_core_hz < 57) + { + ra_set_core_hz = 55; } - if (ben_core_hz >= 57 ){ - set_ben_core_hz = 60; + if (ra_core_hz >= 57 ) + { + ra_set_core_hz = 60; } - video_monitor_set_refresh_rate(ben_core_hz); - ben_tmp_core_hz = ben_core_hz; + video_monitor_set_refresh_rate(ra_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 devmode; @@ -146,49 +177,63 @@ void switch_res(int width, int height, int f_restore){ /* windows function to s int iModeNum; int depth = 0; int freq; - if (f_restore == 0){ - freq = set_ben_core_hz; - } else { + if (f_restore == 0) + { + freq = ra_set_core_hz; + } + else + { freq = 0; } EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); - if (width == curDevmode.dmPelsWidth){ + if (width == curDevmode.dmPelsWidth) + { width = 0; /* used to stop superresolution bug */ } - if (width == 0) { + if (width == 0) + { width = curDevmode.dmPelsWidth; } - if (height == 0) { + if (height == 0) + { height = curDevmode.dmPelsHeight; } - if (depth == 0) { + if (depth == 0) + { depth = curDevmode.dmBitsPerPel; } - if (freq == 0) { + if (freq == 0) + { freq = curDevmode.dmDisplayFrequency; } - for (iModeNum = 0; ; iModeNum++) { - if (EnumDisplaySettings(NULL, iModeNum, &devmode)) { + for (iModeNum = 0; ; iModeNum++) + { + if (EnumDisplaySettings(NULL, iModeNum, &devmode)) + { - if (devmode.dmPelsWidth != width) { + if (devmode.dmPelsWidth != width) + { continue; } - if (devmode.dmPelsHeight != height) { + if (devmode.dmPelsHeight != height) + { continue; } - if (devmode.dmBitsPerPel != depth) { + if (devmode.dmBitsPerPel != depth) + { continue; } - if (devmode.dmDisplayFrequency != freq) { + if (devmode.dmDisplayFrequency != freq) + { 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; LONG res = ChangeDisplaySettings(&devmode, CDS_TEST); - switch (res) { + switch (res) + { case DISP_CHANGE_SUCCESSFUL: res = ChangeDisplaySettings(&devmode, flags); - switch (res) { + switch (res) + { case DISP_CHANGE_SUCCESSFUL: return; @@ -222,15 +269,15 @@ void switch_res(int width, int height, int f_restore){ /* windows function to s break; } } - else { + else + { break; } } - - } -void video_restore(){ +void video_restore() +{ switch_res(orig_width, orig_height,1); } diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 2e39f95ba3..8a1e283cdd 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -17,16 +17,8 @@ * If not, see . */ -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 check_first_run(); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 6ea3de89f8..ff3e055201 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -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; rarch_ctl(RARCH_CTL_UNSET_NONBLOCK_FORCED, NULL); - ben_core_hz = info->fps; + ra_core_hz = info->fps; if (!info || info->fps <= 0.0) return; 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 { 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); if (crt_switching_active == true){ - if (info->fps <= ben_core_hz) + if (info->fps <= ra_core_hz) return; } else { 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){ 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){ 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); } diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 46c19a52dc..c97ed31000 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -72,7 +72,7 @@ RETRO_BEGIN_DECLS #define MAX_VARIABLES 64 /* Added for resolution wswitching */ -void ben_poke_video(); +void crt_poke_video(); /* Added for resolution wswitching */ From 024b23aa2c1339f1be20e2627634742d33dc7d40 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 20:29:34 +0100 Subject: [PATCH 22/46] Add files via upload --- gfx/video_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index ff3e055201..bef90c75ae 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -25,8 +25,6 @@ #include #include -#include - #include #include #include @@ -54,6 +52,7 @@ #include "video_thread_wrapper.h" #include "video_driver.h" #include "video_display_server.h" +#include "video_crt_switch.h" #include "../frontend/frontend_driver.h" #include "../record/record_driver.h" From ce2d4af1035b0a516a3efd785e3806323ee7f4eb Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 21:01:13 +0100 Subject: [PATCH 23/46] Add files via upload Added Linux place holder --- gfx/video_crt_linux.c | 36 +++++++++++++ gfx/video_crt_linux.h | 21 ++++++++ gfx/video_crt_switch.c | 117 +---------------------------------------- gfx/video_crt_switch.h | 3 ++ 4 files changed, 61 insertions(+), 116 deletions(-) create mode 100644 gfx/video_crt_linux.c create mode 100644 gfx/video_crt_linux.h diff --git a/gfx/video_crt_linux.c b/gfx/video_crt_linux.c new file mode 100644 index 0000000000..f663a330e8 --- /dev/null +++ b/gfx/video_crt_linux.c @@ -0,0 +1,36 @@ +/* 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 . +*/ +#include +#include +#include + +#include "video_crt_switch.h" + + +void switch_res(int width, int height, int f_restore) +{ /* Place holder for Linux function to swith resolutions */ + + + +} + +void video_restore() +{ + +} diff --git a/gfx/video_crt_linux.h b/gfx/video_crt_linux.h new file mode 100644 index 0000000000..83a27d47d2 --- /dev/null +++ b/gfx/video_crt_linux.h @@ -0,0 +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 . +*/ + +void switch_res(int width, int height, int f_restore); +void video_restore(); \ No newline at end of file diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 11a731d413..f7c8b22eb9 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -24,15 +24,13 @@ #include #include "video_crt_switch.h" +#include "video_crt_win.h" -static int ra_set_core_hz; 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; @@ -54,7 +52,6 @@ void switch_res_core(int width, int height, float hz) video_driver_set_aspect_ratio_value((float)fly_aspect); crt_poke_video(); } - } void check_first_run() @@ -168,116 +165,4 @@ void switch_crt_hz() } -void switch_res(int width, int height, int f_restore) -{ /* windows function to swith resolutions */ - - DEVMODE curDevmode; - DEVMODE devmode; - DWORD flags = 0; - int iModeNum; - int depth = 0; - int freq; - if (f_restore == 0) - { - freq = ra_set_core_hz; - } - else - { - freq = 0; - } - - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); - - if (width == curDevmode.dmPelsWidth) - { - width = 0; /* used to stop superresolution bug */ - } - if (width == 0) - { - width = curDevmode.dmPelsWidth; - } - if (height == 0) - { - height = curDevmode.dmPelsHeight; - } - if (depth == 0) - { - depth = curDevmode.dmBitsPerPel; - } - if (freq == 0) - { - freq = curDevmode.dmDisplayFrequency; - } - - for (iModeNum = 0; ; iModeNum++) - { - if (EnumDisplaySettings(NULL, iModeNum, &devmode)) - { - - if (devmode.dmPelsWidth != width) - { - continue; - } - - if (devmode.dmPelsHeight != height) - { - continue; - } - - - if (devmode.dmBitsPerPel != depth) - { - continue; - } - - - if (devmode.dmDisplayFrequency != freq) - { - continue; - } - - - devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; - LONG res = ChangeDisplaySettings(&devmode, CDS_TEST); - - switch (res) - { - case DISP_CHANGE_SUCCESSFUL: - res = ChangeDisplaySettings(&devmode, flags); - switch (res) - { - case DISP_CHANGE_SUCCESSFUL: - return; - - case DISP_CHANGE_NOTUPDATED: - - return; - - default: - - break; - } - break; - - case DISP_CHANGE_RESTART: - - break; - - default: - - break; - } - } - else - { - break; - } - } - -} - -void video_restore() -{ - switch_res(orig_width, orig_height,1); -} diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 8a1e283cdd..1ee133c713 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -19,6 +19,9 @@ static float ra_core_hz; /* Shared with video_driver.c */ +static int ra_set_core_hz; +static int orig_width; +static int orig_height; void switch_res_core(int width, int height, float hz); void check_first_run(); From 2243d7641ba36b2fe69010c309aa33aeedcf1e71 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 21:02:50 +0100 Subject: [PATCH 24/46] Add files via upload Windows driver --- gfx/video_crt_win.c | 139 ++++++++++++++++++++++++++++++++++++++++++++ gfx/video_crt_win.h | 21 +++++++ 2 files changed, 160 insertions(+) create mode 100644 gfx/video_crt_win.c create mode 100644 gfx/video_crt_win.h diff --git a/gfx/video_crt_win.c b/gfx/video_crt_win.c new file mode 100644 index 0000000000..6aff3170d2 --- /dev/null +++ b/gfx/video_crt_win.c @@ -0,0 +1,139 @@ +/* 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 . +*/ +#include +#include +#include +#include + +#include "video_crt_switch.h" + + +void switch_res(int width, int height, int f_restore) +{ /* windows function to swith resolutions */ + + DEVMODE curDevmode; + DEVMODE devmode; + DWORD flags = 0; + int iModeNum; + int depth = 0; + int freq; + if (f_restore == 0) + { + freq = ra_set_core_hz; + } + else + { + freq = 0; + } + + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); + + if (width == curDevmode.dmPelsWidth) + { + width = 0; /* used to stop superresolution bug */ + } + + if (width == 0) + { + width = curDevmode.dmPelsWidth; + } + if (height == 0) + { + height = curDevmode.dmPelsHeight; + } + if (depth == 0) + { + depth = curDevmode.dmBitsPerPel; + } + if (freq == 0) + { + freq = curDevmode.dmDisplayFrequency; + } + + for (iModeNum = 0; ; iModeNum++) + { + if (EnumDisplaySettings(NULL, iModeNum, &devmode)) + { + + if (devmode.dmPelsWidth != width) + { + continue; + } + + if (devmode.dmPelsHeight != height) + { + continue; + } + + + if (devmode.dmBitsPerPel != depth) + { + continue; + } + + + if (devmode.dmDisplayFrequency != freq) + { + continue; + } + + + devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + LONG res = ChangeDisplaySettings(&devmode, CDS_TEST); + + switch (res) + { + case DISP_CHANGE_SUCCESSFUL: + res = ChangeDisplaySettings(&devmode, flags); + switch (res) + { + case DISP_CHANGE_SUCCESSFUL: + return; + + case DISP_CHANGE_NOTUPDATED: + + return; + + default: + + break; + } + break; + + case DISP_CHANGE_RESTART: + + break; + + default: + + break; + } + } + else + { + break; + } + } + +} + +void video_restore() +{ + switch_res(orig_width, orig_height,1); +} diff --git a/gfx/video_crt_win.h b/gfx/video_crt_win.h new file mode 100644 index 0000000000..83a27d47d2 --- /dev/null +++ b/gfx/video_crt_win.h @@ -0,0 +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 . +*/ + +void switch_res(int width, int height, int f_restore); +void video_restore(); \ No newline at end of file From 2ed38a8481a4f27f8ee047b4e877e6ff91420f33 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 21:07:22 +0100 Subject: [PATCH 25/46] Add files via upload Includes Linux place holder --- Makefile.common | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index d2569c9ab5..16965ec9e2 100644 --- a/Makefile.common +++ b/Makefile.common @@ -127,6 +127,7 @@ ifneq ($(findstring Linux,$(OS)),) OBJ += input/drivers/linuxraw_input.o \ input/common/linux_common.o \ input/drivers_joypad/linuxraw_joypad.o + gfx/video_crt_linux.o HAVE_UNIX = 1 endif @@ -204,6 +205,7 @@ OBJ += frontend/frontend.o \ gfx/video_coord_array.o \ gfx/video_display_server.o \ gfx/video_driver.o \ + gfx/video_crt_switch.o \ camera/camera_driver.o \ wifi/wifi_driver.o \ location/location_driver.o \ @@ -982,7 +984,7 @@ endif ifneq ($(findstring Win32,$(OS)),) OBJ += input/drivers/winraw_input.o \ - gfx/video_crt_switch.o + gfx/video_crt_win.o endif # Companion UI From 80e295505ec454b3d66ba429d223358e8a73967a Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 21:14:27 +0100 Subject: [PATCH 26/46] Add files via upload --- Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index 16965ec9e2..9db5bbba0f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -126,7 +126,7 @@ ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt OBJ += input/drivers/linuxraw_input.o \ input/common/linux_common.o \ - input/drivers_joypad/linuxraw_joypad.o + input/drivers_joypad/linuxraw_joypad.o \ gfx/video_crt_linux.o HAVE_UNIX = 1 endif From 0ef6455c612c4ec95e741f2d6426a2f63a6a465e Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 21:22:19 +0100 Subject: [PATCH 27/46] Add files via upload Windows / Linux deps fix --- gfx/video_crt_linux.c | 8 ++++++++ gfx/video_crt_linux.h | 2 +- gfx/video_crt_switch.c | 11 ----------- gfx/video_crt_win.c | 11 +++++++++++ gfx/video_crt_win.h | 1 + 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gfx/video_crt_linux.c b/gfx/video_crt_linux.c index f663a330e8..9a2d8299b6 100644 --- a/gfx/video_crt_linux.c +++ b/gfx/video_crt_linux.c @@ -22,6 +22,14 @@ #include "video_crt_switch.h" +void check_first_run() +{ /* ruin of first boot to get current display resolution */ + if (first_run != 1) + { + + } + first_run = 1; +} void switch_res(int width, int height, int f_restore) { /* Place holder for Linux function to swith resolutions */ diff --git a/gfx/video_crt_linux.h b/gfx/video_crt_linux.h index 83a27d47d2..9982fbf3a3 100644 --- a/gfx/video_crt_linux.h +++ b/gfx/video_crt_linux.h @@ -16,6 +16,6 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - +void check_first_run(); void switch_res(int width, int height, int f_restore); void video_restore(); \ No newline at end of file diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index f7c8b22eb9..a496cf5dee 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -18,7 +18,6 @@ */ #include #include -#include #include #include @@ -31,7 +30,6 @@ static int ra_core_width; static int ra_core_height; static int ra_tmp_width; static int ra_tmp_height; -static int first_run; static float fly_aspect; void switch_res_core(int width, int height, float hz) @@ -54,15 +52,6 @@ void switch_res_core(int width, int height, float hz) } } -void check_first_run() -{ /* ruin of first boot to get current display resolution */ - if (first_run != 1) - { - orig_height = GetSystemMetrics(SM_CYSCREEN); - orig_width = GetSystemMetrics(SM_CXSCREEN); - } - first_run = 1; -} void screen_setup_aspect(int width, int height) { /* create correct aspect to fit video if resolution does not exist */ diff --git a/gfx/video_crt_win.c b/gfx/video_crt_win.c index 6aff3170d2..9296720d5f 100644 --- a/gfx/video_crt_win.c +++ b/gfx/video_crt_win.c @@ -23,6 +23,17 @@ #include "video_crt_switch.h" +static int first_run; + +void check_first_run() +{ /* ruin of first boot to get current display resolution */ + if (first_run != 1) + { + orig_height = GetSystemMetrics(SM_CYSCREEN); + orig_width = GetSystemMetrics(SM_CXSCREEN); + } + first_run = 1; +} void switch_res(int width, int height, int f_restore) { /* windows function to swith resolutions */ diff --git a/gfx/video_crt_win.h b/gfx/video_crt_win.h index 83a27d47d2..ec9b68d1f4 100644 --- a/gfx/video_crt_win.h +++ b/gfx/video_crt_win.h @@ -17,5 +17,6 @@ * If not, see . */ +void check_first_run(); void switch_res(int width, int height, int f_restore); void video_restore(); \ No newline at end of file From 316e1ebf66d243acae8a5c9ced0ae5ac53d8eea5 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 21:25:16 +0100 Subject: [PATCH 28/46] Add files via upload Missing var in Linux placeholder --- gfx/video_crt_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/video_crt_linux.c b/gfx/video_crt_linux.c index 9a2d8299b6..f21632c648 100644 --- a/gfx/video_crt_linux.c +++ b/gfx/video_crt_linux.c @@ -22,6 +22,8 @@ #include "video_crt_switch.h" +static int first_run; + void check_first_run() { /* ruin of first boot to get current display resolution */ if (first_run != 1) From d7d1d1d5b89465d8e0623d5339e6b0d0fbc2e595 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 23:49:33 +0100 Subject: [PATCH 29/46] Add files via upload Fixed errors after variable changes --- gfx/video_crt_linux.c | 2 +- gfx/video_crt_linux.h | 2 +- gfx/video_crt_switch.c | 8 ++++++-- gfx/video_crt_switch.h | 1 - gfx/video_crt_win.c | 7 +++---- gfx/video_crt_win.h | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gfx/video_crt_linux.c b/gfx/video_crt_linux.c index f21632c648..89bd46ff6c 100644 --- a/gfx/video_crt_linux.c +++ b/gfx/video_crt_linux.c @@ -33,7 +33,7 @@ void check_first_run() first_run = 1; } -void switch_res(int width, int height, int f_restore) +void switch_res(int width, int height, int f_restore, int ra_hz) { /* Place holder for Linux function to swith resolutions */ diff --git a/gfx/video_crt_linux.h b/gfx/video_crt_linux.h index 9982fbf3a3..48a337b961 100644 --- a/gfx/video_crt_linux.h +++ b/gfx/video_crt_linux.h @@ -17,5 +17,5 @@ * If not, see . */ void check_first_run(); -void switch_res(int width, int height, int f_restore); +void switch_res(int width, int height, int f_restore,int ra_hz); void video_restore(); \ No newline at end of file diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index a496cf5dee..3a9dfe4a80 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -114,8 +114,12 @@ void switch_res_crt(int width, int height){ if ( height > 100) { - - switch_res(width, height,0); + + FILE *ben_res = fopen("ra_res_hz.txt", "a"); + fprintf (ben_res, "%s%d%s%d%s%d%s%lf\n","SuperRes @ 2560 ",width," x ", height," @ ", ra_set_core_hz," Apsect ", fly_aspect); + fclose(ben_res); + + switch_res(width, height,0,ra_set_core_hz); crt_poke_video(); ra_tmp_height = ra_core_height; ra_tmp_width = ra_core_width; diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 1ee133c713..cd51ada523 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -29,5 +29,4 @@ void screen_setup_aspect(int width, int height); void switch_res_crt(int width, int height); void aspect_ratio_switch(int width,int height); void switch_crt_hz(); -void switch_res(int width, int height, int f_restore); void video_restore(); \ No newline at end of file diff --git a/gfx/video_crt_win.c b/gfx/video_crt_win.c index 9296720d5f..6d6264b431 100644 --- a/gfx/video_crt_win.c +++ b/gfx/video_crt_win.c @@ -35,9 +35,8 @@ void check_first_run() first_run = 1; } -void switch_res(int width, int height, int f_restore) +void switch_res(int width, int height, int f_restore,int ra_hz) { /* windows function to swith resolutions */ - DEVMODE curDevmode; DEVMODE devmode; DWORD flags = 0; @@ -46,7 +45,7 @@ void switch_res(int width, int height, int f_restore) int freq; if (f_restore == 0) { - freq = ra_set_core_hz; + freq = ra_hz; } else { @@ -146,5 +145,5 @@ void switch_res(int width, int height, int f_restore) void video_restore() { - switch_res(orig_width, orig_height,1); + switch_res(orig_width, orig_height,0,60); } diff --git a/gfx/video_crt_win.h b/gfx/video_crt_win.h index ec9b68d1f4..b4271264ef 100644 --- a/gfx/video_crt_win.h +++ b/gfx/video_crt_win.h @@ -18,5 +18,5 @@ */ void check_first_run(); -void switch_res(int width, int height, int f_restore); +void switch_res(int width, int height, int f_restore, int ra_hz); void video_restore(); \ No newline at end of file From b1fca8fc7e10dbf0cd899ecaf1f59f2513f753eb Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 23:51:40 +0100 Subject: [PATCH 30/46] Add files via upload Removed debug info --- gfx/video_crt_switch.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 3a9dfe4a80..6030833766 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -114,10 +114,6 @@ void switch_res_crt(int width, int height){ if ( height > 100) { - - FILE *ben_res = fopen("ra_res_hz.txt", "a"); - fprintf (ben_res, "%s%d%s%d%s%d%s%lf\n","SuperRes @ 2560 ",width," x ", height," @ ", ra_set_core_hz," Apsect ", fly_aspect); - fclose(ben_res); switch_res(width, height,0,ra_set_core_hz); crt_poke_video(); From 9ce592b6483eeca3330d868563a40266518c4876 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 26 Mar 2018 23:58:54 +0100 Subject: [PATCH 31/46] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e43a68a15..432ba0eb07 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Instructions for compiling and installing RetroArch can be found in the [Libretr ## CRT 15Khz Resolution Switching -CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. With CRT SwitchRes enable Retroarch will start in 2560 @ 480. +CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. With CRT SwitchRes enable Retroarch will start in 2560 x 480 @ 60. Before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimun modelins for all games to switch correctly are: From 7f3b2474a9c272ca9d122ada084bf12f384ea71c Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 27 Mar 2018 00:08:59 +0100 Subject: [PATCH 32/46] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 432ba0eb07..87f4cfaad9 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Instructions for compiling and installing RetroArch can be found in the [Libretr CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. With CRT SwitchRes enable Retroarch will start in 2560 x 480 @ 60. -Before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimun modelins for all games to switch correctly are: +If you are rnning windows, before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimum modelins for all games to switch correctly are: - 2560 x 192 @ 60.000000 - 2560 x 200 @ 60.000000 From fc173eafabe5f85a9d73b55f5fbdc3e254dbec46 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 27 Mar 2018 00:12:46 +0100 Subject: [PATCH 33/46] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 87f4cfaad9..9eaaefc335 100644 --- a/README.md +++ b/README.md @@ -251,8 +251,8 @@ If native reolutions are activeted you will need a whole new set of modelines: These modelines are more acurate giving exact hz. However, some games may have unwanted results. This is due to mid-scanline resolution chages on the orgiginal hardware. For the best results super resolutions are the way to go. -## CRT SwitchRes & Mame +## CRT resolution switching & Mame -Some arecade resolutions can be alot different. There is rosolution detection to ensure mame games will be diplayed in the closest available resolution but drawn at their native resolution within this resolution. Meaning that the mame game will look just like the original hardware. +Some arecade resolutions can be alot different. There is resolution detection to ensure mame games will be diplayed in the closest available resolution but drawn at their native resolution within this resolution. Meaning that the mame game will look just like the original hardware. Mame roms that run in a vertical aspect like DoDonPachi need to be roted within mame before rolution swithing and aspect correction will work. Do this before enableing CRT switchRes so that Retroarch will run in your desktop resolution. Once you have roted any games that may need it switch CRT SwitchRes on. From 46500e119c379746148e7c2c080e0320b207791c Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 27 Mar 2018 20:18:31 +0100 Subject: [PATCH 34/46] Add files via upload native switch fix --- gfx/video_crt_switch.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 6030833766..78bede1243 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -57,10 +57,14 @@ void screen_setup_aspect(int width, int height) { /* create correct aspect to fit video if resolution does not exist */ switch_crt_hz(); /* get original resolution of core */ - if (width >= 1900) - { + + if (height == 4) - { /* detect menu only */ + { + if (width < 1920) + { + width = 640; + }/* detect menu only */ height = 480; aspect_ratio_switch(width,height); } @@ -106,7 +110,7 @@ void screen_setup_aspect(int width, int height) height = 254; } - } + switch_res_crt(width, height); } From d8c5718a6eb21e05bbfe813e547c82ef01802342 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 27 Mar 2018 23:01:09 +0100 Subject: [PATCH 35/46] Update README.md incorrect spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9eaaefc335..00ada5a316 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Instructions for compiling and installing RetroArch can be found in the [Libretr CRT Switch res will turn on, on the fly. However, you will need to restart retroarch to disable it. With CRT SwitchRes enable Retroarch will start in 2560 x 480 @ 60. -If you are rnning windows, before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimum modelins for all games to switch correctly are: +If you are running windows, before enabling the CRT SwitchRes options pleasae make sure you have installed CRTEmudriver and installed some modelines. The minimum modelins for all games to switch correctly are: - 2560 x 192 @ 60.000000 - 2560 x 200 @ 60.000000 From 6d536974d8893f32887edf308c3bb4600e3dad51 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Thu, 29 Mar 2018 17:37:39 +0100 Subject: [PATCH 36/46] Add files via upload Removed comments --- configuration.c | 2 +- configuration.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.c b/configuration.c index 5f4c717609..85c8ba6a49 100644 --- a/configuration.c +++ b/configuration.c @@ -1242,7 +1242,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, vsync, false); SETTING_BOOL("video_hard_sync", &settings->bools.video_hard_sync, true, hard_sync, false); SETTING_BOOL("video_black_frame_insertion", &settings->bools.video_black_frame_insertion, true, black_frame_insertion, false); - SETTING_BOOL("crt_switch_resolution", &settings->bools.crt_switch_resolution, true, crt_switch_resolution, false); //ben + SETTING_BOOL("crt_switch_resolution", &settings->bools.crt_switch_resolution, true, crt_switch_resolution, false); SETTING_BOOL("video_disable_composition", &settings->bools.video_disable_composition, true, disable_composition, false); SETTING_BOOL("pause_nonactive", &settings->bools.pause_nonactive, true, pause_nonactive, false); SETTING_BOOL("video_gpu_screenshot", &settings->bools.video_gpu_screenshot, true, gpu_screenshot, false); diff --git a/configuration.h b/configuration.h index a937a5bd87..5e15e05f64 100644 --- a/configuration.h +++ b/configuration.h @@ -334,7 +334,7 @@ typedef struct settings unsigned video_window_x; unsigned video_window_y; unsigned video_window_opacity; - unsigned crt_switch_resolution_super; //ben + unsigned crt_switch_resolution_super; unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; From d06386d0a532cbbd5668b3621d0a1c8f3e042f4b Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Thu, 29 Mar 2018 17:54:46 +0100 Subject: [PATCH 37/46] Add files via upload Variables removed from headers. --- gfx/video_crt_switch.c | 6 +++++- gfx/video_crt_switch.h | 6 ------ gfx/video_crt_win.c | 4 ++++ gfx/video_driver.c | 13 ++++++++----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 78bede1243..7fc36dd3c9 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -24,6 +24,7 @@ #include "video_crt_switch.h" #include "video_crt_win.h" +#include "video_crt_linux.h" static float ra_tmp_core_hz; static int ra_core_width; @@ -31,6 +32,8 @@ static int ra_core_height; static int ra_tmp_width; static int ra_tmp_height; static float fly_aspect; +static float ra_core_hz; +static int ra_set_core_hz; void switch_res_core(int width, int height, float hz) { @@ -139,6 +142,7 @@ void switch_crt_hz() if (ra_core_hz != ra_tmp_core_hz) { + if (ra_core_hz < 53 ) { ra_set_core_hz = 50; @@ -152,7 +156,7 @@ void switch_crt_hz() { ra_set_core_hz = 60; } - video_monitor_set_refresh_rate(ra_core_hz); + video_monitor_set_refresh_rate(ra_set_core_hz); ra_tmp_core_hz = ra_core_hz; } diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index cd51ada523..f518dc7bfa 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -17,12 +17,6 @@ * If not, see . */ - -static float ra_core_hz; /* Shared with video_driver.c */ -static int ra_set_core_hz; -static int orig_width; -static int orig_height; - void switch_res_core(int width, int height, float hz); void check_first_run(); void screen_setup_aspect(int width, int height); diff --git a/gfx/video_crt_win.c b/gfx/video_crt_win.c index 6d6264b431..f843279b97 100644 --- a/gfx/video_crt_win.c +++ b/gfx/video_crt_win.c @@ -24,6 +24,8 @@ #include "video_crt_switch.h" static int first_run; +static int orig_width; +static int orig_height; void check_first_run() { /* ruin of first boot to get current display resolution */ @@ -147,3 +149,5 @@ void video_restore() { switch_res(orig_width, orig_height,0,60); } + + diff --git a/gfx/video_driver.c b/gfx/video_driver.c index bef90c75ae..823a74c3c9 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -119,7 +119,9 @@ #define video_driver_context_unlock() ((void)0) #endif -bool crt_switching_active; +static bool crt_switching_active; +static float video_driver_core_hz; + typedef struct video_pixel_scaler { @@ -1417,13 +1419,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; rarch_ctl(RARCH_CTL_UNSET_NONBLOCK_FORCED, NULL); - ra_core_hz = info->fps; + video_driver_core_hz = info->fps; if (!info || info->fps <= 0.0) return; if (crt_switching_active == true){ - timing_skew = fabs(1.0f - info->fps / ra_core_hz); + timing_skew = fabs(1.0f - info->fps / video_driver_core_hz); }else { timing_skew = fabs(1.0f - info->fps / video_refresh_rate); } @@ -1437,7 +1439,7 @@ void video_driver_monitor_adjust_system_rates(void) (float)info->fps); if (crt_switching_active == true){ - if (info->fps <= ra_core_hz) + if (info->fps <= video_driver_core_hz) return; } else { if (info->fps <= video_refresh_rate) @@ -2597,6 +2599,7 @@ void video_driver_frame(const void *data, unsigned width, /* trigger set resolution*/ if (video_info.crt_switch_resolution == true){ crt_switching_active = true; + if (video_info.crt_switch_resolution_super == 2560){ width = 2560; } @@ -2606,7 +2609,7 @@ void video_driver_frame(const void *data, unsigned width, if (video_info.crt_switch_resolution_super == 1920){ width = 1920; } - switch_res_core(width, height, ra_core_hz); + switch_res_core(width, height, video_driver_core_hz); } else if (video_info.crt_switch_resolution == false){ crt_switching_active = false; } From 64ebf62959ff77dfd1221089eadc346055270e54 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sat, 31 Mar 2018 15:15:35 +0100 Subject: [PATCH 38/46] Add files via upload Amended tabbing with spaces --- configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.h b/configuration.h index 5e15e05f64..3afa6fdc4b 100644 --- a/configuration.h +++ b/configuration.h @@ -95,7 +95,7 @@ typedef struct settings bool video_statistics_show; bool video_framecount_show; bool video_msg_bgcolor_enable; - bool crt_switch_resolution; + bool crt_switch_resolution; /* Audio */ bool audio_enable; @@ -334,7 +334,7 @@ typedef struct settings unsigned video_window_x; unsigned video_window_y; unsigned video_window_opacity; - unsigned crt_switch_resolution_super; + unsigned crt_switch_resolution_super; unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; From 9524203051e8dce0825e63431850347f33b5db12 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sat, 31 Mar 2018 15:17:55 +0100 Subject: [PATCH 39/46] Add files via upload Amended braces and function calls. --- gfx/video_driver.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 823a74c3c9..d2832ede8c 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1424,9 +1424,12 @@ void video_driver_monitor_adjust_system_rates(void) if (!info || info->fps <= 0.0) return; - if (crt_switching_active == true){ - timing_skew = fabs(1.0f - info->fps / video_driver_core_hz); - }else { + if (crt_switching_active == true) + { + timing_skew = fabs(1.0f - info->fps / video_driver_core_hz); + } + else + { timing_skew = fabs(1.0f - info->fps / video_refresh_rate); } /* We don't want to adjust pitch too much. If we have extreme cases, @@ -1441,7 +1444,9 @@ void video_driver_monitor_adjust_system_rates(void) if (crt_switching_active == true){ if (info->fps <= video_driver_core_hz) return; - } else { + } + else + { if (info->fps <= video_refresh_rate) return; } @@ -1572,7 +1577,7 @@ static void video_driver_lock_new(void) void video_driver_destroy(void) { video_display_server_destroy(); - video_restore(); + crt_video_restore(); video_driver_cb_has_focus = null_driver_has_focus; video_driver_use_rgba = false; video_driver_data_own = false; @@ -2609,7 +2614,7 @@ void video_driver_frame(const void *data, unsigned width, if (video_info.crt_switch_resolution_super == 1920){ width = 1920; } - switch_res_core(width, height, video_driver_core_hz); + crt_switch_res_core(width, height, video_driver_core_hz); } else if (video_info.crt_switch_resolution == false){ crt_switching_active = false; } From 6a6150bb034597f42539623aa7dc531c8ac5c25e Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:23:05 +0100 Subject: [PATCH 40/46] Add files via upload Removed obsolete/unneeded .o --- Makefile.common | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.common b/Makefile.common index 9db5bbba0f..a49dfc22dd 100644 --- a/Makefile.common +++ b/Makefile.common @@ -126,8 +126,7 @@ ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt OBJ += input/drivers/linuxraw_input.o \ input/common/linux_common.o \ - input/drivers_joypad/linuxraw_joypad.o \ - gfx/video_crt_linux.o + input/drivers_joypad/linuxraw_joypad.o HAVE_UNIX = 1 endif @@ -983,8 +982,7 @@ ifeq ($(HAVE_PARPORT), 1) endif ifneq ($(findstring Win32,$(OS)),) - OBJ += input/drivers/winraw_input.o \ - gfx/video_crt_win.o + OBJ += input/drivers/winraw_input.o endif # Companion UI From dd78622d30b0de23d313a33c84c5b29bd3302408 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:24:26 +0100 Subject: [PATCH 41/46] Add files via upload added files for compile --- griffin/griffin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/griffin/griffin.c b/griffin/griffin.c index 7b321d959e..6b41b8448e 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -798,6 +798,7 @@ AUDIO DRIVERS ============================================================ */ #include "../gfx/video_driver.c" +#include "../gfx/video_crt_switch.c" #include "../gfx/video_display_server.c" #include "../gfx/video_coord_array.c" #include "../input/input_driver.c" From b676167ef6869b36dfafb05d5b8941f948a9e318 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:26:06 +0100 Subject: [PATCH 42/46] Delete video_crt_win.c outdated, not needed --- gfx/video_crt_win.c | 153 -------------------------------------------- 1 file changed, 153 deletions(-) delete mode 100644 gfx/video_crt_win.c diff --git a/gfx/video_crt_win.c b/gfx/video_crt_win.c deleted file mode 100644 index f843279b97..0000000000 --- a/gfx/video_crt_win.c +++ /dev/null @@ -1,153 +0,0 @@ -/* 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 . -*/ -#include -#include -#include -#include - -#include "video_crt_switch.h" - -static int first_run; -static int orig_width; -static int orig_height; - -void check_first_run() -{ /* ruin of first boot to get current display resolution */ - if (first_run != 1) - { - orig_height = GetSystemMetrics(SM_CYSCREEN); - orig_width = GetSystemMetrics(SM_CXSCREEN); - } - first_run = 1; -} - -void switch_res(int width, int height, int f_restore,int ra_hz) -{ /* windows function to swith resolutions */ - DEVMODE curDevmode; - DEVMODE devmode; - DWORD flags = 0; - int iModeNum; - int depth = 0; - int freq; - if (f_restore == 0) - { - freq = ra_hz; - } - else - { - freq = 0; - } - - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); - - if (width == curDevmode.dmPelsWidth) - { - width = 0; /* used to stop superresolution bug */ - } - - if (width == 0) - { - width = curDevmode.dmPelsWidth; - } - if (height == 0) - { - height = curDevmode.dmPelsHeight; - } - if (depth == 0) - { - depth = curDevmode.dmBitsPerPel; - } - if (freq == 0) - { - freq = curDevmode.dmDisplayFrequency; - } - - for (iModeNum = 0; ; iModeNum++) - { - if (EnumDisplaySettings(NULL, iModeNum, &devmode)) - { - - if (devmode.dmPelsWidth != width) - { - continue; - } - - if (devmode.dmPelsHeight != height) - { - continue; - } - - - if (devmode.dmBitsPerPel != depth) - { - continue; - } - - - if (devmode.dmDisplayFrequency != freq) - { - continue; - } - - - devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; - LONG res = ChangeDisplaySettings(&devmode, CDS_TEST); - - switch (res) - { - case DISP_CHANGE_SUCCESSFUL: - res = ChangeDisplaySettings(&devmode, flags); - switch (res) - { - case DISP_CHANGE_SUCCESSFUL: - return; - - case DISP_CHANGE_NOTUPDATED: - - return; - - default: - - break; - } - break; - - case DISP_CHANGE_RESTART: - - break; - - default: - - break; - } - } - else - { - break; - } - } - -} - -void video_restore() -{ - switch_res(orig_width, orig_height,0,60); -} - - From 752eddbb9560349b80c6d1a7708d22e9a396bd50 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:26:24 +0100 Subject: [PATCH 43/46] Delete video_crt_linux.c outdated, not needed --- gfx/video_crt_linux.c | 46 ------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 gfx/video_crt_linux.c diff --git a/gfx/video_crt_linux.c b/gfx/video_crt_linux.c deleted file mode 100644 index 89bd46ff6c..0000000000 --- a/gfx/video_crt_linux.c +++ /dev/null @@ -1,46 +0,0 @@ -/* 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 . -*/ -#include -#include -#include - -#include "video_crt_switch.h" - -static int first_run; - -void check_first_run() -{ /* ruin of first boot to get current display resolution */ - if (first_run != 1) - { - - } - first_run = 1; -} - -void switch_res(int width, int height, int f_restore, int ra_hz) -{ /* Place holder for Linux function to swith resolutions */ - - - -} - -void video_restore() -{ - -} From 79eb3e6b8c9b343d1d1e2fb40c5ea15d3ffc25f4 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:26:44 +0100 Subject: [PATCH 44/46] Delete video_crt_win.h outdated, not needed --- gfx/video_crt_win.h | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 gfx/video_crt_win.h diff --git a/gfx/video_crt_win.h b/gfx/video_crt_win.h deleted file mode 100644 index b4271264ef..0000000000 --- a/gfx/video_crt_win.h +++ /dev/null @@ -1,22 +0,0 @@ -/* 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 . -*/ - -void check_first_run(); -void switch_res(int width, int height, int f_restore, int ra_hz); -void video_restore(); \ No newline at end of file From ca55f3198e073e308c267d0dcdca9629549377f8 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:27:04 +0100 Subject: [PATCH 45/46] Delete video_crt_linux.h outdated, not needed --- gfx/video_crt_linux.h | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 gfx/video_crt_linux.h diff --git a/gfx/video_crt_linux.h b/gfx/video_crt_linux.h deleted file mode 100644 index 48a337b961..0000000000 --- a/gfx/video_crt_linux.h +++ /dev/null @@ -1,21 +0,0 @@ -/* 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 . -*/ -void check_first_run(); -void switch_res(int width, int height, int f_restore,int ra_hz); -void video_restore(); \ No newline at end of file From cf23ff7a8854437883be43581a2d7fb19a15ff0d Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 1 Apr 2018 00:29:46 +0100 Subject: [PATCH 46/46] Add files via upload Fixes, merged changes and additions to remove extra files. --- gfx/video_crt_switch.c | 341 ++++++++++++++++++++++++++++------------- gfx/video_crt_switch.h | 13 +- 2 files changed, 242 insertions(+), 112 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 7fc36dd3c9..d9bded15f9 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -1,5 +1,5 @@ /* CRT SwitchRes Core - * Copyright (C) 2018 Ben Templeman. + * Copyright (C) 2018 Alphanu / Ben Templeman. * * RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen @@ -20,11 +20,13 @@ #include #include -#include +#if defined(_WIN32) + #include +#endif + +#include "video_driver.h" #include "video_crt_switch.h" -#include "video_crt_win.h" -#include "video_crt_linux.h" static float ra_tmp_core_hz; static int ra_core_width; @@ -34,132 +36,259 @@ static int ra_tmp_height; static float fly_aspect; static float ra_core_hz; static int ra_set_core_hz; +static int orig_width; +static int orig_height; +static int first_run; -void switch_res_core(int width, int height, float hz) +void crt_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) */ - ra_core_width = width; - ra_core_height = height; - ra_core_hz = hz; - check_first_run(); + /* ben_core_hz float passed from with in void video_driver_monitor_adjust_system_rates(void) */ + ra_core_width = width; + ra_core_height = height; + ra_core_hz = hz; + crt_check_first_run(); - if (ra_tmp_height != ra_core_height || ra_core_width != ra_tmp_width) - { /* detect resolution change and switch */ - screen_setup_aspect(width,height); - } + if (ra_tmp_height != ra_core_height || ra_core_width != ra_tmp_width) + { /* detect resolution change and switch */ + crt_screen_setup_aspect(width,height); + } + + ra_tmp_height = ra_core_height; + ra_tmp_width = ra_core_width; - if (video_driver_get_aspect_ratio() != fly_aspect) - { /* check aspect is correct else change */ - video_driver_set_aspect_ratio_value((float)fly_aspect); - crt_poke_video(); - } + if (video_driver_get_aspect_ratio() != fly_aspect) + { /* check aspect is correct else change */ + video_driver_set_aspect_ratio_value((float)fly_aspect); + crt_poke_video(); + } +} + +void crt_check_first_run() +{ /* ruin of first boot to get current display resolution */ + if (first_run != 1) + { + #if defined(_WIN32) + orig_height = GetSystemMetrics(SM_CYSCREEN); + orig_width = GetSystemMetrics(SM_CXSCREEN); + #endif + + } + first_run = 1; } -void screen_setup_aspect(int width, int height) +void crt_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 */ - if (height == 4) - { - if (width < 1920) - { - width = 640; - }/* detect menu only */ - height = 480; - aspect_ratio_switch(width,height); - } - if (height < 191 && height != 144) - { - aspect_ratio_switch(width,height); - height = 200; - } - if (height > 191) - { - aspect_ratio_switch(width,height); - } - if (height == 144 && ra_set_core_hz == 50) - { - height = 288; - aspect_ratio_switch(width,height); - } - if (height > 200 && height < 224) - { - aspect_ratio_switch(width,height); - height = 224; - } - if (height > 224 && height < 240) - { - aspect_ratio_switch(width,height); - height = 240; - } - - if (height > 240 && height < 255 ) - { - aspect_ratio_switch(width,height); - height = 254; - } - if (height == 528 && ra_set_core_hz == 60) - { - aspect_ratio_switch(width,height); - height = 480; - } - - if (height >= 240 && height < 255 && ra_set_core_hz == 55) - { - aspect_ratio_switch(width,height); - height = 254; - } + if (height == 4) + { + if (width < 1920) + { + width = 640; + }/* detect menu only */ + height = 480; + crt_aspect_ratio_switch(width,height); + } + if (height < 191 && height != 144) + { + crt_aspect_ratio_switch(width,height); + height = 200; + } + if (height > 191) + { + crt_aspect_ratio_switch(width,height); + } + if (height == 144 && ra_set_core_hz == 50) + { + height = 288; + crt_aspect_ratio_switch(width,height); + } + if (height > 200 && height < 224) + { + crt_aspect_ratio_switch(width,height); + height = 224; + } + if (height > 224 && height < 240) + { + crt_aspect_ratio_switch(width,height); + height = 240; + } + if (height > 240 && height < 255 ) + { + crt_aspect_ratio_switch(width,height); + height = 254; + } + if (height == 528 && ra_set_core_hz == 60) + { + crt_aspect_ratio_switch(width,height); + height = 480; + } + if (height >= 240 && height < 255 && ra_set_core_hz == 55) + { + crt_aspect_ratio_switch(width,height); + height = 254; + } - - switch_res_crt(width, height); + switch_res_crt(width, height); } void switch_res_crt(int width, int height){ - if ( height > 100) - { - - switch_res(width, height,0,ra_set_core_hz); - crt_poke_video(); - ra_tmp_height = ra_core_height; - ra_tmp_width = ra_core_width; - - } - + if ( height > 100) + { + + crt_switch_res(width, height,0,ra_set_core_hz); + crt_poke_video(); + } } -void aspect_ratio_switch(int width,int height) +void crt_aspect_ratio_switch(int width,int height) { /* send aspect float to videeo_driver */ - fly_aspect = (float)width/height; - 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 */ - if (ra_core_hz != ra_tmp_core_hz) - { - - 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; - } - + if (ra_core_hz != ra_tmp_core_hz) + { + 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; + } +} + +void crt_video_restore() +{ + + crt_switch_res(orig_width, orig_height,0,60); + } +void crt_switch_res(int width, int height, int f_restore,int ra_hz) +{ /* windows function to swith resolutions */ + + #if defined(_WIN32) + DEVMODE curDevmode; + DEVMODE devmode; + DWORD flags = 0; + + int iModeNum; + int depth = 0; + int freq; + LONG res; + + if (f_restore == 0) + { + freq = ra_hz; + } + else + { + freq = 0; + } + + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); + + if (width == curDevmode.dmPelsWidth) + { + width = 0; /* used to stop superresolution bug */ + } + if (width == 0) + { + width = curDevmode.dmPelsWidth; + } + if (height == 0) + { + height = curDevmode.dmPelsHeight; + } + if (depth == 0) + { + depth = curDevmode.dmBitsPerPel; + } + if (freq == 0) + { + freq = curDevmode.dmDisplayFrequency; + } + + for (iModeNum = 0; ; iModeNum++) + { + if (EnumDisplaySettings(NULL, iModeNum, &devmode)) + { + + if (devmode.dmPelsWidth != width) + { + continue; + } + + if (devmode.dmPelsHeight != height) + { + continue; + } + + if (devmode.dmBitsPerPel != depth) + { + continue; + } + + if (devmode.dmDisplayFrequency != freq) + { + continue; + } + + devmode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + res = ChangeDisplaySettings(&devmode, CDS_TEST); + + switch (res) + { + case DISP_CHANGE_SUCCESSFUL: + res = ChangeDisplaySettings(&devmode, flags); + switch (res) + { + case DISP_CHANGE_SUCCESSFUL: + return; + + case DISP_CHANGE_NOTUPDATED: + return; + + default: + + break; + } + break; + + case DISP_CHANGE_RESTART: + + break; + + default: + + break; + } + } + else + { + break; + } + } + #endif + + #if defined(linux) + + #endif +} diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index f518dc7bfa..c93d9dea0e 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -1,5 +1,5 @@ /* CRT SwitchRes Core - * Copyright (C) 2018 Ben Templeman. + * Copyright (C) 2018 Alphanu / Ben Templeman. * * RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen @@ -17,10 +17,11 @@ * If not, see . */ -void switch_res_core(int width, int height, float hz); -void check_first_run(); -void screen_setup_aspect(int width, int height); +void crt_check_first_run(); +void crt_switch_res_core(int width, int height, float hz); +void crt_screen_setup_aspect(int width, int height); void switch_res_crt(int width, int height); -void aspect_ratio_switch(int width,int height); +void crt_aspect_ratio_switch(int width,int height); void switch_crt_hz(); -void video_restore(); \ No newline at end of file +void crt_video_restore(); +void crt_switch_res(int width, int height, int f_restore,int ra_hz);