[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
@@ -772,12 +772,7 @@
(logclear! (-> this flags) (cloth-flag no-draw))
)
(when (and (handle->process (-> this owner)) (= (-> (handle->process (-> this owner)) type) target))
(let* ((s5-0 (handle->process (-> this owner)))
(a0-16 (if (type? s5-0 process-focusable)
s5-0
)
)
)
(let ((a0-16 (as-type (handle->process (-> this owner)) process-focusable)))
(when (and a0-16 (focus-test? (the-as process-focusable a0-16) teleporting))
(set! (-> this reset-count) 1)
(logior! (-> this flags) (cloth-flag need-reset no-draw))
+5 -28
View File
@@ -673,12 +673,7 @@
)
)
(else
(let* ((s3-0 (-> s5-0 proc2))
(a0-46 (if (type? s3-0 process-focusable)
s3-0
)
)
)
(let ((a0-46 (as-type (-> s5-0 proc2) process-focusable)))
(if a0-46
(set! (-> s5-0 denom2) (get-inv-mass a0-46))
)
@@ -1413,11 +1408,7 @@
(format *stdcon* "rigid-body-object got touched~%")
)
(when (zero? (-> (the-as process-focusable arg0) rbody))
(let ((s3-0 (if (type? arg0 process-focusable)
arg0
)
)
)
(let ((s3-0 (as-type arg0 process-focusable)))
(when s3-0
(when (logtest? (-> s3-0 mask) (process-mask target))
(logior! (-> this flags) (rigid-body-object-flag player-touching))
@@ -1450,11 +1441,7 @@
(('edge-grabbed 'pilot-edge-grab)
(let ((s5-2 (the-as object (-> arg3 param 0))))
(when (not (logtest? (-> this flags) (rigid-body-object-flag player-impulse-force)))
(let ((a0-25 (if (type? arg0 process-focusable)
(the-as process-focusable arg0)
)
)
)
(let ((a0-25 (as-type arg0 process-focusable)))
(when a0-25
(let ((f0-1 (/ 163840.0 (get-inv-mass a0-25))))
(logior! (-> this flags) (rigid-body-object-flag player-touching player-edge-grabbing player-contact-force))
@@ -1471,12 +1458,7 @@
(('ridden)
(let ((v1-47 (the-as object (-> arg3 param 0))))
(when (the-as uint v1-47)
(let* ((s5-3 (handle->process (-> (the-as focus v1-47) handle)))
(a0-34 (if (type? s5-3 process-focusable)
s5-3
)
)
)
(let ((a0-34 (as-type (handle->process (-> (the-as focus v1-47) handle)) process-focusable)))
(when (and a0-34
(logtest? (-> a0-34 mask) (process-mask target))
(not (logtest? (-> (the-as process-focusable a0-34) focus-status) (focus-status on-water under-water)))
@@ -1498,12 +1480,7 @@
)
(('bonk)
(when #t
(let* ((s3-2 arg0)
(s4-1 (if (type? s3-2 process-focusable)
s3-2
)
)
)
(let ((s4-1 (as-type arg0 process-focusable)))
(when s4-1
(logior! (-> this flags) (rigid-body-object-flag player-touching player-impulse-force))
(set-time! (-> this player-touch-time))
+39 -57
View File
@@ -193,13 +193,9 @@
)
(let ((f30-0 (fill-and-probe-using-line-sphere *collide-cache* arg0)))
(when (and arg1 (>= f30-0 0.0) (>= 0.0 (vector-dot (-> arg0 best-other-tri normal) (-> this dir))))
(let* ((s3-0 (new 'stack-no-clear 'touching-shapes-entry))
(s2-0 (-> arg0 best-other-tri collide-ptr))
(v1-12 (if (type? s2-0 collide-shape-prim)
s2-0
)
)
)
(let ((s3-0 (new 'stack-no-clear 'touching-shapes-entry))
(v1-12 (as-type (-> arg0 best-other-tri collide-ptr) collide-shape-prim))
)
(set! (-> s3-0 cshape1) #f)
(set! (-> s3-0 cshape2) (if v1-12
(-> (the-as collide-shape-prim v1-12) cshape)
@@ -266,51 +262,42 @@
;; definition for method 13 of type combo-tracker
;; WARN: Return type mismatch process vs process-focusable.
(defmethod combo-tracker-method-13 ((this combo-tracker) (arg0 handle) (arg1 vector) (arg2 float) (arg3 vector) (arg4 float))
(the-as
process-focusable
(cond
((send-event (handle->process arg0) 'combo)
(let ((gp-1 (handle->process arg0)))
(if (type? gp-1 process-focusable)
gp-1
)
)
)
(else
(let ((s1-0 (new 'stack-no-clear 'vector))
(s2-1 (new 'stack 'boxed-array collide-shape 32))
)
(sphere<-vector+r! (the-as sphere s1-0) arg1 arg2)
(set! (-> s2-1 length) (fill-actor-list-for-box
*actor-hash*
s1-0
(the-as (pointer collide-shape) (-> s2-1 data))
(-> s2-1 allocated-length)
)
)
(let ((gp-2 (find-nearest-focusable
(the-as (array collide-shape) s2-1)
arg1
arg2
(if (= arg4 65536.0)
(search-info-flag crate enemy combo)
(search-info-flag crate enemy prefer-angle cull-angle combo)
)
(search-info-flag)
arg3
(the-as vector #f)
arg4
)
)
)
(if (type? gp-2 process-focusable)
gp-2
)
)
(the-as process-focusable (cond
((send-event (handle->process arg0) 'combo)
(as-type (handle->process arg0) process-focusable)
)
(else
(let ((s1-0 (new 'stack-no-clear 'vector))
(s2-1 (new 'stack 'boxed-array collide-shape 32))
)
(sphere<-vector+r! (the-as sphere s1-0) arg1 arg2)
(set! (-> s2-1 length) (fill-actor-list-for-box
*actor-hash*
s1-0
(the-as (pointer collide-shape) (-> s2-1 data))
(-> s2-1 allocated-length)
)
)
(as-type
(find-nearest-focusable
(the-as (array collide-shape) s2-1)
arg1
arg2
(if (= arg4 65536.0)
(search-info-flag crate enemy combo)
(search-info-flag crate enemy prefer-angle cull-angle combo)
)
(search-info-flag)
arg3
(the-as vector #f)
arg4
)
process-focusable
)
)
)
)
)
)
)
)
)
;; definition for method 12 of type combo-tracker
@@ -338,12 +325,7 @@
(set! (-> a1-4 from) (process->ppointer pp))
(set! (-> a1-4 num-params) 0)
(set! (-> a1-4 message) 'nav-control)
(let* ((s3-0 (send-event-function (handle->process (-> this target)) a1-4))
(s4-1 (if (type? s3-0 nav-control)
s3-0
)
)
)
(let ((s4-1 (as-type (send-event-function (handle->process (-> this target)) a1-4) nav-control)))
(when s4-1
(let ((a2-3 ((method-of-type nav-control find-poly-containing-point-1) (the-as nav-control s4-1) arg1)))
(if a2-3