[decompiler] clean up vector detection and add vector float product detection (#638)

* change

* recognize vector float product and update tests
This commit is contained in:
water111
2021-06-27 17:24:35 -04:00
committed by GitHub
parent bfb1fbe1fc
commit a6d5c4eda3
146 changed files with 1085 additions and 1653 deletions
+4 -22
View File
@@ -8,28 +8,10 @@
;; definition for function position-in-front-of-camera!
(defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
)
(init-vf0-vector)
(let ((v1-0 arg0))
(let ((a0-2 (-> *math-camera* inv-camera-rot vector 2))
(f0-0 arg1)
)
(.lvf vf1 (&-> a0-2 quad))
(let ((a0-3 f0-0))
(.mov vf2 a0-3)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-0 quad) vf1)
)
(vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot vector 1) arg2)
(vector+! arg0 arg0 (-> *math-camera* trans))
arg0
)
(vector-float*! arg0 (-> *math-camera* inv-camera-rot vector 2) arg1)
(vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot vector 1) arg2)
(vector+! arg0 arg0 (-> *math-camera* trans))
arg0
)
;; definition for function matrix-local->world
+28 -68
View File
@@ -238,77 +238,37 @@
;; INFO: Return type mismatch int vs none.
;; TODO - vector-float*! replacement
(defmethod TODO-RENAME-10 cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
)
(init-vf0-vector)
(let ((gp-0 (new 'stack-no-clear 'vector)))
(let ((f0-0 0.0))
)
(cond
(arg0
(vector+! gp-0 (-> obj target) arg0)
(vector-! gp-0 gp-0 (-> obj value))
)
(else
(vector-! gp-0 (-> obj target) (-> obj value))
)
)
(let ((f30-1 (* (-> obj max-partial) (vector-length gp-0))))
(let ((v1-3 gp-0))
(let ((a0-5 gp-0)
(f0-3 (* (-> obj accel) (-> *display* time-adjust-ratio)))
)
(.lvf vf1 (&-> a0-5 quad))
(let ((a0-6 f0-3))
(.mov vf2 a0-6)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-3 quad) vf1)
)
(vector+! (-> obj vel) (-> obj vel) gp-0)
(let ((f0-4 (vector-length (-> obj vel)))
(f1-2 (fmin f30-1 (-> obj max-vel)))
)
(when (< f1-2 f0-4)
(let ((v1-6 (-> obj vel)))
(let ((a0-9 (-> obj vel))
(f0-5 (/ f1-2 f0-4))
)
(.lvf vf1 (&-> a0-9 quad))
(let ((a0-10 f0-5))
(.mov vf2 a0-10)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-6 quad) vf1)
)
)
)
)
(let ((v1-7 gp-0))
(let ((a0-11 (-> obj vel))
(f0-6 (-> *display* time-adjust-ratio))
)
(.lvf vf1 (&-> a0-11 quad))
(let ((a0-12 f0-6))
(.mov vf2 a0-12)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-7 quad) vf1)
)
(vector+! (-> obj value) (-> obj value) gp-0)
(let ((gp-0 (new 'stack-no-clear 'vector)))
0.0
(cond
(arg0
(vector+! gp-0 (-> obj target) arg0)
(vector-! gp-0 gp-0 (-> obj value))
)
(else
(vector-! gp-0 (-> obj target) (-> obj value))
)
)
(let ((v0-2 0))
(let ((f30-1 (* (-> obj max-partial) (vector-length gp-0))))
(vector-float*!
gp-0
gp-0
(* (-> obj accel) (-> *display* time-adjust-ratio))
)
(vector+! (-> obj vel) (-> obj vel) gp-0)
(let ((f0-4 (vector-length (-> obj vel)))
(f1-2 (fmin f30-1 (-> obj max-vel)))
)
(if (< f1-2 f0-4)
(vector-float*! (-> obj vel) (-> obj vel) (/ f1-2 f0-4))
)
)
)
(none)
(vector-float*! gp-0 (-> obj vel) (-> *display* time-adjust-ratio))
(vector+! (-> obj value) (-> obj value) gp-0)
)
0
(none)
)
;; definition of type cam-rotation-tracker
+28 -58
View File
@@ -11,72 +11,42 @@
;; definition for function update-wind
;; INFO: Return type mismatch int vs none.
(defun update-wind ((arg0 wind-work) (arg1 (array uint8)))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
(let* ((f0-1 (+ (-> arg0 wind-normal w) (rand-vu-float-range -1024.0 1024.0)))
(f30-1 (- f0-1 (* (the float (the int (/ f0-1 65536.0))) 65536.0)))
)
(init-vf0-vector)
(let*
((f0-1 (+ (-> arg0 wind-normal w) (rand-vu-float-range -1024.0 1024.0)))
(f30-1 (- f0-1 (* (the float (the int (/ f0-1 65536.0))) 65536.0)))
)
(set! (-> arg0 wind-normal w) f30-1)
(set! (-> arg0 wind-normal x) (cos f30-1))
(set! (-> arg0 wind-normal z) (sin f30-1))
)
(set! (-> arg0 wind-time) (+ (-> arg0 wind-time) 1))
(let* ((s4-0 (logand (-> arg0 wind-time) 63))
(f0-4 (rand-vu-float-range 0.0 100.0))
(v1-5 (/ (-> arg0 wind-time) (the-as uint 120)))
(f1-6
(*
0.008333334
(the float (mod (-> arg0 wind-time) (the-as uint 120)))
)
(set! (-> arg0 wind-time) (+ (-> arg0 wind-time) 1))
(let* ((s4-0 (logand (-> arg0 wind-time) 63))
(f0-4 (rand-vu-float-range 0.0 100.0))
(v1-5 (/ (-> arg0 wind-time) (the-as uint 120)))
(f1-6 (* 0.008333334
(the float (mod (-> arg0 wind-time) (the-as uint 120)))
)
)
(f2-4
(*
0.0625
(the float (-> arg1 (mod (the-as int v1-5) (-> arg1 length))))
)
(f2-4 (* 0.0625
(the float (-> arg1 (mod (the-as int v1-5) (-> arg1 length))))
)
)
(f0-5
(*
(+
(*
(-
(*
0.0625
(the
float
(-> arg1 (mod (the-as int (+ v1-5 1)) (-> arg1 length)))
)
)
f2-4
)
f1-6
)
f2-4
)
f0-4
)
(f0-5 (* (+ (* (- (* 0.0625
(the float (-> arg1 (mod (the-as int (+ v1-5 1)) (-> arg1 length)))
)
)
f2-4
)
f1-6
)
f2-4
)
f0-4
)
)
)
)
(set! (-> *wind-work* wind-force s4-0) f0-5)
(let ((v1-14 (-> *wind-work* wind-array s4-0)))
(let ((a0-15 (-> arg0 wind-normal)))
(.lvf vf1 (&-> a0-15 quad))
)
(let ((a0-16 f0-5))
(.mov vf2 a0-16)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-14 quad) vf1)
)
(vector-float*! (-> *wind-work* wind-array s4-0) (-> arg0 wind-normal) f0-5)
)
(let ((v0-4 0))
)
(none)
)
0
(none)
)
+3 -40
View File
@@ -521,26 +521,8 @@
(defun vector-v! ((arg0 vector))
"Convert a velocity to a displacement per frame. The velocity should be in X/actual_second"
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
)
(init-vf0-vector)
(let ((v1-0 arg0))
(let ((a1-0 arg0)
(f0-0 (-> *display* seconds-per-frame))
)
(.lvf vf1 (&-> a1-0 quad))
(let ((a1-1 f0-0))
(.mov vf2 a1-1)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-0 quad) vf1)
)
arg0
)
(vector-float*! arg0 arg0 (-> *display* seconds-per-frame))
arg0
)
(defun vector-v+! ((result vector) (position vector) (velocity vector))
@@ -564,26 +546,7 @@
(defun vector-v*float! ((delta-p vector) (velocity vector) (scale float))
"Go from velocity to delta-p per frame, scaling by scale"
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
)
(init-vf0-vector)
(let ((v0-0 delta-p))
(let ((v1-0 velocity)
(f0-1 (* scale (-> *display* seconds-per-frame)))
)
(.lvf vf1 (&-> v1-0 quad))
(let ((v1-1 f0-1))
(.mov vf2 v1-1)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v0-0 quad) vf1)
v0-0
)
)
(vector-float*! delta-p velocity (* scale (-> *display* seconds-per-frame)))
)
(defun vector-v*float++! ((position vector) (velocity vector) (scale float))
+24 -74
View File
@@ -548,80 +548,30 @@
;; definition for method 10 of type oscillating-vector
;; todo vector-float*!
(defmethod dummy-10 oscillating-vector ((obj oscillating-vector) (arg0 vector))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
)
(init-vf0-vector)
(let ((s5-0 (new 'stack-no-clear 'vector)))
(cond
(arg0
(vector+! s5-0 (-> obj target) arg0)
(vector-! s5-0 s5-0 (-> obj value))
)
(else
(vector-! s5-0 (-> obj target) (-> obj value))
)
)
(let ((v1-3 s5-0))
(let ((a0-4 s5-0)
(f0-1 (* (-> obj accel) (-> *display* time-adjust-ratio)))
)
(.lvf vf1 (&-> a0-4 quad))
(let ((a0-5 f0-1))
(.mov vf2 a0-5)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-3 quad) vf1)
)
(vector+! (-> obj vel) (-> obj vel) s5-0)
(let ((f0-2 (vector-length (-> obj vel))))
(when (< (-> obj max-vel) f0-2)
(let ((v1-6 (-> obj vel)))
(let ((a0-8 (-> obj vel))
(f0-3 (/ (-> obj max-vel) f0-2))
)
(.lvf vf1 (&-> a0-8 quad))
(let ((a0-9 f0-3))
(.mov vf2 a0-9)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-6 quad) vf1)
)
)
)
(let ((v1-7 (-> obj vel)))
(let ((a0-10 (-> obj vel))
(f0-4 (-> obj damping))
)
(.lvf vf1 (&-> a0-10 quad))
(let ((a0-11 f0-4))
(.mov vf2 a0-11)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-7 quad) vf1)
)
(let ((v1-8 s5-0))
(let ((a0-12 (-> obj vel))
(f0-5 (-> *display* time-adjust-ratio))
)
(.lvf vf1 (&-> a0-12 quad))
(let ((a0-13 f0-5))
(.mov vf2 a0-13)
)
)
(.add.x.vf vf1 vf0 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-8 quad) vf1)
)
(vector+! (-> obj value) (-> obj value) s5-0)
(let ((s5-0 (new 'stack-no-clear 'vector)))
(cond
(arg0
(vector+! s5-0 (-> obj target) arg0)
(vector-! s5-0 s5-0 (-> obj value))
)
(else
(vector-! s5-0 (-> obj target) (-> obj value))
)
)
(-> obj value)
(vector-float*!
s5-0
s5-0
(* (-> obj accel) (-> *display* time-adjust-ratio))
)
(vector+! (-> obj vel) (-> obj vel) s5-0)
(let ((f0-2 (vector-length (-> obj vel))))
(if (< (-> obj max-vel) f0-2)
(vector-float*! (-> obj vel) (-> obj vel) (/ (-> obj max-vel) f0-2))
)
)
(vector-float*! (-> obj vel) (-> obj vel) (-> obj damping))
(vector-float*! s5-0 (-> obj vel) (-> *display* time-adjust-ratio))
(vector+! (-> obj value) (-> obj value) s5-0)
)
(-> obj value)
)