[gs] fill in most of the register types (#355)

* [gs] fill in most of the register types

that was kinda boring to do

* [display-h] minor decompiler fixes

* Update all-types.gc
This commit is contained in:
ManDude
2021-04-13 05:36:05 +01:00
committed by GitHub
parent a863542fa3
commit fcbf5b60ff
4 changed files with 627 additions and 144 deletions
+295 -49
View File
@@ -2743,17 +2743,23 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;; L139 - #x900000008
;; L138 -
;; L137 -
(deftype gs-pmode (uint64)
()
((en1 uint8 :offset 0 :size 1)
(en2 uint8 :offset 1 :size 1)
(crtmd uint8 :offset 2 :size 3)
(mmod uint8 :offset 5 :size 1)
(amod uint8 :offset 6 :size 1)
(slbg uint8 :offset 7 :size 1)
(alp uint8 :offset 8 :size 8)
)
:flag-assert #x900000008
)
(deftype gs-smode2 (uint64)
()
((int uint8 :offset 0 :size 1)
(ffmd uint8 :offset 1 :size 1)
(dpms uint8 :offset 2 :size 2)
)
:flag-assert #x900000008
)
@@ -2762,25 +2768,59 @@
(define-extern psm->string (function int string))
(deftype gs-display-fb (uint64)
()
((fbp uint16 :offset 0 :size 9)
(fbw uint8 :offset 9 :size 6)
(psm uint8 :offset 15 :size 5)
(dbx uint16 :offset 32 :size 11)
(dby uint16 :offset 43 :size 11)
)
:flag-assert #x900000008
)
;; the GS's DISPLAY registers make settings for the display position on the screen regarding
;; information on Rectangular Area Read Output Circuit n for the PCRTC.
;; write-only
(deftype gs-display (uint64)
()
((dx uint16 :offset 0 :size 12)
(dy uint16 :offset 12 :size 11)
(magh uint8 :offset 23 :size 4)
(magv uint8 :offset 27 :size 2)
(dw uint16 :offset 32 :size 12)
(dh uint16 :offset 44 :size 11)
)
:flag-assert #x900000008
)
;; the GS's BGCOLOR register sets the background color of the PCRTC with RGB value.
;; write-only
(deftype gs-bgcolor (uint64)
()
((r uint8 :offset 0 :size 8)
(g uint8 :offset 0 :size 8)
(b uint8 :offset 0 :size 8)
)
:flag-assert #x900000008
)
;; the GS's CSR register sets and obtains various GS statuses.
;; read-write. the fields have different effects depending on whether they're being read from
;; or written to.
;; bits 5 and 6 (0x20 and 0x40) should be zero
(deftype gs-csr (uint64)
()
((signal uint8 :offset 0 :size 1)
(finish uint8 :offset 1 :size 1)
(hsint uint8 :offset 2 :size 1)
(vsint uint8 :offset 3 :size 1)
(edwint uint8 :offset 4 :size 1)
(flush uint8 :offset 8 :size 1)
(reset uint8 :offset 9 :size 1)
(nfield uint8 :offset 12 :size 1)
(field uint8 :offset 13 :size 1)
(fifo uint8 :offset 14 :size 2)
(rev uint8 :offset 16 :size 8)
(id uint8 :offset 24 :size 8)
)
:flag-assert #x900000008
)
;; memory layout of the GS's privileged registers
;; it is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)
(deftype gs-bank (structure)
((pmode gs-pmode :offset-assert 0)
(smode2 gs-smode2 :offset 32)
@@ -2800,134 +2840,317 @@
:size-assert #x1048
:flag-assert #x900001048
)
;; the GS's FRAME registers store various settings related to the frame buffer.
(deftype gs-frame (uint64)
()
((fbp uint16 :offset 0 :size 9)
(fbw uint8 :offset 16 :size 6)
(psm uint8 :offset 24 :size 6)
(fbmsk uint32 :offset 32 :size 32)
)
:flag-assert #x900000008
)
;; the GS's ZBUF registers make various settings regarding Z buffer.
(deftype gs-zbuf (uint64)
()
((zbp uint16 :offset 0 :size 9)
(psm uint8 :offset 24 :size 4)
(zmsk uint8 :offset 32 :size 1)
)
:flag-assert #x900000008
)
;; the GS's XYOFFSET registers set the offset value for converting from the primitive coordinate
;; system to the window coordinate system.
(deftype gs-xy-offset (uint64)
()
((ofx uint16 :offset 0 :size 16)
(ofy uint16 :offset 32 :size 16)
)
:flag-assert #x900000008
)
;; the GS's SCISSOR registers specify the scissoring area. The coordinate values for
;; the upper-left/lower-right points of the enabled drawing area are specified by the window
;; coordinate system.
(deftype gs-scissor (uint64)
()
((scax0 uint16 :offset 0 :size 11)
(scax1 uint16 :offset 16 :size 11)
(scay0 uint16 :offset 32 :size 11)
(scay1 uint16 :offset 48 :size 11)
)
:flag-assert #x900000008
)
;; the GS's PRMODECONT register sets whether to use primitive attributes (IIP, TME, FGE, ABE,
;; AA1, FST, CTXT, FIX) specified by the PRMODE register or the PRIM register.
(deftype gs-prmode-cont (uint64)
()
((ac uint8 :offset 0 :size 1))
:flag-assert #x900000008
)
;; the GS's COLCLAMP register stores settings as to whether clamping for the RGB value of the
;; pixel is performed.
(deftype gs-color-clamp (uint64)
()
((clamp uint8 :offset 0 :size 1))
:flag-assert #x900000008
)
;; the GS's DTHE register stores settings for dithering (performed/not performed).
(deftype gs-dthe (uint64)
()
((dthe uint8 :offset 0 :size 1))
:flag-assert #x900000008
)
;; the GS's TEST register performs settings related to the pixel test.
(deftype gs-test (uint64)
()
((ate uint8 :offset 0 :size 1) ;; alpha test enable
(atst uint8 :offset 1 :size 3) ;; alpha test method
(aref uint8 :offset 4 :size 8) ;; alpha val reference
(afail uint8 :offset 12 :size 2) ;; processing method on alpha test fail
(date uint8 :offset 14 :size 1) ;; dest alpha test enable
(datm uint8 :offset 15 :size 1) ;; dest alpha test mode
(zte uint8 :offset 16 :size 1) ;; depth test enable
(ztst uint8 :offset 17 :size 2) ;; depth test method
)
:flag-assert #x900000008
)
;; the GS's PRIM register specifies the types of drawing primitives and various attributes, and
;; initializes the contents of the vertex queue.
(deftype gs-prim (uint64)
()
(;; type of primitive:
;; - 0: point
;; - 1: line
;; - 2: line strip
;; - 3: tri
;; - 4: tri strip
;; - 5: tri fan
;; - 6: sprite (what?)
;; - 7: dark magic?
(prim uint8 :offset 0 :size 3)
(iip uint8 :offset 3 :size 1)
(tme uint8 :offset 4 :size 1)
(fge uint8 :offset 5 :size 1)
(abe uint8 :offset 6 :size 1)
(aa1 uint8 :offset 7 :size 1)
(fst uint8 :offset 8 :size 1)
(ctxt uint8 :offset 9 :size 1)
(fix uint8 :offset 10 :size 1)
)
:flag-assert #x900000008
)
;; the GS's RGBAQ register sets the RGBA value of the vertex and the Q value of the normalized
;; texture coordinates.
(deftype gs-rgbaq (uint64)
()
((r uint8 :offset 0 :size 8)
(g uint8 :offset 8 :size 8)
(b uint8 :offset 16 :size 8)
(a uint8 :offset 24 :size 8) ;; 0x80 --> 1.0
(q float :offset 32 :size 32) ;; affects some LOD behavior apparently?
)
:flag-assert #x900000008
)
;; GS XYZ registers
(deftype gs-xyz (uint64)
()
((x uint16 :offset 0 :size 16) ;; Q4 fixed point
(y uint16 :offset 16 :size 16) ;; Q4 fixed point
(z uint32 :offset 32 :size 32)
)
:flag-assert #x900000008
)
;; the GS's UV register specifies the texel coordinate (UV) values of the vertex.
(deftype gs-uv (uint64)
()
((u uint16 :offset 0 :size 14) ;; Q4 fixed point
(v uint16 :offset 16 :size 14) ;; Q4 fixed point
)
:flag-assert #x900000008
)
;; the GS's ST register sets the S and T values of the vertex texture coordinates.
;; The value Q is specified by the RGBAQ register.
(deftype gs-st (uint64)
()
((s float :offset 0 :size 32)
(t float :offset 32 :size 32)
)
:flag-assert #x900000008
)
;; GS XYZF registers
(deftype gs-xyzf (uint64)
()
((x uint16 :offset 0 :size 16) ;; Q4 fixed point
(y uint16 :offset 16 :size 16) ;; Q4 fixed point
(z uint32 :offset 32 :size 24)
(f uint8 :offset 56 :size 8) ;; fog coeff
)
:flag-assert #x900000008
)
;; the GS's TRXPOS register specifies the position and scanning direction of the rectangular area
;; in each buffer where buffer transmission is performed.
(deftype gs-trxpos (uint64)
()
((ssax uint16 :offset 0 :size 11)
(ssay uint16 :offset 16 :size 11)
(dsax uint16 :offset 32 :size 11)
(dsay uint16 :offset 48 :size 11)
(dir uint8 :offset 59 :size 2)
)
:flag-assert #x900000008
)
;; the GS's TRXREG register specifies the size of the rectangular area, where the transmission
;; between buffers is implemented, in units of pixels.
;; The pixel mode must be the one set by the BITBLTBUF register.
(deftype gs-trxreg (uint64)
()
((rrw uint16 :offset 0 :size 12)
(rrh uint16 :offset 32 :size 12)
)
:flag-assert #x900000008
)
;; the GS's TRXDIR register specifies the transmission direction in the transmission between
;; buffers, and activates transmission.
;; Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating
;; the transmission.
(deftype gs-trxdir (uint64)
()
((xdir uint8 :offset 0 :size 2))
:flag-assert #x900000008
)
;; the GS's BITBLTBUF register stores buffer-related settings for transmission source and
;; destination during transmission between buffers.
(deftype gs-bitbltbuf (uint64)
()
((sbp uint16 :offset 0 :size 14)
(sbw uint8 :offset 16 :size 6)
(spsm uint8 :offset 24 :size 6)
(dbp uint16 :offset 32 :size 14)
(dbw uint8 :offset 48 :size 6)
(dpsm uint8 :offset 56 :size 6)
)
:flag-assert #x900000008
)
;; the GS's TEX0 registers set various kinds of information regarding the textures to be used.
(deftype gs-tex0 (uint64)
()
((tbp0 uint16 :offset 0 :size 14)
(tbw uint8 :offset 14 :size 6)
(psm uint8 :offset 20 :size 6)
(tw uint8 :offset 26 :size 4)
(th uint8 :offset 30 :size 4)
(tcc uint8 :offset 34 :size 1)
(tfx uint8 :offset 35 :size 2)
(cbp uint16 :offset 37 :size 14)
(cpsm uint8 :offset 51 :size 4)
(csm uint8 :offset 55 :size 1)
(csa uint8 :offset 56 :size 5)
(cld uint8 :offset 61 :size 3)
)
:flag-assert #x900000008
)
;; the GS's TEX1 registers set information on the sampling method of the textures.
(deftype gs-tex1 (uint64)
()
((lcm uint8 :offset 0 :size 1)
(mxl uint8 :offset 2 :size 3)
(mmag uint8 :offset 5 :size 1)
(mmin uint8 :offset 6 :size 3)
(mtba uint8 :offset 9 :size 1)
(l uint8 :offset 19 :size 2)
(k int16 :offset 32 :size 12)
)
:flag-assert #x900000008
)
;; the GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the
;; texture is not an 8-bit value.
(deftype gs-texa (uint64)
()
((ta0 uint8 :offset 0 :size 8)
(aem uint8 :offset 15 :size 1)
(ta1 uint8 :offset 32 :size 8)
)
:flag-assert #x900000008
)
;; the GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode
;; is CSM=1 (CSM2 mode).
(deftype gs-texclut (uint64)
()
((cbw uint8 :offset 0 :size 6)
(cou uint8 :offset 6 :size 6)
(cov uint16 :offset 12 :size 10)
)
:flag-assert #x900000008
)
;; the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing
;; MIPMAP.
;; MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6.
(deftype gs-miptbp (uint64)
()
((tbp1 uint16 :offset 0 :size 14)
(tbw1 uint8 :offset 14 :size 6)
(tbp2 uint16 :offset 20 :size 14)
(tbw2 uint8 :offset 34 :size 6)
(tbp3 uint16 :offset 40 :size 14)
(tbw3 uint8 :offset 54 :size 6)
)
:flag-assert #x900000008
)
;; the GS's ALPHA registers define the blend function of alpha blending
(deftype gs-alpha (uint64)
()
((a uint8 :offset 0 :size 2)
(b uint8 :offset 2 :size 2)
(c uint8 :offset 4 :size 2)
(d uint8 :offset 6 :size 2)
(fix uint8 :offset 32 :size 8)
)
:flag-assert #x900000008
)
(deftype gs-clamp (uint64)
((wms uint8 :offset 0 :size 2)
(wmt uint8 :offset 2 :size 2)
(minu uint16 :offset 4 :size 10)
(maxu uint16 :offset 14 :size 10)
(minv uint16 :offset 24 :size 10)
(maxv uint16 :offset 34 :size 10)
)
:flag-assert #x900000008
)
(deftype gs-fog (uint64)
()
((f uint8 :offset 56 :size 8))
:flag-assert #x900000008
)
(deftype gs-fogcol (uint64)
()
((fcr uint8 :offset 0 :size 8)
(fcg uint8 :offset 8 :size 8)
(fcb uint8 :offset 16 :size 8)
)
:flag-assert #x900000008
)
(deftype gif-ctrl (uint32)
()
((rst uint8 :offset 0 :size 1)
(pse uint8 :offset 3 :size 1)
)
:flag-assert #x900000004
)
(deftype gif-mode (uint32)
()
((m3r uint8 :offset 0 :size 1)
(imt uint8 :offset 2 :size 1)
)
:flag-assert #x900000004
)
(deftype gif-stat (uint32)
()
((m3r uint8 :offset 0 :size 1)
(m3p uint8 :offset 1 :size 1)
(imt uint8 :offset 2 :size 1)
(pse uint8 :offset 3 :size 1)
(ip3 uint8 :offset 5 :size 1)
(p3q uint8 :offset 6 :size 1)
(p2q uint8 :offset 7 :size 1)
(p1q uint8 :offset 8 :size 1)
(oph uint8 :offset 9 :size 1)
(apath uint8 :offset 10 :size 2)
(dir uint8 :offset 12 :size 1)
(fqc uint8 :offset 24 :size 5)
)
:flag-assert #x900000004
)
(deftype gif-cnt (uint32)
()
((loopcnt uint16 :offset 0 :size 15)
(regcnt uint8 :offset 16 :size 4)
(vuaddr uint16 :offset 20 :size 10)
)
:flag-assert #x900000004
)
(deftype gif-p3cnt (uint32)
()
((p3cnt uint16 :offset 0 :size 15))
:flag-assert #x900000004
)
(deftype gif-p3tag (uint32)
()
((loopcnt uint16 :offset 0 :size 15)
(eop uint8 :offset 15 :size 1)
)
:flag-assert #x900000004
)
@@ -2961,7 +3184,30 @@
:flag-assert #x900000008
)
(deftype gif-tag (uint128)
()
((nloop uint16 :offset 0 :size 15)
(eop uint8 :offset 15 :size 1)
(id uint16 :offset 32 :size 14)
(pre uint8 :offset 46 :size 1)
(prim uint16 :offset 47 :size 11)
(flg uint8 :offset 58 :size 2)
(nreg uint8 :offset 60 :size 4)
(regs0 uint8 :offset 64 :size 4)
(regs1 uint8 :offset 68 :size 4)
(regs2 uint8 :offset 72 :size 4)
(regs3 uint8 :offset 76 :size 4)
(regs4 uint8 :offset 80 :size 4)
(regs5 uint8 :offset 84 :size 4)
(regs6 uint8 :offset 88 :size 4)
(regs7 uint8 :offset 92 :size 4)
(regs8 uint8 :offset 96 :size 4)
(regs9 uint8 :offset 100 :size 4)
(regs10 uint8 :offset 104 :size 4)
(regs11 uint8 :offset 108 :size 4)
(regs12 uint8 :offset 112 :size 4)
(regs13 uint8 :offset 116 :size 4)
(regs14 uint8 :offset 120 :size 4)
(regs15 uint8 :offset 124 :size 4)
)
:flag-assert #x900000010
)
@@ -3113,9 +3359,9 @@
:flag-assert #x900000080
)
;;(define-extern *post-draw-hook* object) ;; unknown type
(define-extern *post-draw-hook* (function none)) ;; unknown type
(define-extern put-draw-env (function dma-packet none))
;;(define-extern *pre-draw-hook* object) ;; unknown type
(define-extern *pre-draw-hook* (function none)) ;; unknown type
(deftype display-frame (basic)
@@ -758,6 +758,15 @@
"args": ["allocation", "type-to-make", "psm", "w", "h", "ztest", "zpsm"],
"vars": { "gp-0": "obj" }
},
"(method 0 draw-context)": {
"args": ["allocation", "type-to-make", "org-x", "org-y", "width", "height", "color-0"],
"vars": { "v0-0": "obj"}
},
"draw-context-set-xy": {
"args": ["ctxt", "x", "y"]
},
"(method 9 __assert-info-private-struct)": {
"args": ["obj", "filename", "line-num", "column-num"]