jak-project/goal_src/jak1/engine/gfx/shadow/shadow-vu1.gc
2022-06-29 22:20:09 -04:00

244 lines
9.5 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: shadow-vu1.gc
;; name in dgo: shadow-vu1
;; dgos: GAME, ENGINE
(deftype shadow-vu1-constants (structure)
((hmgescale vector :inline :offset-assert 0)
(invhscale vector :inline :offset-assert 16)
(texoffset vector :inline :offset-assert 32)
(texscale vector :inline :offset-assert 48)
(hvdfoff vector :inline :offset-assert 64)
(fog vector :inline :offset-assert 80)
(clrs vector 2 :inline :offset-assert 96)
(adgif gs-gif-tag :inline :offset-assert 128)
(texflush ad-cmd :inline :offset-assert 144)
(flush ad-cmd :inline :offset-assert 160)
(trigif gs-gif-tag :inline :offset-assert 176)
(quadgif gs-gif-tag :inline :offset-assert 192)
)
:method-count-assert 9
:size-assert #xd0
:flag-assert #x9000000d0
)
(defmethod inspect shadow-vu1-constants ((obj shadow-vu1-constants))
(format #t "[~8x] ~A~%" obj 'shadow-vu1-constants)
(format #t "~Thmgescale: #<vector @ #x~X>~%" (-> obj hmgescale))
(format #t "~Tinvhscale: #<vector @ #x~X>~%" (-> obj invhscale))
(format #t "~Ttexoffset: #<vector @ #x~X>~%" (-> obj texoffset))
(format #t "~Ttexscale: #<vector @ #x~X>~%" (-> obj texscale))
(format #t "~Thvdfoff: #<vector @ #x~X>~%" (-> obj hvdfoff))
(format #t "~Tfog: #<vector @ #x~X>~%" (-> obj fog))
(format #t "~Tclrs[2] @ #x~X~%" (-> obj clrs))
(format #t "~Tadgif: #<gs-gif-tag @ #x~X>~%" (-> obj adgif))
(format #t "~Ttexflush: #<ad-cmd @ #x~X>~%" (-> obj texflush))
(format #t "~Tflush: #<ad-cmd @ #x~X>~%" (-> obj flush))
(format #t "~Ttrigif: #<gs-gif-tag @ #x~X>~%" (-> obj trigif))
(format #t "~Tquadgif: #<gs-gif-tag @ #x~X>~%" (-> obj quadgif))
obj
)
(deftype shadow-vu1-gifbuf-template (structure)
((adgif gs-gif-tag :inline :offset-assert 0)
(ad ad-cmd :inline :offset-assert 16)
(flush ad-cmd :inline :offset-assert 32)
(trigif gs-gif-tag :inline :offset-assert 48)
(quadgif gs-gif-tag :inline :offset-assert 64)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
(defmethod inspect shadow-vu1-gifbuf-template ((obj shadow-vu1-gifbuf-template))
(format #t "[~8x] ~A~%" obj 'shadow-vu1-gifbuf-template)
(format #t "~Tadgif: #<gs-gif-tag @ #x~X>~%" (-> obj adgif))
(format #t "~Tad: #<ad-cmd @ #x~X>~%" (-> obj ad))
(format #t "~Tflush: #<ad-cmd @ #x~X>~%" (-> obj flush))
(format #t "~Ttrigif: #<gs-gif-tag @ #x~X>~%" (-> obj trigif))
(format #t "~Tquadgif: #<gs-gif-tag @ #x~X>~%" (-> obj quadgif))
obj
)
(define
*shadow-vu1-tri-template*
(new 'static 'shadow-vu1-gifbuf-template
:adgif
(new 'static 'gs-gif-tag
:tag
(new 'static 'gif-tag64 :nloop #x1 :nreg #x1)
:regs
(new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:ad
(new 'static 'ad-cmd :word (new 'static 'array uint32 4 #x0 #x0 #x3f #x0))
:flush
(new 'static 'ad-cmd :word (new 'static 'array uint32 4 #x0 #x3f800000 #x1 #x0))
:trigif
(new 'static 'gs-gif-tag
:tag
(new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1)
:nreg #x7
)
:regs
(new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id st)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id st)
:regs4 (gif-reg-id xyzf2)
:regs5 (gif-reg-id st)
:regs6 (gif-reg-id xyzf2)
)
)
:quadgif
(new 'static 'gs-gif-tag
:tag
(new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1)
:nreg #x9
)
:regs
(new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id st)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id st)
:regs4 (gif-reg-id xyzf2)
:regs5 (gif-reg-id st)
:regs6 (gif-reg-id xyzf2)
:regs7 (gif-reg-id st)
:regs8 (gif-reg-id xyzf2)
)
)
)
)
(define shadow-vu1-block (new 'static 'vu-function :length #x0 :qlength #x0))
(defun shadow-vu1-add-constants ((arg0 dma-buffer))
(let* ((a2-0 13)
(v1-0 arg0)
(a1-0 (the-as object (-> v1-0 base)))
)
(set! (-> (the-as dma-packet a1-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a2-0))
(set! (-> (the-as dma-packet a1-0) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> (the-as dma-packet a1-0) vif1)
(new 'static 'vif-tag :imm #x370 :cmd (vif-cmd unpack-v4-32) :num a2-0)
)
(set! (-> v1-0 base) (&+ (the-as pointer a1-0) 16))
)
(let ((v1-1 (the-as object (-> arg0 base)))
(a3-4 *math-camera*)
(a2-4 *shadow-data*)
(a1-2 *shadow-vu1-tri-template*)
)
(set! (-> (the-as shadow-vu1-constants v1-1) hmgescale quad) (-> a3-4 hmge-scale quad))
(set! (-> (the-as shadow-vu1-constants v1-1) invhscale quad) (-> a3-4 inv-hmge-scale quad))
(set! (-> (the-as shadow-vu1-constants v1-1) texoffset quad) (-> a2-4 texoffset quad))
(set! (-> (the-as shadow-vu1-constants v1-1) texscale quad) (-> a2-4 texscale quad))
(set! (-> (the-as shadow-vu1-constants v1-1) hvdfoff quad) (-> a3-4 hvdf-off quad))
(set! (-> (the-as shadow-vu1-constants v1-1) fog x) (-> a3-4 pfog0))
(set! (-> (the-as shadow-vu1-constants v1-1) clrs 0 quad) (-> a2-4 clrs 0 quad))
(set! (-> (the-as shadow-vu1-constants v1-1) clrs 1 quad) (-> a2-4 clrs 1 quad))
(set! (-> (the-as shadow-vu1-constants v1-1) adgif qword) (-> a1-2 adgif qword))
(set! (-> (the-as shadow-vu1-constants v1-1) texflush quad) (-> a1-2 ad quad))
(set! (-> (the-as shadow-vu1-constants v1-1) flush quad) (-> a1-2 flush quad))
(set! (-> (the-as shadow-vu1-constants v1-1) trigif qword) (-> a1-2 trigif qword))
(set! (-> (the-as shadow-vu1-constants v1-1) quadgif qword) (-> a1-2 quadgif qword))
)
(&+! (-> arg0 base) 208)
(let* ((v1-4 arg0)
(a1-4 (the-as object (-> v1-4 base)))
)
(set! (-> (the-as dma-packet a1-4) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt)))
(set! (-> (the-as dma-packet a1-4) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> (the-as dma-packet a1-4) vif1)
(new 'static 'vif-tag :imm #x3ac :num #x4 :cmd (vif-cmd unpack-v4-32))
)
(set! (-> v1-4 base) (&+ (the-as pointer a1-4) 16))
)
(let* ((v1-5 arg0)
(a1-6 (the-as object (-> v1-5 base)))
)
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) adgif tag) (new 'static 'gif-tag64 :nloop #x1 :nreg #x2))
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) adgif regs)
(new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d) :regs1 (gif-reg-id rgbaq))
)
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) ad data) (the-as uint 0))
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) ad cmds) (the-as uint 63))
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) flush data) (the-as uint 0))
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) flush cmds) (the-as uint 0))
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) trigif tag)
(new 'static 'gif-tag64
:nloop #x3
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1)
:nreg #x2
)
)
(set! (-> (the-as shadow-vu1-gifbuf-template a1-6) trigif regs)
(new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id xyzf2))
)
(set! (-> v1-5 base) (&+ (the-as pointer a1-6) 64))
)
(none)
)
(defun shadow-vu1-add-matrix ((arg0 dma-buffer) (arg1 math-camera))
(let ((v1-0 4))
(let* ((a2-4 arg0)
(a3-0 (the-as object (-> a2-4 base)))
)
(set! (-> (the-as dma-packet a3-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-0))
(set! (-> (the-as dma-packet a3-0) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> (the-as dma-packet a3-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :num v1-0))
(set! (-> a2-4 base) (the-as pointer (&+ (the-as dma-packet a3-0) 16)))
)
)
(let ((v1-5 (the-as object (-> arg0 base))))
(let ((a2-5 (-> arg1 perspective vector 0 quad))
(a3-1 (-> arg1 perspective vector 1 quad))
(t0-4 (-> arg1 perspective vector 2 quad))
(a1-1 (-> arg1 perspective vector 3 quad))
)
(set! (-> (the-as matrix v1-5) vector 0 quad) a2-5)
(set! (-> (the-as matrix v1-5) vector 1 quad) a3-1)
(set! (-> (the-as matrix v1-5) vector 2 quad) t0-4)
(set! (-> (the-as matrix v1-5) vector 3 quad) a1-1)
)
(set! (-> arg0 base) (the-as pointer (&+ (the-as matrix v1-5) 64)))
)
(none)
)
(defun shadow-vu1-init-buffer ((arg0 dma-buffer))
(dma-buffer-add-vu-function arg0 shadow-vu1-block 1)
(shadow-vu1-add-constants arg0)
(shadow-vu1-add-matrix arg0 *math-camera*)
(let* ((v1-0 arg0)
(a0-4 (the-as object (-> v1-0 base)))
)
(set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #xa))
(set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1))
(set! (-> v1-0 base) (&+ (the-as pointer a0-4) 16))
)
(none)
)