start blit-displays decomp & renderer + improve decompilation of some DMA macros (#2616)

Adds sprite distort, fixes buggy sprite rendering in progress, adds
scissoring support (used in various scrolling menus) and a very basic
implementation of `blit-displays`. This is enough to make the fade
effect in the progress menu work, along with all the menus working
properly without needing to use the REPL. This does not make screen
flipping and the filter when failing a mission work.

Added support in the decompiler for detecting `dma-buffer-add-gs-set`
and `dma-buffer-add-gs-set-flusha` and updated all of the Jak 2 code to
use it. Readability improved!

Fixes decompiler issue with `with-dma-buffer-add-bucket` not inlining
forms which broke syntax. Fixes store error warnings showing up for
non-existent stores, there is now a dedicated pass for this at the end.

I started work on making `BITBLTBUF` stuff work in the DirectRenderer,
but stopped for now because it wasn't strictly necessary. It will still
assert like before.
This commit is contained in:
ManDude
2023-05-04 23:34:09 +01:00
committed by GitHub
parent ae3b76e465
commit 6884b0f73e
106 changed files with 3706 additions and 9246 deletions
+73 -94
View File
@@ -664,68 +664,68 @@
(with-dma-buffer-add-bucket ((buf (-> *display* frames (-> *display* on-screen) debug-buf))
bucket
)
(let ((p0 (new 'stack 'vector4w)))
(let ((p1 (new 'stack 'vector4w)))
(set! (-> p0 quad) (-> start quad))
(set! (-> p1 quad) (-> end quad))
(set! (-> p0 x) (* (+ (-> p0 x) 2048) 16))
(set! (-> p0 y) (* -16 (- 2048 (-> p0 y))))
(set! (-> p0 z) #x7fffff)
(set! (-> p1 x) (* (+ (-> p1 x) 2048) 16))
(set! (-> p1 y) (* -16 (- 2048 (-> p1 y))))
(set! (-> p1 z) #x7fffff)
(let ((a0-18 (the-as (pointer uint64) (-> buf base))))
(let* ((a1-7 buf)
(a2-3 (the-as dma-packet (-> a1-7 base)))
)
(set! (-> a2-3 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a2-3 vif0) (new 'static 'vif-tag))
(set! (-> a2-3 vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1))
(set! (-> a1-7 base) (&+ (the-as pointer a2-3) 16))
)
(let* ((a1-8 buf)
(giftag (the-as gs-gif-tag (-> a1-8 base)))
)
(set! (-> giftag tag) (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1)
:nreg #x4
)
)
(set! (-> giftag regs) (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id xyzf2)
:regs2 (gif-reg-id rgbaq)
:regs3 (gif-reg-id xyzf2)
)
)
(set! (-> a1-8 base) (&+ (the-as pointer giftag) 16))
)
(let* ((a1-9 buf)
(v0 (the-as vector4w-2 (-> a1-9 base)))
)
(set! (-> v0 vector 0 quad) (-> color quad))
(set! (-> v0 vector 1 quad) (-> p0 quad))
(set! (-> a1-9 base) (&+ (the-as pointer v0) 32))
)
(let* ((a1-10 buf)
(v1 (the-as vector4w-2 (-> a1-10 base)))
)
(set! (-> v1 vector 0 quad) (-> color quad))
(set! (-> v1 vector 1 quad) (-> p1 quad))
(set! (-> a1-10 base) (&+ (the-as pointer v1) 32))
)
(let ((a1-14 (/ (the-as int (+ (- -16 (the-as int a0-18)) (the-as int (-> buf base)))) 16)))
(cond
((nonzero? a1-14)
(logior! (-> a0-18 0) (shr (shl a1-14 48) 48))
(logior! (-> a0-18 1) (shl (shr (shl a1-14 48) 48) 32))
(let ((p0 (new 'stack 'vector4w))
(p1 (new 'stack 'vector4w))
)
(set! (-> p0 quad) (-> start quad))
(set! (-> p1 quad) (-> end quad))
(set! (-> p0 x) (* (+ (-> p0 x) 2048) 16))
(set! (-> p0 y) (* -16 (- 2048 (-> p0 y))))
(set! (-> p0 z) #x7fffff)
(set! (-> p1 x) (* (+ (-> p1 x) 2048) 16))
(set! (-> p1 y) (* -16 (- 2048 (-> p1 y))))
(set! (-> p1 z) #x7fffff)
(let ((a0-18 (the-as (pointer uint64) (-> buf base))))
(let* ((a1-7 buf)
(a2-3 (the-as dma-packet (-> a1-7 base)))
)
(else
(set! (-> buf base) a0-18)
(set! (-> a2-3 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a2-3 vif0) (new 'static 'vif-tag))
(set! (-> a2-3 vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1))
(set! (-> a1-7 base) (&+ (the-as pointer a2-3) 16))
)
(let* ((a1-8 buf)
(giftag (the-as gs-gif-tag (-> a1-8 base)))
)
(set! (-> giftag tag) (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1)
:nreg #x4
)
)
(set! (-> giftag regs) (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id xyzf2)
:regs2 (gif-reg-id rgbaq)
:regs3 (gif-reg-id xyzf2)
)
)
(set! (-> a1-8 base) (&+ (the-as pointer giftag) 16))
)
(let* ((a1-9 buf)
(v0 (the-as vector4w-2 (-> a1-9 base)))
)
(set! (-> v0 vector 0 quad) (-> color quad))
(set! (-> v0 vector 1 quad) (-> p0 quad))
(set! (-> a1-9 base) (&+ (the-as pointer v0) 32))
)
(let* ((a1-10 buf)
(v1 (the-as vector4w-2 (-> a1-10 base)))
)
(set! (-> v1 vector 0 quad) (-> color quad))
(set! (-> v1 vector 1 quad) (-> p1 quad))
(set! (-> a1-10 base) (&+ (the-as pointer v1) 32))
)
(let ((a1-14 (/ (the-as int (+ (- -16 (the-as int a0-18)) (the-as int (-> buf base)))) 16)))
(cond
((nonzero? a1-14)
(logior! (-> a0-18 0) (shr (shl a1-14 48) 48))
(logior! (-> a0-18 1) (shl (shr (shl a1-14 48) 48) 32))
)
(else
(set! (-> buf base) a0-18)
)
)
)
@@ -1894,7 +1894,7 @@
;; definition (debug) for function add-debug-bound
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
;; ERROR: Failed store: (s.w! (+ v1-29 8) 0) at op 110
;; ERROR: Failed store: (s.w! (+ a0-3 8) 0) at op 36
;; WARN: Function add-debug-bound has a return type of none, but the expression builder found a return statement.
(defun-debug add-debug-bound ((buf bucket-id) (pts (inline-array vector)) (c0 int) (c1 rgba) (flash rgba) (arg5 int))
(local-vars (sv-16 pointer) (sv-32 int))
@@ -1914,39 +1914,18 @@
(with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
buf
)
(let ((v1-16 s4-0))
(let ((a0-3 (the-as dma-packet (-> v1-16 base))))
(set! (-> a0-3 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt)))
(set! (-> a0-3 vif0) (new 'static 'vif-tag))
(set! (-> a0-3 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1))
(set! (-> v1-16 base) (the-as pointer (the-as dma-packet (&+ a0-3 16))))
)
)
(let ((v1-17 s4-0))
(let ((a0-5 (the-as gs-gif-tag (-> v1-17 base))))
(set! (-> a0-5 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3))
(set! (-> a0-5 regs) GIF_REGS_ALL_AD)
(set! (-> v1-17 base) (the-as pointer (the-as gs-gif-tag (&+ a0-5 16))))
)
)
(let ((v1-18 s4-0))
(let ((a0-7 (-> v1-18 base)))
(set! (-> (the-as (pointer gs-zbuf) a0-7) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)))
(set! (-> (the-as (pointer gs-reg64) a0-7) 1) (gs-reg64 zbuf-1))
(set! (-> (the-as (pointer gs-test) a0-7) 2) (new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
(set! (-> (the-as (pointer gs-reg64) a0-7) 3) (gs-reg64 test-1))
(set! (-> (the-as (pointer gs-alpha) a0-7) 4) (new 'static 'gs-alpha :b #x1 :d #x1))
(set! (-> (the-as (pointer gs-reg64) a0-7) 5) (gs-reg64 alpha-1))
(set! (-> v1-18 base) (&+ a0-7 48))
)
)
(dma-buffer-add-gs-set s4-0
(zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)))
(test-1 (new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
(alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
)
(set! sv-16 (-> s4-0 base))
(&+! (-> s4-0 base) 16)
(add-boundary-shader (new 'static 'texture-id :index #x3 :page #x70c) s4-0)