mirror of
https://github.com/open-goal/jak-project
synced 2026-08-02 08:42:11 -04:00
51d008f9ab
Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
124 lines
3.6 KiB
Common Lisp
Vendored
Generated
124 lines
3.6 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type smush-control
|
|
(deftype smush-control (structure)
|
|
((start-time time-frame)
|
|
(period float)
|
|
(duration float)
|
|
(amp float)
|
|
(damp-amp float)
|
|
(damp-period float)
|
|
(ticks float)
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(set-zero! (_type_) _type_)
|
|
(update! (_type_) float)
|
|
(get-no-update (_type_) float)
|
|
(activate! (_type_ float int int float float) _type_)
|
|
(nonzero-amplitude? (_type_) symbol)
|
|
(die-on-next-update! (_type_) _type_)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type smush-control
|
|
(defmethod inspect ((this smush-control))
|
|
(format #t "[~8x] ~A~%" this 'smush-control)
|
|
(format #t "~Tstart-time: ~D~%" (-> this start-time))
|
|
(format #t "~Tperiod: ~f~%" (-> this period))
|
|
(format #t "~Tduration: ~f~%" (-> this duration))
|
|
(format #t "~Tamp: ~f~%" (-> this amp))
|
|
(format #t "~Tdamp-amp: ~f~%" (-> this damp-amp))
|
|
(format #t "~Tdamp-period: ~f~%" (-> this damp-period))
|
|
(format #t "~Tticks: ~f~%" (-> this ticks))
|
|
this
|
|
)
|
|
|
|
;; definition for method 13 of type smush-control
|
|
(defmethod nonzero-amplitude? ((this smush-control))
|
|
(!= (-> this amp) 0.0)
|
|
)
|
|
|
|
;; definition for method 9 of type smush-control
|
|
(defmethod set-zero! ((this smush-control))
|
|
(set! (-> this period) 0.0)
|
|
(set! (-> this duration) 0.0)
|
|
(set! (-> this amp) 0.0)
|
|
(set! (-> this damp-amp) 0.0)
|
|
(set! (-> this damp-period) 0.0)
|
|
(set! (-> this ticks) 0.0)
|
|
this
|
|
)
|
|
|
|
;; definition for method 10 of type smush-control
|
|
(defmethod update! ((this smush-control))
|
|
(cond
|
|
((!= (-> this amp) 0.0)
|
|
(let* ((f30-0 (the float (- (current-time) (-> this start-time))))
|
|
(f0-2 (-> this period))
|
|
(f28-0 (- f30-0 (* (the float (the int (/ f30-0 f0-2))) f0-2)))
|
|
)
|
|
(when (>= (- f30-0 (-> this ticks)) (-> this period))
|
|
(set! (-> this amp) (* (-> this amp) (-> this damp-amp)))
|
|
(set! (-> this period) (* (-> this period) (-> this damp-period)))
|
|
(set! (-> this ticks) f30-0)
|
|
(if (< (-> this damp-period) 0.0)
|
|
(set-zero! this)
|
|
)
|
|
)
|
|
(if (>= f30-0 (-> this duration))
|
|
(set-zero! this)
|
|
)
|
|
(* (sin (/ (* 65536.0 f28-0) (-> this period)))
|
|
(* (-> this amp) (/ (- (-> this duration) f30-0) (-> this duration)))
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
0.0
|
|
)
|
|
)
|
|
)
|
|
|
|
;; definition for method 11 of type smush-control
|
|
(defmethod get-no-update ((this smush-control))
|
|
(cond
|
|
((!= (-> this amp) 0.0)
|
|
(let* ((f30-0 (the float (- (current-time) (-> this start-time))))
|
|
(f0-2 (-> this period))
|
|
(f0-4 (- f30-0 (* (the float (the int (/ f30-0 f0-2))) f0-2)))
|
|
)
|
|
(* (sin (/ (* 65536.0 f0-4) (-> this period)))
|
|
(* (-> this amp) (/ (- (-> this duration) f30-0) (-> this duration)))
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
0.0
|
|
)
|
|
)
|
|
)
|
|
|
|
;; definition for method 14 of type smush-control
|
|
(defmethod die-on-next-update! ((this smush-control))
|
|
(if (!= (-> this amp) 0.0)
|
|
(set! (-> this damp-period) -1.0)
|
|
)
|
|
this
|
|
)
|
|
|
|
;; definition for method 12 of type smush-control
|
|
(defmethod activate! ((this smush-control) (arg0 float) (arg1 int) (arg2 int) (arg3 float) (arg4 float))
|
|
(when (>= (fabs (/ (-> this amp) 5)) (fabs (get-no-update this)))
|
|
(set! (-> this amp) arg0)
|
|
(set! (-> this period) (the float arg1))
|
|
(set! (-> this duration) (the float arg2))
|
|
(set! (-> this damp-amp) arg3)
|
|
(set! (-> this damp-period) arg4)
|
|
(set! (-> this ticks) 0.0)
|
|
(set-time! (-> this start-time))
|
|
)
|
|
this
|
|
)
|