Skip to content

Commit

Permalink
fix draw-string-xy-scaled cropping (#3041)
Browse files Browse the repository at this point in the history
  • Loading branch information
dallmeyer authored Sep 30, 2023
1 parent e130244 commit d149838
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions goal_src/jak1/engine/gfx/font.gc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

0 comments on commit d149838

Please sign in to comment.