;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/gfx/font-h.gc")
(require "engine/ps2/vu1-macros.gc")

;; Font asm macros:
;;  these could likely be reimplemented within the OpenGOAL compiler and be faster.

(defmacro .sll (result in sa)
  `(set! ,result (sext32 (the-as int (shl (logand ,in #xffffffff) ,sa)))))

(defmacro .movz (result value check original)
  `(if (= ,check 0) (set! ,result (the-as int ,value)) (set! ,result (the-as int ,original))))

(defmacro .movz-128 (result value check original)
  "movz, but keeps the upper 64 bits of a 128-bit register the same.
   This is undocumented, but the game depends on it."
  `(let ((temp (new 'stack 'array 'uint64 2)))
    (set! (-> (the (pointer uint128) temp)) ,original)
    (if (= ,check 0) (set! (-> temp 0) ,value))
    (set! ,result (-> (the (pointer uint128) temp)))))

(defmacro .movn (result value check original)
  `(if (!= ,check 0) (set! ,result (the-as int ,value)) (set! ,result (the-as int ,original))))

(defmacro .movn-128 (result value check original)
  `(let ((temp (new 'stack-no-clear 'array 'uint64 2)))
    (set! (-> (the (pointer uint128) temp)) ,original)
    (if (!= ,check 0) (set! (-> temp 0) (the uint ,value)))
    (set! ,result (-> (the (pointer uint128) temp)))))

(defmacro .addu (result a b)
  `(set! ,result (sext32 (logand (+ (the-as int ,a) (the-as int ,b)) #xffffffff))))

(defmacro .sra (result in sa)
  `(set! ,result (sext32 (sar (logand #xffffffff (the-as int ,in)) ,sa))))

;; font vertex table.
(define *font12-table*
  (new 'static
       'inline-array
       vector
       250
       (new 'static 'vector :x 0.0039 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.7539 :y 0.0019 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.8476 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.0644 :z 1.0 :w 22.5)
       (new 'static 'vector :x 0.1914 :y 0.0644 :z 1.0 :w 19.5)
       (new 'static 'vector :x 0.2851 :y 0.0644 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.3789 :y 0.0644 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.4726 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.0644 :z 1.0 :w 10.5)
       (new 'static 'vector :x 0.6601 :y 0.0644 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.7539 :y 0.0644 :z 1.0 :w 10.5)
       (new 'static 'vector :x 0.8476 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.1269 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.0976 :y 0.1269 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.1914 :y 0.1269 :z 1.0 :w 10.5)
       (new 'static 'vector :x 0.2851 :y 0.1269 :z 1.0 :w 7.5)
       (new 'static 'vector :x 0.3789 :y 0.1269 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.4726 :y 0.1269 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.5664 :y 0.1269 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.6601 :y 0.1269 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.7539 :y 0.1269 :z 1.0 :w 7.5)
       (new 'static 'vector :x 0.8476 :y 0.1269 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.0039 :y 0.1894 :z 1.0 :w 7.5)
       (new 'static 'vector :x 0.0976 :y 0.1894 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.1914 :y 0.1894 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.2851 :y 0.1894 :z 1.0 :w 11.25)
       (new 'static 'vector :x 0.3789 :y 0.1894 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.4726 :y 0.1894 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.5664 :y 0.1894 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.6601 :y 0.1894 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.7539 :y 0.1894 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.8476 :y 0.1894 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.0039 :y 0.2519 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.0976 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.2519 :z 1.0 :w 7.5)
       (new 'static 'vector :x 0.2851 :y 0.2519 :z 1.0 :w 7.5)
       (new 'static 'vector :x 0.3789 :y 0.2519 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.4726 :y 0.2519 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.5664 :y 0.2519 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.6601 :y 0.2519 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.7539 :y 0.2519 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.8476 :y 0.2519 :z 1.0 :w 17.25)
       (new 'static 'vector :x 0.0039 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.3144 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.1914 :y 0.3144 :z 1.0 :w 15.75)
       (new 'static 'vector :x 0.2851 :y 0.3144 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.3789 :y 0.3144 :z 1.0 :w 14.25)
       (new 'static 'vector :x 0.4726 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.3144 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.6601 :y 0.3144 :z 1.0 :w 7.5)
       (new 'static 'vector :x 0.7539 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.3769 :z 1.0 :w 15.75)
       (new 'static 'vector :x 0.0976 :y 0.3769 :z 1.0 :w 19.5)
       (new 'static 'vector :x 0.1914 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.3769 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.4726 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.3769 :z 1.0 :w 15.75)
       (new 'static 'vector :x 0.6601 :y 0.3769 :z 1.0 :w 12.75)
       (new 'static 'vector :x 0.7539 :y 0.3769 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.8476 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.4394 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.1914 :y 0.4394 :z 1.0 :w 17.25)
       (new 'static 'vector :x 0.2851 :y 0.4394 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.3789 :y 0.4394 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.4726 :y 0.4394 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.5664 :y 0.4394 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.6601 :y 0.4394 :z 1.0 :w 10.5)
       (new 'static 'vector :x 0.7539 :y 0.4394 :z 1.0 :w 19.5)
       (new 'static 'vector :x 0.8476 :y 0.4394 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.0039 :y 0.5019 :z 1.0 :w 6.0)
       (new 'static 'vector :x 0.0976 :y 0.5019 :z 1.0 :w 14.25)
       (new 'static 'vector :x 0.1914 :y 0.5019 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.2851 :y 0.5019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.3789 :y 0.5019 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.4726 :y 0.5019 :z 1.0 :w 12.75)
       (new 'static 'vector :x 0.5664 :y 0.5019 :z 1.0 :w 12.75)
       (new 'static 'vector :x 0.6601 :y 0.5019 :z 1.0 :w 17.25)
       (new 'static 'vector :x 0.7539 :y 0.5019 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.8476 :y 0.5019 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.0039 :y 0.5644 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.0976 :y 0.5644 :z 1.0 :w 14.25)
       (new 'static 'vector :x 0.1914 :y 0.5644 :z 1.0 :w 9.75)
       (new 'static 'vector :x 0.2851 :y 0.5644 :z 1.0 :w 18.5)
       (new 'static 'vector :x 0.3789 :y 0.5644 :z 1.0 :w 14.25)
       (new 'static 'vector :x 0.4726 :y 0.5644 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.5664 :y 0.5644 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.6601 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.5644 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.8476 :y 0.5644 :z 1.0 :w 10.5)
       (new 'static 'vector :x 0.0039 :y 0.6269 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.0976 :y 0.6269 :z 1.0 :w 12.75)
       (new 'static 'vector :x 0.1914 :y 0.6269 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.2851 :y 0.6269 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.3789 :y 0.6269 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.4726 :y 0.6269 :z 1.0 :w 16.5)
       (new 'static 'vector :x 0.5664 :y 0.6269 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.6601 :y 0.6269 :z 1.0 :w 10.5)
       (new 'static 'vector :x 0.7539 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.6269 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.0039 :y 0.6894 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.0976 :y 0.6894 :z 1.0 :w 13.5)
       (new 'static 'vector :x 0.0039 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.7519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.2851 :y 0.7519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.3789 :y 0.7519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.4726 :y 0.7519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.5664 :y 0.7519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.6601 :y 0.7519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.0039 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.1269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.2519 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.3144 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.3769 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.4394 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.5019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.5644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.2851 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.4726 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.7539 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.8476 :y 0.6269 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.6894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0976 :y 0.6894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.0039 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.7519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.8769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.8769 :z 1.0 :w 24.0)))

(define *font24-table*
  (new 'static
       'inline-array
       vector
       289
       (new 'static 'vector :x 0.0039 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.0976 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.1914 :y 0.0019 :z 1.0 :w 19.5)
       (new 'static 'vector :x 0.2851 :y 0.0019 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.3789 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.4726 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.5664 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.6601 :y 0.0019 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.7539 :y 0.0019 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.8476 :y 0.0019 :z 1.0 :w 12.0)
       (new 'static 'vector :x 0.0039 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.0644 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.3789 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.0644 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.5664 :y 0.0644 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.6601 :y 0.0644 :z 1.0 :w 8.0)
       (new 'static 'vector :x 0.7539 :y 0.0644 :z 1.0 :w 10.0)
       (new 'static 'vector :x 0.8476 :y 0.0644 :z 1.0 :w 22.5)
       (new 'static 'vector :x 0.0039 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.1269 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.1914 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.1269 :z 1.0 :w 10.0)
       (new 'static 'vector :x 0.4726 :y 0.1269 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.5664 :y 0.1269 :z 1.0 :w 22.5)
       (new 'static 'vector :x 0.6601 :y 0.1269 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.7539 :y 0.1269 :z 1.0 :w 7.0)
       (new 'static 'vector :x 0.8476 :y 0.1269 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.0039 :y 0.1894 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.0976 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.1914 :y 0.1894 :z 1.0 :w 22.0)
       (new 'static 'vector :x 0.2851 :y 0.1894 :z 1.0 :w 10.0)
       (new 'static 'vector :x 0.3789 :y 0.1894 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.4726 :y 0.1894 :z 1.0 :w 15.0)
       (new 'static 'vector :x 0.5664 :y 0.1894 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.6601 :y 0.1894 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.7539 :y 0.1894 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.8476 :y 0.1894 :z 1.0 :w 17.0)
       (new 'static 'vector :x 0.0039 :y 0.2519 :z 1.0 :w 17.0)
       (new 'static 'vector :x 0.0976 :y 0.2519 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.1914 :y 0.2519 :z 1.0 :w 8.0)
       (new 'static 'vector :x 0.2851 :y 0.2519 :z 1.0 :w 22.5)
       (new 'static 'vector :x 0.3789 :y 0.2519 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.4726 :y 0.2519 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.5664 :y 0.2519 :z 1.0 :w 9.0)
       (new 'static 'vector :x 0.6601 :y 0.2519 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.7539 :y 0.2519 :z 1.0 :w 22.5)
       (new 'static 'vector :x 0.8476 :y 0.2519 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.0039 :y 0.3144 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.0976 :y 0.3144 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.1914 :y 0.3144 :z 1.0 :w 21.0)
       (new 'static 'vector :x 0.2851 :y 0.3144 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.3789 :y 0.3144 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.4726 :y 0.3144 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.5664 :y 0.3144 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.6601 :y 0.3144 :z 1.0 :w 11.0)
       (new 'static 'vector :x 0.7539 :y 0.3144 :z 1.0 :w 16.0)
       (new 'static 'vector :x 0.8476 :y 0.3144 :z 1.0 :w 21.0)
       (new 'static 'vector :x 0.0039 :y 0.3769 :z 1.0 :w 17.0)
       (new 'static 'vector :x 0.0976 :y 0.3769 :z 1.0 :w 23.0)
       (new 'static 'vector :x 0.1914 :y 0.3769 :z 1.0 :w 18.0)
       (new 'static 'vector :x 0.2851 :y 0.3769 :z 1.0 :w 21.0)
       (new 'static 'vector :x 0.3789 :y 0.3769 :z 1.0 :w 19.0)
       (new 'static 'vector :x 0.4726 :y 0.3769 :z 1.0 :w 22.0)
       (new 'static 'vector :x 0.5664 :y 0.3769 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.6601 :y 0.3769 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.7539 :y 0.3769 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.8476 :y 0.3769 :z 1.0 :w 22.0)
       (new 'static 'vector :x 0.0039 :y 0.4394 :z 1.0 :w 23.0)
       (new 'static 'vector :x 0.0976 :y 0.4394 :z 1.0 :w 23.0)
       (new 'static 'vector :x 0.1914 :y 0.4394 :z 1.0 :w 23.0)
       (new 'static 'vector :x 0.2851 :y 0.4394 :z 1.0 :w 23.0)
       (new 'static 'vector :x 0.3789 :y 0.4394 :z 1.0 :w 20.0)
       (new 'static 'vector :x 0.4726 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.0019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.0644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.1269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.1894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.2519 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.3144 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.3769 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.4394 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.5019 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.5644 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.6269 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7505 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.6894 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0039 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.0976 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.1914 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.2851 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.3789 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.4726 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.5664 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.6601 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.7539 :y 0.7512 :z 1.0 :w 24.0)
       (new 'static 'vector :x 0.8476 :y 0.7512 :z 1.0 :w 5.0)))

;; we have both GOAL and mips2c versions of this function

(define draw-string (the (function string dma-buffer font-context float) (__pc-get-mips2c "draw-string")))

;; for now, use the GOAL one. the mips2c one is super slow with the game compiled in debug mode.
(defun draw-string ((str-in string) (context dma-buffer) (arg2 font-context))
  "Draw a string. Writes dma to the given buffer."
  (local-vars
    (r0 uint128)
    (v0-0 float)
    (a0-2 int)
    (font-table-12 (inline-array vector))
    (a3-6 (inline-array vector))
    (a3-8 (inline-array vector))
    (t0-1 int)
    (q-hi-tmpl uint128)
    (color-array-prod int)
    (q-verts-2t uint128)
    (q-verts-2 uint128)
    (q-verts-3t uint128)
    (q-verts-3 uint128)
    (t4-6 int)
    (fc-cr uint)
    (t4-16 int)
    (t4-17 int)
    (t4-18 int)
    (t4-19 int)
    (t4-23 int)
    (t4-32 int)
    (t4-33 int)
    (t4-36 uint128)
    (t4-37 uint128)
    (q-verts-1t uint128)
    (q-verts-1 uint128)
    (not-sc-lit1 uint)
    (not-sc-~ uint)
    (t5-6 int)
    (t5-7 int)
    (t5-9 int)
    (t5-10 uint)
    (t5-11 uint)
    (t5-13 int)
    (t5-14 int)
    (t5-17 int)
    (t5-18 int)
    (t5-19 int)
    (t5-20 int)
    (t5-23 uint128)
    (t5-24 uint)
    (t5-25 uint)
    (t5-27 int)
    (t5-28 int)
    (t5-32 uint128)
    (t5-33 uint128)
    (t5-35 uint128)
    (t5-36 uint128)
    (t5-39 int)
    (t5-40 int)
    (t5-41 int)
    (t5-42 int)
    (t5-45 uint128)
    (q-verts-0t uint128)
    (q-verts-0 uint128)
    (t6-3 uint)
    (t6-4 uint)
    (t6-5 uint)
    (t6-6 uint)
    (t6-7 uint)
    (t6-10 uint)
    (t6-11 uint)
    (t6-12 uint)
    (t6-13 uint)
    (t6-14 uint)
    (t6-16 uint)
    (t6-20 uint)
    (t6-21 uint)
    (t6-22 uint)
    (t6-23 uint)
    (t6-24 uint)
    (t6-28 uint128)
    (t6-29 uint128)
    (t6-31 uint)
    (t7-0 uint)
    (t7-2 uint)
    (t7-3 uint)
    (t7-4 uint)
    (t7-5 uint)
    (t7-6 uint)
    (t7-7 uint)
    (t7-8 uint)
    (t7-9 uint)
    (t7-10 uint)
    (t7-11 uint)
    (t7-12 uint)
    (t7-13 uint)
    (t7-14 uint)
    (t7-15 uint)
    (t7-16 uint)
    (t7-17 uint)
    (t7-18 uint)
    (t7-20 uint)
    (t7-21 uint)
    (t7-22 uint)
    (t7-23 uint)
    (t7-24 uint)
    (t7-25 uint)
    (t7-26 uint)
    (t7-27 uint)
    (t7-28 uint)
    (t7-29 uint)
    (t7-30 uint)
    (t7-31 uint)
    (t7-32 uint)
    (t7-33 uint)
    (t7-34 uint)
    (t7-35 uint)
    (t7-36 uint)
    (t7-38 uint)
    (t7-39 uint)
    (t7-40 uint)
    (t7-41 uint)
    (t7-42 uint)
    (t7-43 uint)
    (t7-44 uint)
    (t7-45 uint)
    (t7-46 uint)
    (t7-47 uint)
    (t7-48 uint)
    (t7-49 uint)
    (t7-50 uint)
    (t7-51 uint)
    (t7-52 uint)
    (t7-53 uint)
    (t8-0 uint)
    (t8-1 int)
    (t8-2 uint)
    (t8-3 int)
    (t8-4 uint)
    (t8-5 int))
  (set! r0 (the-as uint128 0))
  (rlet ((acc :class vf)
         (Q :class vf)
         (vf0 :class vf)
         (vf1 :class vf)
         (vf10 :class vf)
         (vf11 :class vf)
         (vf12 :class vf)
         (vf13 :class vf)
         (vf14 :class vf)
         (vf15 :class vf)
         (vf16 :class vf)
         (vf17 :class vf)
         (vf18 :class vf)
         (vf19 :class vf)
         (vf2 :class vf)
         (vf23 :class vf)
         (vf24 :class vf)
         (vf25 :class vf)
         (vf26 :class vf)
         (vf27 :class vf)
         (vf28 :class vf)
         (vf29 :class vf)
         (vf3 :class vf)
         (vf30 :class vf)
         (vf31 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         (vf6 :class vf)
         (vf7 :class vf)
         (vf8 :class vf)
         (vf9 :class vf))
    (init-vf0-vector)
    (let ((v1-0 *math-camera*)) (.lvf vf26 (&-> v1-0 hvdf-off quad)) (.lvf vf27 (&-> v1-0 hvdf-off quad)))
    ;; og:preserve-this PC port modification: adjust shadow x to account for widescreen
    (let ((shadow-x 2.)
          (shadow-y 1.)
          (correction (-> *video-parms* relative-x-scale))
          (temp-vec (new-stack-vector0)))
      (set! (-> temp-vec quad) (-> *math-camera* hvdf-off quad))
      (+! (-> temp-vec x) (* correction shadow-x))
      (+! (-> temp-vec y) shadow-y)
      (.lvf vf26 (&-> temp-vec quad)))
    ;; original version
    ; (.add.w.vf.xy vf26 vf26 vf0)
    ; (.add.w.vf.x vf26 vf26 vf0)
    (let ((v1-1 (-> arg2 mat)))
      (.lvf vf25 (&-> arg2 context-vec quad))
      (.lvf vf23 (&-> arg2 origin quad))
      (.lvf vf24 (&-> arg2 origin quad))
      (.lvf vf28 (&-> v1-1 vector 0 quad))
      (.lvf vf29 (&-> v1-1 vector 1 quad))
      (.lvf vf30 (&-> v1-1 vector 2 quad))
      (.lvf vf31 (&-> v1-1 vector 3 quad)))
    (let ((v1-3 *video-parms*)) (.lvf vf1 (+ (the-as int v1-3) 64)))
    (.mul.vf.xy vf25 vf25 vf1)
    (.mul.vf.xy vf23 vf23 vf1)
    ;; hack! fixes small font widescreen
    (unless (logtest? (-> arg2 flags) (font-flags pc-hack))
      (.mul.vf.xy vf24 vf24 vf1))
    (let ((fw *font-work*))
      (set! (-> fw buf) context)
      (let ((dma-out (-> context base)))
        (set! (-> fw str-ptr) (the-as uint str-in))
        (let ((flags (-> arg2 flags-signed)))
          (.mov.vf vf1 vf0)
          (.mov.vf vf2 vf0)
          (.mov.vf vf3 vf0)
          (.mov.vf vf4 vf0)
          (set! (-> fw flags) (the-as font-flags flags))
          (.lvf vf16 (&-> fw size-st1 quad))
          (.lvf vf17 (&-> fw size-st2 quad))
          (.lvf vf18 (&-> fw size-st3 quad))
          (let ((has-flag-size24 (logand flags 32)))
            (b! (nonzero? has-flag-size24) cfg-2 :delay (set! font-table-12 *font12-table*)))
          (let ((font-table-to-use font-table-12))
            (.lvf vf13 (&-> fw size1-small quad))
            (.lvf vf14 (&-> fw size2-small quad))
            (.lvf vf15 (&-> fw size3-small quad))
            (let ((q-lo-tmpl (-> fw small-font-lo-tmpl-qw)))
              (b! #t cfg-3 :delay (set! q-hi-tmpl (-> fw small-font-hi-tmpl-qw)))
              (label cfg-2)
              (set! font-table-to-use *font24-table*)
              (.lvf vf13 (&-> fw size1-large quad))
              (.lvf vf14 (&-> fw size2-large quad))
              (.lvf vf15 (&-> fw size3-large quad))
              (set! q-lo-tmpl (-> fw large-font-lo-tmpl-qw))
              (set! q-hi-tmpl (-> fw large-font-hi-tmpl-qw))
              (label cfg-3)
              (let ((in-color (-> arg2 color-s32))) (set! (-> fw last-color-32) in-color) (.sll color-array-prod in-color 4))
              (let ((fw+col (the-as object (+ color-array-prod (the-as int fw)))))
                (let ((q-verts-0p (the-as uint128 (-> (the-as (pointer uint32) fw+col) 496))))
                  (let ((q-verts-1p (the-as uint128 (-> (the-as (pointer uint32) fw+col) 497))))
                    (.pextlb q-verts-0t r0 q-verts-0p)
                    (let ((q-verts-2p (the-as uint128 (-> (the-as (pointer uint32) fw+col) 498))))
                      (.pextlh q-verts-0 r0 q-verts-0t)
                      (let ((q-verts-3p (the-as uint128 (-> (the-as (pointer uint32) fw+col) 499))))
                        (.pextlb q-verts-1t r0 q-verts-1p)
                        (set! (-> fw current-verts color 0 quad) (the-as uint128 q-verts-0))
                        (.pextlh q-verts-1 r0 q-verts-1t)
                        (set! (-> fw dest-verts color 0 quad) (the-as uint128 q-verts-0))
                        (.pextlb q-verts-2t r0 q-verts-2p)
                        (set! (-> fw current-verts color 1 quad) (the-as uint128 q-verts-1))
                        (.pextlh q-verts-2 r0 q-verts-2t)
                        (set! (-> fw dest-verts color 1 quad) (the-as uint128 q-verts-1))
                        (.pextlb q-verts-3t r0 q-verts-3p))))))
              (set! (-> fw current-verts color 2 quad) (the-as uint128 q-verts-2))
              (.pextlh q-verts-3 r0 q-verts-3t)
              (set! (-> fw dest-verts color 2 quad) (the-as uint128 q-verts-2))
              (set! (-> fw current-verts color 3 quad) (the-as uint128 q-verts-3))
              (set! (-> fw dest-verts color 3 quad) (the-as uint128 q-verts-3))
              (let ((fw2 (the-as object fw)))
                (label cfg-4)
                (let ((str-char (-> (the-as (pointer uint8) str-in) 4)))
                  (set! str-in (the-as string (&-> (the-as (pointer uint8) str-in) 1)))
                  (b! (zero? str-char) cfg-67 :delay (set! not-sc-lit1 (+ str-char -1)))
                  (b! (zero? not-sc-lit1) cfg-54 :delay (set! not-sc-~ (+ str-char -126)))
                  (b! (nonzero? not-sc-~) cfg-55)
                  (set! str-char (-> (the-as (pointer uint8) str-in) 4))
                  (set! str-in (the-as string (&-> (the-as (pointer uint8) str-in) 1)))
                  (let ((t5-5 0)
                        (t6-2 0))
                    (b! (zero? str-char) cfg-67 :delay (set! t7-0 (+ str-char -43)))
                    (.movz t5-6 str-char t7-0 t5-5)
                    (let ((t7-1 (+ str-char -45))) (.movz t5-7 str-char t7-1 t5-6))
                    (b! (nonzero? t5-7) cfg-15 :delay (set! t7-2 (+ str-char -121)))
                    (b! (zero? t7-2) cfg-52 :delay (set! t6-3 (+ str-char -89)))
                    (b! (zero? t6-3) cfg-52 :delay (set! t6-4 (+ str-char -122)))
                    (b! (zero? t6-4) cfg-53 :delay (set! t6-5 (+ str-char -90)))
                    (b! (zero? t6-5) cfg-53 :delay (set! t6-6 (+ str-char -48)))
                    (b! (< (the-as int t6-6) 0) cfg-55 :delay (set! t6-7 (+ str-char -57)))
                    (b! (> (the-as int t6-7) 0) cfg-55 :delay (set! t6-2 (the-as int (+ str-char -48))))
                    (label cfg-15)
                    (set! str-char (-> (the-as (pointer uint8) str-in) 4))
                    (set! str-in (the-as string (&-> (the-as (pointer uint8) str-in) 1)))
                    (b! (zero? str-char) cfg-67 :delay (set! t7-3 (+ str-char -110)))
                    (b! (zero? t7-3) cfg-33 :delay (set! t7-4 (+ str-char -78)))
                    (b! (zero? t7-4) cfg-33 :delay (set! t7-5 (+ str-char -108)))
                    (b! (zero? t7-5) cfg-4 :delay (set! t7-6 (+ str-char -76)))
                    (b! (zero? t7-6) cfg-4 :delay (set! t7-7 (+ str-char -119)))
                    (b! (zero? t7-7) cfg-4 :delay (set! t7-8 (+ str-char -87)))
                    (b! (zero? t7-8) cfg-4 :delay (set! t7-9 (+ str-char -107)))
                    (b! (zero? t7-9) cfg-36 :delay (set! t7-10 (+ str-char -75)))
                    (b! (zero? t7-10) cfg-36 :delay (set! t7-11 (+ str-char -106)))
                    (b! (zero? t7-11) cfg-38 :delay (set! t7-12 (+ str-char -74)))
                    (b! (zero? t7-12) cfg-38 :delay (set! t7-13 (+ str-char -104)))
                    (b! (zero? t7-13) cfg-42 :delay (set! t7-14 (+ str-char -72)))
                    (b! (zero? t7-14) cfg-42 :delay (set! t7-15 (+ str-char -118)))
                    (b! (zero? t7-15) cfg-47 :delay (set! t7-16 (+ str-char -86)))
                    (b! (zero? t7-16) cfg-47 :delay (set! t7-17 (+ str-char -48)))
                    (b! (< (the-as int t7-17) 0) cfg-55 :delay (set! t8-0 (+ str-char -57)))
                    (b! (> (the-as int t8-0) 0) cfg-55 :delay (.sll t8-1 t6-2 2))
                    (let ((t4-5 (+ t6-2 t8-1))) (.sll t4-6 t4-5 1))
                    (b! #t cfg-15 :delay (set! t6-2 (+ t4-6 t7-17)))
                    (label cfg-33)
                    (b! (nonzero? t6-2) cfg-35 :delay (set! t0-1 -33))
                    (set! font-table-to-use *font12-table*)
                    (.lvf vf13 (&-> fw size1-small quad))
                    (.lvf vf14 (&-> fw size2-small quad))
                    (.lvf vf15 (&-> fw size3-small quad))
                    (set! flags (logand flags t0-1))
                    (set! q-lo-tmpl (-> fw small-font-lo-tmpl-qw))
                    (b! #t cfg-4 :delay (set! q-hi-tmpl (-> fw small-font-hi-tmpl-qw)))
                    (label cfg-35)
                    (set! font-table-to-use *font24-table*)
                    (.lvf vf13 (&-> fw size1-large quad))
                    (.lvf vf14 (&-> fw size2-large quad))
                    (.lvf vf15 (&-> fw size3-large quad))
                    (set! flags (logior flags 32))
                    (set! q-lo-tmpl (-> fw large-font-lo-tmpl-qw))
                    (b! #t cfg-4 :delay (set! q-hi-tmpl (-> fw large-font-hi-tmpl-qw)))
                    (label cfg-36)
                    (let ((t4-7 -3)) (b! (zero? t6-2) cfg-4 :delay (set! flags (logand flags t4-7))))
                    (b! #t cfg-4 :delay (set! flags (logior flags 2)))
                    (label cfg-38)
                    (let ((t4-8 -21)
                          (t5-8 (+ t6-2 -2)))
                      (b! (zero? t6-2) cfg-4 :delay (set! flags (logand flags t4-8)))
                      (b! (zero? t5-8) cfg-41))
                    (b! #t cfg-4 :delay (set! flags (logior flags 16)))
                    (label cfg-41)
                    (b! #t cfg-4 :delay (set! flags (logior flags 4)))
                    (label cfg-42)
                    (.mov vf1 t6-2)
                    (let ((t4-9 (+ t5-7 -45))) (b! (zero? t5-7) cfg-46 :delay (.itof.vf vf1 vf1)) (b! (zero? t4-9) cfg-45))
                    (b! #t cfg-4 :delay (.add.x.vf.x vf23 vf23 vf1))
                    (label cfg-45)
                    (b! #t cfg-4 :delay (.sub.x.vf.x vf23 vf23 vf1))
                    (label cfg-46)
                    (b! #t cfg-4 :delay (.add.x.vf.x vf23 vf0 vf1))
                    (label cfg-47)
                    (.mov vf1 t6-2))
                  (let ((t4-10 (+ t5-7 -45))) (b! (zero? t5-7) cfg-51 :delay (.itof.vf vf1 vf1)) (b! (zero? t4-10) cfg-50))
                  (b! #t cfg-4 :delay (.add.x.vf.y vf23 vf23 vf1))
                  (label cfg-50)
                  (b! #t cfg-4 :delay (.sub.x.vf.y vf23 vf23 vf1))
                  (label cfg-51)
                  (b! #t cfg-4 :delay (.add.x.vf.y vf23 vf0 vf1))
                  (label cfg-52)
                  (b! #t cfg-4 :delay (.svf (&-> fw save quad) vf23))
                  (label cfg-53)
                  (b! #t cfg-4 :delay (.lvf vf23 (&-> fw save quad)))
                  (label cfg-54)
                  (let ((t4-11 (-> (the-as (pointer uint8) str-in) 4)))
                    (set! str-in (the-as string (&-> (the-as (pointer uint8) str-in) 1)))
                    (.add.vf.xyz vf4 vf23 vf15)
                    (let ((t4-12 (logand t4-11 127)))
                      (.sub.vf vf1 vf25 vf23)
                      (let ((t4-13 (+ t4-12 255))) (b! #t cfg-62 :delay (.sll t5-9 t4-13 4)))))
                  (label cfg-55)
                  (.add.vf.xyz vf4 vf23 vf15)
                  (.sll t5-9 str-char 4)
                  (.sub.vf vf1 vf25 vf23)
                  (b! (= str-char 10) cfg-57 :delay (set! fc-cr (+ str-char -13))))
                (b! (nonzero? fc-cr) cfg-62)
                (label cfg-57)
                (.sub.vf vf1 vf23 vf24)
                (b! (logtest? flags 16) cfg-60 :delay (set! t4-16 (logand flags 4)))
                (b! (nonzero? t4-16) cfg-61)
                (.add.x.vf.x vf23 vf0 vf24)
                (.svf (&-> (the-as font-work fw2) justify 0 quad) vf23)
                (.add.w.vf.y vf23 vf23 vf15)
                (b! #t cfg-4 :delay (set! fw2 (-> (the-as font-work fw2) font-tmpl gif)))
                (label cfg-60)
                (.sub.vf.x vf23 vf24 vf1)
                (.svf (&-> (the-as font-work fw2) justify 0 quad) vf23)
                (.add.x.vf.x vf23 vf0 vf24)
                (.add.w.vf.y vf23 vf23 vf15)
                (b! #t cfg-4 :delay (set! fw2 (-> (the-as font-work fw2) font-tmpl gif)))
                (label cfg-61)
                (.mul.w.vf.x vf1 vf1 vf16)
                (.sub.vf.x vf23 vf24 vf1)
                (.svf (&-> (the-as font-work fw2) justify 0 quad) vf23)
                (.add.x.vf.x vf23 vf0 vf24)
                (.add.w.vf.y vf23 vf23 vf15)
                (b! #t cfg-4 :delay (set! fw2 (-> (the-as font-work fw2) font-tmpl gif)))
                (label cfg-62)
                (.addu t4-17 t5-9 font-table-to-use)
                (.lvf vf5 (+ t4-17 -256))
                (.mov t4-18 vf1)
                (b! (< (the-as int t4-18) 0) cfg-67 :delay (.sra t4-19 t4-18 31))
                (.mul.vf vf19 vf5 vf13)
                (b! (zero? (logand flags 2)) cfg-65)
                (b! #t cfg-66 :delay (.add.w.vf.x vf23 vf23 vf19))
                (label cfg-65)
                (.add.w.vf.x vf23 vf23 vf14)
                (label cfg-66)
                (b! #t cfg-4)
                (label cfg-67)
                (.sub.vf vf1 vf23 vf24)
                (b! (logtest? flags 16) cfg-70 :delay (set! a0-2 (logand flags 4)))
                (b! (nonzero? a0-2) cfg-71)
                (.add.x.vf.x vf23 vf0 vf24)
                (b! #t cfg-72 :delay (.svf (&-> (the-as font-work fw2) justify 0 quad) vf23))
                (label cfg-70)
                (.sub.vf.x vf23 vf24 vf1)
                (b! #t cfg-72 :delay (.svf (&-> (the-as font-work fw2) justify 0 quad) vf23))
                (label cfg-71)
                (.mul.w.vf.x vf1 vf1 vf16)
                (.sub.vf.x vf23 vf24 vf1)
                (.svf (&-> (the-as font-work fw2) justify 0 quad) vf23))
              (label cfg-72)
              (let ((a0-3 (-> fw flags-signed)))
                (let ((t2-1 (the-as object fw))
                      (t3-7 (-> fw str-ptr-signed)))
                  (.lvf vf23 (&-> (the-as font-work t2-1) justify 0 quad))
                  (label cfg-73)
                  (let ((t4-21 (-> t3-7 4)))
                    (set! t3-7 (&-> t3-7 1))
                    (b! (zero? t4-21) cfg-131 :delay (set! t5-10 (+ t4-21 -1)))
                    (b! (zero? t5-10) cfg-121 :delay (set! t5-11 (+ t4-21 -126)))
                    (b! (nonzero? t5-11) cfg-122)
                    (set! t4-21 (-> t3-7 4))
                    (set! t3-7 (&-> t3-7 1))
                    (let ((t5-12 0)
                          (t6-9 0))
                      (b! (zero? t4-21) cfg-131 :delay (set! t7-18 (+ t4-21 -43)))
                      (.movz t5-13 t4-21 t7-18 t5-12)
                      (let ((t7-19 (+ t4-21 -45))) (.movz t5-14 t4-21 t7-19 t5-13))
                      (b! (nonzero? t5-14) cfg-84 :delay (set! t7-20 (+ t4-21 -121)))
                      (b! (zero? t7-20) cfg-119 :delay (set! t6-10 (+ t4-21 -89)))
                      (b! (zero? t6-10) cfg-119 :delay (set! t6-11 (+ t4-21 -122)))
                      (b! (zero? t6-11) cfg-120 :delay (set! t6-12 (+ t4-21 -90)))
                      (b! (zero? t6-12) cfg-120 :delay (set! t6-13 (+ t4-21 -48)))
                      (b! (< (the-as int t6-13) 0) cfg-122 :delay (set! t6-14 (+ t4-21 -57)))
                      (b! (> (the-as int t6-14) 0) cfg-122 :delay (set! t6-9 (the-as int (+ t4-21 -48))))
                      (label cfg-84)
                      (set! t4-21 (-> t3-7 4))
                      (set! t3-7 (&-> t3-7 1))
                      (b! (zero? t4-21) cfg-131 :delay (set! t7-21 (+ t4-21 -110)))
                      (b! (zero? t7-21) cfg-102 :delay (set! t7-22 (+ t4-21 -78)))
                      (b! (zero? t7-22) cfg-102 :delay (set! t7-23 (+ t4-21 -108)))
                      (b! (zero? t7-23) cfg-73 :delay (set! t7-24 (+ t4-21 -76)))
                      (b! (zero? t7-24) cfg-73 :delay (set! t7-25 (+ t4-21 -119)))
                      (b! (zero? t7-25) cfg-105 :delay (set! t7-26 (+ t4-21 -87)))
                      (b! (zero? t7-26) cfg-105 :delay (set! t7-27 (+ t4-21 -107)))
                      (b! (zero? t7-27) cfg-107 :delay (set! t7-28 (+ t4-21 -75)))
                      (b! (zero? t7-28) cfg-107 :delay (set! t7-29 (+ t4-21 -106)))
                      (b! (zero? t7-29) cfg-73 :delay (set! t7-30 (+ t4-21 -74)))
                      (b! (zero? t7-30) cfg-73 :delay (set! t7-31 (+ t4-21 -104)))
                      (b! (zero? t7-31) cfg-109 :delay (set! t7-32 (+ t4-21 -72)))
                      (b! (zero? t7-32) cfg-109 :delay (set! t7-33 (+ t4-21 -118)))
                      (b! (zero? t7-33) cfg-114 :delay (set! t7-34 (+ t4-21 -86)))
                      (b! (zero? t7-34) cfg-114 :delay (set! t7-35 (+ t4-21 -48)))
                      (b! (< (the-as int t7-35) 0) cfg-122 :delay (set! t8-2 (+ t4-21 -57)))
                      (b! (> (the-as int t8-2) 0) cfg-122 :delay (.sll t8-3 t6-9 2))
                      (let ((t4-22 (+ t6-9 t8-3))) (.sll t4-23 t4-22 1))
                      (b! #t cfg-84 :delay (set! t6-9 (+ t4-23 t7-35)))
                      (label cfg-102)
                      (b! (nonzero? t6-9) cfg-104 :delay (set! a3-6 *font12-table*))
                      (set! font-table-to-use a3-6)
                      (let ((t0-2 -33))
                        (.lvf vf13 (&-> fw size1-small quad))
                        (.lvf vf14 (&-> fw size2-small quad))
                        (.lvf vf15 (&-> fw size3-small quad))
                        (set! a0-3 (logand a0-3 t0-2)))
                      (set! q-lo-tmpl (-> fw small-font-lo-tmpl-qw))
                      (b! #t cfg-73 :delay (set! q-hi-tmpl (-> fw small-font-hi-tmpl-qw)))
                      (label cfg-104)
                      (set! font-table-to-use *font24-table*)
                      (.lvf vf13 (&-> fw size1-large quad))
                      (.lvf vf14 (&-> fw size2-large quad))
                      (.lvf vf15 (&-> fw size3-large quad))
                      (set! a0-3 (logior a0-3 32))
                      (set! q-lo-tmpl (-> fw large-font-lo-tmpl-qw))
                      (b! #t cfg-73 :delay (set! q-hi-tmpl (-> fw large-font-hi-tmpl-qw)))
                      (label cfg-105)
                      (let ((t4-24 -2)) (b! (zero? t6-9) cfg-73 :delay (set! a0-3 (logand a0-3 t4-24))))
                      (b! #t cfg-73 :delay (set! a0-3 (logior a0-3 1)))
                      (label cfg-107)
                      (let ((t4-25 -3)) (b! (zero? t6-9) cfg-73 :delay (set! a0-3 (logand a0-3 t4-25))))
                      (b! #t cfg-73 :delay (set! a0-3 (logior a0-3 2)))
                      (label cfg-109)
                      (.mov vf1 t6-9)
                      (let ((t4-26 (+ t5-14 -45))) (b! (zero? t5-14) cfg-113 :delay (.itof.vf vf1 vf1)) (b! (zero? t4-26) cfg-112))
                      (b! #t cfg-73 :delay (.add.x.vf.x vf23 vf23 vf1))
                      (label cfg-112)
                      (b! #t cfg-73 :delay (.sub.x.vf.x vf23 vf23 vf1))
                      (label cfg-113)
                      (b! #t cfg-73 :delay (.add.x.vf.x vf23 vf0 vf1))
                      (label cfg-114)
                      (.mov vf1 t6-9))
                    (let ((t4-27 (+ t5-14 -45))) (b! (zero? t5-14) cfg-118 :delay (.itof.vf vf1 vf1)) (b! (zero? t4-27) cfg-117))
                    (b! #t cfg-73 :delay (.add.x.vf.y vf23 vf23 vf1))
                    (label cfg-117)
                    (b! #t cfg-73 :delay (.sub.x.vf.y vf23 vf23 vf1))
                    (label cfg-118)
                    (b! #t cfg-73 :delay (.add.x.vf.y vf23 vf0 vf1))
                    (label cfg-119)
                    (b! #t cfg-73 :delay (.svf (&-> fw save quad) vf23))
                    (label cfg-120)
                    (b! #t cfg-73 :delay (.lvf vf23 (&-> fw save quad)))
                    (label cfg-121)
                    (set! t4-21 (-> t3-7 4))
                    (set! t3-7 (&-> t3-7 1))
                    (.add.vf.xyz vf4 vf23 vf15)
                    (let ((t5-15 (logand t4-21 127)))
                      (.sub.vf vf1 vf25 vf23)
                      (let ((t5-16 (+ t5-15 255))) (b! #t cfg-125 :delay (.sll t5-17 t5-16 4))))
                    (label cfg-122)
                    (.add.vf.xyz vf4 vf23 vf15)
                    (.sll t5-17 t4-21 4)
                    (.sub.vf vf1 vf25 vf23)
                    (b! (= t4-21 10) cfg-124 :delay (set! t6-16 (+ t4-21 -13)))
                    (b! (nonzero? t6-16) cfg-125 :delay (logand a0-3 1))
                    (label cfg-124)
                    (set! t2-1 (&-> (the-as (pointer uint64) t2-1) 2))
                    (b! #t cfg-73 :delay (.lvf vf23 (+ (the-as int t2-1) 944)))
                    (label cfg-125)
                    (.addu t5-18 t5-17 font-table-to-use)
                    (.lvf vf5 (+ t5-18 -256))
                    (.mov t5-19 vf1)
                    (b! (< (the-as int t5-19) 0) cfg-131 :delay (.add.vf.xyz vf6 vf5 vf16))
                    (.sra t5-20 t5-19 31)
                    (.add.vf.xyz vf7 vf5 vf17)
                    (b! (< t5-20 0) cfg-73 :delay (.add.vf.xyz vf8 vf5 vf18))
                    (.add.vf.xyz vf1 vf23 vf0)
                    (.add.vf.xyz vf2 vf23 vf13)
                    (.svf (&-> fw current-verts tex-st 0 quad) vf5)
                    (.add.vf.xyz vf3 vf23 vf14)
                    (.svf (&-> fw current-verts tex-st 1 quad) vf6)
                    (.mul.vf vf19 vf5 vf13)
                    (.svf (&-> fw current-verts tex-st 2 quad) vf7)
                    (.svf (&-> fw current-verts tex-st 3 quad) vf8)
                    (.svf (&-> fw current-verts pos 0 quad) vf1)
                    (.svf (&-> fw current-verts pos 1 quad) vf2)
                    (.svf (&-> fw current-verts pos 2 quad) vf3)
                    (.svf (&-> fw current-verts pos 3 quad) vf4)
                    (.lvf vf1 (&-> fw current-verts pos 0 quad))
                    (.lvf vf2 (&-> fw current-verts pos 1 quad))
                    (.mul.w.vf acc vf31 vf0)
                    (.lvf vf3 (&-> fw current-verts pos 2 quad))
                    (.add.mul.x.vf acc vf28 vf1 acc)
                    (.lvf vf4 (&-> fw current-verts pos 3 quad))
                    (.add.mul.y.vf acc vf29 vf1 acc)
                    (.add.mul.z.vf vf1 vf30 vf1 acc)
                    (.mul.w.vf acc vf31 vf0)
                    (.add.mul.x.vf acc vf28 vf2 acc)
                    (.add.mul.y.vf acc vf29 vf2 acc)
                    (.add.mul.z.vf vf2 vf30 vf2 acc)
                    (.mul.w.vf acc vf31 vf0)
                    (.add.mul.x.vf acc vf28 vf3 acc)
                    (.add.mul.y.vf acc vf29 vf3 acc)
                    (.add.mul.z.vf vf3 vf30 vf3 acc)
                    (.mul.w.vf acc vf31 vf0)
                    (.add.mul.x.vf acc vf28 vf4 acc)
                    (.add.mul.y.vf acc vf29 vf4 acc)
                    (.add.mul.z.vf vf4 vf30 vf4 acc)
                    (.div.vf Q vf25 vf1 :fsf #b10 :ftf #b11)
                    (let ((t5-21 (-> fw char-tmpl dma-vif quad)))
                      (let ((t6-18 (-> fw char-tmpl quad 1)))
                        (set! (-> (the-as (pointer uint128) dma-out) 0) t5-21)
                        (set! (-> (the-as (pointer uint128) dma-out) 1) t6-18)))
                    (.lvf vf5 (&-> fw current-verts tex-st 0 quad))
                    (let ((t5-22 q-lo-tmpl))
                      (.lvf vf6 (&-> fw current-verts tex-st 1 quad))
                      (let ((t4-28 (logand t4-21 128)))
                        (.lvf vf7 (&-> fw current-verts tex-st 2 quad))
                        ;; note: this relies on (somewhat) undefined behavior that the upper 64-bits of a
                        ;; gpr aren't changed during movn.
                        (.movn-128 t5-23 q-hi-tmpl t4-28 t5-22)))))
                (.mul.vf.xyz vf1 vf1 Q)
                (set! (-> (the-as (pointer uint128) dma-out) 2) (the-as uint128 t5-23))
                (.mul.vf.xyz vf5 vf5 Q)
                (.nop.vf)
                (.nop.vf)
                (.div.vf Q vf25 vf2 :fsf #b10 :ftf #b11)
                (.lvf vf8 (&-> fw current-verts tex-st 3 quad))
                (.add.vf vf1 vf1 vf26)
                (.lvf vf9 (&-> fw color-shadow quad))
                (vftoi4.xyzw vf1 vf1)
                (.mul.vf.xyz vf2 vf2 Q)
                (.mul.vf.xyz vf6 vf6 Q)
                (.svf (&-> (the-as (pointer uint128) dma-out) 3) vf5)
                (.nop.vf)
                (.nop.vf)
                (.div.vf Q vf25 vf3 :fsf #b10 :ftf #b11)
                (.svf (&-> (the-as (pointer uint128) dma-out) 4) vf9)
                (.svf (&-> (the-as (pointer uint128) dma-out) 5) vf1)
                (.add.vf vf2 vf2 vf26)
                (vftoi4.xyzw vf2 vf2)
                (.mul.vf.xyz vf3 vf3 Q)
                (.mul.vf.xyz vf7 vf7 Q)
                (.svf (&-> (the-as (pointer uint128) dma-out) 6) vf6)
                (.nop.vf)
                (.nop.vf)
                (.div.vf Q vf25 vf4 :fsf #b10 :ftf #b11)
                (.svf (&-> (the-as (pointer uint128) dma-out) 7) vf9)
                (.svf (&-> (the-as (pointer uint128) dma-out) 8) vf2)
                (.add.vf vf3 vf3 vf26)
                (vftoi4.xyzw vf3 vf3)
                (.mul.vf.xyz vf4 vf4 Q)
                (.mul.vf.xyz vf8 vf8 Q)
                (.svf (&-> (the-as (pointer uint128) dma-out) 9) vf7)
                (.svf (&-> (the-as (pointer uint128) dma-out) 10) vf9)
                (.add.vf vf4 vf4 vf26)
                (.svf (&-> (the-as (pointer uint128) dma-out) 11) vf3)
                (let ((t4-29 (logand a0-3 2))) (b! (zero? t4-29) cfg-129)))
              (b! #t cfg-130 :delay (.add.w.vf.x vf23 vf23 vf19))
              (label cfg-129)
              (.add.w.vf.x vf23 vf23 vf14)
              (label cfg-130)
              (vftoi4.xyzw vf4 vf4)
              (.svf (&-> (the-as (pointer uint128) dma-out) 12) vf8)
              (.svf (&-> (the-as (pointer uint128) dma-out) 13) vf9)
              (.svf (&-> (the-as (pointer uint128) dma-out) 14) vf4)
              (b! #t cfg-73 :delay (set! dma-out (&-> (the-as (pointer uint128) dma-out) 15)))
              (label cfg-131)
              (let ((a0-4 (-> fw flags-signed)))
                (let ((t2-2 (the-as object fw))
                      (t3-8 (-> fw str-ptr-signed)))
                  (.lvf vf23 (&-> (the-as font-work t2-2) justify 0 quad))
                  (label cfg-132)
                  (let ((t4-30 (-> t3-8 4)))
                    (set! t3-8 (&-> t3-8 1))
                    (b! (zero? t4-30) cfg-189 :delay (set! t5-24 (+ t4-30 -1)))
                    (b! (zero? t5-24) cfg-179 :delay (set! t5-25 (+ t4-30 -126)))
                    (b! (nonzero? t5-25) cfg-180)
                    (set! t4-30 (-> t3-8 4))
                    (set! t3-8 (&-> t3-8 1))
                    (let ((t5-26 0)
                          (t6-19 0))
                      (b! (zero? t4-30) cfg-189 :delay (set! t7-36 (+ t4-30 -43)))
                      (.movz t5-27 t4-30 t7-36 t5-26)
                      (let ((t7-37 (+ t4-30 -45))) (.movz t5-28 t4-30 t7-37 t5-27))
                      (b! (nonzero? t5-28) cfg-143 :delay (set! t7-38 (+ t4-30 -121)))
                      (b! (zero? t7-38) cfg-177 :delay (set! t6-20 (+ t4-30 -89)))
                      (b! (zero? t6-20) cfg-177 :delay (set! t6-21 (+ t4-30 -122)))
                      (b! (zero? t6-21) cfg-178 :delay (set! t6-22 (+ t4-30 -90)))
                      (b! (zero? t6-22) cfg-178 :delay (set! t6-23 (+ t4-30 -48)))
                      (b! (< (the-as int t6-23) 0) cfg-180 :delay (set! t6-24 (+ t4-30 -57)))
                      (b! (> (the-as int t6-24) 0) cfg-180 :delay (set! t6-19 (the-as int (+ t4-30 -48))))
                      (label cfg-143)
                      (set! t4-30 (-> t3-8 4))
                      (set! t3-8 (&-> t3-8 1))
                      (b! (zero? t4-30) cfg-189 :delay (set! t7-39 (+ t4-30 -110)))
                      (b! (zero? t7-39) cfg-161 :delay (set! t7-40 (+ t4-30 -78)))
                      (b! (zero? t7-40) cfg-161 :delay (set! t7-41 (+ t4-30 -108)))
                      (b! (zero? t7-41) cfg-164 :delay (set! t7-42 (+ t4-30 -76)))
                      (b! (zero? t7-42) cfg-164 :delay (set! t7-43 (+ t4-30 -119)))
                      (b! (zero? t7-43) cfg-132 :delay (set! t7-44 (+ t4-30 -87)))
                      (b! (zero? t7-44) cfg-132 :delay (set! t7-45 (+ t4-30 -107)))
                      (b! (zero? t7-45) cfg-165 :delay (set! t7-46 (+ t4-30 -75)))
                      (b! (zero? t7-46) cfg-165 :delay (set! t7-47 (+ t4-30 -106)))
                      (b! (zero? t7-47) cfg-132 :delay (set! t7-48 (+ t4-30 -74)))
                      (b! (zero? t7-48) cfg-132 :delay (set! t7-49 (+ t4-30 -104)))
                      (b! (zero? t7-49) cfg-167 :delay (set! t7-50 (+ t4-30 -72)))
                      (b! (zero? t7-50) cfg-167 :delay (set! t7-51 (+ t4-30 -118)))
                      (b! (zero? t7-51) cfg-172 :delay (set! t7-52 (+ t4-30 -86)))
                      (b! (zero? t7-52) cfg-172 :delay (set! t7-53 (+ t4-30 -48)))
                      (b! (< (the-as int t7-53) 0) cfg-180 :delay (set! t8-4 (+ t4-30 -57)))
                      (b! (> (the-as int t8-4) 0) cfg-180 :delay (.sll t8-5 t6-19 2))
                      (let ((t4-31 (+ t6-19 t8-5))) (.sll t4-32 t4-31 1))
                      (b! #t cfg-143 :delay (set! t6-19 (+ t4-32 t7-53)))
                      (label cfg-161)
                      (b! (nonzero? t6-19) cfg-163 :delay (set! a3-8 *font12-table*))
                      (set! font-table-to-use a3-8)
                      (let ((t0-3 -33))
                        (.lvf vf13 (&-> fw size1-small quad))
                        (.lvf vf14 (&-> fw size2-small quad))
                        (.lvf vf15 (&-> fw size3-small quad))
                        (set! a0-4 (logand a0-4 t0-3)))
                      (set! q-lo-tmpl (-> fw small-font-lo-tmpl-qw))
                      (b! #t cfg-132 :delay (set! q-hi-tmpl (-> fw small-font-hi-tmpl-qw)))
                      (label cfg-163)
                      (set! font-table-to-use *font24-table*)
                      (.lvf vf13 (&-> fw size1-large quad))
                      (.lvf vf14 (&-> fw size2-large quad))
                      (.lvf vf15 (&-> fw size3-large quad))
                      (set! a0-4 (logior a0-4 32))
                      (set! q-lo-tmpl (-> fw large-font-lo-tmpl-qw))
                      (b! #t cfg-132 :delay (set! q-hi-tmpl (-> fw large-font-hi-tmpl-qw)))
                      (label cfg-164)
                      (set! (-> fw last-color-32) t6-19)
                      (.sll t4-33 t6-19 4)
                      (let ((t5-29 (-> fw current-verts color 0 quad))
                            (t4-34 (the-as object (+ t4-33 (the-as int fw)))))
                        (let ((t6-25 (-> fw current-verts color 1 quad)))
                          (set! (-> fw src-verts color 0 quad) t5-29)
                          (set! (-> fw src-verts color 1 quad) t6-25))
                        (let ((t5-30 (-> fw current-verts color 2 quad)))
                          (let ((t6-26 (-> fw current-verts color 3 quad)))
                            (set! (-> fw src-verts color 2 quad) t5-30)
                            (set! (-> fw src-verts color 3 quad) t6-26)))
                        (let ((t6-27 (the-as uint128 (deref uint32 (+ (the-as int t4-34) 1984)))))
                          (let ((t5-31 (the-as uint128 (-> (the-as font-work t4-34) color-table 0 color 1))))
                            (.pextlb t6-28 r0 t6-27)
                            (.pextlh t6-29 r0 t6-28)
                            (.pextlb t5-32 r0 t5-31)))
                        (set! (-> fw current-verts color 0 quad) (the-as uint128 t6-29))
                        (.pextlh t5-33 r0 t5-32)
                        (set! (-> fw dest-verts color 0 quad) (the-as uint128 t6-29))
                        (set! (-> fw current-verts color 1 quad) (the-as uint128 t5-33))
                        (set! (-> fw dest-verts color 1 quad) (the-as uint128 t5-33))
                        (let ((t5-34 (the-as uint128 (-> (the-as font-work t4-34) color-table 0 color 2))))
                          (let ((t4-35 (the-as uint128 (-> (the-as font-work t4-34) color-table 0 color 3))))
                            (.pextlb t5-35 r0 t5-34)
                            (.pextlh t5-36 r0 t5-35)
                            (.pextlb t4-36 r0 t4-35))))
                      (set! (-> fw current-verts color 2 quad) (the-as uint128 t5-36))
                      (.pextlh t4-37 r0 t4-36)
                      (set! (-> fw dest-verts color 2 quad) (the-as uint128 t5-36))
                      (set! (-> fw current-verts color 3 quad) (the-as uint128 t4-37))
                      (b! #t cfg-132 :delay (set! (-> fw dest-verts color 3 quad) (the-as uint128 (the-as int t4-37))))
                      (label cfg-165)
                      (let ((t4-38 -3)) (b! (zero? t6-19) cfg-132 :delay (set! a0-4 (logand a0-4 t4-38))))
                      (b! #t cfg-132 :delay (set! a0-4 (logior a0-4 2)))
                      (label cfg-167)
                      (.mov vf1 t6-19)
                      (let ((t4-39 (+ t5-28 -45))) (b! (zero? t5-28) cfg-171 :delay (.itof.vf vf1 vf1)) (b! (zero? t4-39) cfg-170))
                      (b! #t cfg-132 :delay (.add.x.vf.x vf23 vf23 vf1))
                      (label cfg-170)
                      (b! #t cfg-132 :delay (.sub.x.vf.x vf23 vf23 vf1))
                      (label cfg-171)
                      (b! #t cfg-132 :delay (.add.x.vf.x vf23 vf0 vf1))
                      (label cfg-172)
                      (.mov vf1 t6-19))
                    (let ((t4-40 (+ t5-28 -45))) (b! (zero? t5-28) cfg-176 :delay (.itof.vf vf1 vf1)) (b! (zero? t4-40) cfg-175))
                    (b! #t cfg-132 :delay (.add.x.vf.y vf23 vf23 vf1))
                    (label cfg-175)
                    (b! #t cfg-132 :delay (.sub.x.vf.y vf23 vf23 vf1))
                    (label cfg-176)
                    (b! #t cfg-132 :delay (.add.x.vf.y vf23 vf0 vf1))
                    (label cfg-177)
                    (let ((t4-41 (-> fw last-color-32)))
                      (.lvf vf9 (&-> fw current-verts color 0 quad))
                      (.lvf vf10 (&-> fw current-verts color 1 quad))
                      (.lvf vf11 (&-> fw current-verts color 2 quad))
                      (.lvf vf12 (&-> fw current-verts color 3 quad))
                      (set! (-> fw save-last-color-32) t4-41))
                    (.svf (&-> fw save-color 0 quad) vf9)
                    (.svf (&-> fw save-color 1 quad) vf10)
                    (.svf (&-> fw save-color 2 quad) vf11)
                    (.svf (&-> fw save-color 3 quad) vf12)
                    (b! #t cfg-132 :delay (.svf (&-> fw save quad) vf23))
                    (label cfg-178)
                    (let ((t4-42 (-> fw save-last-color-32)))
                      (.lvf vf9 (&-> fw save-color 0 quad))
                      (.lvf vf10 (&-> fw save-color 1 quad))
                      (.lvf vf11 (&-> fw save-color 2 quad))
                      (.lvf vf12 (&-> fw save-color 3 quad))
                      (set! (-> fw last-color-32) t4-42))
                    (.svf (&-> fw current-verts color 0 quad) vf9)
                    (.svf (&-> fw dest-verts color 0 quad) vf9)
                    (.svf (&-> fw current-verts color 1 quad) vf10)
                    (.svf (&-> fw dest-verts color 1 quad) vf10)
                    (.svf (&-> fw current-verts color 2 quad) vf11)
                    (.svf (&-> fw dest-verts color 2 quad) vf11)
                    (.svf (&-> fw current-verts color 3 quad) vf12)
                    (.svf (&-> fw dest-verts color 3 quad) vf12)
                    (b! #t cfg-132 :delay (.lvf vf23 (&-> fw save quad)))
                    (label cfg-179)
                    (set! t4-30 (-> t3-8 4))
                    (set! t3-8 (&-> t3-8 1))
                    (.add.vf.xyz vf4 vf23 vf15)
                    (let ((t5-37 (logand t4-30 127)))
                      (.sub.vf vf1 vf25 vf23)
                      (let ((t5-38 (+ t5-37 255))) (b! #t cfg-183 :delay (.sll t5-39 t5-38 4))))
                    (label cfg-180)
                    (.add.vf.xyz vf4 vf23 vf15)
                    (.sll t5-39 t4-30 4)
                    (.sub.vf vf1 vf25 vf23)
                    (b! (= t4-30 10) cfg-182 :delay (set! t6-31 (+ t4-30 -13)))
                    (b! (nonzero? t6-31) cfg-183)
                    (label cfg-182)
                    (set! t2-2 (&-> (the-as (pointer uint64) t2-2) 2))
                    (b! #t cfg-132 :delay (.lvf vf23 (+ (the-as int t2-2) 944)))
                    (label cfg-183)
                    (.addu t5-40 t5-39 font-table-to-use)
                    (.lvf vf5 (+ t5-40 -256))
                    (.mov t5-41 vf1)
                    (b! (< (the-as int t5-41) 0) cfg-189 :delay (.add.vf.xyz vf6 vf5 vf16))
                    (.sra t5-42 t5-41 31)
                    (.add.vf.xyz vf7 vf5 vf17)
                    (b! (< t5-42 0) cfg-132 :delay (.add.vf.xyz vf8 vf5 vf18))
                    (.add.vf.xyz vf1 vf23 vf0)
                    (.add.vf.xyz vf2 vf23 vf13)
                    (.add.vf.xyz vf3 vf23 vf14)
                    (.svf (&-> fw current-verts tex-st 0 quad) vf5)
                    (.add.vf.xyz vf4 vf23 vf15)
                    (.svf (&-> fw current-verts tex-st 1 quad) vf6)
                    (.mul.vf vf19 vf5 vf13)
                    (.svf (&-> fw current-verts tex-st 2 quad) vf7)
                    (.svf (&-> fw current-verts tex-st 3 quad) vf8)
                    (.svf (&-> fw current-verts pos 0 quad) vf1)
                    (.svf (&-> fw current-verts pos 1 quad) vf2)
                    (.svf (&-> fw current-verts pos 2 quad) vf3)
                    (.svf (&-> fw current-verts pos 3 quad) vf4)
                    (.lvf vf1 (&-> fw current-verts pos 0 quad))
                    (.lvf vf2 (&-> fw current-verts pos 1 quad))
                    (.mul.w.vf acc vf31 vf0)
                    (.lvf vf3 (&-> fw current-verts pos 2 quad))
                    (.add.mul.x.vf acc vf28 vf1 acc)
                    (.lvf vf4 (&-> fw current-verts pos 3 quad))
                    (.add.mul.y.vf acc vf29 vf1 acc)
                    (.add.mul.z.vf vf1 vf30 vf1 acc)
                    (.mul.w.vf acc vf31 vf0)
                    (.add.mul.x.vf acc vf28 vf2 acc)
                    (.add.mul.y.vf acc vf29 vf2 acc)
                    (.add.mul.z.vf vf2 vf30 vf2 acc)
                    (.mul.w.vf acc vf31 vf0)
                    (.add.mul.x.vf acc vf28 vf3 acc)
                    (.add.mul.y.vf acc vf29 vf3 acc)
                    (.add.mul.z.vf vf3 vf30 vf3 acc)
                    (.mul.w.vf acc vf31 vf0)
                    (.add.mul.x.vf acc vf28 vf4 acc)
                    (.add.mul.y.vf acc vf29 vf4 acc)
                    (.add.mul.z.vf vf4 vf30 vf4 acc)
                    (.div.vf Q vf25 vf1 :fsf #b10 :ftf #b11)
                    (let ((t5-43 (-> fw char-tmpl dma-vif quad)))
                      (let ((t6-32 (-> fw char-tmpl quad 1)))
                        (set! (-> (the-as (pointer uint128) dma-out) 0) t5-43)
                        (set! (-> (the-as (pointer uint128) dma-out) 1) t6-32)))
                    (.lvf vf5 (&-> fw current-verts tex-st 0 quad))
                    (let ((t5-44 q-lo-tmpl))
                      (.lvf vf6 (&-> fw current-verts tex-st 1 quad))
                      (let ((t4-43 (logand t4-30 128)))
                        (.lvf vf7 (&-> fw current-verts tex-st 2 quad))
                        (.movn-128 t5-45 q-hi-tmpl t4-43 t5-44)))))
                (.mul.vf.xyz vf1 vf1 Q)
                (set! (-> (the-as (pointer uint128) dma-out) 2) (the uint128 t5-45))
                (.mul.vf.xyz vf5 vf5 Q)
                (.nop.vf)
                (.nop.vf)
                (.div.vf Q vf25 vf2 :fsf #b10 :ftf #b11)
                (.lvf vf8 (&-> fw current-verts tex-st 3 quad))
                (.add.vf vf1 vf1 vf27)
                (.lvf vf9 (&-> fw current-verts color 0 quad))
                (.lvf vf10 (&-> fw current-verts color 1 quad))
                (.lvf vf11 (&-> fw current-verts color 2 quad))
                (vftoi4.xyzw vf1 vf1)
                (.mul.vf.xyz vf2 vf2 Q)
                (.mul.vf.xyz vf6 vf6 Q)
                (.svf (&-> (the-as (pointer uint128) dma-out) 3) vf5)
                (.nop.vf)
                (.nop.vf)
                (.div.vf Q vf25 vf3 :fsf #b10 :ftf #b11)
                (.svf (&-> (the-as (pointer uint128) dma-out) 4) vf9)
                (.lvf vf12 (&-> fw current-verts color 3 quad))
                (.svf (&-> (the-as (pointer uint128) dma-out) 5) vf1)
                (.add.vf vf2 vf2 vf27)
                (vftoi4.xyzw vf2 vf2)
                (.mul.vf.xyz vf3 vf3 Q)
                (.mul.vf.xyz vf7 vf7 Q)
                (.svf (&-> (the-as (pointer uint128) dma-out) 6) vf6)
                (.nop.vf)
                (.nop.vf)
                (.div.vf Q vf25 vf4 :fsf #b10 :ftf #b11)
                (.svf (&-> (the-as (pointer uint128) dma-out) 7) vf10)
                (.svf (&-> (the-as (pointer uint128) dma-out) 8) vf2)
                (.add.vf vf3 vf3 vf27)
                (vftoi4.xyzw vf3 vf3)
                (.mul.vf.xyz vf4 vf4 Q)
                (.mul.vf.xyz vf8 vf8 Q)
                (.svf (&-> (the-as (pointer uint128) dma-out) 9) vf7)
                (.svf (&-> (the-as (pointer uint128) dma-out) 10) vf11)
                (.add.vf vf4 vf4 vf27)
                ;;(s.vf! (+ dma-out 176) vf3)
                (.svf (+ (the-as int dma-out) 176) vf3)
                (let ((t4-44 (logand a0-4 2))) (b! (zero? t4-44) cfg-187))))))
        (b! #t cfg-188 :delay (.add.w.vf.x vf23 vf23 vf19))
        (label cfg-187)
        (.add.w.vf.x vf23 vf23 vf14)
        (label cfg-188)
        (vftoi4.xyzw vf4 vf4)
        ;;(s.vf! (+ dma-out 192) vf8)
        (.svf (+ (the-as int dma-out) 192) vf8)
        ;;(s.vf! (+ dma-out 208) vf12)
        (.svf (+ (the-as int dma-out) 208) vf12)
        ;;(s.vf! (+ dma-out 224) vf4)
        (.svf (+ (the-as int dma-out) 224) vf4)
        (b! #t cfg-132 :delay (set! dma-out (&+ dma-out 240)))
        (label cfg-189)
        (let ((v1-6 (-> fw buf)))
          ;;(s.w! (+ v1-6 4) dma-out)
          (set! (-> (the-as (pointer pointer) v1-6) 1) dma-out))))
    (.lvf vf24 (&-> arg2 origin quad))
    (.sub.vf vf23 vf23 vf24)
    (.mov v0-0 vf23)
    v0-0))

(defun draw-string-adv ((str string) (buf dma-buffer) (ctxt font-context))
  "Draw a string and advance the position of the context."
  (+! (-> ctxt origin x) (draw-string str buf ctxt))
  (none))

(defun get-string-length ((arg0 string) (arg1 font-context))
  (local-vars (v0-0 float))
  (rlet ((vf0 :class vf)
         (vf1 :class vf)
         (vf13 :class vf)
         (vf14 :class vf)
         (vf19 :class vf)
         (vf23 :class vf)
         (vf24 :class vf)
         (vf25 :class vf)
         (vf5 :class vf))
    (init-vf0-vector)
    (.lvf vf25 (&-> arg1 context-vec quad))
    (.lvf vf23 (&-> arg1 origin quad))
    (.lvf vf24 (&-> arg1 origin quad))
    (let ((flags (-> arg1 flags))
          (work *font-work*))
      (.lvf vf1 (&-> *video-parms* relative-x-scale-reciprical))
      (.mul.vf.xy vf25 vf25 vf1)
      (.mul.vf.xy vf23 vf23 vf1)
      ;; hack! fixes small font widescreen
      (unless (logtest? (-> arg1 flags) (font-flags pc-hack))
        (.mul.vf.xy vf24 vf24 vf1))
      (set! (-> work str-ptr) (the-as uint arg0))
      (set! (-> work flags) flags)
      (.mov.vf vf1 vf0)
      (let ((kerning-table (cond
                             ((logtest? flags (font-flags large))
                              (.lvf vf13 (&-> work size1-large quad))
                              (.lvf vf14 (&-> work size2-large quad))
                              *font24-table*)
                             (else (.lvf vf13 (&-> work size1-small quad)) (.lvf vf14 (&-> work size2-small quad)) *font12-table*))))
        (label cfg-3)
        (let ((cur-char (-> arg0 data 0)))
          (set! arg0 (the-as string (&-> (the-as (pointer uint8) arg0) 1)))
          (if (zero? cur-char) (goto cfg-51))
          (when (= cur-char 1)
            (let ((a3-6 (-> arg0 data 0)))
              (set! arg0 (the-as string (&-> (the-as (pointer uint8) arg0) 1)))
              (set! cur-char (+ (logand a3-6 127) 255))
              (goto cfg-48)))
          (when (= cur-char #\~)
            (set! cur-char (-> arg0 data 0))
            (set! arg0 (the-as string (&-> (the-as (pointer uint8) arg0) 1)))
            (if (zero? cur-char) (goto cfg-51))
            (when (or (= cur-char #\Y) (= cur-char #\y))
              (.svf (&-> work save quad) vf23)
              (goto cfg-3))
            (when (or (= cur-char #\Z) (= cur-char #\z))
              (.lvf vf23 (&-> work save quad))
              (goto cfg-3))
            (let ((sign-char (if (or (= cur-char #\-) (= cur-char #\+)) cur-char 0))
                  (arg-val 0))
              (when (or (nonzero? sign-char) (and (>= cur-char #\0) (<= cur-char #\9)))
                (label cfg-14)
                (set! cur-char (-> arg0 data 0))
                (set! arg0 (the-as string (&-> (the-as (pointer uint8) arg0) 1)))
                (if (zero? cur-char) (goto cfg-51))
                (case cur-char
                  ((#\n #\N)
                   (cond
                     ((nonzero? arg-val)
                      (.lvf vf13 (&-> work size1-large quad))
                      (.lvf vf14 (&-> work size2-large quad))
                      (set! kerning-table *font24-table*)
                      (logior! flags (font-flags large)))
                     (else
                      (.lvf vf13 (&-> work size1-small quad))
                      (.lvf vf14 (&-> work size2-small quad))
                      (set! kerning-table *font12-table*)
                      (logclear! flags (font-flags large))))
                   (goto cfg-3))
                  ((#\l #\L #\w #\W #\j #\J #\v #\V) (goto cfg-3))
                  ((#\k #\K)
                   (if (zero? arg-val) (logclear! flags (font-flags kerning)) (logior! flags (font-flags kerning)))
                   (goto cfg-3))
                  ((#\h #\H)
                   (.mov vf1 arg-val)
                   (.itof.vf vf1 vf1)
                   (cond
                     ((zero? sign-char) (.add.x.vf.x vf23 vf0 vf1))
                     ((= sign-char #\-) (.sub.x.vf.x vf23 vf23 vf1))
                     (else (.add.x.vf.x vf23 vf23 vf1)))
                   (goto cfg-3)))
                (when (and (>= cur-char #\0) (<= cur-char #\9))
                  (set! arg-val (+ (* arg-val 10) (- cur-char #\0)))
                  (goto cfg-14)))))
          (cond
            ((and (!= cur-char 10) (!= cur-char 13))
             (label cfg-48)
             (.lvf vf5 (&-> kerning-table (- cur-char 16) quad))
             (.mul.vf vf19 vf5 vf13)
             (if (logtest? flags (font-flags kerning)) (.add.w.vf.x vf23 vf23 vf19) (.add.w.vf.x vf23 vf23 vf14)))
            (else (.add.x.vf.x vf23 vf0 vf24)))
          (goto cfg-3))))
    (label cfg-51)
    (.sub.vf vf23 vf23 vf24)
    (.mov v0-0 vf23)
    v0-0))

(defun draw-string-xy ((str string) (buf dma-buffer) (x int) (y int) (color font-color) (flags font-flags))
  "Draw a string at the given xy location."
  (let ((context (new 'stack 'font-context *font-default-matrix* x y 0.0 color flags))) (draw-string str buf context)))

;; 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))
         (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))))
  (none))
