mirror of
https://github.com/open-goal/jak-project
synced 2026-05-24 23:22:14 -04:00
219 lines
6.6 KiB
Common Lisp
Vendored
Generated
219 lines
6.6 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type dma-packet
|
|
(deftype dma-packet (structure)
|
|
"The header for a DMA transfer, containing an DMA tag, and VIF tags."
|
|
((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)
|
|
"Unused dma array. Unclear how it should be used."
|
|
((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)
|
|
"Believed unused GIF header type."
|
|
((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)
|
|
"The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags."
|
|
((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)
|
|
"A buffer for DMA data."
|
|
((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 ((dma-buff dma-buffer) (size-bytes int))
|
|
"Create a dma-buffer in-place. Does not set the type of the dma-buffer object."
|
|
(set! (-> dma-buff base) (-> dma-buff data))
|
|
(set! (-> dma-buff allocated-length) size-bytes)
|
|
dma-buff
|
|
)
|
|
|
|
;; 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 ((dma-buf dma-buffer))
|
|
"Get length used in quadwords, rounded up."
|
|
(shr (+ (&- (-> dma-buf base) (the-as uint (-> dma-buf data))) 15) 4)
|
|
)
|
|
|
|
;; definition for function dma-buffer-free
|
|
(defun dma-buffer-free ((dma-buf dma-buffer))
|
|
"Get the number of free quadwords between base and end pointers."
|
|
(shr (+ (&- (-> dma-buf end) (the-as uint (-> dma-buf 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 ((chan dma-bank) (buf dma-buffer))
|
|
"Send the DMA buffer! DOES NOT TRANSFER TAG, you probably want dma-buffer-send-chain instead."
|
|
(when (< (-> buf allocated-length) (&- (-> buf base) (the-as uint (-> buf data))))
|
|
(crash!)
|
|
0
|
|
)
|
|
(dma-send chan (the-as uint (-> buf data)) (the-as uint (dma-buffer-length buf)))
|
|
(none)
|
|
)
|
|
|
|
;; definition for function dma-buffer-send-chain
|
|
(defun dma-buffer-send-chain ((chan dma-bank-source) (buf dma-buffer))
|
|
"Send the DMA buffer! Sends the tags, so this is suitable for the main graphics chain."
|
|
(when (< (-> buf allocated-length) (&- (-> buf base) (the-as uint (-> buf data))))
|
|
(crash!)
|
|
0
|
|
)
|
|
(dma-send-chain chan (the-as uint (-> buf data)))
|
|
(none)
|
|
)
|