;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
(#when PC_BIG_MEMORY
  (defconstant SPRITE_MAX_AMOUNT_MULT 12))

;; DECOMP BEGINS

(deftype sprite-vec-data-2d (structure)
  ((x-y-z-sx    vector :inline)
   (flag-rot-sy vector :inline)
   (r-g-b-a     vector :inline)
   (x           float :overlay-at (-> x-y-z-sx x))
   (y           float :overlay-at (-> x-y-z-sx y))
   (z           float :overlay-at (-> x-y-z-sx z))
   (sx          float :overlay-at (-> x-y-z-sx w))
   (sy          float :overlay-at (-> flag-rot-sy w))
   (rot         float :overlay-at (-> flag-rot-sy z))
   (flag        int32 :overlay-at (-> flag-rot-sy x))
   (matrix      int32 :overlay-at (-> flag-rot-sy y))
   (warp-turns  int32 :overlay-at (-> flag-rot-sy x))
   (r           float :overlay-at (-> r-g-b-a x))
   (g           float :overlay-at (-> r-g-b-a y))
   (b           float :overlay-at (-> r-g-b-a z))
   (a           float :overlay-at (-> r-g-b-a w))
   (trans       vector3s :inline :overlay-at (-> x-y-z-sx x))
   (color       rgbaf :inline :overlay-at (-> r-g-b-a x))
   (data        uint128 1 :overlay-at (-> x-y-z-sx quad))
   (data64      uint64 6 :overlay-at (-> x-y-z-sx x))))

(deftype sprite-array-2d (basic)
  ((num-sprites int32 2)
   (num-valid   int32 2)
   (vec-data    pointer)
   (adgif-data  (inline-array adgif-shader))
   (pad         uint128 4)
   (data        uint128 1))
  (:methods
   (new (symbol type int int) _type_)))

(deftype sprite-vec-data-3d (structure)
  ((x-y-z-sx    vector :inline)
   (qx-qy-qz-sy vector :inline)
   (r-g-b-a     vector :inline)
   (x           float :overlay-at (-> x-y-z-sx x))
   (y           float :overlay-at (-> x-y-z-sx y))
   (z           float :overlay-at (-> x-y-z-sx z))
   (sx          float :overlay-at (-> x-y-z-sx w))
   (sy          float :overlay-at (-> qx-qy-qz-sy w))
   (qx          float :overlay-at (-> qx-qy-qz-sy x))
   (qy          float :overlay-at (-> qx-qy-qz-sy y))
   (qz          float :overlay-at (-> qx-qy-qz-sy z))
   (r           float :overlay-at (-> r-g-b-a x))
   (g           float :overlay-at (-> r-g-b-a y))
   (b           float :overlay-at (-> r-g-b-a z))
   (a           float :overlay-at (-> r-g-b-a w))
   (trans       vector3s :inline :overlay-at (-> x-y-z-sx x))
   (rot         vector3s :inline :overlay-at (-> qx-qy-qz-sy x))
   (color       rgbaf :inline :overlay-at (-> r-g-b-a x))
   (data        uint128 1 :overlay-at (-> x-y-z-sx quad))))

(deftype sprite-array-3d (basic)
  ((num-sprites int32 2)
   (num-valid   int32 2)
   (vec-data    pointer)
   (adgif-data  (inline-array adgif-shader))
   (data        uint128 1))
  (:methods
   (new (symbol type int int) _type_)))

(define-extern sprite-init-distorter (function dma-buffer uint none))

(define-extern sprite-draw-distorters (function dma-buffer none))

(define-extern sprite-vu1-block vu-function)
