jak-project/goal_src/jak2/engine/debug/sampler.gc
Tyler Wilding be1e40a041
d/jak2: decompile conveyor | elevator | plat | bouncer | basebutton | base-plat | most of sampler | simple-nav-sphere | simple-focus | elec-gate and blocking-plane (#1942)
Most of these have been atleast partially documented / named / cleaned
up as well.

Co-authored-by: water <awaterford111445@gmail.com>
2022-10-08 12:42:52 -04:00

54 lines
1.6 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: sampler.gc
;; name in dgo: sampler
;; dgos: ENGINE, GAME
;; og:ignore-form:install-handler 9 timer0-handler
;; DECOMP BEGINS
;; this file is debug only
(declare-file (debug))
(when *debug-segment*
(define *sampler-mem* "A pointer to where the sampled data should be stored" (the-as pointer #f))
(define *sampler-compare*
"The value used to set the EE register's `Timer 0 Compare Value`. Always `1`"
(the-as uint 1)
)
(define *sampler-count* "Incremented everytime a metric is sampled
@see [[timer0-handler]]" 0)
(defun-debug sampler-start ()
"Reset the [[timer-bank]] EE registers.
- If [[*sampler-mem*]] is undefined, allocate 16.7MB in the debug segment
- and when [[*sampler-mem*]] is defined, initialize the [[timer-bank]] fully. Reset [[*sampler-count*]] to 0 as well"
(set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode))
(set! (-> (the-as timer-bank #x10000000) count) (the-as uint 0))
(set! (-> (the-as timer-bank #x10000000) comp) *sampler-compare*)
(if (not *sampler-mem*)
(set! *sampler-mem* (malloc 'debug #x1000000))
)
(when (nonzero? *sampler-mem*)
(mem-set32! *sampler-mem* #x400000 0)
(set! (-> (the-as timer-bank #x10000000) mode)
(new 'static 'timer-mode :clks (timer-clock-selection busclk/256) :zret #x1 :cue #x1 :cmpe #x1 :equf #x1)
)
(set! *sampler-count* 0)
0
)
(none)
)
(defun-debug sampler-stop ()
"Sets the [[timer-bank]] mode EE register to 0"
(set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode))
0
(none)
)
)