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

;; name: ocean-texture.gc
;; name in dgo: ocean-texture
;; dgos: GAME

;; DECOMP BEGINS

(define ocean-texture-vu1-block (new 'static 'vu-function #|:length #x7c :qlength 62|#))

(defmethod ocean-texture-setup-constants ((this ocean) (arg0 ocean-texture-constants))
  (set! (-> arg0 giftag tag)
        (new 'static 'gif-tag64
          :nloop #x42
          :eop #x1
          :pre #x1
          :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1)
          :nreg #x3
          )
        )
  (set! (-> arg0 giftag regs)
        (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyz2))
        )
  (set-vector! (-> arg0 buffers) 384 583 384 583)
  (set-vector! (-> arg0 dests) 782 881 782 881)
  (set-vector! (-> arg0 start) 0.0 0.0 1048575.94 0.0)
  (set-vector! (-> arg0 offsets) 4.0 8.0 12.0 16.0)
  (set-vector! (-> arg0 constants) 0.5 0.5 0.0 128.0)
  (set! (-> arg0 cam-nrm x) 0.0)
  (set! (-> arg0 cam-nrm y) 0.707)
  (set! (-> arg0 cam-nrm z) 0.707)
  (set! (-> arg0 cam-nrm w) 0.0)
  0
  (none)
  )

(defmethod ocean-texture-add-constants ((this ocean) (arg0 dma-buffer))
  (let* ((a2-0 7)
         (v1-0 arg0)
         (a1-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a1-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a2-0))
    (set! (-> (the-as dma-packet a1-1) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a1-1) vif1)
          (new 'static 'vif-tag :imm #x3d9 :cmd (vif-cmd unpack-v4-32) :num a2-0)
          )
    (set! (-> v1-0 base) (&+ (the-as pointer a1-1) 16))
    )
  (ocean-texture-setup-constants this (the-as ocean-texture-constants (-> arg0 base)))
  (&+! (-> arg0 base) 112)
  0
  (none)
  )

(defmethod ocean-texture-add-envmap ((this ocean) (arg0 dma-buffer))
  (let ((v1-0 (the-as object (-> arg0 base))))
    (set! (-> (the-as (inline-array vector4w) v1-0) 0 quad) (-> this adgif-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-0) 1 quad) (-> this adgif-tmpl quad 1))
    (let ((s4-0 (&+ (the-as pointer v1-0) 32)))
      (adgif-shader<-texture-simple!
        (the-as adgif-shader s4-0)
        (get-texture environment-ocean-alphamod sky-textures)
        )
      )
    )
  (&+! (-> arg0 base) 112)
  0
  (none)
  )

(defmethod ocean-texture-add-verts ((this ocean) (arg0 dma-buffer) (arg1 int))
  (let* ((v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :qwc #xc0 :id (dma-tag-id ref) :addr arg1))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a0-1) vif1)
          (new 'static 'vif-tag :imm #x8000 :num #xc0 :cmd (vif-cmd unpack-v4-32))
          )
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  0
  (none)
  )

(defmethod ocean-texture-add-verts-last ((this ocean) (arg0 dma-buffer) (arg1 int) (arg2 int))
  (let* ((v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :qwc #x80 :id (dma-tag-id ref) :addr arg1))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a0-1) vif1)
          (new 'static 'vif-tag :imm #x8000 :num #x80 :cmd (vif-cmd unpack-v4-32))
          )
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  (let* ((v1-1 arg0)
         (a0-3 (the-as object (-> v1-1 base)))
         )
    (set! (-> (the-as dma-packet a0-3) dma) (new 'static 'dma-tag :qwc #x40 :id (dma-tag-id ref) :addr arg2))
    (set! (-> (the-as dma-packet a0-3) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
    (set! (-> (the-as dma-packet a0-3) vif1)
          (new 'static 'vif-tag :imm #x8080 :num #x40 :cmd (vif-cmd unpack-v4-32))
          )
    (set! (-> v1-1 base) (&+ (the-as pointer a0-3) 16))
    )
  0
  (none)
  )

(defmethod ocean-texture-add-call-start ((this ocean) (arg0 dma-buffer))
  (let* ((v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
    (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  0
  (none)
  )

(defmethod ocean-texture-add-call-rest ((this ocean) (arg0 dma-buffer))
  (let* ((v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd mscalf) :msk #x1))
    (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  0
  (none)
  )

(defmethod ocean-texture-add-call-done ((this ocean) (arg0 dma-buffer))
  (let* ((v1-0 arg0)
         (a0-1 (the-as object (-> v1-0 base)))
         )
    (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd mscalf) :msk #x1))
    (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd stmod)))
    (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16))
    )
  0
  (none)
  )

(defmethod draw-ocean-texture ((this ocean) (arg0 dma-buffer) (arg1 int))
  (set-display-gs-state arg0 21 128 128 0 0)
  (ocean-texture-add-envmap this arg0)
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)))
                         (alpha-1 (new 'static 'gs-alpha :b #x2 :d #x1))
                         (tex1-1 (new 'static 'gs-tex1))
                         )
  (dma-buffer-add-vu-function arg0 ocean-texture-vu1-block 1)
  (let* ((v1-5 arg0)
         (a0-10 (the-as object (-> v1-5 base)))
         )
    (set! (-> (the-as dma-packet a0-10) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
    (set! (-> (the-as dma-packet a0-10) vif0) (new 'static 'vif-tag :cmd (vif-cmd base)))
    (set! (-> (the-as dma-packet a0-10) vif1) (new 'static 'vif-tag :imm #xc0 :cmd (vif-cmd offset)))
    (set! (-> v1-5 base) (&+ (the-as pointer a0-10) 16))
    )
  (ocean-texture-add-constants this arg0)
  (let ((s3-0 (+ arg1 0)))
    (ocean-texture-add-verts this arg0 s3-0)
    (let ((s3-1 (+ s3-0 3072)))
      (ocean-texture-add-call-start this arg0)
      (dotimes (s2-0 9)
        (ocean-texture-add-verts this arg0 s3-1)
        (+! s3-1 3072)
        (ocean-texture-add-call-rest this arg0)
        )
      (ocean-texture-add-verts-last this arg0 s3-1 (+ arg1 0))
      )
    )
  (ocean-texture-add-call-rest this arg0)
  (ocean-texture-add-call-done this arg0)
  ;; og:preserve-this not-yet-implemented
  ; (ocean-method-80 this arg0)
  ; (reset-display-gs-state *display* arg0)
  0
  (none)
  )

(defmethod ocean-method-89 ((this ocean) (arg0 dma-buffer))
  (set-display-gs-state arg0 53 64 64 0 0)
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x2a0 :tbw #x2 :tcc #x1 :th (log2 128) :tw (log2 128)))
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (clamp-1 (new 'static 'gs-clamp))
                         (texflush 0)
                         )
  (let ((v1-17 (the-as object (-> arg0 base))))
    (set! (-> (the-as (inline-array vector4w) v1-17) 0 quad) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-17) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-17) 2 quad) (-> this color80808040 quad))
    (set! (-> (the-as (inline-array vector4w) v1-17) 3 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-17) 4 quad) (-> this xy00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-17) 5 quad) (-> this uv8080 quad))
    (set! (-> (the-as (inline-array vector4w) v1-17) 6 quad) (-> this xy4040 quad))
    )
  (&+! (-> arg0 base) 112)
  (set-display-gs-state arg0 61 32 32 0 0)
  (dma-buffer-add-gs-set arg0
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x6a0 :tbw #x1 :tcc #x1 :th (log2 64) :tw (log2 64)))
                         (texflush 0)
                         )
  (let ((v1-30 (the-as object (-> arg0 base))))
    (set! (-> (the-as (pointer uint128) v1-30)) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-30) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-30) 2 quad) (-> this color80808000 quad))
    (set! (-> (the-as (inline-array vector4w) v1-30) 3 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-30) 4 quad) (-> this xy00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-30) 5 quad) (-> this uv4040 quad))
    (set! (-> (the-as (inline-array vector4w) v1-30) 6 quad) (-> this xy2020 quad))
    )
  (&+! (-> arg0 base) 112)
  (set-display-gs-state arg0 63 16 16 0 0)
  (dma-buffer-add-gs-set arg0
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x7a0 :tcc #x1 :th (log2 32) :tw (log2 32)))
                         (texflush 0)
                         )
  (let ((v1-43 (the-as object (-> arg0 base))))
    (set! (-> (the-as (inline-array vector4w) v1-43) 0 quad) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-43) 2 quad) (-> this color80808000 quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 3 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 4 quad) (-> this xy00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 5 quad) (-> this uv2020 quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 6 quad) (-> this xy1010 quad))
    )
  (&+! (-> arg0 base) 112)
  (set-display-gs-state arg0 64 8 8 0 0)
  (dma-buffer-add-gs-set arg0
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x7e0 :tcc #x1 :th (log2 16) :tw (log2 16)))
                         (texflush 0)
                         )
  (let ((v1-56 (the-as object (-> arg0 base))))
    (set! (-> (the-as (inline-array vector4w) v1-56) 0 quad) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-56) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-56) 2 quad) (-> this color80808000 quad))
    (set! (-> (the-as (inline-array vector4w) v1-56) 3 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-56) 4 quad) (-> this xy00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-56) 5 quad) (-> this uv1010 quad))
    (set! (-> (the-as (inline-array vector4w) v1-56) 6 quad) (-> this xy88 quad))
    )
  (&+! (-> arg0 base) 112)
  (set-display-gs-state arg0 65 8 8 0 0)
  (dma-buffer-add-gs-set arg0
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x800 :tcc #x1 :th (log2 8) :tw (log2 8)))
                         (texflush 0)
                         )
  (let ((v1-69 (the-as object (-> arg0 base))))
    (set! (-> (the-as (inline-array vector4w) v1-69) 0 quad) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-69) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-69) 2 quad) (-> this color80808000 quad))
    (set! (-> (the-as (inline-array vector4w) v1-69) 3 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-69) 4 quad) (-> this xy00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-69) 5 quad) (-> this uv1010 quad))
    (set! (-> (the-as (inline-array vector4w) v1-69) 6 quad) (-> this xy88 quad))
    )
  (&+! (-> arg0 base) 112)
  (set-display-gs-state arg0 66 8 8 0 0)
  (dma-buffer-add-gs-set arg0
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x820 :tcc #x1 :th (log2 4) :tw (log2 4)))
                         (texflush 0)
                         )
  (let ((v1-82 (the-as object (-> arg0 base))))
    (set! (-> (the-as (pointer uint128) v1-82)) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-82) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-82) 2 quad) (-> this color80808000 quad))
    (set! (-> (the-as (inline-array vector4w) v1-82) 3 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-82) 4 quad) (-> this xy00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-82) 5 quad) (-> this uv00 quad))
    (set! (-> (the-as (inline-array vector4w) v1-82) 6 quad) (-> this xy88 quad))
    )
  (&+! (-> arg0 base) 112)
  (reset-display-gs-state *display* arg0)
  0
  (none)
  )

(defmethod ocean-method-79 ((this ocean) (arg0 (pointer rgba)))
  (dotimes (v1-0 256)
    (let ((a0-3 (-> *clut-translate* v1-0)))
      (set! (-> arg0 a0-3 r) v1-0)
      (set! (-> arg0 a0-3 g) v1-0)
      (set! (-> arg0 a0-3 b) v1-0)
      (set! (-> arg0 a0-3 a) v1-0)
      )
    )
  0
  (none)
  )

(defmethod do-tex-scroll! ((this ocean))
  (when (not (paused?))
    (+! (-> this st-scroll x) (* 8.0 (seconds-per-frame)))
    (set! (-> this st-scroll y) (- (-> this st-scroll y) (* 8.0 (seconds-per-frame))))
    (if (< 128.0 (-> this st-scroll x))
        (+! (-> this st-scroll x) -128.0)
        )
    (if (< (-> this st-scroll y) 0.0)
        (+! (-> this st-scroll y) 128.0)
        )
    )
  (set! (-> this uv-scroll-0 x) (the int (* 16.0 (-> this st-scroll x))))
  (set! (-> this uv-scroll-0 y) (the int (* 16.0 (+ 256.0 (-> this st-scroll y)))))
  (set! (-> this uv-scroll-1 x) (the int (* 16.0 (+ 256.0 (-> this st-scroll x)))))
  (set! (-> this uv-scroll-1 y) (the int (* 16.0 (-> this st-scroll y))))
  0
  (none)
  )

(defmethod ocean-method-80 ((this ocean) (arg0 dma-buffer))
  (set-display-gs-state arg0 53 128 128 0 0)
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x2a0 :tbw #x2 :tcc #x1 :th (log2 128) :tw (log2 128)))
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (clamp-1 (new 'static 'gs-clamp))
                         (texflush 0)
                         )
  (let ((v1-17 (the-as (inline-array vector4w) (-> arg0 base))))
    (set! (-> v1-17 0 quad) (-> this sprite-tmpl dma-vif quad))
    (set! (-> v1-17 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> v1-17 2 quad) (-> this color80808080 quad))
    (set! (-> v1-17 3 quad) (-> this uv00 quad))
    (set! (-> v1-17 4 quad) (-> this xy00 quad))
    (set! (-> v1-17 5 quad) (-> this uv8080 quad))
    (set! (-> v1-17 6 quad) (-> this xy8080 quad))
    )
  (&+! (-> arg0 base) 112)
  (dma-buffer-add-gs-set arg0
                         (bitbltbuf (new 'static 'gs-bitbltbuf :dbp #x860))
                         (trxpos (new 'static 'gs-trxpos))
                         (trxreg (new 'static 'gs-trxreg :rrw #x10 :rrh #x10))
                         (trxdir (new 'static 'gs-trxdir))
                         )
  (let ((v1-23 (the-as object (-> arg0 base))))
    (set! (-> (the-as (inline-array vector4w) v1-23) 0 quad) (-> this clut-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-23) 1 quad) (-> this clut-tmpl quad 1))
    (ocean-method-79 this (the-as (pointer rgba) (&+ (the-as pointer v1-23) 32)))
    )
  (&+! (-> arg0 base) 1056)
  (set-display-gs-state arg0 85 128 128 0 0)
  (dma-buffer-add-gs-set arg0
                         (alpha-1 (new 'static 'gs-alpha))
                         (tex0-1
                           (new 'static 'gs-tex0
                             :tbp0 #x2a0
                             :tbw #x2
                             :psm #x1b
                             :tcc #x1
                             :cbp #x860
                             :cld #x1
                             :th (log2 128)
                             :tw (log2 128)
                             )
                           )
                         (tex1-1 (new 'static 'gs-tex1))
                         (clamp-1 (new 'static 'gs-clamp))
                         (texflush 0)
                         )
  (let ((v1-40 (the-as (inline-array vector4w) (-> arg0 base))))
    (set! (-> v1-40 0 quad) (-> this sprite-tmpl3 dma-vif quad))
    (set! (-> v1-40 1 quad) (-> this sprite-tmpl3 quad 1))
    (set-vector! (-> v1-40 2) 96 96 96 128)
    (set! (-> v1-40 3 quad) (-> this uv00 quad))
    (set! (-> v1-40 4 quad) (-> this xy00 quad))
    (set! (-> v1-40 5 quad) (-> this uv8080 quad))
    (set! (-> v1-40 6 quad) (-> this xy8080 quad))
    )
  (&+! (-> arg0 base) 112)
  (dma-buffer-add-gs-set arg0
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (texflush 0)
                         )
  (let ((v1-46 (the-as (inline-array vector4w) (-> arg0 base))))
    (set! (-> v1-46 0 quad) (-> this sprite-tmpl3 dma-vif quad))
    (set! (-> v1-46 1 quad) (-> this sprite-tmpl3 quad 1))
    (set-vector! (-> v1-46 2) 64 64 64 64)
    (set! (-> v1-46 3 quad) (-> this uv-scroll-0 quad))
    (set! (-> v1-46 4 quad) (-> this xy00 quad))
    (set! (-> v1-46 5 quad) (-> this uv-scroll-1 quad))
    (set! (-> v1-46 6 quad) (-> this xy8080 quad))
    )
  (&+! (-> arg0 base) 112)
  (set-display-gs-state arg0 21 128 128 0 0)
  (dma-buffer-add-gs-set arg0
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x6a0 :tbw #x2 :th (log2 128) :tw (log2 128)))
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (texflush 0)
                         )
  (let ((v1-63 (the-as (inline-array vector4w) (-> arg0 base))))
    (set! (-> v1-63 0 quad) (-> this sprite-tmpl3 dma-vif quad))
    (set! (-> v1-63 1 quad) (-> this sprite-tmpl3 quad 1))
    (set-vector! (-> v1-63 2) 128 128 128 64)
    (set! (-> v1-63 3 quad) (-> this uv-scroll-0 quad))
    (set! (-> v1-63 4 quad) (-> this xy00 quad))
    (set! (-> v1-63 5 quad) (-> this uv-scroll-1 quad))
    (set! (-> v1-63 6 quad) (-> this xy8080 quad))
    )
  (&+! (-> arg0 base) 112)
  (let ((s5-1 128)
        (s4-3 128)
        )
    (let ((s1-0 21)
          (s2-5 2720)
          (s3-3 (log2 (* s5-1 2)))
          (v1-66 (log2 s4-3))
          (a0-69 (/ (+ (* s5-1 2) 63) 64))
          (a1-55 #x3fff)
          )
      (dma-buffer-add-gs-set-flusha arg0
                                    (xyoffset-1 (new 'static 'gs-xy-offset))
                                    (frame-1 (new 'static 'gs-frame :psm (gs-psm ct16) :fbmsk a1-55 :fbw a0-69 :fbp s1-0))
                                    (scissor-1 (new 'static 'gs-scissor :scax1 (+ s5-1 -1) :scay1 (+ s4-3 -1)))
                                    (test-1 (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)))
                                    (alpha-1 (new 'static 'gs-alpha :a #x2 :b #x2 :c #x2 :fix #x80))
                                    (tex0-1 (new 'static 'gs-tex0 :psm #x2 :tcc #x1 :tfx #x1 :th v1-66 :tw s3-3 :tbw a0-69 :tbp0 s2-5))
                                    (fba-1 0)
                                    (texa (new 'static 'gs-texa :ta1 #x80))
                                    (tex1-1 (new 'static 'gs-tex1 :lcm #x1))
                                    (texflush 0)
                                    (prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1 :fst #x1))
                                    )
      (let ((a2-6 s4-3))
        (dotimes (a3-9 (/ s5-1 16))
          (dma-buffer-add-gs-set arg0
                                 (uv (new 'static 'gs-uv :v #x8 :u (+ (* a3-9 256) 8)))
                                 (xyz2 (new 'static 'gs-xyz :x (+ (* a3-9 256) 128)))
                                 (uv (new 'static 'gs-uv :u (+ (* a3-9 256) 136) :v (+ (* a2-6 16) 8)))
                                 (xyz2 (new 'static 'gs-xyz :y (* a2-6 16) :x (+ (* a3-9 256) 256)))
                                 )
          )
        )
      (let ((t0-42 (/ s5-1 64)))
        (dma-buffer-add-gs-set arg0
                               (frame-1 (new 'static 'gs-frame :psm (gs-psm ct16) :fbmsk a1-55 :fbw a0-69 :fbp (+ s1-0 t0-42)))
                               (tex0-1
                                 (new 'static 'gs-tex0 :psm #x2 :tcc #x1 :tfx #x1 :th v1-66 :tw s3-3 :tbw a0-69 :tbp0 (+ s2-5 (* t0-42 32)))
                                 )
                               (prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1 :fst #x1))
                               )
        )
      )
    (dotimes (v1-73 (/ s5-1 16))
      (dma-buffer-add-gs-set arg0
                             (uv (new 'static 'gs-uv :v #x8 :u (+ (* v1-73 256) 8)))
                             (xyz2 (new 'static 'gs-xyz :x (+ (* v1-73 256) 128)))
                             (uv (new 'static 'gs-uv :u (+ (* v1-73 256) 136) :v (+ (* s4-3 16) 8)))
                             (xyz2 (new 'static 'gs-xyz :y (* s4-3 16) :x (+ (* v1-73 256) 256)))
                             )
      )
    )
  0
  (none)
  )

(defmethod draw-envmap-debug ((this ocean) (arg0 dma-buffer))
  (format *stdcon* "draw-envmap-debug~%")
  (-> arg0 base)
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (tex0-1 (new 'static 'gs-tex0 :tbp0 #x2a0 :tbw #x2 :tcc #x1 :th (log2 128) :tw (log2 128)))
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
                         (texflush 0)
                         )
  (let ((v1-19 (the-as object (-> arg0 base))))
    (set! (-> (the-as (pointer uint128) v1-19)) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-19) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-19) 2 quad) (-> this color80808080 quad))
    (set! (-> (the-as (inline-array vector4w) v1-19) 3 quad) (-> this uv00 quad))
    (set-vector! (-> (the-as (inline-array vector4w) v1-19) 4) #x7b50 #x8000 #xffffff 0)
    (set! (-> (the-as (inline-array vector4w) v1-19) 5 quad) (-> this uv4040 quad))
    (let ((v1-20 (the-as object (-> (the-as (inline-array vector4w) v1-19) 6))))
      (set! (-> (the-as (inline-array vector4w) v1-20) 0 x) #x7f60)
      (set! (-> (the-as (inline-array vector4w) v1-20) 0 y) #x8400)
      (set! (-> (the-as (inline-array vector4w) v1-20) 0 z) #xffffff)
      (set! (-> (the-as vector4w v1-20) w) 0)
      )
    )
  (&+! (-> arg0 base) 112)
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
                         (alpha-1 (new 'static 'gs-alpha))
                         (tex0-1
                           (new 'static 'gs-tex0 :tbw #x1 :th (log2 64) :tw (log2 64) :tbp0 (-> *ocean-envmap-texture-base* vram-block))
                           )
                         (tex1-1 (new 'static 'gs-tex1))
                         (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
                         (texflush 0)
                         )
  (let ((v1-43 (the-as object (-> arg0 base))))
    (set! (-> (the-as (pointer uint128) v1-43)) (-> this sprite-tmpl dma-vif quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 1 quad) (-> this sprite-tmpl quad 1))
    (set! (-> (the-as (inline-array vector4w) v1-43) 2 quad) (-> this color80808080 quad))
    (set! (-> (the-as (inline-array vector4w) v1-43) 3 quad) (-> this uv00 quad))
    (set-vector! (-> (the-as (inline-array vector4w) v1-43) 4) #x8000 #x8000 #xffffff 0)
    (set! (-> (the-as (inline-array vector4w) v1-43) 5 quad) (-> this uv4040 quad))
    (let ((v1-44 (the-as object (-> (the-as (inline-array vector4w) v1-43) 6))))
      (set! (-> (the-as (inline-array vector4w) v1-44) 0 x) #x8820)
      (set! (-> (the-as (inline-array vector4w) v1-44) 0 y) #x8400)
      (set! (-> (the-as (inline-array vector4w) v1-44) 0 z) #xffffff)
      (set! (-> (the-as vector4w v1-44) w) 0)
      )
    )
  (&+! (-> arg0 base) 112)
  0
  (none)
  )

(defmethod ocean-method-82 ((this ocean) (arg0 dma-buffer) (arg1 float))
  (let* ((s4-0 64)
         (s3-0 0)
         (f30-0 (/ -65536.0 (the float s4-0)))
         (f28-0 arg1)
         )
    (dma-buffer-add-gs-set arg0
                           (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                           (tex0-1 (new 'static 'gs-tex0
                                     :tbw #x1
                                     :tcc #x1
                                     :th (log2 64)
                                     :tw (log2 64)
                                     :tbp0 (+ (-> *ocean-texture-base* vram-block) 256)
                                     )
                                   )
                           (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
                           (texflush 0)
                           )
    (let ((v1-16 (-> arg0 base)))
      (set! (-> (the-as (pointer uint128) v1-16)) (-> this line-tmpl dma-vif quad))
      (set! (-> (the-as (pointer uint128) v1-16) 1) (-> this line-tmpl quad 1))
      )
    (&+! (-> arg0 base) 32)
    (dotimes (s2-1 s4-0)
      (let ((s1-1 (the-as object (-> arg0 base))))
        (let ((f26-1 (+ 0.5 (* 0.5 (sin f28-0))))
              (f0-5 (+ 0.5 (* 0.5 (cos f28-0))))
              )
          (set! (-> (the-as (inline-array vector4w) s1-1) 0 quad) (-> this color80808000 quad))
          (set! (-> (the-as (inline-array vector4w) s1-1) 1 quad) (-> this st0505 quad))
          (set-vector! (-> (the-as (inline-array vector4w) s1-1) 2) s3-0 0 #xffffff 0)
          (set-vector!
            (-> (the-as (inline-array vector4w) s1-1) 3)
            (the-as int f26-1)
            (the-as int f0-5)
            (the-as int 1.0)
            (the-as int 0.0)
            )
          )
        (set-vector! (-> (the-as (inline-array vector4w) s1-1) 4) s3-0 512 #xffffff 0)
        )
      (+! s3-0 16)
      (+! f28-0 f30-0)
      (&+! (-> arg0 base) 80)
      )
    )
  0
  )

(defmethod ocean-method-83 ((this ocean) (arg0 dma-buffer) (arg1 sky-upload-data) (arg2 vector4w) (arg3 float))
  (when (>= (-> arg1 sun 0 pos y) -150.0)
    (let* ((f2-0 (/ (-> arg1 sun 0 pos x) 9950))
           (f1-3 (/ (-> arg1 sun 0 pos z) 9950))
           (f0-6 (if (< 0.0 (-> arg1 sun 0 pos y))
                     1.0
                     (* 0.006666667 (+ 150.0 (-> arg1 sun 0 pos y)))
                     )
                 )
           (f3-6 (if (< 4000.0 (-> arg1 sun 0 pos y))
                     1.0
                     (+ 1.0 (* 0.001 (- 4000.0 (-> arg1 sun 0 pos y))))
                     )
                 )
           (t0-1 (* arg3 f3-6))
           (v1-14 (the int (+ 1024.0 (* 512.0 f2-0))))
           (a2-3 (the int (+ 1024.0 (* 512.0 f1-3))))
           (t0-2 (the int t0-1))
           (t1-0 (the-as (inline-array vector4w) (-> arg0 base)))
           )
      (set! (-> t1-0 0 quad) (-> this sun-tmpl dma-vif quad))
      (set! (-> t1-0 1 quad) (-> this sun-tmpl quad 1))
      (set! (-> t1-0 2 quad) (-> arg2 quad))
      (set! (-> t1-0 2 w) (the int (* 128.0 f0-6)))
      (set! (-> t1-0 3 quad) (-> this st0000 quad))
      (set-vector! (-> t1-0 4) (- v1-14 t0-2) (- a2-3 t0-2) #xffffff 0)
      (set! (-> t1-0 5 quad) (-> this st1010 quad))
      (set-vector! (-> t1-0 6) (+ v1-14 t0-2) (+ a2-3 t0-2) #xffffff 0)
      )
    (&+! (-> arg0 base) 112)
    )
  0
  (none)
  )

(defmethod ocean-method-84 ((this ocean) (arg0 dma-buffer))
  (local-vars (sv-48 vector4w) (sv-64 vector4w))
  (dma-buffer-add-gs-set arg0 (alpha-1 (new 'static 'gs-alpha :b #x2 :d #x1)))
  (let ((v1-3 (-> arg0 base)))
    (set! (-> (the-as (pointer uint128) v1-3)) (-> this haze-tmpl dma-vif quad))
    (set! (-> (the-as (pointer uint128) v1-3) 1) (-> this haze-tmpl quad 1))
    )
  (&+! (-> arg0 base) 32)
  (let ((f30-0 0.0)
        (f28-0 4096.0)
        (s3-0 (new 'stack-no-clear 'vector))
        (s2-0 (new 'stack-no-clear 'ocean-vertex))
        (s4-0 (-> arg0 base))
        )
    (dotimes (s1-0 16)
      (let ((s0-0 (the-as object (-> arg0 base))))
        (set! sv-48 (-> this haze-verts (* s1-0 2)))
        (set! sv-64 (-> this haze-verts (+ (* s1-0 2) 1)))
        (let ((f0-1 (+ -1024.0 (the float (-> sv-48 x))))
              (f1-3 (+ -1024.0 (the float (-> sv-48 y))))
              (v1-22 s2-0)
              )
          (set! (-> v1-22 pos x) f0-1)
          (set! (-> v1-22 pos y) 0.0)
          (set! (-> v1-22 pos z) f1-3)
          (set! (-> v1-22 pos w) 1.0)
          )
        (add-colors! this s3-0 s2-0)
        (vector-float*! s3-0 s3-0 0.25)
        (set-vector!
          (-> (the-as (inline-array vector4w) s0-0) 0)
          (the int (-> s3-0 x))
          (the int (-> s3-0 y))
          (the int (-> s3-0 z))
          0
          )
        (set! (-> (the-as (inline-array vector4w) s0-0) 1 quad) (-> sv-48 quad))
        (set-vector!
          (-> (the-as (inline-array vector4w) s0-0) 2)
          (the int (-> s3-0 x))
          (the int (-> s3-0 y))
          (the int (-> s3-0 z))
          128
          )
        (set! (-> (the-as (inline-array vector4w) s0-0) 3 quad) (-> sv-64 quad))
        )
      (&+! (-> arg0 base) 64)
      (+! f30-0 f28-0)
      )
    (let ((v1-37 (the-as (pointer uint128) (-> arg0 base))))
      (set! (-> v1-37 0) (-> (the-as (pointer uint128) s4-0) 0))
      (set! (-> v1-37 1) (-> (the-as (pointer uint128) s4-0) 1))
      (set! (-> v1-37 2) (-> (the-as (pointer uint128) s4-0) 2))
      (set! (-> v1-37 3) (-> (the-as (pointer uint128) s4-0) 3))
      )
    )
  (&+! (-> arg0 base) 64)
  0
  (none)
  )

(defmethod ocean-method-85 ((this ocean) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector))
  (local-vars (v1-1 float))
  (rlet ((acc :class vf)
         (vf0 :class vf)
         (vf1 :class vf)
         (vf10 :class vf)
         (vf11 :class vf)
         (vf12 :class vf)
         (vf13 :class vf)
         (vf2 :class vf)
         (vf3 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         (vf6 :class vf)
         (vf7 :class vf)
         (vf8 :class vf)
         (vf9 :class vf)
         )
    (init-vf0-vector)
    (let ((v1-0 (new 'static 'vector :y 128.0 :z 255.0)))
      (.max.w.vf vf1 vf0 vf0)
      (.lvf vf2 (&-> v1-0 quad))
      )
    (.lvf vf7 (&-> arg1 quad))
    (.lvf vf4 (&-> this cloud-lights sun0-normal quad))
    (.lvf vf5 (&-> this cloud-lights sun1-normal quad))
    (.lvf vf6 (&-> this cloud-lights moon-normal quad))
    (.mul.vf vf8 vf4 vf7)
    (.mul.vf vf9 vf5 vf7)
    (.mul.vf vf10 vf6 vf7)
    (.lvf vf3 (&-> arg3 quad))
    (.mul.w.vf acc vf8 vf0)
    (.add.mul.y.vf acc vf1 vf8 acc)
    (.add.mul.z.vf vf8 vf1 vf8 acc)
    (.mul.w.vf acc vf9 vf0)
    (.add.mul.y.vf acc vf1 vf9 acc)
    (.add.mul.z.vf vf9 vf1 vf9 acc)
    (.mul.w.vf acc vf10 vf0)
    (.add.mul.y.vf acc vf1 vf10 acc)
    (.add.mul.z.vf vf10 vf1 vf10 acc)
    (.lvf vf11 (&-> arg2 quad))
    (.max.vf vf8 vf8 vf0)
    (.max.vf vf9 vf9 vf0)
    (.max.vf vf10 vf10 vf0)
    (.lvf vf12 (&-> this cloud-lights sun1-color quad))
    (.lvf vf13 (&-> this cloud-lights moon-color quad))
    (.mul.w.vf acc vf3 vf0)
    (.add.mul.x.vf acc vf11 vf8 acc)
    (.add.mul.x.vf acc vf12 vf9 acc)
    (.add.mul.x.vf vf3 vf13 vf10 acc)
    (.mul.y.vf vf3 vf3 vf2)
    (.max.x.vf vf3 vf3 vf0)
    (.min.z.vf vf3 vf3 vf2)
    (.ftoi.vf vf3 vf3)
    (.svf (&-> arg0 quad) vf3)
    (.mov v1-1 vf3)
    0
    (none)
    )
  )

(defmethod ocean-method-86 ((this ocean) (arg0 vector) (arg1 vector) (arg2 vector))
  (let ((s5-0 (new 'stack-no-clear 'vector))
        (s2-0 (new 'stack-no-clear 'vector))
        (s4-0 (new 'stack-no-clear 'vector))
        (f28-0 0.00390625)
        (f30-0 0.015625)
        )
    (let ((s3-0 (-> this cloud-lights)))
      (vector-copy! arg0 arg1)
      (vector--float*! s5-0 arg2 (-> s3-0 sun0-normal) 9.0)
      (vector--float*! s2-0 arg2 (-> s3-0 sun1-normal) 9.0)
      (vector--float*! s4-0 arg2 (-> s3-0 moon-normal) 9.0)
      (vector-float*! s5-0 s5-0 (* (-> s3-0 sun0-scale) f28-0))
      (vector+float*! s5-0 s5-0 s2-0 (* (/ f28-0 4) (-> s3-0 sun1-scale)))
      (vector+float*! s5-0 s5-0 s4-0 (* (-> s3-0 moon-scale) f28-0))
      )
    (+! (-> arg0 x) (fmax (fmin (-> s5-0 x) f30-0) (- f30-0)))
    (+! (-> arg0 y) (fmax (fmin (-> s5-0 z) f30-0) (- f30-0)))
    )
  0
  (none)
  )

(defmethod ocean-method-87 ((this ocean) (arg0 dma-buffer))
  (local-vars (sv-48 vector) (sv-64 uint) (sv-80 vector) (sv-96 vector) (sv-112 vector))
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test
                                   :ate #x1
                                   :atst (gs-atest greater-equal)
                                   :aref #x50
                                   :afail #x1
                                   :zte #x1
                                   :ztst (gs-ztest greater-equal)
                                   )
                                 )
                         (tex0-1 (new 'static 'gs-tex0
                                   :tbp0 #x100
                                   :tbw #x2
                                   :psm #x1b
                                   :tcc #x1
                                   :cbp #x300
                                   :cld #x1
                                   :th (log2 128)
                                   :tw (log2 128)
                                   )
                                 )
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (clamp-1 (new 'static 'gs-clamp))
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (texflush 0)
                         )
  (let* ((v1-17 *sky-work*)
         (f0-1 (* 0.000015258789 (the float (-> v1-17 off-s))))
         (f1-3 (* 0.000015258789 (the float (-> v1-17 off-t))))
         )
    (dotimes (v1-19 6)
      (dotimes (a0-10 6)
        (set-vector!
          (-> this cloud-st0 (+ (* 6 v1-19) a0-10))
          (+ (* 0.5 (the float a0-10)) f0-1)
          (+ (* 0.5 (the float v1-19)) f1-3)
          1.0
          0.0
          )
        )
      )
    )
  (let ((s4-1 (new 'stack-no-clear 'vector))
        (s3-1 (new 'stack-no-clear 'vector))
        (s2-2 (-> this cloud-lights))
        )
    (vector-float*! (-> s2-2 sun0-color) (-> s2-2 sun0-color) 0.25)
    (vector-float*! (-> s2-2 sun0-color-lower) (-> s2-2 sun0-color-lower) 0.25)
    (vector-float*! (-> s2-2 sun1-color) (-> s2-2 sun1-color) 0.25)
    (vector-float*! (-> s2-2 moon-color) (-> s2-2 moon-color) 0.25)
    (vector-float*! (-> s2-2 ambi-color) (-> s2-2 ambi-color) 0.25)
    (vector-float*! (-> s2-2 ambi-color-lower) (-> s2-2 ambi-color-lower) 0.25)
    (dotimes (s1-0 36)
      (let ((v1-36 (-> this cloud-verts s1-0)))
        (set! sv-80 (-> this cloud-nrms s1-0))
        (let ((s0-0 (-> this cloud-col0 s1-0)))
          (set! sv-48 (-> this cloud-col1 s1-0))
          (set! sv-112 (-> this cloud-st0 s1-0))
          (set! sv-96 (-> this cloud-st1 s1-0))
          (set! sv-64 (-> this cloud-alpha s1-0))
          (set! (-> s4-1 x) (* 0.140625 (+ -1024.0 (the float (-> v1-36 x)))))
          (set! (-> s4-1 z) (* 0.140625 (+ -1024.0 (the float (-> v1-36 z)))))
          (vector-negate! s3-1 sv-80)
          (let ((a0-41 this)
                (t9-3 (method-of-type ocean ocean-method-85))
                (a1-19 s0-0)
                (a3-0 (-> s2-2 sun0-color))
                (t0-0 (-> s2-2 ambi-color))
                )
            (t9-3 a0-41 a1-19 sv-80 a3-0 t0-0)
            )
          (ocean-method-85 this sv-48 s3-1 (-> s2-2 sun0-color-lower) (-> s2-2 ambi-color-lower))
          (set! (-> s0-0 w) (the-as float sv-64))
          )
        )
      (set! (-> sv-48 w) (the-as float sv-64))
      (let ((a0-44 this)
            (t9-5 (method-of-type ocean ocean-method-86))
            (a3-2 s4-1)
            )
        (t9-5 a0-44 sv-96 sv-112 a3-2)
        )
      )
    )
  (dotimes (v1-46 5)
    (let ((a0-45 (the-as (inline-array vector4w) (-> arg0 base))))
      (set! (-> a0-45 0 quad) (-> this cloud-tmpl dma-vif quad))
      (set! (-> a0-45 1 quad) (-> this cloud-tmpl quad 1))
      )
    (&+! (-> arg0 base) 32)
    (dotimes (a0-48 6)
      (let ((a3-3 (+ (* 6 v1-46) a0-48))
            (a2-7 (+ (* 6 (+ v1-46 1)) a0-48))
            (a1-28 (the-as (inline-array vector4w) (-> arg0 base)))
            )
        (set! (-> a1-28 0 quad) (-> this cloud-col0 a3-3 quad))
        (set! (-> a1-28 1 quad) (-> this cloud-st0 a3-3 quad))
        (set! (-> a1-28 2 quad) (-> this cloud-verts a3-3 quad))
        (set! (-> a1-28 3 quad) (-> this cloud-col0 a2-7 quad))
        (set! (-> a1-28 4 quad) (-> this cloud-st0 a2-7 quad))
        (set! (-> a1-28 5 quad) (-> this cloud-verts a2-7 quad))
        )
      (&+! (-> arg0 base) 96)
      )
    )
  (dotimes (v1-49 5)
    (let ((a0-51 (the-as (inline-array vector4w) (-> arg0 base))))
      (set! (-> a0-51 0 quad) (-> this cloud-tmpl dma-vif quad))
      (set! (-> a0-51 1 quad) (-> this cloud-tmpl quad 1))
      )
    (&+! (-> arg0 base) 32)
    (dotimes (a0-54 6)
      (let ((a3-13 (+ (* 6 v1-49) a0-54))
            (a2-12 (+ (* 6 (+ v1-49 1)) a0-54))
            (a1-37 (the-as (inline-array vector4w) (-> arg0 base)))
            )
        (set! (-> a1-37 0 quad) (-> this cloud-col1 a3-13 quad))
        (set! (-> a1-37 1 quad) (-> this cloud-st1 a3-13 quad))
        (set! (-> a1-37 2 quad) (-> this cloud-verts a3-13 quad))
        (set! (-> a1-37 3 quad) (-> this cloud-col1 a2-12 quad))
        (set! (-> a1-37 4 quad) (-> this cloud-st1 a2-12 quad))
        (set! (-> a1-37 5 quad) (-> this cloud-verts a2-12 quad))
        )
      (&+! (-> arg0 base) 96)
      )
    )
  0
  (none)
  )

(defmethod ocean-method-88 ((this ocean) (arg0 dma-buffer))
  (set-display-gs-state arg0 (the-as int (+ (-> *ocean-texture-base* vram-page) 8)) 64 64 0 0)
  (vector-float*! (-> this sky-color) (-> *time-of-day-context* current-sky-color) 0.25)
  (+! (-> this sky-color x) (* 0.5 (- (-> this sky-color z) (-> this sky-color x))))
  (+! (-> this sky-color y) (* 0.5 (- (-> this sky-color z) (-> this sky-color y))))
  (dma-buffer-add-gs-set arg0
                         (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)))
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (texflush 0)
                         )
  (let ((v1-9 (the-as object (-> arg0 base))))
    (let ((a1-13 (-> this sky-color)))
      (set! (-> (the-as (inline-array vector4w) v1-9) 0 quad) (-> this sprite-tmpl2 dma-vif quad))
      (set! (-> (the-as (inline-array vector4w) v1-9) 1 quad) (-> this sprite-tmpl2 quad 1))
      (set-vector!
        (-> (the-as (inline-array vector4w) v1-9) 2)
        (the int (-> a1-13 x))
        (the int (-> a1-13 y))
        (the int (-> a1-13 z))
        128
        )
      )
    (let ((a0-13 (the-as (inline-array vector4w) (&+ (the-as pointer v1-9) 48))))
      (set! (-> a0-13 0 x) 0)
      (set! (-> a0-13 0 y) 0)
      (set! (-> a0-13 0 z) #xffffff)
      (set! (-> a0-13 0 w) 0)
      )
    (let ((v1-10 (the-as (inline-array vector4w) (-> (the-as (inline-array vector4w) v1-9) 4))))
      (set! (-> v1-10 0 x) 1024)
      (set! (-> v1-10 0 y) 1024)
      (set! (-> v1-10 0 z) #xffffff)
      (set! (-> v1-10 0 w) 0)
      )
    )
  (&+! (-> arg0 base) 80)
  (dma-buffer-add-gs-set arg0
                         (xyoffset-1 (new 'static 'gs-xy-offset :ofx #x200 :ofy #x200))
                         (texa (new 'static 'gs-texa :ta1 #x80))
                         (texflush 0)
                         )
  (let ((v1-16 (the-as adgif-shader (-> arg0 base))))
    (set! (-> v1-16 quad 0 quad) (-> this adgif-tmpl dma-vif quad))
    (set! (-> v1-16 quad 1 quad) (-> this adgif-tmpl quad 1))
    (let ((s4-0 (&-> v1-16 miptbp1)))
      (adgif-shader<-texture-simple! (the-as adgif-shader s4-0) (get-texture sky-glow-soft sky-textures))
      (set! (-> s4-0 8) (new 'static 'gs-miptbp :tbp1 #x48))
      )
    )
  (&+! (-> arg0 base) 112)
  (let ((s4-1 (-> *sky-work* upload-data))
        (a3-1 (new 'stack 'vector4w))
        )
    (let ((a0-28 (-> this cloud-lights sun0-color)))
      (set-vector!
        a3-1
        (the int (* 128.0 (-> a0-28 x)))
        (the int (* 80.0 (-> a0-28 y)))
        (the int (* 32.0 (-> a0-28 z)))
        1
        )
      )
    (ocean-method-83 this arg0 s4-1 a3-1 80.0)
    )
  (let ((s4-2 (&-> *sky-work* upload-data data 4))
        (a3-2 (new 'stack 'vector4w))
        )
    (let ((a0-32 (-> this cloud-lights sun1-color)))
      (set-vector!
        a3-2
        (the int (* 255.0 (-> a0-32 x)))
        (the int (* 255.0 (-> a0-32 y)))
        (the int (* 255.0 (-> a0-32 z)))
        1
        )
      )
    (ocean-method-83 this arg0 (the-as sky-upload-data s4-2) a3-2 64.0)
    )
  (let ((v1-30 (the-as adgif-shader (-> arg0 base))))
    (set! (-> v1-30 quad 0 quad) (-> this adgif-tmpl dma-vif quad))
    (set! (-> v1-30 quad 1 quad) (-> this adgif-tmpl quad 1))
    (let ((s4-3 (&-> v1-30 miptbp1)))
      (adgif-shader<-texture-simple! (the-as adgif-shader s4-3) (get-texture full-moon sky-textures))
      (set! (-> s4-3 8) (new 'static 'gs-miptbp :tbp1 #x44))
      )
    )
  (&+! (-> arg0 base) 112)
  (let ((a2-3 (-> *sky-work* upload-data moon))
        (a3-3 (new 'static 'vector4w :x 80 :y 80 :z 80))
        )
    (ocean-method-83 this arg0 (the-as sky-upload-data a2-3) a3-3 48.0)
    )
  (ocean-method-84 this arg0)
  (ocean-method-87 this arg0)
  (set-display-gs-state arg0 (the-as int (-> *ocean-envmap-texture-base* vram-page)) 64 64 0 0)
  (ocean-method-82 this arg0 32768.0)
  (dma-buffer-add-gs-set arg0
                         (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                         (tex0-1 (new 'static 'gs-tex0
                                   :tbw #x1
                                   :tcc #x1
                                   :th (log2 32)
                                   :tw (log2 64)
                                   :tbp0 (-> *ocean-envmap-texture-base* vram-block)
                                   )
                                 )
                         (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                         (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
                         (rgbaq (new 'static 'gs-rgbaq :r #x80 :g #x80 :b #x80 :a #x80 :q 1.0))
                         (texflush 0)
                         )
  (dma-buffer-add-gs-set arg0 (tex1-1 (new 'static 'gs-tex1)) (texflush 0))
  (let ((v1-66 (the-as (inline-array vector4w) (-> arg0 base))))
    (set! (-> v1-66 0 quad) (-> this sprite-tmpl dma-vif quad))
    (set! (-> v1-66 1 quad) (-> this sprite-tmpl quad 1))
    (set-vector! (-> v1-66 2) 128 128 128 128)
    (set-vector! (-> v1-66 3) 8 520 0 0)
    (set-vector! (-> v1-66 4) 0 512 #xffffff 0)
    (set-vector! (-> v1-66 5) 1032 8 0 0)
    (let ((v1-67 (the-as object (-> v1-66 6))))
      (set! (-> (the-as (inline-array vector4w) v1-67) 0 x) 1024)
      (set! (-> (the-as vector4w v1-67) y) 1024)
      (set! (-> (the-as vector4w v1-67) z) #xffffff)
      (set! (-> (the-as vector4w v1-67) w) 0)
      )
    )
  (&+! (-> arg0 base) 112)
  (reset-display-gs-state *display* arg0)
  0
  (none)
  )

;; ERROR: Expression building failed: In check-normals: Could not match ArrayFieldAccess (stride power of 2) values: v1-4

(defun-debug generate-cloud-verts ((arg0 int) (arg1 float))
  (let ((f30-0 8192.0)
        (f28-0 (/ 65536.0 (the float arg0)))
        )
    (dotimes (s4-0 arg0)
      (let* ((f26-0 (sin f30-0))
             (f0-1 (cos f30-0))
             (a2-0 (* (the int (+ 64.0 (* f26-0 arg1))) 16))
             (a3-0 (* (the int (+ 64.0 (* f0-1 arg1))) 16))
             )
        (format
          0
          "(new 'static 'vector4w :x #x~x :y #x~x :z #xffffff :w 0) ; ~f degrees~%"
          a2-0
          a3-0
          (* 0.005493164 f30-0)
          )
        )
      (+! f30-0 f28-0)
      )
    )
  #f
  )

(defun-debug generate-cloud-nrms ((arg0 int) (arg1 float))
  (let ((f30-0 8192.0)
        (f28-0 (/ 65536.0 (the float arg0)))
        )
    (dotimes (s4-0 arg0)
      (let ((f26-0 (sin f30-0))
            (f0-1 (cos f30-0))
            (s3-0 (new 'stack-no-clear 'vector))
            )
        (set-vector! s3-0 f26-0 arg1 f0-1 1.0)
        (vector-normalize! s3-0 1.0)
        (format
          0
          "(new 'static 'vector :x ~f :y ~f :z ~f :w 0) ; ~f degrees~%"
          (-> s3-0 x)
          (-> s3-0 y)
          (-> s3-0 z)
          (* 0.005493164 f30-0)
          )
        )
      (+! f30-0 f28-0)
      )
    )
  #f
  )

;; WARN: Return type mismatch gs-tex1 vs none.
(defun-debug set-ocean-lk ((arg0 int) (arg1 int))
  (let ((v1-0 *ocean*))
    (set! (-> v1-0 tex1 l) arg0)
    (set! (-> v1-0 tex1 k) arg1)
    (set! (-> v1-0 tex1-near l) arg0)
    (set! (-> v1-0 tex1-near k) arg1)
    )
  (none)
  )

(defun-debug set-ocean-normal-scale ((arg0 float))
  (let* ((v1-0 *ocean*)
         (f0-1 (/ -1.0 (* 4096.0 arg0)))
         (v0-0 (-> v1-0 scales))
         )
    (set! (-> v0-0 x) f0-1)
    (set! (-> v0-0 y) 255.0)
    (set! (-> v0-0 z) f0-1)
    (set! (-> v0-0 w) 128.0)
    v0-0
    )
  )
