mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
fc43870d85
This renames the method object in `defmethod`s to `this` and adds detection for the `set-time!` and `time-elapsed?` macros. Definitely my biggest PR yet...
123 lines
4.1 KiB
Common Lisp
123 lines
4.1 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: drawable-tree.gc
|
|
;; name in dgo: drawable-tree
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; The "drawable tree" represents a BVH for a specific render.
|
|
;; Typically, levels will have ~10 drawable trees. There will be a tree for
|
|
;; tfrag, a tree for actors, a tree for tie,
|
|
|
|
;; This file contains common functions for all drawable trees.
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defmethod draw drawable-tree-array ((this drawable-tree-array) (arg0 drawable-tree-array) (arg1 display-frame))
|
|
"Draw a drawable tree array. If the current level is set to special or special-vis, the draw is skipped."
|
|
(let ((v1-1 (-> (scratchpad-object terrain-context) bsp lev-index)))
|
|
(case (-> *level* level v1-1 display?)
|
|
(('special 'special-vis #f)
|
|
)
|
|
(else
|
|
(dotimes (s3-0 (-> this length))
|
|
(draw (-> this trees s3-0) (-> arg0 trees s3-0) arg1)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collect-stats drawable-tree-array ((this drawable-tree-array))
|
|
(dotimes (s5-0 (-> this length))
|
|
(collect-stats (-> this trees s5-0))
|
|
)
|
|
(none)
|
|
)
|
|
|
|
(defmethod debug-draw drawable-tree-array ((this drawable-tree-array) (arg0 drawable) (arg1 display-frame))
|
|
(dotimes (s3-0 (-> this length))
|
|
(debug-draw (-> this trees s3-0) (-> (the-as drawable-tree-array arg0) trees s3-0) arg1)
|
|
)
|
|
(none)
|
|
)
|
|
|
|
(defmethod unpack-vis drawable-tree ((this drawable-tree) (arg0 (pointer int8)) (arg1 (pointer int8)))
|
|
"Copy our visibility data from arg1 to arg0, unpacking it."
|
|
(local-vars (t5-1 int))
|
|
|
|
;; grab the first array
|
|
(let* ((v1-0 (the-as drawable-inline-array-node (-> this data 0)))
|
|
;; first elt in top array
|
|
(a3-1 (/ (-> v1-0 data 0 id) 8))
|
|
;; number in first array (8 or fewer)
|
|
(t0-0 (-> v1-0 length))
|
|
;; offset in destination
|
|
(v1-1 (&+ arg0 a3-1))
|
|
;; number of bytes
|
|
(a3-3 (/ (+ t0-0 7) 8))
|
|
)
|
|
;; copy the data!
|
|
;;(mem-print (the (pointer uint32) arg1) 10)
|
|
(dotimes (t0-1 a3-3)
|
|
(let ((t1-0 (-> arg1 0)))
|
|
;;(format 0 "top-copy: #x~X~%" t1-0)
|
|
(set! arg1 (&-> arg1 1))
|
|
(set! (-> v1-1 0) t1-0)
|
|
)
|
|
(set! v1-1 (&-> v1-1 1))
|
|
)
|
|
)
|
|
;; now, the remaining arrays, excluding the final which isn't a draw node array.
|
|
(let ((v1-5 (+ (-> this length) -1)))
|
|
(when (nonzero? v1-5)
|
|
(dotimes (a3-5 v1-5)
|
|
;; pointer to this array
|
|
(let* ((t0-4 (-> this data a3-5))
|
|
;; pointer to next depth array
|
|
(t2-0 (-> this data (+ a3-5 1)))
|
|
;; id of first in prev
|
|
(t1-5 (/ (-> (the-as drawable-inline-array-node t0-4) data 0 id) 8))
|
|
;; id of first in next
|
|
(t2-2 (/ (-> (the-as drawable-inline-array-node t2-0) data 0 id) 8))
|
|
;; number of nodes in this one
|
|
(t0-5 (-> (the-as drawable-inline-array-node t0-4) length))
|
|
;; output for prev level
|
|
(t1-6 (&+ arg0 t1-5))
|
|
;; output for next level
|
|
(t2-3 (&+ arg0 t2-2))
|
|
)
|
|
(while #t
|
|
;; load the vis byte for the one in this array
|
|
(let ((t3-0 (-> t1-6 0)))
|
|
;; inc vis ptr.
|
|
(set! t1-6 (&-> t1-6 1))
|
|
;; vis mask bit. (init at highest)
|
|
(let ((t4-0 128))
|
|
(label cfg-7)
|
|
;; check if we're visible
|
|
(b! (zero? (logand t3-0 t4-0)) cfg-9 :delay (set! t5-1 (-> arg1 0)))
|
|
;; we are visible. write 8 in the output
|
|
(set! arg1 (&-> arg1 1))
|
|
(set! (-> t2-3 0) t5-1)
|
|
(label cfg-9)
|
|
(+! t0-5 -1)
|
|
;; check if we've done all nodes
|
|
(b! (zero? t0-5) cfg-12 :delay (.sra t4-0 t4-0 1))
|
|
;; check if we're done with this byte and inc output.
|
|
(b! (nonzero? t4-0) cfg-7 :delay (set! t2-3 (&-> t2-3 1)))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(label cfg-12)
|
|
(nop!)
|
|
0
|
|
)
|
|
)
|
|
)
|
|
arg1
|
|
)
|