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

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

(define-extern update-eyes (function none))


;; DECOMP BEGINS

(deftype eye (structure)
  ((data         vector  2 :inline)
   (x            float   :overlay-at (-> data 0 data 0))
   (y            float   :overlay-at (-> data 0 data 1))
   (lid          float   :overlay-at (-> data 0 data 2))
   (iris-scale   float   :offset  16)
   (pupil-scale  float   :offset  20)
   (lid-scale    float   :offset  24)
   )
  )


(deftype eye-control (structure)
  ((process         handle)
   (draw-flag       symbol)
   (different-eyes  symbol)
   (random-time     uint16)
   (bucket          uint16)
   (blink           float)
   (shaders         (inline-array adgif-shader))
   (left            eye  :inline)
   (right           eye  :inline)
   )
  )


(deftype eye-control-array (basic)
  ((data  eye-control  16 :inline)
   )
  )


(deftype eye-control-arrays (basic)
  ((data  eye-control-array  6 :inline)
   (pad   uint32)
   )
  )


(deftype eye-work (structure)
  ((sprite-tmpl   dma-gif-packet  :inline)
   (sprite-tmpl2  dma-gif-packet  :inline)
   (adgif-tmpl    dma-gif-packet  :inline)
   (blink-table   float           10)
   )
  )


(define *eye-control-arrays*
  (new 'static 'eye-control-arrays :data (new 'static 'inline-array eye-control-array 6
                                           (new 'static 'eye-control-array)
                                           (new 'static 'eye-control-array)
                                           (new 'static 'eye-control-array)
                                           (new 'static 'eye-control-array)
                                           (new 'static 'eye-control-array)
                                           (new 'static 'eye-control-array)
                                           )
                                   )
  )

(dotimes (v1-6 6)
  (dotimes (a0-10 16)
    (let ((a1-14 (the-as eye-control (+ (+ (* 96 a0-10) 28 (* 1552 v1-6)) (the-as int *eye-control-arrays*)))))
      (set! (-> a1-14 process) (the-as handle #f))
      (set! (-> a1-14 draw-flag) #t)
      (set! (-> a1-14 shaders) (the-as (inline-array adgif-shader) #f))
      (set! (-> a1-14 random-time) (the-as uint 60))
      (set! (-> a1-14 blink) 0.0)
      )
    )
  )
