Files
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

434 lines
14 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type joint-anim
(deftype joint-anim (basic)
((name string)
(number int16)
(length int16)
)
)
;; definition for method 3 of type joint-anim
(defmethod inspect ((this joint-anim))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tname: ~A~%" (-> this name))
(format #t "~Tnumber: ~D~%" (-> this number))
(format #t "~Tlength: ~D~%" (-> this length))
this
)
;; definition of type joint-anim-matrix
(deftype joint-anim-matrix (joint-anim)
((data matrix :inline :dynamic :offset 16)
)
)
;; definition of type joint-anim-transformq
(deftype joint-anim-transformq (joint-anim)
((data transformq :inline :dynamic :offset 16)
)
)
;; definition of type joint-anim-drawable
(deftype joint-anim-drawable (joint-anim)
((data drawable :dynamic)
)
)
;; definition for method 3 of type joint-anim-drawable
(defmethod inspect ((this joint-anim-drawable))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tname: ~A~%" (-> this name))
(format #t "~Tnumber: ~D~%" (-> this number))
(format #t "~Tlength: ~D~%" (-> this length))
(format #t "~Tdata[0] @ #x~X~%" (-> this data))
this
)
;; definition of type joint-anim-compressed
(deftype joint-anim-compressed (joint-anim)
((data uint32 :dynamic)
)
)
;; definition for method 3 of type joint-anim-compressed
(defmethod inspect ((this joint-anim-compressed))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tname: ~A~%" (-> this name))
(format #t "~Tnumber: ~D~%" (-> this number))
(format #t "~Tlength: ~D~%" (-> this length))
this
)
;; definition of type joint-anim-frame
(deftype joint-anim-frame (structure)
((matrices matrix 2 :inline)
(data matrix :inline :dynamic)
)
(:methods
(new (symbol type int) _type_)
)
)
;; definition for method 3 of type joint-anim-frame
(defmethod inspect ((this joint-anim-frame))
(format #t "[~8x] ~A~%" this 'joint-anim-frame)
(format #t "~Tmatrices[2] @ #x~X~%" (-> this matrices))
(format #t "~Tdata[0] @ #x~X~%" (-> this data))
this
)
;; definition for method 0 of type joint-anim-frame
;; INFO: Return type mismatch structure vs joint-anim-frame.
(defmethod new joint-anim-frame ((allocation symbol) (type-to-make type) (arg0 int))
(let ((v1-1 (max 0 (+ arg0 -2))))
(the-as
joint-anim-frame
(new-dynamic-structure allocation type-to-make (the-as int (+ (-> type-to-make size) (* 48 v1-1))))
)
)
)
;; definition of type joint-anim-compressed-hdr
(deftype joint-anim-compressed-hdr (structure)
((control-bits uint32 14)
(num-joints uint32)
(matrix-bits uint32)
)
)
;; definition for method 3 of type joint-anim-compressed-hdr
(defmethod inspect ((this joint-anim-compressed-hdr))
(format #t "[~8x] ~A~%" this 'joint-anim-compressed-hdr)
(format #t "~Tcontrol-bits[14] @ #x~X~%" (-> this control-bits))
(format #t "~Tnum-joints: ~D~%" (-> this num-joints))
(format #t "~Tmatrix-bits: ~D~%" (-> this matrix-bits))
this
)
;; definition of type joint-anim-compressed-fixed
(deftype joint-anim-compressed-fixed (structure)
((hdr joint-anim-compressed-hdr :inline)
(offset-64 uint32)
(offset-32 uint32)
(offset-16 uint32)
(reserved uint32)
(data vector 133 :inline)
)
)
;; definition for method 3 of type joint-anim-compressed-fixed
(defmethod inspect ((this joint-anim-compressed-fixed))
(format #t "[~8x] ~A~%" this 'joint-anim-compressed-fixed)
(format #t "~Thdr: #<joint-anim-compressed-hdr @ #x~X>~%" (-> this hdr))
(format #t "~Toffset-64: ~D~%" (-> this offset-64))
(format #t "~Toffset-32: ~D~%" (-> this offset-32))
(format #t "~Toffset-16: ~D~%" (-> this offset-16))
(format #t "~Treserved: ~D~%" (-> this reserved))
(format #t "~Tdata[133] @ #x~X~%" (-> this data))
this
)
;; definition of type joint-anim-compressed-frame
(deftype joint-anim-compressed-frame (structure)
((offset-64 uint32)
(offset-32 uint32)
(offset-16 uint32)
(reserved uint32)
(data vector 133 :inline)
)
)
;; definition for method 3 of type joint-anim-compressed-frame
(defmethod inspect ((this joint-anim-compressed-frame))
(format #t "[~8x] ~A~%" this 'joint-anim-compressed-frame)
(format #t "~Toffset-64: ~D~%" (-> this offset-64))
(format #t "~Toffset-32: ~D~%" (-> this offset-32))
(format #t "~Toffset-16: ~D~%" (-> this offset-16))
(format #t "~Treserved: ~D~%" (-> this reserved))
(format #t "~Tdata[133] @ #x~X~%" (-> this data))
this
)
;; definition of type joint-anim-compressed-control
(deftype joint-anim-compressed-control (structure)
((num-frames uint32)
(fixed-qwc uint32)
(frame-qwc uint32)
(fixed joint-anim-compressed-fixed)
(data joint-anim-compressed-frame 1)
)
)
;; definition for method 3 of type joint-anim-compressed-control
(defmethod inspect ((this joint-anim-compressed-control))
(format #t "[~8x] ~A~%" this 'joint-anim-compressed-control)
(format #t "~Tnum-frames: ~D~%" (-> this num-frames))
(format #t "~Tfixed-qwc: ~D~%" (-> this fixed-qwc))
(format #t "~Tframe-qwc: ~D~%" (-> this frame-qwc))
(format #t "~Tfixed: #<joint-anim-compressed-fixed @ #x~X>~%" (-> this fixed))
(format #t "~Tdata[1] @ #x~X~%" (-> this data))
this
)
;; definition of type art
(deftype art (basic)
((name string :offset 8)
(length int32)
(extra res-lump)
)
(:methods
(login (_type_) _type_)
(lookup-art (_type_ string type) joint)
(lookup-idx-of-art (_type_ string type) int)
(needs-link? (_type_) symbol)
)
)
;; definition for method 3 of type art
(defmethod inspect ((this art))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tname: ~A~%" (-> this name))
(format #t "~Tlength: ~D~%" (-> this length))
(format #t "~Textra: ~A~%" (-> this extra))
this
)
;; definition of type art-element
(deftype art-element (art)
((pad uint8 12)
)
)
;; definition for method 3 of type art-element
(defmethod inspect ((this art-element))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tname: ~A~%" (-> this name))
(format #t "~Tlength: ~D~%" (-> this length))
(format #t "~Textra: ~A~%" (-> this extra))
this
)
;; definition of type art-mesh-anim
(deftype art-mesh-anim (art-element)
((data basic :dynamic)
)
)
;; definition of type art-joint-anim
(deftype art-joint-anim (art-element)
((eye-anim-data merc-eye-anim-block :offset 4)
(speed float :overlay-at (-> pad 0))
(artist-base float :overlay-at (-> pad 4))
(artist-step float :overlay-at (-> pad 8))
(master-art-group-name string :offset 32)
(master-art-group-index int32 :offset 36)
(blerc-data (pointer uint8) :offset 40)
(frames joint-anim-compressed-control :offset 44)
(data joint-anim-compressed :dynamic)
)
)
;; definition of type art-group
(deftype art-group (art)
((info file-info :offset 4)
(data art-element :dynamic :offset 32)
)
(:methods
(relocate (_type_ kheap (pointer uint8)) none :replace)
(link-art! (_type_) art-group)
(unlink-art! (_type_) int)
)
)
;; definition of type art-mesh-geo
(deftype art-mesh-geo (art-element)
((data basic :dynamic)
)
)
;; definition of type art-joint-geo
(deftype art-joint-geo (art-element)
((data joint :dynamic)
)
)
;; definition of type skeleton-group
(deftype skeleton-group (basic)
((art-group-name string)
(jgeo int32)
(janim int32)
(bounds vector :inline)
(radius meters :overlay-at (-> bounds w))
(mgeo int16 4)
(max-lod int32)
(lod-dist float 4)
(longest-edge meters)
(texture-level int8)
(version int8)
(shadow int8)
(sort int8)
(_pad uint8 4)
)
)
;; definition for method 3 of type skeleton-group
(defmethod inspect ((this skeleton-group))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tart-group-name: ~A~%" (-> this art-group-name))
(format #t "~Tjgeo: ~D~%" (-> this jgeo))
(format #t "~Tjanim: ~D~%" (-> this janim))
(format #t "~Tbounds: ~`vector`P~%" (-> this bounds))
(format #t "~Tradius: (meters ~m)~%" (-> this bounds w))
(format #t "~Tmgeo[4] @ #x~X~%" (-> this mgeo))
(format #t "~Tmax-lod: ~D~%" (-> this max-lod))
(format #t "~Tlod-dist[4] @ #x~X~%" (-> this lod-dist))
(format #t "~Tlongest-edge: (meters ~m)~%" (-> this longest-edge))
(format #t "~Ttexture-level: ~D~%" (-> this texture-level))
(format #t "~Tversion: ~D~%" (-> this version))
(format #t "~Tshadow: ~D~%" (-> this shadow))
(format #t "~Tsort: ~D~%" (-> this sort))
this
)
;; definition of type lod-group
(deftype lod-group (structure)
((geo merc-ctrl)
(dist meters)
)
:pack-me
)
;; definition for method 3 of type lod-group
(defmethod inspect ((this lod-group))
(format #t "[~8x] ~A~%" this 'lod-group)
(format #t "~Tgeo: ~A~%" (-> this geo))
(format #t "~Tdist: (meters ~m)~%" (-> this dist))
this
)
;; definition of type lod-set
(deftype lod-set (structure)
((lod lod-group 4 :inline)
(max-lod int8)
)
:pack-me
(:methods
(setup-lods! (_type_ skeleton-group art-group entity) _type_)
)
)
;; definition for method 3 of type lod-set
(defmethod inspect ((this lod-set))
(format #t "[~8x] ~A~%" this 'lod-set)
(format #t "~Tlod[4] @ #x~X~%" (-> this lod))
(format #t "~Tmax-lod: ~D~%" (-> this max-lod))
this
)
;; definition of type draw-control
(deftype draw-control (basic)
((status draw-status)
(matrix-type uint8)
(data-format uint8)
(global-effect draw-effect)
(art-group art-group)
(jgeo art-joint-geo)
(mgeo merc-ctrl)
(dma-add-func (function process-drawable draw-control symbol object none))
(skeleton skeleton)
(lod-set lod-set :inline)
(lod lod-group 4 :inline :overlay-at (-> lod-set lod 0))
(max-lod int8 :overlay-at (-> lod-set max-lod))
(force-lod int8)
(cur-lod int8)
(desired-lod int8)
(ripple ripple-control)
(longest-edge meters)
(longest-edge? uint32 :overlay-at longest-edge)
(light-index uint8)
(dummy uint8 2)
(death-draw-overlap uint8)
(death-timer uint8)
(death-timer-org uint8)
(death-vertex-skip uint16)
(death-effect uint32)
(sink-group dma-foreground-sink-group)
(process process)
(shadow shadow-geo)
(shadow-ctrl shadow-control)
(origin vector :inline)
(bounds vector :inline)
(radius meters :overlay-at (-> bounds w))
(color-mult rgbaf :inline)
(color-emissive rgbaf :inline)
(secondary-interp float)
(current-secondary-interp float)
(shadow-mask uint8)
(level-index uint8)
(origin-joint-index uint8)
(shadow-joint-index uint8)
)
(:methods
(new (symbol type process art-joint-geo) _type_)
(get-skeleton-origin (_type_) vector)
(lod-set! (_type_ int) none)
(lods-assign! (_type_ lod-set) none)
)
)
;; definition for method 3 of type draw-control
(defmethod inspect ((this draw-control))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tstatus: ~D~%" (-> this status))
(format #t "~Tmatrix-type: ~D~%" (-> this matrix-type))
(format #t "~Tdata-format: ~D~%" (-> this data-format))
(format #t "~Tglobal-effect: ~D~%" (-> this global-effect))
(format #t "~Tart-group: ~A~%" (-> this art-group))
(format #t "~Tjgeo: ~A~%" (-> this jgeo))
(format #t "~Tmgeo: ~A~%" (-> this mgeo))
(format #t "~Tdma-add-func: ~A~%" (-> this dma-add-func))
(format #t "~Tskeleton: ~A~%" (-> this skeleton))
(format #t "~Tlod-set: #<lod-set @ #x~X>~%" (-> this lod-set))
(format #t "~Tlod[4] @ #x~X~%" (-> this lod-set))
(format #t "~Tmax-lod: ~D~%" (-> this lod-set max-lod))
(format #t "~Tforce-lod: ~D~%" (-> this force-lod))
(format #t "~Tcur-lod: ~D~%" (-> this cur-lod))
(format #t "~Tdesired-lod: ~D~%" (-> this desired-lod))
(format #t "~Tripple: ~A~%" (-> this ripple))
(format #t "~Tlongest-edge: (meters ~m)~%" (-> this longest-edge))
(format #t "~Tlongest-edge?: ~D~%" (-> this longest-edge))
(format #t "~Tlight-index: ~D~%" (-> this light-index))
(format #t "~Tdummy[2] @ #x~X~%" (-> this dummy))
(format #t "~Tdeath-draw-overlap: ~D~%" (-> this death-draw-overlap))
(format #t "~Tdeath-timer: ~D~%" (-> this death-timer))
(format #t "~Tdeath-timer-org: ~D~%" (-> this death-timer-org))
(format #t "~Tdeath-vertex-skip: ~D~%" (-> this death-vertex-skip))
(format #t "~Tdeath-effect: ~D~%" (-> this death-effect))
(format #t "~Tsink-group: ~A~%" (-> this sink-group))
(format #t "~Tprocess: ~A~%" (-> this process))
(format #t "~Tshadow: ~A~%" (-> this shadow))
(format #t "~Tshadow-ctrl: ~A~%" (-> this shadow-ctrl))
(format #t "~Torigin: ~`vector`P~%" (-> this origin))
(format #t "~Tbounds: ~`vector`P~%" (-> this bounds))
(format #t "~Tradius: (meters ~m)~%" (-> this bounds w))
(format #t "~Tcolor-mult: #<rgbaf @ #x~X>~%" (-> this color-mult))
(format #t "~Tcolor-emissive: #<rgbaf @ #x~X>~%" (-> this color-emissive))
(format #t "~Tsecondary-interp: ~f~%" (-> this secondary-interp))
(format #t "~Tcurrent-secondary-interp: ~f~%" (-> this current-secondary-interp))
(format #t "~Tshadow-mask: ~D~%" (-> this shadow-mask))
(format #t "~Tlevel-index: ~D~%" (-> this level-index))
(format #t "~Torigin-joint-index: ~D~%" (-> this origin-joint-index))
(format #t "~Tshadow-joint-index: ~D~%" (-> this shadow-joint-index))
this
)
;; definition for method 9 of type draw-control
(defmethod get-skeleton-origin ((this draw-control))
(-> this skeleton bones 0 transform vector 3)
)
;; failed to figure out what this is:
0