Files
jak-project/test/decompiler/reference/jak2/engine/ps2/vif-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

121 lines
3.6 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type vif-stat
(deftype vif-stat (uint32)
((vps uint8 :offset 0 :size 2)
(vew uint8 :offset 2 :size 1)
(mrk uint8 :offset 6 :size 1)
(vss uint8 :offset 8 :size 1)
(vfs uint8 :offset 9 :size 1)
(vis uint8 :offset 10 :size 1)
(int uint8 :offset 11 :size 1)
(er0 uint8 :offset 12 :size 1)
(er1 uint8 :offset 13 :size 1)
(fqc uint8 :offset 24 :size 4)
)
)
;; definition for method 3 of type vif-stat
(defmethod inspect ((this vif-stat))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'vif-stat)
(format #t "~1Tvps: ~D~%" (-> this vps))
(format #t "~1Tvew: ~D~%" (-> this vew))
(format #t "~1Tmrk: ~D~%" (-> this mrk))
(format #t "~1Tvss: ~D~%" (-> this vss))
(format #t "~1Tvfs: ~D~%" (-> this vfs))
(format #t "~1Tvis: ~D~%" (-> this vis))
(format #t "~1Tint: ~D~%" (-> this int))
(format #t "~1Ter0: ~D~%" (-> this er0))
(format #t "~1Ter1: ~D~%" (-> this er1))
(format #t "~1Tfqc: ~D~%" (-> this fqc))
(label cfg-4)
this
)
;; definition of type vif-fbrst
(deftype vif-fbrst (uint32)
((rst uint8 :offset 0 :size 1)
(fbk uint8 :offset 1 :size 1)
(stp uint8 :offset 2 :size 1)
(stc uint8 :offset 3 :size 1)
)
)
;; definition of type vif-err
(deftype vif-err (uint32)
((mii uint8 :offset 0 :size 1)
(me0 uint8 :offset 1 :size 1)
(me1 uint8 :offset 2 :size 1)
)
)
;; definition of type vif-bank
(deftype vif-bank (structure)
((stat uint32)
(fbrst uint32 :offset 16)
(err vif-err :offset 32)
(mark uint32 :offset 48)
(cycle uint32 :offset 64)
(mode uint32 :offset 80)
(num uint32 :offset 96)
(mask uint32 :offset 112)
(code uint32 :offset 128)
(itops uint32 :offset 144)
(base uint32 :offset 160)
(offset uint32 :offset 176)
(tops uint32 :offset 192)
(itop uint32 :offset 208)
(top uint32 :offset 224)
(r0 uint32 :offset 256)
(r1 uint32 :offset 272)
(r2 uint32 :offset 288)
(r3 uint32 :offset 304)
(c0 uint32 :offset 320)
(c1 uint32 :offset 336)
(c2 uint32 :offset 352)
(c3 uint32 :offset 368)
)
)
;; definition for method 3 of type vif-bank
(defmethod inspect ((this vif-bank))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'vif-bank)
(format #t "~1Tstat: #x~X~%" (-> this stat))
(format #t "~1Tfbrst: #x~X~%" (-> this fbrst))
(format #t "~1Terr: #x~X~%" (-> this err))
(format #t "~1Tmark: #x~X~%" (-> this mark))
(format #t "~1Tcycle: #x~X~%" (-> this cycle))
(format #t "~1Tmode: #x~X~%" (-> this mode))
(format #t "~1Tnum: #x~X~%" (-> this num))
(format #t "~1Tmask: #x~X~%" (-> this mask))
(format #t "~1Tcode: #x~X~%" (-> this code))
(format #t "~1Titops: #x~X~%" (-> this itops))
(format #t "~1Tbase: #x~X~%" (-> this base))
(format #t "~1Toffset: #x~X~%" (-> this offset))
(format #t "~1Ttops: #x~X~%" (-> this tops))
(format #t "~1Titop: #x~X~%" (-> this itop))
(format #t "~1Ttop: #x~X~%" (-> this top))
(format #t "~1Tr0: #x~X~%" (-> this r0))
(format #t "~1Tr1: #x~X~%" (-> this r1))
(format #t "~1Tr2: #x~X~%" (-> this r2))
(format #t "~1Tr3: #x~X~%" (-> this r3))
(format #t "~1Tc0: #x~X~%" (-> this c0))
(format #t "~1Tc1: #x~X~%" (-> this c1))
(format #t "~1Tc2: #x~X~%" (-> this c2))
(format #t "~1Tc3: #x~X~%" (-> this c3))
(label cfg-4)
this
)
;; failed to figure out what this is:
0