[decompiler] process initialization macros (#807)

* implementation and a few working cases

* fix self issue

* fix run-function-in-process

* fix up set-to-run
This commit is contained in:
water111
2021-09-01 16:59:26 -04:00
committed by GitHub
parent 35e4b9907f
commit 9b0480c50d
35 changed files with 285 additions and 317 deletions
+20
View File
@@ -493,4 +493,24 @@
*res-static-buf*
)
)
)
;; run the given function in a process right now.
;; will return to here when:
;; - you return
;; - you deactivate
;; - you go
;; - you throw to 'initialize
(defmacro run-now-in-process (proc func &rest args)
`((the (function _varargs_ object) run-function-in-process)
,proc ,func ,@args
)
)
;; sets the main thread of the given process to run the given thing.
;; this resets the main thread stack back to the top
(defmacro run-next-time-in-process (proc func &rest args)
`((the (function _varargs_ object) set-to-run)
(-> ,proc main-thread) ,func ,@args
)
)
+7 -15
View File
@@ -28,10 +28,7 @@
(the-as pointer #x70004000)
)
)
((the-as (function process object function) run-function-in-process)
s5-0
cam-combiner-init
)
(run-now-in-process s5-0 cam-combiner-init)
(-> s5-0 ppointer)
)
)
@@ -58,17 +55,8 @@
)
)
)
((the-as
(function process object function)
set-to-run
)
(the-as
process
(->
s5-1
main-thread
)
)
(run-next-time-in-process
s5-1
cam-master-init
)
(-> s5-1 ppointer)
@@ -86,3 +74,7 @@
;; failed to figure out what this is:
(cam-start #f)
+40 -26
View File
@@ -939,10 +939,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function process function vector meters int none)
run-function-in-process
)
(run-now-in-process
s3-5
touch-tracker-init
(-> s5-1 root trans)
@@ -1033,28 +1030,45 @@
(let ((t9-35 (method-of-type process activate)))
(t9-35 s4-4 s5-1 'process (the-as pointer #x70004000))
)
((the-as
(function cpu-thread function process-drawable none)
set-to-run
)
(-> s4-4 main-thread)
(lambda ((arg0 process-drawable))
(with-pp
(let ((s5-0 (-> *display* base-frame-counter)))
(until (>= (- (-> *display* base-frame-counter) s5-0) 180)
(let ((a1-0 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-0 from) pp)
(set! (-> a1-0 num-params) 1)
(set! (-> a1-0 message) 'effect)
(set! (-> a1-0 param 0) (the-as uint 'eco-blue))
(send-event-function arg0 a1-0)
)
(suspend)
)
)
(none)
)
)
(run-next-time-in-process s4-4 (lambda ((arg0 process-drawable))
(with-pp
(let
((s5-0
(-> *display* base-frame-counter)
)
)
(until
(>=
(-
(->
*display*
base-frame-counter
)
s5-0
)
180
)
(let
((a1-0
(new 'stack-no-clear 'event-message-block
)
)
)
(set! (-> a1-0 from) pp)
(set! (-> a1-0 num-params) 1)
(set! (-> a1-0 message) 'effect)
(set!
(-> a1-0 param 0)
(the-as uint 'eco-blue)
)
(send-event-function arg0 a1-0)
)
(suspend)
)
)
(none)
)
)
s5-1
)
(-> s4-4 ppointer)
+6 -6
View File
@@ -3,11 +3,11 @@
;; definition of type ripple-merc-query
(deftype ripple-merc-query (inline-array-class)
((start-vertex int32 :offset-assert 16)
(vertex-skip int32 :offset-assert 20)
(vertex-count int32 :offset-assert 24)
(current-loc int32 :offset-assert 28)
(data2 uint8 :dynamic :offset-assert 32)
((start-vertex int32 :offset-assert 16)
(vertex-skip int32 :offset-assert 20)
(vertex-count int32 :offset-assert 24)
(current-loc int32 :offset-assert 28)
(data vector :inline :dynamic :offset-assert 32)
)
:method-count-assert 9
:size-assert #x20
@@ -23,7 +23,7 @@
(format #t "~Tvertex-skip: ~D~%" (-> obj vertex-skip))
(format #t "~Tvertex-count: ~D~%" (-> obj vertex-count))
(format #t "~Tcurrent-loc: ~D~%" (-> obj current-loc))
(format #t "~Tdata[0] @ #x~X~%" (-> obj data2))
(format #t "~Tdata[0] @ #x~X~%" (-> obj data))
obj
)
+2 -12
View File
@@ -2929,10 +2929,7 @@
)
)
)
((the-as
(function process function object)
run-function-in-process
)
(run-now-in-process
s5-1
init-sidekick
)
@@ -2981,14 +2978,7 @@
(&-> *dram-stack* 14336)
)
)
((the-as
(function process function symbol object)
run-function-in-process
)
s5-0
init-target
(the-as symbol arg1)
)
(run-now-in-process s5-0 init-target arg1)
(-> s5-0 ppointer)
)
)
+7 -23
View File
@@ -1321,26 +1321,13 @@
(the-as pointer #x70004000)
)
)
(let
((t9-6
(the-as function run-function-in-process)
)
(a0-9 gp-1)
(a1-4 othercam-init-by-other)
(a3-2 7)
(t0-1 #f)
)
(run-now-in-process
gp-1
othercam-init-by-other
self
7
#f
#t
((the-as
(function object object object object object object)
t9-6
)
a0-9
a1-4
self
a3-2
t0-1
)
)
(-> gp-1 ppointer)
)
@@ -1357,10 +1344,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function object object object object object)
run-function-in-process
)
(run-now-in-process
s5-0
fuel-cell-init-as-clone
(process->handle self)
@@ -91,10 +91,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s5-1
manipy-init
(-> obj root trans)
@@ -138,10 +135,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s5-2
manipy-init
(-> obj root trans)
+2 -8
View File
@@ -124,10 +124,7 @@
)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s5-0
manipy-init
(->
@@ -307,10 +304,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s5-1
manipy-init
(-> obj root trans)
@@ -1190,7 +1190,7 @@
(the-as pointer #x70004000)
)
)
(run-function-in-process
(run-now-in-process
s4-1
part-tracker-init
(-> *part-group-id-table* 445)
@@ -1198,7 +1198,7 @@
#f
#f
#f
(+ (+ (* s3-0 16) 28) (the-as int s5-0))
(-> s5-0 data s3-0)
)
(-> s4-1 ppointer)
)
@@ -88,10 +88,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function object object object object)
run-function-in-process
)
(run-now-in-process
gp-0
camera-tracker-init
(lambda :behavior camera-tracker
+1 -8
View File
@@ -647,10 +647,7 @@
(the-as pointer #x70004000)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s5-2
manipy-init
(-> obj root trans)
@@ -1398,7 +1395,3 @@
(dummy-42 obj)
(none)
)
@@ -95,7 +95,7 @@
(the-as pointer #x70004000)
)
)
(run-function-in-process
(run-now-in-process
gp-0
pov-camera-init-by-other
(-> self spawn-pos)
@@ -128,7 +128,7 @@
(the-as pointer #x70004000)
)
)
(run-function-in-process
(run-now-in-process
gp-1
pov-camera-init-by-other
(-> self spawn-pos)
@@ -185,7 +185,7 @@
(the-as pointer #x70004000)
)
)
(run-function-in-process
(run-now-in-process
gp-0
pov-camera-init-by-other
(-> self spawn-pos)
@@ -703,10 +703,7 @@
)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s3-0
manipy-init
s4-0
@@ -777,10 +774,7 @@
)
)
)
((the-as
(function process function object object object object object)
run-function-in-process
)
(run-now-in-process
s3-1
manipy-init
s4-0