the GS as a machine: local memory, its registers, the vertex queue, transfers, the CLUT.
(defconstant +gs-words+) source(defconstant +gs-words+ 1048576 "the local memory: 4 MiB")(defconstant +psmct32+) source(defconstant +psmct32+ #x00)(defconstant +psmct24+) source(defconstant +psmct24+ #x01)(defconstant +psmct16+) source(defconstant +psmct16+ #x02)(defconstant +psmct16s+) source(defconstant +psmct16s+ #x0A)(defconstant +psmt8+) source(defconstant +psmt8+ #x13)(defconstant +psmt4+) source(defconstant +psmt4+ #x14)(defconstant +psmt8h+) source(defconstant +psmt8h+ #x1B)(defconstant +psmt4hl+) source(defconstant +psmt4hl+ #x24)(defconstant +psmt4hh+) source(defconstant +psmt4hh+ #x2C)(defconstant +psmz32+) source(defconstant +psmz32+ #x30)(defconstant +psmz24+) source(defconstant +psmz24+ #x31)(defconstant +psmz16+) source(defconstant +psmz16+ #x32)(defconstant +psmz16s+) source(defconstant +psmz16s+ #x3A)(defmacro gsf) source(defmacro gsf (value lo size) `(ldb (byte ,size ,lo) ,value))(defstruct gsm) source(defstruct (gsm (:conc-name gsm-))
(mem (make-array 1048576 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (1048576)))
(reg (make-array 128 :element-type '(unsigned-byte 64) :initial-element 0)
:type (simple-array (unsigned-byte 64) (128)))
(priv (make-array 32 :element-type '(unsigned-byte 64) :initial-element 0)
:type (simple-array (unsigned-byte 64) (32)))
;; the vertex queue: X Y in 12.4 less XYOFFSET, Z, colour RGBA (R low), Q S T, U V (12.4), fog
(vx (make-array 4 :element-type '(signed-byte 32) :initial-element 0) :type (simple-array (signed-byte 32) (4)))
(vy (make-array 4 :element-type '(signed-byte 32) :initial-element 0) :type (simple-array (signed-byte 32) (4)))
(vz (make-array 4 :element-type '(unsigned-byte 32) :initial-element 0) :type (simple-array (unsigned-byte 32) (4)))
(vc (make-array 4 :element-type '(unsigned-byte 32) :initial-element 0) :type (simple-array (unsigned-byte 32) (4)))
(vq (make-array 4 :element-type 'single-float :initial-element 1.0) :type (simple-array single-float (4)))
(vs (make-array 4 :element-type 'single-float :initial-element 0.0) :type (simple-array single-float (4)))
(vt (make-array 4 :element-type 'single-float :initial-element 0.0) :type (simple-array single-float (4)))
(vu (make-array 4 :element-type '(unsigned-byte 32) :initial-element 0) :type (simple-array (unsigned-byte 32) (4)))
(vv (make-array 4 :element-type '(unsigned-byte 32) :initial-element 0) :type (simple-array (unsigned-byte 32) (4)))
(vf (make-array 4 :element-type '(unsigned-byte 8) :initial-element 0) :type (simple-array (unsigned-byte 8) (4)))
(vn 0 :type (unsigned-byte 8)) ; vertices queued since the last primitive (or PRIM)
(vstrip 0 :type (unsigned-byte 32)) ; vertices of the strip or fan so far
(cur-c #x80000000 :type (unsigned-byte 32)) ; RGBAQ's colour
(cur-q 1.0 :type single-float) ; RGBAQ's Q
(cur-s 0.0 :type single-float)
(cur-t 0.0 :type single-float)
(cur-u 0 :type (unsigned-byte 32))
(cur-v 0 :type (unsigned-byte 32))
(cur-f 0 :type (unsigned-byte 8))
(packed-q 1.0 :type single-float) ; the Q of the last PACKED ST, for the next PACKED RGBAQ
;; transfers (xfer.lisp)
(xfer-dir 3 :type (unsigned-byte 8)) ; TRXDIR's XDIR: 0 host->local, 1 local->host, 2 local->local, 3 none
(xfer-x 0 :type (unsigned-byte 32)) ; the next pixel, relative to the rectangle's corner
(xfer-y 0 :type (unsigned-byte 32))
(xfer-acc 0 :type (unsigned-byte 64)) ; bits of an incomplete pixel (24-bit) not yet written
(xfer-bits 0 :type (unsigned-byte 8))
(clut (make-array 256 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (256)))
(cbp0 0 :type (unsigned-byte 32)) ; the CLUT base pointers CLD 2..5 compare with
(cbp1 0 :type (unsigned-byte 32))
(gfx (make-gfx) :type gfx)
;; counters
(draws 0 :type (unsigned-byte 64))
(prims 0 :type (unsigned-byte 64))
(pixels 0 :type (unsigned-byte 64))
(xfers 0 :type (unsigned-byte 64))
(events 0 :type (unsigned-byte 32))
(unknown 0 :type (unsigned-byte 32)))(defmacro gsm-csr) source(defmacro gsm-csr (g) `(aref (gsm-priv ,g) 16))(defmacro gsm-imr) source(defmacro gsm-imr (g) `(aref (gsm-priv ,g) 17))(defun gs-reset) source(defun gs-reset (g)
"the GS after a reset: registers zero, CSR's revision and id, IMR all masked, the queue empty"
(declare (type gsm g))
(let ((a (gsm-reg g))) (dotimes (i (length a)) (setf (aref a i) 0)))
(let ((a (gsm-priv g))) (dotimes (i (length a)) (setf (aref a i) 0)))
;; CSR: REV #x1B, ID #x55 (bits 16-23, 24-31), FIFO empty (14-15 = 1) [GSUM] "CSR"
(setf (gsm-csr g) #x551B4000 (gsm-imr g) #xFF00)
(setf (gsm-vn g) 0 (gsm-vstrip g) 0 (gsm-xfer-dir g) 3 (gsm-xfer-bits g) 0
(gsm-cur-c g) #x80000000 (gsm-cur-q g) 1.0 (gsm-packed-q g) 1.0)
nil)Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.