2022-06-30 01:22:51 -04:00
|
|
|
;;-*-Lisp-*-
|
|
|
|
(in-package goal)
|
|
|
|
|
|
|
|
;; name: sampler.gc
|
|
|
|
;; name in dgo: sampler
|
|
|
|
;; dgos: ENGINE, GAME
|
|
|
|
|
2022-10-08 12:42:52 -04:00
|
|
|
;; og:ignore-form:install-handler 9 timer0-handler
|
|
|
|
|
2022-08-05 16:12:54 -04:00
|
|
|
;; DECOMP BEGINS
|
|
|
|
|
2022-10-08 12:42:52 -04:00
|
|
|
;; this file is debug only
|
|
|
|
(declare-file (debug))
|
2023-02-13 16:39:14 -05:00
|
|
|
|
2022-10-08 12:42:52 -04:00
|
|
|
(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)
|
|
|
|
)
|