[decompiler] Update vector ops, reduce casts (#3849)

Update the decompiler to use the new vf macros.

Also, fix a bunch of silly casting issues where accessing inline fields
with an offset of 0 would be better than a cast:

![image](https://github.com/user-attachments/assets/885bbb07-634f-47b8-99f5-5a947941cdde)

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
This commit is contained in:
water111
2025-01-20 16:32:58 -05:00
committed by GitHub
parent 98d6618a8b
commit 7348e6a4ff
958 changed files with 8680 additions and 10112 deletions
+11 -20
View File
@@ -30,10 +30,10 @@
(.add.mul.z.vf vf5 vf3 vf5 acc)
(.div.vf Q vf9 vf5 :fsf #b0 :ftf #b11)
(.wait.vf)
(.mul.vf vf5 vf5 Q :mask #b111)
(.mul.vf.xyz vf5 vf5 Q)
(.add.vf vf5 vf5 vf8)
(.max.x.vf vf5 vf5 vf0 :mask #b1000)
(.min.x.vf vf5 vf5 vf6 :mask #b1000)
(.max.x.vf.w vf5 vf5 vf0)
(.min.x.vf.w vf5 vf5 vf6)
(vftoi4.xyzw vf5 vf5)
(.svf (&-> out quad) vf5)
out
@@ -51,7 +51,7 @@
)
(set! (-> pt-copy quad) (-> pt quad))
(set! (-> pt-copy w) 1.0)
(when (transform-point-qword! (the-as vector4w (-> s5-0 vector)) pt-copy)
(when (transform-point-qword! (-> s5-0 vector 0) pt-copy)
(with-dma-buffer-add-bucket ((buf (-> *display* frames (-> *display* on-screen) debug-buf))
bucket
)
@@ -189,9 +189,7 @@
(when (debug-line-clip? sv-128 sv-144 start var-end)
(set! (-> sv-128 w) 1.0)
(set! (-> sv-144 w) 1.0)
(when (and (transform-point-qword! (the-as vector4w (-> s4-0 vector)) sv-128)
(transform-point-qword! (-> s4-0 vector 1) sv-144)
)
(when (and (transform-point-qword! (-> s4-0 vector 0) sv-128) (transform-point-qword! (-> s4-0 vector 1) sv-144))
(with-dma-buffer-add-bucket ((buf2 (-> *display* frames (-> *display* on-screen) debug-buf))
bucket
)
@@ -368,7 +366,7 @@
(set! (-> a1-3 w) 1.0)
(set! (-> s2-0 w) 1.0)
(set! (-> s1-0 w) 1.0)
(when (and (transform-point-qword! (the-as vector4w (-> s5-0 vector)) a1-3)
(when (and (transform-point-qword! (-> s5-0 vector 0) a1-3)
(transform-point-qword! (-> s5-0 vector 1) s2-0)
(transform-point-qword! (-> s5-0 vector 2) s1-0)
)
@@ -1174,7 +1172,7 @@
enable
bucket
(-> mat trans)
(the-as vector (-> mat vector))
(-> mat vector 0)
line-length
(new 'static 'rgba :r #xff :a #x80)
)
@@ -1199,14 +1197,7 @@
;; definition (debug) for function add-debug-rot-matrix
(defun-debug add-debug-rot-matrix ((enable symbol) (bucket bucket-id) (mat matrix) (position vector))
(add-debug-vector
enable
bucket
position
(the-as vector (-> mat vector))
(meters 2)
(new 'static 'rgba :r #xff :a #x80)
)
(add-debug-vector enable bucket position (-> mat vector 0) (meters 2) (new 'static 'rgba :r #xff :a #x80))
(add-debug-vector enable bucket position (-> mat vector 1) (meters 2) (new 'static 'rgba :g #xff :a #x80))
(add-debug-vector enable bucket position (-> mat vector 2) (meters 2) (new 'static 'rgba :b #xff :a #x80))
mat
@@ -1540,9 +1531,9 @@
(.lvf vf5 (&-> v1-3 quad))
)
(.lvf vf4 (&-> position quad))
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> sphere-pos quad) vf6)
(let ((color-rgba (logior (logior (logior (shr (shl (the int (* 128.0 (-> light color w))) 56) 32)
(shr (shl (the int (* 128.0 (-> light color z))) 56) 40)
+8 -8
View File
@@ -781,7 +781,7 @@
(while (< s0-6 s1-5)
(when (and a0-36 (logtest? (-> a0-36 flags) (editable-flag selected)))
(if (= (-> s2-4 w) 0.0)
(editable-method-20 a0-36 s5-4 (the-as vector s4-4) s3-4 s2-4)
(editable-method-20 a0-36 s5-4 (-> s4-4 0) s3-4 s2-4)
(editable-method-15 a0-36 s2-4 56)
)
)
@@ -807,7 +807,7 @@
(while (< s0-7 s1-6)
(when (and a0-40 (logtest? (-> a0-40 flags) (editable-flag selected)))
(if (= (-> s2-5 w) 0.0)
(editable-method-20 a0-40 s5-5 (the-as vector s4-5) s3-5 s2-5)
(editable-method-20 a0-40 s5-5 (-> s4-5 0) s3-5 s2-5)
(editable-method-15 a0-40 s2-5 56)
)
)
@@ -889,7 +889,7 @@
(set! (-> arg0 region) (new 'debug 'editable-region))
)
(sound-play-by-spec (static-sound-spec "beep" :fo-curve 1) (new-sound-id) (the-as vector #t))
(let* ((a2-3 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (the-as vector (-> arg2 pos))))
(let* ((a2-3 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (-> arg2 pos 0)))
(s3-4 (new 'debug 'editable-sphere a2-3 2048.0 (-> arg0 region)))
)
(set! (-> arg0 data s4-3) s3-4)
@@ -906,7 +906,7 @@
(set! (-> arg0 region) (new 'debug 'editable-region))
)
(sound-play-by-spec (static-sound-spec "beep" :fo-curve 1) (new-sound-id) (the-as vector #t))
(let* ((a2-7 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (the-as vector (-> arg2 pos))))
(let* ((a2-7 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (-> arg2 pos 0)))
(s3-6 (new 'debug 'editable-point a2-7 (-> arg0 region)))
)
(set! (-> arg0 data s4-4) s3-6)
@@ -920,7 +920,7 @@
(let ((s4-5 (editable-array-method-11 arg0)))
(when (>= s4-5 0)
(sound-play-by-spec (static-sound-spec "beep" :fo-curve 1) (new-sound-id) (the-as vector #t))
(let* ((a2-11 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (the-as vector (-> arg2 pos))))
(let* ((a2-11 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (-> arg2 pos 0)))
(s3-8 (new 'debug 'editable-sample a2-11 *editable-sample-region*))
)
(set! (-> arg0 data s4-5) s3-8)
@@ -946,7 +946,7 @@
(let ((s4-7 (editable-array-method-11 arg0)))
(when (>= s4-7 0)
(sound-play-by-spec (static-sound-spec "beep" :fo-curve 1) (new-sound-id) (the-as vector #t))
(let* ((a2-18 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (the-as vector (-> arg2 pos))))
(let* ((a2-18 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (-> arg2 pos 0)))
(s3-13 (new 'debug 'editable-light a2-18 2048.0 *editable-light-region*))
)
(set! (-> arg0 data s4-7) s3-13)
@@ -962,7 +962,7 @@
(let ((s4-8 (editable-array-method-11 arg0)))
(when (>= s4-8 0)
(sound-play-by-spec (static-sound-spec "beep" :fo-curve 1) (new-sound-id) (the-as vector #t))
(let* ((a2-22 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (the-as vector (-> arg2 pos))))
(let* ((a2-22 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (-> arg2 pos 0)))
(s3-15 (new 'debug 'editable-entity a2-22 *editable-entity-region*))
)
(set! (-> arg0 data s4-8) s3-15)
@@ -977,7 +977,7 @@
(if (and (-> arg0 region) (-> arg0 region locked))
(set! (-> arg0 region) (new 'debug 'editable-region))
)
(let ((a1-42 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (the-as vector (-> arg2 pos)))))
(let ((a1-42 (editable-array-method-17 arg0 (new 'stack-no-clear 'vector) (-> arg2 pos 0))))
(insert-box arg0 a1-42)
)
)
+3 -6
View File
@@ -1363,8 +1363,8 @@
(dotimes (v1-0 6)
(set! (-> s4-0 quad v1-0) (the-as uint128 0))
)
(if (>= (editable-face-method-30 this (the-as (inline-array vector) s4-0)) 3)
(normal-of-plane arg0 (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1) (-> s4-0 vector 2))
(if (>= (editable-face-method-30 this (-> s4-0 vector)) 3)
(normal-of-plane arg0 (-> s4-0 vector 0) (-> s4-0 vector 1) (-> s4-0 vector 2))
)
)
(if (logtest? (-> this flags) (editable-flag orient))
@@ -1574,10 +1574,7 @@
1.0
)
(vector-normalize! (editable-face-method-31 this (-> sv-368 vector 1)) 1.0)
(vector-normalize!
(vector-cross! (the-as vector (-> sv-368 vector)) (-> sv-368 vector 2) (-> sv-368 vector 1))
1.0
)
(vector-normalize! (vector-cross! (-> sv-368 vector 0) (-> sv-368 vector 2) (-> sv-368 vector 1)) 1.0)
(set! (-> sv-368 trans quad) (-> (edit-get-trans (-> this vertex 0)) quad))
(set! (-> sv-368 trans w) 1.0)
(matrix-4x4-inverse! sv-368 sv-368)
+39 -42
View File
@@ -328,28 +328,25 @@
(let ((v1-23 (-> this nav-graph visnode-array data s3-1)))
(when (and (= (-> v1-23 runtime-edge-id) arg0) (not (logtest? (-> v1-23 mysql-save-flag) (mysql-save-flag delete))))
(vector-!
(the-as vector (-> s4-0 vector))
(-> s4-0 vector 0)
(the-as
vector
(+ (the-as uint (-> this nav-graph node-array data 0 position)) (* 80 (-> v1-23 runtime-node-id)))
)
(-> s4-0 trans)
)
(vector-normalize!
(the-as vector (-> s4-0 vector))
(fmax 15360.0 (+ -15360.0 (vector-length (the-as vector (-> s4-0 vector)))))
)
(vector-rotate-around-y! (-> s4-0 vector 1) (the-as vector (-> s4-0 vector)) 24576.0)
(vector-normalize! (-> s4-0 vector 0) (fmax 15360.0 (+ -15360.0 (vector-length (-> s4-0 vector 0)))))
(vector-rotate-around-y! (-> s4-0 vector 1) (-> s4-0 vector 0) 24576.0)
(vector-normalize! (-> s4-0 vector 1) 16384.0)
(vector-rotate-around-y! (-> s4-0 vector 2) (the-as vector (-> s4-0 vector)) -24576.0)
(vector-rotate-around-y! (-> s4-0 vector 2) (-> s4-0 vector 0) -24576.0)
(vector-normalize! (-> s4-0 vector 2) 16384.0)
(vector+! (the-as vector (-> s4-0 vector)) (the-as vector (-> s4-0 vector)) (-> s4-0 trans))
(vector+! (-> s4-0 vector 2) (-> s4-0 vector 2) (the-as vector (-> s4-0 vector)))
(vector+! (-> s4-0 vector 1) (-> s4-0 vector 1) (the-as vector (-> s4-0 vector)))
(vector+! (-> s4-0 vector 0) (-> s4-0 vector 0) (-> s4-0 trans))
(vector+! (-> s4-0 vector 2) (-> s4-0 vector 2) (-> s4-0 vector 0))
(vector+! (-> s4-0 vector 1) (-> s4-0 vector 1) (-> s4-0 vector 0))
(add-debug-line
#t
(bucket-id debug2)
(the-as vector (-> s4-0 vector))
(-> s4-0 vector 0)
(-> s4-0 vector 1)
*color-light-yellow*
#f
@@ -358,7 +355,7 @@
(add-debug-line
#t
(bucket-id debug2)
(the-as vector (-> s4-0 vector))
(-> s4-0 vector 0)
(-> s4-0 vector 2)
*color-light-yellow*
#f
@@ -373,12 +370,12 @@
#f
(the-as rgba -1)
)
(vector-lerp! (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1) (-> s4-0 vector 2) 0.5)
(vector-lerp! (-> s4-0 vector 0) (-> s4-0 vector 1) (-> s4-0 vector 2) 0.5)
(add-debug-line
#t
(bucket-id debug2)
(-> s4-0 trans)
(the-as vector (-> s4-0 vector))
(-> s4-0 vector 0)
*color-light-yellow*
#f
(the-as rgba -1)
@@ -462,9 +459,9 @@
)
(.lvf vf4 (&-> v1-6 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> a2-2 quad) vf6)
(t9-3 a0-8 (the-as bucket-id a1-4) a2-2 (-> gp-0 radius) *color-green*)
)
@@ -480,9 +477,9 @@
(.lvf vf5 (&-> s5-1 quad))
(.lvf vf4 (&-> v1-7 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> a2-3 quad) vf6)
(t9-4 a0-9 (the-as bucket-id a1-5) a2-3 (-> gp-0 radius) *color-green*)
)
@@ -547,8 +544,8 @@
)
(.lvf vf4 (&-> a0-11 quad))
)
(.add.x.vf vf5 vf0 vf0 :mask #b1000)
(.add.x.vf vf5 vf4 vf6 :mask #b111)
(.add.x.vf.w vf5 vf0 vf0)
(.add.x.vf.xyz vf5 vf4 vf6)
(.svf (&-> a1-4 quad) vf5)
)
(let ((a1-5 (-> v1-21 1)))
@@ -558,8 +555,8 @@
)
(.lvf vf4 (&-> a0-12 quad))
)
(.add.x.vf vf5 vf0 vf0 :mask #b1000)
(.add.x.vf vf5 vf4 vf6 :mask #b111)
(.add.x.vf.w vf5 vf0 vf0)
(.add.x.vf.xyz vf5 vf4 vf6)
(.svf (&-> a1-5 quad) vf5)
)
(add-debug-box #t (bucket-id debug2) (-> v1-21 0) (-> v1-21 1) *color-yellow*)
@@ -708,9 +705,9 @@
)
(.lvf vf4 (&-> s4-2 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> s0-0 quad) vf6)
)
(reverse-transform-point! s5-1 s2-0 s3-0 s1-0)
@@ -737,9 +734,9 @@
)
(.lvf vf4 (&-> v1-16 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> a1-3 quad) vf6)
)
(vector+!
@@ -830,7 +827,7 @@
)
)
((and (-> this next-state) (= (-> this next-state name) 'move-plane))
(vector-cross! s3-0 *up-vector* (the-as vector (-> (camera-matrix) vector)))
(vector-cross! s3-0 *up-vector* (-> (camera-matrix) vector 0))
(vector-normalize! s3-0 1.0)
(set! (-> s2-0 quad) (-> this mouse-hit quad))
(reverse-transform-point! s5-1 s2-0 s3-0 s1-0)
@@ -907,7 +904,7 @@
(dotimes (a0-64 4)
(set! (-> v1-57 quad a0-64) (the-as uint128 0))
)
(vector+! (the-as vector (-> v1-57 vector)) s5-1 (new 'static 'vector :x 8192.0 :z 8192.0 :w 1.0))
(vector+! (-> v1-57 vector 0) s5-1 (new 'static 'vector :x 8192.0 :z 8192.0 :w 1.0))
(vector+! (-> v1-57 vector 1) s5-1 (new 'static 'vector :x 8192.0 :z -8192.0 :w 1.0))
(vector+! (-> v1-57 vector 2) s5-1 (new 'static 'vector :x -8192.0 :z -8192.0 :w 1.0))
(vector+! (-> v1-57 trans) s5-1 (new 'static 'vector :x -8192.0 :z 8192.0 :w 1.0))
@@ -1131,8 +1128,8 @@
(.lvf vf4 (&-> v1-18 quad))
(.lvf vf5 (&-> a0-13 quad))
)
(.mov.vf vf6 vf0 :mask #b1000)
(.sub.vf vf6 vf4 vf5 :mask #b111)
(.mov.vf.w vf6 vf0)
(.sub.vf.xyz vf6 vf4 vf5)
(.svf (&-> sv-144 quad) vf6)
(let ((a3-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) s2-0 1.0))
(t0-0 1024.0)
@@ -1190,8 +1187,8 @@
)
(.lvf vf4 (&-> a0-5 quad))
)
(.add.x.vf vf5 vf0 vf0 :mask #b1000)
(.add.x.vf vf5 vf4 vf6 :mask #b111)
(.add.x.vf.w vf5 vf0 vf0)
(.add.x.vf.xyz vf5 vf4 vf6)
(.svf (the-as (pointer uint128) (&-> a1-1 0)) vf5)
)
(let ((a1-2 (&+ v1-3 16)))
@@ -1201,8 +1198,8 @@
)
(.lvf vf4 (&-> a0-6 quad))
)
(.add.x.vf vf5 vf0 vf0 :mask #b1000)
(.add.x.vf vf5 vf4 vf6 :mask #b111)
(.add.x.vf.w vf5 vf0 vf0)
(.add.x.vf.xyz vf5 vf4 vf6)
(.svf (&-> a1-2 quad) vf5)
)
(add-debug-box #t (bucket-id debug2) (the-as vector (&-> v1-3 x)) (&+ v1-3 16) *color-green*)
@@ -2284,12 +2281,12 @@
(set! sv-160 s1-0)
(let ((v0-0 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> a1-3 position) (-> v1-27 position)) 1.0))
)
(.mov.vf vf6 vf0 :mask #b1000)
(.mov.vf.w vf6 vf0)
(.lvf vf4 (&-> sv-160 quad))
(.lvf vf5 (&-> v0-0 quad))
)
)
(.add.vf vf6 vf4 vf5 :mask #b111)
(.add.vf.xyz vf6 vf4 vf5)
(.svf (&-> sv-176 quad) vf6)
(set! sv-112 (+ sv-112 1))
sv-112
@@ -2302,12 +2299,12 @@
(set! sv-192 s0-0)
(let ((v0-1 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> a1-9 position) (-> v1-40 position)) 1.0))
)
(.mov.vf vf6 vf0 :mask #b1000)
(.mov.vf.w vf6 vf0)
(.lvf vf4 (&-> sv-192 quad))
(.lvf vf5 (&-> v0-1 quad))
)
)
(.add.vf vf6 vf4 vf5 :mask #b111)
(.add.vf.xyz vf6 vf4 vf5)
(.svf (&-> sv-208 quad) vf6)
(set! sv-96 (+ sv-96 1))
sv-96
+1 -1
View File
@@ -78,7 +78,7 @@
(when (!= gp-1 (-> self old-group))
(when (nonzero? (-> self part))
(kill-and-free-particles (-> self part))
(set! (-> self heap-cur) (&-> (-> self part) type))
(set! (-> self heap-cur) (&-> self part type))
)
(set! (-> self part) (create-launch-control gp-1 self))
)