[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
+1 -3
View File
@@ -622,9 +622,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
@@ -695,14 +695,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))
)
)
)
+2 -2
View File
@@ -87,8 +87,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
@@ -1040,7 +1040,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
@@ -2962,7 +2962,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
@@ -1165,13 +1165,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)
+21 -30
View File
@@ -816,9 +816,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
@@ -2484,13 +2480,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
@@ -2617,13 +2611,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
@@ -3424,12 +3416,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))
+16 -29
View File
@@ -379,9 +379,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)
)
@@ -406,12 +404,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)
)
@@ -423,9 +417,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)
)
@@ -2522,13 +2514,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)
@@ -2545,15 +2535,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)
@@ -3518,7 +3505,7 @@
)
arg2
arg3
(-> (new 'static 'array float 1 143360.0) 0)
143360.0
)
(-> s3-1 ppointer)
)
+2 -4
View File
@@ -354,7 +354,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)
@@ -416,9 +416,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 -2
View File
@@ -1594,8 +1594,7 @@
))
)
(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) new-lang)
(set! old-lang new-lang)
+33 -49
View File
@@ -27,14 +27,8 @@
:flag-assert #x900000048
)
(define *progress-state*
(new 'static 'progress-global-state
:yes-no-choice #f
:which -1
:last-slot-saved -1
)
)
(define *progress-state* (new 'static 'progress-global-state :yes-no-choice #f :which -1 :last-slot-saved -1))
(defun get-game-count ((arg0 int))
(-> *game-counts* data arg0)
@@ -1914,30 +1908,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))))
@@ -2233,16 +2223,13 @@
:code
(behavior ()
(loop
(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))
@@ -2273,17 +2260,14 @@
:code
(behavior ()
(loop
(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)
)