Files
jak-project/test/decompiler/reference/jak2/engine/geometry/vol-h_REF.gc
T
ManDude cd68cb671e deftype and defmethod syntax major changes (#3094)
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>
2023-10-30 03:20:02 +00:00

143 lines
5.0 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type plane-volume
(deftype plane-volume (structure)
((volume-type symbol)
(point-count int16)
(normal-count int16)
(first-point (pointer vector))
(first-normal (pointer vector))
(num-planes int32)
(plane (inline-array plane))
)
:pack-me
(:methods
(plane-volume-method-9 (_type_ symbol vector-array vector-array) plane-volume)
(debug-draw (_type_) none)
(point-in-vol? (_type_ vector float) symbol)
)
)
;; definition for method 3 of type plane-volume
(defmethod inspect ((this plane-volume))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'plane-volume)
(format #t "~1Tvolume-type: ~A~%" (-> this volume-type))
(format #t "~1Tpoint-count: ~D~%" (-> this point-count))
(format #t "~1Tnormal-count: ~D~%" (-> this normal-count))
(format #t "~1Tfirst-point: #<vector @ #x~X>~%" (-> this first-point))
(format #t "~1Tfirst-normal: #<vector @ #x~X>~%" (-> this first-normal))
(format #t "~1Tnum-planes: ~D~%" (-> this num-planes))
(format #t "~1Tplane: #x~X~%" (-> this plane))
(label cfg-4)
this
)
;; definition of type vol-control
(deftype vol-control (basic)
((flags vol-flags)
(process process-drawable)
(pos-vol-count int32)
(pos-vol plane-volume 32 :inline)
(neg-vol-count int32)
(neg-vol plane-volume 32 :inline)
(debug-point vector-array)
(debug-normal vector-array)
)
(:methods
(new (symbol type process-drawable) _type_)
(debug-draw (_type_) none)
(vol-control-method-10 (_type_ plane) symbol)
(should-display? (_type_) symbol)
)
)
;; definition for method 3 of type vol-control
(defmethod inspect ((this vol-control))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tflags: #x~X~%" (-> this flags))
(format #t "~1Tprocess: ~A~%" (-> this process))
(format #t "~1Tpos-vol-count: ~D~%" (-> this pos-vol-count))
(format #t "~1Tpos-vol[32] @ #x~X~%" (-> this pos-vol))
(format #t "~1Tneg-vol-count: ~D~%" (-> this neg-vol-count))
(format #t "~1Tneg-vol[32] @ #x~X~%" (-> this neg-vol))
(format #t "~1Tdebug-point: ~A~%" (-> this debug-point))
(format #t "~1Tdebug-normal: ~A~%" (-> this debug-normal))
(label cfg-4)
this
)
;; definition for method 0 of type vol-control
;; INFO: Used lq/sq
;; WARN: Return type mismatch object vs vol-control.
(defmethod new vol-control ((allocation symbol) (type-to-make type) (arg0 process-drawable))
(let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size))))))
(when (zero? (the-as vol-control gp-0))
(go process-drawable-art-error "memory")
(set! gp-0 0)
(goto cfg-13)
)
(set! (-> (the-as vol-control gp-0) process) arg0)
(let* ((s5-1 (-> (the-as vol-control gp-0) process entity))
(s4-0 (-> ((method-of-type res-lump lookup-tag-idx) s5-1 'vol 'base -1000000000.0) lo))
)
(when (>= (the-as int s4-0) 0)
(let ((s3-0 (the-as int s4-0))
(s2-0 (-> s5-1 tag s4-0))
)
0
(while (= (-> s2-0 name) (-> s5-1 tag s4-0 name))
(let ((v1-12 (make-property-data s5-1 0.0 (the-as res-tag-pair s3-0) (the-as pointer #f)))
(a0-8 (-> (the-as vol-control gp-0) pos-vol (-> (the-as vol-control gp-0) pos-vol-count)))
)
(set! (-> a0-8 num-planes) (the-as int (-> s2-0 elt-count)))
(set! (-> a0-8 plane) (the-as (inline-array plane) v1-12))
)
(+! (-> (the-as vol-control gp-0) pos-vol-count) 1)
(+! s3-0 1)
(set! s2-0 (-> s5-1 tag s3-0))
)
)
)
)
(let* ((s5-2 (-> (the-as vol-control gp-0) process entity))
(s4-1 (-> ((method-of-type res-lump lookup-tag-idx) s5-2 'cutoutvol 'base -1000000000.0) lo))
)
(when (>= (the-as int s4-1) 0)
(let ((s3-1 (the-as int s4-1))
(s2-1 (-> s5-2 tag s4-1))
)
0
(while (= (-> s2-1 name) (-> s5-2 tag s4-1 name))
(let ((v1-31 (make-property-data s5-2 0.0 (the-as res-tag-pair s3-1) (the-as pointer #f)))
(a0-19 (-> (the-as vol-control gp-0) neg-vol (-> (the-as vol-control gp-0) neg-vol-count)))
)
(set! (-> a0-19 num-planes) (the-as int (-> s2-1 elt-count)))
(set! (-> a0-19 plane) (the-as (inline-array plane) v1-31))
)
(+! (-> (the-as vol-control gp-0) neg-vol-count) 1)
(+! s3-1 1)
(set! s2-1 (-> s5-2 tag s3-1))
)
)
)
)
(label cfg-13)
(the-as vol-control gp-0)
)
)
;; definition for method 11 of type vol-control
(defmethod should-display? ((this vol-control))
"Returns true/false if the volume's marks should be displayed"
(and *display-vol-marks* (logtest? (-> this flags) (vol-flags display?)))
)