diff --git a/game/kernel/common/kmachine.cpp b/game/kernel/common/kmachine.cpp index 5e771e19ba4..b07bc005b1d 100644 --- a/game/kernel/common/kmachine.cpp +++ b/game/kernel/common/kmachine.cpp @@ -609,6 +609,14 @@ void pc_get_resolution(u32 id, u32 for_windowed, u32 w_ptr, u32 h_ptr) { } } +u32 pc_get_current_height_resolution() { + return Gfx::g_global_settings.game_res_h; +} + +u32 pc_get_current_width_resolution() { + return Gfx::g_global_settings.game_res_w; +} + u64 pc_is_supported_resolution(u64 width, u64 height) { if (Display::GetMainDisplay()) { return bool_to_symbol( @@ -955,6 +963,8 @@ void init_common_pc_port_functions( make_func_symbol_func("pc-set-window-size!", (void*)pc_set_window_size); make_func_symbol_func("pc-get-num-resolutions", (void*)pc_get_num_resolutions); make_func_symbol_func("pc-get-resolution", (void*)pc_get_resolution); + make_func_symbol_func("pc-get-resolution-h", (void*)pc_get_current_height_resolution); + make_func_symbol_func("pc-get-resolution-w", (void*)pc_get_current_width_resolution); make_func_symbol_func("pc-is-supported-resolution?", (void*)pc_is_supported_resolution); // -- INPUT RELATED -- diff --git a/goal_src/jak1/kernel-defs.gc b/goal_src/jak1/kernel-defs.gc index ec4aa4a4819..9ee71c600fb 100644 --- a/goal_src/jak1/kernel-defs.gc +++ b/goal_src/jak1/kernel-defs.gc @@ -511,6 +511,10 @@ (define-extern pc-get-resolution (function int symbol (pointer int64) (pointer int64) none)) +(define-extern pc-get-resolution-h (function int)) + +(define-extern pc-get-resolution-w (function int)) + (define-extern pc-is-supported-resolution? (function int int symbol)) (define-extern pc-set-frame-rate (function int none)) diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index 1ed36ec0750..cf8366efb4f 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -1163,15 +1163,37 @@ (1+! (-> *temp-options* length)))) (defmacro add-resolution-option (x y) - "add a resolution button to *temp-options* with specified size" - `(let ((option (-> *temp-options* (length *temp-options*)))) - (set! (-> option option-type) (game-option-type resolution)) - (set! (-> option option-disabled-func) #f) - (set! (-> option name) (text-id resolution-fmt)) - (set! (-> option param1) (the float ,x)) - (set! (-> option param2) (the float ,y)) - (set! (-> option scale) #t) - (1+! (-> *temp-options* length)))) + "Add a resolution button to *temp-options* with specified size. + Reserve the first index for the current resolution if it matches." + `(let ((current-width (pc-get-resolution-w)) + (current-height (pc-get-resolution-h))) + ;; First we check to see if we have a match, and if so insert it into index 0 + (if (and (= current-width ,x) (= current-height ,y)) + (let ((current-option (-> *temp-options* 0))) + (set! (-> current-option option-type) (game-option-type resolution)) + (set! (-> current-option option-disabled-func) #f) + (set! (-> current-option name) (text-id resolution-fmt)) + (set! (-> current-option param1) (the float ,x)) + (set! (-> current-option param2) (the float ,y)) + (set! (-> current-option scale) #t)) + ;;Here we are checking to see if we are at the start of *temp-options* and if so we skip index 0, as we are saving that for the resolution match + (if (= (length *temp-options*) 0) + (let ((option (-> *temp-options* 1))) + (set! (-> option option-type) (game-option-type resolution)) + (set! (-> option option-disabled-func) #f) + (set! (-> option name) (text-id resolution-fmt)) + (set! (-> option param1) (the float ,x)) + (set! (-> option param2) (the float ,y)) + (set! (-> option scale) #t) + (set! (-> *temp-options* length) (+ (-> *temp-options* length) 2))) + (let ((option (-> *temp-options* (length *temp-options*)))) + (set! (-> option option-type) (game-option-type resolution)) + (set! (-> option option-disabled-func) #f) + (set! (-> option name) (text-id resolution-fmt)) + (set! (-> option param1) (the float ,x)) + (set! (-> option param2) (the float ,y)) + (set! (-> option scale) #t) + (1+! (-> *temp-options* length))))))) (defun build-resolution-options () (set! (-> *temp-options* length) 0)