jak-project/goal_src/jak2/engine/gfx/shrub/shrubbery-h.gc
water111 edecac9f09
[decomp] add shrubbery renderer (#1914)
as with last time, fog and time of day are still garbage, but it still
works:


![image](https://user-images.githubusercontent.com/48171810/192119423-91b80500-a161-42ce-b734-0c528cc721cf.png)

The shrub near render is just falling back to generic again.
2022-09-24 17:46:13 -04:00

271 lines
12 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: shrubbery-h.gc
;; name in dgo: shrubbery-h
;; dgos: ENGINE, GAME
;; NOTE - for cam-update
(declare-type instance-shrub-work structure)
(define-extern *instance-shrub-work* instance-shrub-work)
(define-extern shrub-make-perspective-matrix (function matrix matrix matrix))
;; DECOMP BEGINS
(deftype billboard (drawable)
((flat adgif-shader :inline :offset-assert 32)
)
:method-count-assert 17
:size-assert #x70
:flag-assert #x1100000070
)
(deftype shrub-view-data (structure)
((data uint128 3 :offset-assert 0)
(texture-giftag gs-gif-tag :inline :offset 0)
(consts vector :inline :offset 16)
(fog-clamp vector :inline :offset 32)
(tex-start-ptr int32 :offset 16)
(gifbufsum float :offset 16)
(mtx-buf-ptr int32 :offset 20)
(exp23 float :offset 20)
(fog-0 float :offset 24)
(fog-1 float :offset 28)
(fog-min float :offset 32)
(fog-max float :offset 36)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)
(deftype shrubbery (drawable)
((textures (inline-array adgif-shader) :offset 4)
(header qword :offset 8)
(obj-qwc uint8 :offset 12)
(vtx-qwc uint8 :offset 13)
(col-qwc uint8 :offset 14)
(stq-qwc uint8 :offset 15)
(obj uint32 :offset 16)
(vtx uint32 :offset 20)
(col uint32 :offset 24)
(stq uint32 :offset 28)
)
:method-count-assert 17
:size-assert #x20
:flag-assert #x1100000020
)
(deftype instance-shrubbery (instance)
((flat-normal vector :inline :offset-assert 64)
(flat-hwidth float :offset 76)
(color uint32 :offset 8)
)
:method-count-assert 17
:size-assert #x50
:flag-assert #x1100000050
)
(deftype drawable-inline-array-instance-shrub (drawable-inline-array)
((data instance-shrubbery 1 :inline :offset-assert 32)
(pad uint32 :offset-assert 112)
)
:method-count-assert 17
:size-assert #x74
:flag-assert #x1100000074
)
(deftype drawable-tree-instance-shrub (drawable-tree)
((info prototype-array-shrub-info :offset 8)
(colors-added time-of-day-palette :offset 12)
)
:method-count-assert 17
:size-assert #x20
:flag-assert #x1100000020
)
(deftype generic-shrub-fragment (drawable)
((textures (inline-array adgif-shader) :offset 4)
(vtx-cnt uint32 :offset 8)
(cnt-qwc uint8 :offset 12)
(vtx-qwc uint8 :offset 13)
(col-qwc uint8 :offset 14)
(stq-qwc uint8 :offset 15)
(cnt uint32 :offset 16)
(vtx uint32 :offset 20)
(col uint32 :offset 24)
(stq uint32 :offset 28)
)
:method-count-assert 17
:size-assert #x20
:flag-assert #x1100000020
)
(deftype prototype-shrubbery (drawable-inline-array)
((data shrubbery 1 :inline :offset-assert 32)
(pad uint32 :offset-assert 64)
)
:method-count-assert 17
:size-assert #x44
:flag-assert #x1100000044
)
(deftype prototype-trans-shrubbery (prototype-shrubbery)
()
:method-count-assert 17
:size-assert #x44
:flag-assert #x1100000044
)
(deftype prototype-generic-shrub (drawable-group)
()
:method-count-assert 17
:size-assert #x20
:flag-assert #x1100000020
)
(deftype shrubbery-matrix (structure)
((mat matrix :inline :offset-assert 0)
(color qword :inline :offset-assert 64)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
(defun shrubbery-login-post-texture ((arg0 shrubbery))
(let* ((v1-1 (-> arg0 header data 0))
(a1-1 (the-as object (+ (the-as uint (-> arg0 header)) (* (+ (-> arg0 header data 1) 1) 16))))
(a2-5 (the-as object (+ (the-as int a1-1) (* v1-1 64))))
(a3-0 (the-as object (-> arg0 textures)))
)
(dotimes (a0-1 (the-as int v1-1))
(set! (-> (the-as qword a2-5) quad) (-> (the-as qword a3-0) quad))
(let ((a2-6 (the-as object (+ (the-as int a2-5) 16)))
(a3-1 (the-as object (&+ (the-as pointer a3-0) 16)))
)
(set! (-> (the-as qword a1-1) vector4w x) (the-as int (-> (the-as qword a3-1) data 0)))
(set! (-> (the-as qword a1-1) vector4w y) (the-as int (-> (the-as qword a3-1) data 1)))
(set! (-> (the-as qword a1-1) vector4w z) (the-as int (-> (the-as qword a3-1) data 2)))
(set! a1-1 (+ (the-as int a1-1) 16))
(let ((a3-2 (the-as object (&+ (the-as pointer a3-1) 16))))
(dotimes (t0-4 3)
(set! (-> (the-as qword a1-1) quad) (-> (the-as qword a3-2) quad))
(set! a1-1 (+ (the-as int a1-1) 16))
(set! a3-2 (&+ (the-as pointer a3-2) 16))
)
(set! (-> (the-as qword a2-6) quad) (-> (the-as qword a3-2) quad))
(set! a2-5 (+ (the-as int a2-6) 16))
(set! a3-0 (&+ (the-as pointer a3-2) 80))
)
)
)
)
(none)
)
(define *shrub-state* 0)
(deftype shrub-near-packet (structure)
((matrix-tmpl dma-packet :inline :offset-assert 0)
(header-tmpl dma-packet :inline :offset-assert 16)
(stq-tmpl dma-packet :inline :offset-assert 32)
(color-tmpl dma-packet :inline :offset-assert 48)
(vertex-tmpl dma-packet :inline :offset-assert 64)
(mscal-tmpl dma-packet :inline :offset-assert 80)
(init-tmpl dma-packet :inline :offset-assert 96)
(init-data qword 2 :inline :offset-assert 112)
)
:method-count-assert 9
:size-assert #x90
:flag-assert #x900000090
)
(deftype instance-shrub-work (structure)
((dummy qword 3 :inline :offset-assert 0)
(chaina qword 8 :inline :offset-assert 48)
(chainb qword 8 :inline :offset-assert 176)
(colors rgba 1024 :offset-assert 304)
(matrix-tmpl qword 20 :inline :offset-assert 4400)
(count-tmpl vector4w 20 :inline :offset-assert 4720)
(mscalf-tmpl dma-packet :inline :offset-assert 5040)
(mscalf-ret-tmpl dma-packet :inline :offset-assert 5056)
(adgif-tmpl dma-gif-packet :inline :offset-assert 5072)
(billboard-tmpl dma-gif-packet :inline :offset-assert 5104)
(billboard-const vector :inline :offset-assert 5136)
(shrub-near-packets shrub-near-packet 6 :inline :offset-assert 5152)
(dma-ref dma-packet :inline :offset-assert 6016)
(dma-end dma-packet :inline :offset-assert 6032)
(wind-const vector :inline :offset-assert 6048)
(constants vector :inline :offset-assert 6064)
(color-constant vector4w :inline :offset-assert 6080)
(hmge-d vector :inline :offset-assert 6096)
(hvdf-offset vector :inline :offset-assert 6112)
(wind-force vector :inline :offset-assert 6128)
(color vector :inline :offset-assert 6144)
(bb-color vector :inline :offset-assert 6160)
(min-dist vector :inline :offset-assert 6176)
(temp-vec vector :inline :offset-assert 6192)
(guard-plane plane 4 :inline :offset-assert 6208)
(plane plane 4 :inline :offset-assert 6272)
(last uint32 4 :offset-assert 6336)
(next uint32 4 :offset-assert 6352)
(count uint16 4 :offset-assert 6368)
(mod-count uint16 4 :offset-assert 6376)
(wind-vectors uint32 :offset-assert 6384)
(instance-ptr uint32 :offset-assert 6388)
(chain-ptr uint32 :offset-assert 6392)
(chain-ptr-next uint32 :offset-assert 6396)
(stack-ptr uint32 :offset-assert 6400)
(bucket-ptr uint32 :offset-assert 6404)
(src-ptr uint32 :offset-assert 6408)
(to-spr uint32 :offset-assert 6412)
(from-spr uint32 :offset-assert 6416)
(shrub-count uint32 :offset-assert 6420)
(pad uint32 :offset-assert 6424)
(node uint32 6 :offset-assert 6428)
(length uint32 6 :offset-assert 6452)
(prototypes uint32 :offset-assert 6476)
(pad2 uint32 :offset-assert 6480)
(start-bank uint8 20 :offset-assert 6484)
(buffer-index uint32 :offset-assert 6504)
(current-spr uint32 :offset-assert 6508)
(current-mem uint32 :offset-assert 6512)
(current-shrub-near-packet uint32 :offset-assert 6516)
(current-shrub-near-trans-packet uint32 :offset-assert 6520)
(pad3 uint32 :offset-assert 6524)
(dma-buffer basic :offset-assert 6528)
(near-last uint32 :offset-assert 6532)
(near-next uint32 :offset-assert 6536)
(near-count uint32 :offset-assert 6540)
(near-trans-last uint32 :offset-assert 6544)
(near-trans-next uint32 :offset-assert 6548)
(near-trans-count uint32 :offset-assert 6552)
(last-shrubs uint32 :offset-assert 6556)
(chains uint32 :offset-assert 6560)
(flags uint32 :offset-assert 6564)
(node-count uint32 :offset-assert 6568)
(inst-count uint32 :offset-assert 6572)
(wait-from-spr uint32 :offset-assert 6576)
(wait-to-spr uint32 :offset-assert 6580)
(texture-dists uint32 :offset-assert 6584)
)
:method-count-assert 9
:size-assert #x19bc
:flag-assert #x9000019bc
)
(deftype instance-shrub-dma (structure)
((instancea uint128 325 :offset-assert 0)
(instanceb uint128 325 :offset-assert 5200)
(outa uint128 128 :offset-assert 10400)
(outb uint128 128 :offset-assert 12448)
)
:method-count-assert 9
:size-assert #x38a0
:flag-assert #x9000038a0
)
;; DECOMP ENDS
(define-extern draw-drawable-tree-instance-shrub (function drawable-tree-instance-shrub level none))