[decompiler] detect seek! and seekl! macros (#1317)

* detect `seek!` and `seekl!`

* fancy struct instead of pair mess

* fixes

* i think this was wrong?

* update refs

* update source

* More logical branching

* even better branching
This commit is contained in:
ManDude
2022-04-18 20:01:44 +01:00
committed by GitHub
parent cbc6987351
commit 66e395d547
109 changed files with 952 additions and 1398 deletions
+2 -6
View File
@@ -1633,13 +1633,9 @@
(when (not (paused?))
(let ((s5-1 (-> *display* frames (-> *display* last-screen) frame run-time)))
(let ((f0-5 (fmax 327680.0 (fmin (+ 327680.0 (* 204.8 (the float (- 7000 s5-1)))) (-> *ACTOR-bank* birth-dist)))))
(set! (-> *ACTOR-bank* pause-dist)
(seek (-> *ACTOR-bank* pause-dist) f0-5 (* 81920.0 (-> *display* seconds-per-frame)))
)
(seek! (-> *ACTOR-bank* pause-dist) f0-5 (* 81920.0 (-> *display* seconds-per-frame)))
)
(set! (-> *ACTOR-bank* birth-max)
(seekl (-> *ACTOR-bank* birth-max) (the int (lerp-scale 25.0 1.0 (the float s5-1) 2000.0 7000.0)) 10)
)
(seekl! (-> *ACTOR-bank* birth-max) (the int (lerp-scale 25.0 1.0 (the float s5-1) 2000.0 7000.0)) 10)
)
(if (movie?)
(set! (-> *ACTOR-bank* birth-max) 1000)
+5 -5
View File
@@ -294,8 +294,8 @@
(case item
(('life)
(if (>= amount 0.0)
(set! (-> obj life) (seek (-> obj life) (-> obj life-max) amount))
(set! (-> obj life) (seek (-> obj life) 0.0 (- amount)))
(seek! (-> obj life) (-> obj life-max) amount)
(seek! (-> obj life) 0.0 (- amount))
)
(-> obj life)
)
@@ -466,10 +466,10 @@
)
)
(set! (-> obj health-pickup-time) (-> *display* base-frame-counter))
(set! (-> obj health) (seek (-> obj health) (-> obj health-max) amount))
(seek! (-> obj health) (-> obj health-max) amount)
)
(else
(set! (-> obj health) (seek (-> obj health) 0.0 (- amount)))
(seek! (-> obj health) 0.0 (- amount))
(if (>= amount -10.0)
(pickup-collectable! obj (pickup-type eco-pill) 0.0 source-handle)
)
@@ -491,7 +491,7 @@
(((pickup-type eco-pill))
(when (>= amount 0.0)
(set! (-> obj eco-pill-pickup-time) (-> *display* base-frame-counter))
(set! (-> obj eco-pill) (seek (-> obj eco-pill) (-> obj eco-pill-max) amount))
(seek! (-> obj eco-pill) (-> obj eco-pill-max) amount)
(when (and (>= (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) (< (-> obj health) (-> obj health-max)))
(set! (-> obj eco-pill) (- (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)))
(pickup-collectable!
+1 -1
View File
@@ -1645,7 +1645,7 @@ auto-save-post
(else
(case (-> self mode)
(('auto-save)
(set! (-> *game-info* auto-save-count) (seekl (-> *game-info* auto-save-count) 0 1))
(seekl! (-> *game-info* auto-save-count) 0 1)
)
)
(go-virtual error (-> self result))
+1 -3
View File
@@ -650,9 +650,7 @@
)
(set! f0-8 (* 0.75 f0-8))
)
(set! (-> self control unknown-float141)
(seek (-> self control unknown-float141) f0-8 (* 100.0 (-> *display* seconds-per-frame)))
)
(seek! (-> self control unknown-float141) f0-8 (* 100.0 (-> *display* seconds-per-frame)))
)
(let ((f30-0 (-> self control unknown-float141))
(f0-13 (lerp-scale -0.3 0.3 (-> self control unknown-float01) 0.0 81920.0))
+3 -3
View File
@@ -739,14 +739,14 @@
(dummy-28 self)
((-> self update-velocity) self)
(when (logtest? (-> self options) 2)
(set! (-> self tween) (seek (-> self tween) 1.0 (* 0.5 (-> *display* seconds-per-frame))))
(seek! (-> self tween) 1.0 (* 0.5 (-> *display* seconds-per-frame)))
(let ((f0-6 (vector-vector-distance (-> self root-override trans) (-> self target))))
(cond
((< f0-6 20480.0)
(set! (-> self tween) (seek (-> self tween) 1.0 (* 3.0 (-> *display* seconds-per-frame))))
(seek! (-> self tween) 1.0 (* 3.0 (-> *display* seconds-per-frame)))
)
((< f0-6 40960.0)
(set! (-> self tween) (seek (-> self tween) 1.0 (-> *display* seconds-per-frame)))
(seek! (-> self tween) 1.0 (-> *display* seconds-per-frame))
)
)
)
+5 -15
View File
@@ -269,27 +269,19 @@
(let ((s5-1 (-> obj target)))
(when *sound-player-enable*
(when (!= (-> gp-0 sfx-volume) (-> s5-1 sfx-volume))
(set! (-> gp-0 sfx-volume)
(seek (-> gp-0 sfx-volume) (-> s5-1 sfx-volume) (* 100.0 (-> *display* seconds-per-frame)))
)
(seek! (-> gp-0 sfx-volume) (-> s5-1 sfx-volume) (* 100.0 (-> *display* seconds-per-frame)))
(sound-set-volume (the-as uint 1) (-> gp-0 sfx-volume))
)
(when (!= (-> gp-0 music-volume) (-> s5-1 music-volume))
(set! (-> gp-0 music-volume)
(seek (-> gp-0 music-volume) (-> s5-1 music-volume) (* 100.0 (-> *display* seconds-per-frame)))
)
(seek! (-> gp-0 music-volume) (-> s5-1 music-volume) (* 100.0 (-> *display* seconds-per-frame)))
(sound-set-volume (the-as uint 2) (-> gp-0 music-volume))
)
(when (!= (-> gp-0 dialog-volume) (-> s5-1 dialog-volume))
(set! (-> gp-0 dialog-volume)
(seek (-> gp-0 dialog-volume) (-> s5-1 dialog-volume) (* 100.0 (-> *display* seconds-per-frame)))
)
(seek! (-> gp-0 dialog-volume) (-> s5-1 dialog-volume) (* 100.0 (-> *display* seconds-per-frame)))
(sound-set-volume (the-as uint 4) (-> gp-0 dialog-volume))
)
(when (!= (-> gp-0 ambient-volume) (-> s5-1 ambient-volume))
(set! (-> gp-0 ambient-volume)
(seek (-> gp-0 ambient-volume) (-> s5-1 ambient-volume) (* 100.0 (-> *display* seconds-per-frame)))
)
(seek! (-> gp-0 ambient-volume) (-> s5-1 ambient-volume) (* 100.0 (-> *display* seconds-per-frame)))
(sound-set-volume (the-as uint 16) (-> gp-0 ambient-volume))
)
)
@@ -342,9 +334,7 @@
(set! (-> gp-0 bg-r) (-> s5-1 bg-r))
(set! (-> gp-0 bg-g) (-> s5-1 bg-g))
(set! (-> gp-0 bg-b) (-> s5-1 bg-b))
(set! (-> gp-0 bg-a)
(seek (-> gp-0 bg-a) (-> s5-1 bg-a) (* (-> s5-1 bg-a-speed) (-> *display* seconds-per-frame)))
)
(seek! (-> gp-0 bg-a) (-> s5-1 bg-a) (* (-> s5-1 bg-a-speed) (-> *display* seconds-per-frame)))
)
(let ((v1-60 (-> *display* frames (-> *display* on-screen) display))
(f0-39 (-> gp-0 bg-a))
+2 -4
View File
@@ -329,9 +329,7 @@
(defun increment-success-for-hint ((arg0 game-text-id))
(let ((gp-0 (find-hint-control-index arg0)))
(when (>= gp-0 0)
(set! (-> *game-info* hint-control gp-0 num-success)
(seekl (-> *game-info* hint-control gp-0 num-success) 127 1)
)
(seekl! (-> *game-info* hint-control gp-0 num-success) 127 1)
0
)
)
@@ -398,7 +396,7 @@
)
(cond
(v1-21
(set! (-> gp-1 num-attempts) (seekl (-> gp-1 num-attempts) 127 1))
(seekl! (-> gp-1 num-attempts) 127 1)
(and (>= (-> gp-1 num-attempts) (-> gp-1 num-attempts-before-playing))
(or (= (-> gp-1 num-success-before-killing) -1)
(< (-> gp-1 num-success) (-> gp-1 num-success-before-killing))
+2 -2
View File
@@ -104,8 +104,8 @@
)
)
(if (< 0.0 f0-8)
(set! (-> self twist) (seek (-> self twist) -0.4 (* 0.3 (-> *display* seconds-per-frame))))
(set! (-> self twist) (seek (-> self twist) 0.4 (* 0.3 (-> *display* seconds-per-frame))))
(seek! (-> self twist) -0.4 (* 0.3 (-> *display* seconds-per-frame)))
(seek! (-> self twist) 0.4 (* 0.3 (-> *display* seconds-per-frame)))
)
)
(let ((a1-9 (new 'stack-no-clear 'event-message-block)))
+1 -1
View File
@@ -1087,7 +1087,7 @@
)
(set! (-> obj drip-time) (-> *display* base-frame-counter))
(set! (-> obj flags) (logand -32769 (-> obj flags)))
(set! (-> obj drip-wetness) (seek (-> obj drip-wetness) 0.0 (* 0.001 (-> obj drip-speed))))
(seek! (-> obj drip-wetness) 0.0 (* 0.001 (-> obj drip-speed)))
(set! (-> obj drip-speed) (* 1.05 (-> obj drip-speed)))
(if (= (-> obj drip-wetness) 0.0)
(set! (-> obj drip-height) 0.0)
+1 -1
View File
@@ -3250,7 +3250,7 @@
(defmethod dummy-11 nav-control ((obj nav-control) (arg0 vector))
(set! (-> obj old-travel quad) (-> obj travel quad))
(-> obj block-count)
(set! (-> obj block-count) (seek (-> obj block-count) 0.0 0.016666668))
(seek! (-> obj block-count) 0.0 0.016666668)
(logclear! (-> obj flags) (nav-control-flags navcf9 navcf17 navcf18 navcf19))
(TODO-RENAME-27 obj)
(if (logtest? (-> obj flags) (nav-control-flags navcf8))
+5 -7
View File
@@ -1201,13 +1201,11 @@
)
)
)
(set! (-> self control unknown-float80)
(seek
(-> self control unknown-float80)
f0-2
(* (-> self control unknown-float82) (-> *display* seconds-per-frame))
)
)
(seek!
(-> self control unknown-float80)
f0-2
(* (-> self control unknown-float82) (-> *display* seconds-per-frame))
)
)
(vector-deg-slerp
(-> self control dynam gravity-normal)
+15 -28
View File
@@ -396,9 +396,7 @@
:code
(behavior ()
(while #t
(set! (-> self in-out-position)
(seekl (-> self in-out-position) 0 (the int (* 350.0 (-> *display* time-adjust-ratio))))
)
(seekl! (-> self in-out-position) 0 (the int (* 350.0 (-> *display* time-adjust-ratio))))
(if (zero? (-> self in-out-position))
(go hud-normal)
)
@@ -424,12 +422,8 @@
(= (-> *progress-process* 0 next-state name) 'progress-going-out)
(= (-> *progress-process* 0 next-state name) 'progress-gone)
)
(set! (-> self in-out-position)
(seekl (-> self in-out-position) 0 (the int (* 150.0 (-> *display* time-adjust-ratio))))
)
(set! (-> self in-out-position)
(seekl (-> self in-out-position) 4096 (the int (* 200.0 (-> *display* time-adjust-ratio))))
)
(seekl! (-> self in-out-position) 0 (the int (* 150.0 (-> *display* time-adjust-ratio))))
(seekl! (-> self in-out-position) 4096 (the int (* 200.0 (-> *display* time-adjust-ratio))))
)
(suspend)
)
@@ -442,9 +436,7 @@
:code
(behavior ()
(while #t
(set! (-> self in-out-position)
(seekl (-> self in-out-position) 4096 (the int (* 350.0 (-> *display* time-adjust-ratio))))
)
(seekl! (-> self in-out-position) 4096 (the int (* 350.0 (-> *display* time-adjust-ratio))))
(if (= (-> self in-out-position) 4096)
(deactivate self)
)
@@ -2567,13 +2559,11 @@
(fmin 1.0 (* arg0 (/ (-> self control unknown-float01) (-> self control unknown-surface01 target-speed))))
)
)
(set! (-> self control unknown-float130)
(seek
(-> self control unknown-float130)
(fmax (fmin (* (+ f0-1 arg2) (fmax 0.5 (+ 0.5 (vector-dot gp-0 v1-2)))) arg3) (- arg3))
(* arg1 (-> *display* seconds-per-frame))
)
)
(seek!
(-> self control unknown-float130)
(fmax (fmin (* (+ f0-1 arg2) (fmax 0.5 (+ 0.5 (vector-dot gp-0 v1-2)))) arg3) (- arg3))
(* arg1 (-> *display* seconds-per-frame))
)
)
(let ((a2-2 (vector-y-quaternion! (new 'stack-no-clear 'vector) (-> self control unknown-quaternion00))))
(forward-up-nopitch->quaternion (-> self control unknown-quaternion01) gp-0 a2-2)
@@ -2590,15 +2580,12 @@
)
(set! (-> self control unknown-float00) (fabs (-> self control unknown-float130)))
(if (= (-> self next-state name) 'target-swim-down)
(set! (-> self control unknown-float131)
(seek (-> self control unknown-float131) (the-as float -6144.0) (* 4096.0 (-> *display* seconds-per-frame)))
)
(set! (-> self control unknown-float131) (seek
(-> self control unknown-float131)
(the-as float (-> (new 'static 'array int32 1 0) 0))
(* 2048.0 (-> *display* seconds-per-frame))
)
)
(seek! (-> self control unknown-float131) (the-as float -6144.0) (* 4096.0 (-> *display* seconds-per-frame)))
(seek!
(-> self control unknown-float131)
(the-as float (-> (new 'static 'array int32 1 0) 0))
(* 2048.0 (-> *display* seconds-per-frame))
)
)
(let ((f0-20 (-> self control unknown-float131)))
(set! (-> self control unknown-vector11 y) f0-20)
+21 -30
View File
@@ -806,9 +806,7 @@
)
)
(until (ja-done? 0)
(set! (-> self control unknown-float81)
(seek (-> self control unknown-float81) (the-as float 0.0) (-> *display* seconds-per-frame))
)
(seek! (-> self control unknown-float81) (the-as float 0.0) (-> *display* seconds-per-frame))
(suspend)
(let ((a0-50 (-> self skel root-channel 0)))
(set! (-> a0-50 param 0) (the float (+ (-> a0-50 frame-group data 0 length) -1)))
@@ -2287,13 +2285,11 @@
)
(mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
(slide-down-test)
(set! (-> self control unknown-float122)
(seek
(-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
(-> *display* seconds-per-frame)
)
)
(seek!
(-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
(-> *display* seconds-per-frame)
)
(none)
)
:code
@@ -2486,13 +2482,11 @@
(if (!= (-> self state-time) (-> *display* base-frame-counter))
(mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
)
(set! (-> self control unknown-float122)
(seek
(-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
(-> *display* seconds-per-frame)
)
)
(seek!
(-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
(-> *display* seconds-per-frame)
)
(none)
)
:code
@@ -2620,13 +2614,11 @@
)
)
(mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
(set! (-> self control unknown-float122)
(seek
(-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.00012207031 (+ -2048.0 (-> self control unknown-float01)))))
(-> *display* seconds-per-frame)
)
)
(seek!
(-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.00012207031 (+ -2048.0 (-> self control unknown-float01)))))
(-> *display* seconds-per-frame)
)
(none)
)
:code
@@ -3434,12 +3426,11 @@
(go target-hit-ground #f)
)
(if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.5))
(set! (-> self control dynam gravity-length) (seek
(-> self control dynam gravity-length)
(-> self control unknown-dynamics00 gravity-length)
(* 245760.0 (-> *display* seconds-per-frame))
)
)
(seek!
(-> self control dynam gravity-length)
(-> self control unknown-dynamics00 gravity-length)
(* 245760.0 (-> *display* seconds-per-frame))
)
)
(when (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.05))
(< (vector-dot (-> self control dynam gravity-normal) (-> self control unknown-vector10))
+2 -4
View File
@@ -364,7 +364,7 @@
(behavior ()
(while #t
(if (not (paused?))
(set! (-> self offset) (seekl (-> self offset) 0 (the int (* 15.0 (-> *display* time-adjust-ratio)))))
(seekl! (-> self offset) 0 (the int (* 15.0 (-> *display* time-adjust-ratio))))
)
(dummy-17 self)
(if (<= (-> self offset) 0)
@@ -428,9 +428,7 @@
(behavior ((arg0 int))
(while #t
(if (not (paused?))
(set! (-> self offset)
(seekl (-> self offset) 128 (the int (* (the float arg0) (-> *display* time-adjust-ratio))))
)
(seekl! (-> self offset) 128 (the int (* (the float arg0) (-> *display* time-adjust-ratio))))
)
(dummy-17 self)
(when (movie?)
+1 -3
View File
@@ -1758,9 +1758,7 @@
(set! sv-464 6)
)
(if (-> obj language-transition)
(set! (-> obj language-x-offset)
(seekl (-> obj language-x-offset) 200 (the int (* 10.0 (-> *display* time-adjust-ratio))))
)
(seekl! (-> obj language-x-offset) 200 (the int (* 10.0 (-> *display* time-adjust-ratio))))
)
(when (>= (-> obj language-x-offset) 100)
(set! (-> obj language-selection) (the-as language-enum sv-448))
+32 -42
View File
@@ -2136,30 +2136,26 @@
(if (and (= (-> self display-state) (-> self next-display-state))
(= (-> self display-level-index) (-> self next-level-index))
)
(set! (-> self transition-offset)
(seekl
(-> self transition-offset)
0
(* (the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
(if (or (-> self stat-transition) (nonzero? (-> self level-transition)))
2
1
)
)
)
)
(set! (-> self transition-offset)
(seekl
(-> self transition-offset)
512
(* (the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
(if (or (-> self stat-transition) (nonzero? (-> self level-transition)))
2
1
)
)
)
)
(seekl!
(-> self transition-offset)
0
(* (the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
(if (or (-> self stat-transition) (nonzero? (-> self level-transition)))
2
1
)
)
)
(seekl!
(-> self transition-offset)
512
(* (the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
(if (or (-> self stat-transition) (nonzero? (-> self level-transition)))
2
1
)
)
)
)
(set-transition-progress! self (-> self transition-offset))
(set! (-> self in-transition) (or (-> self force-transition) (nonzero? (-> self transition-offset))))
@@ -2457,16 +2453,13 @@
:code
(behavior ()
(while #t
(set! (-> self in-out-position)
(seekl (-> self in-out-position) 0 (the int (* 170.0 (-> *display* time-adjust-ratio))))
)
(seekl! (-> self in-out-position) 0 (the int (* 170.0 (-> *display* time-adjust-ratio))))
(when (< (-> self in-out-position) 2867)
(set! (-> self transition-offset) (seekl
(-> self transition-offset)
0
(the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
)
)
(seekl!
(-> self transition-offset)
0
(the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
)
(set-transition-progress! self (-> self transition-offset))
)
(if (zero? (-> self in-out-position))
@@ -2498,17 +2491,14 @@
:code
(behavior ()
(while #t
(set! (-> self transition-offset) (seekl
(-> self transition-offset)
512
(the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
)
)
(seekl!
(-> self transition-offset)
512
(the int (* (-> self transition-speed) (-> *display* time-adjust-ratio)))
)
(set-transition-progress! self (-> self transition-offset))
(when (< 153 (-> self transition-offset))
(set! (-> self in-out-position)
(seekl (-> self in-out-position) 4096 (the int (* 170.0 (-> *display* time-adjust-ratio))))
)
(seekl! (-> self in-out-position) 4096 (the int (* 170.0 (-> *display* time-adjust-ratio))))
(if (= (-> self in-out-position) 4096)
(go progress-gone)
)