jak-project/goal_src/jak2/engine/gfx/blit-displays.gc

249 lines
9.9 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: blit-displays.gc
;; name in dgo: blit-displays
;; dgos: ENGINE, GAME
(define *blit-displays-work*
(new 'static 'blit-displays-work
: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)
)
:gif0 (new 'static 'gif-tag64 :nloop #x5 :eop #x1 :nreg #x1)
:gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:sprite-tmpl (new 'static 'dma-gif-packet
:dma-vif (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x51 :id (dma-tag-id cnt))
:vif1 (new 'static 'vif-tag :imm #x51 :cmd (vif-cmd direct) :msk #x1)
)
:gif0 (new 'static 'gif-tag64
:nloop #x10
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :fst #x1)
:nreg #x5
)
:gif1 (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id uv)
:regs2 (gif-reg-id xyz2)
:regs3 (gif-reg-id uv)
:regs4 (gif-reg-id xyz2)
)
)
:sprite-slow-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)
)
:gif0 (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :fst #x1)
:nreg #x5
)
:gif1 (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id uv)
:regs2 (gif-reg-id xyz2)
:regs3 (gif-reg-id uv)
:regs4 (gif-reg-id xyz2)
)
)
:line-tmpl (new 'static 'dma-gif-packet
:dma-vif (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x41 :id (dma-tag-id cnt))
:vif1 (new 'static 'vif-tag :imm #x41 :cmd (vif-cmd direct) :msk #x1)
)
:gif0 (new 'static 'gif-tag64
:nloop #x20
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type line) :abe #x1)
:nreg #x2
)
:gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id xyz2) :regs1 (gif-reg-id xyz2))
)
:scan-tmpl (new 'static 'dma-gif-packet
:dma-vif (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x4c :id (dma-tag-id cnt))
:vif1 (new 'static 'vif-tag :imm #x4c :cmd (vif-cmd direct) :msk #x1)
)
:gif0 (new 'static 'gif-tag64
:nloop #xf
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type line) :abe #x1)
:nreg #x5
)
:gif1 (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id xyz2)
:regs2 (gif-reg-id xyz2)
:regs3 (gif-reg-id xyz2)
:regs4 (gif-reg-id xyz2)
)
)
:color (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)
:line-color #x3f80000000000000
:scan-colors (new 'static 'inline-array vector4w 15
(new 'static 'vector4w :y 1 :z 1)
(new 'static 'vector4w :y 1 :z 1)
(new 'static 'vector4w :y 1 :z 1)
(new 'static 'vector4w :y 1 :z 1)
(new 'static 'vector4w :x 1 :y 3 :z 2)
(new 'static 'vector4w :x 1 :y 4 :z 3)
(new 'static 'vector4w :x 2 :y 6 :z 5)
(new 'static 'vector4w :x 3 :y 8 :z 7)
(new 'static 'vector4w :x 5 :y 11 :z 10)
(new 'static 'vector4w :x 6 :y 14 :z 13)
(new 'static 'vector4w :x 9 :y 20 :z 17)
(new 'static 'vector4w :x 13 :y 27 :z 21)
(new 'static 'vector4w :x 17 :y 36 :z 24)
(new 'static 'vector4w :x 22 :y 45 :z 28)
(new 'static 'vector4w :x 32 :y 63 :z 32)
)
:menu-mode #f
:screen-copied #f
:horizontal-flip-flag #f
)
)
(defun pc-upload-raw-texture ((dma-buf dma-buffer) (image-data pointer) (width int) (height int) (tbp int))
"Added function in the PC port to create a 'raw' texture (no clut)"
(pc-texture-anim-flag start-anim-array dma-buf)
(pc-texture-anim-flag upload-generic-vram dma-buf :qwc 1)
(let ((upload-record (the texture-anim-pc-upload (-> dma-buf base))))
(set! (-> upload-record data) image-data)
(set! (-> upload-record width) width)
(set! (-> upload-record height) height)
(set! (-> upload-record dest) tbp)
(set! (-> upload-record format) (gs-psm ct32))
(set! (-> upload-record force-to-gpu) 1)
)
(&+! (-> dma-buf base) 16)
(pc-texture-anim-flag finish-anim-array dma-buf)
)
(defun draw-raw-image ((arg0 bucket-id) (arg1 art-group) (arg2 int) (arg3 int) (arg4 level) (arg5 int))
(local-vars (sv-16 blit-displays-work) (sv-32 int))
(set! sv-16 *blit-displays-work*)
(with-dma-buffer-add-bucket ((s0-0 (-> *display* frames (-> *display* on-screen) global-buf))
arg0
)
(#when PC_PORT
;; draw a black rectangle covering the screen first
(draw-sprite2d-xy s0-0 0 0 512 416 (static-rgba 0 0 0 128))
)
;; (upload-vram-data s0-0 0 (the-as pointer arg1) arg3 arg2)
(pc-upload-raw-texture s0-0 (the pointer arg1) arg2 arg3 0)
(set! sv-32 (+ (log2 (+ arg2 -1)) 1))
(let ((v1-8 (+ (log2 (+ arg3 -1)) 1)))
(dma-buffer-add-gs-set s0-0
(test-1 (new 'static 'gs-test :ate #x1 :afail #x3 :zte #x1 :ztst (gs-ztest always)))
(alpha-1 (new 'static 'gs-alpha))
(tex0-1 (new 'static 'gs-tex0 :tcc #x1 :th v1-8 :tw sv-32 :tbw (/ arg2 64)))
(tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
(clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
(texflush 0)
)
)
(let ((v1-19 (-> s0-0 base)))
(set! (-> (the-as (pointer uint128) v1-19)) (-> sv-16 sprite-slow-tmpl dma-vif quad))
(set! (-> (the-as (pointer uint128) v1-19) 1) (-> sv-16 sprite-slow-tmpl quad 1))
(set! (-> (the-as (pointer uint128) v1-19) 2) (-> sv-16 color quad))
(set-vector! (the-as vector4w (&+ v1-19 48)) 0 0 0 0)
(set-vector! (the-as vector4w (&+ v1-19 64)) #x7000 #x7300 0 0)
(set-vector! (the-as vector4w (&+ v1-19 80)) (* arg2 16) (* arg3 16) 0 0)
(set-vector! (the-as vector4w (&+ v1-19 96)) #x9000 #x8d00 0 0)
(#when PC_PORT
(when (not (-> *pc-settings* use-vis?))
(let ((corrected-width (the int (* (-> *pc-settings* aspect-ratio-reciprocal) #x1000))))
(set-vector! (the-as vector4w (&+ v1-19 64)) (- #x8000 corrected-width) #x7300 0 0)
(set-vector! (the-as vector4w (&+ v1-19 96)) (+ #x8000 corrected-width) #x8d00 0 0)
)
)
)
)
(&+! (-> s0-0 base) 112)
(set-dirty-mask! arg4 arg5 (* (* arg3 arg2) 4) 0)
)
(none)
)
;; not the real thing. just a temp hack.
(defun blit-displays ()
(local-vars (v1-182 uint) (v1-183 int))
(let ((gp-0 *blit-displays-work*))
(when (zero? (-> gp-0 count-down))
(cond
((and (-> gp-0 menu-mode) (not (-> gp-0 screen-copied)))
(with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
(bucket-id bucket-3)
)
(fx-copy-buf s4-0)
)
(set! (-> gp-0 vu1-enable-user-menu) (-> *display* vu1-enable-user-menu))
(set! (-> *display* vu1-enable-user-menu) (vu1-renderer-mask merc)) ;;(vu1-renderer-mask generic))
(set! (-> *display* vu1-enable-user) (vu1-renderer-mask merc)) ;;(vu1-renderer-mask generic))
(set! (-> gp-0 texture-enable-user-menu) (the-as uint (-> *texture-pool* texture-enable-user-menu)))
(set! (-> *texture-pool* texture-enable-user-menu) (texture-enable-mask shrub water map))
(set! (-> *texture-pool* texture-enable-user) (texture-enable-mask shrub water map))
(set! (-> gp-0 count-down) (the-as uint 3))
(set! (-> gp-0 screen-copied) #t)
(set! (-> gp-0 progress-interp) 0.0)
(set! (-> gp-0 progress-interp-dest) 1.0)
(set! (-> gp-0 progress-interp-speed) (/ 1.0 30))
(#when PC_PORT
(when (-> *pc-settings* fast-progress?)
(*! (-> gp-0 progress-interp-speed) (-> *pc-cheat-state* progress-speed))
)
)
)
((and (not (-> gp-0 menu-mode)) (-> gp-0 screen-copied))
(set! (-> *display* vu1-enable-user-menu) (-> gp-0 vu1-enable-user-menu))
(set! (-> *texture-pool* texture-enable-user-menu)
(the-as texture-enable-mask (-> gp-0 texture-enable-user-menu))
)
(set! (-> gp-0 count-down) (the-as uint 3))
(set! (-> gp-0 screen-copied) #f)
)
)
)
(when (and (-> *setting-control* user-current render) (>= (the-as uint 1) (-> gp-0 count-down)))
(when (and (-> gp-0 horizontal-flip-flag) (not (-> gp-0 menu-mode)))
)
)
(let ((a1-23 (-> *time-of-day-context* filter)))
(when (and (or (!= (-> a1-23 x) 1.0) (!= (-> a1-23 y) 1.0) (!= (-> a1-23 z) 1.0)) (not (-> gp-0 menu-mode)))
)
)
(cond
((and (-> *setting-control* user-current render) (zero? (-> gp-0 count-down)))
)
(else
)
)
(when (nonzero? (-> gp-0 count-down))
(+! (-> gp-0 count-down) -1)
(with-dma-buffer-add-bucket ((arg0 (-> *display* frames (-> *display* on-screen) global-buf))
(bucket-id bucket-3)
)
(dma-buffer-add-cnt-vif2 arg0 0 (new 'static 'vif-tag :cmd (vif-cmd pc-port) :imm #x11) ;; kind - do nothing
(new 'static 'vif-tag :cmd (vif-cmd pc-port)))
)
)
)
(none)
)
;; DECOMP BEGINS