diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 2867761063..2bf1cd1d25 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -10173,15 +10173,15 @@ :size-assert #x8 :flag-assert #x1200000008 (:methods - (dummy-9 (_type_ float) float 9) - (dummy-10 (_type_) float 10) - (dummy-11 (_type_) float 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) ;; 3 arg for parent 5 for child - (dummy-15 (_type_ process) float 15) ;; wip - (dummy-16 (_type_ float) float 16) - (dummy-17 (_type_) float 17) + (get-current-value (_type_ float) float 9) + (get-current-phase-no-mod (_type_) float 10) + (get-current-phase (_type_) float 11) + (get-current-value-with-mirror (_type_ float) float 12) + (get-current-phase-with-mirror (_type_) float 13) + (setup-params! (_type_ uint float float float) none 14) + (load-params! (_type_ process uint float float float) symbol 15) + (sync-now! (_type_ float) float 16) + (get-phase-offset (_type_) float 17) ) ) @@ -10196,17 +10196,6 @@ :method-count-assert 18 :size-assert #x1c :flag-assert #x120000001c - (:methods - ;; (dummy-9 () none 9) - ;; (dummy-10 () none 10) - ;; (dummy-11 () none 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) - (dummy-15 (_type_ process) float 15) ;; wip - ;; (dummy-16 () none 16) - ;; (dummy-17 () none 17) - ) ) (deftype sync-info-paused (sync-info) @@ -10216,17 +10205,6 @@ :method-count-assert 18 :size-assert #x10 :flag-assert #x1200000010 - (:methods - (dummy-9 (_type_ float) float 9) - ;; (dummy-10 () none 10) - (dummy-11 (_type_) float 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) - (dummy-15 (_type_ process) float 15) ;; wip - ;; (dummy-16 () none 16) - ;; (dummy-17 () none 17) - ) ) (deftype delayed-rand-float (structure) @@ -10241,8 +10219,8 @@ :size-assert #x1c :flag-assert #xb0000001c (:methods - (dummy-9 (_type_ int int float) float 9) - (dummy-10 (_type_ ) float 10) + (set-params! (_type_ int int float) float 9) + (update! (_type_ ) float 10) ) ) @@ -10258,8 +10236,8 @@ :size-assert #x18 :flag-assert #xb00000018 (:methods - (dummy-9 (_type_ float float float float) float 9) - (dummy-10 (_type_ float) float 10) + (set-params! (_type_ float float float float) float 9) + (update! (_type_ float) float 10) ) ) @@ -10274,10 +10252,10 @@ :size-assert #x28 :flag-assert #xd00000028 (:methods - (dummy-9 (_type_ float float float float float float float) float 9) - (dummy-10 (_type_ float) float 10) - (dummy-11 (_type_) symbol 11) ;; bool - (dummy-12 (_type_) symbol 12) ;; bool + (set-params! (_type_ float float float float float float float) float 9) + (update! (_type_ float) float 10) + (at-min? (_type_) symbol 11) ;; bool + (at-max? (_type_) symbol 12) ;; bool ) ) @@ -10294,10 +10272,10 @@ :size-assert #x30 :flag-assert #xd00000030 (:methods - (dummy-9 (_type_ int int float float) vector 9) - (dummy-10 (_type_) vector 10) - (dummy-11 (_type_) vector 11) - (dummy-12 (_type_) vector 12) + (set-params! (_type_ int int float float) vector 9) + (update-now! (_type_) vector 10) + (update-with-delay! (_type_) vector 11) + (update-with-delay-or-reset! (_type_) vector 12) ) ) @@ -10313,8 +10291,8 @@ :size-assert #x3c :flag-assert #xb0000003c (:methods - (dummy-9 (_type_ vector float float float) vector 9) - (dummy-10 (_type_ vector) vector 10) + (set-params! (_type_ vector float float float) vector 9) + (update! (_type_ vector) vector 10) ) ) @@ -10348,7 +10326,14 @@ (die-on-next-update! (_type_) _type_ 14) ) ) - ;; trajectory-h + +;; ---------------------- +;; File - trajectory-h +;; Source Path - engine/physics/trajectory-h.gc +;; Containing DGOs - ['GAME', 'ENGINE'] +;; Version - 3 + + (deftype trajectory (structure) ((initial-position vector :inline :offset-assert 0) (initial-velocity vector :inline :offset-assert 16) @@ -10359,28 +10344,16 @@ :size-assert #x28 :flag-assert #x1000000028 (:methods - (TODO-RENAME-9 (_type_ float vector) vector 9) - (TODO-RENAME-10 (_type_ float vector) vector 10) - (TODO-RENAME-11 (_type_ vector vector float float) none 11) - (TODO-RENAME-12 (_type_ vector vector float float) none 12) - (TODO-RENAME-13 (_type_ vector vector float float) none 13) - (TODO-RENAME-14 (_type_ vector vector float float) none 14) - (TODO-RENAME-15 (_type_) none 15) + (eval-position! (_type_ float vector) vector 9) + (eval-velocity! (_type_ float vector) vector 10) + (setup-from-to-duration! (_type_ vector vector float float) none 11) + (setup-from-to-xz-vel! (_type_ vector vector float float) none 12) + (setup-from-to-y-vel! (_type_ vector vector float float) none 13) + (setup-from-to-height! (_type_ vector vector float float) none 14) + (debug-draw! (_type_) none 15) ) ) - -;; ---------------------- -;; File - trajectory-h -;; Source Path - engine/physics/trajectory-h.gc -;; Containing DGOs - ['GAME', 'ENGINE'] -;; Version - 3 - -;; - Unknowns - -;;(define-extern trajectory object) ;; unknown type - - ;; ---------------------- ;; File - debug-h ;; Source Path - engine/debug/debug-h.gc diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index 67ce19ed2d..6c6ad2b182 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -406,13 +406,7 @@ "(anon-function 43 maincave-obs)", "(anon-function 2 target-tube)", "(anon-function 5 orbit-plat)", - "(anon-function 2 ogreboss)", - - // not enough type info to decompile these - // (these are NOT actually asm functions) - "(method 15 sync-info)", // NEED *res-static-buf* - "(method 15 sync-info-eased)", // NEED *res-static-buf* - "(method 15 sync-info-paused)" // NEED *res-static-buf* + "(anon-function 2 ogreboss)" ], diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 8acafbb977..8ab0548d7a 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -527,6 +527,23 @@ ["_stack_", 32, "res-tag"] ], + "(method 15 sync-info)": [ + ["_stack_", 16, "res-tag"], + [[19, 24], "v1", "(pointer float)"] + ], + + "(method 15 sync-info-eased)": [ + ["_stack_", 16, "res-tag"], + [[44, 49], "v1", "(pointer float)"], + [[26, 35], "v1", "(pointer float)"] + ], + + "(method 15 sync-info-paused)": [ + ["_stack_", 16, "res-tag"], + [[44, 49], "v1", "(pointer float)"], + [[26, 35], "v1", "(pointer float)"] + ], + "(method 15 res-lump)": [[132, "s5", "res-tag-pair"]], "(method 17 res-lump)": [[22, "s4", "(pointer pointer)"]], @@ -1219,9 +1236,7 @@ [[106, 110], "v1", "dma-packet"] ], - "debug-menu-item-var-msg": [ - [64, "t9", "(function int int int int int)"] - ], + "debug-menu-item-var-msg": [[64, "t9", "(function int int int int int)"]], "debug-menu-item-var-make-int": [ [21, "t9", "(function int int int int int)"] @@ -1652,9 +1667,7 @@ [[28, 33], "t9", "(function object)"] ], - "(anon-function 1 cam-combiner)": [ - [[0, 999], "s6", "camera-combiner"] - ], + "(anon-function 1 cam-combiner)": [[[0, 999], "s6", "camera-combiner"]], "(anon-function 2 cam-combiner)": [ [10, "a0", "vector"], @@ -1688,9 +1701,7 @@ [[40, 42], "a1", "vector"] ], - "cam-slave-init-vars": [ - [[0, 999], "s6", "camera-slave"] - ], + "cam-slave-init-vars": [[[0, 999], "s6", "camera-slave"]], "cam-slave-get-vector-with-offset": [[[52, 65], "s3", "vector"]], @@ -1774,9 +1785,7 @@ [[17, 46], "v1", "matrix"] ], - "draw-ocean-transition": [ - [255, "v1", "ocean-mid-mask"] - ], + "draw-ocean-transition": [[255, "v1", "ocean-mid-mask"]], // "ocean-trans-mask-ptrs-bit?": [ // [[32, 41], "a0", "(pointer ocean-trans-mask)"] diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 92cc0410f1..1e6612bbc5 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -2558,7 +2558,7 @@ "sv-64": "spool-sound" } }, - + "(method 3 anim-tester)": { "vars": { "s5-0": ["s5-0", "anim-test-obj"], @@ -2566,13 +2566,13 @@ "s3-0": ["s3-0", "anim-test-seq-item"] } }, - + "anim-test-obj-item-valid?": { "vars": { "s5-0": ["s5-0", "anim-test-sequence"] } }, - + "anim-test-obj-remove-invalid": { "vars": { //"s5-0": ["s5-0", "anim-test-sequence"], @@ -2581,13 +2581,13 @@ "s2-0": ["s2-0", "anim-test-seq-item"] } }, - + "anim-tester-reset": { "vars": { "v1-1": ["v1-1", "anim-test-obj"] } }, - + "anim-tester-save-object-seqs": { "vars": { "s4-2": ["s4-2", "anim-test-seq-item"] @@ -2772,36 +2772,36 @@ "level-remap-texture": { "args": ["tex-id"], "vars": { - "v1-1":"bsp-hdr", + "v1-1": "bsp-hdr", "a3-0": "table-size", "v1-2": ["table-data-start", "(pointer uint64)"], - "t0-0":"table-data-ptr", - "a1-1":"mask1", - "a2-1":"masked-tex-id", - "a3-2":"table-data-end", - "t0-3":"midpoint", - "t1-1":"diff" + "t0-0": "table-data-ptr", + "a1-1": "mask1", + "a2-1": "masked-tex-id", + "a3-2": "table-data-end", + "t0-3": "midpoint", + "t1-1": "diff" } }, - + "debug-menu-make-from-template": { "vars": { "s5-1": ["s5-1", "string"] } }, - + "debug-menu-item-var-render": { "vars": { "v1-14": ["v1-14", "dma-packet"] } }, - + "generic-add-constants": { "vars": { "a0-1": ["a0-1", "dma-packet"] } }, - + "generic-init-buf": { "vars": { "a0-2": ["a0-2", "dma-packet"], @@ -2823,5 +2823,221 @@ } }, + "(method 14 sync-info)": { + "args": ["obj", "period", "phase"], + "vars": { + "f0-1": "period-float", + "f1-1": "value" + } + }, + + "(method 14 sync-info-eased)": { + "args": ["obj", "period", "phase", "out-param", "in-param"], + "vars": { + "f0-9": "total-easing-phase", + "f1-11": "total-normal-phase", + "f0-1": "period-float", + "f1-1": "value", + "f3-4": "y-end" + } + }, + + "(method 14 sync-info-paused)": { + "args": ["obj", "period", "phase", "out-param", "in-param"] + }, + + "(method 15 sync-info)": { + "args": [ + "obj", + "proc", + "default-period", + "default-phase", + "default-out", + "default-in" + ] + }, + + "(method 15 sync-info-eased)": { + "args": [ + "obj", + "proc", + "default-period", + "default-phase", + "default-out", + "default-in" + ] + }, + + "(method 15 sync-info-paused)": { + "args": [ + "obj", + "proc", + "default-period", + "default-phase", + "default-out", + "default-in" + ] + }, + + "(method 10 sync-info)": { + "vars": { + "v1-0": "period", + "f0-1": "period-float", + "f1-2": "current-time" + } + }, + + "(method 16 sync-info)": { + "args": ["obj", "user-time-offset"], + "vars": { + "a2-0": "period", + "f0-1": "period-float", + "v1-0": "wrapped-user-offset", + "f1-4": "current-time", + "f1-6": "current-time-wrapped", + "f1-10": "combined-offset", + "f0-3": "combined-offset-wrapped" + } + }, + + "(method 11 sync-info)": { + "vars": { + "v1-0": "period", + "f0-1": "period-float", + "f1-2": "current-time" + } + }, + + "(method 11 sync-info-paused)": { + "vars": { + "v1-0": "period", + "f1-0": "period-float", + "f0-1": "max-phase", + "f2-2": "current-time" + } + }, + + "(method 9 sync-info)": { + "args": ["obj", "max-val"], + "vars": { + "v1-0": "period", + "f0-1": "period-float", + "f1-2": "current-time" + } + }, + + "(method 13 sync-info)": { + "args": ["obj"], + "vars": { + "v1-0": "period", + "f1-0": "period-float", + "f2-2": "current-time", + "f0-1": "max-val", + "f0-2": "phase-out-of-2" + } + }, + + "(method 13 sync-info-eased)": { + "args": ["obj"], + "vars": { + "v1-0": "period", + "f1-0": "period-float", + "f0-1": "max-val", + "f2-2": "current-time", + "f0-2": "current-val", + "v1-2": "in-mirror?", + "f1-4": "tlo", + "f0-7": "eased-phase" + } + }, + + "(method 12 sync-info)": { + "args": ["obj", "max-out-val"], + "vars": { + "v1-0": "period", + "f1-0": "period-float", + "f0-1": "max-val", + "f2-2": "current-time", + "f0-2": "current-val" + } + }, + + "(method 12 sync-info-eased)": { + "args": ["obj", "max-out-val"] + }, + "(method 12 sync-info-paused)": { + "args": ["obj", "max-out-val"] + }, + + "(method 9 delayed-rand-float)": { + "args": ["obj", "min-tim", "max-time", "max-times-two"] + }, + + "(method 10 oscillating-float)": { + "args": ["obj", "target-offset"], + "vars": { "f0-3": "acc" } + }, + + "(method 9 oscillating-float)": { + "args": ["obj", "init-val", "accel", "max-vel", "damping"] + }, + + "(method 9 bouncing-float)": { + "args": [ + "obj", + "init-val", + "max-val", + "min-val", + "elast", + "accel", + "max-vel", + "damping" + ] + }, + + "(method 9 delayed-rand-vector)": { + "args": ["obj", "min-time", "max-time", "xz-range", "y-range"] + }, + + "(method 9 oscillating-vector)": { + "args": ["obj", "init-val", "accel", "max-vel", "damping"] + }, + + "(method 10 oscillating-vector)": { + "args": ["obj", "target-offset"], + "vars": { "f0-2": "vel" } + }, + + "(method 9 trajectory)": { + "args": ["obj", "time", "result"] + }, + + "(method 10 trajectory)": { + "args": ["obj", "time", "result"] + }, + + "(method 11 trajectory)": { + "args": ["obj", "from", "to", "duration", "grav"], + "vars": { "f0-3": "xz-vel" } + }, + + "(method 12 trajectory)": { + "args": ["obj", "from", "to", "xz-vel", "grav"], + "vars": { "f0-1": "duration" } + }, + + "(method 13 trajectory)": { + "args": ["obj", "from", "to", "y-vel", "grav"] + }, + + "(method 15 trajectory)": { + "vars":{ + "s5-0":"prev-pos", + "s4-0":"pos", + "s3-0":"num-segments", + "f0-1":"t-eval" + } + }, + "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/goal_src/engine/physics/trajectory-h.gc b/goal_src/engine/physics/trajectory-h.gc index 566d3deef5..9b222bf881 100644 --- a/goal_src/engine/physics/trajectory-h.gc +++ b/goal_src/engine/physics/trajectory-h.gc @@ -5,7 +5,10 @@ ;; name in dgo: trajectory-h ;; dgos: GAME, ENGINE -;; definition of type trajectory +;; Trajectory represents a ballistic trajectory. +;; First, call one of the setup methods to setup the trajectory object. +;; Then, use eval-position or eval-velocity to get the position or velocity of the +;; object along the trajectory. (deftype trajectory (structure) ((initial-position vector :inline :offset-assert 0) (initial-velocity vector :inline :offset-assert 16) @@ -16,13 +19,13 @@ :size-assert #x28 :flag-assert #x1000000028 (:methods - (TODO-RENAME-9 (_type_ float vector) vector 9) - (TODO-RENAME-10 (_type_ float vector) vector 10) - (TODO-RENAME-11 (_type_ vector vector float float) none 11) - (TODO-RENAME-12 (_type_ vector vector float float) none 12) - (TODO-RENAME-13 (_type_ vector vector float float) none 13) - (TODO-RENAME-14 (_type_ vector vector float float) none 14) - (TODO-RENAME-15 (_type_) none 15) + (eval-position! (_type_ float vector) vector 9) + (eval-velocity! (_type_ float vector) vector 10) + (setup-from-to-duration! (_type_ vector vector float float) none 11) + (setup-from-to-xz-vel! (_type_ vector vector float float) none 12) + (setup-from-to-y-vel! (_type_ vector vector float float) none 13) + (setup-from-to-height! (_type_ vector vector float float) none 14) + (debug-draw! (_type_) none 15) ) ) diff --git a/goal_src/engine/physics/trajectory.gc b/goal_src/engine/physics/trajectory.gc index 00e4910e57..7258b10455 100644 --- a/goal_src/engine/physics/trajectory.gc +++ b/goal_src/engine/physics/trajectory.gc @@ -5,94 +5,72 @@ ;; name in dgo: trajectory ;; dgos: GAME, ENGINE -;; definition for method 9 of type trajectory -;; Used lq/sq -(defmethod TODO-RENAME-9 trajectory ((obj trajectory) (arg0 float) (arg1 vector)) - (let ((v1-0 arg1)) - (set! (-> v1-0 quad) (-> obj initial-position quad)) - ) - (set! (-> arg1 x) (+ (-> arg1 x) (* arg0 (-> obj initial-velocity x)))) - (set! (-> arg1 y) (+ (-> arg1 y) (* arg0 (-> obj initial-velocity y)))) - (set! (-> arg1 z) (+ (-> arg1 z) (* arg0 (-> obj initial-velocity z)))) - (set! (-> arg1 y) (+ (-> arg1 y) (* (* (* 0.5 arg0) arg0) (-> obj gravity)))) - arg1 +(defmethod eval-position! trajectory ((obj trajectory) (time float) (result vector)) + "Evaluate the position of the object at a give time" + (set! (-> result quad) (-> obj initial-position quad)) + (+! (-> result x) (* time (-> obj initial-velocity x))) + (+! (-> result y) (* time (-> obj initial-velocity y))) + (+! (-> result z) (* time (-> obj initial-velocity z))) + (+! (-> result y) (* (* (* 0.5 time) time) (-> obj gravity))) + result ) -;; definition for method 10 of type trajectory -;; Used lq/sq -(defmethod - TODO-RENAME-10 - trajectory - ((obj trajectory) (arg0 float) (arg1 vector)) - (let ((v1-0 arg1)) - (set! (-> v1-0 quad) (-> obj initial-velocity quad)) - ) - (set! (-> arg1 y) (+ (-> arg1 y) (* arg0 (-> obj gravity)))) - arg1 +(defmethod eval-velocity! trajectory ((obj trajectory) (time float) (result vector)) + "Evaluate the velocity of the object at a given time" + (set! (-> result quad) (-> obj initial-velocity quad)) + (+! (-> result y) (* time (-> obj gravity))) + result ) -;; definition for method 11 of type trajectory -;; INFO: Return type mismatch int vs none. -;; Used lq/sq -(defmethod TODO-RENAME-11 trajectory ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) - (set! (-> obj initial-position quad) (-> arg0 quad)) - (set! (-> obj gravity) arg3) - (set! (-> obj time) arg2) - (let ((f0-3 (/ (vector-vector-xz-distance arg1 arg0) arg2))) - (vector-! (-> obj initial-velocity) arg1 arg0) - (vector-xz-normalize! (-> obj initial-velocity) f0-3) +(defmethod setup-from-to-duration! trajectory ((obj trajectory) (from vector) (to vector) (duration float) (grav float)) + "Set up a trajectory that goes from->to in the given duration" + (set! (-> obj initial-position quad) (-> from quad)) + (set! (-> obj gravity) grav) + (set! (-> obj time) duration) + ;; the velocity we need in xz to make it in time + (let ((xz-vel (/ (vector-vector-xz-distance to from) duration))) + ;; our velocity will point along from -> to + (vector-! (-> obj initial-velocity) to from) + ;; but have magnitude that we calculated above. + (vector-xz-normalize! (-> obj initial-velocity) xz-vel) ) - (set! - (-> obj initial-velocity y) - (- (/ (- (-> arg1 y) (-> arg0 y)) arg2) (* (* 0.5 arg2) (-> obj gravity))) - ) - (let ((v0-2 0)) + ;; solve for the y velocity that makes us land at the right height. + (set! (-> obj initial-velocity y) + (- (/ (- (-> to y) (-> from y)) duration) + (* (* 0.5 duration) (-> obj gravity)) ) - (none) - ) - -;; definition for method 12 of type trajectory -;; INFO: Return type mismatch int vs none. -(defmethod - TODO-RENAME-12 - trajectory - ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) - (let ((f0-1 (/ (vector-vector-xz-distance arg1 arg0) arg2))) - ((method-of-type trajectory TODO-RENAME-11) obj arg0 arg1 f0-1 arg3) - ) - (let ((v0-1 0)) ) (none) ) -;; definition for method 13 of type trajectory -;; INFO: Return type mismatch int vs none. -(defmethod - TODO-RENAME-13 - trajectory - ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) - (let* ((f0-0 arg2) - (f1-3 (- (* f0-0 f0-0) (* (* 2.0 (- (-> arg0 y) (-> arg1 y))) arg3))) +(defmethod setup-from-to-xz-vel! trajectory ((obj trajectory) (from vector) (to vector) (xz-vel float) (grav float)) + "Set up a trajectory that goes from->to with the given velocity" + ;; just solve for the duration and use the previous + (let ((duration (/ (vector-vector-xz-distance to from) xz-vel))) + (setup-from-to-duration! obj from to duration grav) + ) + (none) + ) + +(defmethod setup-from-to-y-vel! trajectory ((obj trajectory) (from vector) (to vector) (y-vel float) (grav float)) + "Set up a trajectory with the given initial y velocity." + (let* ((f0-0 y-vel) + (f1-3 (- (* f0-0 f0-0) (* (* 2.0 (- (-> from y) (-> to y))) grav))) (f0-3 900.0) ) (when (>= f1-3 0.0) (let ((f0-4 (sqrtf f1-3))) - (set! f0-3 (fmax (/ (- (- arg2) f0-4) arg3) (/ (+ (- arg2) f0-4) arg3))) + (set! f0-3 (fmax (/ (- (- y-vel) f0-4) grav) (/ (+ (- y-vel) f0-4) grav))) ) ) - ((method-of-type trajectory TODO-RENAME-11) obj arg0 arg1 f0-3 arg3) - ) - (let ((v0-1 0)) + (setup-from-to-duration! obj from to f0-3 grav) ) + 0 (none) ) -;; definition for method 14 of type trajectory -;; INFO: Return type mismatch int vs none. -(defmethod - TODO-RENAME-14 - trajectory - ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) +(defmethod setup-from-to-height! trajectory ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + "Setup a trajectory that reaches a given height" (let* ((f1-2 (+ arg2 (fmax (-> arg0 y) (-> arg1 y)))) (f1-5 (* (* 2.0 (- (-> arg0 y) f1-2)) arg3)) (f0-3 4096.0) @@ -100,36 +78,33 @@ (if (< 0.0 f1-5) (set! f0-3 (sqrtf f1-5)) ) - ((method-of-type trajectory TODO-RENAME-13) obj arg0 arg1 f0-3 arg3) - ) - (let ((v0-1 0)) + (setup-from-to-y-vel! obj arg0 arg1 f0-3 arg3) ) (none) ) -;; definition for method 15 of type trajectory -;; INFO: Return type mismatch int vs none. -;; Used lq/sq -(defmethod TODO-RENAME-15 trajectory ((obj trajectory)) - (let ((s5-0 (new 'stack-no-clear 'vector)) - (s4-0 (new 'stack-no-clear 'vector)) - (s3-0 10) +(defmethod debug-draw! trajectory ((obj trajectory)) + "Draw the trajectory" + (let ((prev-pos (new 'stack-no-clear 'vector)) + (pos (new 'stack-no-clear 'vector)) + (num-segments 10) ) - (let ((v1-0 s4-0)) - (set! (-> v1-0 quad) (-> obj initial-position quad)) + (set! (-> pos quad) (-> obj initial-position quad)) + (dotimes (s2-0 num-segments) + (set! (-> prev-pos quad) (-> pos quad)) + (let ((t-eval (* (-> obj time) (/ (+ 1.0 (the float s2-0)) (the float num-segments))))) + (eval-position! obj t-eval pos) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + prev-pos + pos + (new 'static 'rgba :r #xff :a #x80) + #f + (the-as rgba -1) + ) + ) ) - (dotimes (s2-0 s3-0) - (let ((v1-1 s5-0)) - (set! (-> v1-1 quad) (-> s4-0 quad)) - ) - (let - ((f0-1 (* (-> obj time) (/ (+ 1.0 (the float s2-0)) (the float s3-0))))) - ((method-of-type trajectory TODO-RENAME-9) obj f0-1 s4-0) - ) - (add-debug-line #t (the bucket-id 68) s5-0 s4-0 (new 'static 'rgba :r #xff :a #x80) #f (the rgba -1)) - ) - ) - (let ((v0-2 0)) - ) (none) ) diff --git a/goal_src/engine/util/sync-info-h.gc b/goal_src/engine/util/sync-info-h.gc index 4e289fba96..1e8ebd9307 100644 --- a/goal_src/engine/util/sync-info-h.gc +++ b/goal_src/engine/util/sync-info-h.gc @@ -5,26 +5,35 @@ ;; name in dgo: sync-info-h ;; dgos: GAME, ENGINE +;; The sync-info system is used to synchronize the motion of objects. +;; For example, platforms use this to have consistent relative positions. + +;; There are also some non-syncronized movement helpers in here. + +;; Simplest synchronization. Simply counts up, then resets once it reaches period. +;; For example, this is used to synchronize the "pies" in citadel. (deftype sync-info (structure) - ((offset float :offset-assert 0) - (period uint32 :offset-assert 4) + ((offset float :offset-assert 0) ;; offset, stored as a time, not a phase. + (period uint32 :offset-assert 4) ;; period, stored in seconds units ) :method-count-assert 18 :size-assert #x8 :flag-assert #x1200000008 (:methods - (dummy-9 (_type_ float) float 9) - (dummy-10 (_type_) float 10) - (dummy-11 (_type_) float 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) - (dummy-15 (_type_ process) float 15) ;; wip - (dummy-16 (_type_ float) float 16) - (dummy-17 (_type_) float 17) - ) + (get-current-value (_type_ float) float 9) + (get-current-phase-no-mod (_type_) float 10) + (get-current-phase (_type_) float 11) + (get-current-value-with-mirror (_type_ float) float 12) + (get-current-phase-with-mirror (_type_) float 13) + (setup-params! (_type_ uint float float float) none 14) + (load-params! (_type_ process uint float float float) symbol 15) + (sync-now! (_type_ float) float 16) + (get-phase-offset (_type_) float 17) + ) ) +;; Syncronized, but also includes some smoothing at the beginning. +;; This is used for motion of platforms. (deftype sync-info-eased (sync-info) ((tlo float :offset-assert 8) (thi float :offset-assert 12) @@ -36,19 +45,10 @@ :method-count-assert 18 :size-assert #x1c :flag-assert #x120000001c - (:methods - ;; (dummy-9 () none 9) - ;; (dummy-10 () none 10) - ;; (dummy-11 () none 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) - (dummy-15 (_type_ process) float 15) ;; wip - ;; (dummy-16 () none 16) - ;; (dummy-17 () none 17) - ) ) +;; Syncronized, but includes a pause. +;; This is used for whirlpools in lpc and the pushers in the yellow-eco room in snowy (deftype sync-info-paused (sync-info) ((pause-after-out float :offset-assert 8) (pause-after-in float :offset-assert 12) @@ -56,19 +56,9 @@ :method-count-assert 18 :size-assert #x10 :flag-assert #x1200000010 - (:methods - (dummy-9 (_type_ float) float 9) - ;; (dummy-10 () none 10) - (dummy-11 (_type_) float 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) - (dummy-15 (_type_ process) float 15) ;; wip - ;; (dummy-16 () none 16) - ;; (dummy-17 () none 17) - ) ) +;; This is a strange one. After a random amount of time, it changes to a random value. (deftype delayed-rand-float (structure) ((min-time int32 :offset-assert 0) (max-time int32 :offset-assert 4) @@ -81,79 +71,80 @@ :size-assert #x1c :flag-assert #xb0000001c (:methods - (dummy-9 (_type_ int int float) float 9) - (dummy-10 (_type_ ) float 10) - ) + (set-params! (_type_ int int float) float 9) + (update! (_type_) float 10) + ) ) (deftype oscillating-float (structure) - ((value float :offset-assert 0) - (target float :offset-assert 4) - (vel float :offset-assert 8) - (max-vel float :offset-assert 12) - (damping float :offset-assert 16) - (accel float :offset-assert 20) + ((value float :offset-assert 0) + (target float :offset-assert 4) + (vel float :offset-assert 8) + (max-vel float :offset-assert 12) + (damping float :offset-assert 16) + (accel float :offset-assert 20) ) :method-count-assert 11 :size-assert #x18 :flag-assert #xb00000018 (:methods - (dummy-9 (_type_ float float float float) float 9) - (dummy-10 (_type_ float) float 10) - ) + (set-params! (_type_ float float float float) float 9) + (update! (_type_ float) float 10) + ) ) (deftype bouncing-float (structure) - ((osc oscillating-float :inline :offset-assert 0) - (max-value float :offset-assert 24) - (min-value float :offset-assert 28) - (elasticity float :offset-assert 32) - (state int32 :offset-assert 36) + ((osc oscillating-float :inline :offset-assert 0) + (max-value float :offset-assert 24) + (min-value float :offset-assert 28) + (elasticity float :offset-assert 32) + (state int32 :offset-assert 36) ) :method-count-assert 13 :size-assert #x28 :flag-assert #xd00000028 (:methods - (dummy-9 (_type_ float float float float float float float) float 9) - (dummy-10 (_type_ float) float 10) - (dummy-11 (_type_) symbol 11) ;; bool - (dummy-12 (_type_) symbol 12) ;; bool - ) + (set-params! (_type_ float float float float float float float) float 9) + (update! (_type_ float) float 10) + (at-min? (_type_) symbol 11) + (at-max? (_type_) symbol 12) + ) ) (deftype delayed-rand-vector (structure) - ((min-time int32 :offset-assert 0) - (max-time int32 :offset-assert 4) - (xz-max float :offset-assert 8) - (y-max float :offset-assert 12) - (timer int32 :offset-assert 16) - (start-time uint64 :offset-assert 24) - (value vector :inline :offset-assert 32) + ((min-time int32 :offset-assert 0) + (max-time int32 :offset-assert 4) + (xz-max float :offset-assert 8) + (y-max float :offset-assert 12) + (timer int32 :offset-assert 16) + (start-time uint64 :offset-assert 24) + (value vector :inline :offset-assert 32) ) :method-count-assert 13 :size-assert #x30 :flag-assert #xd00000030 (:methods - (dummy-9 (_type_ int int float float) vector 9) - (dummy-10 (_type_) vector 10) - (dummy-11 (_type_) vector 11) - (dummy-12 (_type_) vector 12) - ) + (set-params! (_type_ int int float float) vector 9) + (update-now! (_type_) vector 10) + (update-with-delay! (_type_) vector 11) + (update-with-delay-or-reset! (_type_) vector 12) + ) ) (deftype oscillating-vector (structure) - ((value vector :inline :offset-assert 0) - (target vector :inline :offset-assert 16) - (vel vector :inline :offset-assert 32) - (max-vel float :offset-assert 48) - (damping float :offset-assert 52) - (accel float :offset-assert 56) + ((value vector :inline :offset-assert 0) + (target vector :inline :offset-assert 16) + (vel vector :inline :offset-assert 32) + (max-vel float :offset-assert 48) + (damping float :offset-assert 52) + (accel float :offset-assert 56) ) :method-count-assert 11 :size-assert #x3c :flag-assert #xb0000003c (:methods - (dummy-9 (_type_ vector float float float) vector 9) - (dummy-10 (_type_ vector) vector 10) - ) + (set-params! (_type_ vector float float float) vector 9) + (update! (_type_ vector) vector 10) + ) ) + diff --git a/goal_src/engine/util/sync-info.gc b/goal_src/engine/util/sync-info.gc index cd16fee149..c77fb4e4d6 100644 --- a/goal_src/engine/util/sync-info.gc +++ b/goal_src/engine/util/sync-info.gc @@ -6,567 +6,679 @@ ;; dgos: GAME, ENGINE -;; definition for method 14 of type sync-info -(defmethod - dummy-14 - sync-info - ((obj sync-info) (arg0 uint) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj period) arg0) - (let* ((f0-1 (the float arg0)) - (f1-1 (* arg1 f0-1)) +(defmethod setup-params! sync-info ((obj sync-info) (period uint) (phase float) (arg2 float) (arg3 float)) + "Setup a sync-info. + period is the duration of the pattern. + phase is the offset relative to the global clock, specified as a fraction of period." + (set! (-> obj period) period) + (let* ((period-float (the float period)) + (value (* phase period-float)) ) - (set! (-> obj offset) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1))) - ) - 0 - ) - -;; definition for method 14 of type sync-info-eased -(defmethod - dummy-14 - sync-info-eased - ((obj sync-info-eased) (arg0 uint) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj period) arg0) - (let* ((f0-1 (the float arg0)) - (f1-1 (* arg1 f0-1)) - ) - (set! (-> obj offset) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1))) - ) - (if (< arg2 0.0) - (set! arg2 0.0) - ) - (if (< 1.0 arg2) - (set! arg2 1.0) - ) - (if (< arg3 0.001) - (set! arg3 0.001) - ) - (if (< 1.0 arg3) - (set! arg3 1.0) - ) - (let ((f0-9 (+ arg2 arg3))) - (when (< 1.0 f0-9) - (set! f0-9 1.0) - (set! arg2 (- 1.0 arg3)) - ) - (let* ((f1-11 (- 1.0 f0-9)) - (f0-10 arg2) - (f1-12 (+ arg2 f1-11)) - (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))) - (f3-4 (+ (* (* (- 1.0 f1-12) (- 1.0 f1-12)) f4-3) f3-3)) + ;; this is like (fmod value period-float) + (set! (-> obj offset) + (- value (* (the float (the int (/ value period-float))) period-float)) ) - (set! (-> obj tlo) f0-10) - (set! (-> obj thi) f1-12) - (set! (-> obj ylo) f2-5) - (set! (-> obj m2) f4-3) - (set! (-> obj yend) f3-4) ) - ) - 0 + (none) ) -;; definition for method 14 of type sync-info-paused -(defmethod - dummy-14 - sync-info-paused - ((obj sync-info-paused) (arg0 uint) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj period) arg0) - (let* ((f0-1 (the float arg0)) - (f1-1 (* arg1 f0-1)) +(defmethod setup-params! sync-info-eased ((obj sync-info-eased) (period uint) (phase float) (out-param float) (in-param float)) + "Setup a sync-info-eased. The out-param and in-param are related to the smoothing at the beginning/end. + it looks like the easing is cubic so the first derivative is continuous." + (set! (-> obj period) period) + + ;; set the offset from the phase + (let* ((period-float (the float period)) + (value (* phase period-float)) ) - (set! (-> obj offset) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1))) - ) - (cond - ((< arg2 0.0) - (set! arg2 0.0) + (set! (-> obj offset) (- value (* (the float (the int (/ value period-float))) period-float))) ) - ((< 1.0 arg2) - (set! arg2 1.0) - ) - ) - (cond - ((< arg3 0.0) - (set! arg3 0.0) - ) - ((< (- 1.0 arg2) arg3) - (set! arg3 (- 1.0 arg2)) - ) - ) - (set! (-> obj pause-after-in) arg3) - (set! (-> obj pause-after-out) arg2) - 0 - ) - -;; definition for method 15 of type sync-info -;; ERROR: function was not converted to expressions. Cannot decompile. - -;; definition for method 15 of type sync-info-eased -;; ERROR: function was not converted to expressions. Cannot decompile. - -;; definition for method 15 of type sync-info-paused -;; ERROR: function was not converted to expressions. Cannot decompile. - -;; definition for method 10 of type sync-info -(defmethod dummy-10 sync-info ((obj sync-info)) - (let* ((v1-0 (-> obj period)) - (f0-1 (the float v1-0)) - (f1-2 - (+ - (the float (mod (-> *display* base-frame-counter) v1-0)) - (-> obj offset) + ;; saturate the params + (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) + ) + ) + (none) + ) + +(defmethod setup-params! sync-info-paused ((obj sync-info-paused) (period uint) (phase float) (out-param float) (in-param float)) + "Setup a sync-info-paused. The params are delays for the pause, specified in a fraction of period." + (set! (-> obj period) period) + ;; set phase. + (let* ((f0-1 (the float period)) + (f1-1 (* phase f0-1)) ) - (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) + (set! (-> obj offset) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1))) + ) + ;; saturate params + (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) + ) + ;; note: makes sure pauses don't overlap + ((< (- 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) + (none) + ) + +(defmethod load-params! sync-info ((obj sync-info) (proc process) (default-period uint) (default-phase float) (default-out float) (default-in float)) + "Load params from the res of a process, and set them up. If the res lookup fails, returns #f and uses + the specified defaults." + (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 + ;; res lookup succeeded, we should have two values: a period (not yet in seconds) and a phase. + (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 + ;; failed, set defaults + (setup-params! obj default-period default-phase 0.15 0.15) + #f + ) + ) + ) + ) + +(defmethod load-params! sync-info-eased ((obj sync-info-eased) (proc process) (default-period uint) (default-phase float) (default-out float) (default-in float)) + "Load settings from a res. Can load settings from just a sync-info and uses defaults. + If res lookup totally fails, will return #f and use all defaults." + (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 + ;; we may not get all the parameters + (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 + ) + ) + ) + ) + +(defmethod load-params! sync-info-paused ((obj sync-info-paused) (proc process) (default-period uint) (default-phase float) (default-out float) (default-in float)) + "Load and setup a sync-info-paused." + (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 17 of type sync-info -(defmethod dummy-17 sync-info ((obj sync-info)) +(defmethod get-current-phase-no-mod sync-info ((obj sync-info)) + "Based on the current frame, get the current phase. Does not apply any modifications + like pauses or eases." + (let* ((period (-> obj period)) + (period-float (the float period)) + ;; now + offset + (current-time + (+ (the float (mod (-> *display* base-frame-counter) period)) + (-> obj offset) + ) + ) + ) + ;; compute wrapped phase from current-time + (/ (- current-time + (* (the float (the int (/ current-time period-float))) period-float)) + period-float + ) + ) + ) + +(defmethod get-phase-offset sync-info ((obj sync-info)) + "Get the offset, as a fraction of period" (/ (-> obj offset) (the float (-> obj period))) ) -;; definition for method 16 of type sync-info -(defmethod dummy-16 sync-info ((obj sync-info) (arg0 float)) - (let* ((a2-0 (-> obj period)) - (f0-1 (the float a2-0)) - (v1-0 (- arg0 (* (the float (the int (/ arg0 f0-1))) f0-1))) - (f1-4 - (+ - (the float (mod (-> *display* base-frame-counter) a2-0)) - (-> obj offset) +(defmethod sync-now! sync-info ((obj sync-info) (user-phase-offset float)) + "Adjusts our offset so we are at phase user-phase-offset now" + (let* ((period (-> obj period)) + (period-float (the float period)) + ;; in (0, 1) + (wrapped-user-offset + (- user-phase-offset + (* (the float (the int (/ user-phase-offset period-float))) + period-float + ) + ) ) - ) - (f1-6 (/ (- f1-4 (* (the float (the int (/ f1-4 f0-1))) f0-1)) f0-1)) - (f1-10 (+ (+ (* (- v1-0 f1-6) f0-1) f0-1) (-> obj offset))) - (f0-3 (- f1-10 (* (the float (the int (/ f1-10 f0-1))) f0-1))) - ) - (set! (-> obj offset) f0-3) - f0-3 - ) - ) - -;; definition for method 11 of type sync-info -(defmethod dummy-11 sync-info ((obj sync-info)) - (let* ((v1-0 (-> obj period)) - (f0-1 (the float v1-0)) - (f1-2 - (+ - (the float (mod (-> *display* base-frame-counter) v1-0)) - (-> obj offset) + ;; with the current offset, what is the time (0, period)? + (current-time + (+ (the float (mod (-> *display* base-frame-counter) period)) + (-> obj offset) + ) ) - ) - ) - (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) - ) - ) - -;; definition for method 11 of type sync-info-paused -(defmethod dummy-11 sync-info-paused ((obj sync-info-paused)) - (let* ((v1-0 (-> obj period)) - (f1-0 (the float v1-0)) - (f0-1 1.0) - (f2-2 - (+ - (the float (mod (-> *display* base-frame-counter) v1-0)) - (-> obj offset) + ;; current period in (0, 1) + (current-period-wrapped + (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) + period-float + ) + ) + ;; a time + (combined-offset + (+ (+ (* (- wrapped-user-offset current-period-wrapped) period-float) + period-float + ) + (-> obj offset) + ) + ) + ;; wrap it + (combined-offset-wrapped + (- combined-offset + (* (the float (the int (/ combined-offset period-float))) period-float) + ) ) - ) ) - (fmin - f0-1 - (/ - (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) - (* f1-0 (- 1.0 (-> obj pause-after-out))) - ) + (set! (-> obj offset) combined-offset-wrapped) + combined-offset-wrapped ) - ) ) -;; definition for method 9 of type sync-info -(defmethod dummy-9 sync-info ((obj sync-info) (arg0 float)) - (let* ((v1-0 (-> obj period)) - (f0-1 (the float v1-0)) - (f1-2 - (+ - (the float (mod (-> *display* base-frame-counter) v1-0)) - (-> obj offset) - ) - ) +(defmethod get-current-phase sync-info ((obj sync-info)) + "Get the current phase." + (let* ((period (-> obj period)) + (period-float (the float period)) + (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) ) - (* (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) arg0) - ) + ;; don't need to wrap this again. + (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) + period-float + ) + ) ) -;; definition for method 9 of type sync-info-paused -(defmethod dummy-9 sync-info-paused ((obj sync-info-paused) (arg0 float)) - (* (dummy-11 obj) arg0) +(defmethod get-current-phase sync-info-paused ((obj sync-info-paused)) + "Get the current phase. this only uses the pause-after-out - use the mirrored version + for pauses on both ends" + (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))) ;; just tweak the effective period so we end early + ) + ) + ) ) -;; definition for method 13 of type sync-info -(defmethod dummy-13 sync-info ((obj sync-info)) +(defmethod get-current-value sync-info ((obj sync-info) (max-val float)) + "This is just get-current-phase multiplied by max-val" + (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 + ) + ) + ) + +(defmethod get-current-value sync-info-paused ((obj sync-info-paused) (arg0 float)) + "This is just get-current-phase multiplied by max-val" + (* (get-current-phase obj) arg0) + ) + +(defmethod get-current-phase-with-mirror sync-info ((obj sync-info)) + "Gets the phase that goes from 0 to 1 back to 0 every period." + (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 + ) + ) + + +(defmethod get-current-phase-with-mirror sync-info-eased ((obj sync-info-eased)) + "Get the phase that goes from 0 to 1 back to 0 every period. + Note that sync-info-eased only does easing on this mirrored version." + (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) + ) + + ;; the input to the eased-phase calculation is un-mirrored, then mirrored after + (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) + ;; quadratic ramp in + (* current-val current-val) + ) + ((< current-val (-> obj thi)) + ;; linear part + (+ (* (* 2.0 tlo) (- current-val tlo)) (-> obj ylo)) + ) + (else + (let ((f1-7 (- 1.0 current-val))) + ;; quadratic ramp out + (- (-> obj yend) (* (* f1-7 f1-7) (-> obj m2))) + ) + ) + ) + (-> obj yend) + ) + ) + ) + ;; flip again + (if in-mirror? + (set! eased-phase (- 1.0 eased-phase)) + ) + eased-phase + ) + ) + ) + +(defmethod get-current-phase-with-mirror sync-info-paused ((obj sync-info-paused)) + "Get the phase that goes from 0 to 1 to 0 in one period." (let* ((v1-0 (-> obj period)) (f1-0 (the float v1-0)) + ;; max val (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) - ) - ) - ) - (if (>= f0-2 1.0) - (set! f0-2 (- 2.0 f0-2)) - ) - f0-2 - ) - ) - -;; definition for method 13 of type sync-info-eased -(defmethod dummy-13 sync-info-eased ((obj sync-info-eased)) - (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) - ) - ) - (v1-2 #f) - ) - (when (>= f0-2 1.0) - (set! v1-2 #t) - (set! f0-2 (+ -1.0 f0-2)) - ) - (let* ((f1-4 (-> obj tlo)) - (f0-7 (/ (cond - ((< f0-2 f1-4) - (* f0-2 f0-2) - ) - ((< f0-2 (-> obj thi)) - (+ (* (* 2.0 f1-4) (- f0-2 f1-4)) (-> obj ylo)) - ) - (else - (let ((f1-7 (- 1.0 f0-2))) - (- (-> obj yend) (* (* f1-7 f1-7) (-> obj m2))) - ) - ) - ) - (-> obj yend) - ) - ) - ) - (if v1-2 - (set! f0-7 (- 1.0 f0-7)) - ) - f0-7 - ) - ) - ) - -;; definition for method 13 of type sync-info-paused -(defmethod dummy-13 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) - ) - ) + ;; current-time + (f2-2 (+ (the float (mod (-> *display* base-frame-counter) v1-0)) (-> obj offset))) + ;; phase + (f0-2 (* f0-1 (/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0))) + ;; offset for pause (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 + 0.0 ;; before pause ends ) ((< 1.0 f0-2) + ;; in moving part (- 1.0 (/ (+ -1.0 f0-2) f1-3)) ) ((>= f0-2 f2-7) + ;; after end pause 1.0 ) (else + ;; in moving part (/ f0-2 f2-7) ) ) ) ) -;; definition for method 12 of type sync-info -(defmethod dummy-12 sync-info ((obj sync-info) (arg0 float)) - (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) +(defmethod get-current-value-with-mirror sync-info ((obj sync-info) (max-out-val float)) + "Get the phase that goes from 0 to max-out-val to 0 in each period." + (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 + ) + ) ) - ) - (f0-2 - (* - f0-1 - (/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0) - ) - ) ) - (if (>= f0-2 1.0) - (set! f0-2 (- 2.0 f0-2)) + (if (>= current-val 1.0) + (set! current-val (- 2.0 current-val)) + ) + (* current-val max-out-val) ) - (* f0-2 arg0) - ) ) -;; definition for method 12 of type sync-info-eased -(defmethod dummy-12 sync-info-eased ((obj sync-info-eased) (arg0 float)) - (* (dummy-13 obj) arg0) +(defmethod get-current-value-with-mirror sync-info-eased ((obj sync-info-eased) (max-out-val float)) + "Get phase that goes from 0 to max-out-val to 0 in each period" + (* (get-current-phase-with-mirror obj) max-out-val) ) -;; definition for method 12 of type sync-info-paused -(defmethod dummy-12 sync-info-paused ((obj sync-info-paused) (arg0 float)) - (* (dummy-13 obj) arg0) +(defmethod get-current-value-with-mirror sync-info-paused ((obj sync-info-paused) (max-out-val float)) + "Get phase that goes from 0 to max-out-val to 0 in each period" + (* (get-current-phase-with-mirror obj) max-out-val) ) -;; definition for method 9 of type delayed-rand-float -(defmethod - dummy-9 - delayed-rand-float - ((obj delayed-rand-float) (arg0 int) (arg1 int) (arg2 float)) - (set! (-> obj min-time) arg0) - (set! (-> obj max-time) arg1) - (set! (-> obj max-val) (* 0.5 arg2)) +(defmethod set-params! delayed-rand-float ((obj delayed-rand-float) (min-tim int) (max-time int) (max-times-two float)) + "Float that changes randomly: + min-time: minimum time between changes + max-time: maximum time between changes + max-times-two: maximum range. result is centered around zero." + (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 dummy-10 delayed-rand-float ((obj delayed-rand-float)) - (when - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) - (-> obj timer) +(defmethod update! delayed-rand-float ((obj delayed-rand-float)) + "Get the value." + (when (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) (-> obj timer)) + ;; only update if enough time has passed. + (set! (-> obj start-time) (-> *display* base-frame-counter)) + ;; come up with a random end time. + (set! (-> obj timer) (rand-vu-int-range (-> obj min-time) (-> obj max-time))) + ;; come up with a random value in (-max, max) + (set! (-> obj value) (rand-vu-float-range (- (-> obj max-val)) (-> obj max-val))) ) - (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 - dummy-9 - oscillating-float - ((obj oscillating-float) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj value) arg0) - (set! (-> obj target) arg0) +(defmethod set-params! oscillating-float ((obj oscillating-float) (init-val float) (accel float) (max-vel float) (damping float)) + "Setup an oscillating-float. It will head toward the target, but will overshoot and oscillate before + eventually reaching the target. + init-val: the initial value and target + max-vel: velocity limit + damping: this is 1 - damping really. 0 means don't move, 1 means oscillate forever. + accel: gain." + + (set! (-> obj value) init-val) + (set! (-> obj target) init-val) (set! (-> obj vel) 0.0) - (set! (-> obj max-vel) arg2) - (set! (-> obj damping) arg3) - (set! (-> obj accel) arg1) + (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 dummy-10 oscillating-float ((obj oscillating-float) (arg0 float)) - (let - ((f0-3 - (* - (- (+ (-> obj target) arg0) (-> obj value)) - (* (-> obj accel) (-> *display* time-adjust-ratio)) - ) - ) +(defmethod update! oscillating-float ((obj oscillating-float) (target-offset float)) + ;; first compute desired acceleration + (let ((acc (* (- (+ (-> obj target) target-offset) (-> obj value)) + (* (-> obj accel) (-> *display* time-adjust-ratio)) + ) + ) + ) + ;; integrate and update velocity + (+! (-> obj vel) acc) ) - (set! (-> obj vel) (+ (-> obj vel) f0-3)) - ) - (set! - (-> obj vel) - (fmin (-> obj max-vel) (fmax (- (-> obj max-vel)) (-> obj vel))) - ) + ;; limit velocity + (set! (-> obj vel) (fmin (-> obj max-vel) (fmax (- (-> obj max-vel)) (-> obj vel)))) + ;; apply damping (set! (-> obj vel) (* (-> obj vel) (-> obj damping))) - (set! - (-> obj value) - (+ (-> obj value) (* (-> obj vel) (-> *display* time-adjust-ratio))) - ) + ;; integrate and update position + (+! (-> obj value) (* (-> obj vel) (-> *display* time-adjust-ratio))) (-> obj value) ) -;; definition for method 9 of type bouncing-float -(defmethod - dummy-9 - bouncing-float - ((obj bouncing-float) - (arg0 float) - (arg1 float) - (arg2 float) - (arg3 float) - (arg4 float) - (arg5 float) - (arg6 float) - ) - (dummy-9 (-> obj osc) arg0 arg4 arg5 arg6) - (set! (-> obj max-value) arg1) - (set! (-> obj min-value) arg2) - (set! (-> obj elasticity) arg3) +(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)) + "Float that bounces. It's an oscillating float, but you can add a floor/ceiling that has an + elastic collision. + init-val: intial value and target. + max-val: ceiling to bounce off of + min-val: floor to bounce off of + elast: elasticity + accel: gain + max-vel: maximum velocity, not in elastic part. + damping: damping for the non-elastic part." + (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 dummy-10 bouncing-float ((obj bouncing-float) (arg0 float)) - (dummy-10 (-> obj osc) arg0) +(defmethod update! bouncing-float ((obj bouncing-float) (arg0 float)) + ;; first, update the oscillator and assume we aren't in a bouncing part + (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)))) + ;; boucing off of the ceiling. first, saturate to max-val + (set! (-> obj osc value) (-> obj max-value)) + (if (< 0.0 (-> obj osc vel)) + ;; then update our velocity for the elastic collision + (set! (-> obj osc vel) (* (-> obj osc vel) (- (-> obj elasticity)))) + ) + ;; and remember we did this, so at-min/at-max work + (set! (-> obj state) 1) ) - (set! (-> obj state) 1) - ) + ;; same for bouncing off of the floor (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 osc value) (-> obj min-value)) + (if (< (-> obj osc vel) 0.0) + (set! (-> obj osc vel) (* (-> obj osc vel) (- (-> obj elasticity)))) + ) + (set! (-> obj state) -1) ) - (set! (-> obj state) -1) - ) (-> obj osc value) ) -;; definition for method 11 of type bouncing-float -(defmethod dummy-11 bouncing-float ((obj bouncing-float)) +(defmethod at-min? bouncing-float ((obj bouncing-float)) + "Did the last update it the minimum value?" (= (-> obj state) -1) ) -;; definition for method 12 of type bouncing-float -(defmethod dummy-12 bouncing-float ((obj bouncing-float)) +(defmethod at-max? bouncing-float ((obj bouncing-float)) + "Did the last update hit the maximum value?" (= (-> obj state) 1) ) -;; definition for method 9 of type delayed-rand-vector -(defmethod dummy-9 delayed-rand-vector ((obj delayed-rand-vector) (arg0 int) (arg1 int) (arg2 float) (arg3 float)) - (set! (-> obj min-time) arg0) - (set! (-> obj max-time) arg1) - (set! (-> obj xz-max) (* 0.5 arg2)) - (set! (-> obj y-max) (* 0.5 arg3)) +(defmethod set-params! delayed-rand-vector ((obj delayed-rand-vector) (min-time int) (max-time int) (xz-range float) (y-range float)) + "Set up a delayed-rand-vector. This vector randomly changes at random times. + min-time: minimum time between changes + max-time: maximum time between changes + xz-range: xz results in (-range/2, range/2) + y-range: y results in (-range/2, range/2)" + (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 dummy-10 delayed-rand-vector ((obj delayed-rand-vector)) +(defmethod update-now! delayed-rand-vector ((obj delayed-rand-vector)) + "update to a random value now" (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)) + (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) + ) + +(defmethod update-with-delay! delayed-rand-vector ((obj delayed-rand-vector)) + "Update, if enough time has passed" + (if (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) (-> obj timer)) + (update-now! obj) ) (-> obj value) ) -;; definition for method 11 of type delayed-rand-vector -(defmethod dummy-11 delayed-rand-vector ((obj delayed-rand-vector)) - (if - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) - (-> obj timer) - ) - (dummy-10 obj) +(defmethod update-with-delay-or-reset! delayed-rand-vector ((obj delayed-rand-vector)) + "Update, if enough time has passed. Otherwise reset to zero." + (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 12 of type delayed-rand-vector -(defmethod dummy-12 delayed-rand-vector ((obj delayed-rand-vector)) - (if (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) - (-> obj timer) - ) - (dummy-10 obj) - (vector-reset! (-> obj value)) - ) - (-> obj value) - ) - -;; definition for method 9 of type oscillating-vector -;; Used lq/sq -(defmethod dummy-9 oscillating-vector ((obj oscillating-vector) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) +(defmethod set-params! oscillating-vector ((obj oscillating-vector) (init-val vector) (accel float) (max-vel float) (damping float)) + "Works just like oscillating-float, but does a whole vector. + init-val can be #f to reset to 0." (cond - (arg0 - (set! (-> obj value quad) (-> arg0 quad)) - (set! (-> obj target quad) (-> arg0 quad)) - ) - (else - (vector-reset! (-> obj value)) - (vector-reset! (-> obj target)) - ) + (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) arg2) - (set! (-> obj damping) arg3) - (set! (-> obj accel) arg1) + (set! (-> obj max-vel) max-vel) + (set! (-> obj damping) damping) + (set! (-> obj accel) accel) (-> obj value) ) -;; definition for method 10 of type oscillating-vector -;; todo vector-float*! -(defmethod dummy-10 oscillating-vector ((obj oscillating-vector) (arg0 vector)) +(defmethod update! oscillating-vector ((obj oscillating-vector) (target-offset vector)) + "target-offset can be #f, acts like 0" (let ((s5-0 (new 'stack-no-clear 'vector))) (cond - (arg0 - (vector+! s5-0 (-> obj target) arg0) + (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-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)) + (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)) diff --git a/test/decompiler/reference/engine/physics/trajectory-h_REF.gc b/test/decompiler/reference/engine/physics/trajectory-h_REF.gc index ed1044dc54..94943ca219 100644 --- a/test/decompiler/reference/engine/physics/trajectory-h_REF.gc +++ b/test/decompiler/reference/engine/physics/trajectory-h_REF.gc @@ -12,13 +12,13 @@ :size-assert #x28 :flag-assert #x1000000028 (:methods - (TODO-RENAME-9 (_type_ float vector) vector 9) - (TODO-RENAME-10 (_type_ float vector) vector 10) - (TODO-RENAME-11 (_type_ vector vector float float) none 11) - (TODO-RENAME-12 (_type_ vector vector float float) none 12) - (TODO-RENAME-13 (_type_ vector vector float float) none 13) - (TODO-RENAME-14 (_type_ vector vector float float) none 14) - (TODO-RENAME-15 (_type_) none 15) + (eval-position! (_type_ float vector) vector 9) + (eval-velocity! (_type_ float vector) vector 10) + (setup-from-to-duration! (_type_ vector vector float float) none 11) + (setup-from-to-xz-vel! (_type_ vector vector float float) none 12) + (setup-from-to-y-vel! (_type_ vector vector float float) none 13) + (setup-from-to-height! (_type_ vector vector float float) none 14) + (debug-draw! (_type_) none 15) ) ) @@ -34,3 +34,7 @@ ;; failed to figure out what this is: 0 + + + + diff --git a/test/decompiler/reference/engine/physics/trajectory_REF.gc b/test/decompiler/reference/engine/physics/trajectory_REF.gc index 2f7776369b..029177a5a3 100644 --- a/test/decompiler/reference/engine/physics/trajectory_REF.gc +++ b/test/decompiler/reference/engine/physics/trajectory_REF.gc @@ -3,43 +3,49 @@ ;; definition for method 9 of type trajectory ;; Used lq/sq -(defmethod TODO-RENAME-9 trajectory ((obj trajectory) (arg0 float) (arg1 vector)) - (set! (-> arg1 quad) (-> obj initial-position quad)) - (+! (-> arg1 x) (* arg0 (-> obj initial-velocity x))) - (+! (-> arg1 y) (* arg0 (-> obj initial-velocity y))) - (+! (-> arg1 z) (* arg0 (-> obj initial-velocity z))) - (+! (-> arg1 y) (* (* (* 0.5 arg0) arg0) (-> obj gravity))) - arg1 +(defmethod + eval-position! + trajectory + ((obj trajectory) (time float) (result vector)) + (set! (-> result quad) (-> obj initial-position quad)) + (+! (-> result x) (* time (-> obj initial-velocity x))) + (+! (-> result y) (* time (-> obj initial-velocity y))) + (+! (-> result z) (* time (-> obj initial-velocity z))) + (+! (-> result y) (* (* (* 0.5 time) time) (-> obj gravity))) + result ) ;; definition for method 10 of type trajectory ;; Used lq/sq (defmethod - TODO-RENAME-10 + eval-velocity! trajectory - ((obj trajectory) (arg0 float) (arg1 vector)) - (set! (-> arg1 quad) (-> obj initial-velocity quad)) - (+! (-> arg1 y) (* arg0 (-> obj gravity))) - arg1 + ((obj trajectory) (time float) (result vector)) + (set! (-> result quad) (-> obj initial-velocity quad)) + (+! (-> result y) (* time (-> obj gravity))) + result ) ;; definition for method 11 of type trajectory ;; INFO: Return type mismatch int vs none. ;; Used lq/sq (defmethod - TODO-RENAME-11 + setup-from-to-duration! trajectory - ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) - (set! (-> obj initial-position quad) (-> arg0 quad)) - (set! (-> obj gravity) arg3) - (set! (-> obj time) arg2) - (let ((f0-3 (/ (vector-vector-xz-distance arg1 arg0) arg2))) - (vector-! (-> obj initial-velocity) arg1 arg0) - (vector-xz-normalize! (-> obj initial-velocity) f0-3) + ((obj trajectory) (from vector) (to vector) (duration float) (grav float)) + (set! (-> obj initial-position quad) (-> from quad)) + (set! (-> obj gravity) grav) + (set! (-> obj time) duration) + (let ((xz-vel (/ (vector-vector-xz-distance to from) duration))) + (vector-! (-> obj initial-velocity) to from) + (vector-xz-normalize! (-> obj initial-velocity) xz-vel) ) (set! (-> obj initial-velocity y) - (- (/ (- (-> arg1 y) (-> arg0 y)) arg2) (* (* 0.5 arg2) (-> obj gravity))) + (- + (/ (- (-> to y) (-> from y)) duration) + (* (* 0.5 duration) (-> obj gravity)) + ) ) 0 (none) @@ -48,11 +54,11 @@ ;; definition for method 12 of type trajectory ;; INFO: Return type mismatch int vs none. (defmethod - TODO-RENAME-12 + setup-from-to-xz-vel! trajectory - ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) - (let ((f0-1 (/ (vector-vector-xz-distance arg1 arg0) arg2))) - (TODO-RENAME-11 obj arg0 arg1 f0-1 arg3) + ((obj trajectory) (from vector) (to vector) (xz-vel float) (grav float)) + (let ((duration (/ (vector-vector-xz-distance to from) xz-vel))) + (setup-from-to-duration! obj from to duration grav) ) 0 (none) @@ -61,19 +67,19 @@ ;; definition for method 13 of type trajectory ;; INFO: Return type mismatch int vs none. (defmethod - TODO-RENAME-13 + setup-from-to-y-vel! trajectory - ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) - (let* ((f0-0 arg2) - (f1-3 (- (* f0-0 f0-0) (* (* 2.0 (- (-> arg0 y) (-> arg1 y))) arg3))) + ((obj trajectory) (from vector) (to vector) (y-vel float) (grav float)) + (let* ((f0-0 y-vel) + (f1-3 (- (* f0-0 f0-0) (* (* 2.0 (- (-> from y) (-> to y))) grav))) (f0-3 900.0) ) (when (>= f1-3 0.0) (let ((f0-4 (sqrtf f1-3))) - (set! f0-3 (fmax (/ (- (- arg2) f0-4) arg3) (/ (+ (- arg2) f0-4) arg3))) + (set! f0-3 (fmax (/ (- (- y-vel) f0-4) grav) (/ (+ (- y-vel) f0-4) grav))) ) ) - (TODO-RENAME-11 obj arg0 arg1 f0-3 arg3) + (setup-from-to-duration! obj from to f0-3 grav) ) 0 (none) @@ -82,7 +88,7 @@ ;; definition for method 14 of type trajectory ;; INFO: Return type mismatch int vs none. (defmethod - TODO-RENAME-14 + setup-from-to-height! trajectory ((obj trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) (let* ((f1-2 (+ arg2 (fmax (-> arg0 y) (-> arg1 y)))) @@ -92,7 +98,7 @@ (if (< 0.0 f1-5) (set! f0-3 (sqrtf f1-5)) ) - (TODO-RENAME-13 obj arg0 arg1 f0-3 arg3) + (setup-from-to-y-vel! obj arg0 arg1 f0-3 arg3) ) 0 (none) @@ -101,23 +107,26 @@ ;; definition for method 15 of type trajectory ;; INFO: Return type mismatch int vs none. ;; Used lq/sq -(defmethod TODO-RENAME-15 trajectory ((obj trajectory)) - (let ((s5-0 (new 'stack-no-clear 'vector)) - (s4-0 (new 'stack-no-clear 'vector)) - (s3-0 10) +(defmethod debug-draw! trajectory ((obj trajectory)) + (let ((prev-pos (new 'stack-no-clear 'vector)) + (pos (new 'stack-no-clear 'vector)) + (num-segments 10) ) - (set! (-> s4-0 quad) (-> obj initial-position quad)) - (dotimes (s2-0 s3-0) - (set! (-> s5-0 quad) (-> s4-0 quad)) + (set! (-> pos quad) (-> obj initial-position quad)) + (dotimes (s2-0 num-segments) + (set! (-> prev-pos quad) (-> pos quad)) (let - ((f0-1 (* (-> obj time) (/ (+ 1.0 (the float s2-0)) (the float s3-0))))) - (TODO-RENAME-9 obj f0-1 s4-0) + ((t-eval + (* (-> obj time) (/ (+ 1.0 (the float s2-0)) (the float num-segments))) + ) + ) + (eval-position! obj t-eval pos) ) (add-debug-line #t (bucket-id debug-draw1) - s5-0 - s4-0 + prev-pos + pos (new 'static 'rgba :r #xff :a #x80) #f (the-as rgba -1) @@ -127,3 +136,7 @@ 0 (none) ) + + + + diff --git a/test/decompiler/reference/engine/util/sync-info-h_REF.gc b/test/decompiler/reference/engine/util/sync-info-h_REF.gc index 21bc6bc647..5fc40dc25e 100644 --- a/test/decompiler/reference/engine/util/sync-info-h_REF.gc +++ b/test/decompiler/reference/engine/util/sync-info-h_REF.gc @@ -10,15 +10,15 @@ :size-assert #x8 :flag-assert #x1200000008 (:methods - (dummy-9 (_type_ float) float 9) - (dummy-10 (_type_) float 10) - (dummy-11 (_type_) float 11) - (dummy-12 (_type_ float) float 12) - (dummy-13 (_type_) float 13) - (dummy-14 (_type_ uint float float float) int 14) - (dummy-15 (_type_ process) float 15) - (dummy-16 (_type_ float) float 16) - (dummy-17 (_type_) float 17) + (get-current-value (_type_ float) float 9) + (get-current-phase-no-mod (_type_) float 10) + (get-current-phase (_type_) float 11) + (get-current-value-with-mirror (_type_ float) float 12) + (get-current-phase-with-mirror (_type_) float 13) + (setup-params! (_type_ uint float float float) none 14) + (load-params! (_type_ process uint float float float) symbol 15) + (sync-now! (_type_ float) float 16) + (get-phase-offset (_type_) float 17) ) ) @@ -89,8 +89,8 @@ :size-assert #x1c :flag-assert #xb0000001c (:methods - (dummy-9 (_type_ int int float) float 9) - (dummy-10 (_type_) float 10) + (set-params! (_type_ int int float) float 9) + (update! (_type_) float 10) ) ) @@ -119,8 +119,8 @@ :size-assert #x18 :flag-assert #xb00000018 (:methods - (dummy-9 (_type_ float float float float) float 9) - (dummy-10 (_type_ float) float 10) + (set-params! (_type_ float float float float) float 9) + (update! (_type_ float) float 10) ) ) @@ -148,10 +148,10 @@ :size-assert #x28 :flag-assert #xd00000028 (:methods - (dummy-9 (_type_ float float float float float float float) float 9) - (dummy-10 (_type_ float) float 10) - (dummy-11 (_type_) symbol 11) - (dummy-12 (_type_) symbol 12) + (set-params! (_type_ float float float float float float float) float 9) + (update! (_type_ float) float 10) + (at-min? (_type_) symbol 11) + (at-max? (_type_) symbol 12) ) ) @@ -180,10 +180,10 @@ :size-assert #x30 :flag-assert #xd00000030 (:methods - (dummy-9 (_type_ int int float float) vector 9) - (dummy-10 (_type_) vector 10) - (dummy-11 (_type_) vector 11) - (dummy-12 (_type_) vector 12) + (set-params! (_type_ int int float float) vector 9) + (update-now! (_type_) vector 10) + (update-with-delay! (_type_) vector 11) + (update-with-delay-or-reset! (_type_) vector 12) ) ) @@ -213,8 +213,8 @@ :size-assert #x3c :flag-assert #xb0000003c (:methods - (dummy-9 (_type_ vector float float float) vector 9) - (dummy-10 (_type_ vector) vector 10) + (set-params! (_type_ vector float float float) vector 9) + (update! (_type_ vector) vector 10) ) ) @@ -232,3 +232,7 @@ ;; failed to figure out what this is: 0 + + + + diff --git a/test/decompiler/reference/engine/util/sync-info_REF.gc b/test/decompiler/reference/engine/util/sync-info_REF.gc index 96ac1d5079..da1c866363 100644 --- a/test/decompiler/reference/engine/util/sync-info_REF.gc +++ b/test/decompiler/reference/engine/util/sync-info_REF.gc @@ -2,279 +2,528 @@ (in-package goal) ;; definition for method 14 of type sync-info +;; INFO: Return type mismatch int vs none. (defmethod - dummy-14 + setup-params! sync-info - ((obj sync-info) (arg0 uint) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj period) arg0) - (let* ((f0-1 (the float arg0)) - (f1-1 (* arg1 f0-1)) + ((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) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1))) + (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 - dummy-14 + setup-params! sync-info-eased - ((obj sync-info-eased) (arg0 uint) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj period) arg0) - (let* ((f0-1 (the float arg0)) - (f1-1 (* arg1 f0-1)) + ((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) (- f1-1 (* (the float (the int (/ f1-1 f0-1))) f0-1))) - ) - (if (< arg2 0.0) - (set! arg2 0.0) - ) - (if (< 1.0 arg2) - (set! arg2 1.0) - ) - (if (< arg3 0.001) - (set! arg3 0.001) - ) - (if (< 1.0 arg3) - (set! arg3 1.0) - ) - (let ((f0-9 (+ arg2 arg3))) - (when (< 1.0 f0-9) - (set! f0-9 1.0) - (set! arg2 (- 1.0 arg3)) + (set! + (-> obj offset) + (- value (* (the float (the int (/ value period-float))) period-float)) ) - (let* ((f1-11 (- 1.0 f0-9)) - (f0-10 arg2) - (f1-12 (+ arg2 f1-11)) + ) + (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))) - (f3-4 (+ (* (* (- 1.0 f1-12) (- 1.0 f1-12)) f4-3) f3-3)) + (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) f3-4) + (set! (-> obj yend) y-end) ) ) 0 + (none) ) ;; definition for method 14 of type sync-info-paused +;; INFO: Return type mismatch int vs none. (defmethod - dummy-14 + setup-params! sync-info-paused - ((obj sync-info-paused) (arg0 uint) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj period) arg0) - (let* ((f0-1 (the float arg0)) - (f1-1 (* arg1 f0-1)) + ((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 - ((< arg2 0.0) - (set! arg2 0.0) + ((< out-param 0.0) + (set! out-param 0.0) ) - ((< 1.0 arg2) - (set! arg2 1.0) + ((< 1.0 out-param) + (set! out-param 1.0) ) ) (cond - ((< arg3 0.0) - (set! arg3 0.0) + ((< in-param 0.0) + (set! in-param 0.0) ) - ((< (- 1.0 arg2) arg3) - (set! arg3 (- 1.0 arg2)) + ((< (- 1.0 out-param) in-param) + (set! in-param (- 1.0 out-param)) ) ) - (set! (-> obj pause-after-in) arg3) - (set! (-> obj pause-after-out) arg2) + (set! (-> obj pause-after-in) in-param) + (set! (-> obj pause-after-out) out-param) 0 + (none) ) ;; definition for method 15 of type sync-info -;; ERROR: function was not converted to expressions. Cannot decompile. +;; 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 -;; ERROR: function was not converted to expressions. Cannot decompile. +;; 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 -;; ERROR: function was not converted to expressions. Cannot decompile. +;; 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 dummy-10 sync-info ((obj sync-info)) - (let* ((v1-0 (-> obj period)) - (f0-1 (the float v1-0)) - (f1-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) ) - (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) + (/ + (- + current-time + (* (the float (the int (/ current-time period-float))) period-float) + ) + period-float + ) ) ) ;; definition for method 17 of type sync-info -(defmethod dummy-17 sync-info ((obj 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 dummy-16 sync-info ((obj sync-info) (arg0 float)) - (let* ((a2-0 (-> obj period)) - (f0-1 (the float a2-0)) - (v1-0 (- arg0 (* (the float (the int (/ arg0 f0-1))) f0-1))) - (f1-4 +(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) a2-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) - (f1-6 (/ (- f1-4 (* (the float (the int (/ f1-4 f0-1))) f0-1)) f0-1)) - (f1-10 (+ (+ (* (- v1-0 f1-6) f0-1) f0-1) (-> obj offset))) - (f0-3 (- f1-10 (* (the float (the int (/ f1-10 f0-1))) f0-1))) + (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) f0-3) - f0-3 + (set! (-> obj offset) combined-offset-wrapped) + combined-offset-wrapped ) ) ;; definition for method 11 of type sync-info -(defmethod dummy-11 sync-info ((obj sync-info)) - (let* ((v1-0 (-> obj period)) - (f0-1 (the float v1-0)) - (f1-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) ) - (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) + (/ + (- + current-time + (* (the float (the int (/ current-time period-float))) period-float) + ) + period-float + ) ) ) ;; definition for method 11 of type sync-info-paused -(defmethod dummy-11 sync-info-paused ((obj sync-info-paused)) - (let* ((v1-0 (-> obj period)) - (f1-0 (the float v1-0)) - (f0-1 1.0) - (f2-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) ) (fmin - f0-1 + max-phase (/ - (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) - (* f1-0 (- 1.0 (-> obj pause-after-out))) + (- + 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 dummy-9 sync-info ((obj sync-info) (arg0 float)) - (let* ((v1-0 (-> obj period)) - (f0-1 (the float v1-0)) - (f1-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) ) - (* (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) arg0) + (* + (/ + (- + 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 dummy-9 sync-info-paused ((obj sync-info-paused) (arg0 float)) - (* (dummy-11 obj) arg0) +(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 dummy-13 sync-info ((obj sync-info)) - (let* ((v1-0 (-> obj period)) - (f1-0 (the float v1-0)) - (f0-1 2.0) - (f2-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) - (f0-2 + (phase-out-of-2 (* - f0-1 - (/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0) + max-val + (/ + (- + current-time + (* + (the float (the int (/ current-time period-float))) + period-float + ) + ) + period-float + ) ) ) ) - (if (>= f0-2 1.0) - (set! f0-2 (- 2.0 f0-2)) + (if (>= phase-out-of-2 1.0) + (set! phase-out-of-2 (- 2.0 phase-out-of-2)) ) - f0-2 + phase-out-of-2 ) ) ;; definition for method 13 of type sync-info-eased -(defmethod dummy-13 sync-info-eased ((obj sync-info-eased)) - (let* ((v1-0 (-> obj period)) - (f1-0 (the float v1-0)) - (f0-1 2.0) - (f2-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) - (f0-2 + (current-val (* - f0-1 - (/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0) + max-val + (/ + (- + current-time + (* + (the float (the int (/ current-time period-float))) + period-float + ) + ) + period-float + ) ) ) - (v1-2 #f) + (in-mirror? #f) ) - (when (>= f0-2 1.0) - (set! v1-2 #t) - (set! f0-2 (+ -1.0 f0-2)) + (when (>= current-val 1.0) + (set! in-mirror? #t) + (set! current-val (+ -1.0 current-val)) ) - (let* ((f1-4 (-> obj tlo)) - (f0-7 (/ (cond - ((< f0-2 f1-4) - (* f0-2 f0-2) - ) - ((< f0-2 (-> obj thi)) - (+ (* (* 2.0 f1-4) (- f0-2 f1-4)) (-> obj ylo)) - ) - (else - (let ((f1-7 (- 1.0 f0-2))) - (- (-> obj yend) (* (* f1-7 f1-7) (-> obj m2))) - ) - ) - ) - (-> obj yend) - ) + (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 v1-2 - (set! f0-7 (- 1.0 f0-7)) + (if in-mirror? + (set! eased-phase (- 1.0 eased-phase)) ) - f0-7 + eased-phase ) ) ) ;; definition for method 13 of type sync-info-paused -(defmethod dummy-13 sync-info-paused ((obj 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) @@ -311,48 +560,66 @@ ) ;; definition for method 12 of type sync-info -(defmethod dummy-12 sync-info ((obj sync-info) (arg0 float)) - (let* ((v1-0 (-> obj period)) - (f1-0 (the float v1-0)) - (f0-1 2.0) - (f2-2 +(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) v1-0)) + (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset) ) ) - (f0-2 + (current-val (* - f0-1 - (/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0) + max-val + (/ + (- + current-time + (* + (the float (the int (/ current-time period-float))) + period-float + ) + ) + period-float + ) ) ) ) - (if (>= f0-2 1.0) - (set! f0-2 (- 2.0 f0-2)) + (if (>= current-val 1.0) + (set! current-val (- 2.0 current-val)) ) - (* f0-2 arg0) + (* current-val max-out-val) ) ) ;; definition for method 12 of type sync-info-eased -(defmethod dummy-12 sync-info-eased ((obj sync-info-eased) (arg0 float)) - (* (dummy-13 obj) arg0) +(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 dummy-12 sync-info-paused ((obj sync-info-paused) (arg0 float)) - (* (dummy-13 obj) arg0) +(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 - dummy-9 + set-params! delayed-rand-float - ((obj delayed-rand-float) (arg0 int) (arg1 int) (arg2 float)) - (set! (-> obj min-time) arg0) - (set! (-> obj max-time) arg1) - (set! (-> obj max-val) (* 0.5 arg2)) + ((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) @@ -360,7 +627,7 @@ ) ;; definition for method 10 of type delayed-rand-float -(defmethod dummy-10 delayed-rand-float ((obj delayed-rand-float)) +(defmethod update! delayed-rand-float ((obj delayed-rand-float)) (when (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) @@ -378,29 +645,37 @@ ;; definition for method 9 of type oscillating-float (defmethod - dummy-9 + set-params! oscillating-float - ((obj oscillating-float) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) - (set! (-> obj value) arg0) - (set! (-> obj target) arg0) + ((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) arg2) - (set! (-> obj damping) arg3) - (set! (-> obj accel) arg1) + (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 dummy-10 oscillating-float ((obj oscillating-float) (arg0 float)) +(defmethod + update! + oscillating-float + ((obj oscillating-float) (target-offset float)) (let - ((f0-3 + ((acc (* - (- (+ (-> obj target) arg0) (-> obj value)) + (- (+ (-> obj target) target-offset) (-> obj value)) (* (-> obj accel) (-> *display* time-adjust-ratio)) ) ) ) - (+! (-> obj vel) f0-3) + (+! (-> obj vel) acc) ) (set! (-> obj vel) @@ -413,28 +688,28 @@ ;; definition for method 9 of type bouncing-float (defmethod - dummy-9 + set-params! bouncing-float ((obj bouncing-float) - (arg0 float) - (arg1 float) - (arg2 float) - (arg3 float) - (arg4 float) - (arg5 float) - (arg6 float) + (init-val float) + (max-val float) + (min-val float) + (elast float) + (accel float) + (max-vel float) + (damping float) ) - (dummy-9 (-> obj osc) arg0 arg4 arg5 arg6) - (set! (-> obj max-value) arg1) - (set! (-> obj min-value) arg2) - (set! (-> obj elasticity) arg3) + (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 dummy-10 bouncing-float ((obj bouncing-float) (arg0 float)) - (dummy-10 (-> obj osc) arg0) +(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)) @@ -454,24 +729,29 @@ ) ;; definition for method 11 of type bouncing-float -(defmethod dummy-11 bouncing-float ((obj bouncing-float)) +(defmethod at-min? bouncing-float ((obj bouncing-float)) (= (-> obj state) -1) ) ;; definition for method 12 of type bouncing-float -(defmethod dummy-12 bouncing-float ((obj bouncing-float)) +(defmethod at-max? bouncing-float ((obj bouncing-float)) (= (-> obj state) 1) ) ;; definition for method 9 of type delayed-rand-vector (defmethod - dummy-9 + set-params! delayed-rand-vector - ((obj delayed-rand-vector) (arg0 int) (arg1 int) (arg2 float) (arg3 float)) - (set! (-> obj min-time) arg0) - (set! (-> obj max-time) arg1) - (set! (-> obj xz-max) (* 0.5 arg2)) - (set! (-> obj y-max) (* 0.5 arg3)) + ((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)) @@ -479,7 +759,7 @@ ) ;; definition for method 10 of type delayed-rand-vector -(defmethod dummy-10 delayed-rand-vector ((obj 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! @@ -498,25 +778,28 @@ ) ;; definition for method 11 of type delayed-rand-vector -(defmethod dummy-11 delayed-rand-vector ((obj 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) ) - (dummy-10 obj) + (update-now! obj) ) (-> obj value) ) ;; definition for method 12 of type delayed-rand-vector -(defmethod dummy-12 delayed-rand-vector ((obj 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) ) - (dummy-10 obj) + (update-now! obj) (vector-reset! (-> obj value)) ) (-> obj value) @@ -525,18 +808,18 @@ ;; definition for method 9 of type oscillating-vector ;; Used lq/sq (defmethod - dummy-9 + set-params! oscillating-vector ((obj oscillating-vector) - (arg0 vector) - (arg1 float) - (arg2 float) - (arg3 float) + (init-val vector) + (accel float) + (max-vel float) + (damping float) ) (cond - (arg0 - (set! (-> obj value quad) (-> arg0 quad)) - (set! (-> obj target quad) (-> arg0 quad)) + (init-val + (set! (-> obj value quad) (-> init-val quad)) + (set! (-> obj target quad) (-> init-val quad)) ) (else (vector-reset! (-> obj value)) @@ -544,18 +827,21 @@ ) ) (vector-reset! (-> obj vel)) - (set! (-> obj max-vel) arg2) - (set! (-> obj damping) arg3) - (set! (-> obj accel) arg1) + (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 dummy-10 oscillating-vector ((obj oscillating-vector) (arg0 vector)) +(defmethod + update! + oscillating-vector + ((obj oscillating-vector) (target-offset vector)) (let ((s5-0 (new 'stack-no-clear 'vector))) (cond - (arg0 - (vector+! s5-0 (-> obj target) arg0) + (target-offset + (vector+! s5-0 (-> obj target) target-offset) (vector-! s5-0 s5-0 (-> obj value)) ) (else @@ -568,9 +854,9 @@ (* (-> 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)) + (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)) @@ -579,3 +865,7 @@ ) (-> obj value) ) + + + +