From 083505abd9b1615935e9a3f11eda0c29c2fefd13 Mon Sep 17 00:00:00 2001 From: icex2 Date: Sat, 20 Mar 2021 11:35:31 +0100 Subject: [PATCH] hook/other classic piu: Add gfx scaling feature Support every game except for mk3 ports and pro series. Pro series can do scaling etc by game configuration and mk3 has a different gfx backend setup --- dist/conf/exchook.conf | 3 +++ dist/conf/f2hook.conf | 3 +++ dist/conf/fexhook.conf | 3 +++ dist/conf/fsthook.conf | 3 +++ dist/conf/nxahook.conf | 3 +++ dist/conf/nxhook.conf | 3 +++ dist/conf/prihook.conf | 3 +++ dist/conf/x2hook.conf | 3 +++ dist/conf/zerohook.conf | 3 +++ src/main/hook/exc/main.c | 4 ++++ src/main/hook/exc/options.c | 10 ++++++++++ src/main/hook/exc/options.h | 4 ++++ src/main/hook/f2/main.c | 4 ++++ src/main/hook/f2/options.c | 10 ++++++++++ src/main/hook/f2/options.h | 4 ++++ src/main/hook/fex/main.c | 4 ++++ src/main/hook/fex/options.c | 10 ++++++++++ src/main/hook/fex/options.h | 4 ++++ src/main/hook/fst/main.c | 4 ++++ src/main/hook/fst/options.c | 10 ++++++++++ src/main/hook/fst/options.h | 4 ++++ src/main/hook/nx/main.c | 4 ++++ src/main/hook/nx/options.c | 10 ++++++++++ src/main/hook/nx/options.h | 4 ++++ src/main/hook/nxa/main.c | 4 ++++ src/main/hook/nxa/options.c | 8 ++++++++ src/main/hook/nxa/options.h | 4 ++++ src/main/hook/pri/main.c | 4 ++++ src/main/hook/pri/options.c | 10 ++++++++++ src/main/hook/pri/options.h | 4 ++++ src/main/hook/x2/main.c | 4 ++++ src/main/hook/x2/options.c | 10 ++++++++++ src/main/hook/x2/options.h | 4 ++++ src/main/hook/zero/main.c | 4 ++++ src/main/hook/zero/options.c | 10 ++++++++++ src/main/hook/zero/options.h | 4 ++++ 36 files changed, 187 insertions(+) diff --git a/dist/conf/exchook.conf b/dist/conf/exchook.conf index 571581b..756bbda 100644 --- a/dist/conf/exchook.conf +++ b/dist/conf/exchook.conf @@ -4,6 +4,9 @@ game.settings=./save # [str]: Version of the game (format YYYYMMDD). Make sure this matches exactly the version you are running because the hook lib has to apply memory patches. game.version=20040408 +# 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/dist/conf/f2hook.conf b/dist/conf/f2hook.conf index 032c662..650292b 100644 --- a/dist/conf/f2hook.conf +++ b/dist/conf/f2hook.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/dist/conf/fexhook.conf b/dist/conf/fexhook.conf index 032c662..650292b 100644 --- a/dist/conf/fexhook.conf +++ b/dist/conf/fexhook.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/dist/conf/fsthook.conf b/dist/conf/fsthook.conf index 032c662..650292b 100644 --- a/dist/conf/fsthook.conf +++ b/dist/conf/fsthook.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/dist/conf/nxahook.conf b/dist/conf/nxahook.conf index 032c662..650292b 100644 --- a/dist/conf/nxahook.conf +++ b/dist/conf/nxahook.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/dist/conf/nxhook.conf b/dist/conf/nxhook.conf index 7697c80..1b35370 100644 --- a/dist/conf/nxhook.conf +++ b/dist/conf/nxhook.conf @@ -4,6 +4,9 @@ game.force_unlock=0 # [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/dist/conf/prihook.conf b/dist/conf/prihook.conf index 7b928ee..42e383b 100644 --- a/dist/conf/prihook.conf +++ b/dist/conf/prihook.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/dist/conf/x2hook.conf b/dist/conf/x2hook.conf index 86b072b..6f46b6e 100644 --- a/dist/conf/x2hook.conf +++ b/dist/conf/x2hook.conf @@ -4,6 +4,9 @@ game.force_unlock=0 # [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/dist/conf/zerohook.conf b/dist/conf/zerohook.conf index 7391e8f..ac82b29 100644 --- a/dist/conf/zerohook.conf +++ b/dist/conf/zerohook.conf @@ -4,6 +4,9 @@ game.force_unlock=0 # [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/exc/main.c b/src/main/hook/exc/main.c index d7494ad..6fade61 100644 --- a/src/main/hook/exc/main.c +++ b/src/main/hook/exc/main.c @@ -129,6 +129,10 @@ static void exchook_patch_gfx_init(struct exchook_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 exchook_patch_main_loop_init(struct exchook_options *options) diff --git a/src/main/hook/exc/options.c b/src/main/hook/exc/options.c index 17b24e1..eaae862 100644 --- a/src/main/hook/exc/options.c +++ b/src/main/hook/exc/options.c @@ -4,6 +4,7 @@ #define EXCHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" #define EXCHOOK_OPTIONS_STR_GAME_VERSION "game.version" +#define EXCHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define EXCHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define EXCHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define EXCHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -40,6 +41,13 @@ static const struct util_options_def exchook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "20040408", }, + { + .name = EXCHOOK_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 = EXCHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -165,6 +173,8 @@ bool exchook_options_init( util_options_get_str(options_opt, EXCHOOK_OPTIONS_STR_GAME_SETTINGS); options->game.version = util_options_get_str(options_opt, EXCHOOK_OPTIONS_STR_GAME_VERSION); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, EXCHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, EXCHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = diff --git a/src/main/hook/exc/options.h b/src/main/hook/exc/options.h index b7de3c6..a805c78 100644 --- a/src/main/hook/exc/options.h +++ b/src/main/hook/exc/options.h @@ -13,6 +13,10 @@ struct exchook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/f2/main.c b/src/main/hook/f2/main.c index f435f00..3eb56a1 100644 --- a/src/main/hook/f2/main.c +++ b/src/main/hook/f2/main.c @@ -139,6 +139,10 @@ static void f2hook_patch_gfx_init(struct f2hook_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 f2hook_patch_main_loop_init(struct f2hook_options *options) diff --git a/src/main/hook/f2/options.c b/src/main/hook/f2/options.c index a55f545..d2a86e3 100644 --- a/src/main/hook/f2/options.c +++ b/src/main/hook/f2/options.c @@ -3,6 +3,7 @@ #include "util/options.h" #define F2HOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define F2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define F2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define F2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define F2HOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -32,6 +33,13 @@ const struct util_options_def f2hook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = F2HOOK_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 = F2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -168,6 +176,8 @@ bool f2hook_options_init(int argc, char **argv, struct f2hook_options *options) options->game.settings = util_options_get_str(options_opt, F2HOOK_OPTIONS_STR_GAME_SETTINGS); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, F2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, F2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = diff --git a/src/main/hook/f2/options.h b/src/main/hook/f2/options.h index 17c5b04..5e22c99 100644 --- a/src/main/hook/f2/options.h +++ b/src/main/hook/f2/options.h @@ -12,6 +12,10 @@ struct f2hook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/fex/main.c b/src/main/hook/fex/main.c index d99affe..b7add57 100644 --- a/src/main/hook/fex/main.c +++ b/src/main/hook/fex/main.c @@ -137,6 +137,10 @@ static void fexhook_patch_gfx_init(struct fexhook_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 fexhook_patch_main_loop_init(struct fexhook_options *options) diff --git a/src/main/hook/fex/options.c b/src/main/hook/fex/options.c index 5fcbfc3..f071447 100644 --- a/src/main/hook/fex/options.c +++ b/src/main/hook/fex/options.c @@ -3,6 +3,7 @@ #include "util/options.h" #define FEXHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define FEXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define FEXHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define FEXHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define FEXHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -32,6 +33,13 @@ const struct util_options_def fexhook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = FEXHOOK_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 = FEXHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -170,6 +178,8 @@ bool fexhook_options_init( options->game.settings = util_options_get_str(options_opt, FEXHOOK_OPTIONS_STR_GAME_SETTINGS); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, FEXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, FEXHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = diff --git a/src/main/hook/fex/options.h b/src/main/hook/fex/options.h index a21c79b..2eee416 100644 --- a/src/main/hook/fex/options.h +++ b/src/main/hook/fex/options.h @@ -12,6 +12,10 @@ struct fexhook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/fst/main.c b/src/main/hook/fst/main.c index b082ab0..e4103da 100644 --- a/src/main/hook/fst/main.c +++ b/src/main/hook/fst/main.c @@ -137,6 +137,10 @@ static void fsthook_patch_gfx_init(struct fsthook_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 fsthook_patch_main_loop_init(struct fsthook_options *options) diff --git a/src/main/hook/fst/options.c b/src/main/hook/fst/options.c index 963f3c5..5eb54a5 100644 --- a/src/main/hook/fst/options.c +++ b/src/main/hook/fst/options.c @@ -3,6 +3,7 @@ #include "util/options.h" #define FSTHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define FSTHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define FSTHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define FSTHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define FSTHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -32,6 +33,13 @@ const struct util_options_def fsthook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = FSTHOOK_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 = FSTHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -170,6 +178,8 @@ bool fsthook_options_init( options->game.settings = util_options_get_str(options_opt, FSTHOOK_OPTIONS_STR_GAME_SETTINGS); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, FSTHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, FSTHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = diff --git a/src/main/hook/fst/options.h b/src/main/hook/fst/options.h index d21d607..c114fb6 100644 --- a/src/main/hook/fst/options.h +++ b/src/main/hook/fst/options.h @@ -12,6 +12,10 @@ struct fsthook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/nx/main.c b/src/main/hook/nx/main.c index fe3d951..0bae61c 100644 --- a/src/main/hook/nx/main.c +++ b/src/main/hook/nx/main.c @@ -161,6 +161,10 @@ static void nxhook_patch_gfx_init(struct nxhook_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 nxhook_patch_game_init(struct nxhook_options *options) diff --git a/src/main/hook/nx/options.c b/src/main/hook/nx/options.c index 6d13a31..36057e8 100644 --- a/src/main/hook/nx/options.c +++ b/src/main/hook/nx/options.c @@ -4,6 +4,7 @@ #define NXHOOK_OPTIONS_STR_GAME_FORCE_UNLOCK "game.force_unlock" #define NXHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define NXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define NXHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define NXHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define NXHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -31,6 +32,13 @@ static const struct util_options_def nxhook_options_def[] = { .type = UTIL_OPTIONS_TYPE_BOOL, .default_value.b = false, }, + { + .name = NXHOOK_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 = NXHOOK_OPTIONS_STR_GAME_SETTINGS, .description = "Path to game settings (SETTINGS) folder", @@ -159,6 +167,8 @@ bool nxhook_options_init(int argc, char **argv, struct nxhook_options *options) options->game.force_unlock = util_options_get_bool(options_opt, NXHOOK_OPTIONS_STR_GAME_FORCE_UNLOCK); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, NXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->game.settings = util_options_get_str(options_opt, NXHOOK_OPTIONS_STR_GAME_SETTINGS); options->patch.hook_mon.file = util_options_get_bool( diff --git a/src/main/hook/nx/options.h b/src/main/hook/nx/options.h index 9b7db95..9bbb057 100644 --- a/src/main/hook/nx/options.h +++ b/src/main/hook/nx/options.h @@ -13,6 +13,10 @@ struct nxhook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/nxa/main.c b/src/main/hook/nxa/main.c index c60dc95..64609bc 100644 --- a/src/main/hook/nxa/main.c +++ b/src/main/hook/nxa/main.c @@ -203,6 +203,10 @@ static void nxahook_patch_gfx_init(struct nxahook_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 nxahook_patch_main_loop_init(struct nxahook_options *options) diff --git a/src/main/hook/nxa/options.c b/src/main/hook/nxa/options.c index e16952a..8513bc4 100644 --- a/src/main/hook/nxa/options.c +++ b/src/main/hook/nxa/options.c @@ -3,6 +3,7 @@ #include "util/options.h" #define NXAHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define NXAHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define NXAHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define NXAHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define NXAHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -32,6 +33,13 @@ const struct util_options_def nxahook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = NXAHOOK_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 = NXAHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", diff --git a/src/main/hook/nxa/options.h b/src/main/hook/nxa/options.h index 38a48ac..a7717e6 100644 --- a/src/main/hook/nxa/options.h +++ b/src/main/hook/nxa/options.h @@ -12,6 +12,10 @@ struct nxahook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/pri/main.c b/src/main/hook/pri/main.c index 2693daa..5a23871 100644 --- a/src/main/hook/pri/main.c +++ b/src/main/hook/pri/main.c @@ -145,6 +145,10 @@ static void prihook_patch_gfx_init(struct prihook_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 prihook_patch_main_loop_init(struct prihook_options *options) diff --git a/src/main/hook/pri/options.c b/src/main/hook/pri/options.c index efd1214..6a4d9dd 100644 --- a/src/main/hook/pri/options.c +++ b/src/main/hook/pri/options.c @@ -3,6 +3,7 @@ #include "util/options.h" #define PRIHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define PRIHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define PRIHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define PRIHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define PRIHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -30,6 +31,13 @@ const struct util_options_def prihook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = PRIHOOK_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 = PRIHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -161,6 +169,8 @@ bool prihook_options_init( options->game.settings = util_options_get_str(options_opt, PRIHOOK_OPTIONS_STR_GAME_SETTINGS); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, PRIHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, PRIHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = diff --git a/src/main/hook/pri/options.h b/src/main/hook/pri/options.h index 812f55a..96bf2b4 100644 --- a/src/main/hook/pri/options.h +++ b/src/main/hook/pri/options.h @@ -12,6 +12,10 @@ struct prihook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/x2/main.c b/src/main/hook/x2/main.c index eec4e5b..6698e72 100644 --- a/src/main/hook/x2/main.c +++ b/src/main/hook/x2/main.c @@ -141,6 +141,10 @@ static void x2hook_patch_gfx_init(struct x2hook_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 x2hook_patch_game_init(struct x2hook_options *options) diff --git a/src/main/hook/x2/options.c b/src/main/hook/x2/options.c index 75404b5..21ff273 100644 --- a/src/main/hook/x2/options.c +++ b/src/main/hook/x2/options.c @@ -4,6 +4,7 @@ #define X2HOOK_OPTIONS_STR_GAME_FORCE_UNLOCK "game.force_unlock" #define X2HOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define X2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -38,6 +39,13 @@ static const struct util_options_def x2hook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = X2HOOK_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 = X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -159,6 +167,8 @@ bool x2hook_options_init(int argc, char **argv, struct x2hook_options *options) options->game.force_unlock = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_GAME_FORCE_UNLOCK); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, X2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->game.settings = util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_GAME_SETTINGS); options->patch.hook_mon.file = util_options_get_bool( diff --git a/src/main/hook/x2/options.h b/src/main/hook/x2/options.h index cfe0a18..cdbbce5 100644 --- a/src/main/hook/x2/options.h +++ b/src/main/hook/x2/options.h @@ -13,6 +13,10 @@ struct x2hook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs; diff --git a/src/main/hook/zero/main.c b/src/main/hook/zero/main.c index 5f861ab..dbce774 100644 --- a/src/main/hook/zero/main.c +++ b/src/main/hook/zero/main.c @@ -143,6 +143,10 @@ static void zerohook_patch_gfx_init(struct zerohook_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 zerohook_patch_game_init(struct zerohook_options *options) diff --git a/src/main/hook/zero/options.c b/src/main/hook/zero/options.c index f3cc4f4..15fefaf 100644 --- a/src/main/hook/zero/options.c +++ b/src/main/hook/zero/options.c @@ -4,6 +4,7 @@ #define ZEROHOOK_OPTIONS_STR_GAME_FORCE_UNLOCK "game.force_unlock" #define ZEROHOOK_OPTIONS_STR_GAME_SETTINGS "game.settings" +#define ZEROHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE "gfx.scaling_mode" #define ZEROHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE "patch.hook_mon.file" #define ZEROHOOK_OPTIONS_STR_PATCH_HOOK_MON_FS "patch.hook_mon.fs" #define ZEROHOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io" @@ -38,6 +39,13 @@ static const struct util_options_def zerohook_options_def[] = { .type = UTIL_OPTIONS_TYPE_STR, .default_value.str = "./save", }, + { + .name = ZEROHOOK_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 = ZEROHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE, .description = "Enable file call monitoring", @@ -163,6 +171,8 @@ bool zerohook_options_init( options_opt, ZEROHOOK_OPTIONS_STR_GAME_FORCE_UNLOCK); options->game.settings = util_options_get_str(options_opt, ZEROHOOK_OPTIONS_STR_GAME_SETTINGS); + options->patch.gfx.scaling_mode = util_options_get_int( + options_opt, ZEROHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE); options->patch.hook_mon.file = util_options_get_bool( options_opt, ZEROHOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE); options->patch.hook_mon.fs = util_options_get_bool( diff --git a/src/main/hook/zero/options.h b/src/main/hook/zero/options.h index 9dbc9a0..a78488f 100644 --- a/src/main/hook/zero/options.h +++ b/src/main/hook/zero/options.h @@ -13,6 +13,10 @@ struct zerohook_options { } game; struct patch { + struct gfx { + uint8_t scaling_mode; + } gfx; + struct hook_mon { bool file; bool fs;