[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
+1 -6
View File
@@ -2571,12 +2571,7 @@
(set! (-> self control unknown-vector39 quad) (-> self control quat quad))
(ja :group! s4-0 :num! (seek!) :frame-num 0.0)
(until #f
(let* ((s3-0 (handle->process arg0))
(s4-1 (if (type? s3-0 process-focusable)
s3-0
)
)
)
(let ((s4-1 (the-as process (as-type (handle->process arg0) process-focusable))))
(when s4-1
(set! (-> self control unknown-vector38 quad) (-> (get-trans (the-as process-focusable s4-1) 0) quad))
(+! (-> self control unknown-vector38 y) 4096.0)
+2 -12
View File
@@ -363,12 +363,7 @@
(let ((s5-0 (new 'stack-no-clear 'matrix)))
(let ((s4-0 (new 'stack-no-clear 'vector)))
(vector-normalize-copy! s4-0 (-> self core-velocity) 1.0)
(let* ((s3-0 (handle->process (-> self track-target)))
(v1-3 (if (type? s3-0 process-drawable)
(the-as process-drawable s3-0)
)
)
)
(let ((v1-3 (as-type (handle->process (-> self track-target)) process-drawable)))
(when v1-3
(let* ((s3-2 (vector-! (new 'stack-no-clear 'vector) (-> v1-3 root trans) (-> self core-position)))
(f0-0 (vector-normalize-ret-len! s3-2 1.0))
@@ -768,12 +763,7 @@
)
)
(countdown (s5-3 gp-2)
(let* ((s3-1 (handle->process (-> self result-array s5-3)))
(s4-1 (if (type? s3-1 process-focusable)
s3-1
)
)
)
(let ((s4-1 (the-as process (as-type (handle->process (-> self result-array s5-3)) process-focusable))))
(when s4-1
(send-event s4-1 'attack #f (static-attack-info ((id (new-attack-id)) (mode 'explode) (damage 16.0))))
(process-spawn-function
+4 -13
View File
@@ -147,12 +147,7 @@
;; definition for method 29 of type gun-red-shot
;; INFO: Used lq/sq
(defmethod fire! ((this gun-red-shot) (arg0 process-drawable) (arg1 int))
(let* ((s5-0 arg0)
(v1-0 (if (type? s5-0 process-drawable)
s5-0
)
)
)
(let ((v1-0 (as-type arg0 process-drawable)))
(when v1-0
(let* ((s5-2 (vector-! (new 'stack-no-clear 'vector) (-> v1-0 root trans) (-> this start-pos)))
(f30-0 (* (if (< (vector-length s5-2) 24576.0)
@@ -210,13 +205,9 @@
"Create all 19 probe vectors"
(let ((s5-0 (-> this probe-count)))
(when (< s5-0 19)
(let* ((s4-0 (-> arg0 process))
(a0-2 (if (type? s4-0 process-focusable)
(the-as process-focusable s4-0)
)
)
(s4-1 (new 'stack-no-clear 'vector))
)
(let ((a0-2 (as-type (-> arg0 process) process-focusable))
(s4-1 (new 'stack-no-clear 'vector))
)
(if a0-2
(set! (-> s4-1 quad) (-> (get-trans a0-2 3) quad))
(set! (-> s4-1 quad) (-> arg0 root-prim prim-core world-sphere quad))
+4 -8
View File
@@ -991,14 +991,10 @@
((>= f0-3 0.0)
(vector+float*! (-> s4-0 start-pos) (-> s4-0 start-pos) (-> s4-0 move-dist) f0-3)
(vector+float*! (-> s4-0 start-pos) (-> s4-0 start-pos) (-> s3-0 0) (-> this track-beam-size))
(let* ((s2-0 (-> s4-0 best-other-tri collide-ptr))
(s0-0 (if (type? s2-0 collide-shape-prim)
(the-as collide-shape-prim s2-0)
)
)
(s1-0 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) s5-0 (-> s4-0 start-pos)) 1638.4))
(s2-1 (new 'stack-no-clear 'vector))
)
(let ((s0-0 (as-type (-> s4-0 best-other-tri collide-ptr) collide-shape-prim))
(s1-0 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) s5-0 (-> s4-0 start-pos)) 1638.4))
(s2-1 (new 'stack-no-clear 'vector))
)
(set! (-> s2-1 quad) (-> s4-0 start-pos quad))
(cond
((and s0-0
+4 -24
View File
@@ -111,12 +111,7 @@
(set! (-> gp-0 max-distance) 8192.0)
(set! (-> gp-0 local-point quad) (-> arg2 quad))
(set! (-> gp-0 local-normal quad) (-> arg3 quad))
(let* ((s5-1 (-> arg0 root))
(v1-7 (if (type? s5-1 collide-shape)
(the-as collide-shape s5-1)
)
)
)
(let ((v1-7 (as-type (-> arg0 root) collide-shape)))
(when v1-7
(set! (-> gp-0 backup-radius) (-> v1-7 root-prim local-sphere w))
(set! (-> gp-0 carry-radius) (-> v1-7 root-prim local-sphere w))
@@ -238,12 +233,7 @@
(set! (-> this pickup-time) (-> this process 0 clock frame-counter))
(set! (-> arg0 pickup-time) (-> arg0 process 0 clock frame-counter))
(set! (-> arg0 grab-trans-blend) 1.0)
(let* ((s4-0 (the-as collide-shape (-> arg0 process 0 control)))
(v1-17 (if (type? (the-as control-info s4-0) collide-shape)
s4-0
)
)
)
(let ((v1-17 (as-type (-> arg0 process 0 control) collide-shape)))
(if v1-17
(set! (-> v1-17 root-prim local-sphere w) (-> arg0 carry-radius))
)
@@ -320,12 +310,7 @@
(set! (-> a1-2 y) 0.0)
(set-heading-vec-clear-roll-pitch! (-> arg0 process 0 control) a1-2)
)
(let* ((s4-0 (the-as collide-shape (-> arg0 process 0 control)))
(v1-9 (if (type? (the-as control-info s4-0) collide-shape)
s4-0
)
)
)
(let ((v1-9 (as-type (-> arg0 process 0 control) collide-shape)))
(if v1-9
(set! (-> v1-9 root-prim local-sphere w) (-> arg0 backup-radius))
)
@@ -453,12 +438,7 @@
(set! (-> this pickup-time) (-> this process 0 clock frame-counter))
(set! (-> arg0 pickup-time) (-> arg0 process 0 clock frame-counter))
(set! (-> arg0 grab-trans-blend) 1.0)
(let* ((s2-0 (the-as collide-shape (-> arg0 process 0 control)))
(v1-17 (if (type? (the-as control-info s2-0) collide-shape)
s2-0
)
)
)
(let ((v1-17 (as-type (-> arg0 process 0 control) collide-shape)))
(if v1-17
(set! (-> v1-17 root-prim local-sphere w) (-> arg0 carry-radius))
)
+10 -19
View File
@@ -458,19 +458,15 @@
(when (-> self control danger-mode)
(-> block param 1)
(let* ((gp-1 (the-as object (-> block param 3)))
(s5-1 (-> (the-as collide-query gp-1) best-other-tri collide-ptr))
(s4-1 (if (type? s5-1 collide-shape-prim)
(the-as collide-shape-prim s5-1)
)
)
(s3-1 (if s4-1
(-> s4-1 cshape process)
(the-as process-drawable #f)
)
)
(s5-2 (if (type? s3-1 process-focusable)
s3-1
)
(s4-1 (as-type (-> (the-as collide-query gp-1) best-other-tri collide-ptr) collide-shape-prim))
(s5-2 (the-as process-drawable (as-type
(if s4-1
(-> s4-1 cshape process)
(the-as process-drawable #f)
)
process-focusable
)
)
)
)
(if (and s4-1
@@ -2480,12 +2476,7 @@
(set! (-> self control unknown-vector38 quad) (-> self control trans quad))
(set! (-> self control unknown-vector39 quad) (-> self control quat quad))
(set! (-> self control unknown-vector40 quad) (-> self control quat quad))
(let* ((gp-1 (handle->process arg0))
(v1-23 (if (type? gp-1 process-drawable)
gp-1
)
)
)
(let ((v1-23 (the-as process (as-type (handle->process arg0) process-drawable))))
(when v1-23
(set! (-> self control unknown-vector38 quad) (-> (the-as process-drawable v1-23) root trans quad))
(set! (-> self control unknown-vector40 quad) (-> (the-as process-drawable v1-23) root quat quad))
+3 -9
View File
@@ -163,15 +163,9 @@
(new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning))
)
)
(let ((v1-31 gp-0))
(set! (-> v1-31 width) (the float 340))
)
(let ((v1-32 gp-0))
(set! (-> v1-32 height) (the float 80))
)
(let ((v1-33 gp-0))
(set! (-> v1-33 scale) 0.9)
)
(set-width! gp-0 340)
(set-height! gp-0 80)
(set-scale! gp-0 0.9)
(set! (-> gp-0 flags) (font-flags shadow kerning large))
(print-game-text
(lookup-text! *common-text* (text-id press-triangle-to-use) #f)
+7 -12
View File
@@ -745,12 +745,12 @@
)
(send-event (handle->process (-> self control unknown-combo-tracker00 target)) 'combo)
)
(let* ((s5-0 (handle->process (-> self control unknown-combo-tracker00 target)))
(gp-0 (if (type? s5-0 process-focusable)
s5-0
)
)
)
(let ((gp-0 (the-as
process
(as-type (handle->process (-> self control unknown-combo-tracker00 target)) process-focusable)
)
)
)
(let ((s5-1 (get-trans (the-as process-focusable gp-0) 3)))
(when (and (< 2048.0 (vector-vector-distance (-> self control trans) s5-1))
(or (and (= gp-0 (handle->process sv-56)) (not (time-elapsed? (the-as time-frame sv-64) (seconds 0.1))))
@@ -1742,12 +1742,7 @@
(set! sv-40 (fill-actor-list-for-sphere *actor-hash* sv-56 (-> sv-32 data) (-> sv-32 allocated-length)))
(set! (-> sv-32 length) sv-40)
(countdown (s5-0 sv-40)
(let* ((s4-0 (-> sv-32 s5-0 process))
(v1-53 (if (type? s4-0 process-focusable)
s4-0
)
)
)
(let ((v1-53 (the-as process-drawable (as-type (-> sv-32 s5-0 process) process-focusable))))
(when (and v1-53 (logtest? (process-mask enemy guard vehicle) (-> v1-53 mask)))
(set! (-> sv-60 sv-48) (process->handle v1-53))
(set! sv-48 (+ sv-48 1))
+3 -7
View File
@@ -1602,13 +1602,9 @@
cfg-132
:delay (nop!)
)
(let ((s5-0 (handle->process (-> self attack-info attacker))))
(when (if (type? s5-0 water-vol)
s5-0
)
(logior! (-> self state-flags) (state-flags sf14))
(set! (-> self alt-cam-pos y) (+ 4096.0 (-> self water height)))
)
(when (the-as process (as-type (handle->process (-> self attack-info attacker)) water-vol))
(logior! (-> self state-flags) (state-flags sf14))
(set! (-> self alt-cam-pos y) (+ 4096.0 (-> self water height)))
)
(set! (-> self control mod-surface) *neutral-mods*)
(let ((v1-63 arg0))
+1 -5
View File
@@ -254,11 +254,7 @@
(sv-704 matrix)
)
(set! sv-224 arg5)
(let* ((s3-0 arg0)
(s4-0 (if (type? s3-0 process-focusable)
s3-0
)
)
(let* ((s4-0 (the-as process (as-type arg0 process-focusable)))
(s3-1 (and s4-0 (focus-test? (the-as process-focusable s4-0) dead hit)))
)
(set! sv-96
+6 -15
View File
@@ -1111,12 +1111,7 @@
(go-virtual slide-control-watch)
)
(('update)
(let* ((s4-0 proc)
(gp-0 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((gp-0 (the-as process (as-type proc process-drawable))))
(if gp-0
(find-target-point (-> (the-as process-drawable gp-0) root trans))
)
@@ -1142,15 +1137,11 @@
(process-entity-status! self (entity-perm-status no-kill) #f)
)
:trans (behavior ()
(let ((gp-0 (handle->process (-> self target))))
(cond
((if (type? gp-0 process-drawable)
gp-0
)
)
(else
(go-virtual slide-control-watch)
)
(cond
((the-as process (as-type (handle->process (-> self target)) process-drawable))
)
(else
(go-virtual slide-control-watch)
)
)
)
+1 -6
View File
@@ -214,12 +214,7 @@
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touched)
(let* ((toucher-proc proc)
(toucher (if (type? toucher-proc process-drawable)
(the-as process-drawable toucher-proc)
)
)
)
(let ((toucher (as-type proc process-drawable)))
(when toucher
(-> toucher root)
(send-event
+12 -44
View File
@@ -1112,15 +1112,9 @@
(new 'stack 'font-context *font-default-matrix* 32 320 0.0 (font-color default) (font-flags shadow kerning))
)
)
(let ((v1-21 gp-1))
(set! (-> v1-21 width) (the float 340))
)
(let ((v1-22 gp-1))
(set! (-> v1-22 height) (the float 80))
)
(let ((v1-23 gp-1))
(set! (-> v1-23 scale) 0.9)
)
(set-width! gp-1 340)
(set-height! gp-1 80)
(set-scale! gp-1 0.9)
(set! (-> gp-1 flags) (font-flags shadow kerning large))
(print-game-text
(lookup-text! *common-text* (text-id press-triangle-to-use) #f)
@@ -1259,14 +1253,10 @@
#f
)
(('touch 'attack)
(let* ((gp-0 (-> block param 0))
(s5-0 (the-as object (-> block param 1)))
(s4-0 proc)
(v1-21 (if (type? s4-0 projectile)
s4-0
)
)
)
(let ((gp-0 (-> block param 0))
(s5-0 (the-as object (-> block param 1)))
(v1-21 (the-as object (as-type proc projectile)))
)
(when (and gp-0 v1-21)
(case (-> (the-as attack-info s5-0) mode)
(('wasp-shot 'guard-shot)
@@ -1755,19 +1745,9 @@
(set! (-> a1-0 quad) (-> a0-1 quad))
(set! (-> a1-0 w) 409600.0)
(countdown (s3-0 (fill-actor-list-for-sphere *actor-hash* (the-as sphere a1-0) s5-0 32))
(let* ((s2-0 (-> s5-0 s3-0))
(a0-5 (if (type? s2-0 collide-shape)
s2-0
)
)
)
(let ((a0-5 (as-type (-> s5-0 s3-0) collide-shape)))
(when a0-5
(let* ((s1-0 (-> a0-5 process))
(s2-1 (if (type? s1-0 process-focusable)
s1-0
)
)
)
(let ((s2-1 (the-as process-drawable (as-type (-> a0-5 process) process-focusable))))
(when (and s2-1
(logtest? (process-mask enemy) (-> s2-1 mask))
(logtest? (process-mask collectable) (-> s2-1 mask))
@@ -2342,9 +2322,7 @@
(the-as attack-info gp-0)
(-> block param 1)
self
(if (type? proc process-drawable)
proc
)
(the-as process (as-type proc process-drawable))
(the-as touching-shapes-entry (-> block param 0))
)
(case (-> (the-as attack-info gp-0) mode)
@@ -2497,12 +2475,7 @@
(set! (-> self control unknown-vector38 quad) (-> self control trans quad))
(set! (-> self control unknown-vector39 quad) (-> self control quat quad))
(set! (-> self control unknown-vector40 quad) (-> self control quat quad))
(let* ((s4-0 (handle->process arg0))
(s5-0 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((s5-0 (the-as process (as-type (handle->process arg0) process-drawable))))
(when s5-0
(vector-matrix*!
(-> self control unknown-vector38)
@@ -2517,12 +2490,7 @@
(until (ja-done? 0)
(let ((f30-0 (sin (lerp-scale 0.0 16384.0 (ja-aframe-num 0) 0.0 12.0))))
(let ((f28-0 (lerp-scale 0.0 1.0 (ja-aframe-num 0) 0.0 12.0)))
(let* ((s5-3 (handle->process arg0))
(a0-39 (if (type? s5-3 process-drawable)
s5-3
)
)
)
(let ((a0-39 (the-as process (as-type (handle->process arg0) process-drawable))))
(if a0-39
(set! (-> self alt-cam-pos quad) (-> (the-as process-focusable a0-39) root trans quad))
)
+4 -22
View File
@@ -1657,16 +1657,8 @@
(vf2 :class vf)
)
(init-vf0-vector)
(let ((s5-0 (if (type? arg1 process-drawable)
arg1
)
)
)
(let ((v1-0 (if (type? arg2 process-drawable)
arg2
)
)
)
(let ((s5-0 (as-type arg1 process-drawable)))
(let ((v1-0 (as-type arg2 process-drawable)))
(cond
((logtest? (attack-mask attacker-velocity) (-> this mask))
(set! (-> arg0 attacker-velocity quad) (-> this attacker-velocity quad))
@@ -1809,12 +1801,7 @@
)
(cond
((not (logtest? s4-0 (attack-mask vector)))
(let* ((s2-0 (handle->process (-> this attacker)))
(v1-65 (if (type? s2-0 process-drawable)
s2-0
)
)
)
(let ((v1-65 (the-as process (as-type (handle->process (-> this attacker)) process-drawable))))
(when (and v1-65 (nonzero? (-> (the-as process-drawable v1-65) root)))
(set! (-> this trans quad) (-> (the-as process-drawable v1-65) root trans quad))
(vector-! (-> this vector) (-> arg1 root trans) (-> (the-as process-drawable v1-65) root trans))
@@ -1823,12 +1810,7 @@
)
)
(else
(let* ((s3-1 (handle->process (-> this attacker)))
(v1-72 (if (type? s3-1 process-drawable)
s3-1
)
)
)
(let ((v1-72 (the-as process (as-type (handle->process (-> this attacker)) process-drawable))))
(if (and v1-72 (nonzero? (-> (the-as process-drawable v1-72) root)))
(set! (-> this trans quad) (-> (the-as process-drawable v1-72) root trans quad))
)
+2 -11
View File
@@ -2241,18 +2241,9 @@
(set-time! (-> self control sliding-start-time))
(set-time! (-> self gun combo-window-start))
(set! (-> self gun combo-window-state) (-> self state name))
(let ((v1-13 (if (type? proc process-focusable)
proc
)
)
)
(let ((v1-13 (the-as process (as-type proc process-focusable))))
(when v1-13
(let* ((s5-1 (-> (the-as target v1-13) control))
(v1-14 (if (type? s5-1 collide-shape)
s5-1
)
)
)
(let ((v1-14 (the-as control-info (as-type (-> (the-as target v1-13) control) collide-shape))))
(if (and v1-14 (or (logtest? (-> v1-14 root-prim prim-core collide-as) (collide-spec enemy))
(logtest? (-> v1-14 root-prim prim-core action) (collide-action no-smack))
)