Files
jak-project/goal_src/engine/gfx/shadow/shadow-cpu-h.gc
T
ManDude 4d634cf50d [decomp] add a bunch of flag enums (#1350)
* update refs

* first pass

* update refs 2

* update

* update

* update

* stuff and things

* accidentally wiped this

* fancy decomp for static sound specs

* clang

* 5 more refs
2022-05-02 18:35:17 -04:00

274 lines
7.8 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: shadow-cpu-h.gc
;; name in dgo: shadow-cpu-h
;; dgos: GAME, ENGINE
(defenum shadow-flags
:bitfield #t
:type int32
(shdf00)
(shdf01)
(shdf02)
(shdf03)
(shdf04)
(shdf05)
(shdf06)
(shdf07)
(shdf08)
(shdf09)
(shdf10)
(shdf11)
(shdf12)
(shdf13)
(shdf14)
(shdf15)
(shdf16)
(shdf17)
(shdf18)
(shdf19)
(shdf20)
(shdf21)
(shdf22)
(shdf23)
(shdf24)
(shdf25)
(shdf26)
(shdf27)
(shdf28)
(shdf29)
(shdf30)
(shdf31)
)
(deftype shadow-settings (structure)
((center vector :inline :offset-assert 0)
(flags shadow-flags :offset 12)
(shadow-dir vector :inline :offset-assert 16)
(dist-to-locus float :offset 28)
(bot-plane plane :inline :offset-assert 32)
(top-plane plane :inline :offset-assert 48)
(fade-dist float :offset-assert 64)
(fade-start float :offset-assert 68)
(dummy-2 int32 :offset-assert 72)
(dummy-3 int32 :offset-assert 76)
(fade-vec vector :inline :offset 64) ;; added
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
(deftype shadow-control (basic)
((settings shadow-settings :inline :offset-assert 16)
)
:method-count-assert 16
:size-assert #x60
:flag-assert #x1000000060
(:methods
(new (symbol type float float float float float) _type_ 0)
(clear-offset-bit (shadow-control) int 9)
(set-offset-bit (shadow-control) int 10)
(set-top-plane-offset (shadow-control float) int 11)
(set-bottom-plane-offset (shadow-control float) int 12)
(dummy-13 (_type_) none 13)
(update-direction-from-time-of-day (_type_) none 14)
(collide-to-find-planes (_type_ vector float float float) none 15)
)
)
(defmethod clear-offset-bit shadow-control ((obj shadow-control))
"Clear a bit in w for the center of the shadow."
(set! (-> obj settings center w)
(the-as float (logand (lognot #x20)
(the-as int (-> obj settings center w))))
)
0
)
(defmethod set-offset-bit shadow-control ((obj shadow-control))
"Set a bit in w for the center position of the shadow"
(set! (-> obj settings center w)
(the-as float (logior (the-as int (-> obj settings center w))
#x20))
)
0
)
(defmethod set-bottom-plane-offset shadow-control ((obj shadow-control) (arg0 float))
(set! (-> obj settings bot-plane d) (- arg0))
0
)
(defmethod set-top-plane-offset shadow-control ((obj shadow-control) (arg0 float))
(set! (-> obj settings top-plane d) (- arg0))
0
)
(deftype shadow-data (structure)
((texoffset vector :inline :offset-assert 0)
(texscale vector :inline :offset-assert 16)
(clrs vector 2 :inline :offset-assert 32)
(dma-unpack-template dma-packet :inline :offset-assert 64)
(dma-cnt dma-tag :offset-assert 80)
(vif-nop vif-tag :offset-assert 88)
(vif-unpack-v4-8 vif-tag :offset-assert 92)
(pdc basic :offset-assert 96)
(dist float :offset-assert 100)
(oddeven uint8 :offset-assert 104)
(waits uint32 :offset-assert 108)
)
:method-count-assert 9
:size-assert #x70
:flag-assert #x900000070
)
(deftype shadow-work (structure)
((shadow-data shadow-data :inline :offset-assert 0)
(inbuf uint128 600 :offset-assert 112)
)
:method-count-assert 9
:size-assert #x25f0
:flag-assert #x9000025f0
)
(deftype shadow-run (structure)
((first dma-packet :offset-assert 0)
(next (pointer dma-packet) :offset-assert 4)
)
:allow-misaligned
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
(deftype shadow-queue (structure)
((num-runs uint32 :offset-assert 0)
(cur-run uint32 :offset-assert 4)
(run shadow-run 15 :inline :offset-assert 8)
)
:method-count-assert 9
:size-assert #xf8
:flag-assert #x9000000f8
)
(defun shadow-queue-append ((arg0 shadow-queue))
"Increment the run counter"
(set! (-> arg0 cur-run) (+ (-> arg0 cur-run) 1))
)
(defun shadow-queue-reset ((arg0 shadow-queue))
"Reset the run counter"
(set! (-> arg0 cur-run) 0)
)
(define *shadow-queue* (new 'global 'shadow-queue))
(deftype shadow-vertex (structure)
((x float :offset-assert 0)
(y float :offset-assert 4)
(z float :offset-assert 8)
(weight float :offset-assert 12)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(deftype shadow-matrix-ref (structure)
((joint-0 uint8 :offset-assert 0)
(joint-1 uint8 :offset-assert 1)
)
:method-count-assert 9
:size-assert #x2
:flag-assert #x900000002
)
;; BUG:
;; the shadow-edge type is multiply defined.
;; it seems like the first definition is not used.
;; The OpenGOAL compiler doesn't like this, so this is commented out.
#|
;; shadow-cpu-h
; (deftype shadow-edge (structure) ;
; ((ind-0 uint16 :offset-assert 0) ;
; (ind-1 uint16 :offset-assert 2) ;
; (tri-0 uint16 :offset-assert 4) ;
; (tri-1 uint16 :offset-assert 6) ;
; ) ;
; :method-count-assert 9 ;
; :size-assert #x4 ;
; :flag-assert #x900000004 ;
; ) ;
|#
(deftype shadow-tri (structure)
((ind-0 uint8 :offset-assert 0)
(ind-1 uint8 :offset-assert 1)
(ind-2 uint8 :offset-assert 2)
(faces uint8 :offset-assert 3)
)
:method-count-assert 9
:size-assert #x4
:flag-assert #x900000004
)
(deftype shadow-edge (structure)
((ind-0 uint8 :offset-assert 0)
(ind-1 uint8 :offset-assert 1)
(tri-0 uint8 :offset-assert 2)
(tri-1 uint8 :offset-assert 3)
)
:method-count-assert 9
:size-assert #x4
:flag-assert #x900000004
)
(deftype shadow-header (structure)
((qwc-data uint32 :offset-assert 0)
(num-joints uint32 :offset-assert 4)
(num-verts uint16 :offset-assert 8)
(num-twos uint16 :offset-assert 10)
(num-single-tris uint16 :offset-assert 12)
(num-single-edges uint16 :offset-assert 14)
(num-double-tris uint16 :offset-assert 16)
(num-double-edges uint16 :offset-assert 18)
(ofs-verts uint32 :offset-assert 20)
(ofs-refs uint32 :offset-assert 24)
(ofs-single-tris uint32 :offset-assert 28)
(ofs-single-edges uint32 :offset-assert 32)
(ofs-double-tris uint32 :offset-assert 36)
(ofs-double-edges uint32 :offset-assert 40)
)
:method-count-assert 9
:size-assert #x2c
:flag-assert #x90000002c
)
(deftype shadow-geo (art-element)
((total-size uint32 :offset-assert 32)
(header shadow-header :inline :offset 32)
(rest uint64 :dynamic :offset-assert 80)
)
:method-count-assert 13
:size-assert #x50
:flag-assert #xd00000050
)
(defmethod new shadow-control ((allocation symbol) (type-to-make type) (bottom-offset float) (top-offset float) (dir float) (center float) (fade float))
(let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> obj settings center w) center)
(set-vector! (-> obj settings shadow-dir) 0.0 -1.0 0.0 dir)
(set-vector! (-> obj settings bot-plane) 0.0 1.0 0.0 (- bottom-offset))
(set-vector! (-> obj settings top-plane) 0.0 1.0 0.0 (- top-offset))
(set! (-> obj settings fade-dist) fade)
obj
)
)
(define *shadow* #f)
(define *shadow-object* #f)
(define *shadow-debug* #f)