Files
jak-project/test/decompiler/reference/engine/util/sync-info_REF.gc
T
water111 5293f583a8 [decomp] clean up sync info (#735)
* clean up sync info

* clean up trajectory
2021-08-02 21:49:05 -04:00

872 lines
20 KiB
Common Lisp
Vendored

;;-*-Lisp-*-
(in-package goal)
;; definition for method 14 of type sync-info
;; INFO: Return type mismatch int vs none.
(defmethod
setup-params!
sync-info
((obj sync-info) (period uint) (phase float) (arg2 float) (arg3 float))
(set! (-> obj period) period)
(let* ((period-float (the float period))
(value (* phase period-float))
)
(set!
(-> obj offset)
(- value (* (the float (the int (/ value period-float))) period-float))
)
)
0
(none)
)
;; definition for method 14 of type sync-info-eased
;; INFO: Return type mismatch int vs none.
(defmethod
setup-params!
sync-info-eased
((obj sync-info-eased)
(period uint)
(phase float)
(out-param float)
(in-param float)
)
(set! (-> obj period) period)
(let* ((period-float (the float period))
(value (* phase period-float))
)
(set!
(-> obj offset)
(- value (* (the float (the int (/ value period-float))) period-float))
)
)
(if (< out-param 0.0)
(set! out-param 0.0)
)
(if (< 1.0 out-param)
(set! out-param 1.0)
)
(if (< in-param 0.001)
(set! in-param 0.001)
)
(if (< 1.0 in-param)
(set! in-param 1.0)
)
(let ((total-easing-phase (+ out-param in-param)))
(when (< 1.0 total-easing-phase)
(set! total-easing-phase 1.0)
(set! out-param (- 1.0 in-param))
)
(let* ((total-normal-phase (- 1.0 total-easing-phase))
(f0-10 out-param)
(f1-12 (+ out-param total-normal-phase))
(f2-5 (* f0-10 f0-10))
(f3-3 (+ (* (* 2.0 f0-10) (- f1-12 f0-10)) f2-5))
(f4-3 (/ f0-10 (- 1.0 f1-12)))
(y-end (+ (* (* (- 1.0 f1-12) (- 1.0 f1-12)) f4-3) f3-3))
)
(set! (-> obj tlo) f0-10)
(set! (-> obj thi) f1-12)
(set! (-> obj ylo) f2-5)
(set! (-> obj m2) f4-3)
(set! (-> obj yend) y-end)
)
)
0
(none)
)
;; definition for method 14 of type sync-info-paused
;; INFO: Return type mismatch int vs none.
(defmethod
setup-params!
sync-info-paused
((obj sync-info-paused)
(period uint)
(phase float)
(out-param float)
(in-param float)
)
(set! (-> obj period) period)
(let* ((f0-1 (the float period))
(f1-1 (* phase f0-1))
)
(set! (-> obj offset) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1)))
)
(cond
((< out-param 0.0)
(set! out-param 0.0)
)
((< 1.0 out-param)
(set! out-param 1.0)
)
)
(cond
((< in-param 0.0)
(set! in-param 0.0)
)
((< (- 1.0 out-param) in-param)
(set! in-param (- 1.0 out-param))
)
)
(set! (-> obj pause-after-in) in-param)
(set! (-> obj pause-after-out) out-param)
0
(none)
)
;; definition for method 15 of type sync-info
;; Used lq/sq
(defmethod
load-params!
sync-info
((obj sync-info)
(proc process)
(default-period uint)
(default-phase float)
(default-out float)
(default-in float)
)
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(cond
(v1-1
(setup-params!
obj
(the-as uint (the int (* 300.0 (-> (the-as (pointer float) v1-1) 0))))
(-> (the-as (pointer float) v1-1) 1)
0.15
0.15
)
#t
)
(else
(setup-params! obj default-period default-phase 0.15 0.15)
#f
)
)
)
)
;; definition for method 15 of type sync-info-eased
;; Used lq/sq
(defmethod
load-params!
sync-info-eased
((obj sync-info-eased)
(proc process)
(default-period uint)
(default-phase float)
(default-out float)
(default-in float)
)
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(cond
(v1-1
(if (>= (-> sv-16 elt-count) (the-as uint 4))
(setup-params!
obj
(the-as uint (the int (* 300.0 (-> (the-as (pointer float) v1-1) 0))))
(-> (the-as (pointer float) v1-1) 1)
(-> (the-as (pointer float) v1-1) 2)
(-> (the-as (pointer float) v1-1) 3)
)
(setup-params!
obj
(the-as uint (the int (* 300.0 (-> (the-as (pointer float) v1-1) 0))))
(-> (the-as (pointer float) v1-1) 1)
default-out
default-in
)
)
#t
)
(else
(setup-params! obj default-period default-phase default-out default-in)
#f
)
)
)
)
;; definition for method 15 of type sync-info-paused
;; Used lq/sq
(defmethod
load-params!
sync-info-paused
((obj sync-info-paused)
(proc process)
(default-period uint)
(default-phase float)
(default-out float)
(default-in float)
)
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(cond
(v1-1
(if (>= (-> sv-16 elt-count) (the-as uint 4))
(setup-params!
obj
(the-as uint (the int (* 300.0 (-> (the-as (pointer float) v1-1) 0))))
(-> (the-as (pointer float) v1-1) 1)
(-> (the-as (pointer float) v1-1) 2)
(-> (the-as (pointer float) v1-1) 3)
)
(setup-params!
obj
(the-as uint (the int (* 300.0 (-> (the-as (pointer float) v1-1) 0))))
(-> (the-as (pointer float) v1-1) 1)
default-out
default-in
)
)
#t
)
(else
(setup-params! obj default-period default-phase default-out default-in)
#f
)
)
)
)
;; definition for method 10 of type sync-info
(defmethod get-current-phase-no-mod sync-info ((obj sync-info))
(let* ((period (-> obj period))
(period-float (the float period))
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
)
(/
(-
current-time
(* (the float (the int (/ current-time period-float))) period-float)
)
period-float
)
)
)
;; definition for method 17 of type sync-info
(defmethod get-phase-offset sync-info ((obj sync-info))
(/ (-> obj offset) (the float (-> obj period)))
)
;; definition for method 16 of type sync-info
(defmethod sync-now! sync-info ((obj sync-info) (user-time-offset float))
(let* ((period (-> obj period))
(period-float (the float period))
(wrapped-user-offset
(-
user-time-offset
(*
(the float (the int (/ user-time-offset period-float)))
period-float
)
)
)
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
(current-time-wrapped
(/
(-
current-time
(* (the float (the int (/ current-time period-float))) period-float)
)
period-float
)
)
(combined-offset
(+
(+
(* (- wrapped-user-offset current-time-wrapped) period-float)
period-float
)
(-> obj offset)
)
)
(combined-offset-wrapped
(-
combined-offset
(*
(the float (the int (/ combined-offset period-float)))
period-float
)
)
)
)
(set! (-> obj offset) combined-offset-wrapped)
combined-offset-wrapped
)
)
;; definition for method 11 of type sync-info
(defmethod get-current-phase sync-info ((obj sync-info))
(let* ((period (-> obj period))
(period-float (the float period))
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
)
(/
(-
current-time
(* (the float (the int (/ current-time period-float))) period-float)
)
period-float
)
)
)
;; definition for method 11 of type sync-info-paused
(defmethod get-current-phase sync-info-paused ((obj sync-info-paused))
(let* ((period (-> obj period))
(period-float (the float period))
(max-phase 1.0)
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
)
(fmin
max-phase
(/
(-
current-time
(* (the float (the int (/ current-time period-float))) period-float)
)
(* period-float (- 1.0 (-> obj pause-after-out)))
)
)
)
)
;; definition for method 9 of type sync-info
(defmethod get-current-value sync-info ((obj sync-info) (max-val float))
(let* ((period (-> obj period))
(period-float (the float period))
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
)
(*
(/
(-
current-time
(* (the float (the int (/ current-time period-float))) period-float)
)
period-float
)
max-val
)
)
)
;; definition for method 9 of type sync-info-paused
(defmethod
get-current-value
sync-info-paused
((obj sync-info-paused) (arg0 float))
(* (get-current-phase obj) arg0)
)
;; definition for method 13 of type sync-info
(defmethod get-current-phase-with-mirror sync-info ((obj sync-info))
(let* ((period (-> obj period))
(period-float (the float period))
(max-val 2.0)
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
(phase-out-of-2
(*
max-val
(/
(-
current-time
(*
(the float (the int (/ current-time period-float)))
period-float
)
)
period-float
)
)
)
)
(if (>= phase-out-of-2 1.0)
(set! phase-out-of-2 (- 2.0 phase-out-of-2))
)
phase-out-of-2
)
)
;; definition for method 13 of type sync-info-eased
(defmethod get-current-phase-with-mirror sync-info-eased ((obj sync-info-eased))
(let* ((period (-> obj period))
(period-float (the float period))
(max-val 2.0)
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
(current-val
(*
max-val
(/
(-
current-time
(*
(the float (the int (/ current-time period-float)))
period-float
)
)
period-float
)
)
)
(in-mirror? #f)
)
(when (>= current-val 1.0)
(set! in-mirror? #t)
(set! current-val (+ -1.0 current-val))
)
(let* ((tlo (-> obj tlo))
(eased-phase (/ (cond
((< current-val tlo)
(* current-val current-val)
)
((< current-val (-> obj thi))
(+ (* (* 2.0 tlo) (- current-val tlo)) (-> obj ylo))
)
(else
(let ((f1-7 (- 1.0 current-val)))
(- (-> obj yend) (* (* f1-7 f1-7) (-> obj m2)))
)
)
)
(-> obj yend)
)
)
)
(if in-mirror?
(set! eased-phase (- 1.0 eased-phase))
)
eased-phase
)
)
)
;; definition for method 13 of type sync-info-paused
(defmethod
get-current-phase-with-mirror
sync-info-paused
((obj sync-info-paused))
(let* ((v1-0 (-> obj period))
(f1-0 (the float v1-0))
(f0-1 2.0)
(f2-2
(+
(the float (mod (-> *display* base-frame-counter) v1-0))
(-> obj offset)
)
)
(f0-2
(*
f0-1
(/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0)
)
)
(f1-3 (- 1.0 (* 2.0 (-> obj pause-after-in))))
(f2-7 (- 1.0 (* 2.0 (-> obj pause-after-out))))
)
(cond
((>= f0-2 (+ 1.0 f1-3))
0.0
)
((< 1.0 f0-2)
(- 1.0 (/ (+ -1.0 f0-2) f1-3))
)
((>= f0-2 f2-7)
1.0
)
(else
(/ f0-2 f2-7)
)
)
)
)
;; definition for method 12 of type sync-info
(defmethod
get-current-value-with-mirror
sync-info
((obj sync-info) (max-out-val float))
(let* ((period (-> obj period))
(period-float (the float period))
(max-val 2.0)
(current-time
(+
(the float (mod (-> *display* base-frame-counter) period))
(-> obj offset)
)
)
(current-val
(*
max-val
(/
(-
current-time
(*
(the float (the int (/ current-time period-float)))
period-float
)
)
period-float
)
)
)
)
(if (>= current-val 1.0)
(set! current-val (- 2.0 current-val))
)
(* current-val max-out-val)
)
)
;; definition for method 12 of type sync-info-eased
(defmethod
get-current-value-with-mirror
sync-info-eased
((obj sync-info-eased) (max-out-val float))
(* (get-current-phase-with-mirror obj) max-out-val)
)
;; definition for method 12 of type sync-info-paused
(defmethod
get-current-value-with-mirror
sync-info-paused
((obj sync-info-paused) (max-out-val float))
(* (get-current-phase-with-mirror obj) max-out-val)
)
;; definition for method 9 of type delayed-rand-float
(defmethod
set-params!
delayed-rand-float
((obj delayed-rand-float) (min-tim int) (max-time int) (max-times-two float))
(set! (-> obj min-time) min-tim)
(set! (-> obj max-time) max-time)
(set! (-> obj max-val) (* 0.5 max-times-two))
(set! (-> obj start-time) (the-as uint 0))
(set! (-> obj timer) 0)
(set! (-> obj value) 0.0)
(-> obj value)
)
;; definition for method 10 of type delayed-rand-float
(defmethod update! delayed-rand-float ((obj delayed-rand-float))
(when
(>=
(the-as int (- (-> *display* base-frame-counter) (-> obj start-time)))
(-> obj timer)
)
(set! (-> obj start-time) (-> *display* base-frame-counter))
(set! (-> obj timer) (rand-vu-int-range (-> obj min-time) (-> obj max-time)))
(set!
(-> obj value)
(rand-vu-float-range (- (-> obj max-val)) (-> obj max-val))
)
)
(-> obj value)
)
;; definition for method 9 of type oscillating-float
(defmethod
set-params!
oscillating-float
((obj oscillating-float)
(init-val float)
(accel float)
(max-vel float)
(damping float)
)
(set! (-> obj value) init-val)
(set! (-> obj target) init-val)
(set! (-> obj vel) 0.0)
(set! (-> obj max-vel) max-vel)
(set! (-> obj damping) damping)
(set! (-> obj accel) accel)
(-> obj value)
)
;; definition for method 10 of type oscillating-float
(defmethod
update!
oscillating-float
((obj oscillating-float) (target-offset float))
(let
((acc
(*
(- (+ (-> obj target) target-offset) (-> obj value))
(* (-> obj accel) (-> *display* time-adjust-ratio))
)
)
)
(+! (-> obj vel) acc)
)
(set!
(-> obj vel)
(fmin (-> obj max-vel) (fmax (- (-> obj max-vel)) (-> obj vel)))
)
(set! (-> obj vel) (* (-> obj vel) (-> obj damping)))
(+! (-> obj value) (* (-> obj vel) (-> *display* time-adjust-ratio)))
(-> obj value)
)
;; definition for method 9 of type bouncing-float
(defmethod
set-params!
bouncing-float
((obj bouncing-float)
(init-val float)
(max-val float)
(min-val float)
(elast float)
(accel float)
(max-vel float)
(damping float)
)
(set-params! (-> obj osc) init-val accel max-vel damping)
(set! (-> obj max-value) max-val)
(set! (-> obj min-value) min-val)
(set! (-> obj elasticity) elast)
(set! (-> obj state) 0)
(-> obj osc value)
)
;; definition for method 10 of type bouncing-float
(defmethod update! bouncing-float ((obj bouncing-float) (arg0 float))
(update! (-> obj osc) arg0)
(set! (-> obj state) 0)
(when (>= (-> obj osc value) (-> obj max-value))
(set! (-> obj osc value) (-> obj max-value))
(if (< 0.0 (-> obj osc vel))
(set! (-> obj osc vel) (* (-> obj osc vel) (- (-> obj elasticity))))
)
(set! (-> obj state) 1)
)
(when (>= (-> obj min-value) (-> obj osc value))
(set! (-> obj osc value) (-> obj min-value))
(if (< (-> obj osc vel) 0.0)
(set! (-> obj osc vel) (* (-> obj osc vel) (- (-> obj elasticity))))
)
(set! (-> obj state) -1)
)
(-> obj osc value)
)
;; definition for method 11 of type bouncing-float
(defmethod at-min? bouncing-float ((obj bouncing-float))
(= (-> obj state) -1)
)
;; definition for method 12 of type bouncing-float
(defmethod at-max? bouncing-float ((obj bouncing-float))
(= (-> obj state) 1)
)
;; definition for method 9 of type delayed-rand-vector
(defmethod
set-params!
delayed-rand-vector
((obj delayed-rand-vector)
(min-time int)
(max-time int)
(xz-range float)
(y-range float)
)
(set! (-> obj min-time) min-time)
(set! (-> obj max-time) max-time)
(set! (-> obj xz-max) (* 0.5 xz-range))
(set! (-> obj y-max) (* 0.5 y-range))
(set! (-> obj start-time) (the-as uint 0))
(set! (-> obj timer) 0)
(vector-reset! (-> obj value))
(-> obj value)
)
;; definition for method 10 of type delayed-rand-vector
(defmethod update-now! delayed-rand-vector ((obj delayed-rand-vector))
(set! (-> obj start-time) (-> *display* base-frame-counter))
(set! (-> obj timer) (rand-vu-int-range (-> obj min-time) (-> obj max-time)))
(set!
(-> obj value x)
(rand-vu-float-range (- (-> obj xz-max)) (-> obj xz-max))
)
(set!
(-> obj value y)
(rand-vu-float-range (- (-> obj y-max)) (-> obj y-max))
)
(set!
(-> obj value z)
(rand-vu-float-range (- (-> obj xz-max)) (-> obj xz-max))
)
(-> obj value)
)
;; definition for method 11 of type delayed-rand-vector
(defmethod update-with-delay! delayed-rand-vector ((obj delayed-rand-vector))
(if
(>=
(the-as int (- (-> *display* base-frame-counter) (-> obj start-time)))
(-> obj timer)
)
(update-now! obj)
)
(-> obj value)
)
;; definition for method 12 of type delayed-rand-vector
(defmethod
update-with-delay-or-reset!
delayed-rand-vector
((obj delayed-rand-vector))
(if
(>=
(the-as int (- (-> *display* base-frame-counter) (-> obj start-time)))
(-> obj timer)
)
(update-now! obj)
(vector-reset! (-> obj value))
)
(-> obj value)
)
;; definition for method 9 of type oscillating-vector
;; Used lq/sq
(defmethod
set-params!
oscillating-vector
((obj oscillating-vector)
(init-val vector)
(accel float)
(max-vel float)
(damping float)
)
(cond
(init-val
(set! (-> obj value quad) (-> init-val quad))
(set! (-> obj target quad) (-> init-val quad))
)
(else
(vector-reset! (-> obj value))
(vector-reset! (-> obj target))
)
)
(vector-reset! (-> obj vel))
(set! (-> obj max-vel) max-vel)
(set! (-> obj damping) damping)
(set! (-> obj accel) accel)
(-> obj value)
)
;; definition for method 10 of type oscillating-vector
(defmethod
update!
oscillating-vector
((obj oscillating-vector) (target-offset vector))
(let ((s5-0 (new 'stack-no-clear 'vector)))
(cond
(target-offset
(vector+! s5-0 (-> obj target) target-offset)
(vector-! s5-0 s5-0 (-> obj value))
)
(else
(vector-! s5-0 (-> obj target) (-> obj value))
)
)
(vector-float*!
s5-0
s5-0
(* (-> obj accel) (-> *display* time-adjust-ratio))
)
(vector+! (-> obj vel) (-> obj vel) s5-0)
(let ((vel (vector-length (-> obj vel))))
(if (< (-> obj max-vel) vel)
(vector-float*! (-> obj vel) (-> obj vel) (/ (-> obj max-vel) vel))
)
)
(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)
)