decomp: emerc, emerc-vu1 (#1833)

* decompiler: add support for `MADDq` in VU disassembler, add `emerc-vu1` program

* decomp: `emerc`, `emerc-vu1`
This commit is contained in:
Hat Kid 2022-09-03 00:29:30 +02:00 committed by GitHub
parent 59617c2ee0
commit 2a1dc7bd2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 4857 additions and 61 deletions

View File

@ -86,9 +86,9 @@ VuDisassembler::VuDisassembler(VuKind kind) : m_kind(kind) {
m_upper_op6_table[0b011110].set(VuInstrK::MULi); // 30
m_upper_op6_table[0b011111].set(VuInstrK::MINIi); // 31
m_upper_op6_table[0b100000].set(VuInstrK::ADDq); // 32
// m_upper_op6_table[0b100001].set(VuInstrK::MADDq); // 33
m_upper_op6_table[0b100010].set(VuInstrK::ADDi); // 34
m_upper_op6_table[0b100000].set(VuInstrK::ADDq); // 32
m_upper_op6_table[0b100001].set(VuInstrK::MADDq); // 33
m_upper_op6_table[0b100010].set(VuInstrK::ADDi); // 34
// m_upper_op6_table[0b100011].set(VuInstrK::MADDi); // 35
// m_upper_op6_table[0b100100].set(VuInstrK::SUBq); // 36
// m_upper_op6_table[0b100101].set(VuInstrK::MSUBq); // 37
@ -143,6 +143,7 @@ VuDisassembler::VuDisassembler(VuKind kind) : m_kind(kind) {
add_op(VuInstrK::ADDA, "adda").iemdt().dst_mask().dst_acc().src_vfs().src_vft();
add_op(VuInstrK::MADD, "madd").iemdt().dst_mask().dss_fd_fs_ft();
add_op(VuInstrK::ADDq, "addq").iemdt().dst_mask().vft_zero().dst_vfd().src_vfs().src_q();
add_op(VuInstrK::MADDq, "madd").iemdt().dst_mask().vft_zero().dst_vfd().src_vfs().src_q();
add_op(VuInstrK::MULi, "muli").iemdt().dst_mask().vft_zero().dst_vfd().src_vfs().src_i();
add_op(VuInstrK::ADDi, "addi").iemdt().dst_mask().vft_zero().dst_vfd().src_vfs().src_i();
add_op(VuInstrK::MULAq, "mula").iemdt().dst_mask().dst_acc().vft_zero().src_vfs().src_q();

View File

@ -37,7 +37,7 @@ enum class VuInstrK {
MULAbc,
MADD,
// MADDi,
// MADDq,
MADDq,
MADDbc,
MADDA,
// MADDAi, // 30

View File

@ -4263,13 +4263,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype display-frame (basic)
((buffer dma-buffer 11 :offset-assert 4) ;; guessed by decompiler
(calc-buf dma-buffer :offset 8)
(vu1-buf dma-buffer :offset 8)
(debug-buf dma-buffer :offset 36)
(global-buf dma-buffer :offset 40)
(bucket-group dma-bucket :offset 44) ;; (inline-array dma-bucket)
(profile-array profile-array :inline :offset-assert 48)
((buffer dma-buffer 11 :offset-assert 4) ;; guessed by decompiler
(calc-buf dma-buffer :offset 8)
(vu1-buf dma-buffer :offset 8)
(debug-buf dma-buffer :offset 36)
(global-buf dma-buffer :offset 40)
(bucket-group (inline-array dma-bucket) :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64) ;; int64
)
@ -10584,12 +10584,12 @@
)
(deftype emerc-vu1-low-mem (structure)
((tri-strip-gif qword :inline :offset-assert 0)
(ad-gif qword :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective vector 4 :inline :offset-assert 48)
(fog vector :inline :offset-assert 112)
(unperspect vector :inline :offset-assert 128)
((tri-strip-gif gs-gif-tag :inline :offset-assert 0)
(ad-gif gs-gif-tag :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective vector 4 :inline :offset-assert 48)
(fog vector :inline :offset-assert 112)
(unperspect vector :inline :offset-assert 128)
)
:method-count-assert 9
:size-assert #x90
@ -21774,7 +21774,7 @@
;; emerc-vu1 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern emerc-vu1-block object)
(define-extern emerc-vu1-block vu-function)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; merc-blend-shape ;;
@ -21901,7 +21901,7 @@
;; (define-extern merc-stats-display function) ;; (function merc-ctrl none)
(define-extern merc-stats (function none))
;; (define-extern merc-edge-stats function) ;; (function none)
;; (define-extern merc-vu1-add-vu-function function) ;; (function dma-packet vu-function int dma-gif-packet)
(define-extern merc-vu1-add-vu-function (function dma-packet vu-function int dma-gif-packet))
;; (define-extern merc-vu1-initialize-chain function) ;; (function dma-gif-packet dma-packet)
;; (define-extern merc-vu1-init-buffer function) ;; (function bucket-id gs-test int none)
;; (define-extern merc-vu1-init-buffers function) ;; (function none)
@ -21910,9 +21910,9 @@
;; emerc ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern emerc-vu1-initialize-chain function)
;; (define-extern emerc-vu1-init-buffer function)
;; (define-extern emerc-vu1-init-buffers function)
(define-extern emerc-vu1-initialize-chain (function dma-gif-packet dma-packet))
(define-extern emerc-vu1-init-buffer (function bucket-id gs-test int none))
(define-extern emerc-vu1-init-buffers (function none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ripple ;;

View File

@ -112,5 +112,8 @@
],
"collide-cache": [
["L171", "vector"]
],
"emerc-vu1": [
["L1", "vu-function"]
]
}

View File

@ -1421,6 +1421,18 @@
[116, "f0", "float"],
[137, "f0", "float"]
],
"emerc-vu1-initialize-chain": [
[[19, 59], "s5", "emerc-vu1-low-mem"],
[80, "gp", "(inline-array dma-packet)"],
[[12, 18], "gp", "(pointer vif-tag)"]
],
"emerc-vu1-init-buffer": [
[[25, 31], "a0", "dma-packet"],
[[37, 40], "a0", "gs-gif-tag"],
[44, "a0", "(pointer gs-test)"],
[46, "a0", "(pointer gs-reg64)"],
[[49, 61], "v1", "dma-packet"]
],
// placeholder
"placeholder-do-not-add-below": [],
"drawable-load": [[[25, 28], "s5", "drawable"]],

View File

@ -290,5 +290,12 @@
"matrix-local->world": {
"args": ["smooth?"]
},
"emerc-vu1-init-buffer": {
"args": ["dma-bucket", "test"],
"vars": {
"gp-0": "bucket",
"s4-0": "dma-buf"
}
}
}

View File

@ -283,7 +283,7 @@
(set! (-> v1-5 base) (&+ (the-as pointer a0-2) 16))
)
(dma-bucket-insert-tag
(the-as (inline-array dma-bucket) (-> *display* frames (-> *display* on-screen) bucket-group))
(-> *display* frames (-> *display* on-screen) bucket-group)
(bucket-id bucket-318)
a2-0
(the-as (pointer dma-tag) a3-16)

View File

@ -18,15 +18,15 @@
;; per-frame DMA buffers, timing, and profiling info.
(deftype display-frame (basic)
((buffer dma-buffer 11 :offset-assert 4)
(calc-buf dma-buffer :offset 8)
(vu1-buf dma-buffer :offset 8)
(debug-buf dma-buffer :offset 36)
(global-buf dma-buffer :offset 40)
(bucket-group dma-bucket :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64)
((buffer dma-buffer 11 :offset-assert 4)
(calc-buf dma-buffer :offset 8)
(vu1-buf dma-buffer :offset 8)
(debug-buf dma-buffer :offset 36)
(global-buf dma-buffer :offset 40)
(bucket-group (inline-array dma-bucket) :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64)
)
:method-count-assert 9
:size-assert #x48

View File

@ -7,3 +7,4 @@
;; DECOMP BEGINS
(define emerc-vu1-block (new 'static 'vu-function :length #x56b :qlength #x2b6))

View File

@ -5,5 +5,254 @@
;; name in dgo: emerc
;; dgos: ENGINE, GAME
(define-extern merc-vu1-add-vu-function (function dma-packet vu-function int dma-gif-packet))
;; DECOMP BEGINS
(defun emerc-vu1-initialize-chain ((arg0 dma-gif-packet))
(let ((gp-0 (the-as object (merc-vu1-add-vu-function (the-as dma-packet arg0) emerc-vu1-block 1))))
(set! (-> (the-as dma-gif-packet gp-0) dma-vif dma) (new 'static 'dma-tag :qwc #xb :id (dma-tag-id cnt)))
(set! (-> (the-as dma-gif-packet gp-0) dma-vif vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> (the-as dma-gif-packet gp-0) dma-vif vif1) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
(set! (-> (the-as (pointer vif-tag) gp-0) 4) (new 'static 'vif-tag :imm #x1ba :cmd (vif-cmd base)))
(set! (-> (the-as (pointer vif-tag) gp-0) 5) (new 'static 'vif-tag :imm #xfe46 :cmd (vif-cmd offset)))
(set! (-> (the-as (pointer vif-tag) gp-0) 6) (new 'static 'vif-tag))
(set! (-> (the-as (pointer vif-tag) gp-0) 7) (new 'static 'vif-tag :num #x9 :cmd (vif-cmd unpack-v4-32)))
(let ((s5-0 (the-as emerc-vu1-low-mem (&+ (the-as dma-gif-packet gp-0) 32))))
(set! (-> s5-0 tri-strip-gif tag)
(new 'static 'gif-tag64
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1)
:nreg #x3
)
)
(set! (-> s5-0 tri-strip-gif regs)
(new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))
)
(set! (-> s5-0 tri-strip-gif word 3) (shr (make-u128 0 (shl #x303e4000 32)) 32))
(set! (-> s5-0 ad-gif tag) (new 'static 'gif-tag64 :nloop #x5 :nreg #x1))
(set! (-> s5-0 ad-gif regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d)))
(set! (-> s5-0 hvdf-offset quad) (-> *math-camera* hvdf-off quad))
(quad-copy! (the-as pointer (-> s5-0 perspective)) (the-as pointer (-> *math-camera* perspective)) 4)
(set-vector! (-> s5-0 fog) (-> *math-camera* pfog0) (-> *math-camera* fog-min) (-> *math-camera* fog-max) 0.0)
(set-vector!
(-> s5-0 unperspect)
(/ 1.0 (-> *math-camera* perspective vector 0 x))
(/ 1.0 (-> *math-camera* perspective vector 1 y))
0.5
(/ 1.0 (-> *math-camera* perspective vector 2 w))
)
)
(let ((v1-21 (-> (the-as (inline-array dma-packet) gp-0) 11)))
(set! (-> v1-21 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> v1-21 vif0) (new 'static 'vif-tag))
(set! (-> v1-21 vif1) (new 'static 'vif-tag :cmd (vif-cmd mscal) :msk #x1 :imm #x0))
(&+ v1-21 16)
)
)
)
(defun emerc-vu1-init-buffer ((dma-bucket bucket-id) (test gs-test) (arg2 int))
(let ((bucket (-> *display* frames (-> *display* on-screen) bucket-group dma-bucket)))
(when (!= bucket (-> bucket last))
(let* ((dma-buf (-> *display* frames (-> *display* on-screen) global-buf))
(s3-1 (-> dma-buf base))
)
(set! (-> dma-buf base)
(the-as pointer (emerc-vu1-initialize-chain (the-as dma-gif-packet (-> dma-buf base))))
)
(let* ((v1-12 dma-buf)
(a0-4 (the-as object (-> v1-12 base)))
)
(set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
(set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
(set! (-> v1-12 base) (&+ (the-as pointer a0-4) 16))
)
(let* ((v1-13 dma-buf)
(a0-6 (the-as object (-> v1-13 base)))
)
(set! (-> (the-as gs-gif-tag a0-6) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
(set! (-> (the-as gs-gif-tag a0-6) 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-13 base) (&+ (the-as pointer a0-6) 16))
)
(let* ((v1-14 dma-buf)
(a0-8 (-> v1-14 base))
)
(set! (-> (the-as (pointer gs-test) a0-8) 0) test)
(set! (-> (the-as (pointer gs-reg64) a0-8) 1) (gs-reg64 test-1))
(set! (-> v1-14 base) (&+ a0-8 16))
)
(let ((v1-15 (the-as dma-packet (-> dma-buf base))))
(set! (-> v1-15 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> bucket next)))
(set! (-> v1-15 vif0) (new 'static 'vif-tag))
(set! (-> v1-15 vif1) (new 'static 'vif-tag))
(set! (-> dma-buf base) (the-as pointer (the-as dma-packet (&+ v1-15 16))))
)
(set! (-> bucket next) (the-as uint s3-1))
)
)
)
0
(none)
)
(defun emerc-vu1-init-buffers ()
(when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask rn14))
(emerc-vu1-init-buffer (bucket-id bucket-15) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-26) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-37) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-48) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-59) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-70) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer
(bucket-id bucket-189)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-198)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-202)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-206)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-210)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-214)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-218)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-222)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer (bucket-id bucket-80) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-89) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-98) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer
(bucket-id bucket-107)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-116)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-125)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-193)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-132)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-142)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-152)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-162)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-172)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-182)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-226)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-230)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-234)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-238)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-242)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-246)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-250)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
)
0
(none)
)

View File

@ -328,12 +328,12 @@
)
(deftype emerc-vu1-low-mem (structure)
((tri-strip-gif qword :inline :offset-assert 0)
(ad-gif qword :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective vector 4 :inline :offset-assert 48)
(fog vector :inline :offset-assert 112)
(unperspect vector :inline :offset-assert 128)
((tri-strip-gif gs-gif-tag :inline :offset-assert 0)
(ad-gif gs-gif-tag :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective vector 4 :inline :offset-assert 48)
(fog vector :inline :offset-assert 112)
(unperspect vector :inline :offset-assert 128)
)
:method-count-assert 9
:size-assert #x90

View File

@ -1025,7 +1025,7 @@
(set! (-> dma-buff base) (&+ (the-as pointer pkt7) 16))
)
(dma-bucket-insert-tag
(the-as (inline-array dma-bucket) (-> *display* frames (-> *display* on-screen) bucket-group))
(-> *display* frames (-> *display* on-screen) bucket-group)
(bucket-id bucket-313)
dma-bucket-begin
(the-as (pointer dma-tag) a3-0)

View File

@ -269,7 +269,7 @@
(set! (-> v1-5 base) (&+ (the-as pointer a0-2) 16))
)
(dma-bucket-insert-tag
(the-as (inline-array dma-bucket) (-> *display* frames (-> *display* on-screen) bucket-group))
(-> *display* frames (-> *display* on-screen) bucket-group)
(bucket-id bucket-318)
a2-0
(the-as (pointer dma-tag) a3-16)

View File

@ -3,15 +3,15 @@
;; definition of type display-frame
(deftype display-frame (basic)
((buffer dma-buffer 11 :offset-assert 4)
(calc-buf dma-buffer :offset 8)
(vu1-buf dma-buffer :offset 8)
(debug-buf dma-buffer :offset 36)
(global-buf dma-buffer :offset 40)
(bucket-group dma-bucket :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64)
((buffer dma-buffer 11 :offset-assert 4)
(calc-buf dma-buffer :offset 8)
(vu1-buf dma-buffer :offset 8)
(debug-buf dma-buffer :offset 36)
(global-buf dma-buffer :offset 40)
(bucket-group (inline-array dma-bucket) :offset 44)
(profile-array profile-array :inline :offset-assert 48)
(start-time time-frame :offset-assert 56)
(run-time time-frame :offset-assert 64)
)
:method-count-assert 9
:size-assert #x48

View File

@ -0,0 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol emerc-vu1-block, type vu-function
(define emerc-vu1-block (new 'static 'vu-function :length #x56b :qlength #x2b6))

View File

@ -0,0 +1,260 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for function emerc-vu1-initialize-chain
;; INFO: Used lq/sq
(defun emerc-vu1-initialize-chain ((arg0 dma-gif-packet))
(let ((gp-0 (the-as object (merc-vu1-add-vu-function (the-as dma-packet arg0) emerc-vu1-block 1))))
(set! (-> (the-as dma-gif-packet gp-0) dma-vif dma) (new 'static 'dma-tag :qwc #xb :id (dma-tag-id cnt)))
(set! (-> (the-as dma-gif-packet gp-0) dma-vif vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> (the-as dma-gif-packet gp-0) dma-vif vif1) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
(set! (-> (the-as (pointer vif-tag) gp-0) 4) (new 'static 'vif-tag :imm #x1ba :cmd (vif-cmd base)))
(set! (-> (the-as (pointer vif-tag) gp-0) 5) (new 'static 'vif-tag :imm #xfe46 :cmd (vif-cmd offset)))
(set! (-> (the-as (pointer vif-tag) gp-0) 6) (new 'static 'vif-tag))
(set! (-> (the-as (pointer vif-tag) gp-0) 7) (new 'static 'vif-tag :num #x9 :cmd (vif-cmd unpack-v4-32)))
(let ((s5-0 (the-as emerc-vu1-low-mem (&+ (the-as dma-gif-packet gp-0) 32))))
(set! (-> s5-0 tri-strip-gif tag)
(new 'static 'gif-tag64
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1)
:nreg #x3
)
)
(set! (-> s5-0 tri-strip-gif regs)
(new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))
)
(set! (-> s5-0 tri-strip-gif word 3) (shr (make-u128 0 (shl #x303e4000 32)) 32))
(set! (-> s5-0 ad-gif tag) (new 'static 'gif-tag64 :nloop #x5 :nreg #x1))
(set! (-> s5-0 ad-gif regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d)))
(set! (-> s5-0 hvdf-offset quad) (-> *math-camera* hvdf-off quad))
(quad-copy! (the-as pointer (-> s5-0 perspective)) (the-as pointer (-> *math-camera* perspective)) 4)
(set-vector! (-> s5-0 fog) (-> *math-camera* pfog0) (-> *math-camera* fog-min) (-> *math-camera* fog-max) 0.0)
(set-vector!
(-> s5-0 unperspect)
(/ 1.0 (-> *math-camera* perspective vector 0 x))
(/ 1.0 (-> *math-camera* perspective vector 1 y))
0.5
(/ 1.0 (-> *math-camera* perspective vector 2 w))
)
)
(let ((v1-21 (-> (the-as (inline-array dma-packet) gp-0) 11)))
(set! (-> v1-21 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> v1-21 vif0) (new 'static 'vif-tag))
(set! (-> v1-21 vif1) (new 'static 'vif-tag :cmd (vif-cmd mscal) :msk #x1 :imm #x0))
(&+ v1-21 16)
)
)
)
;; definition for function emerc-vu1-init-buffer
;; INFO: Return type mismatch int vs none.
(defun emerc-vu1-init-buffer ((dma-bucket bucket-id) (test gs-test) (arg2 int))
(let ((bucket (-> *display* frames (-> *display* on-screen) bucket-group dma-bucket)))
(when (!= bucket (-> bucket last))
(let* ((dma-buf (-> *display* frames (-> *display* on-screen) global-buf))
(s3-1 (-> dma-buf base))
)
(set! (-> dma-buf base)
(the-as pointer (emerc-vu1-initialize-chain (the-as dma-gif-packet (-> dma-buf base))))
)
(let* ((v1-12 dma-buf)
(a0-4 (the-as object (-> v1-12 base)))
)
(set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)))
(set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1))
(set! (-> v1-12 base) (&+ (the-as pointer a0-4) 16))
)
(let* ((v1-13 dma-buf)
(a0-6 (the-as object (-> v1-13 base)))
)
(set! (-> (the-as gs-gif-tag a0-6) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1))
(set! (-> (the-as gs-gif-tag a0-6) 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-13 base) (&+ (the-as pointer a0-6) 16))
)
(let* ((v1-14 dma-buf)
(a0-8 (-> v1-14 base))
)
(set! (-> (the-as (pointer gs-test) a0-8) 0) test)
(set! (-> (the-as (pointer gs-reg64) a0-8) 1) (gs-reg64 test-1))
(set! (-> v1-14 base) (&+ a0-8 16))
)
(let ((v1-15 (the-as dma-packet (-> dma-buf base))))
(set! (-> v1-15 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> bucket next)))
(set! (-> v1-15 vif0) (new 'static 'vif-tag))
(set! (-> v1-15 vif1) (new 'static 'vif-tag))
(set! (-> dma-buf base) (the-as pointer (the-as dma-packet (&+ v1-15 16))))
)
(set! (-> bucket next) (the-as uint s3-1))
)
)
)
0
(none)
)
;; definition for function emerc-vu1-init-buffers
;; INFO: Return type mismatch int vs none.
(defun emerc-vu1-init-buffers ()
(when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask rn14))
(emerc-vu1-init-buffer (bucket-id bucket-15) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-26) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-37) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-48) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-59) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-70) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer
(bucket-id bucket-189)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-198)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-202)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-206)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-210)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-214)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-218)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-222)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer (bucket-id bucket-80) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-89) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer (bucket-id bucket-98) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) 0)
(emerc-vu1-init-buffer
(bucket-id bucket-107)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-116)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-125)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-193)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-132)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-142)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-152)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-162)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-172)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-182)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-226)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-230)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-234)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-238)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-242)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-246)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(emerc-vu1-init-buffer
(bucket-id bucket-250)
(new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal))
0
)
)
0
(none)
)

View File

@ -744,12 +744,12 @@
;; definition of type emerc-vu1-low-mem
(deftype emerc-vu1-low-mem (structure)
((tri-strip-gif qword :inline :offset-assert 0)
(ad-gif qword :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective vector 4 :inline :offset-assert 48)
(fog vector :inline :offset-assert 112)
(unperspect vector :inline :offset-assert 128)
((tri-strip-gif gs-gif-tag :inline :offset-assert 0)
(ad-gif gs-gif-tag :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective vector 4 :inline :offset-assert 48)
(fog vector :inline :offset-assert 112)
(unperspect vector :inline :offset-assert 128)
)
:method-count-assert 9
:size-assert #x90
@ -896,7 +896,3 @@
;; failed to figure out what this is:
0

View File

@ -912,7 +912,7 @@
(set! (-> dma-buff base) (&+ (the-as pointer pkt7) 16))
)
(dma-bucket-insert-tag
(the-as (inline-array dma-bucket) (-> *display* frames (-> *display* on-screen) bucket-group))
(-> *display* frames (-> *display* on-screen) bucket-group)
(bucket-id bucket-313)
dma-bucket-begin
(the-as (pointer dma-tag) a3-0)

View File

@ -580,7 +580,7 @@
(set! (-> s2-1 base) (&+ v1-121 16))
)
(dma-bucket-insert-tag
(the-as (inline-array dma-bucket) (-> *display* frames (-> *display* on-screen) bucket-group))
(-> *display* frames (-> *display* on-screen) bucket-group)
(the-as bucket-id arg4)
s3-1
(the-as (pointer dma-tag) a3-2)

View File

@ -30,6 +30,13 @@ std::string get_expected(const std::string& name) {
}
} // namespace
TEST(VuDisasm, Emerc) {
auto data = get_test_data("jak2/emerc-vu1");
VuDisassembler disasm(VuDisassembler::VuKind::VU1);
auto prog = disasm.disassemble(data.data(), data.size() * 4, false);
EXPECT_EQ(disasm.to_string(prog), get_expected("jak2/emerc-vu1"));
}
TEST(VuDisasm, Sprite_Jak2) {
auto data = get_test_data("jak2/sprite");
VuDisassembler disasm(VuDisassembler::VuKind::VU1);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff