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

209 lines
5.9 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type dma-packet
(deftype dma-packet (structure)
((dma dma-tag)
(vif0 vif-tag)
(vif1 vif-tag)
(quad uint128 :overlay-at dma)
)
)
;; definition for method 3 of type dma-packet
;; INFO: Used lq/sq
(defmethod inspect ((this dma-packet))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'dma-packet)
(format #t "~1Tdma: #x~X~%" (-> this dma))
(format #t "~1Tvif0: #x~X~%" (-> this vif0))
(format #t "~1Tvif1: #x~X~%" (-> this vif1))
(format #t "~1Tquad: ~D~%" (-> this quad))
(label cfg-4)
this
)
;; definition of type dma-packet-array
(deftype dma-packet-array (inline-array-class)
((data dma-packet :inline :dynamic)
)
)
;; definition for method 3 of type dma-packet-array
(defmethod inspect ((this dma-packet-array))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tlength: ~D~%" (-> this length))
(format #t "~1Tallocated-length: ~D~%" (-> this allocated-length))
(format #t "~1Tdata[0] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; failed to figure out what this is:
(set! (-> dma-packet-array heap-base) (the-as uint 16))
;; definition of type dma-gif
(deftype dma-gif (structure)
((gif uint64 2)
(quad uint128 :overlay-at (-> gif 0))
(gif0 uint64 :overlay-at (-> gif 0))
(gif1 uint64 :overlay-at (-> gif 1))
)
)
;; definition for method 3 of type dma-gif
;; INFO: Used lq/sq
(defmethod inspect ((this dma-gif))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'dma-gif)
(format #t "~1Tgif[2] @ #x~X~%" (&-> this gif0))
(format #t "~1Tquad: ~D~%" (-> this quad))
(label cfg-4)
this
)
;; definition of type dma-gif-packet
(deftype dma-gif-packet (structure)
((dma-vif dma-packet :inline)
(gif uint64 2)
(gif0 uint64 :overlay-at (-> gif 0))
(gif1 uint64 :overlay-at (-> gif 1))
(quad uint128 2 :overlay-at (-> dma-vif dma))
)
)
;; definition for method 3 of type dma-gif-packet
(defmethod inspect ((this dma-gif-packet))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'dma-gif-packet)
(format #t "~1Tdma-vif: #<dma-packet @ #x~X>~%" (-> this dma-vif))
(format #t "~1Tgif[2] @ #x~X~%" (&-> this gif0))
(format #t "~1Tquad[2] @ #x~X~%" (-> this dma-vif))
(label cfg-4)
this
)
;; definition of type dma-buffer
(deftype dma-buffer (basic)
((allocated-length int32)
(base pointer)
(end pointer)
(data uint64 1)
(data-buffer uint8 :dynamic :overlay-at (-> data 0))
)
(:methods
(new (symbol type int) _type_)
)
)
;; definition for method 3 of type dma-buffer
(defmethod inspect ((this dma-buffer))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tallocated-length: ~D~%" (-> this allocated-length))
(format #t "~1Tbase: #x~X~%" (-> this base))
(format #t "~1Tend: #x~X~%" (-> this end))
(format #t "~1Tdata[1] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; definition for method 0 of type dma-buffer
(defmethod new dma-buffer ((allocation symbol) (type-to-make type) (arg0 int))
(let ((v0-0 (object-new allocation type-to-make (+ arg0 -4 (-> type-to-make size)))))
(set! (-> v0-0 base) (-> v0-0 data))
(set! (-> v0-0 allocated-length) arg0)
v0-0
)
)
;; definition for function dma-buffer-inplace-new
(defun dma-buffer-inplace-new ((arg0 dma-buffer) (arg1 int))
(set! (-> arg0 base) (-> arg0 data))
(set! (-> arg0 allocated-length) arg1)
arg0
)
;; definition for method 4 of type dma-buffer
(defmethod length ((this dma-buffer))
(-> this allocated-length)
)
;; definition for method 5 of type dma-buffer
(defmethod asize-of ((this dma-buffer))
(+ (-> this allocated-length) -4 (-> dma-buffer size))
)
;; definition for function dma-buffer-length
(defun dma-buffer-length ((arg0 dma-buffer))
(shr (+ (&- (-> arg0 base) (the-as uint (-> arg0 data))) 15) 4)
)
;; definition for function dma-buffer-free
(defun dma-buffer-free ((arg0 dma-buffer))
(shr (+ (&- (-> arg0 end) (the-as uint (-> arg0 base))) 15) 4)
)
;; definition for function dma-buffer-add-vu-function
(defun dma-buffer-add-vu-function ((arg0 dma-buffer) (arg1 vu-function) (arg2 int))
(let ((v1-0 (the-as object (+ (the-as uint arg1) 16)))
(a3-0 (-> arg1 qlength))
(a1-1 (-> arg1 origin))
)
(while (> a3-0 0)
(let ((t0-1 (min 127 a3-0)))
(let* ((t1-1 arg0)
(t2-0 (the-as object (-> t1-1 base)))
)
(set! (-> (the-as dma-packet t2-0) dma)
(new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int v1-0) :qwc t0-1)
)
(set! (-> (the-as dma-packet t2-0) vif0) (new 'static 'vif-tag :cmd (if (zero? arg2) 16 19)))
(set! (-> (the-as dma-packet t2-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd mpg) :num (* t0-1 2) :imm a1-1))
(set! (-> t1-1 base) (&+ (the-as pointer t2-0) 16))
)
(set! v1-0 (+ (the-as uint v1-0) (* t0-1 16)))
(set! a3-0 (- a3-0 t0-1))
(+! a1-1 (* t0-1 2))
)
)
)
#f
)
;; definition for function dma-buffer-send
(defun dma-buffer-send ((arg0 dma-bank) (arg1 dma-buffer))
(when (< (-> arg1 allocated-length) (&- (-> arg1 base) (the-as uint (-> arg1 data))))
(crash!)
0
)
(dma-send arg0 (the-as uint (-> arg1 data)) (the-as uint (dma-buffer-length arg1)))
(none)
)
;; definition for function dma-buffer-send-chain
(defun dma-buffer-send-chain ((arg0 dma-bank-source) (arg1 dma-buffer))
(when (< (-> arg1 allocated-length) (&- (-> arg1 base) (the-as uint (-> arg1 data))))
(crash!)
0
)
(dma-send-chain arg0 (the-as uint (-> arg1 data)))
(none)
)