diff --git a/.vscode/settings.json b/.vscode/settings.json index 69a3110e6..7a44546b2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -48,6 +48,16 @@ } ] }, + "(lwu .., 4\\(..\\).*)(dma-buffer)": { + "filterFileRegex": ".*ir2\\.asm", + "decorations": [ + {}, + { + "overviewRulerColor": "transparent", + "color": "red" + } + ] + }, "(sp, -?\\d+ )": { "filterFileRegex": ".*ir2\\.asm", "decorations": [ diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 087af52ff..6795526f0 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -16627,11 +16627,11 @@ ;; - Functions -(define-extern depth-cue-draw-front (function dma-buffer int float float uint int none)) -(define-extern depth-cue-set-stencil function) -(define-extern depth-cue-draw-depth function) -(define-extern depth-cue-calc-z function) -(define-extern depth-cue (function display none)) +(define-extern depth-cue-draw-front (function dma-buffer int float float uint int symbol)) +(define-extern depth-cue-set-stencil (function dma-buffer int int int dma-gif-packet vector4w)) +(define-extern depth-cue-draw-depth (function dma-buffer int float float int int symbol)) +(define-extern depth-cue-calc-z (function float float)) +(define-extern depth-cue (function display pointer)) ;; - Unknowns diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 654e33341..bb80c1157 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -1632,11 +1632,6 @@ ["L530", "uint64", true] ], - "mother-spider": [ - ["L301", "(inline-array mother-spider-leg-info)", 8], - ["L302", "(inline-array mother-spider-thread)", 9] - ], - "target-flut": [ ["L399", "attack-info"], ["L406", "float", true], @@ -1996,6 +1991,11 @@ ["L38", "vector"] ], + + "depth-cue": [ + ["L17", "depth-cue-work"] + ], + // please do not add things after this entry! git is dumb. "object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 08c370bd0..546f8864a 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -7460,5 +7460,102 @@ [110, "v1", "float"] ], + "depth-cue-set-stencil": [ + [[1, 7], "t1", "dma-packet"], + [[10, 16], "t1", "gs-gif-tag"], + [27, "t1", "(pointer gs-xy-offset)"], + [29, "t1", "(pointer gs-reg64)"], + [34, "t1", "(pointer gs-frame)"], + [36, "t1", "(pointer gs-reg64)"], + [38, "t1", "(pointer gs-test)"], + [40, "t1", "(pointer gs-reg64)"], + [[43, 53], "a3", "(inline-array vector4w)"], + [[52, 80], "v0", "(inline-array vector4w)"] + ], + + "depth-cue-draw-front": [ + [[26, 32], "t6", "dma-packet"], + [[33, 41], "t6", "gs-gif-tag"], + [49, "t6", "(pointer gs-xy-offset)"], + [51, "t6", "(pointer gs-reg64)"], + [56, "t6", "(pointer gs-frame)"], + [58, "t6", "(pointer gs-reg64)"], + [64, "t6", "(pointer gs-tex0)"], + [66, "t6", "(pointer gs-reg64)"], + [68, "t6", "(pointer gs-test)"], + [70, "t6", "(pointer gs-reg64)"], + [71, "t6", "(pointer gs-alpha)"], + [73, "t6", "(pointer gs-reg64)"], + [[76, 109], "t5", "(inline-array vector4w)"], + [112, "t5", "depth-cue-work"], + [[115, 121], "t6", "dma-packet"], + [[122, 130], "t6", "gs-gif-tag"], + [137, "t6", "(pointer gs-xy-offset)"], + [139, "t6", "(pointer gs-reg64)"], + [144, "t6", "(pointer gs-frame)"], + [146, "t6", "(pointer gs-reg64)"], + [148, "t6", "(pointer gs-texa)"], + [150, "t6", "(pointer gs-reg64)"], + [156, "t6", "(pointer gs-tex0)"], + [158, "t6", "(pointer gs-reg64)"], + [160, "t6", "(pointer gs-alpha)"], + [162, "t6", "(pointer gs-reg64)"], + [[165, 190], "t5", "(inline-array vector4w)"], + [[191, 201], "t5", "vector4w"], + [201, "t5", "depth-cue-work"] + ], + + "depth-cue-draw-depth": [ + [[26, 32], "t6", "dma-packet"], + [[33, 41], "t6", "gs-gif-tag"], + [49, "t6", "(pointer gs-xy-offset)"], + [51, "t6", "(pointer gs-reg64)"], + [56, "t6", "(pointer gs-frame)"], + [58, "t6", "(pointer gs-reg64)"], + [64, "t6", "(pointer gs-tex0)"], + [66, "t6", "(pointer gs-reg64)"], + [68, "t6", "(pointer gs-test)"], + [70, "t6", "(pointer gs-reg64)"], + [[73, 106], "t5", "(inline-array vector4w)"], + [109, "t5", "depth-cue-work"], + [[112, 118], "t6", "dma-packet"], + [[121, 127], "t6", "gs-gif-tag"], + [134, "t6", "(pointer gs-xy-offset)"], + [136, "t6", "(pointer gs-reg64)"], + [141, "t6", "(pointer gs-frame)"], + [143, "t6", "(pointer gs-reg64)"], + [149, "t6", "(pointer gs-tex0)"], + [151, "t6", "(pointer gs-reg64)"], + [153, "t6", "(pointer gs-test)"], + [155, "t6", "(pointer gs-reg64)"], + [[158, 183], "t5", "(inline-array vector4w)"], + [[184, 193], "t5", "vector4w"], + [194, "t5", "depth-cue-work"] + ], + + "depth-cue": [ + [[22, 28], "a2", "dma-packet"], + [[31, 37], "a2", "gs-gif-tag"], + [42, "a2", "(pointer gs-test)"], + [44, "a2", "(pointer gs-reg64)"], + [46, "a2", "(pointer gs-zbuf)"], + [48, "a2", "(pointer gs-reg64)"], + [50, "a2", "(pointer gs-reg64)"], + [52, "a2", "(pointer gs-reg64)"], + [53, "a2", "(pointer gs-tex1)"], + [55, "a2", "(pointer gs-reg64)"], + [62, "a2", "(pointer gs-clamp)"], + [64, "a2", "(pointer gs-reg64)"], + [66, "a2", "(pointer gs-reg64)"], + [68, "a2", "(pointer gs-reg64)"], + [[94, 100], "a0", "dma-packet"], + [[103, 109], "a0", "gs-gif-tag"], + [120, "a0", "(pointer gs-xy-offset)"], + [122, "a0", "(pointer gs-reg64)"], + [127, "a0", "(pointer gs-frame)"], + [129, "a0", "(pointer gs-reg64)"], + [[133, 138], "v1", "dma-packet"] + ], + "placeholder-do-not-add-below": [] } diff --git a/goal_src/engine/gfx/depth-cue.gc b/goal_src/engine/gfx/depth-cue.gc index c77bfc350..742bd77c7 100644 --- a/goal_src/engine/gfx/depth-cue.gc +++ b/goal_src/engine/gfx/depth-cue.gc @@ -5,3 +5,582 @@ ;; name in dgo: depth-cue ;; dgos: GAME, ENGINE +;; DECOMP BEGINS + +(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)) + ) + ) + +(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) + ) + ) + ) + +(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 + ) + +(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 + ) + +(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) + ) + ) + +(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 + ) + ) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/engine/gfx/depth-cue_REF.gc b/test/decompiler/reference/engine/gfx/depth-cue_REF.gc new file mode 100644 index 000000000..134a4e984 --- /dev/null +++ b/test/decompiler/reference/engine/gfx/depth-cue_REF.gc @@ -0,0 +1,589 @@ +;;-*-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 +;; 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 +;; 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 +;; 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 + ) + ) + ) + ) + ) + + + +