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

;; name: generic-tie-h.gc
;; name in dgo: generic-tie-h
;; dgos: ENGINE, GAME

;; DECOMP BEGINS

(deftype generic-tie-instance (structure)
  ((matrix-tag   dma-packet  :inline)
   (matrix-data  vector      6 :inline)
   (index-tag    dma-packet  :inline)
   (indices      uint8       224)
   (end-tag      dma-packet  :inline)
   )
  )


(deftype generic-tie-input (structure)
  ((palette-tag  dma-packet  :inline)
   (palette      rgba        128)
   (model-tag    dma-packet  :inline)
   (model        vector      146 :inline)
   (matrix-tag   dma-packet  :inline)
   (matrix-data  vector      6 :inline)
   (index-tag    dma-packet  :inline)
   (indices      uint8       224)
   (end-tag      dma-packet  :inline)
   )
  )


(deftype generic-tie-run-control (structure)
  ((skip-bp2     uint8)
   (skip-ips     uint8)
   (gifbuf-skip  uint8)
   (strips       uint8)
   (target-bp1   uint8)
   (target-bp2   uint8)
   (target-ip1   uint8)
   (target-ip2   uint8)
   (target-bps   uint8)
   (target-ips   uint8)
   (is-generic   uint8)
   (reserved     uint8)
   )
  )


(deftype generic-tie-base-point (structure)
  ((data  uint16   8)
   (quad  uint128  :overlay-at (-> data 0))
   (x     int16    :overlay-at (-> data 0))
   (y     int16    :overlay-at (-> data 1))
   (z     int16    :overlay-at (-> data 2))
   (d0    int16    :overlay-at (-> data 3))
   (vtx   uint64   :overlay-at (-> data 0))
   (u     int16    :overlay-at (-> data 4))
   (v     int16    :overlay-at (-> data 5))
   (tex   uint32   :overlay-at (-> data 4))
   (w     int16    :overlay-at (-> data 6))
   (d1    int16    :overlay-at (-> data 7))
   )
  )


(deftype generic-tie-bps (structure)
  ((bp  generic-tie-base-point  4 :inline)
   )
  )


(deftype generic-tie-interp-point (structure)
  ((data    uint16  12)
   (x       int16   :overlay-at (-> data 0))
   (y       int16   :overlay-at (-> data 1))
   (z       int16   :overlay-at (-> data 2))
   (d0      int16   :overlay-at (-> data 3))
   (vtx0    uint64  :overlay-at (-> data 0))
   (dx      int16   :overlay-at (-> data 4))
   (dy      int16   :overlay-at (-> data 5))
   (dz      int16   :overlay-at (-> data 6))
   (unused  int16   :overlay-at (-> data 7))
   (vtx1    uint64  :overlay-at (-> data 4))
   (u       int16   :overlay-at (-> data 8))
   (v       int16   :overlay-at (-> data 9))
   (tex     uint32  :overlay-at (-> data 8))
   (w       int16   :overlay-at (-> data 10))
   (d1      int16   :overlay-at (-> data 11))
   )
  :pack-me
  )


(deftype generic-tie-ips (structure)
  ((ip  generic-tie-interp-point  2 :inline)
   )
  )


(deftype generic-tie-header (structure)
  ((effect               uint8)
   (interp-table-size    uint8)
   (num-bps              uint8)
   (num-ips              uint8)
   (tint-color           uint32)
   (index-table-offset   uint16)
   (kick-table-offset    uint16)
   (normal-table-offset  uint16)
   (interp-table-offset  uint16)
   (gsf-header           gsf-header  :inline)
   )
  )


(deftype generic-tie-matrix (structure)
  ((matrix  matrix  :inline)
   (morph   vector  :inline)
   (fog     qword   :inline)
   )
  )


(deftype generic-tie-normal (structure)
  ((x      int8)
   (y      int8)
   (z      int8)
   (dummy  int8)
   )
  )


(deftype generic-tie-control (structure)
  ((ptr-palette    uint32)
   (ptr-shaders    uint32)
   (ptr-runctrl    generic-tie-run-control)
   (ptr-verts      uint32)
   (ptr-generic    generic-tie-header)
   (ptr-dps        uint32)
   (ptr-kicks      uint32)
   (ptr-normals    uint32)
   (ptr-interp     uint32)
   (ptr-mtxs       generic-tie-matrix)
   (ptr-cinds      uint32)
   (next-instance  uint32)
   (next-model     uint32)
   (next-is-model  uint32)
   (tie-type       uint32)
   )
  )


(deftype generic-tie-stats (structure)
  ((num-bps        uint32)
   (num-ips        uint32)
   (num-dps        uint32)
   (num-shaders    uint32)
   (num-models     uint32)
   (num-instances  uint32)
   (num-waits      uint32)
   (num-qwc        uint32)
   (max-qwc        uint32)
   )
  )


(deftype generic-tie-calls (structure)
  ((generic-prepare-dma-double  basic)
   (generic-envmap-dproc        basic)
   (generic-interp-dproc        basic)
   (generic-no-light-dproc      basic)
   )
  :pack-me
  )


(deftype generic-tie-shadow (structure)
  ((out-buf       gsf-buffer)
   (cur-buf       uint32)
   (tie-type      int32)
   (ptr-inst      uint32)
   (ptr-buf       uint32)
   (inst-xor      int32)
   (end-of-chain  uint32)
   (write-limit   uint32)
   (calls         generic-tie-calls  :inline)
   )
  :pack-me
  )


(deftype generic-tie-work (structure)
  ((control      generic-tie-control   :inline)
   (interp-job   generic-interp-job    :inline)
   (shadow       generic-tie-shadow    :inline)
   (input-a      generic-tie-input     :inline)
   (input-b      generic-tie-input     :inline)
   (inst-buf     generic-tie-instance  :inline)
   (palette-buf  rgba                  128)
   )
  )
