From d149838485145f79ee915324b18e8f293282ef4d Mon Sep 17 00:00:00 2001 From: Matt Dallmeyer Date: Sat, 30 Sep 2023 16:17:50 -0700 Subject: [PATCH] fix draw-string-xy-scaled cropping (#3041) fixes #3038 https://github.com/open-goal/jak-project/assets/2515356/5b7a490f-e1fb-4a12-a3d9-b576a2c1d574 --- goal_src/jak1/engine/gfx/font.gc | 53 +++++++++++++++----------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/goal_src/jak1/engine/gfx/font.gc b/goal_src/jak1/engine/gfx/font.gc index 7b0654f932..9b19149c86 100644 --- a/goal_src/jak1/engine/gfx/font.gc +++ b/goal_src/jak1/engine/gfx/font.gc @@ -1784,36 +1784,31 @@ ;; Added for PC port (defun draw-string-xy-scaled ((str string) (buf dma-buffer) (x int) (y int) (color font-color) (flags font-flags) (scale float)) "Draw a string at the given xy location, with the given scale." - (let ((font-ctxt (new 'stack 'font-context *font-default-matrix* x y 0.0 color flags))) - (let ((scaled-width (* (-> font-ctxt width) scale)) - (scaled-height (* (-> font-ctxt height) scale)) - (orig-mat-x-scale (-> font-ctxt mat vector 0 x)) - (orig-mat-y-scale (-> font-ctxt mat vector 1 y)) - (orig-vid-parms-x-scale (-> *video-parms* relative-x-scale)) - (orig-vid-parms-y-scale (-> *video-parms* relative-y-scale)) - ) - (*! (-> font-ctxt scale) scale) - (set! (-> font-ctxt width) scaled-width) - (set! (-> font-ctxt height) scaled-height) - - ;; scaling globals *font-default-matrix*, *video-parms* (based on print-game-text scaling) - (*! (-> *font-default-matrix* vector 0 x) scale) - (*! (-> *font-default-matrix* vector 1 y) scale) - (*! (-> *video-parms* relative-x-scale) scale) - (*! (-> *video-parms* relative-y-scale) scale) - (set! (-> *video-parms* relative-x-scale-reciprical) (/ 1.0 (-> *video-parms* relative-x-scale))) - (set! (-> *video-parms* relative-y-scale-reciprical) (/ 1.0 scale)) + (let* ((font-ctxt (new 'stack 'font-context *font-default-matrix* x y 0.0 color flags)) + (scaled-width (* (-> font-ctxt width) scale)) + (scaled-height (* (-> font-ctxt height) scale)) + (orig-mat-x-scale (-> font-ctxt mat vector 0 x)) + (orig-mat-y-scale (-> font-ctxt mat vector 1 y)) + (orig-vid-parms-x-scale (-> *video-parms* relative-x-scale)) + (orig-vid-parms-y-scale (-> *video-parms* relative-y-scale)) + ) + ;; scaling globals *font-default-matrix*, *video-parms* (based on print-game-text scaling) + (*! (-> *font-default-matrix* vector 0 x) scale) + (*! (-> *font-default-matrix* vector 1 y) scale) + (*! (-> *video-parms* relative-x-scale) scale) + (*! (-> *video-parms* relative-y-scale) scale) + (set! (-> *video-parms* relative-x-scale-reciprical) (/ 1.0 (-> *video-parms* relative-x-scale))) + (set! (-> *video-parms* relative-y-scale-reciprical) (/ 1.0 (-> *video-parms* relative-y-scale))) - (draw-string str buf font-ctxt) - - ;; un-scaling globals *font-default-matrix*, *video-params* - (set! (-> *font-default-matrix* vector 0 x) orig-mat-x-scale) - (set! (-> *font-default-matrix* vector 1 y) orig-mat-y-scale) - (set! (-> *video-parms* relative-x-scale) orig-vid-parms-x-scale) - (set! (-> *video-parms* relative-y-scale) orig-vid-parms-y-scale) - (set! (-> *video-parms* relative-x-scale-reciprical) (/ 1.0 (-> *video-parms* relative-x-scale))) - (set! (-> *video-parms* relative-y-scale-reciprical) (/ 1.0 (-> *video-parms* relative-y-scale))) - ) + (draw-string str buf font-ctxt) + + ;; un-scaling globals *font-default-matrix*, *video-params* + (set! (-> *font-default-matrix* vector 0 x) orig-mat-x-scale) + (set! (-> *font-default-matrix* vector 1 y) orig-mat-y-scale) + (set! (-> *video-parms* relative-x-scale) orig-vid-parms-x-scale) + (set! (-> *video-parms* relative-y-scale) orig-vid-parms-y-scale) + (set! (-> *video-parms* relative-x-scale-reciprical) (/ 1.0 (-> *video-parms* relative-x-scale))) + (set! (-> *video-parms* relative-y-scale-reciprical) (/ 1.0 (-> *video-parms* relative-y-scale))) ) (none) )