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

388 lines
16 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type bigmap-bit-mask
(deftype bigmap-bit-mask (structure)
((data uint8 6656)
)
)
;; definition for method 3 of type bigmap-bit-mask
(defmethod inspect ((this bigmap-bit-mask))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bigmap-bit-mask)
(format #t "~1Tdata[6656] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; definition of type bigmap-layer-mask
(deftype bigmap-layer-mask (structure)
((data uint8 26624)
)
)
;; definition for method 3 of type bigmap-layer-mask
(defmethod inspect ((this bigmap-layer-mask))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bigmap-layer-mask)
(format #t "~1Tdata[26624] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; definition of type bigmap-image
(deftype bigmap-image (structure)
((clut-offset uint32)
(image-offset uint32)
(pad uint32 2)
(data uint8 1)
)
)
;; definition for method 3 of type bigmap-image
(defmethod inspect ((this bigmap-image))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bigmap-image)
(format #t "~1Tclut-offset: ~D~%" (-> this clut-offset))
(format #t "~1Timage-offset: ~D~%" (-> this image-offset))
(format #t "~1Tpad[2] @ #x~X~%" (-> this pad))
(format #t "~1Tdata[1] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; definition of type bigmap-info
(deftype bigmap-info (vector)
((scale float :overlay-at (-> data 2))
(inv-scale float :overlay-at (-> data 3))
)
)
;; definition for method 3 of type bigmap-info
;; INFO: Used lq/sq
(defmethod inspect ((this bigmap-info))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bigmap-info)
(format #t "~1Tdata[4] @ #x~X~%" (&-> this x))
(format #t "~1Tx: ~f~%" (-> this x))
(format #t "~1Ty: ~f~%" (-> this y))
(format #t "~1Tz: ~f~%" (-> this scale))
(format #t "~1Tw: ~f~%" (-> this inv-scale))
(format #t "~1Tquad: ~D~%" (-> this quad))
(format #t "~1Tscale: ~f~%" (-> this scale))
(format #t "~1Tinv-scale: ~f~%" (-> this inv-scale))
(label cfg-4)
this
)
;; definition of type bigmap-info-array
(deftype bigmap-info-array (structure)
((data bigmap-info 21 :inline)
)
)
;; definition for method 3 of type bigmap-info-array
(defmethod inspect ((this bigmap-info-array))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bigmap-info-array)
(format #t "~1Tdata[21] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; definition of type bigmap-compressed-layers
(deftype bigmap-compressed-layers (structure)
((data (pointer uint32) 20)
(layer0 (pointer uint32) :overlay-at (-> data 0))
(layer1 (pointer uint32) :overlay-at (-> data 1))
(layer2 (pointer uint32) :overlay-at (-> data 2))
(layer3 (pointer uint32) :overlay-at (-> data 3))
(layer4 (pointer uint32) :overlay-at (-> data 4))
(layer5 (pointer uint32) :overlay-at (-> data 5))
(layer6 (pointer uint32) :overlay-at (-> data 6))
(layer7 (pointer uint32) :overlay-at (-> data 7))
(layer8 (pointer uint32) :overlay-at (-> data 8))
(layer9 (pointer uint32) :overlay-at (-> data 9))
(layer10 (pointer uint32) :overlay-at (-> data 10))
(layer11 (pointer uint32) :overlay-at (-> data 11))
(layer12 (pointer uint32) :overlay-at (-> data 12))
(layer13 (pointer uint32) :overlay-at (-> data 13))
(layer14 (pointer uint32) :overlay-at (-> data 14))
(layer15 (pointer uint32) :overlay-at (-> data 15))
(layer16 (pointer uint32) :overlay-at (-> data 16))
(layer17 (pointer uint32) :overlay-at (-> data 17))
(layer18 (pointer uint32) :overlay-at (-> data 18))
(layer19 (pointer uint32) :overlay-at (-> data 19))
)
)
;; definition for method 3 of type bigmap-compressed-layers
(defmethod inspect ((this bigmap-compressed-layers))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bigmap-compressed-layers)
(format #t "~1Tdata[20] @ #x~X~%" (&-> this layer0))
(format #t "~1Tlayer0: #x~X~%" (-> this layer0))
(format #t "~1Tlayer1: #x~X~%" (-> this layer1))
(format #t "~1Tlayer2: #x~X~%" (-> this layer2))
(format #t "~1Tlayer3: #x~X~%" (-> this layer3))
(format #t "~1Tlayer4: #x~X~%" (-> this layer4))
(format #t "~1Tlayer5: #x~X~%" (-> this layer5))
(format #t "~1Tlayer6: #x~X~%" (-> this layer6))
(format #t "~1Tlayer7: #x~X~%" (-> this layer7))
(format #t "~1Tlayer8: #x~X~%" (-> this layer8))
(format #t "~1Tlayer9: #x~X~%" (-> this layer9))
(format #t "~1Tlayer10: #x~X~%" (-> this layer10))
(format #t "~1Tlayer11: #x~X~%" (-> this layer11))
(format #t "~1Tlayer12: #x~X~%" (-> this layer12))
(format #t "~1Tlayer13: #x~X~%" (-> this layer13))
(format #t "~1Tlayer14: #x~X~%" (-> this layer14))
(format #t "~1Tlayer15: #x~X~%" (-> this layer15))
(format #t "~1Tlayer16: #x~X~%" (-> this layer16))
(format #t "~1Tlayer17: #x~X~%" (-> this layer17))
(format #t "~1Tlayer18: #x~X~%" (-> this layer18))
(format #t "~1Tlayer19: #x~X~%" (-> this layer19))
(label cfg-4)
this
)
;; definition of type bigmap
(deftype bigmap (basic)
((drawing-flag symbol)
(loading-flag symbol)
(recording-flag symbol)
(fill-flag symbol)
(bigmap-index uint32)
(bigmap-image external-art-buffer)
(tpage external-art-buffer)
(progress-minimap texture-page)
(mask-index uint32)
(bit-mask bigmap-bit-mask)
(compressed-next-index uint32)
(max-next-index uint32)
(compressed-masks (pointer int8) 20)
(compressed-data uint32)
(layer-index uint32)
(layer-mask bigmap-layer-mask)
(compressed-layers bigmap-compressed-layers)
(layer-mask-enable uint32)
(load-index uint32)
(x0 int32)
(y0 int32)
(x1 int32)
(y1 int32)
(y2 int32)
(goal-time float)
(sprite-tmpl dma-gif-packet :inline)
(draw-tmpl dma-gif-packet :inline)
(adgif-tmpl dma-gif-packet :inline)
(offset vector :inline)
(size float :overlay-at (-> offset data 2))
(scale float :overlay-at (-> offset data 3))
(draw-offset vector :inline)
(draw-size float :overlay-at (-> draw-offset data 2))
(draw-scale float :overlay-at (-> draw-offset data 3))
(scroll vector :inline)
(pos vector4w :inline)
(color vector4w :inline)
(corner vector 4 :inline)
(auto-save-icon-flag symbol)
)
(:methods
(new (symbol type) _type_)
(initialize (_type_) none)
(update (_type_) none)
(draw (_type_ int int int int) int)
(handle-cpad-inputs (_type_) int)
(compress-all (_type_) int)
(enable-drawing (_type_) none)
(disable-drawing (_type_) int)
(dump-to-file (_type_) file-stream)
(set-pos! (_type_ vector) int)
(decompress-current-masks! (_type_) int)
(compress-current-masks! (_type_) int)
(set-enable-from-position! (_type_) int)
(maybe-fill-for-position (_type_ int int) int)
(texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none)
(mask-image-from-bit-mask (_type_) none)
(draw-non-city-map (_type_ dma-buffer) none)
(draw-city-map (_type_ dma-buffer) none)
(sprite-dma (_type_ dma-buffer int int int int) none)
(draw-from-minimap (_type_ dma-buffer connection-minimap) int)
)
)
;; definition for method 3 of type bigmap
(defmethod inspect ((this bigmap))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tdrawing-flag: ~A~%" (-> this drawing-flag))
(format #t "~1Tloading-flag: ~A~%" (-> this loading-flag))
(format #t "~1Trecording-flag: ~A~%" (-> this recording-flag))
(format #t "~1Tfill-flag: ~A~%" (-> this fill-flag))
(format #t "~1Tbigmap-index: ~D~%" (-> this bigmap-index))
(format #t "~1Tbigmap-image: ~A~%" (-> this bigmap-image))
(format #t "~1Ttpage: ~A~%" (-> this tpage))
(format #t "~1Tprogress-minimap: ~A~%" (-> this progress-minimap))
(format #t "~1Tmask-index: ~D~%" (-> this mask-index))
(format #t "~1Tbit-mask: #<bigmap-bit-mask @ #x~X>~%" (-> this bit-mask))
(format #t "~1Tcompressed-next-index: ~D~%" (-> this compressed-next-index))
(format #t "~1Tmax-next-index: ~D~%" (-> this max-next-index))
(format #t "~1Tcompressed-masks[20] @ #x~X~%" (-> this compressed-masks))
(format #t "~1Tcompressed-data: #x~X~%" (-> this compressed-data))
(format #t "~1Tlayer-index: ~D~%" (-> this layer-index))
(format #t "~1Tlayer-mask: #<bigmap-layer-mask @ #x~X>~%" (-> this layer-mask))
(format #t "~1Tcompressed-layers: #<bigmap-compressed-layers @ #x~X>~%" (-> this compressed-layers))
(format #t "~1Tlayer-mask-enable: ~D~%" (-> this layer-mask-enable))
(format #t "~1Tload-index: ~D~%" (-> this load-index))
(format #t "~1Tx0: ~D~%" (-> this x0))
(format #t "~1Ty0: ~D~%" (-> this y0))
(format #t "~1Tx1: ~D~%" (-> this x1))
(format #t "~1Ty1: ~D~%" (-> this y1))
(format #t "~1Ty2: ~D~%" (-> this y2))
(format #t "~1Tgoal-time: ~f~%" (-> this goal-time))
(format #t "~1Tsprite-tmpl: #<dma-gif-packet @ #x~X>~%" (-> this sprite-tmpl))
(format #t "~1Tdraw-tmpl: #<dma-gif-packet @ #x~X>~%" (-> this draw-tmpl))
(format #t "~1Tadgif-tmpl: #<dma-gif-packet @ #x~X>~%" (-> this adgif-tmpl))
(format #t "~1Toffset: #<vector @ #x~X>~%" (-> this offset))
(format #t "~1Tsize: ~f~%" (-> this offset z))
(format #t "~1Tscale: ~f~%" (-> this offset w))
(format #t "~1Tdraw-offset: #<vector @ #x~X>~%" (-> this draw-offset))
(format #t "~1Tdraw-size: ~f~%" (-> this draw-offset z))
(format #t "~1Tdraw-scale: ~f~%" (-> this draw-offset w))
(format #t "~1Tscroll: #<vector @ #x~X>~%" (-> this scroll))
(format #t "~1Tpos: #<vector4w @ #x~X>~%" (-> this pos))
(format #t "~1Tcolor: #<vector4w @ #x~X>~%" (-> this color))
(format #t "~1Tcorner[4] @ #x~X~%" (-> this corner))
(format #t "~1Tauto-save-icon-flag: ~A~%" (-> this auto-save-icon-flag))
(label cfg-4)
this
)
;; definition for method 0 of type bigmap
(defmethod new bigmap ((allocation symbol) (type-to-make type))
(let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> gp-0 bigmap-image)
((method-of-type external-art-buffer new)
allocation
external-art-buffer
0
(lambda ((arg0 external-art-buffer))
(let ((a1-3 (logand -64 (&+ (&+ (-> *display* frames 0 global-buf end) -430144) 63)))
(v1-1 (-> arg0 heap))
)
(set! (-> v1-1 base) a1-3)
(set! (-> v1-1 current) (-> v1-1 base))
(set! (-> v1-1 top-base) (&+ (-> v1-1 base) #x69000))
(set! (-> v1-1 top) (-> v1-1 top-base))
)
0
(none)
)
#f
)
)
(set! (-> gp-0 tpage)
((method-of-type external-art-buffer new)
allocation
external-art-buffer
0
(lambda ((arg0 external-art-buffer))
(let ((a1-3 (logand -64 (&+ (&+ (-> *display* frames 0 global-buf end) -774208) 63)))
(v1-1 (-> arg0 heap))
)
(set! (-> v1-1 base) a1-3)
(set! (-> v1-1 current) (-> v1-1 base))
(set! (-> v1-1 top-base) (&+ (-> v1-1 base) #xbd000))
(set! (-> v1-1 top) (-> v1-1 top-base))
)
0
(none)
)
#f
)
)
(set! (-> gp-0 bit-mask) (new 'global 'bigmap-bit-mask))
(set! (-> gp-0 compressed-data) (the-as uint (malloc 'global #x8000)))
(set! (-> gp-0 layer-mask) (new 'global 'bigmap-layer-mask))
(set! (-> gp-0 compressed-layers) *bigmap-compressed-layers*)
(set! (-> gp-0 sprite-tmpl dma-vif dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)))
(set! (-> gp-0 sprite-tmpl dma-vif vif0) (new 'static 'vif-tag))
(set! (-> gp-0 sprite-tmpl dma-vif vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
(set! (-> gp-0 sprite-tmpl gif0) (the-as uint #x50ab400000008001))
(set! (-> gp-0 sprite-tmpl gif1) (the-as uint #x53531))
(set! (-> gp-0 draw-tmpl dma-vif dma) (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt)))
(set! (-> gp-0 draw-tmpl dma-vif vif0) (new 'static 'vif-tag))
(set! (-> gp-0 draw-tmpl dma-vif vif1) (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1))
(set! (-> gp-0 draw-tmpl gif0) (the-as uint #x90aa400000008001))
(set! (-> gp-0 draw-tmpl gif1) (the-as uint #x535353531))
(set! (-> gp-0 adgif-tmpl dma-vif dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)))
(set! (-> gp-0 adgif-tmpl dma-vif vif0) (new 'static 'vif-tag))
(set! (-> gp-0 adgif-tmpl dma-vif vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
(set! (-> gp-0 adgif-tmpl gif0) (the-as uint #x1000000000008005))
(set! (-> gp-0 adgif-tmpl gif1) (the-as uint 14))
(set-vector! (-> gp-0 offset) 0.0 0.0 0.0 0.0)
(set-vector! (-> gp-0 scroll) 0.0 0.0 0.0 0.0)
(set-vector! (-> gp-0 pos) 0 0 0 0)
(set-vector! (-> gp-0 color) 128 128 128 128)
(set! (-> gp-0 drawing-flag) #f)
(set! (-> gp-0 loading-flag) #f)
(set! (-> gp-0 recording-flag) #f)
(set! (-> gp-0 fill-flag) #t)
(set! (-> gp-0 progress-minimap) #f)
(set! (-> gp-0 auto-save-icon-flag) #f)
(initialize gp-0)
gp-0
)
)
;; definition for symbol *bigmap-info-array*, type bigmap-info-array
(define *bigmap-info-array*
(new 'static 'bigmap-info-array
:data (new 'static 'inline-array bigmap-info 21
(new 'static 'bigmap-info :x -251215.88 :y -6390620.0 :scale 7477.334 :inv-scale 0.00006686875)
(new 'static 'bigmap-info :x -68266.805 :y -7629693.0 :scale 4266.668 :inv-scale 0.00011718746)
(new 'static 'bigmap-info :x -1612460.0 :y -7806484.5 :scale 3498.668 :inv-scale 0.00014291154)
(new 'static 'bigmap-info :x 339968.0 :y -8220672.0 :scale 3200.0 :inv-scale 0.00015625)
(new 'static 'bigmap-info :x -602935.3 :y -9531720.0 :scale 6933.332 :inv-scale 0.0000721154)
(new 'static 'bigmap-info :x -1565331.5 :y -1109332.0 :scale 5337.4277 :inv-scale 0.000093678085)
(new 'static 'bigmap-info :x -3681067.0 :y 2179413.2 :scale 4586.668 :inv-scale 0.0001090116)
(new 'static 'bigmap-info :x 1110016.0 :y -20480.0 :scale 4096.0 :inv-scale 0.00012207031)
(new 'static 'bigmap-info :x -4358144.0 :y -581632.0 :scale 5469.09 :inv-scale 0.00009142289)
(new 'static 'bigmap-info :x -1646719.0 :y -1395200.0 :scale 4000.002 :inv-scale 0.00012499993)
(new 'static 'bigmap-info :x -1292161.0 :y -935251.94 :scale 7253.332 :inv-scale 0.000068933834)
(new 'static 'bigmap-info :x -87520.055 :y 1879040.0 :scale 2880.0 :inv-scale 0.00017361112)
(new 'static 'bigmap-info :x -87520.055 :y 1879040.0 :scale 2880.0 :inv-scale 0.00017361112)
(new 'static 'bigmap-info :x 3053472.2 :y -2397868.0 :scale 3946.668 :inv-scale 0.00012668915)
(new 'static 'bigmap-info :x 4027306.8 :y 1112746.8 :scale 4693.332 :inv-scale 0.00010653412)
(new 'static 'bigmap-info :x 4027306.8 :y 1112746.8 :scale 4693.332 :inv-scale 0.00010653412)
(new 'static 'bigmap-info :x 4027306.8 :y 1112746.8 :scale 4693.332 :inv-scale 0.00010653412)
(new 'static 'bigmap-info :x 8574157.0 :y -1033420.8 :scale 5430.231 :inv-scale 0.00009207711)
(new 'static 'bigmap-info :x -787795.94 :y 4102697.0 :scale 5717.332 :inv-scale 0.00008745338)
(new 'static 'bigmap-info :x -1558401.0 :y 6746452.0 :scale 5866.668 :inv-scale 0.00008522726)
(new 'static 'bigmap-info)
)
)
)