;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")

;; VU1 renderers are enabled/disabled with a bitmask.

;; I believe this is renderers which can be enabled/disabled in the debug menu?

(defenum vu1-renderer-mask
  :bitfield #t
  (sky 3)
  (ocean 4)
  (ocean-wave 5)
  (tfrag 6)
  (tie-near 7)
  (tie 8)
  (generic 9)
  (merc 10)
  (shrubbery 11)
  (shrub-near 12)
  (billboard 13)
  (trans-shrubbery 14)
  (trans-tfrag 15)
  (sprite 16)
  (shadow 17)
  (depth-cue 18)
  (nineteen 19)
  (twenty 20))

;; DECOMP BEGINS

(define *vu1-enable-user-menu*
  (vu1-renderer-mask sky
                     ocean
                     ocean-wave
                     tfrag
                     tie-near
                     tie
                     generic
                     merc
                     shrubbery
                     shrub-near
                     billboard
                     trans-shrubbery
                     trans-tfrag
                     sprite
                     shadow
                     depth-cue
                     nineteen
                     twenty))

;; disable depth-cue by default for the PC port
(#when PC_PORT
  (logclear! *vu1-enable-user-menu* (vu1-renderer-mask depth-cue)))

;; by default, all off.
;; the menu renderers get copied to this on each frame
(define *vu1-enable-user* (the-as vu1-renderer-mask 0))

;; a dma "sink" is somewhere where a renderer can put stuff.
(deftype dma-foreground-sink (basic)
  ((bucket                   bucket-id)
   (foreground-texture-page  int8)
   (foreground-texture-level int8)
   (foreground-output-bucket int8)))

;; additional info for the generic renderer
(deftype generic-bucket-state (structure)
  ((gifbuf-adr uint32)
   (inbuf-adr  uint32))
  :pack-me)

;; sink for the generic renderer, a normal sink + extra data.
(deftype generic-dma-foreground-sink (dma-foreground-sink)
  ((state generic-bucket-state :inline)))

;; group of sinks used for the foreground renderers.
(declare-type level basic)

(deftype dma-foreground-sink-group (basic)
  ((sink         dma-foreground-sink 3)
   (merc-sink    dma-foreground-sink :overlay-at (-> sink 0))
   (generic-sink generic-dma-foreground-sink :overlay-at (-> sink 1))
   (level        level)))
