mirror of
https://github.com/open-goal/jak-project
synced 2026-06-14 14:28:25 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
139 lines
3.8 KiB
Common Lisp
Vendored
Generated
139 lines
3.8 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition for function box-vector-enside?
|
|
(defun box-vector-enside? ((box bounding-box) (pt vector))
|
|
(and (< (-> box min x) (-> pt x))
|
|
(< (-> box min y) (-> pt y))
|
|
(< (-> box min z) (-> pt z))
|
|
(< (-> pt x) (-> box max x))
|
|
(< (-> pt y) (-> box max y))
|
|
(< (-> pt z) (-> box max z))
|
|
)
|
|
)
|
|
|
|
;; definition for function box-vector-inside?
|
|
(defun box-vector-inside? ((box bounding-box) (pt vector))
|
|
(and (>= (-> pt x) (-> box min x))
|
|
(>= (-> pt y) (-> box min y))
|
|
(>= (-> pt z) (-> box min z))
|
|
(>= (-> box max x) (-> pt x))
|
|
(>= (-> box max y) (-> pt y))
|
|
(>= (-> box max z) (-> pt z))
|
|
)
|
|
)
|
|
|
|
;; definition for method 11 of type bounding-box
|
|
;; ERROR: Failed load: (set! vf3 (l.vf a2-0)) at op 0
|
|
(defmethod set-from-point-offset! ((this bounding-box) (arg0 vector3s) (arg1 vector3s))
|
|
(rlet ((vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
(vf5 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(.lvf vf3 arg1)
|
|
(.lvf vf4 arg0)
|
|
(.add.vf vf5 vf4 vf3)
|
|
(.min.vf vf1 vf4 vf5)
|
|
(.max.vf vf2 vf4 vf5)
|
|
(.mov.vf vf1 vf0 :mask #b1000)
|
|
(.mov.vf vf2 vf0 :mask #b1000)
|
|
(.svf (&-> this min quad) vf1)
|
|
(.svf (&-> this max quad) vf2)
|
|
0
|
|
)
|
|
)
|
|
|
|
;; definition for method 10 of type bounding-box
|
|
;; ERROR: Failed load: (set! vf3 (l.vf a1-0)) at op 2
|
|
(defmethod add-point! ((this bounding-box) (arg0 vector3s))
|
|
(rlet ((vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
)
|
|
(.lvf vf1 (&-> this min quad))
|
|
(.lvf vf2 (&-> this max quad))
|
|
(.lvf vf3 arg0)
|
|
(.min.vf vf1 vf1 vf3)
|
|
(.max.vf vf2 vf2 vf3)
|
|
(.svf (&-> this min quad) vf1)
|
|
(.svf (&-> this max quad) vf2)
|
|
0
|
|
)
|
|
)
|
|
|
|
;; definition for method 15 of type bounding-box
|
|
(defmethod add-box! ((this bounding-box) (arg0 bounding-box))
|
|
(rlet ((vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
)
|
|
(.lvf vf1 (&-> this min quad))
|
|
(.lvf vf2 (&-> this max quad))
|
|
(.lvf vf3 (&-> arg0 min quad))
|
|
(.lvf vf4 (&-> arg0 max quad))
|
|
(.min.vf vf1 vf1 vf3)
|
|
(.max.vf vf2 vf2 vf4)
|
|
(.svf (&-> this min quad) vf1)
|
|
(.svf (&-> this max quad) vf2)
|
|
0
|
|
)
|
|
)
|
|
|
|
;; definition for method 12 of type bounding-box
|
|
;; ERROR: Failed load: (set! vf4 (l.vf a2-0)) at op 0
|
|
(defmethod set-from-point-offset-pad! ((this bounding-box) (arg0 vector3s) (arg1 vector3s) (arg2 float))
|
|
(rlet ((vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
(vf5 :class vf)
|
|
(vf6 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(.lvf vf4 arg1)
|
|
(.lvf vf5 arg0)
|
|
(.mov vf1 arg2)
|
|
(.add.vf vf6 vf5 vf4)
|
|
(.min.vf vf2 vf5 vf6)
|
|
(.max.vf vf3 vf5 vf6)
|
|
(.add.x.vf vf3 vf3 vf1 :mask #b111)
|
|
(.sub.x.vf vf2 vf2 vf1 :mask #b111)
|
|
(.mov.vf vf2 vf0 :mask #b1000)
|
|
(.mov.vf vf3 vf0 :mask #b1000)
|
|
(.svf (&-> this min quad) vf2)
|
|
(.svf (&-> this max quad) vf3)
|
|
0
|
|
)
|
|
)
|
|
|
|
;; definition for method 13 of type bounding-box
|
|
(defmethod set-from-sphere! ((this bounding-box) (arg0 sphere))
|
|
(rlet ((vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(.lvf vf1 (&-> arg0 quad))
|
|
(.sub.w.vf vf2 vf1 vf1 :mask #b111)
|
|
(.add.w.vf vf3 vf1 vf1 :mask #b111)
|
|
(.mov.vf vf2 vf0 :mask #b1000)
|
|
(.mov.vf vf3 vf0 :mask #b1000)
|
|
(.svf (&-> this min quad) vf2)
|
|
(.svf (&-> this max quad) vf3)
|
|
0
|
|
)
|
|
)
|
|
|
|
;; definition for method 14 of type bounding-box
|
|
;; ERROR: function was not converted to expressions. Cannot decompile.
|
|
|
|
;; definition for method 9 of type bounding-box
|
|
;; ERROR: function was not converted to expressions. Cannot decompile.
|