Files
jak-project/goal_src/jak2/engine/gfx/font.gc
T
ManDude e130244271 [jak2] scalable debug font + fix debug menu widescreen bugs (#3044)
also hides empty (no commands) regions from the viewers by default now.
2023-09-30 21:19:47 +01:00

216 lines
7.3 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: font.gc
;; name in dgo: font
;; dgos: ENGINE, GAME
(def-mips2c draw-string-asm (function string dma-buffer font-context draw-string-result))
; (def-mips2c get-string-length (function string font-context draw-string-result))
(def-mips2c get-string-length-asm (function string font-context draw-string-result))
;; DECOMP BEGINS
;; WARN: Return type mismatch object vs none.
(defun gen-font-12 ((arg0 string))
(format #t "(define ~s~%" arg0)
(format #t " (new 'static 'inline-array 'vector 0~%")
(dotimes (gp-0 250)
(let ((f0-1 (+ 0.0009765625 (* 0.03125 (the float (/ (mod gp-0 250) 10)))))
(f1-3 (+ 0.00390625 (* 0.09375 (the float (mod gp-0 10)))))
(v1-10 (if (< gp-0 250)
gp-0
(+ gp-0 6)
)
)
)
(cond
((zero? v1-10)
(format
#t
"~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x 'upside down ~c'~%"
f1-3
f0-1
(+ v1-10 6)
94
)
)
((= v1-10 1)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '`'~%" f1-3 f0-1 (+ v1-10 6))
)
((= v1-10 2)
(let ((t9-4 format)
(a0-8 #t)
(a1-4 "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x ''~%")
(a2-3 f1-3)
(a3-2 f0-1)
(t0-2 (+ v1-10 6))
)
180
(t9-4 a0-8 a1-4 a2-3 a3-2 t0-2)
)
)
((= v1-10 3)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 94)
)
((= v1-10 4)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 126)
)
((= v1-10 5)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 168)
)
((= v1-10 6)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 176)
)
((= v1-10 7)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 161)
)
((= v1-10 8)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 191)
)
((= v1-10 9)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 186)
)
((= v1-10 10)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 174)
)
((= v1-10 11)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 198)
)
((= v1-10 12)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 230)
)
((= v1-10 13)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 199)
)
((= v1-10 14)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 231)
)
((= v1-10 15)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%" f1-3 f0-1 (+ v1-10 6) 223)
)
((and (< 15 v1-10) (< v1-10 78))
(format
#t
"~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%"
f1-3
f0-1
(+ v1-10 6)
(+ v1-10 16)
)
)
((= v1-10 78)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x 'oe'~%" f1-3 f0-1 (+ v1-10 6))
)
((and (< 78 v1-10) (< v1-10 108))
(format
#t
"~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%"
f1-3
f0-1
(+ v1-10 6)
(+ v1-10 16)
)
)
((= v1-10 108)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x 'OE'~%" f1-3 f0-1 (+ v1-10 6))
)
((and (< 108 v1-10) (< v1-10 111))
(format
#t
"~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x '~c'~%"
f1-3
f0-1
(+ v1-10 6)
(+ v1-10 16)
)
)
((= v1-10 111)
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x 'TM'~%" f1-3 f0-1 (+ v1-10 6))
)
(else
(format #t "~t (new 'static 'vector :x ~f :y ~f :z 1.0 :w 16.0) ; $~2x~%" f1-3 f0-1 (+ v1-10 6))
)
)
)
(when (= (mod gp-0 10) 9)
(if (!= gp-0 419)
(format #t "~%")
)
)
)
(format #t "~t)~%")
(format #t " )~%")
(none)
)
;; ERROR: function was not converted to expressions. Cannot decompile.
(defun draw-string ((arg0 string) (arg1 dma-buffer) (arg2 font-context))
;; og:preserve-this modified a bit for debug font scaling.
(let ((result (the draw-string-result #f))
(orig-scale (-> arg2 scale)))
(#when PC_PORT
;; debug font scaling.
(unless (logtest? (-> arg2 flags) (font-flags large pc-hack))
(*! (-> arg2 scale) (get-debug-font-scale-factor))))
(let ((v1-1 (the int (* 128.0 (-> arg2 alpha)))))
(-> arg2 origin quad)
(dotimes (a0-2 40)
(dotimes (a1-1 4)
(set! (-> *font-work* color-table a0-2 color a1-1 a) v1-1)
)
)
(set! (-> *font-work* color-shadow w) v1-1)
)
(if (< (the-as uint (dma-buffer-free arg1)) (the-as uint (* (length arg0) 32)))
(set! result (the-as draw-string-result (-> arg2 origin quad)))
(set! result (draw-string-asm arg0 arg1 arg2))
)
(dotimes (v1-7 40)
(dotimes (a0-9 4)
(set! (-> *font-work* color-table v1-7 color a0-9 a) #x80)
)
)
(set! (-> *font-work* color-shadow w) 128)
(set! (-> arg2 scale) orig-scale)
result
))
(#when PC_PORT
;; og:preserve-this get-string-length is an asm function, but for PC port we use a trampoline in order to inject hacks more easily
(defun get-string-length ((text string) (ctx font-context))
"return the length of a string, in gs framebuffer units"
(let ((orig-scale (-> ctx scale))
(result (begin (#when PC_PORT ;; debug font scaling.
(unless (logtest? (-> ctx flags) (font-flags large pc-hack))
(*! (-> ctx scale) (get-debug-font-scale-factor))))
(get-string-length-asm text ctx))))
(set! (-> ctx scale) orig-scale)
result)
)
)
;; ERROR: function was not converted to expressions. Cannot decompile.
(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 font-color) (arg5 font-flags))
(let ((a2-2 (new 'stack 'font-context *font-default-matrix* arg2 arg3 0.0 arg4 arg5)))
(draw-string arg0 arg1 a2-2)
)
)
;; WARN: Return type mismatch float vs none.
(defun draw-string-adv ((arg0 string) (arg1 dma-buffer) (arg2 font-context))
(let ((v1-0 (draw-string arg0 arg1 arg2)))
(+! (-> arg2 origin x) (-> v1-0 length))
)
(none)
)