;;-*-Lisp-*-
(in-package goal)

;; definition for symbol *depth-cue-work*, type depth-cue-work
(define *depth-cue-work*
  (new 'static 'depth-cue-work
    :texture-strip-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 #x50ab400000008001 #x43431)
      )
    :temp-strip-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 #x43431)
      )
    :stencil-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #x17 :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #x17 :cmd (vif-cmd direct) :msk #x1)
        )
      :gif (new 'static 'array uint64 2 #xb003400000008002 #x44444444441)
      )
    :set-color (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)
    :draw-color (new 'static 'vector4w :x #x84 :y #x84 :z #x84 :w #x80)
    :depth (new 'static 'depth-cue-data :data (new 'static 'vector :x 1.0 :z 163840.0))
    :front (new 'static 'depth-cue-data :data (new 'static 'vector :x 0.999 :y 0.4 :z 4096.0 :w 1.0))
    )
  )

;; definition for function depth-cue-set-stencil
;; INFO: Used lq/sq
(defun depth-cue-set-stencil ((arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 dma-gif-packet))
  (let* ((v1-0 arg0)
         (t1-0 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet t1-0) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet t1-0) vif0) (new 'static 'vif-tag))
    (set! (-> (the-as dma-packet t1-0) vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1))
    (set! (-> v1-0 base) (&+ (the-as pointer t1-0) 16))
    )
  (let* ((v1-1 arg0)
         (t1-2 (the-as object (-> v1-1 base)))
         )
    (set! (-> (the-as gs-gif-tag t1-2) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3))
    (set! (-> (the-as gs-gif-tag t1-2) 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-1 base) (&+ (the-as pointer t1-2) 16))
    )
  (let* ((v1-2 arg0)
         (t1-4 (-> v1-2 base))
         )
    (set! (-> (the-as (pointer gs-xy-offset) t1-4) 0)
          (new 'static 'gs-xy-offset :ofx #x7000 :ofy (+ (* (-> *video-parms* screen-miny) 16) arg3))
          )
    (set! (-> (the-as (pointer gs-reg64) t1-4) 1) (gs-reg64 xyoffset-1))
    (set! (-> (the-as (pointer gs-frame) t1-4) 2) (new 'static 'gs-frame :fbw #x8 :fbmsk #xffffff :fbp arg1))
    (set! (-> (the-as (pointer gs-reg64) t1-4) 3) (gs-reg64 frame-1))
    (set! (-> (the-as (pointer gs-test) t1-4) 4) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)))
    (set! (-> (the-as (pointer gs-reg64) t1-4) 5) (gs-reg64 test-1))
    (set! (-> v1-2 base) (&+ t1-4 48))
    )
  (let ((a3-7 (the-as (inline-array vector4w) (-> arg0 base)))
        (v1-3 #x7000)
        (a1-8 1024)
        )
    (set! (-> a3-7 0 quad) (-> *depth-cue-work* stencil-tmpl dma-vif quad))
    (set! (-> a3-7 1 quad) (-> *depth-cue-work* stencil-tmpl quad 1))
    (let ((v0-0 (the-as object (-> a3-7 2))))
      (dotimes (a3-8 2)
        (set! (-> (the-as (inline-array vector4w) v0-0) 0 quad) (-> arg4 dma-vif quad))
        (set! v0-0 (-> (the-as (inline-array vector4w) v0-0) 1))
        (dotimes (t1-10 5)
          (set-vector! (-> (the-as (inline-array vector4w) v0-0) 0) v1-3 (* (-> *video-parms* screen-miny) 16) arg2 0)
          (set-vector!
            (-> (the-as (inline-array vector4w) v0-0) 1)
            (+ v1-3 a1-8)
            (* (-> *video-parms* screen-maxy) 16)
            arg2
            #x10000
            )
          (+! v1-3 a1-8)
          (set! v0-0 (-> (the-as (inline-array vector4w) v0-0) 2))
          )
        )
      (set! (-> arg0 base) (the-as pointer v0-0))
      (the-as vector4w v0-0)
      )
    )
  )

;; definition for function depth-cue-draw-depth
;; INFO: Used lq/sq
(defun depth-cue-draw-depth ((arg0 dma-buffer) (arg1 int) (arg2 float) (arg3 float) (arg4 int) (arg5 int))
  (set! (-> *depth-cue-work* draw-color w) (the int (* 128.0 arg3)))
  (let ((v1-1 (the int (* 512.0 arg2)))
        (a2-1 (the int (* (the float (* (-> *video-parms* screen-sy) 16)) arg2)))
        (a3-4 0)
        (t2-0 512)
        (t3-0 *depth-cue-base-page*)
        )
    (dotimes (t4-0 16)
      (let* ((t5-0 arg0)
             (t6-0 (the-as object (-> t5-0 base)))
             )
        (set! (-> (the-as dma-packet t6-0) dma) (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt)))
        (set! (-> (the-as dma-packet t6-0) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet t6-0) vif1) (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd direct) :msk #x1))
        (set! (-> t5-0 base) (the-as pointer (the-as gs-gif-tag (&+ (the-as pointer t6-0) 16))))
        )
      (let* ((t5-1 arg0)
             (t6-2 (the-as object (-> t5-1 base)))
             )
        (set! (-> (the-as gs-gif-tag t6-2) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x4))
        (set! (-> (the-as gs-gif-tag t6-2) 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! (-> t5-1 base) (&+ (the-as pointer t6-2) 16))
        )
      (let* ((t5-2 arg0)
             (t6-4 (-> t5-2 base))
             )
        (set! (-> (the-as (pointer gs-xy-offset) t6-4) 0) (new 'static 'gs-xy-offset :ofy (- 8 arg5)))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 1) (gs-reg64 xyoffset-1))
        (set! (-> (the-as (pointer gs-frame) t6-4) 2) (new 'static 'gs-frame :fbw #x1 :fbp t3-0))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 3) (gs-reg64 frame-1))
        (set! (-> (the-as (pointer gs-tex0) t6-4) 4)
              (new 'static 'gs-tex0 :tbw #x8 :tw #xa :th #x8 :tcc #x1 :tbp0 (* arg4 32))
              )
        (set! (-> (the-as (pointer gs-reg64) t6-4) 5) (gs-reg64 tex0-1))
        (set! (-> (the-as (pointer gs-test) t6-4) 6) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 7) (gs-reg64 test-1))
        (set! (-> t5-2 base) (&+ t6-4 64))
        )
      (let ((t5-3 (the-as (inline-array vector4w) (-> arg0 base))))
        (set! (-> t5-3 0 quad) (-> *depth-cue-work* temp-strip-tmpl dma-vif quad))
        (set! (-> t5-3 1 quad) (-> *depth-cue-work* temp-strip-tmpl quad 1))
        (set! (-> t5-3 2 quad) (-> *depth-cue-work* set-color quad))
        (set-vector! (-> t5-3 3) a3-4 0 0 0)
        (set-vector! (-> t5-3 4) 0 0 0 0)
        (set-vector! (-> t5-3 5) (+ a3-4 t2-0) (* (-> *video-parms* screen-sy) 16) 0 0)
        (set-vector! (-> t5-3 6) v1-1 a2-1 0 #x10000)
        )
      (set! (-> arg0 base) (the-as pointer (-> (the-as depth-cue-work (-> arg0 base)) set-color)))
      (let* ((t5-7 arg0)
             (t6-16 (the-as object (-> t5-7 base)))
             )
        (set! (-> (the-as dma-packet t6-16) dma) (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt)))
        (set! (-> (the-as dma-packet t6-16) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet t6-16) vif1) (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd direct) :msk #x1))
        (set! (-> t5-7 base) (&+ (the-as pointer t6-16) 16))
        )
      (let* ((t5-8 arg0)
             (t6-18 (the-as object (-> t5-8 base)))
             )
        (set! (-> (the-as gs-gif-tag t6-18) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x4))
        (set! (-> (the-as gs-gif-tag t6-18) 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! (-> t5-8 base) (&+ (the-as pointer t6-18) 16))
        )
      (let* ((t5-9 arg0)
             (t6-20 (-> t5-9 base))
             )
        (set! (-> (the-as (pointer gs-xy-offset) t6-20) 0) (new 'static 'gs-xy-offset :ofy (+ arg5 4)))
        (set! (-> (the-as (pointer gs-reg64) t6-20) 1) (gs-reg64 xyoffset-1))
        (set! (-> (the-as (pointer gs-frame) t6-20) 2) (new 'static 'gs-frame :fbw #x8 :fbmsk #xff000000 :fbp arg4))
        (set! (-> (the-as (pointer gs-reg64) t6-20) 3) (gs-reg64 frame-1))
        (set! (-> (the-as (pointer gs-tex0) t6-20) 4)
              (new 'static 'gs-tex0 :tbw #x1 :tw #x5 :th #x8 :tcc #x1 :tbp0 (* t3-0 32))
              )
        (set! (-> (the-as (pointer gs-reg64) t6-20) 5) (gs-reg64 tex0-1))
        (set! (-> (the-as (pointer gs-test) t6-20) 6)
              (new 'static 'gs-test :date #x1 :datm #x1 :zte #x1 :ztst (gs-ztest always))
              )
        (set! (-> (the-as (pointer gs-reg64) t6-20) 7) (gs-reg64 test-1))
        (set! (-> t5-9 base) (&+ t6-20 64))
        )
      (let ((t5-10 (the-as object (-> arg0 base))))
        (set! (-> (the-as (inline-array vector4w) t5-10) 0 quad)
              (-> *depth-cue-work* texture-strip-tmpl dma-vif quad)
              )
        (set! (-> (the-as (inline-array vector4w) t5-10) 1 quad) (-> *depth-cue-work* texture-strip-tmpl quad 1))
        (set! (-> (the-as (inline-array vector4w) t5-10) 2 quad) (-> *depth-cue-work* draw-color quad))
        (set-vector! (-> (the-as (inline-array vector4w) t5-10) 3) 0 0 0 0)
        (set-vector! (-> (the-as (inline-array vector4w) t5-10) 4) a3-4 0 0 0)
        (set-vector! (-> (the-as (inline-array vector4w) t5-10) 5) v1-1 a2-1 0 0)
        (set-vector!
          (the-as vector4w (&+ (the-as pointer t5-10) 96))
          (+ a3-4 t2-0)
          (* (-> *video-parms* screen-sy) 16)
          arg1
          #x10000
          )
        )
      (set! (-> arg0 base) (the-as pointer (-> (the-as depth-cue-work (-> arg0 base)) set-color)))
      (+! a3-4 t2-0)
      )
    )
  #f
  )

;; definition for function depth-cue-draw-front
;; INFO: Used lq/sq
(defun depth-cue-draw-front ((arg0 dma-buffer) (arg1 int) (arg2 float) (arg3 float) (arg4 uint) (arg5 int))
  (set! (-> *depth-cue-work* draw-color w) (the int (* 128.0 arg3)))
  (let ((v1-1 (the int (* 512.0 arg2)))
        (a2-1 (the int (* (the float (* (-> *video-parms* screen-sy) 16)) arg2)))
        (a3-4 0)
        (t2-0 512)
        (t3-0 *depth-cue-base-page*)
        )
    (dotimes (t4-0 16)
      (let* ((t5-0 arg0)
             (t6-0 (the-as object (-> t5-0 base)))
             )
        (set! (-> (the-as dma-packet t6-0) dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)))
        (set! (-> (the-as dma-packet t6-0) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet t6-0) vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
        (set! (-> t5-0 base) (the-as pointer (the-as gs-gif-tag (&+ (the-as pointer t6-0) 16))))
        )
      (let* ((t5-1 arg0)
             (t6-2 (the-as object (-> t5-1 base)))
             )
        (set! (-> (the-as gs-gif-tag t6-2) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5))
        (set! (-> (the-as gs-gif-tag t6-2) 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! (-> t5-1 base) (&+ (the-as pointer t6-2) 16))
        )
      (let* ((t5-2 arg0)
             (t6-4 (-> t5-2 base))
             )
        (set! (-> (the-as (pointer gs-xy-offset) t6-4) 0) (new 'static 'gs-xy-offset :ofy (- 8 arg5)))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 1) (gs-reg64 xyoffset-1))
        (set! (-> (the-as (pointer gs-frame) t6-4) 2) (new 'static 'gs-frame :fbw #x1 :fbp t3-0))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 3) (gs-reg64 frame-1))
        (set! (-> (the-as (pointer gs-tex0) t6-4) 4)
              (new 'static 'gs-tex0 :tbw #x8 :tw #xa :th #x8 :tcc #x1 :tbp0 (* arg4 32))
              )
        (set! (-> (the-as (pointer gs-reg64) t6-4) 5) (gs-reg64 tex0-1))
        (set! (-> (the-as (pointer gs-test) t6-4) 6) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 7) (gs-reg64 test-1))
        (set! (-> (the-as (pointer gs-alpha) t6-4) 8) (new 'static 'gs-alpha))
        (set! (-> (the-as (pointer gs-reg64) t6-4) 9) (gs-reg64 alpha-1))
        (set! (-> t5-2 base) (&+ t6-4 80))
        )
      (let ((t5-3 (the-as (inline-array vector4w) (-> arg0 base))))
        (set! (-> t5-3 0 quad) (-> *depth-cue-work* temp-strip-tmpl dma-vif quad))
        (set! (-> t5-3 1 quad) (-> *depth-cue-work* temp-strip-tmpl quad 1))
        (set! (-> t5-3 2 quad) (-> *depth-cue-work* set-color quad))
        (set-vector! (-> t5-3 3) a3-4 0 0 0)
        (set-vector! (-> t5-3 4) 0 0 0 0)
        (set-vector! (-> t5-3 5) (+ a3-4 t2-0) (* (-> *video-parms* screen-sy) 16) 0 0)
        (set-vector! (-> t5-3 6) v1-1 a2-1 0 #x10000)
        )
      (set! (-> arg0 base) (the-as pointer (-> (the-as depth-cue-work (-> arg0 base)) set-color)))
      (let* ((t5-7 arg0)
             (t6-16 (the-as object (-> t5-7 base)))
             )
        (set! (-> (the-as dma-packet t6-16) dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)))
        (set! (-> (the-as dma-packet t6-16) vif0) (new 'static 'vif-tag))
        (set! (-> (the-as dma-packet t6-16) vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
        (set! (-> t5-7 base) (the-as pointer (the-as gs-gif-tag (&+ (the-as pointer t6-16) 16))))
        )
      (let* ((t5-8 arg0)
             (t6-18 (the-as object (-> t5-8 base)))
             )
        (set! (-> (the-as gs-gif-tag t6-18) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5))
        (set! (-> (the-as gs-gif-tag t6-18) 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! (-> t5-8 base) (&+ (the-as pointer t6-18) 16))
        )
      (let* ((t5-9 arg0)
             (t6-20 (-> t5-9 base))
             )
        (set! (-> (the-as (pointer gs-xy-offset) t6-20) 0) (new 'static 'gs-xy-offset :ofy (+ arg5 4)))
        (set! (-> (the-as (pointer gs-reg64) t6-20) 1) (gs-reg64 xyoffset-1))
        (set! (-> (the-as (pointer gs-frame) t6-20) 2) (new 'static 'gs-frame :fbw #x8 :fbmsk #xff000000 :fbp arg4))
        (set! (-> (the-as (pointer gs-reg64) t6-20) 3) (gs-reg64 frame-1))
        (set! (-> (the-as (pointer gs-texa) t6-20) 4) (new 'static 'gs-texa :ta0 #x80 :ta1 #x80))
        (set! (-> (the-as (pointer gs-reg64) t6-20) 5) (gs-reg64 texa))
        (set! (-> (the-as (pointer gs-tex0) t6-20) 6)
              (new 'static 'gs-tex0 :tbw #x1 :psm #x1 :tw #x5 :th #x8 :tbp0 (* t3-0 32))
              )
        (set! (-> (the-as (pointer gs-reg64) t6-20) 7) (gs-reg64 tex0-1))
        (set! (-> (the-as (pointer gs-alpha) t6-20) 8) (new 'static 'gs-alpha :b #x1 :d #x1))
        (set! (-> (the-as (pointer gs-reg64) t6-20) 9) (gs-reg64 alpha-1))
        (set! (-> t5-9 base) (&+ t6-20 80))
        )
      (let ((t5-10 (the-as object (-> arg0 base))))
        (set! (-> (the-as (inline-array vector4w) t5-10) 0 quad)
              (-> *depth-cue-work* texture-strip-tmpl dma-vif quad)
              )
        (set! (-> (the-as (inline-array vector4w) t5-10) 1 quad) (-> *depth-cue-work* texture-strip-tmpl quad 1))
        (set! (-> (the-as (inline-array vector4w) t5-10) 2 quad) (-> *depth-cue-work* draw-color quad))
        (set-vector! (-> (the-as (inline-array vector4w) t5-10) 3) 0 0 0 0)
        (set-vector! (-> (the-as (inline-array vector4w) t5-10) 4) a3-4 0 0 0)
        (set-vector! (-> (the-as (inline-array vector4w) t5-10) 5) v1-1 a2-1 0 0)
        (set-vector!
          (the-as vector4w (&+ (the-as pointer t5-10) 96))
          (+ a3-4 t2-0)
          (* (-> *video-parms* screen-sy) 16)
          arg1
          #x10000
          )
        )
      (set! (-> arg0 base) (the-as pointer (-> (the-as depth-cue-work (-> arg0 base)) set-color)))
      (+! a3-4 t2-0)
      )
    )
  #f
  )

;; definition for function depth-cue-calc-z
(defun depth-cue-calc-z ((arg0 float))
  (+ (* (+ (* arg0 (-> *math-camera* perspective vector 2 z)) (-> *math-camera* perspective vector 3 z))
        (/ (-> *math-camera* d) arg0)
        )
     (-> *math-camera* hvdf-off z)
     )
  )

;; definition for function depth-cue
(defun depth-cue ((arg0 display))
  (when (logtest? (vu1-renderer-mask depth-cue) *vu1-enable-user*)
    (let* ((gp-0 (-> *display* frames (-> *display* on-screen) frame global-buf base))
           (s4-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
           (s5-0 (-> s4-0 base))
           )
      (let ((v1-9 (-> arg0 on-screen)))
        (let* ((a1-7 s4-0)
               (a2-0 (the-as object (-> a1-7 base)))
               )
          (set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)))
          (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet a2-0) vif1) (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1))
          (set! (-> a1-7 base) (&+ (the-as pointer a2-0) 16))
          )
        (let* ((a1-8 s4-0)
               (a2-2 (the-as object (-> a1-8 base)))
               )
          (set! (-> (the-as gs-gif-tag a2-2) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6))
          (set! (-> (the-as gs-gif-tag a2-2) 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-8 base) (&+ (the-as pointer a2-2) 16))
          )
        (let* ((a1-9 s4-0)
               (a2-4 (-> a1-9 base))
               )
          (set! (-> (the-as (pointer gs-test) a2-4) 0) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 1) (gs-reg64 test-1))
          (set! (-> (the-as (pointer gs-zbuf) a2-4) 2) (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24) :zmsk #x1))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 3) (gs-reg64 zbuf-1))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 4) (gs-reg64 signal))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 5) (gs-reg64 tex1-1))
          (set! (-> (the-as (pointer gs-tex1) a2-4) 6) (new 'static 'gs-tex1))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 7) (gs-reg64 miptbp1-1))
          (set! (-> (the-as (pointer gs-clamp) a2-4) 8) (new 'static 'gs-clamp
                                                          :wms (gs-tex-wrap-mode clamp)
                                                          :wmt (gs-tex-wrap-mode clamp)
                                                          :maxu #x1ff
                                                          :maxv (-> *video-parms* screen-masky)
                                                          )
                )
          (set! (-> (the-as (pointer gs-reg64) a2-4) 9) (gs-reg64 clamp-1))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 10) (gs-reg64 dimx))
          (set! (-> (the-as (pointer gs-reg64) a2-4) 11) (gs-reg64 alpha-1))
          (set! (-> a1-9 base) (&+ a2-4 96))
          )
        (let ((s3-0 (* *oddeven* 8))
              (s2-0 (-> arg0 frames v1-9 draw frame1 fbp))
              )
          (depth-cue-draw-front
            s4-0
            #xffffff
            (-> *depth-cue-work* front data x)
            (-> *depth-cue-work* front data y)
            s2-0
            s3-0
            )
          (let* ((v1-19 s4-0)
                 (a0-2 (the-as object (-> v1-19 base)))
                 )
            (set! (-> (the-as dma-packet a0-2) dma) (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)))
            (set! (-> (the-as dma-packet a0-2) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a0-2) vif1) (new 'static 'vif-tag :imm #x3 :cmd (vif-cmd direct) :msk #x1))
            (set! (-> v1-19 base) (&+ (the-as pointer a0-2) 16))
            )
          (let* ((v1-20 s4-0)
                 (a0-4 (the-as object (-> v1-20 base)))
                 )
            (set! (-> (the-as gs-gif-tag a0-4) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x2))
            (set! (-> (the-as gs-gif-tag a0-4) 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-20 base) (&+ (the-as pointer a0-4) 16))
            )
          (let* ((v1-21 s4-0)
                 (a0-6 (-> v1-21 base))
                 )
            (set! (-> (the-as (pointer gs-xy-offset) a0-6) 0)
                  (new 'static 'gs-xy-offset :ofx #x7000 :ofy (+ (* (-> *video-parms* screen-miny) 16) s3-0))
                  )
            (set! (-> (the-as (pointer gs-reg64) a0-6) 1) (gs-reg64 xyoffset-1))
            (set! (-> (the-as (pointer gs-frame) a0-6) 2) (new 'static 'gs-frame :fbw #x8 :fbp s2-0))
            (set! (-> (the-as (pointer gs-reg64) a0-6) 3) (gs-reg64 frame-1))
            (set! (-> v1-21 base) (&+ a0-6 32))
            )
          )
        )
      (let ((a3-18 (-> s4-0 base)))
        (let ((v1-22 (the-as object (-> s4-0 base))))
          (set! (-> (the-as dma-packet v1-22) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
          (set! (-> (the-as dma-packet v1-22) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet v1-22) vif1) (new 'static 'vif-tag))
          (set! (-> s4-0 base) (&+ (the-as pointer v1-22) 16))
          )
        (let ((v0-0 (dma-bucket-insert-tag
                      (-> *display* frames (-> *display* on-screen) frame bucket-group)
                      (bucket-id depth-cue)
                      s5-0
                      (the-as (pointer dma-tag) a3-18)
                      )
                    )
              )
          (let ((v1-27 *dma-mem-usage*))
            (when (nonzero? v1-27)
              (set! (-> v1-27 length) (max 84 (-> v1-27 length)))
              (set! (-> v1-27 data 83 name) "depth-cue")
              (+! (-> v1-27 data 83 count) 1)
              (+! (-> v1-27 data 83 used)
                  (&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint gp-0))
                  )
              (set! (-> v1-27 data 83 total) (-> v1-27 data 83 used))
              )
            )
          v0-0
          )
        )
      )
    )
  )
