Files
jak-project/test/decompiler/reference/jak1/engine/gfx/math-camera-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

179 lines
7.4 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type vis-gif-tag
(deftype vis-gif-tag (structure)
((fog0 uint32)
(strip uint32)
(regs uint32)
(fan uint32)
)
)
;; definition for method 3 of type vis-gif-tag
(defmethod inspect ((this vis-gif-tag))
(format #t "[~8x] ~A~%" this 'vis-gif-tag)
(format #t "~Tfog0: ~D~%" (-> this fog0))
(format #t "~Tstrip: ~D~%" (-> this strip))
(format #t "~Tregs: ~D~%" (-> this regs))
(format #t "~Tfan: ~D~%" (-> this fan))
this
)
;; definition of type cull-info
(deftype cull-info (structure)
((x-fact float)
(y-fact float)
(z-fact float)
(cam-radius float)
(cam-x float)
(cam-y float)
(xz-dir-ax float)
(xz-dir-az float)
(xz-dir-bx float)
(xz-dir-bz float)
(xz-cross-ab float)
(yz-dir-ay float)
(yz-dir-az float)
(yz-dir-by float)
(yz-dir-bz float)
(yz-cross-ab float)
)
:pack-me
)
;; definition for method 3 of type cull-info
(defmethod inspect ((this cull-info))
(format #t "[~8x] ~A~%" this 'cull-info)
(format #t "~Tx-fact: ~f~%" (-> this x-fact))
(format #t "~Ty-fact: ~f~%" (-> this y-fact))
(format #t "~Tz-fact: ~f~%" (-> this z-fact))
(format #t "~Tcam-radius: ~f~%" (-> this cam-radius))
(format #t "~Tcam-x: ~f~%" (-> this cam-x))
(format #t "~Tcam-y: ~f~%" (-> this cam-y))
(format #t "~Txz-dir-ax: ~f~%" (-> this xz-dir-ax))
(format #t "~Txz-dir-az: ~f~%" (-> this xz-dir-az))
(format #t "~Txz-dir-bx: ~f~%" (-> this xz-dir-bx))
(format #t "~Txz-dir-bz: ~f~%" (-> this xz-dir-bz))
(format #t "~Txz-cross-ab: ~f~%" (-> this xz-cross-ab))
(format #t "~Tyz-dir-ay: ~f~%" (-> this yz-dir-ay))
(format #t "~Tyz-dir-az: ~f~%" (-> this yz-dir-az))
(format #t "~Tyz-dir-by: ~f~%" (-> this yz-dir-by))
(format #t "~Tyz-dir-bz: ~f~%" (-> this yz-dir-bz))
(format #t "~Tyz-cross-ab: ~f~%" (-> this yz-cross-ab))
this
)
;; definition of type math-camera
(deftype math-camera (basic)
((d meters)
(f meters)
(fov degrees)
(x-ratio float)
(y-ratio float)
(x-pix float)
(x-clip float)
(x-clip-ratio-in float)
(x-clip-ratio-over float)
(y-pix float)
(y-clip float)
(y-clip-ratio-in float)
(y-clip-ratio-over float)
(cull-info cull-info :inline)
(fog-start meters)
(fog-end meters)
(fog-max float)
(fog-min float)
(reset int32)
(smooth-step float)
(smooth-t float)
(perspective matrix :inline)
(isometric matrix :inline)
(sprite-2d matrix :inline)
(sprite-2d-hvdf vector :inline)
(camera-rot matrix :inline)
(inv-camera-rot matrix :inline)
(inv-camera-rot-smooth matrix :inline)
(inv-camera-rot-smooth-from quaternion :inline)
(camera-temp matrix :inline)
(prev-camera-temp matrix :inline)
(hmge-scale vector :inline)
(inv-hmge-scale vector :inline)
(hvdf-off vector :inline)
(guard vector :inline)
(vis-gifs vis-gif-tag 4 :inline)
(vis-gifs-quads uint128 4 :overlay-at vis-gifs)
(giftex vis-gif-tag :overlay-at (-> vis-gifs 0))
(gifgr vis-gif-tag :overlay-at (-> vis-gifs 1))
(giftex-trans vis-gif-tag :overlay-at (-> vis-gifs 2))
(gifgr-trans vis-gif-tag :overlay-at (-> vis-gifs 3))
(pfog0 float)
(pfog1 float)
(trans vector :inline)
(plane plane 4 :inline)
(guard-plane plane 4 :inline)
(shrub-mat matrix :inline)
(fov-correction-factor float)
)
(:methods
(new (symbol type) _type_)
)
)
;; definition for method 3 of type math-camera
;; INFO: Used lq/sq
(defmethod inspect ((this math-camera))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Td: (meters ~m)~%" (-> this d))
(format #t "~Tf: (meters ~m)~%" (-> this f))
(format #t "~Tfov: (deg ~r)~%" (-> this fov))
(format #t "~Tx-ratio: ~f~%" (-> this x-ratio))
(format #t "~Ty-ratio: ~f~%" (-> this y-ratio))
(format #t "~Tx-pix: ~f~%" (-> this x-pix))
(format #t "~Tx-clip: ~f~%" (-> this x-clip))
(format #t "~Tx-clip-ratio-in: ~f~%" (-> this x-clip-ratio-in))
(format #t "~Tx-clip-ratio-over: ~f~%" (-> this x-clip-ratio-over))
(format #t "~Ty-pix: ~f~%" (-> this y-pix))
(format #t "~Ty-clip: ~f~%" (-> this y-clip))
(format #t "~Ty-clip-ratio-in: ~f~%" (-> this y-clip-ratio-in))
(format #t "~Ty-clip-ratio-over: ~f~%" (-> this y-clip-ratio-over))
(format #t "~Tcull-info: #<cull-info @ #x~X>~%" (-> this cull-info))
(format #t "~Tfog-start: (meters ~m)~%" (-> this fog-start))
(format #t "~Tfog-end: (meters ~m)~%" (-> this fog-end))
(format #t "~Tfog-max: ~f~%" (-> this fog-max))
(format #t "~Tfog-min: ~f~%" (-> this fog-min))
(format #t "~Treset: ~D~%" (-> this reset))
(format #t "~Tsmooth-step: ~f~%" (-> this smooth-step))
(format #t "~Tsmooth-t: ~f~%" (-> this smooth-t))
(format #t "~Tperspective: #<matrix @ #x~X>~%" (-> this perspective))
(format #t "~Tisometric: #<matrix @ #x~X>~%" (-> this isometric))
(format #t "~Tsprite-2d: #<matrix @ #x~X>~%" (-> this sprite-2d))
(format #t "~Tsprite-2d-hvdf: #<vector @ #x~X>~%" (-> this sprite-2d-hvdf))
(format #t "~Tcamera-rot: #<matrix @ #x~X>~%" (-> this camera-rot))
(format #t "~Tinv-camera-rot: #<matrix @ #x~X>~%" (-> this inv-camera-rot))
(format #t "~Tinv-camera-rot-smooth: #<matrix @ #x~X>~%" (-> this inv-camera-rot-smooth))
(format #t "~Tinv-camera-rot-smooth-from: #<quaternion @ #x~X>~%" (-> this inv-camera-rot-smooth-from))
(format #t "~Tcamera-temp: #<matrix @ #x~X>~%" (-> this camera-temp))
(format #t "~Tprev-camera-temp: #<matrix @ #x~X>~%" (-> this prev-camera-temp))
(format #t "~Thmge-scale: #<vector @ #x~X>~%" (-> this hmge-scale))
(format #t "~Tinv-hmge-scale: #<vector @ #x~X>~%" (-> this inv-hmge-scale))
(format #t "~Thvdf-off: #<vector @ #x~X>~%" (-> this hvdf-off))
(format #t "~Tguard: #<vector @ #x~X>~%" (-> this guard))
(format #t "~Tvis-gifs[4] @ #x~X~%" (-> this vis-gifs))
(format #t "~Tgiftex: ~D~%" (-> this vis-gifs-quads 0))
(format #t "~Tgifgr: ~D~%" (-> this vis-gifs-quads 1))
(format #t "~Tgiftex-trans: ~D~%" (-> this vis-gifs-quads 2))
(format #t "~Tgifgr-trans: ~D~%" (-> this vis-gifs-quads 3))
(format #t "~Tpfog0: ~f~%" (-> this pfog0))
(format #t "~Tpfog1: ~f~%" (-> this pfog1))
(format #t "~Ttrans: ~`vector`P~%" (-> this trans))
(format #t "~Tplane[4] @ #x~X~%" (-> this plane))
(format #t "~Tguard-plane[4] @ #x~X~%" (-> this guard-plane))
(format #t "~Tshrub-mat: #<matrix @ #x~X>~%" (-> this shrub-mat))
(format #t "~Tfov-correction-factor: ~f~%" (-> this fov-correction-factor))
this
)
;; failed to figure out what this is:
0