[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
+7 -13
View File
@@ -339,12 +339,7 @@
(init-vf0-vector)
(cond
((= (-> arg1 position) #t)
(let* ((s3-0 (handle->process (-> arg1 handle)))
(v1-4 (if (type? s3-0 process-drawable)
(the-as process-drawable s3-0)
)
)
)
(let ((v1-4 (as-type (handle->process (-> arg1 handle)) process-drawable)))
(if (and v1-4 (nonzero? (-> v1-4 root)))
(set! (-> arg1 last-world-pos quad) (-> v1-4 root trans quad))
)
@@ -354,13 +349,12 @@
(= (-> (the-as basic (-> arg1 position)) type) entity-actor)
)
(let* ((v1-14 (the-as entity-actor (-> arg1 position)))
(s3-1 (if v1-14
(-> v1-14 extra process)
)
)
(a0-13 (if (type? s3-1 process-drawable)
(the-as process-drawable s3-1)
)
(a0-13 (as-type
(if v1-14
(-> v1-14 extra process)
)
process-drawable
)
)
)
(if a0-13
+20 -50
View File
@@ -945,12 +945,7 @@
)
(set! s3-0 (cond
((= s2-0 #t)
(let* ((s2-1 (handle->process (-> v1-9 handle)))
(v1-13 (if (type? s2-1 process-drawable)
s2-1
)
)
)
(let ((v1-13 (the-as process (as-type (handle->process (-> v1-9 handle)) process-drawable))))
(if v1-13
(set! s3-0 (-> (the-as process-drawable v1-13) root trans))
)
@@ -959,13 +954,13 @@
)
((and (= (logand (the-as int s2-0) 7) 4) (= (-> (the-as basic s2-0) type) entity-actor))
(let* ((v1-19 s2-0)
(s3-1 (if v1-19
(-> (the-as entity-actor v1-19) extra process)
)
)
(v1-21 (if (type? s3-1 process-drawable)
s3-1
)
(v1-21 (the-as process (as-type
(if v1-19
(-> (the-as entity-actor v1-19) extra process)
)
process-drawable
)
)
)
)
(if v1-21
@@ -1425,12 +1420,7 @@
(sv-224 matrix)
(sv-228 matrix)
)
(let ((s3-0 (handle->process (-> arg1 handle))))
(set! sv-16 (if (type? s3-0 process-drawable)
s3-0
)
)
)
(set! sv-16 (the-as process (as-type (handle->process (-> arg1 handle)) process-drawable)))
(set! sv-20 (-> arg0 buf))
(when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
(set! sv-208 (-> sv-20 base))
@@ -1551,12 +1541,7 @@
(sv-136 vector)
(sv-140 matrix)
)
(let ((s0-0 (handle->process (-> arg1 handle))))
(set! sv-16 (if (type? s0-0 process-drawable)
s0-0
)
)
)
(set! sv-16 (the-as process (as-type (handle->process (-> arg1 handle)) process-drawable)))
(set! sv-20 (-> *video-params* relative-x-scale))
(set! sv-24 (-> arg0 buf))
(when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
@@ -1684,12 +1669,7 @@
(vf4 :class vf)
(vf5 :class vf)
)
(let ((s3-0 (handle->process (-> arg1 handle))))
(set! sv-16 (if (type? s3-0 process-drawable)
s3-0
)
)
)
(set! sv-16 (the-as process (as-type (handle->process (-> arg1 handle)) process-drawable)))
(set! sv-20 (-> arg0 buf))
(when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
(set! sv-208 (-> sv-20 base))
@@ -1835,12 +1815,7 @@
(sv-228 matrix)
(sv-232 matrix)
)
(let ((s3-0 (handle->process (-> arg1 handle))))
(set! sv-16 (if (type? s3-0 process-drawable)
s3-0
)
)
)
(set! sv-16 (the-as process (as-type (handle->process (-> arg1 handle)) process-drawable)))
(set! sv-20 (-> arg0 buf))
(when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
(set! sv-208 (-> sv-20 base))
@@ -2313,12 +2288,7 @@
(let ((s1-0 (target-pos 0)))
(cond
((= (-> arg1 position) #t)
(let* ((s3-0 (handle->process (-> arg1 handle)))
(v1-4 (if (type? s3-0 process-drawable)
s3-0
)
)
)
(let ((v1-4 (the-as process (as-type (handle->process (-> arg1 handle)) process-drawable))))
(when (and v1-4 (nonzero? (-> (the-as process-drawable v1-4) root)))
(set! (-> arg1 last-world-pos quad) (-> (the-as process-drawable v1-4) root trans quad))
(vector-! (-> arg1 last-relative-pos) s1-0 (-> arg1 last-world-pos))
@@ -2329,13 +2299,13 @@
(= (-> (the-as basic (-> arg1 position)) type) entity-actor)
)
(let* ((v1-15 (-> arg1 position))
(s3-1 (if v1-15
(-> (the-as entity-actor v1-15) extra process)
)
)
(a0-16 (if (type? s3-1 process-drawable)
s3-1
)
(a0-16 (the-as process (as-type
(if v1-15
(-> (the-as entity-actor v1-15) extra process)
)
process-drawable
)
)
)
)
(cond
File diff suppressed because it is too large Load Diff
+3 -9
View File
@@ -1424,17 +1424,11 @@
(+! s5-0 20)
)
(dotimes (s4-1 (length gp-0))
(let ((v1-24 sv-144))
(set! (-> v1-24 scale) 0.5)
)
(set-scale! sv-144 0.5)
(set! (-> sv-144 origin x) 79.0)
(set! (-> sv-144 origin y) (the float sv-148))
(let ((v1-29 sv-144))
(set! (-> v1-29 width) (the float 355))
)
(let ((v1-30 sv-144))
(set! (-> v1-30 height) (the float 30))
)
(set-width! sv-144 355)
(set-height! sv-144 30)
(set! (-> sv-144 flags) (if (= (-> *setting-control* user-default language) (language-enum japanese))
(font-flags middle middle-vert large)
(font-flags kerning middle middle-vert large)
+1 -3
View File
@@ -405,9 +405,7 @@
(if (logtest? (-> arg2 flags) (font-flags middle-vert))
(+! (-> arg2 origin y) (* 0.5 (- f30-0 f1-2)))
)
(let ((v1-10 arg2))
(set! (-> v1-10 scale) (* f28-0 arg1))
)
(set-scale! arg2 (* f28-0 arg1))
(set! (-> arg2 width) f0-1)
(set! (-> arg2 height) f1-2)
)