[decompiler] as-type and font method support (#3855)

Add support for `as-type` macro, and detecting inline font methods. This
works in all three games but I've only updated jak 3's goal_src for now.
Eventually I will go back and work through the others, but I want to get
more decompiler features in first.


![image](https://github.com/user-attachments/assets/5c31bf85-97b4-437c-bc4b-dc054e60551e)

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
This commit is contained in:
water111
2025-02-01 21:23:11 -05:00
committed by GitHub
parent d5590ab638
commit 48cb9bb787
645 changed files with 5391 additions and 16694 deletions
+8 -33
View File
@@ -224,12 +224,7 @@
(set! (-> this root root-prim local-sphere w) (* 2.5 (-> this root root-prim local-sphere w)))
)
(when (and arg2 (nonzero? (-> this draw)))
(let* ((s5-0 (-> arg2 process))
(v1-56 (if (type? s5-0 process-drawable)
s5-0
)
)
)
(let ((v1-56 (the-as process (as-type (-> arg2 process) process-drawable))))
(if v1-56
(set! (-> this draw light-index) (-> (the-as process-drawable v1-56) draw light-index))
)
@@ -543,11 +538,9 @@
(lambda ((arg0 part-tracker))
(let ((v1-1 (handle->process (-> arg0 userdata))))
(when (the-as process v1-1)
(let* ((s5-0 (handle->process (-> (the-as collectable v1-1) pickup-handle)))
(a0-9 (if (type? s5-0 process-focusable)
s5-0
)
)
(let* ((a0-9
(the-as process (as-type (handle->process (-> (the-as collectable v1-1) pickup-handle)) process-focusable))
)
(a2-0 (if (not a0-9)
(-> arg0 root trans)
(get-trans (the-as process-focusable a0-9) 3)
@@ -604,18 +597,9 @@
;; definition for function check-blue-suck
(defbehavior check-blue-suck eco ((arg0 process-drawable))
(let ((v1-0 (if (type? arg0 process-drawable)
arg0
)
)
)
(let ((v1-0 (as-type arg0 process-drawable)))
(when v1-0
(let* ((gp-1 (-> v1-0 root))
(v1-1 (if (type? gp-1 collide-shape)
gp-1
)
)
)
(let ((v1-1 (the-as trsqv (as-type (-> v1-0 root) collide-shape))))
(when v1-1
(let ((a0-5 (-> self root root-prim prim-core))
(a1-2 (-> (the-as collide-shape v1-1) root-prim prim-core))
@@ -633,18 +617,9 @@
;; definition for function add-blue-motion
(defbehavior add-blue-motion eco ((arg0 symbol) (arg1 symbol) (arg2 symbol) (arg3 symbol))
(let* ((gp-0 (handle->process (-> self target)))
(s2-0 (if (type? gp-0 process-drawable)
gp-0
)
)
)
(let ((s2-0 (the-as process (as-type (handle->process (-> self target)) process-drawable))))
(when s2-0
(let ((a0-6 (if (type? s2-0 process-focusable)
(the-as process-focusable s2-0)
)
)
)
(let ((a0-6 (as-type s2-0 process-focusable)))
(when a0-6
(let ((s2-1 (-> self root root-prim prim-core))
(gp-1 (get-trans a0-6 3))
+1 -5
View File
@@ -332,11 +332,7 @@
(.mov a0-10 vf3)
(let ((s4-0 (-> v1-23 process)))
(b! (< f0-2 a0-10) cfg-27)
(let ((a1-29 (if (type? s4-0 process-focusable)
(the-as process-focusable s4-0)
)
)
)
(let ((a1-29 (as-type s4-0 process-focusable)))
(if a1-29
(conveyor-method-26 this a1-29)
)
+2 -12
View File
@@ -810,19 +810,9 @@
:code (behavior ((arg0 handle))
(set! (-> self target) arg0)
(until #f
(let* ((gp-0 (handle->process (-> self target)))
(v1-3 (if (type? gp-0 process-drawable)
gp-0
)
)
)
(let ((v1-3 (the-as process (as-type (handle->process (-> self target)) process-drawable))))
(when v1-3
(let* ((gp-1 (-> (the-as process-drawable v1-3) root))
(v1-4 (if (type? (the-as collide-shape-moving gp-1) collide-shape)
gp-1
)
)
)
(let ((v1-4 (the-as trsqv (as-type (-> (the-as process-drawable v1-3) root) collide-shape))))
(when v1-4
(let* ((gp-2 (-> (the-as collide-shape-moving (-> self root)) root-prim prim-core))
(a1-3 (-> (the-as collide-shape-moving v1-4) root-prim prim-core))
+4 -24
View File
@@ -310,12 +310,7 @@
(set! (-> self move-pos 0) (-> self move-pos 1))
(cond
((not (logtest? (-> event param 0) 7))
(let ((gp-0 (the-as number (-> event param 0))))
(set! (-> self move-pos 1) (if (type? (the-as uint gp-0) float)
(the-as float gp-0)
)
)
)
(set! (-> self move-pos 1) (as-type (-> event param 0) float))
)
(else
(case (-> event param 0)
@@ -334,12 +329,7 @@
(('jump-to)
(cond
((not (logtest? (-> event param 0) 7))
(let ((gp-1 (the-as number (-> event param 0))))
(set! (-> self move-pos 1) (if (type? (the-as uint gp-1) float)
(the-as float gp-1)
)
)
)
(set! (-> self move-pos 1) (as-type (-> event param 0) float))
)
(else
(case (-> event param 0)
@@ -465,12 +455,7 @@
;; definition for method 44 of type elevator
;; WARN: Return type mismatch object vs symbol.
(defmethod elevator-method-44 ((this elevator))
(let* ((target-temp *target*)
(target (if (type? target-temp process-focusable)
target-temp
)
)
)
(let ((target (the-as target (as-type *target* process-focusable))))
(the-as
symbol
(and target (move-between-points this (get-trans target 0) (-> this move-pos 0) (-> this move-pos 1)))
@@ -877,12 +862,7 @@
)
(set! sv-32 (the-as float 0.0))
(set! sv-36 (-> this path))
(let ((s5-2 *target*))
(set! sv-40 (if (type? s5-2 process-focusable)
s5-2
)
)
)
(set! sv-40 (the-as target (as-type *target* process-focusable)))
(if (not (and sv-40
(logtest? (-> this params flags) (elevator-flags elevator-flags-4))
(find-closest-point-in-path! this (get-trans sv-40 0) (& sv-32) #f #t)
+22 -125
View File
@@ -63,12 +63,7 @@
)
)
(when arg1
(let* ((s5-1 (-> self root))
(a0-7 (if (type? s5-1 collide-shape)
(the-as collide-shape s5-1)
)
)
)
(let ((a0-7 (as-type (-> self root) collide-shape)))
(if a0-7
(move-to-point! a0-7 (-> (the-as process-drawable gp-0) root trans))
(set! (-> self root trans quad) (-> (the-as process-drawable gp-0) root trans quad))
@@ -83,12 +78,7 @@
(if (or (zero? (-> self skel active-channels)) (not (-> self skel root-channel 0 frame-group)))
(logior! (-> self draw status) (draw-control-status no-draw-temp))
)
(let* ((gp-1 self)
(v1-38 (if (type? gp-1 manipy)
gp-1
)
)
)
(let ((v1-38 (the-as process-drawable (as-type self manipy))))
(if (and v1-38 (not (-> (the-as manipy v1-38) draw?)))
(logior! (-> self draw status) (draw-control-status no-draw-temp))
)
@@ -216,12 +206,7 @@
:code (behavior ((arg0 handle))
(move-along-path self)
(suspend)
(while (let* ((s5-0 (handle->process arg0))
(a0-7 (if (type? s5-0 process-focusable)
s5-0
)
)
)
(while (let ((a0-7 (the-as process (as-type (handle->process arg0) process-focusable))))
(and a0-7 (focus-test? (the-as process-focusable a0-7) pole))
)
(move-along-path self)
@@ -1314,25 +1299,8 @@
;; definition for method 15 of type part-tracker
;; WARN: Return type mismatch object vs none.
(defmethod notify-parent-of-death ((this part-tracker))
(with-pp
(let ((gp-0 (new 'stack-no-clear 'event-message-block)))
(set! (-> gp-0 from) (process->ppointer pp))
(set! (-> gp-0 num-params) 1)
(set! (-> gp-0 message) 'notify)
(set! (-> gp-0 param 0) (the-as uint 'die))
(let ((s5-0 send-event-function)
(s4-0 (ppointer->process (-> this parent)))
)
(s5-0
(if (type? s4-0 process)
s4-0
)
gp-0
)
)
)
(none)
)
(send-event (the-as process-tree (as-type (ppointer->process (-> this parent)) process)) 'notify 'die)
(none)
)
;; failed to figure out what this is:
@@ -1353,12 +1321,7 @@
(if (-> self callback)
((-> self callback) self)
)
(let* ((gp-0 (handle->process (-> self target)))
(v1-8 (if (type? gp-0 process-drawable)
gp-0
)
)
)
(let ((v1-8 (the-as process (as-type (handle->process (-> self target)) process-drawable))))
(cond
((and v1-8
(nonzero? (-> (the-as process-drawable v1-8) root))
@@ -1381,12 +1344,7 @@
(if (-> self linger-callback)
((-> self linger-callback) self)
)
(let* ((s5-0 (handle->process (-> self target)))
(v1-30 (if (type? s5-0 process-drawable)
s5-0
)
)
)
(let ((v1-30 (the-as process (as-type (handle->process (-> self target)) process-drawable))))
(if (and v1-30
(nonzero? (-> (the-as process-drawable v1-30) root))
(nonzero? (-> (the-as process-drawable v1-30) node-list))
@@ -1536,25 +1494,8 @@
;; definition for method 15 of type lightning-tracker
;; WARN: Return type mismatch object vs none.
(defmethod notify-parent-of-death ((this lightning-tracker))
(with-pp
(let ((gp-0 (new 'stack-no-clear 'event-message-block)))
(set! (-> gp-0 from) (process->ppointer pp))
(set! (-> gp-0 num-params) 1)
(set! (-> gp-0 message) 'notify)
(set! (-> gp-0 param 0) (the-as uint 'die))
(let ((s5-0 send-event-function)
(s4-0 (ppointer->process (-> this parent)))
)
(s5-0
(if (type? s4-0 process)
s4-0
)
gp-0
)
)
)
(none)
)
(send-event (the-as process-tree (as-type (ppointer->process (-> this parent)) process)) 'notify 'die)
(none)
)
;; definition for method 16 of type lightning-tracker
@@ -1564,18 +1505,10 @@
(if (-> this callback)
((-> this callback) this)
)
(let ((a0-6 (cond
((>= (-> this target-joint0) 0)
(let ((s5-0 (handle->process (-> this target0))))
(if (type? s5-0 process-drawable)
s5-0
)
)
)
(else
(let ((a0-6 (if (>= (-> this target-joint0) 0)
(the-as process (as-type (handle->process (-> this target0)) process-drawable))
(the-as process #f)
)
)
)
)
(cond
@@ -1611,18 +1544,10 @@
)
)
)
(let ((a0-22 (cond
((>= (-> this target-joint1) 0)
(let ((s5-3 (handle->process (-> this target1))))
(if (type? s5-3 process-drawable)
s5-3
)
)
)
(else
(let ((a0-22 (if (>= (-> this target-joint1) 0)
(the-as process (as-type (handle->process (-> this target1)) process-drawable))
(the-as process #f)
)
)
)
)
(cond
@@ -1706,12 +1631,7 @@
(let ((s5-1 (new 'stack-no-clear 'vector)))
(set! (-> s5-1 quad) (-> self offset1 quad))
(when (and (>= (-> self target-joint1) 0) (< (-> self target-joint1) 256))
(let* ((s4-0 (handle->process (-> self target1)))
(v1-28 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((v1-28 (the-as process (as-type (handle->process (-> self target1)) process-drawable))))
(if (and v1-28 (nonzero? (-> (the-as process-drawable v1-28) root)))
(set! (-> s5-1 quad) (-> (vector<-cspace!
(new 'stack-no-clear 'vector)
@@ -1808,14 +1728,11 @@
(defbehavior lightning-tracker-init lightning-tracker ((arg0 lightning-spec) (arg1 time-frame) (arg2 symbol) (arg3 process-drawable) (arg4 vector) (arg5 vector))
(stack-size-set! (-> self main-thread) 128)
(set! (-> self target0) (process->handle arg3))
(let ((s1-1 (ppointer->process (-> self parent))))
(set! (-> self target1) (process->handle (the-as process (if (type? s1-1 process-drawable)
s1-1
)
)
)
(set! (-> self target1)
(process->handle
(the-as process (the-as process-tree (as-type (ppointer->process (-> self parent)) process-drawable)))
)
)
)
(cond
((>= 256 (the-as int arg4))
(set! (-> self target-joint0) (the-as int arg4))
@@ -1904,12 +1821,7 @@
;; definition for function process-release?
;; WARN: Return type mismatch object vs symbol.
(defbehavior process-release? process ((arg0 process))
(let* ((gp-0 (command-get-process arg0 *target*))
(a0-2 (if (type? gp-0 process-focusable)
(the-as process-focusable gp-0)
)
)
)
(let ((a0-2 (as-type (command-get-process arg0 *target*) process-focusable)))
(the-as symbol (if (and a0-2 (focus-test? a0-2 grabbed))
(send-event a0-2 'end-mode)
#t
@@ -2980,19 +2892,9 @@
:code (behavior ()
(set-time! (-> self state-time))
(while ((-> self run-function))
(let* ((gp-0 (handle->process (-> self target)))
(a0-4 (if (type? gp-0 process-drawable)
gp-0
)
)
)
(let ((a0-4 (the-as process (as-type (handle->process (-> self target)) process-drawable))))
(when a0-4
(let* ((gp-1 (-> (the-as process-drawable a0-4) root))
(a0-6 (if (type? gp-1 collide-shape)
gp-1
)
)
)
(let ((a0-6 (the-as trsqv (as-type (-> (the-as process-drawable a0-4) root) collide-shape))))
(if a0-6
(set! (-> self root trans quad) (-> (the-as collide-shape a0-6) root-prim prim-core world-sphere quad))
)
@@ -3163,12 +3065,7 @@
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touched)
(let* ((s4-0 proc)
(v1-1 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((v1-1 (the-as process (as-type proc process-drawable))))
(when v1-1
(let ((a0-3 (-> (the-as process-drawable v1-1) root))
(a1-2 (new 'stack-no-clear 'collide-query))
+2 -10
View File
@@ -277,12 +277,7 @@
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touch 'attack 'bonk)
(let* ((proc-temp proc)
(proc-focus (if (type? proc-temp process-focusable)
(the-as process-focusable proc-temp)
)
)
)
(let ((proc-focus (as-type proc process-focusable)))
(cond
((and proc-focus (focus-test? proc-focus edge-grab))
(set! (-> self safe-time) (+ (current-time) (seconds 0.2)))
@@ -293,10 +288,7 @@
)
)
(set! (-> self hit-point quad) (-> self root trans quad))
(set! proc-focus (if (type? proc process-focusable)
(the-as process-focusable proc)
)
)
(set! proc-focus (as-type proc process-focusable))
(set! (-> self hit-point quad) (-> (get-trans proc-focus 0) quad))
)
(if (zero? (-> self bounce-time))
+2 -12
View File
@@ -340,12 +340,7 @@
(('ridden)
(let ((v1-7 (the-as object (-> arg3 param 0))))
(when (the-as uint v1-7)
(let* ((s5-1 (handle->process (-> (the-as collide-rider v1-7) rider-handle)))
(v1-11 (if (type? s5-1 process-focusable)
(the-as process-focusable s5-1)
)
)
)
(let ((v1-11 (as-type (handle->process (-> (the-as collide-rider v1-7) rider-handle)) process-focusable)))
(when (and v1-11
(logtest? (-> v1-11 mask) (process-mask target))
(not (logtest? (-> v1-11 focus-status) (focus-status on-water under-water)))
@@ -376,12 +371,7 @@
(the-as time-frame (-> this info player-force-timeout))
)
(set! (-> this player-bonk-timeout) (the-as uint (current-time)))
(let* ((s4-0 arg0)
(v1-31 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((v1-31 (as-type arg0 process-drawable)))
(when v1-31
(logior! (-> this flags) (rigid-body-object-flag player-impulse-force))
(set! (-> this player-force-position quad) (-> v1-31 root trans quad))
+3 -16
View File
@@ -260,12 +260,7 @@
)
:enter (behavior ()
(set! (-> self start-time) (-> *display* game-clock frame-counter))
(let* ((gp-0 (ppointer->process (-> self parent 0 parent)))
(a1-1 (if (type? gp-0 process-focusable)
gp-0
)
)
)
(let ((a1-1 (the-as process-tree (as-type (ppointer->process (-> self parent 0 parent)) process-focusable))))
(if a1-1
(try-update-focus (-> self focus) (the-as process-focusable a1-1))
)
@@ -280,12 +275,7 @@
)
)
:code (behavior ()
(let* ((gp-0 (ppointer->process (-> self parent 0 parent)))
(a0-1 (if (type? gp-0 process-focusable)
(the-as process-focusable gp-0)
)
)
)
(let ((a0-1 (as-type (ppointer->process (-> self parent 0 parent)) process-focusable)))
(if (and a0-1 (focus-test? a0-1 pilot))
(send-event
(ppointer->process (-> self parent))
@@ -522,10 +512,7 @@
)
(('touch 'attack)
(let ((s4-0 (process-spawn camera-remote :init cam-slave-init cam-remote #f :from *camera-dead-pool* :to proc))
(s5-2 (if (type? proc process-focusable)
(the-as process-focusable proc)
)
)
(s5-2 (as-type proc process-focusable))
)
(when (and s4-0 (begin (send-event s5-2 'change-mode 'board #f) (focus-test? s5-2 board)))
(change-parent self (ppointer->process s4-0))
+3 -7
View File
@@ -395,13 +395,9 @@
v0-1
)
(('water)
(let* ((s5-0 (the-as object (-> arg3 param 0)))
(s4-0 (the-as object (-> arg3 param 1)))
(gp-0 (if (type? (the-as process s4-0) process-focusable)
(the-as uint s4-0)
)
)
)
(let ((s5-0 (the-as object (-> arg3 param 0)))
(gp-0 (the-as object (as-type (-> arg3 param 1) process-focusable)))
)
(when (and (logtest? (-> self flags) (water-flags deadly))
(logtest? (water-flags touch-water) (-> (the-as water-info s5-0) flags))
(the-as uint gp-0)
+1 -5
View File
@@ -334,11 +334,7 @@
(.mov a0-10 vf3)
(let ((s4-0 (-> v1-23 process)))
(b! (< f0-2 a0-10) cfg-27)
(let ((a1-29 (if (type? s4-0 process-focusable)
s4-0
)
)
)
(let ((a1-29 (the-as process-drawable (as-type s4-0 process-focusable))))
(if a1-29
(push-process this (the-as process-focusable a1-29))
)
+12 -21
View File
@@ -933,11 +933,7 @@
)
)
)
(let* ((s3-2 (-> this process control))
(v1-236 (if (type? s3-2 control-info)
s3-2
)
)
(let* ((v1-236 (as-type (-> this process control) control-info))
(v1-237 (and v1-236 (not (time-elapsed? (-> v1-236 last-time-on-surface) (seconds 0.5)))))
)
(if (and (logtest? (-> this flags) (water-flags swim-ground))
@@ -1456,16 +1452,16 @@
)
)
(('water-anim)
(let* ((s0-0 (command-get-process
(-> (the-as pair (-> (the-as pair (-> (the-as pair s2-0) cdr)) cdr)) car)
(the-as process #f)
)
)
(s1-0 (if (type? s0-0 process-drawable)
s0-0
)
)
)
(let ((s1-0 (the-as process (as-type
(command-get-process
(-> (the-as pair (-> (the-as pair (-> (the-as pair s2-0) cdr)) cdr)) car)
(the-as process #f)
)
process-drawable
)
)
)
)
(cond
(s1-0
(set! (-> arg0 flags) (water-flags active use-water-anim))
@@ -1506,12 +1502,7 @@
(logior! (-> arg0 flags) (water-flags lava))
)
((= v1-39 'mech)
(let* ((s1-1 (-> arg2 process))
(a0-39 (if (type? s1-1 process-focusable)
s1-1
)
)
)
(let ((a0-39 (the-as process-drawable (as-type (-> arg2 process) process-focusable))))
(when (and a0-39 (not (logtest? (focus-status mech) (-> (the-as process-focusable a0-39) focus-status))))
(set! (-> arg0 flags) (water-flags))
0