Change CRT switch resolution - add options 'Off/15 Khz/31Khz'

This commit is contained in:
twinaphex 2018-09-17 01:30:49 +02:00
parent 369f8206d1
commit b5c6586b12
8 changed files with 61 additions and 21 deletions

View File

@ -20,6 +20,7 @@
#include <boolean.h>
#include <audio/audio_resampler.h>
#include "configuration.h"
#include "gfx/video_defines.h"
#include "input/input_driver.h"
@ -67,7 +68,7 @@ static bool bundle_assets_extract_enable = false;
static bool materialui_icons_enable = true;
#endif
static const bool crt_switch_resolution = false;
static const unsigned crt_switch_resolution = CRT_SWITCH_NONE;
static const int crt_switch_resolution_super = 2560;
static const int crt_switch_center_adjust = 0;

View File

@ -1309,7 +1309,6 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("video_adaptive_vsync", &settings->bools.video_adaptive_vsync, true, false, 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);
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);
@ -1518,6 +1517,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
unsigned count = 0;
struct config_uint_setting *tmp = (struct config_uint_setting*)malloc((*size + 1) * sizeof(struct config_uint_setting));
SETTING_UINT("crt_switch_resolution", &settings->uints.crt_switch_resolution, true, crt_switch_resolution, false);
SETTING_UINT("input_bind_timeout", &settings->uints.input_bind_timeout, true, input_bind_timeout, false);
SETTING_UINT("input_bind_hold", &settings->uints.input_bind_hold, true, input_bind_hold, false);
SETTING_UINT("input_turbo_period", &settings->uints.input_turbo_period, true, turbo_period, false);

View File

@ -53,6 +53,13 @@
var = newvar; \
}
enum crt_switch_type
{
CRT_SWITCH_NONE = 0,
CRT_SWITCH_15KHZ,
CRT_SWITCH_31KHZ
};
enum override_type
{
OVERRIDE_NONE = 0,
@ -97,7 +104,6 @@ typedef struct settings
bool video_statistics_show;
bool video_framecount_show;
bool video_msg_bgcolor_enable;
bool crt_switch_resolution;
/* Audio */
bool audio_enable;
@ -361,6 +367,7 @@ typedef struct settings
unsigned video_window_x;
unsigned video_window_y;
unsigned video_window_opacity;
unsigned crt_switch_resolution;
unsigned crt_switch_resolution_super;
unsigned video_monitor_index;
unsigned video_fullscreen_x;

View File

@ -2741,7 +2741,7 @@ 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;
video_info->crt_switch_resolution = settings->uints.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;

View File

@ -409,7 +409,6 @@ typedef struct video_frame_info
bool black_frame_insertion;
bool hard_sync;
bool fps_show;
bool crt_switch_resolution;
bool statistics_show;
bool framecount_show;
bool scale_integer;
@ -435,6 +434,7 @@ typedef struct video_frame_info
unsigned aspect_ratio_idx;
unsigned max_swapchain_images;
unsigned monitor_index;
unsigned crt_switch_resolution;
unsigned crt_switch_resolution_super;
unsigned width;
unsigned height;

View File

@ -126,6 +126,36 @@ static void menu_action_setting_disp_set_label_cheevos_locked_entry(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CHEEVOS_LOCKED_ENTRY), len);
}
static void menu_action_setting_disp_set_label_crt_switch_resolution(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
char *s, size_t len,
const char *entry_label,
const char *path,
char *s2, size_t len2)
{
settings_t *settings = config_get_ptr();
*w = 19;
strlcpy(s2, path, len2);
if (settings)
{
switch (settings->uints.crt_switch_resolution)
{
case CRT_SWITCH_NONE:
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF), len);
break;
case CRT_SWITCH_15KHZ:
strlcpy(s, "15 Khz", len);
break;
case CRT_SWITCH_31KHZ:
strlcpy(s, "31 Khz", len);
break;
}
}
}
static void menu_action_setting_disp_set_label_crt_switch_resolution_super(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
@ -2393,6 +2423,10 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs,
{
switch (cbs->enum_idx)
{
case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION:
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_crt_switch_resolution);
return 0;
case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER:
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_crt_switch_resolution_super);

View File

@ -6292,7 +6292,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION,
PARSE_ONLY_BOOL, false);
PARSE_ONLY_UINT, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER,
PARSE_ONLY_UINT, false);

View File

@ -4560,21 +4560,19 @@ static bool setting_append_list(
START_SUB_GROUP(list, list_info, "State", &group_info, &subgroup_info, parent_group);
CONFIG_BOOL(
CONFIG_UINT(
list, list_info,
&settings->bools.crt_switch_resolution,
&settings->uints.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_ADVANCED
);
general_read_handler);
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED);
menu_settings_list_current_add_range(list, list_info, CRT_SWITCH_NONE, CRT_SWITCH_31KHZ, 1.0, true, true);
CONFIG_UINT(
list, list_info,