;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/gfx/hw/display.gc")
(require "engine/gfx/foreground/eye-h.gc")
(require "engine/ps2/vu1-macros.gc")
(require "engine/math/vector.gc")

;; note: changed for high fps

;; DECOMP BEGINS

(define *eye-work*
  (new 'static
       'eye-work
       :sprite-tmpl
       (new 'static
            'dma-gif-packet
            :dma-vif
            (new 'static
                 'dma-packet
                 :dma
                 (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))
                 :vif1
                 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
            :gif
            (new 'static 'array uint64 2 #x508b400000008001 #x53531))
       :sprite-tmpl2
       (new 'static
            'dma-gif-packet
            :dma-vif
            (new 'static
                 'dma-packet
                 :dma
                 (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))
                 :vif1
                 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
            :gif
            (new 'static 'array uint64 2 #x50ab400000008001 #x53531))
       :adgif-tmpl
       (new 'static
            'dma-gif-packet
            :dma-vif
            (new 'static
                 'dma-packet
                 :dma
                 (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))
                 :vif1
                 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
            :gif
            (new 'static 'array uint64 2 #x1000000000008005 #xe))
       :blink-table
       (new 'static 'array float 10 0.0 0.667 0.9 1.0 1.0 1.0 1.0 0.333 0.1 0.0)))

;; WARN: Stack slot offset 16 signed mismatch
;; WARN: Stack slot offset 16 signed mismatch
;; WARN: Stack slot offset 16 signed mismatch
;; WARN: Stack slot offset 16 signed mismatch
(defun render-eyes ((arg0 dma-buffer) (arg1 eye-control) (arg2 int))
  (local-vars (sv-16 float))
  (let ((s4-0 32)
        (s3-0 (+ (* arg2 32) 32))
        (s2-0 (* arg2 32)))
    (let ((f28-0 (* 16.0 (+ (the float (+ s4-0 16)) (* 32.0 (-> arg1 left x)))))
          (f26-0 (* 16.0 (+ (the float (+ s3-0 16)) (* 32.0 (-> arg1 left y)))))
          (f30-0 (* 16.0 (+ (the float (+ s4-0 48)) (* 32.0 (-> arg1 right x))))))
      (set! sv-16 (* 16.0 (+ (the float (+ s3-0 16)) (* 32.0 (-> arg1 right y)))))
      (let ((s1-0 (-> arg1 shaders 0)))
        ;; ADGIF 0
        (let ((v1-6 (the-as object (-> arg0 base))))
          (set! (-> (the-as dma-gif-packet v1-6) dma-vif quad) (-> *eye-work* adgif-tmpl dma-vif quad))
          (set! (-> (the-as dma-gif-packet v1-6) quad 1) (-> *eye-work* adgif-tmpl quad 1))
          (let ((s0-0 (the-as adgif-shader (&+ (the-as pointer v1-6) 32))))
            (quad-copy! (the-as pointer s0-0) (the-as pointer s1-0) 5)
            (set! (-> s0-0 clamp)
                  (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp) :maxu #x1f :maxv #x1f))
            (set! (-> s0-0 alpha) (new 'static 'gs-alpha :b #x1 :d #x1))
            (set! (-> s0-0 prims 9) (gs-reg64 alpha-1))))
        (&+! (-> arg0 base) 112)
        ;; SCISSOR0
        (let* ((v1-12 arg0)
               (a0-6 (the-as object (-> v1-12 base))))
          (set! (-> (the-as dma-packet a0-6) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
          (set! (-> (the-as dma-packet a0-6) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet a0-6) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
          (set! (-> v1-12 base) (&+ (the-as pointer a0-6) 16)))
        (let* ((v1-13 arg0)
               (a0-8 (the-as object (-> v1-13 base))))
          (set! (-> (the-as gs-gif-tag a0-8) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
          (set! (-> (the-as gs-gif-tag a0-8) regs)
                (new 'static
                     'gif-tag-regs
                     :regs0 (gif-reg-id a+d)
                     :regs1 (gif-reg-id a+d)
                     :regs2 (gif-reg-id a+d)
                     :regs3 (gif-reg-id a+d)
                     :regs4 (gif-reg-id a+d)
                     :regs5 (gif-reg-id a+d)
                     :regs6 (gif-reg-id a+d)
                     :regs7 (gif-reg-id a+d)
                     :regs8 (gif-reg-id a+d)
                     :regs9 (gif-reg-id a+d)
                     :regs10 (gif-reg-id a+d)
                     :regs11 (gif-reg-id a+d)
                     :regs12 (gif-reg-id a+d)
                     :regs13 (gif-reg-id a+d)
                     :regs14 (gif-reg-id a+d)
                     :regs15 (gif-reg-id a+d)))
          (set! (-> v1-13 base) (&+ (the-as pointer a0-8) 16)))
        (let* ((v1-14 arg0)
               (a0-10 (-> v1-14 base)))
          (set! (-> (the-as (pointer gs-scissor) a0-10) 0) (new 'static 'gs-scissor :scax1 #x3f :scay1 (+ s2-0 31) :scay0 s2-0))
          (set! (-> (the-as (pointer gs-reg64) a0-10) 1) (gs-reg64 scissor-1))
          (set! (-> v1-14 base) (&+ a0-10 16)))
        ;; SPRITE0
        (let ((v1-15 (the-as (inline-array vector4w) (-> arg0 base))))
          (set! (-> v1-15 0 quad) (-> *eye-work* sprite-tmpl dma-vif quad))
          (set! (-> v1-15 1 quad) (-> *eye-work* sprite-tmpl quad 1))
          (set-vector! (-> v1-15 2) 128 128 128 128)
          (set-vector! (-> v1-15 3) 0 0 0 0)
          (set-vector! (-> v1-15 4) (* s4-0 16) (* s3-0 16) #xffffff 0)
          (set-vector! (-> v1-15 5) 0 0 0 0)
          (set-vector! (-> v1-15 6) (* (+ s4-0 64) 16) (* (+ s3-0 32) 16) #xffffff 0))
        (set! (-> arg0 base) (the-as pointer (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
        (let ((v1-20 (ash 16 (-> s1-0 tex0 tw)))
              (a0-30 (ash 16 (-> s1-0 tex0 th))))
          ;; SCISSOR1
          (let* ((a1-22 arg0)
                 (a2-7 (the-as object (-> a1-22 base))))
            (set! (-> (the-as dma-packet a2-7) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
            (set! (-> (the-as dma-packet a2-7) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a2-7) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
            (set! (-> a1-22 base) (&+ (the-as pointer a2-7) 16)))
          (let* ((a1-23 arg0)
                 (a2-9 (the-as object (-> a1-23 base))))
            (set! (-> (the-as gs-gif-tag a2-9) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
            (set! (-> (the-as gs-gif-tag a2-9) regs)
                  (new 'static
                       'gif-tag-regs
                       :regs0 (gif-reg-id a+d)
                       :regs1 (gif-reg-id a+d)
                       :regs2 (gif-reg-id a+d)
                       :regs3 (gif-reg-id a+d)
                       :regs4 (gif-reg-id a+d)
                       :regs5 (gif-reg-id a+d)
                       :regs6 (gif-reg-id a+d)
                       :regs7 (gif-reg-id a+d)
                       :regs8 (gif-reg-id a+d)
                       :regs9 (gif-reg-id a+d)
                       :regs10 (gif-reg-id a+d)
                       :regs11 (gif-reg-id a+d)
                       :regs12 (gif-reg-id a+d)
                       :regs13 (gif-reg-id a+d)
                       :regs14 (gif-reg-id a+d)
                       :regs15 (gif-reg-id a+d)))
            (set! (-> a1-23 base) (&+ (the-as pointer a2-9) 16)))
          (let* ((a1-24 arg0)
                 (a2-11 (-> a1-24 base)))
            (set! (-> (the-as (pointer gs-scissor) a2-11) 0) (new 'static 'gs-scissor :scax1 #x1f :scay1 (+ s2-0 31) :scay0 s2-0))
            (set! (-> (the-as (pointer gs-reg64) a2-11) 1) (gs-reg64 scissor-1))
            (set! (-> a1-24 base) (&+ a2-11 16)))
          ;; SPRITE1
          (let* ((f0-6 (* 256.0 (-> arg1 left iris-scale)))
                 (a1-25 (the-as (inline-array vector4w) (-> arg0 base)))
                 (a2-13 (the int (- f28-0 f0-6)))
                 (t0-5 (the int (- f26-0 f0-6)))
                 (a3-9 (the int (+ f28-0 f0-6)))
                 (t1-0 (the int (+ f26-0 f0-6))))
            (set! (-> a1-25 0 quad) (-> *eye-work* sprite-tmpl dma-vif quad))
            (set! (-> a1-25 1 quad) (-> *eye-work* sprite-tmpl quad 1))
            (set-vector! (-> a1-25 2) 128 128 128 128)
            (set-vector! (-> a1-25 3) 0 0 0 0)
            (set-vector! (-> a1-25 4) a2-13 t0-5 #xffffff 0)
            (set-vector! (-> a1-25 5) v1-20 a0-30 0 0)
            (set-vector! (-> a1-25 6) a3-9 t1-0 #xffffff 0))
          (set! (-> arg0 base) (the-as pointer (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
          ;; SCISSOR2
          (let* ((a1-29 arg0)
                 (a2-17 (the-as object (-> a1-29 base))))
            (set! (-> (the-as dma-packet a2-17) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
            (set! (-> (the-as dma-packet a2-17) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a2-17) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
            (set! (-> a1-29 base) (&+ (the-as pointer a2-17) 16)))
          (let* ((a1-30 arg0)
                 (a2-19 (the-as object (-> a1-30 base))))
            (set! (-> (the-as gs-gif-tag a2-19) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
            (set! (-> (the-as gs-gif-tag a2-19) regs)
                  (new 'static
                       'gif-tag-regs
                       :regs0 (gif-reg-id a+d)
                       :regs1 (gif-reg-id a+d)
                       :regs2 (gif-reg-id a+d)
                       :regs3 (gif-reg-id a+d)
                       :regs4 (gif-reg-id a+d)
                       :regs5 (gif-reg-id a+d)
                       :regs6 (gif-reg-id a+d)
                       :regs7 (gif-reg-id a+d)
                       :regs8 (gif-reg-id a+d)
                       :regs9 (gif-reg-id a+d)
                       :regs10 (gif-reg-id a+d)
                       :regs11 (gif-reg-id a+d)
                       :regs12 (gif-reg-id a+d)
                       :regs13 (gif-reg-id a+d)
                       :regs14 (gif-reg-id a+d)
                       :regs15 (gif-reg-id a+d)))
            (set! (-> a1-30 base) (&+ (the-as pointer a2-19) 16)))
          (let* ((a1-31 arg0)
                 (a2-21 (-> a1-31 base)))
            (set! (-> (the-as (pointer gs-scissor) a2-21) 0)
                  (new 'static 'gs-scissor :scax0 #x20 :scax1 #x3f :scay1 (+ s2-0 31) :scay0 s2-0))
            (set! (-> (the-as (pointer gs-reg64) a2-21) 1) (gs-reg64 scissor-1))
            (set! (-> a1-31 base) (&+ a2-21 16)))
          ;; SPRITE2
          (let* ((f0-10 (* 256.0 (-> arg1 right iris-scale)))
                 (a1-32 (the-as (inline-array vector4w) (-> arg0 base)))
                 (a2-23 (the int (- f30-0 f0-10)))
                 (t0-11 (the int (- sv-16 f0-10)))
                 (a3-20 (the int (+ f30-0 f0-10)))
                 (t1-2 (the int (+ sv-16 f0-10))))
            (set! (-> a1-32 0 quad) (-> *eye-work* sprite-tmpl dma-vif quad))
            (set! (-> a1-32 1 quad) (-> *eye-work* sprite-tmpl quad 1))
            (set-vector! (-> a1-32 2) 128 128 128 128)
            (set-vector! (-> a1-32 3) 0 0 0 0)
            (set-vector! (-> a1-32 4) a2-23 t0-11 #xffffff 0)
            (set-vector! (-> a1-32 5) v1-20 a0-30 0 0)
            (set-vector! (-> a1-32 6) a3-20 t1-2 #xffffff 0))))
      (set! (-> arg0 base) (the-as pointer (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
      (let* ((v1-24 arg0)
             (a0-32 (the-as object (-> v1-24 base))))
        (set! (-> (the-as dma-packet a0-32) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
        (set! (-> (the-as dma-packet a0-32) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet a0-32) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
        (set! (-> v1-24 base) (&+ (the-as pointer a0-32) 16)))
      (let* ((v1-25 arg0)
             (a0-34 (the-as object (-> v1-25 base))))
        (set! (-> (the-as gs-gif-tag a0-34) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
        (set! (-> (the-as gs-gif-tag a0-34) regs)
              (new 'static
                   'gif-tag-regs
                   :regs0 (gif-reg-id a+d)
                   :regs1 (gif-reg-id a+d)
                   :regs2 (gif-reg-id a+d)
                   :regs3 (gif-reg-id a+d)
                   :regs4 (gif-reg-id a+d)
                   :regs5 (gif-reg-id a+d)
                   :regs6 (gif-reg-id a+d)
                   :regs7 (gif-reg-id a+d)
                   :regs8 (gif-reg-id a+d)
                   :regs9 (gif-reg-id a+d)
                   :regs10 (gif-reg-id a+d)
                   :regs11 (gif-reg-id a+d)
                   :regs12 (gif-reg-id a+d)
                   :regs13 (gif-reg-id a+d)
                   :regs14 (gif-reg-id a+d)
                   :regs15 (gif-reg-id a+d)))
        (set! (-> v1-25 base) (&+ (the-as pointer a0-34) 16)))
      (let* ((v1-26 arg0)
             (a0-36 (-> v1-26 base)))
        (set! (-> (the-as (pointer gs-test) a0-36) 0) (new 'static 'gs-test :ate #x1 :afail #x3 :zte #x1 :ztst (gs-ztest always)))
        (set! (-> (the-as (pointer gs-reg64) a0-36) 1) (gs-reg64 test-1))
        (set! (-> v1-26 base) (&+ a0-36 16)))
      (let ((s1-1 (-> arg1 shaders 1)))
        (let ((v1-28 (the-as object (-> arg0 base))))
          (set! (-> (the-as (inline-array vector4w) v1-28) 0 quad) (-> *eye-work* adgif-tmpl dma-vif quad))
          (set! (-> (the-as (inline-array vector4w) v1-28) 1 quad) (-> *eye-work* adgif-tmpl quad 1))
          (let ((s0-1 (the-as adgif-shader (&+ (the-as pointer v1-28) 32))))
            (quad-copy! (the-as pointer s0-1) (the-as pointer s1-1) 5)
            (set! (-> s0-1 clamp)
                  (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp) :maxu #x1f :maxv #x1f))
            (set! (-> s0-1 alpha) (new 'static 'gs-alpha :b #x1 :d #x1))
            (set! (-> s0-1 prims 9) (gs-reg64 alpha-1))))
        (&+! (-> arg0 base) 112)
        (let ((v1-35 (ash 16 (-> s1-1 tex0 tw)))
              (a0-48 (ash 16 (-> s1-1 tex0 th))))
          (let* ((a1-45 arg0)
                 (a2-27 (the-as object (-> a1-45 base))))
            (set! (-> (the-as dma-packet a2-27) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
            (set! (-> (the-as dma-packet a2-27) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a2-27) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
            (set! (-> a1-45 base) (&+ (the-as pointer a2-27) 16)))
          (let* ((a1-46 arg0)
                 (a2-29 (the-as object (-> a1-46 base))))
            (set! (-> (the-as gs-gif-tag a2-29) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
            (set! (-> (the-as gs-gif-tag a2-29) regs)
                  (new 'static
                       'gif-tag-regs
                       :regs0 (gif-reg-id a+d)
                       :regs1 (gif-reg-id a+d)
                       :regs2 (gif-reg-id a+d)
                       :regs3 (gif-reg-id a+d)
                       :regs4 (gif-reg-id a+d)
                       :regs5 (gif-reg-id a+d)
                       :regs6 (gif-reg-id a+d)
                       :regs7 (gif-reg-id a+d)
                       :regs8 (gif-reg-id a+d)
                       :regs9 (gif-reg-id a+d)
                       :regs10 (gif-reg-id a+d)
                       :regs11 (gif-reg-id a+d)
                       :regs12 (gif-reg-id a+d)
                       :regs13 (gif-reg-id a+d)
                       :regs14 (gif-reg-id a+d)
                       :regs15 (gif-reg-id a+d)))
            (set! (-> a1-46 base) (&+ (the-as pointer a2-29) 16)))
          (let* ((a1-47 arg0)
                 (a2-31 (-> a1-47 base)))
            (set! (-> (the-as (pointer gs-scissor) a2-31) 0) (new 'static 'gs-scissor :scax1 #x1f :scay1 (+ s2-0 31) :scay0 s2-0))
            (set! (-> (the-as (pointer gs-reg64) a2-31) 1) (gs-reg64 scissor-1))
            (set! (-> a1-47 base) (&+ a2-31 16)))
          (let* ((f0-14 (* 256.0 (-> arg1 left pupil-scale)))
                 (a1-48 (the-as (inline-array vector4w) (-> arg0 base)))
                 (a2-33 (the int (- f28-0 f0-14)))
                 (t0-17 (the int (- f26-0 f0-14)))
                 (a3-30 (the int (+ f28-0 f0-14)))
                 (t1-3 (the int (+ f26-0 f0-14))))
            (set! (-> a1-48 0 quad) (-> *eye-work* sprite-tmpl2 dma-vif quad))
            (set! (-> a1-48 1 quad) (-> *eye-work* sprite-tmpl2 quad 1))
            (set-vector! (-> a1-48 2) 128 128 128 128)
            (set-vector! (-> a1-48 3) 0 0 0 0)
            (set-vector! (-> a1-48 4) a2-33 t0-17 #xffffff 0)
            (set-vector! (-> a1-48 5) v1-35 a0-48 0 0)
            (let ((a1-49 (the-as (inline-array vector4w) (-> a1-48 6))))
              (set! (-> a1-49 0 x) a3-30)
              (set! (-> a1-49 0 y) t1-3)
              (set! (-> a1-49 0 z) #xffffff)
              (set! (-> a1-49 0 w) 0)))
          (set! (-> arg0 base) (the-as pointer (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
          (let* ((a1-52 arg0)
                 (a2-37 (the-as object (-> a1-52 base))))
            (set! (-> (the-as dma-packet a2-37) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
            (set! (-> (the-as dma-packet a2-37) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a2-37) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
            (set! (-> a1-52 base) (&+ (the-as pointer a2-37) 16)))
          (let* ((a1-53 arg0)
                 (a2-39 (the-as object (-> a1-53 base))))
            (set! (-> (the-as gs-gif-tag a2-39) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
            (set! (-> (the-as gs-gif-tag a2-39) regs)
                  (new 'static
                       'gif-tag-regs
                       :regs0 (gif-reg-id a+d)
                       :regs1 (gif-reg-id a+d)
                       :regs2 (gif-reg-id a+d)
                       :regs3 (gif-reg-id a+d)
                       :regs4 (gif-reg-id a+d)
                       :regs5 (gif-reg-id a+d)
                       :regs6 (gif-reg-id a+d)
                       :regs7 (gif-reg-id a+d)
                       :regs8 (gif-reg-id a+d)
                       :regs9 (gif-reg-id a+d)
                       :regs10 (gif-reg-id a+d)
                       :regs11 (gif-reg-id a+d)
                       :regs12 (gif-reg-id a+d)
                       :regs13 (gif-reg-id a+d)
                       :regs14 (gif-reg-id a+d)
                       :regs15 (gif-reg-id a+d)))
            (set! (-> a1-53 base) (&+ (the-as pointer a2-39) 16)))
          (let* ((a1-54 arg0)
                 (a2-41 (-> a1-54 base)))
            (set! (-> (the-as (pointer gs-scissor) a2-41) 0)
                  (new 'static 'gs-scissor :scax0 #x20 :scax1 #x3f :scay1 (+ s2-0 31) :scay0 s2-0))
            (set! (-> (the-as (pointer gs-reg64) a2-41) 1) (gs-reg64 scissor-1))
            (set! (-> a1-54 base) (&+ a2-41 16)))
          (let* ((f0-18 (* 256.0 (-> arg1 right pupil-scale)))
                 (a1-55 (the-as (inline-array vector4w) (-> arg0 base)))
                 (a2-43 (the int (- f30-0 f0-18)))
                 (t0-23 (the int (- sv-16 f0-18)))
                 (a3-41 (the int (+ f30-0 f0-18)))
                 (t1-5 (the int (+ sv-16 f0-18))))
            (set! (-> a1-55 0 quad) (-> *eye-work* sprite-tmpl2 dma-vif quad))
            (set! (-> a1-55 1 quad) (-> *eye-work* sprite-tmpl2 quad 1))
            (set-vector! (-> a1-55 2) 128 128 128 128)
            (set-vector! (-> a1-55 3) 0 0 0 0)
            (set-vector! (-> a1-55 4) a2-43 t0-23 #xffffff 0)
            (set-vector! (-> a1-55 5) v1-35 a0-48 0 0)
            (set-vector! (-> a1-55 6) a3-41 t1-5 #xffffff 0)))))
    (set! (-> arg0 base) (the-as pointer (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
    (let* ((v1-39 arg0)
           (a0-50 (the-as object (-> v1-39 base))))
      (set! (-> (the-as dma-packet a0-50) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-50) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-50) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-39 base) (&+ (the-as pointer a0-50) 16)))
    (let* ((v1-40 arg0)
           (a0-52 (the-as object (-> v1-40 base))))
      (set! (-> (the-as gs-gif-tag a0-52) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-52) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-40 base) (&+ (the-as pointer a0-52) 16)))
    (let* ((v1-41 arg0)
           (a0-54 (-> v1-41 base)))
      (set! (-> (the-as (pointer gs-test) a0-54) 0)
            (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
      (set! (-> (the-as (pointer gs-reg64) a0-54) 1) (gs-reg64 test-1))
      (set! (-> v1-41 base) (&+ a0-54 16)))
    (let ((s1-2 (-> arg1 shaders 2)))
      (let ((v1-43 (the-as object (-> arg0 base))))
        (set! (-> (the-as dma-gif-packet v1-43) dma-vif quad) (-> *eye-work* adgif-tmpl dma-vif quad))
        (set! (-> (the-as dma-gif-packet v1-43) quad 1) (-> *eye-work* adgif-tmpl quad 1))
        (let ((s0-2 (the-as adgif-shader (&+ (the-as pointer v1-43) 32))))
          (quad-copy! (the-as pointer s0-2) (the-as pointer s1-2) 5)
          (set! (-> s0-2 clamp)
                (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp) :maxu #x1f :maxv #x1f))
          (set! (-> s0-2 alpha) (new 'static 'gs-alpha :a #x1))
          (set! (-> s0-2 prims 9) (gs-reg64 alpha-1))))
      (set! (-> arg0 base) (-> (the-as (inline-array dma-gif-packet) (-> arg0 base)) 3 gif))
      (let ((v1-50 (ash 16 (-> s1-2 tex0 tw)))
            (a0-66 (ash 16 (-> s1-2 tex0 th))))
        (when (< (-> arg1 left lid) 0.0)
          (let ((f0-23 (+ 1.0 (-> arg1 left lid)))) (set! (-> arg1 left lid) (+ f0-23 (* (- 1.0 f0-23) (-> arg1 blink))))))
        (let* ((a1-70 arg0)
               (a2-47 (the-as object (-> a1-70 base))))
          (set! (-> (the-as dma-packet a2-47) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
          (set! (-> (the-as dma-packet a2-47) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet a2-47) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
          (set! (-> a1-70 base) (&+ (the-as pointer a2-47) 16)))
        (let* ((a1-71 arg0)
               (a2-49 (the-as object (-> a1-71 base))))
          (set! (-> (the-as gs-gif-tag a2-49) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
          (set! (-> (the-as gs-gif-tag a2-49) regs)
                (new 'static
                     'gif-tag-regs
                     :regs0 (gif-reg-id a+d)
                     :regs1 (gif-reg-id a+d)
                     :regs2 (gif-reg-id a+d)
                     :regs3 (gif-reg-id a+d)
                     :regs4 (gif-reg-id a+d)
                     :regs5 (gif-reg-id a+d)
                     :regs6 (gif-reg-id a+d)
                     :regs7 (gif-reg-id a+d)
                     :regs8 (gif-reg-id a+d)
                     :regs9 (gif-reg-id a+d)
                     :regs10 (gif-reg-id a+d)
                     :regs11 (gif-reg-id a+d)
                     :regs12 (gif-reg-id a+d)
                     :regs13 (gif-reg-id a+d)
                     :regs14 (gif-reg-id a+d)
                     :regs15 (gif-reg-id a+d)))
          (set! (-> a1-71 base) (&+ (the-as pointer a2-49) 16)))
        (let* ((a1-72 arg0)
               (a2-51 (-> a1-72 base)))
          (set! (-> (the-as (pointer gs-scissor) a2-51) 0) (new 'static 'gs-scissor :scax1 #x1f :scay1 (+ s2-0 31) :scay0 s2-0))
          (set! (-> (the-as (pointer gs-reg64) a2-51) 1) (gs-reg64 scissor-1))
          (set! (-> a1-72 base) (&+ a2-51 16)))
        (let* ((f0-27 (+ (the float (+ s3-0 -32)) (* 32.0 (-> arg1 left lid))))
               (a1-74 (the-as (inline-array vector4w) (-> arg0 base)))
               (a2-53 (* s4-0 16))
               (t0-29 (the int (* 16.0 f0-27)))
               (a3-52 (* (+ s4-0 32) 16))
               (t1-6 (the int (* 16.0 (+ f0-27 (* 32.0 (-> arg1 left lid-scale)))))))
          (set! (-> a1-74 0 quad) (-> *eye-work* sprite-tmpl2 dma-vif quad))
          (set! (-> a1-74 1 quad) (-> *eye-work* sprite-tmpl2 quad 1))
          (set-vector! (-> a1-74 2) 128 128 128 0)
          (set-vector! (-> a1-74 3) 0 0 0 0)
          (set-vector! (-> a1-74 4) a2-53 t0-29 #xffffff 0)
          (set-vector! (-> a1-74 5) v1-50 a0-66 0 0)
          (set-vector! (-> a1-74 6) a3-52 t1-6 #xffffff 0))
        (set! (-> arg0 base) (the-as pointer (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
        (when (< (-> arg1 right lid) 0.0)
          (let ((f0-33 (+ 1.0 (-> arg1 right lid)))) (set! (-> arg1 right lid) (+ f0-33 (* (- 1.0 f0-33) (-> arg1 blink))))))
        (let* ((a1-80 arg0)
               (a2-57 (the-as object (-> a1-80 base))))
          (set! (-> (the-as dma-packet a2-57) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
          (set! (-> (the-as dma-packet a2-57) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet a2-57) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
          (set! (-> a1-80 base) (&+ (the-as pointer a2-57) 16)))
        (let* ((a1-81 arg0)
               (a2-59 (the-as object (-> a1-81 base))))
          (set! (-> (the-as gs-gif-tag a2-59) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
          (set! (-> (the-as gs-gif-tag a2-59) regs)
                (new 'static
                     'gif-tag-regs
                     :regs0 (gif-reg-id a+d)
                     :regs1 (gif-reg-id a+d)
                     :regs2 (gif-reg-id a+d)
                     :regs3 (gif-reg-id a+d)
                     :regs4 (gif-reg-id a+d)
                     :regs5 (gif-reg-id a+d)
                     :regs6 (gif-reg-id a+d)
                     :regs7 (gif-reg-id a+d)
                     :regs8 (gif-reg-id a+d)
                     :regs9 (gif-reg-id a+d)
                     :regs10 (gif-reg-id a+d)
                     :regs11 (gif-reg-id a+d)
                     :regs12 (gif-reg-id a+d)
                     :regs13 (gif-reg-id a+d)
                     :regs14 (gif-reg-id a+d)
                     :regs15 (gif-reg-id a+d)))
          (set! (-> a1-81 base) (&+ (the-as pointer a2-59) 16)))
        (let* ((a1-82 arg0)
               (a2-61 (-> a1-82 base)))
          (set! (-> (the-as (pointer gs-scissor) a2-61) 0)
                (new 'static 'gs-scissor :scax0 #x20 :scax1 #x3f :scay1 (+ s2-0 31) :scay0 s2-0))
          (set! (-> (the-as (pointer gs-reg64) a2-61) 1) (gs-reg64 scissor-1))
          (set! (-> a1-82 base) (&+ a2-61 16)))
        (let* ((f0-37 (+ (the float (+ s3-0 -32)) (* 32.0 (-> arg1 right lid))))
               (a1-84 (the-as (inline-array vector4w) (-> arg0 base)))
               (a2-64 (* (+ s4-0 64) 16))
               (t0-35 (the int (* 16.0 f0-37)))
               (a3-63 (* (+ s4-0 32) 16))
               (t1-7 (the int (* 16.0 (+ f0-37 (* 32.0 (-> arg1 left lid-scale)))))))
          (set! (-> a1-84 0 quad) (-> *eye-work* sprite-tmpl2 dma-vif quad))
          (set! (-> a1-84 1 quad) (-> *eye-work* sprite-tmpl2 quad 1))
          (set-vector! (-> a1-84 2) 128 128 128 0)
          (set-vector! (-> a1-84 3) 0 0 0 0)
          (set-vector! (-> a1-84 4) a2-64 t0-35 #xffffff 0)
          (set-vector! (-> a1-84 5) v1-50 a0-66 0 0)
          (set-vector! (-> a1-84 6) a3-63 t1-7 #xffffff 0)))))
  (let ((v0-3 (-> (the-as (inline-array vector4w) (-> arg0 base)) 7)))
    (set! (-> arg0 base) (the-as pointer v0-3))
    (the-as pointer v0-3)))

(defun update-eyes ()
  ;; Setup GS for level 0 eyes
  (let* ((s5-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
         (gp-0 (-> s5-0 base)))
    (set-display-gs-state-offset s5-0 *eyes-base-page* 64 352 0 0 32 32)
    (let* ((v1-3 s5-0)
           (a0-4 (the-as object (-> v1-3 base))))
      (set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-3 base) (&+ (the-as pointer a0-4) 16)))
    (let* ((v1-4 s5-0)
           (a0-6 (the-as object (-> v1-4 base))))
      (set! (-> (the-as gs-gif-tag a0-6) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-6) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-4 base) (&+ (the-as pointer a0-6) 16)))
    (let* ((v1-5 s5-0)
           (a0-8 (-> v1-5 base)))
      (set! (-> (the-as (pointer gs-test) a0-8) 0)
            (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
      (set! (-> (the-as (pointer gs-reg64) a0-8) 1) (gs-reg64 test-1))
      (set! (-> v1-5 base) (&+ a0-8 16)))
    (let ((a3-1 (-> s5-0 base)))
      (let ((v1-6 (the-as object (-> s5-0 base))))
        (set! (-> (the-as dma-packet v1-6) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
        (set! (-> (the-as dma-packet v1-6) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet v1-6) vif1) (new 'static 'vif-tag))
        (set! (-> s5-0 base) (&+ (the-as pointer v1-6) 16)))
      (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                             (bucket-id pris-tex0)
                             gp-0
                             (the-as (pointer dma-tag) a3-1))))
  ;; Setup GS for level 1 eyes
  (let* ((s5-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
         (gp-1 (-> s5-1 base)))
    (set-display-gs-state-offset s5-1 *eyes-base-page* 64 352 0 0 32 32)
    (let* ((v1-15 s5-1)
           (a0-19 (the-as object (-> v1-15 base))))
      (set! (-> (the-as dma-packet a0-19) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-19) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-19) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-15 base) (&+ (the-as pointer a0-19) 16)))
    (let* ((v1-16 s5-1)
           (a0-21 (the-as object (-> v1-16 base))))
      (set! (-> (the-as gs-gif-tag a0-21) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-21) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-16 base) (&+ (the-as pointer a0-21) 16)))
    (let* ((v1-17 s5-1)
           (a0-23 (-> v1-17 base)))
      (set! (-> (the-as (pointer gs-test) a0-23) 0)
            (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
      (set! (-> (the-as (pointer gs-reg64) a0-23) 1) (gs-reg64 test-1))
      (set! (-> v1-17 base) (&+ a0-23 16)))
    (let ((a3-3 (-> s5-1 base)))
      (let ((v1-18 (the-as object (-> s5-1 base))))
        (set! (-> (the-as dma-packet v1-18) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
        (set! (-> (the-as dma-packet v1-18) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet v1-18) vif1) (new 'static 'vif-tag))
        (set! (-> s5-1 base) (&+ (the-as pointer v1-18) 16)))
      (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                             (bucket-id pris-tex1)
                             gp-1
                             (the-as (pointer dma-tag) a3-3))))
  ;; Setup GS for common eyes
  (let* ((s5-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
         (gp-2 (-> s5-2 base)))
    (set-display-gs-state-offset s5-2 *eyes-base-page* 64 352 0 0 32 32)
    (let* ((v1-27 s5-2)
           (a0-34 (the-as object (-> v1-27 base))))
      (set! (-> (the-as dma-packet a0-34) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-34) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-34) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-27 base) (&+ (the-as pointer a0-34) 16)))
    (let* ((v1-28 s5-2)
           (a0-36 (the-as object (-> v1-28 base))))
      (set! (-> (the-as gs-gif-tag a0-36) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-36) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-28 base) (&+ (the-as pointer a0-36) 16)))
    (let* ((v1-29 s5-2)
           (a0-38 (-> v1-29 base)))
      (set! (-> (the-as (pointer gs-test) a0-38) 0)
            (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
      (set! (-> (the-as (pointer gs-reg64) a0-38) 1) (gs-reg64 test-1))
      (set! (-> v1-29 base) (&+ a0-38 16)))
    (let ((a3-5 (-> s5-2 base)))
      (let ((v1-30 (the-as object (-> s5-2 base))))
        (set! (-> (the-as dma-packet v1-30) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
        (set! (-> (the-as dma-packet v1-30) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet v1-30) vif1) (new 'static 'vif-tag))
        (set! (-> s5-2 base) (&+ (the-as pointer v1-30) 16)))
      (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                             (bucket-id eyes)
                             gp-2
                             (the-as (pointer dma-tag) a3-5))))
  ;; rendering of eyes.
  (dotimes (gp-3 11)
    ;; grab the eye and the process
    (let* ((s5-3 (-> *eye-control-array* data gp-3))
           (v1-40 (handle->process (-> s5-3 process))))
      ;; see if we need the eye
      (when (and v1-40
                 (logtest? (-> (the-as process-drawable v1-40) skel status) (janim-status eye))
                 (logtest? (-> (the-as process-drawable v1-40) draw status) (draw-status was-drawn)))
        (when (-> s5-3 shaders)
          ;; update blinking
          (when (not (paused?))
            (cond
              ((and (>= (-> s5-3 left lid) 0.0) (>= (-> s5-3 right lid) 0.0))
               (set! (-> s5-3 random-time)
                     (the int
                          (* (/ 1.0 (-> *display* time-adjust-ratio)) ;; og:preserve-this changed for high fps
                             (the-as uint 60))))
               (set! (-> s5-3 blink) 0.0))
              (else
               (+! (-> s5-3 random-time) -1)
               (let ((v1-54 (-> s5-3 random-time)))
                 (when (< v1-54 (the-as uint 10))
                   (set! (-> s5-3 blink) (-> *eye-work* blink-table v1-54))
                   (if (zero? v1-54)
                     (set! (-> s5-3 random-time) (the-as uint (the int (* (1/ DISPLAY_FPS_RATIO) (rand-vu-float-range 60.0 240.0)))))))))))
          ;; pick between level and common eyes
          (cond
            ((>= (the-as uint 1) (-> s5-3 level))
             ;; level eyes
             (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
                    (s4-0 (-> s3-0 base)))
               (render-eyes s3-0 s5-3 gp-3)
               (let ((a3-6 (-> s3-0 base)))
                 (let ((v1-59 (the-as object (-> s3-0 base))))
                   (set! (-> (the-as dma-packet v1-59) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
                   (set! (-> (the-as dma-packet v1-59) vif0) (new 'static 'vif-tag))
                   (set! (-> (the-as dma-packet v1-59) vif1) (new 'static 'vif-tag))
                   (set! (-> s3-0 base) (&+ (the-as pointer v1-59) 16)))
                 (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                                        (the-as bucket-id (if (zero? (-> s5-3 level)) (bucket-id pris-tex0) (bucket-id pris-tex1)))
                                        s4-0
                                        (the-as (pointer dma-tag) a3-6)))))
            (else
             (let* ((s3-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
                    (s4-1 (-> s3-1 base)))
               (render-eyes s3-1 s5-3 gp-3)
               (let ((a3-7 (-> s3-1 base)))
                 (let ((v1-69 (the-as object (-> s3-1 base))))
                   (set! (-> (the-as dma-packet v1-69) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
                   (set! (-> (the-as dma-packet v1-69) vif0) (new 'static 'vif-tag))
                   (set! (-> (the-as dma-packet v1-69) vif1) (new 'static 'vif-tag))
                   (set! (-> s3-1 base) (&+ (the-as pointer v1-69) 16)))
                 (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                                        (bucket-id eyes)
                                        s4-1
                                        (the-as (pointer dma-tag) a3-7))))))))))
  (let* ((s5-4 (-> *display* frames (-> *display* on-screen) frame global-buf))
         (gp-4 (-> s5-4 base)))
    (reset-display-gs-state *display* s5-4 *oddeven*)
    (let* ((v1-80 s5-4)
           (a0-85 (the-as object (-> v1-80 base))))
      (set! (-> (the-as dma-packet a0-85) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-85) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-85) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-80 base) (&+ (the-as pointer a0-85) 16)))
    (let* ((v1-81 s5-4)
           (a0-87 (the-as object (-> v1-81 base))))
      (set! (-> (the-as gs-gif-tag a0-87) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-87) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-81 base) (&+ (the-as pointer a0-87) 16)))
    (let* ((v1-82 s5-4)
           (a0-89 (-> v1-82 base)))
      (set! (-> (the-as (pointer gs-reg64) a0-89) 0) (gs-reg64 dimx))
      (set! (-> (the-as (pointer gs-reg64) a0-89) 1) (gs-reg64 alpha-1))
      (set! (-> v1-82 base) (&+ a0-89 16)))
    (let ((a3-8 (-> s5-4 base)))
      (let ((v1-83 (the-as object (-> s5-4 base))))
        (set! (-> (the-as dma-packet v1-83) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
        (set! (-> (the-as dma-packet v1-83) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet v1-83) vif1) (new 'static 'vif-tag))
        (set! (-> s5-4 base) (&+ (the-as pointer v1-83) 16)))
      (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                             (bucket-id pris-tex0)
                             gp-4
                             (the-as (pointer dma-tag) a3-8))))
  (let* ((s5-5 (-> *display* frames (-> *display* on-screen) frame global-buf))
         (gp-5 (-> s5-5 base)))
    (reset-display-gs-state *display* s5-5 *oddeven*)
    (let* ((v1-92 s5-5)
           (a0-100 (the-as object (-> v1-92 base))))
      (set! (-> (the-as dma-packet a0-100) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-100) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-100) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-92 base) (&+ (the-as pointer a0-100) 16)))
    (let* ((v1-93 s5-5)
           (a0-102 (the-as object (-> v1-93 base))))
      (set! (-> (the-as gs-gif-tag a0-102) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-102) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-93 base) (&+ (the-as pointer a0-102) 16)))
    (let* ((v1-94 s5-5)
           (a0-104 (-> v1-94 base)))
      (set! (-> (the-as (pointer gs-reg64) a0-104) 0) (gs-reg64 dimx))
      (set! (-> (the-as (pointer gs-reg64) a0-104) 1) (gs-reg64 alpha-1))
      (set! (-> v1-94 base) (&+ a0-104 16)))
    (let ((a3-9 (-> s5-5 base)))
      (let ((v1-95 (the-as object (-> s5-5 base))))
        (set! (-> (the-as dma-packet v1-95) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
        (set! (-> (the-as dma-packet v1-95) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet v1-95) vif1) (new 'static 'vif-tag))
        (set! (-> s5-5 base) (&+ (the-as pointer v1-95) 16)))
      (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                             (bucket-id pris-tex1)
                             gp-5
                             (the-as (pointer dma-tag) a3-9))))
  (let* ((s5-6 (-> *display* frames (-> *display* on-screen) frame global-buf))
         (gp-6 (-> s5-6 base)))
    (reset-display-gs-state *display* s5-6 *oddeven*)
    (let* ((v1-104 s5-6)
           (a0-115 (the-as object (-> v1-104 base))))
      (set! (-> (the-as dma-packet a0-115) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
      (set! (-> (the-as dma-packet a0-115) vif0) (new 'static 'vif-tag))
      (set! (-> (the-as dma-packet a0-115) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
      (set! (-> v1-104 base) (&+ (the-as pointer a0-115) 16)))
    (let* ((v1-105 s5-6)
           (a0-117 (the-as object (-> v1-105 base))))
      (set! (-> (the-as gs-gif-tag a0-117) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
      (set! (-> (the-as gs-gif-tag a0-117) regs)
            (new 'static
                 'gif-tag-regs
                 :regs0 (gif-reg-id a+d)
                 :regs1 (gif-reg-id a+d)
                 :regs2 (gif-reg-id a+d)
                 :regs3 (gif-reg-id a+d)
                 :regs4 (gif-reg-id a+d)
                 :regs5 (gif-reg-id a+d)
                 :regs6 (gif-reg-id a+d)
                 :regs7 (gif-reg-id a+d)
                 :regs8 (gif-reg-id a+d)
                 :regs9 (gif-reg-id a+d)
                 :regs10 (gif-reg-id a+d)
                 :regs11 (gif-reg-id a+d)
                 :regs12 (gif-reg-id a+d)
                 :regs13 (gif-reg-id a+d)
                 :regs14 (gif-reg-id a+d)
                 :regs15 (gif-reg-id a+d)))
      (set! (-> v1-105 base) (&+ (the-as pointer a0-117) 16)))
    (let* ((v1-106 s5-6)
           (a0-119 (-> v1-106 base)))
      (set! (-> (the-as (pointer gs-reg64) a0-119) 0) (gs-reg64 dimx))
      (set! (-> (the-as (pointer gs-reg64) a0-119) 1) (gs-reg64 alpha-1))
      (set! (-> v1-106 base) (&+ a0-119 16)))
    (let ((a3-10 (-> s5-6 base)))
      (let ((v1-107 (the-as object (-> s5-6 base))))
        (set! (-> (the-as dma-packet v1-107) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
        (set! (-> (the-as dma-packet v1-107) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet v1-107) vif1) (new 'static 'vif-tag))
        (set! (-> s5-6 base) (&+ (the-as pointer v1-107) 16)))
      (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                             (bucket-id eyes)
                             gp-6
                             (the-as (pointer dma-tag) a3-10))))
  0
  (none))

(defun get-eye-block ((arg0 int) (arg1 int))
  (#when PC_PORT
    ;; hack to make this easier to figure out on the PC side.
    (return (+ *eyes-base-block* (* arg0 2) arg1)))
  (let ((v1-0 arg0)
        (a0-4 (-> ct32-24-block-table (* arg1 4))))
    (+ *eyes-base-block* (* v1-0 32) a0-4)))

(defun convert-eye-data ((arg0 eye) (arg1 uint))
  (local-vars (v0-0 float) (v1-0 uint128) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (v1-4 uint128) (v1-5 uint128))
  (rlet ((vf1 :class vf)
         (vf2 :class vf))
    (.pextlb v1-0 arg1 0)
    (.pextlh v1-1 v1-0 0)
    (.pw.sra v1-2 v1-1 16)
    (.mov vf1 v1-2)
    (.pextlb v1-3 0 arg1)
    (.pextuh v1-4 0 v1-3)
    (.pw.sll v1-5 v1-4 6)
    (.mov vf2 v1-5)
    (vitof15.xyzw vf1 vf1)
    (vitof12.xyzw vf2 vf2)
    (.svf (&-> arg0 data 0 quad) vf1)
    (.svf (&-> arg0 data 1 quad) vf2)
    (.mov v0-0 vf2)
    v0-0))

(defun merc-eye-anim ((arg0 process-drawable))
  (let* ((s5-0 (-> arg0 draw mgeo header eye-ctrl))
         (a0-1 (-> arg0 skel root-channel 0))
         (s4-0 (-> a0-1 frame-group)))
    (when (and (logtest? (-> arg0 skel status) (janim-status eye))
               (nonzero? s5-0)
               (> (-> arg0 skel active-channels) 0)
               s4-0
               (nonzero? (-> s4-0 eye-anim-data)))
      (let* ((v1-15 (-> *eye-control-array* data (-> s5-0 eye-slot)))
             (s3-1 (min (the int (-> a0-1 frame-num)) (-> s4-0 eye-anim-data max-frame)))
             (s2-1 (min (+ (the int (-> a0-1 frame-num)) 1) (-> s4-0 eye-anim-data max-frame)))
             (f0-4 (-> a0-1 frame-num))
             (f30-0 (- f0-4 (* (the float (the int (/ f0-4 1.0))) 1.0))))
        (set! (-> v1-15 process) (process->handle arg0))
        (set! (-> v1-15 shaders) (the-as (inline-array adgif-shader) (-> s5-0 iris-shader)))
        (set! (-> v1-15 level)
              (the-as uint (-> (if (-> arg0 entity) (-> arg0 entity extra level) (-> *level* level-default)) index)))
        (let ((s1-0 (new 'stack-no-clear 'eye))
              (s0-0 (new 'stack-no-clear 'eye)))
          (cond
            ((-> s4-0 eye-anim-data)
             (convert-eye-data s1-0 (-> s4-0 eye-anim-data data (* s3-1 2) dword))
             (convert-eye-data s0-0 (-> s4-0 eye-anim-data data (* s2-1 2) dword))
             (vector4-lerp! (the-as vector (+ (the-as uint (-> *eye-control-array* data 0 left)) (* 96 (-> s5-0 eye-slot))))
                            (the-as vector (-> s1-0 data))
                            (the-as vector (-> s0-0 data))
                            f30-0)
             (vector4-lerp! (the-as vector (+ (the-as uint (-> *eye-control-array* data 0 left data 1)) (* 96 (-> s5-0 eye-slot))))
                            (-> s1-0 data 1)
                            (-> s0-0 data 1)
                            f30-0)
             (convert-eye-data s1-0 (-> s4-0 eye-anim-data data (+ (* s3-1 2) 1) dword))
             (convert-eye-data s0-0 (-> s4-0 eye-anim-data data (+ (* s2-1 2) 1) dword))
             (vector4-lerp! (the-as vector (+ (the-as uint (-> *eye-control-array* data 0 right)) (* 96 (-> s5-0 eye-slot))))
                            (the-as vector (-> s1-0 data))
                            (the-as vector (-> s0-0 data))
                            f30-0)
             (vector4-lerp! (the-as vector (+ (the-as uint (-> *eye-control-array* data 0 right data 1)) (* 96 (-> s5-0 eye-slot))))
                            (-> s1-0 data 1)
                            (-> s0-0 data 1)
                            f30-0))
            (else
             (let ((v1-37 (-> *eye-control-array* data (-> s5-0 eye-slot))))
               (set! (-> v1-37 left data 0 x) 0.0)
               (set! (-> v1-37 left data 0 y) 0.0)
               (set! (-> v1-37 left data 0 z) -1.0)
               (set! (-> v1-37 left data 1 x) 1.0)
               (set! (-> v1-37 left data 1 y) 1.0)
               (set! (-> v1-37 left data 1 z) 1.0)
               (set! (-> v1-37 right data 0 x) 0.0)
               (set! (-> v1-37 right data 0 y) 0.0)
               (set! (-> v1-37 right data 0 z) -1.0)
               (set! (-> v1-37 right data 1 x) 1.0)
               (set! (-> v1-37 right data 1 y) 1.0)
               (set! (-> v1-37 right data 1 z) 1.0))))))
      (logior! (-> arg0 skel status) (janim-status eye-done))))
  (if (logtest? (-> arg0 skel status) (janim-status eye-done)) (logclear! (-> arg0 skel status) (janim-status eye-done)))
  0
  (none))
