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

;; definition for method 9 of type tfragment
(defmethod login tfragment ((obj tfragment))
  (dotimes (s5-0 (the-as int (-> obj num-shaders)))
    (adgif-shader-login-no-remap (-> obj shader s5-0))
    )
  obj
  )

;; definition for method 8 of type tfragment
(defmethod mem-usage tfragment ((obj tfragment) (arg0 memory-usage-block) (arg1 int))
  (when (logtest? arg1 2)
    (+! (-> arg0 data 19 count) 1)
    (let ((v1-6 (+ (-> obj num-base-colors) (-> obj num-level0-colors) (-> obj num-level1-colors))))
      (+! (-> arg0 data 19 used) v1-6)
      (+! (-> arg0 data 19 total) (logand -4 (+ v1-6 3)))
      )
    (set! obj obj)
    (goto cfg-16)
    )
  (let ((s4-0 1))
    (set! (-> arg0 length) (max (-> arg0 length) (+ s4-0 8)))
    (set! (-> arg0 data s4-0 name) (symbol->string 'tfragment))
    (+! (-> arg0 data s4-0 count) 1)
    (let ((v1-22 (asize-of obj)))
      (+! (-> arg0 data s4-0 used) v1-22)
      (+! (-> arg0 data s4-0 total) (logand -16 (+ v1-22 15)))
      )
    (set! (-> arg0 data (+ s4-0 1) name) "tfragment-base")
    (+! (-> arg0 data (+ s4-0 1) count) 1)
    (let ((v1-33 (* (-> obj dma-qwc 0) 16)))
      (+! (-> arg0 data (+ s4-0 1) used) v1-33)
      (+! (-> arg0 data (+ s4-0 1) total) v1-33)
      )
    (set! (-> arg0 data (+ s4-0 2) name) "tfragment-common")
    (+! (-> arg0 data (+ s4-0 2) count) 1)
    (let ((v1-43 (* (- (-> obj dma-qwc 1) (-> obj dma-qwc 0)) 16)))
      (+! (-> arg0 data (+ s4-0 2) used) v1-43)
      (+! (-> arg0 data (+ s4-0 2) total) v1-43)
      )
    (set! (-> arg0 data (+ s4-0 3) name) "tfragment-level0")
    (when (nonzero? (-> obj num-level0-colors))
      (+! (-> arg0 data (+ s4-0 3) count) 1)
      (let ((v1-55 (* (- (-> obj dma-qwc 2) (-> obj dma-qwc 0)) 16)))
        (+! (-> arg0 data (+ s4-0 3) used) v1-55)
        (+! (-> arg0 data (+ s4-0 3) total) v1-55)
        )
      )
    (set! (-> arg0 data (+ s4-0 4) name) "tfragment-level1")
    (when (not (or (= (-> obj dma-level-1) (-> obj dma-common))
                   (= (-> obj dma-level-1) (-> obj dma-base))
                   (zero? (-> obj num-level1-colors))
                   )
               )
      (+! (-> arg0 data (+ s4-0 4) count) 1)
      (let ((v1-70
              (* (- (-> obj dma-qwc 3)
                    (the-as
                      uint
                      (- (/ (the-as int (- (-> obj dma-level-1) (-> obj dma-common))) 16) (the-as int (-> obj dma-qwc 0)))
                      )
                    )
                 16
                 )
              )
            )
        (+! (-> arg0 data (+ s4-0 4) used) v1-70)
        (+! (-> arg0 data (+ s4-0 4) total) v1-70)
        )
      )
    (set! (-> arg0 data (+ s4-0 5) name) "tfragment-color")
    (+! (-> arg0 data (+ s4-0 5) count) 1)
    (let ((v1-79
            (if (logtest? arg1 1)
                0
                (the-as int (* (+ (-> obj num-base-colors) (-> obj num-level0-colors) (-> obj num-level1-colors)) 2))
                )
            )
          )
      (+! (-> arg0 data (+ s4-0 5) used) v1-79)
      (+! (-> arg0 data (+ s4-0 5) total) (logand -16 (+ v1-79 15)))
      )
    (set! (-> arg0 data (+ s4-0 6) name) "tfragment-debug")
    )
  (label cfg-16)
  obj
  )

;; definition for method 3 of type drawable-inline-array-tfrag
(defmethod inspect drawable-inline-array-tfrag ((obj drawable-inline-array-tfrag))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Tdata[~D]: @ #x~X~%" (-> obj length) (-> obj data))
  (dotimes (s5-0 (-> obj length))
    (format #t "~T  [~D] ~A~%" s5-0 (-> obj data s5-0))
    )
  obj
  )

;; definition for method 9 of type drawable-inline-array-tfrag
(defmethod login drawable-inline-array-tfrag ((obj drawable-inline-array-tfrag))
  (dotimes (s5-0 (-> obj length))
    (login (-> obj data s5-0))
    )
  obj
  )

;; definition for method 8 of type drawable-inline-array-tfrag
(defmethod mem-usage drawable-inline-array-tfrag ((obj drawable-inline-array-tfrag) (arg0 memory-usage-block) (arg1 int))
  (set! (-> arg0 length) (max 1 (-> arg0 length)))
  (set! (-> arg0 data 0 name) (symbol->string 'drawable-group))
  (+! (-> arg0 data 0 count) 1)
  (let ((v1-7 32))
    (+! (-> arg0 data 0 used) v1-7)
    (+! (-> arg0 data 0 total) (logand -16 (+ v1-7 15)))
    )
  (dotimes (s3-0 (-> obj length))
    (mem-usage (-> obj data s3-0) arg0 arg1)
    )
  obj
  )

;; definition for method 8 of type drawable-tree-tfrag
(defmethod mem-usage drawable-tree-tfrag ((obj drawable-tree-tfrag) (arg0 memory-usage-block) (arg1 int))
  (set! (-> arg0 length) (max 1 (-> arg0 length)))
  (set! (-> arg0 data 0 name) "drawable-group")
  (+! (-> arg0 data 0 count) 1)
  (let ((v1-6 (asize-of obj)))
    (+! (-> arg0 data 0 used) v1-6)
    (+! (-> arg0 data 0 total) (logand -16 (+ v1-6 15)))
    )
  (when (nonzero? (-> obj time-of-day-pal))
    (set! (-> arg0 length) (max 9 (-> arg0 length)))
    (set! (-> arg0 data 8 name) "tfragment-pal")
    (+! (-> arg0 data 8 count) 1)
    (let ((v1-18 (asize-of (-> obj time-of-day-pal))))
      (+! (-> arg0 data 8 used) v1-18)
      (+! (-> arg0 data 8 total) (logand -16 (+ v1-18 15)))
      )
    )
  (dotimes (s3-0 (-> obj length))
    (mem-usage (-> obj arrays s3-0) arg0 arg1)
    )
  obj
  )

;; definition for method 5 of type drawable-inline-array-tfrag
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of drawable-inline-array-tfrag ((obj drawable-inline-array-tfrag))
  (the-as int (+ (-> drawable-inline-array-tfrag size) (* (+ (-> obj length) -1) 64)))
  )

;; definition for symbol *tfrag-display-stats*, type symbol
(define *tfrag-display-stats* #f)

;; definition for symbol tfrag-vu1-block, type vu-function
(define tfrag-vu1-block (new 'static 'vu-function :length #x74b :qlength #x3a6))

;; definition for function tfrag-data-setup
;; INFO: Return type mismatch tfrag-data vs none.
;; Used lq/sq
(defun tfrag-data-setup ((arg0 tfrag-data) (arg1 int))
  (let ((v1-0 *math-camera*))
    (set-vector! (-> arg0 fog) (-> v1-0 pfog0) (-> v1-0 fog-min) (-> v1-0 fog-max) 3072.0)
    (set-vector! (-> arg0 val) 0.5 1.0 2048.0 0.0)
    (set-vector! (-> arg0 ambient) 1.0 1.0 1.0 1.0)
    (cond
      ((zero? *subdivide-draw-mode*)
       (set! (-> arg0 strgif tag)
             (new 'static 'gif-tag64
               :pre #x1
               :nreg #x3
               :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1 :abe arg1)
               )
             )
       (set! (-> arg0 fangif tag)
             (new 'static 'gif-tag64
               :pre #x1
               :nreg #x3
               :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1 :abe arg1)
               )
             )
       )
      ((= *subdivide-draw-mode* 1)
       (set! (-> arg0 strgif tag)
             (new 'static 'gif-tag64
               :pre #x1
               :nreg #x3
               :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1 :abe arg1)
               )
             )
       (set! (-> arg0 fangif tag)
             (new 'static 'gif-tag64
               :pre #x1
               :nreg #x3
               :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1 :abe arg1)
               )
             )
       )
      ((= *subdivide-draw-mode* 2)
       (set! (-> arg0 strgif tag)
             (new 'static 'gif-tag64
               :pre #x1
               :nreg #x3
               :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1 :abe arg1)
               )
             )
       (set! (-> arg0 fangif tag)
             (new 'static 'gif-tag64
               :pre #x1
               :nreg #x3
               :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :fge #x1 :abe arg1)
               )
             )
       )
      )
    (set! (-> arg0 strgif regs)
          (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))
          )
    (set! (-> arg0 fangif regs)
          (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))
          )
    (set! (-> arg0 adgif tag) (new 'static 'gif-tag64 :nloop #x5 :nreg #x1))
    (set! (-> arg0 adgif regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d)))
    (set! (-> arg0 hvdf-offset quad) (-> v1-0 hvdf-off quad))
    (set! (-> arg0 hmge-scale quad) (-> v1-0 hmge-scale quad))
    (set! (-> arg0 invh-scale quad) (-> v1-0 inv-hmge-scale quad))
    (set! (-> arg0 guard quad) (-> v1-0 guard quad))
    )
  (set-tfrag-dists! (-> arg0 dists))
  (none)
  )

;; definition for function add-tfrag-mtx-0
;; INFO: Return type mismatch pointer vs none.
(defun add-tfrag-mtx-0 ((arg0 dma-buffer))
  (let* ((a1-0 4)
         (v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a1-0))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a0-1) vif1)
          (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd unpack-v4-32) :num a1-0)
          )
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  (column-scale-matrix!
    (the-as matrix (-> arg0 base))
    (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)
    (-> *math-camera* camera-temp)
    )
  (&+! (-> arg0 base) 64)
  (none)
  )

;; definition for function add-tfrag-mtx-1
;; INFO: Return type mismatch pointer vs none.
(defun add-tfrag-mtx-1 ((arg0 dma-buffer))
  (let* ((a1-0 4)
         (v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a1-0))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a0-1) vif1)
          (new 'static 'vif-tag :imm #x14d :cmd (vif-cmd unpack-v4-32) :num a1-0)
          )
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  (column-scale-matrix!
    (the-as matrix (-> arg0 base))
    (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)
    (-> *math-camera* camera-temp)
    )
  (&+! (-> arg0 base) 64)
  (none)
  )

;; definition for function add-tfrag-data
;; INFO: Return type mismatch pointer vs none.
(defun add-tfrag-data ((arg0 dma-buffer) (arg1 int))
  (let* ((a2-0 14)
         (v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a2-0))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a0-1) vif1)
          (new 'static 'vif-tag :imm #x290 :cmd (vif-cmd unpack-v4-32) :num a2-0)
          )
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  (tfrag-data-setup (the-as tfrag-data (-> arg0 base)) arg1)
  (&+! (-> arg0 base) 224)
  (let ((v1-3 (the-as object (-> arg0 base))))
    (set! (-> (the-as dma-packet v1-3) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet v1-3) vif0) (new 'static 'vif-tag))
    (set! (-> (the-as dma-packet v1-3) vif1) (new 'static 'vif-tag :cmd (vif-cmd mscal) :msk #x1))
    (set! (-> arg0 base) (&+ (the-as pointer v1-3) 16))
    )
  (none)
  )

;; definition for symbol t-stat, type tfrag-stats
(define t-stat (new 'global 'tfrag-stats))

;; definition for function tfrag-print-stats
;; INFO: Return type mismatch symbol vs none.
(defun tfrag-print-stats ((arg0 symbol))
  (when (and *tfrag-display-stats* (!= *master-mode* 'menu))
    (format arg0 "~%")
    (format arg0 "tris:   ~8d~%" (-> t-stat tris))
    (format arg0 "verts:  ~8d~%" (+ (-> t-stat base-verts) (-> t-stat level0-verts) (-> t-stat level1-verts)))
    (format arg0 " base:  ~8d~%" (-> t-stat base-verts))
    (format arg0 " lev0:  ~8d~%" (-> t-stat level0-verts))
    (format arg0 " lev1:  ~8d~%" (-> t-stat level1-verts))
    (format arg0 "tfaces: ~8d~%" (-> t-stat tfaces))
    (format arg0 "tfrags: ~8d~%" (-> t-stat tfrags))
    (format arg0 "dtris:  ~8d~%" (-> t-stat dtris))
    (format arg0 "dps:    ~8d~%" (-> t-stat drawpoints))
    (format arg0 "strips: ~8d~%" (-> t-stat strips))
    (format arg0 "shaders:~8d~%" (-> t-stat dma-tex))
    (format arg0 "tri/str:~8f~%" (/ (the float (-> t-stat dtris)) (the float (-> t-stat strips))))
    (format arg0 "dma-cnt:~8d (~8d)~%" (-> t-stat dma-cnt) (* (-> t-stat dma-cnt) 32))
    (format arg0 "dma-dta:~8d (~8d)~%" (-> t-stat dma-dta) (/ (* 33 (-> t-stat dma-dta)) 10))
    (let ((f0-4 (* 32.0 (the float (-> t-stat dma-cnt))))
          (f1-5 (* 3.3 (the float (-> t-stat dma-dta))))
          (f2-3 (* 30.0 (the float (-> t-stat tfrags))))
          )
      (+ f0-4 f1-5 f2-3)
      )
    )
  (none)
  )

;; failed to figure out what this is:
(set! (-> t-stat from) 0)

;; failed to figure out what this is:
(set! (-> t-stat to) 0)

;; failed to figure out what this is:
(set! (-> t-stat cnt) 0)

;; definition for function tfrag-init-buffer
;; INFO: Return type mismatch symbol vs none.
(defun tfrag-init-buffer ((arg0 dma-buffer) (arg1 gs-test) (arg2 int))
  (dma-buffer-add-vu-function arg0 tfrag-vu1-block 1)
  (let* ((v1-0 arg0)
         (a0-2 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-2) dma) (new 'static 'dma-tag :qwc #x2 :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 #x2 :cmd (vif-cmd direct) :msk #x1))
    (set! (-> v1-0 base) (&+ (the-as pointer a0-2) 16))
    )
  (let* ((v1-1 arg0)
         (a0-4 (the-as object (-> v1-1 base)))
         )
    (set! (-> (the-as gs-gif-tag a0-4) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
    (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-1 base) (&+ (the-as pointer a0-4) 16))
    )
  (let* ((v1-2 arg0)
         (a0-6 (-> v1-2 base))
         )
    (set! (-> (the-as (pointer gs-test) a0-6) 0) arg1)
    (set! (-> (the-as (pointer gs-reg64) a0-6) 1) (gs-reg64 test-1))
    (set! (-> v1-2 base) (&+ a0-6 16))
    )
  (add-tfrag-mtx-0 arg0)
  (add-tfrag-mtx-1 arg0)
  (add-tfrag-data arg0 arg2)
  (let ((v1-3 (the-as object (-> arg0 base))))
    (set! (-> (the-as dma-packet v1-3) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet v1-3) vif0) (new 'static 'vif-tag :cmd (vif-cmd base)))
    (set! (-> (the-as dma-packet v1-3) vif1) (new 'static 'vif-tag :imm #x148 :cmd (vif-cmd offset)))
    (set! (-> arg0 base) (&+ (the-as pointer v1-3) 16))
    )
  (set! (-> *tfrag-work* last-call) (the-as uint 0))
  (set! (-> t-stat cnt) 0)
  (set! (-> t-stat tris) 0)
  (set! (-> t-stat tfaces) 0)
  (set! (-> t-stat tfrags) 0)
  (set! (-> t-stat dtris) 0)
  (set! (-> t-stat dma-cnt) 0)
  (set! (-> t-stat dma-dta) 0)
  (set! (-> t-stat dma-tex) 0)
  (set! (-> t-stat strips) 0)
  (set! (-> t-stat drawpoints) 0)
  (set! (-> t-stat base-verts) 0)
  (set! (-> t-stat level0-verts) 0)
  (set! (-> t-stat level1-verts) 0)
  (none)
  )

;; definition for function tfrag-end-buffer
;; INFO: Return type mismatch symbol vs none.
(defun tfrag-end-buffer ((arg0 dma-buffer))
  (let* ((v1-0 arg0)
         (a1-0 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a1-0) dma) (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet a1-0) vif0) (new 'static 'vif-tag :cmd (vif-cmd stmask)))
    (set! (-> (the-as dma-packet a1-0) vif1) (new 'static 'vif-tag))
    (set! (-> v1-0 base) (&+ (the-as pointer a1-0) 16))
    )
  (let* ((v1-1 arg0)
         (a0-1 (-> v1-1 base))
         )
    (set! (-> (the-as (pointer vif-tag) a0-1) 0) (the-as vif-tag (-> *tfrag-work* last-call)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 1) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1))
    (set! (-> (the-as (pointer vif-tag) a0-1) 2) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 3) (new 'static 'vif-tag :cmd (vif-cmd strow) :msk #x1))
    (set! (-> (the-as (pointer uint32) a0-1) 4) (the-as uint 0))
    (set! (-> (the-as (pointer uint32) a0-1) 5) (the-as uint 0))
    (set! (-> (the-as (pointer uint32) a0-1) 6) (the-as uint 0))
    (set! (-> (the-as (pointer uint32) a0-1) 7) (the-as uint 0))
    (set! (-> (the-as (pointer vif-tag) a0-1) 8) (new 'static 'vif-tag :cmd (vif-cmd base)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 9) (new 'static 'vif-tag :cmd (vif-cmd offset)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 10) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 11) (new 'static 'vif-tag))
    (set! (-> v1-1 base) (&+ a0-1 48))
    )
  (none)
  )

;; definition for function draw-inline-array-tfrag
;; ERROR: function was not converted to expressions. Cannot decompile.

;; definition for function tfrag-near-init-buffer
;; INFO: Return type mismatch symbol vs none.
(defun tfrag-near-init-buffer ((arg0 dma-buffer) (arg1 gs-test) (arg2 int))
  (dma-buffer-add-vu-function arg0 tnear-vu1-block 1)
  (let* ((v1-0 arg0)
         (a0-2 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-2) dma) (new 'static 'dma-tag :qwc #x2 :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 #x2 :cmd (vif-cmd direct) :msk #x1))
    (set! (-> v1-0 base) (&+ (the-as pointer a0-2) 16))
    )
  (let* ((v1-1 arg0)
         (a0-4 (the-as object (-> v1-1 base)))
         )
    (set! (-> (the-as gs-gif-tag a0-4) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
    (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-1 base) (&+ (the-as pointer a0-4) 16))
    )
  (let* ((v1-2 arg0)
         (a0-6 (-> v1-2 base))
         )
    (set! (-> (the-as (pointer gs-test) a0-6) 0) arg1)
    (set! (-> (the-as (pointer gs-reg64) a0-6) 1) (gs-reg64 test-1))
    (set! (-> v1-2 base) (&+ a0-6 16))
    )
  (add-tfrag-mtx-0 arg0)
  (add-tfrag-mtx-1 arg0)
  (add-tfrag-data arg0 arg2)
  (let ((v1-3 (the-as object (-> arg0 base))))
    (set! (-> (the-as dma-packet v1-3) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet v1-3) vif0) (new 'static 'vif-tag :cmd (vif-cmd base)))
    (set! (-> (the-as dma-packet v1-3) vif1) (new 'static 'vif-tag :imm #x148 :cmd (vif-cmd offset)))
    (set! (-> arg0 base) (&+ (the-as pointer v1-3) 16))
    )
  (set! (-> *tfrag-work* last-call) (the-as uint 0))
  (none)
  )

;; definition for function tfrag-near-end-buffer
;; INFO: Return type mismatch symbol vs none.
(defun tfrag-near-end-buffer ((arg0 dma-buffer))
  (let* ((v1-0 arg0)
         (a1-0 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a1-0) dma) (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet a1-0) vif0) (new 'static 'vif-tag :cmd (vif-cmd stmask)))
    (set! (-> (the-as dma-packet a1-0) vif1) (new 'static 'vif-tag))
    (set! (-> v1-0 base) (&+ (the-as pointer a1-0) 16))
    )
  (let* ((v1-1 arg0)
         (a0-1 (-> v1-1 base))
         )
    (set! (-> (the-as (pointer uint32) a0-1)) (-> *tfrag-work* last-call))
    (set! (-> (the-as (pointer vif-tag) a0-1) 1) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1))
    (set! (-> (the-as (pointer vif-tag) a0-1) 2) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 3) (new 'static 'vif-tag :cmd (vif-cmd strow) :msk #x1))
    (set! (-> (the-as (pointer uint32) a0-1) 4) (the-as uint 0))
    (set! (-> (the-as (pointer uint32) a0-1) 5) (the-as uint 0))
    (set! (-> (the-as (pointer uint32) a0-1) 6) (the-as uint 0))
    (set! (-> (the-as (pointer uint32) a0-1) 7) (the-as uint 0))
    (set! (-> (the-as (pointer vif-tag) a0-1) 8) (new 'static 'vif-tag :cmd (vif-cmd base)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 9) (new 'static 'vif-tag :cmd (vif-cmd offset)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 10) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as (pointer vif-tag) a0-1) 11) (new 'static 'vif-tag))
    (set! (-> v1-1 base) (&+ a0-1 48))
    )
  (none)
  )

;; definition for function draw-inline-array-tfrag-near
;; ERROR: function was not converted to expressions. Cannot decompile.

;; definition for function stats-tfrag-asm
;; ERROR: function was not converted to expressions. Cannot decompile.
