From e86742b03ca50a0aa7eed17c39c435d9b0192fc9 Mon Sep 17 00:00:00 2001 From: icex2 Date: Fri, 19 Mar 2021 23:43:10 +0100 Subject: [PATCH] hook/nx2: Add option to enable gfx scaling --- dist/conf/nx2hook.conf | 3 +++ src/main/hook/nx2/main.c | 4 ++++ src/main/hook/nx2/options.c | 10 ++++++++++ src/main/hook/nx2/options.h | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/dist/conf/nx2hook.conf b/dist/conf/nx2hook.conf index 84d6404..f23dbaa 100644 --- a/dist/conf/nx2hook.conf +++ b/dist/conf/nx2hook.conf @@ -1,6 +1,9 @@ # [str]: Path to game settings (SETTINGS) folder game.settings=./save +# Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080 +gfx.scaling_mode=0 + # [bool (0/1)]: Enable file call monitoring patch.hook_mon.file=0 diff --git a/src/main/hook/nx2/main.c b/src/main/hook/nx2/main.c index 72b5438..a8ab357 100644 --- a/src/main/hook/nx2/main.c +++ b/src/main/hook/nx2/main.c @@ -196,6 +196,10 @@ static void nx2hook_patch_gfx_init(struct nx2hook_options *options) log_assert(options); patch_gfx_init(); + + if (options->patch.gfx.scaling_mode != PATCH_GFX_SCALE_MODE_INVALID) { + patch_gfx_scale(options->patch.gfx.scaling_mode); + } } static void nx2hook_patch_main_loop_init(struct nx2hook_options *options) diff --git a/src/main/hook/nx2/options.c b/src/main/hook/nx2/options.c index cacc4eb..e76b223 100644 --- a/src/main/hook/nx2/options.c +++ b/src/main/hook/nx2/options.c @@ -3,6 +3,7 @@ #include "util/options.h" #define NX2HOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define NX2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define NX2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define NX2HOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -36,6 +37,13 @@ const struct util_options_def nx2hook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE, + .description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080", + .param = 'z', + .type = UTIL_OPTIONS_TYPE_INT, + .default_value.i = 0, + }, { .name = NX2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -191,6 +199,8 @@ bool nx2hook_options_init( options->game.settings = util_options_get_str(options_opt, NX2HOOK_OPTIONS_STR_GAME_SETTINGS); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, NX2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = diff --git a/src/main/hook/nx2/options.h b/src/main/hook/nx2/options.h index 85c7b0b..7fd7b50 100644 --- a/src/main/hook/nx2/options.h +++ b/src/main/hook/nx2/options.h @@ -12,6 +12,10 @@ struct nx2hook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs;