[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
@@ -1760,12 +1760,7 @@
;; definition for function calculate-ship-projectile-velocity
;; WARN: Return type mismatch int vs none.
(defun calculate-ship-projectile-velocity ((arg0 projectile-init-by-other-params) (arg1 float))
(let* ((s4-0 *target*)
(a0-2 (if (type? s4-0 process-focusable)
s4-0
)
)
)
(let ((a0-2 (the-as target (as-type *target* process-focusable))))
(cond
(a0-2
(let ((a0-3 (get-trans a0-2 0)))
+10 -25
View File
@@ -276,9 +276,7 @@
(the-as attack-info (mem-copy! (the-as pointer (new 'stack-no-clear 'attack-info)) (the-as pointer s4-0) 160))
(the-as uint s4-0)
self
(if (type? arg0 process-drawable)
arg0
)
(the-as process (as-type arg0 process-drawable))
(the-as touching-shapes-entry (-> arg3 param 0))
)
(+! (-> self next-hit-state) 1)
@@ -474,12 +472,7 @@
(defstate idle (drill-sliding-door)
:virtual #t
:trans (behavior ()
(let* ((gp-0 *target*)
(a0-1 (if (type? gp-0 process-focusable)
gp-0
)
)
)
(let ((a0-1 (the-as target (as-type *target* process-focusable))))
(if (and a0-1 (< (vector-vector-distance (-> self root trans) (get-trans a0-1 0)) 40960.0))
(go-virtual open)
)
@@ -770,14 +763,10 @@
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('attack)
(let* ((s5-0 (-> block param 0))
(gp-0 (the-as object (-> block param 1)))
(s4-0 proc)
(v1-1 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((s5-0 (-> block param 0))
(gp-0 (the-as object (-> block param 1)))
(v1-1 (the-as process (as-type proc process-drawable)))
)
(when (and s5-0
v1-1
(or (= (-> (the-as attack-info gp-0) mode) 'turret) (= (-> (the-as attack-info gp-0) mode) 'explode))
@@ -1216,14 +1205,10 @@
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('attack)
(let* ((gp-0 (-> block param 0))
(s5-0 (the-as object (-> block param 1)))
(s4-0 proc)
(v1-1 (if (type? s4-0 process-drawable)
s4-0
)
)
)
(let ((gp-0 (-> block param 0))
(s5-0 (the-as object (-> block param 1)))
(v1-1 (the-as process (as-type proc process-drawable)))
)
(if (and gp-0 v1-1 (case (-> (the-as attack-info s5-0) mode)
(('turret 'explode 'wasp-shot)
#t
+7 -21
View File
@@ -621,12 +621,7 @@
(defmethod commited-to-ride? ((this drill-mech-elevator))
"@returns if the target is considered within the elevator area enough to begin descending/ascending"
(when (= (-> this move-pos 1) (-> this bottom-top 0))
(let* ((s5-0 *target*)
(a0-2 (if (type? s5-0 process-focusable)
s5-0
)
)
)
(let ((a0-2 (the-as target (as-type *target* process-focusable))))
(when (and a0-2 (focus-test? a0-2 mech) (not (logtest? (-> a0-2 focus-status) (focus-status dead ignore))))
(let* ((v1-5 (get-trans a0-2 0))
(s5-2 (vector-! (new 'stack-no-clear 'vector) v1-5 (-> this root trans)))
@@ -759,12 +754,7 @@
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touch 'attack)
(let* ((s4-0 proc)
(gp-0 (if (type? s4-0 process-focusable)
s4-0
)
)
)
(let ((gp-0 (the-as process (as-type proc process-focusable))))
(when gp-0
(when (or (focus-test? (the-as process-focusable gp-0) mech)
(time-elapsed? (-> self no-collision-timer) (the-as time-frame (-> *TARGET-bank* hit-invulnerable-timeout)))
@@ -1598,15 +1588,11 @@
(let ((f0-7 (probe-using-line-sphere *collide-cache* s5-1)))
(when (>= f0-7 0.0)
(vector-float*! (-> s5-1 move-dist) (-> s5-1 move-dist) f0-7)
(let ((s4-2 (-> s5-1 best-other-tri collide-ptr)))
(when (if (type? s4-2 collide-shape-prim-sphere)
s4-2
)
(set! gp-0 #t)
(if (zero? (-> self hit-sound-id))
(set! (-> self hit-sound-id) (sound-play "drill-laser-cut"))
)
)
(when (the-as basic (as-type (-> s5-1 best-other-tri collide-ptr) collide-shape-prim-sphere))
(set! gp-0 #t)
(if (zero? (-> self hit-sound-id))
(set! (-> self hit-sound-id) (sound-play "drill-laser-cut"))
)
)
)
)
+1 -6
View File
@@ -142,12 +142,7 @@
;; definition for method 45 of type drill-lift
(defmethod commited-to-ride? ((this drill-lift))
"@returns if the target is considered within the elevator area enough to begin descending/ascending"
(let* ((gp-0 *target*)
(a0-2 (if (type? gp-0 process-focusable)
gp-0
)
)
)
(let ((a0-2 (the-as target (as-type *target* process-focusable))))
(when a0-2
(let* ((v1-1 (get-trans a0-2 0))
(gp-2 (vector-! (new 'stack-no-clear 'vector) v1-1 (-> this root trans)))
+9 -13
View File
@@ -584,21 +584,17 @@
(local-vars (v0-1 object))
(case arg2
(('touched)
(let ((s5-0 arg0))
(when (if (type? s5-0 ginsu)
s5-0
)
(let ((s5-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this node-list data 8))))
(let ((a0-5 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this node-list data 8))))
(vector+! s5-1 s5-1 a0-5)
)
(vector-float*! s5-1 s5-1 0.5)
(spawn (-> this part) s5-1)
(when (the-as process (as-type arg0 ginsu))
(let ((s5-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this node-list data 8))))
(let ((a0-5 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this node-list data 8))))
(vector+! s5-1 s5-1 a0-5)
)
(set! v0-1 (+ (current-time) (seconds 0.125)))
(set! (-> this grind-timer) (the-as time-frame v0-1))
v0-1
(vector-float*! s5-1 s5-1 0.5)
(spawn (-> this part) s5-1)
)
(set! v0-1 (+ (current-time) (seconds 0.125)))
(set! (-> this grind-timer) (the-as time-frame v0-1))
v0-1
)
)
(('touch 'bonk 'attack)