Files
jak-project/test/decompiler/reference/jak1/engine/level/bsp-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

208 lines
6.8 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type bsp-node
(deftype bsp-node (structure)
((front int32)
(back int32)
(front-flags uint32)
(back-flags uint32)
(plane vector :inline)
)
)
;; definition for method 3 of type bsp-node
(defmethod inspect ((this bsp-node))
(format #t "[~8x] ~A~%" this 'bsp-node)
(format #t "~Tfront: ~D~%" (-> this front))
(format #t "~Tback: ~D~%" (-> this back))
(format #t "~Tfront-flags: ~D~%" (-> this front-flags))
(format #t "~Tback-flags: ~D~%" (-> this back-flags))
(format #t "~Tplane: #<vector @ #x~X>~%" (-> this plane))
this
)
;; definition of type bsp-header
(deftype bsp-header (drawable)
((info file-info :overlay-at id)
(all-visible-list (pointer uint16))
(visible-list-length int32)
(drawable-trees drawable-tree-array)
(pat pointer)
(pat-length int32)
(texture-remap-table (pointer uint64))
(texture-remap-table-len int32)
(texture-ids (pointer texture-id))
(texture-page-count int32)
(unk-zero-0 basic)
(name symbol)
(nickname symbol)
(vis-info level-vis-info 8)
(actors drawable-inline-array-actor)
(cameras (array entity-camera))
(nodes (inline-array bsp-node))
(level level)
(current-leaf-idx uint16)
(unk-data-2 uint16 9)
(boxes box8s-array)
(current-bsp-back-flags uint32)
(ambients drawable-inline-array-ambient)
(unk-data-4 float)
(unk-data-5 float)
(adgifs adgif-shader-array)
(actor-birth-order (pointer uint32))
(split-box-indices (pointer uint16))
(unk-data-8 uint32 55)
)
(:methods
(relocate (_type_ kheap (pointer uint8)) none :replace)
(birth (_type_) none)
(deactivate-entities (_type_) none)
)
)
;; definition of type game-level
(deftype game-level (basic)
((master-bsp basic)
)
)
;; definition for method 3 of type game-level
(defmethod inspect ((this game-level))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tmaster-bsp: ~A~%" (-> this master-bsp))
this
)
;; definition of type view-frustum
(deftype view-frustum (structure)
((hither-top-left vector :inline)
(hither-top-right vector :inline)
(hither-bottom-left vector :inline)
(hither-bottom-right vector :inline)
(yon-top-left vector :inline)
(yon-top-right vector :inline)
(yon-bottom-left vector :inline)
(yon-bottom-right vector :inline)
)
)
;; definition for method 3 of type view-frustum
(defmethod inspect ((this view-frustum))
(format #t "[~8x] ~A~%" this 'view-frustum)
(format #t "~Thither-top-left: #<vector @ #x~X>~%" (-> this hither-top-left))
(format #t "~Thither-top-right: #<vector @ #x~X>~%" (-> this hither-top-right))
(format #t "~Thither-bottom-left: #<vector @ #x~X>~%" (-> this hither-bottom-left))
(format #t "~Thither-bottom-right: #<vector @ #x~X>~%" (-> this hither-bottom-right))
(format #t "~Tyon-top-left: #<vector @ #x~X>~%" (-> this yon-top-left))
(format #t "~Tyon-top-right: #<vector @ #x~X>~%" (-> this yon-top-right))
(format #t "~Tyon-bottom-left: #<vector @ #x~X>~%" (-> this yon-bottom-left))
(format #t "~Tyon-bottom-right: #<vector @ #x~X>~%" (-> this yon-bottom-right))
this
)
;; definition for method 3 of type bsp-header
(defmethod inspect ((this bsp-header))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tall-visible-list: #x~X~%" (-> this all-visible-list))
(format #t "~Tvisible-list-length: ~D~%" (-> this visible-list-length))
(format #t "~Tdrawable-trees: ~A~%" (-> this drawable-trees))
(format #t "~Tpat: #x~X~%" (-> this pat))
(format #t "~Tpat-length: ~D~%" (-> this pat-length))
(inspect-bsp-tree this (the-as bsp-node (-> this nodes)))
this
)
;; definition (debug) for function inspect-bsp-tree
;; INFO: Return type mismatch bsp-header vs none.
(defun-debug inspect-bsp-tree ((arg0 bsp-header) (arg1 bsp-node))
(cond
((zero? arg1)
)
(else
(format #t "_#x~X________________~%" arg1)
(inspect arg1)
(let ((s4-0 *print-column*))
(set! *print-column* (+ *print-column* 64))
(if (> (-> arg1 front) 0)
(inspect-bsp-tree arg0 (the-as bsp-node (-> arg1 front)))
(format #t "_#x~X________________~%" arg1)
)
(if (> (-> arg1 back) 0)
(inspect-bsp-tree arg0 (the-as bsp-node (-> arg1 back)))
(format #t "_#x~X________________~%" arg1)
)
(set! *print-column* s4-0)
)
)
)
(none)
)
;; definition for function map-bsp-tree
;; INFO: Return type mismatch bsp-header vs none.
(defun map-bsp-tree ((arg0 (function bsp-node none)) (arg1 bsp-header) (arg2 bsp-node))
(cond
((zero? arg2)
)
(else
(if (> (-> arg2 front) 0)
(map-bsp-tree arg0 arg1 (the-as bsp-node (-> arg2 front)))
(arg0 arg2)
)
(if (> (-> arg2 back) 0)
(map-bsp-tree arg0 arg1 (the-as bsp-node (-> arg2 back)))
(arg0 arg2)
)
)
)
(none)
)
;; definition of type cl-stat
(deftype cl-stat (structure)
((fragments uint32)
(tris uint32)
(output uint32)
)
:pack-me
)
;; definition for method 3 of type cl-stat
(defmethod inspect ((this cl-stat))
(format #t "[~8x] ~A~%" this 'cl-stat)
(format #t "~Tfragments: ~D~%" (-> this fragments))
(format #t "~Ttris: ~D~%" (-> this tris))
(format #t "~Toutput: ~D~%" (-> this output))
this
)
;; definition of type collide-stats
(deftype collide-stats (structure)
((other cl-stat :inline)
(total cl-stat :inline)
(nodes uint32)
(calls uint32)
(total-target stopwatch :inline)
(target-cache-fill stopwatch :inline)
(target-ray-poly stopwatch :inline)
(pad uint32)
)
)
;; definition for method 3 of type collide-stats
(defmethod inspect ((this collide-stats))
(format #t "[~8x] ~A~%" this 'collide-stats)
(format #t "~Tother: #<cl-stat @ #x~X>~%" (-> this other))
(format #t "~Ttotal: #<cl-stat @ #x~X>~%" (-> this total))
(format #t "~Tnodes: ~D~%" (-> this nodes))
(format #t "~Tcalls: ~D~%" (-> this calls))
(format #t "~Ttotal-target: #<stopwatch @ #x~X>~%" (-> this total-target))
(format #t "~Ttarget-cache-fill: #<stopwatch @ #x~X>~%" (-> this target-cache-fill))
(format #t "~Ttarget-ray-poly: #<stopwatch @ #x~X>~%" (-> this target-ray-poly))
this
)
;; failed to figure out what this is:
0