;;-*-Lisp-*-
(in-package goal)

;; definition of type gs-pmode
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-smode2
(deftype gs-smode2 (uint64)
  ((int  uint8 :offset   0 :size   1)
   (ffmd uint8 :offset   1 :size   1)
   (dpms uint8 :offset   2 :size   2)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for function psm-size
(defun psm-size ((arg0 gs-psm))
  (cond
    ((= arg0 (gs-psm mt8))
     64
     )
    ((= arg0 (gs-psm mt4))
     32
     )
    ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s)))
     128
     )
    (else
      256
      )
    )
  )

;; definition for function psm-page-height
(defun psm-page-height ((arg0 gs-psm))
  (cond
    ((= arg0 (gs-psm mt8))
     64
     )
    ((= arg0 (gs-psm mt4))
     128
     )
    ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s)))
     64
     )
    (else
      32
      )
    )
  )

;; definition for function psm->string
(defun psm->string ((arg0 gs-psm))
  (case arg0
    (((gs-psm mz16s))
     "mz16s"
     )
    (((gs-psm mz16))
     "mz16"
     )
    (((gs-psm mz24))
     "mz24"
     )
    (((gs-psm mz32))
     "mz32"
     )
    (((gs-psm mt4hh))
     "mt4hh"
     )
    (((gs-psm mt4hl))
     "mt4hl"
     )
    (((gs-psm mt8h))
     "mt8h"
     )
    (((gs-psm mt4))
     "mt4"
     )
    (((gs-psm mt8))
     "mt8"
     )
    (((gs-psm ct16s))
     "ct16s"
     )
    (((gs-psm ct16))
     "ct16"
     )
    (((gs-psm ct24))
     "ct24"
     )
    (((gs-psm ct32))
     "ct32"
     )
    (else
      "*unknown*"
      )
    )
  )

;; definition of type gs-display-fb
(deftype gs-display-fb (uint64)
  ((fbp uint16 :offset   0 :size   9)
   (fbw uint8  :offset   9 :size   6)
   (psm gs-psm :offset  15 :size   5)
   (dbx uint16 :offset  32 :size  11)
   (dby uint16 :offset  43 :size  11)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-display
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-bgcolor
(deftype gs-bgcolor (uint64)
  ((r uint8 :offset   0 :size   8)
   (g uint8 :offset   8 :size   8)
   (b uint8 :offset  16 :size   8)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-csr
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-bank
(deftype gs-bank (structure)
  ((pmode    gs-pmode       :offset-assert   0)
   (smode2   gs-smode2      :offset         32)
   (dspfb1   gs-display-fb  :offset        112)
   (display1 gs-display     :offset        128)
   (dspfb2   gs-display-fb  :offset        144)
   (display2 gs-display     :offset        160)
   (extbuf   uint64         :offset        176)
   (extdata  uint64         :offset        192)
   (extwrite uint64         :offset        208)
   (bgcolor  gs-bgcolor     :offset        224)
   (csr      gs-csr         :offset        4096)
   (imr      uint64         :offset        4112)
   (busdir   uint64         :offset        4160)
   )
  :method-count-assert 9
  :size-assert         #x1048
  :flag-assert         #x900001048
  )

;; definition for method 3 of type gs-bank
(defmethod inspect gs-bank ((obj gs-bank))
  (format #t "[~8x] ~A~%" obj 'gs-bank)
  (format #t "~Tpmode: #x~X~%" (-> obj pmode))
  (format #t "~Tsmode2: #x~X~%" (-> obj smode2))
  (format #t "~Tdspfb1: #x~X~%" (-> obj dspfb1))
  (format #t "~Tdisplay1: #x~X~%" (-> obj display1))
  (format #t "~Tdspfb2: #x~X~%" (-> obj dspfb2))
  (format #t "~Tdisplay2: #x~X~%" (-> obj display2))
  (format #t "~Textbuf: #x~X~%" (-> obj extbuf))
  (format #t "~Textdata: #x~X~%" (-> obj extdata))
  (format #t "~Textwrite: #x~X~%" (-> obj extwrite))
  (format #t "~Tbgcolor: #x~X~%" (-> obj bgcolor))
  (format #t "~Tcsr: #x~X~%" (-> obj csr))
  (format #t "~Timr: #x~X~%" (-> obj imr))
  (format #t "~Tbusdir: #x~X~%" (-> obj busdir))
  obj
  )

;; definition of type gs-frame
(deftype gs-frame (uint64)
  ((fbp   uint16 :offset   0 :size   9)
   (fbw   uint8  :offset  16 :size   6)
   (psm   gs-psm :offset  24 :size   6)
   (fbmsk uint32 :offset  32 :size  32)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-zbuf
(deftype gs-zbuf (uint64)
  ((zbp  uint16 :offset   0 :size   9)
   (psm  gs-psm :offset  24 :size   4)
   (zmsk uint8  :offset  32 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-xy-offset
(deftype gs-xy-offset (uint64)
  ((ofx uint16 :offset   0 :size  16)
   (ofy uint16 :offset  32 :size  16)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-scissor
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-prmode-cont
(deftype gs-prmode-cont (uint64)
  ((ac uint8 :offset   0 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-color-clamp
(deftype gs-color-clamp (uint64)
  ((clamp uint8 :offset   0 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-dthe
(deftype gs-dthe (uint64)
  ((dthe uint8 :offset   0 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-test
(deftype gs-test (uint64)
  ((ate   uint8    :offset   0 :size   1)
   (atst  gs-atest :offset   1 :size   3)
   (aref  uint8    :offset   4 :size   8)
   (afail uint8    :offset  12 :size   2)
   (date  uint8    :offset  14 :size   1)
   (datm  uint8    :offset  15 :size   1)
   (zte   uint8    :offset  16 :size   1)
   (ztst  gs-ztest :offset  17 :size   2)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-prim
(deftype gs-prim (uint64)
  ((prim gs-prim-type :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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-rgbaq
(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)
   (q float :offset  32 :size  32)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-xyz
(deftype gs-xyz (uint64)
  ((x uint16 :offset   0 :size  16)
   (y uint16 :offset  16 :size  16)
   (z uint32 :offset  32 :size  32)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-uv
(deftype gs-uv (uint64)
  ((u uint16 :offset   0 :size  14)
   (v uint16 :offset  16 :size  14)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-st
(deftype gs-st (uint64)
  ((s float :offset   0 :size  32)
   (t float :offset  32 :size  32)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-xyzf
(deftype gs-xyzf (uint64)
  ((x uint16 :offset   0 :size  16)
   (y uint16 :offset  16 :size  16)
   (z uint32 :offset  32 :size  24)
   (f uint8  :offset  56 :size   8)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-trxpos
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-trxreg
(deftype gs-trxreg (uint64)
  ((rrw uint16 :offset   0 :size  12)
   (rrh uint16 :offset  32 :size  12)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-trxdir
(deftype gs-trxdir (uint64)
  ((xdir uint8 :offset   0 :size   2)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-bitbltbuf
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-tex0
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-tex1
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-texa
(deftype gs-texa (uint64)
  ((ta0 uint8 :offset   0 :size   8)
   (aem uint8 :offset  15 :size   1)
   (ta1 uint8 :offset  32 :size   8)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-texclut
(deftype gs-texclut (uint64)
  ((cbw uint8  :offset   0 :size   6)
   (cou uint8  :offset   6 :size   6)
   (cov uint16 :offset  12 :size  10)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-miptbp
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-alpha
(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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for method 3 of type gs-alpha
(defmethod inspect gs-alpha ((obj gs-alpha))
  (format #t "[~8x] ~A~%" obj 'gs-alpha)
  (format #t "~Ta: ~D~%" (-> obj a))
  (format #t "~Tb: ~D~%" (-> obj b))
  (format #t "~Tc: ~D~%" (-> obj c))
  (format #t "~Td: ~D~%" (-> obj d))
  (format #t "~Tfix: ~D~%" (-> obj fix))
  obj
  )

;; definition of type gs-clamp
(deftype gs-clamp (uint64)
  ((wms  gs-tex-wrap-mode :offset   0 :size   2)
   (wmt  gs-tex-wrap-mode :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)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gs-fog
(deftype gs-fog (uint64)
  ((f uint8 :offset  56 :size   8)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for method 3 of type gs-fog
(defmethod inspect gs-fog ((obj gs-fog))
  (format #t "[~8x] ~A~%" obj 'gs-fog)
  (format #t "~Tf: ~D~%" (-> obj f))
  obj
  )

;; definition of type gs-fogcol
(deftype gs-fogcol (uint64)
  ((fcr uint8 :offset   0 :size   8)
   (fcg uint8 :offset   8 :size   8)
   (fcb uint8 :offset  16 :size   8)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for method 3 of type gs-fogcol
(defmethod inspect gs-fogcol ((obj gs-fogcol))
  (format #t "[~8x] ~A~%" obj 'gs-fogcol)
  (format #t "~Tr: ~D~%" (-> obj fcr))
  (format #t "~Tg: ~D~%" (-> obj fcg))
  (format #t "~Tb: ~D~%" (-> obj fcb))
  obj
  )

;; definition of type gif-ctrl
(deftype gif-ctrl (uint32)
  ((rst uint8 :offset   0 :size   1)
   (pse uint8 :offset   3 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-mode
(deftype gif-mode (uint32)
  ((m3r uint8 :offset   0 :size   1)
   (imt uint8 :offset   2 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-stat
(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)
   )
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-cnt
(deftype gif-cnt (uint32)
  ((loopcnt uint16 :offset   0 :size  15)
   (regcnt  uint8  :offset  16 :size   4)
   (vuaddr  uint16 :offset  20 :size  10)
   )
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-p3cnt
(deftype gif-p3cnt (uint32)
  ((p3cnt uint16 :offset   0 :size  15)
   )
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-p3tag
(deftype gif-p3tag (uint32)
  ((loopcnt uint16 :offset   0 :size  15)
   (eop     uint8  :offset  15 :size   1)
   )
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-bank
(deftype gif-bank (structure)
  ((ctrl  gif-ctrl   :offset   0)
   (mode  gif-mode   :offset  16)
   (stat  gif-stat   :offset  32)
   (tag0  uint32     :offset  64)
   (tag1  uint32     :offset  80)
   (tag2  uint32     :offset  96)
   (tag3  uint32     :offset 112)
   (cnt   gif-cnt    :offset 128)
   (p3cnt gif-p3cnt  :offset 144)
   (p3tag gif-p3tag  :offset 160)
   )
  :method-count-assert 9
  :size-assert         #xa4
  :flag-assert         #x9000000a4
  )

;; definition for method 3 of type gif-bank
(defmethod inspect gif-bank ((obj gif-bank))
  (format #t "[~8x] ~A~%" obj 'gif-bank)
  (format #t "~Tctrl: #x~X~%" (-> obj ctrl))
  (format #t "~Tmode: #x~X~%" (-> obj mode))
  (format #t "~Tstat: #x~X~%" (-> obj stat))
  (format #t "~Ttag0: #x~X~%" (-> obj tag0))
  (format #t "~Ttag1: #x~X~%" (-> obj tag1))
  (format #t "~Ttag2: #x~X~%" (-> obj tag2))
  (format #t "~Ttag3: #x~X~%" (-> obj tag3))
  (format #t "~Tcnt: #x~X~%" (-> obj cnt))
  (format #t "~Tp3cnt: #x~X~%" (-> obj p3cnt))
  (format #t "~Tp3tag: #x~X~%" (-> obj p3tag))
  obj
  )

;; definition of type gif-tag-prim
(deftype gif-tag-prim (uint32)
  ()
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-tag-count
(deftype gif-tag-count (uint32)
  ()
  :method-count-assert 9
  :size-assert         #x4
  :flag-assert         #x900000004
  )

;; definition of type gif-tag64
(deftype gif-tag64 (uint64)
  ((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  gs-prim  :offset  47 :size  11)
   (flg   gif-flag :offset  58 :size   2)
   (nreg  uint8    :offset  60 :size   4)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition of type gif-tag
(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    gif-flag   :offset  58 :size   2)
   (nreg   uint8      :offset  60 :size   4)
   (regs0  gif-reg-id :offset  64 :size   4)
   (regs1  gif-reg-id :offset  68 :size   4)
   (regs2  gif-reg-id :offset  72 :size   4)
   (regs3  gif-reg-id :offset  76 :size   4)
   (regs4  gif-reg-id :offset  80 :size   4)
   (regs5  gif-reg-id :offset  84 :size   4)
   (regs6  gif-reg-id :offset  88 :size   4)
   (regs7  gif-reg-id :offset  92 :size   4)
   (regs8  gif-reg-id :offset  96 :size   4)
   (regs9  gif-reg-id :offset 100 :size   4)
   (regs10 gif-reg-id :offset 104 :size   4)
   (regs11 gif-reg-id :offset 108 :size   4)
   (regs12 gif-reg-id :offset 112 :size   4)
   (regs13 gif-reg-id :offset 116 :size   4)
   (regs14 gif-reg-id :offset 120 :size   4)
   (regs15 gif-reg-id :offset 124 :size   4)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition of type gs-gif-tag
(deftype gs-gif-tag (structure)
  ((qword uint128        :offset-assert   0)
   (tag   gif-tag64      :offset          0)
   (regs  gif-tag-regs   :offset          8)
   (dword uint64       2 :offset          0)
   (word  uint32       4 :offset          0)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition for method 3 of type gs-gif-tag
(defmethod inspect gs-gif-tag ((obj gs-gif-tag))
  (format #t "[~8x] ~A~%" obj 'gs-gif-tag)
  (format #t "~Tqword: #<qword @ #x~X>~%" (&-> obj tag))
  (format #t "~Tdword[2] @ #x~X~%" (&-> obj tag))
  (format #t "~Tword[4] @ #x~X~%" (&-> obj tag))
  (format #t "~Ttag: ~D~%" (-> obj tag))
  (format #t "~Tregs: ~D~%" (-> obj regs))
  obj
  )

;; definition for method 3 of type gif-tag
;; INFO: Return type mismatch object vs gif-tag.
(defmethod inspect gif-tag ((obj gif-tag))
  (format #t "[~8x] gif-tag~%" obj)
  (format #t "~Tnloop: ~4d~%" (-> obj nloop))
  (format #t "~Teop  : ~4d~%" (-> obj eop))
  (format #t "~Tid   : ~4d~%" (-> obj id))
  (format #t "~Tpre  : ~4d~%" (-> obj pre))
  (format #t "~Tprim : ~4d~%" (-> obj prim))
  (format #t "~Tflg  : ~4d~%" (-> obj flg))
  (format #t "~Tnreg : ~4d~%" (-> obj nreg))
  (format #t "~Tregs0 : ~4d~%" (-> obj regs0))
  (format #t "~Tregs1 : ~4d~%" (-> obj regs1))
  (format #t "~Tregs2 : ~4d~%" (-> obj regs2))
  (format #t "~Tregs3 : ~4d~%" (-> obj regs3))
  (format #t "~Tregs4 : ~4d~%" (-> obj regs4))
  (format #t "~Tregs5 : ~4d~%" (-> obj regs5))
  (format #t "~Tregs6 : ~4d~%" (-> obj regs6))
  (format #t "~Tregs7 : ~4d~%" (-> obj regs7))
  (format #t "~Tregs8 : ~4d~%" (-> obj regs8))
  (format #t "~Tregs9 : ~4d~%" (-> obj regs9))
  (format #t "~Tregs10: ~4d~%" (-> obj regs10))
  (format #t "~Tregs11: ~4d~%" (-> obj regs11))
  (format #t "~Tregs12: ~4d~%" (-> obj regs12))
  (format #t "~Tregs13: ~4d~%" (-> obj regs13))
  (format #t "~Tregs14: ~4d~%" (-> obj regs14))
  (the-as gif-tag (format #t "~Tregs15: ~4d~%" (-> obj regs15)))
  )

;; definition for symbol *fog-color*, type rgba
(define *fog-color* (new 'static 'rgba :r #x29 :g #x80 :b #xc8))

;; definition for symbol *default-regs-buffer*, type dma-buffer
(define *default-regs-buffer* (new 'global 'dma-buffer 1024))

;; definition for function default-buffer-init
;; INFO: Return type mismatch pointer vs none.
(defun default-buffer-init ((buff dma-buffer))
  (let ((buff-ptr buff))
    (set! (-> buff-ptr base) (-> buff-ptr data))
    (set! (-> buff-ptr end) (&-> buff-ptr data-buffer (-> buff-ptr allocated-length)))
    )
  (let* ((buff-ptr2 buff)
         (packet (the-as dma-gif-packet (-> buff-ptr2 base)))
         )
    (set! (-> packet dma-vif dma) (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt)))
    (set! (-> packet dma-vif vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1))
    (set! (-> packet dma-vif vif1) (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1))
    (set! (-> buff-ptr2 base) (&+ (the-as pointer packet) 16))
    )
  (let* ((buff-ptr5 buff)
         (gif-tag (the-as gs-gif-tag (-> buff-ptr5 base)))
         )
    (set! (-> gif-tag tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x9))
    (set! (-> gif-tag regs)
          (new 'static 'gif-tag-regs
            :regs0 (gif-reg-id a+d)
            :regs1 (gif-reg-id a+d)
            :regs2 (gif-reg-id a+d)
            :regs3 (gif-reg-id a+d)
            :regs4 (gif-reg-id a+d)
            :regs5 (gif-reg-id a+d)
            :regs6 (gif-reg-id a+d)
            :regs7 (gif-reg-id a+d)
            :regs8 (gif-reg-id a+d)
            :regs9 (gif-reg-id a+d)
            :regs10 (gif-reg-id a+d)
            :regs11 (gif-reg-id a+d)
            :regs12 (gif-reg-id a+d)
            :regs13 (gif-reg-id a+d)
            :regs14 (gif-reg-id a+d)
            :regs15 (gif-reg-id a+d)
            )
          )
    (set! (-> buff-ptr5 base) (&+ (the-as pointer gif-tag) 16))
    )
  (let* ((buff-ptr3 buff)
         (data (the-as (pointer uint64) (-> buff-ptr3 base)))
         )
    (set! (-> (the-as (pointer gs-alpha) data) 0) (new 'static 'gs-alpha :b #x1 :d #x1))
    (set! (-> (the-as (pointer gs-reg64) data) 1) (gs-reg64 alpha-1))
    (set! (-> (the-as (pointer gs-zbuf) data) 2) (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24)))
    (set! (-> (the-as (pointer gs-reg64) data) 3) (gs-reg64 zbuf-1))
    (set! (-> (the-as (pointer gs-test) data) 4)
          (new 'static 'gs-test :atst (gs-atest not-equal) :zte #x1 :ztst (gs-ztest greater-equal))
          )
    (set! (-> (the-as (pointer gs-reg64) data) 5) (gs-reg64 test-1))
    (set! (-> data 6) (the-as uint 0))
    (set! (-> (the-as (pointer gs-reg64) data) 7) (gs-reg64 pabe))
    (set! (-> (the-as (pointer gs-clamp) data) 8)
          (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))
          )
    (set! (-> (the-as (pointer gs-reg64) data) 9) (gs-reg64 clamp-1))
    (set! (-> (the-as (pointer gs-tex1) data) 10) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
    (set! (-> (the-as (pointer gs-reg64) data) 11) (gs-reg64 tex1-1))
    (set! (-> (the-as (pointer gs-texa) data) 12) (new 'static 'gs-texa :ta1 #x80))
    (set! (-> (the-as (pointer gs-reg64) data) 13) (gs-reg64 texa))
    (set! (-> (the-as (pointer gs-texclut) data) 14) (new 'static 'gs-texclut :cbw #x4))
    (set! (-> (the-as (pointer gs-reg64) data) 15) (gs-reg64 texclut))
    (set! (-> (the-as (pointer gs-fogcol) data) 16) (the-as gs-fogcol *fog-color*))
    (set! (-> (the-as (pointer gs-reg64) data) 17) (gs-reg64 fogcol))
    (set! (-> buff-ptr3 base) (&+ (the-as pointer data) 144))
    )
  (let* ((buff-ptr4 buff)
         (ret-packet (the-as dma-packet (-> buff-ptr4 base)))
         )
    (set! (-> ret-packet dma) (new 'static 'dma-tag :id (dma-tag-id ret)))
    (set! (-> ret-packet vif0) (new 'static 'vif-tag))
    (set! (-> ret-packet vif1) (new 'static 'vif-tag))
    (set! (-> buff-ptr4 base) (&+ (the-as pointer ret-packet) 16))
    )
  (none)
  )

;; failed to figure out what this is:
(default-buffer-init *default-regs-buffer*)

;; definition of type gif-packet
(deftype gif-packet (basic)
  ((reg-count int32              :offset-assert   4)
   (gif-tag   gs-gif-tag :inline :offset-assert  16)
   (gif-tag0  uint128            :offset         16)
   (args      uint64     1       :offset-assert  32)
   )
  :method-count-assert 9
  :size-assert         #x28
  :flag-assert         #x900000028
  (:methods
    (new (symbol type int) _type_ 0)
    )
  )

;; definition for method 3 of type gif-packet
;; Used lq/sq
(defmethod inspect gif-packet ((obj gif-packet))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Treg-count: ~D~%" (-> obj reg-count))
  (format #t "~Tgif-tag0: #x~X~%" (-> obj gif-tag0))
  (format #t "~Targs[1] @ #x~X~%" (-> obj args))
  obj
  )

;; definition for method 0 of type gif-packet
(defmethod new gif-packet ((allocation symbol) (type-to-make type) (arg0 int))
  (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 8))))
  )

;; definition for function open-gif-packet
(defun open-gif-packet ((arg0 gif-packet))
  (set! (-> arg0 reg-count) 0)
  (set! (-> arg0 gif-tag regs) (new 'static 'gif-tag-regs))
  arg0
  )

;; definition for function add-reg-gif-packet
;; INFO: Return type mismatch gif-packet vs none.
(defun add-reg-gif-packet ((packet gif-packet) (reg-idx int) (reg-val int))
  (let ((tag (-> packet gif-tag)))
    (logior! (-> tag regs) (ash reg-idx (* (-> packet reg-count) 4)))
    )
  (set! (-> (&-> packet args (-> packet reg-count)) 0) (the-as uint reg-val))
  (+! (-> packet reg-count) 1)
  (none)
  )

;; definition for function close-gif-packet
(defun close-gif-packet ((arg0 gif-packet) (arg1 int))
  (set! (-> arg0 gif-tag tag)
        (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :eop arg1 :nreg (-> arg0 reg-count))
        )
  arg0
  )

;; definition of type draw-context
(deftype draw-context (basic)
  ((orgx   int32   :offset-assert   4)
   (orgy   int32   :offset-assert   8)
   (orgz   int32   :offset-assert  12)
   (width  int32   :offset-assert  16)
   (height int32   :offset-assert  20)
   (color  rgba  4 :offset-assert  24)
   )
  :method-count-assert 9
  :size-assert         #x28
  :flag-assert         #x900000028
  (:methods
    (new (symbol type int int int int rgba) _type_ 0)
    )
  )

;; definition for method 3 of type draw-context
(defmethod inspect draw-context ((obj draw-context))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Torgx: ~D~%" (-> obj orgx))
  (format #t "~Torgy: ~D~%" (-> obj orgy))
  (format #t "~Torgz: ~D~%" (-> obj orgz))
  (format #t "~Twidth: ~D~%" (-> obj width))
  (format #t "~Theight: ~D~%" (-> obj height))
  (format #t "~Tcolor[4] @ #x~X~%" (-> obj color))
  obj
  )

;; definition for method 0 of type draw-context
(defmethod new draw-context ((allocation symbol) (type-to-make type) (org-x int) (org-y int) (width int) (height int) (color-0 rgba))
  (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
    (let ((v1-3 (the int (* (the float org-y) (-> *video-parms* relative-y-scale))))
          (a0-2 (the int (* (the float height) (-> *video-parms* relative-y-scale))))
          )
      (set! (-> obj orgx) org-x)
      (set! (-> obj orgy) v1-3)
      (set! (-> obj orgz) #xffffff)
      (set! (-> obj width) width)
      (set! (-> obj height) a0-2)
      )
    (set! (-> obj color 0) color-0)
    obj
    )
  )

;; definition for function draw-context-set-xy
;; INFO: Return type mismatch int vs none.
(defun draw-context-set-xy ((ctxt draw-context) (x int) (y int))
  (let ((v0-0 (the int (* (the float y) (-> *video-parms* relative-y-scale)))))
    (set! (-> ctxt orgx) x)
    (set! (-> ctxt orgy) v0-0)
    )
  (none)
  )
