ScarletNX / xspe models / rsx
rsx: xfer.lisp
the transfer classes: NV0039 (memory to memory), NV3062/NV309E (2D surfaces),
NV0039_BUFFER_NOTIFY source
(defmethod-rsx NV0039_BUFFER_NOTIFY #x2328 (value)
"copy LINE_COUNT lines of LINE_LENGTH_IN bytes (TODO: element strides other than 1)"
(let ((in (rsx-address rsx (reg NV0039_SET_CONTEXT_DMA_BUFFER_IN) (reg NV0039_OFFSET_IN)))
(out (rsx-address rsx (reg NV0039_SET_CONTEXT_DMA_BUFFER_OUT) (reg NV0039_OFFSET_OUT)))
(pitch-in (sext 32 (reg NV0039_PITCH_IN)))
(pitch-out (sext 32 (reg NV0039_PITCH_OUT)))
(length (reg NV0039_LINE_LENGTH_IN)))
(dotimes (line (reg NV0039_LINE_COUNT))
(let ((src (wrap 32 (+ in (* line pitch-in)))) (dst (wrap 32 (+ out (* line pitch-out)))))
(dotimes (b length)
(mem-write 8 (+ dst b) (mem-read 8 (+ src b))))))
(setf (rsx-transfers rsx) (wrap 32 (+ (rsx-transfers rsx) 1)))))
NV308A_COLOR source
(defmethod-rsx NV308A_COLOR (#xA400 #x700 4) (value i)
"word I of the image's row at POINT, into the NV3062 destination (TODO: clipping, conversions)"
(let* ((point (reg NV308A_POINT))
(bpp (if (= (reg NV3062_SET_COLOR_FORMAT) 4) 2 4))
(base (rsx-address rsx (reg NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN) (reg NV3062_SET_OFFSET_DESTIN)))
(row (wrap 32 (+ base (* (ldb (byte 16 16) point) (ldb (byte 16 16) (reg NV3062_SET_PITCH)))))))
(mem-write 32 (+ row (* (ldb (byte 16 0) point) bpp) (* 4 i)) value)))
NV3089_IMAGE_IN source
(defmethod-rsx NV3089_IMAGE_IN #xC40C (value)
"starts the scaled blit: TODO (sampling, format conversion, swizzled destinations)"
(setf (rsx-transfers rsx) (wrap 32 (+ (rsx-transfers rsx) 1))))