jak-project/goal_src/jak1/pc/debug/pc-debug-common.gc

65 lines
2.9 KiB
Common Lisp
Raw Normal View History

;;-*-Lisp-*-
(in-package goal)
#|
Various debugging displays made for the pc port. This file is shared for all games.
|#
;; debug-only file!
(declare-file (debug))
;; ----------------------
;; memory usage bars!
;; ----------------------
(defconstant MEM_BAR_WIDTH 104) ;; total width of the bar
(defconstant MEM_BAR_HEIGHT 8) ;; total height of the bar
(defconstant MEM_BAR_HORZ_PAD 8) ;; horizontal padding for the bar text
(defconstant MEM_BAR_NUM 7) ;; amount of bars (override later if wanted)
(defconstant MEM_BAR_BG_COL (static-rgba 64 64 64 64)) ;; color for the empty part of the bar
(defconstant MEM_BAR_RIGHT 480) ;; x coord for the right side of the bar list
(defconstant MEM_BAR_BOTTOM 224) ;; x coord for the bottom side of the bar list
(defconstant MEM_BAR_Y (- MEM_BAR_BOTTOM 4 (* MEM_BAR_HEIGHT MEM_BAR_NUM))) ;; y coord for top side of the bar list
(defmacro draw-memory-bar-generic (buf &key remain &key total &key name &key idx &key color)
"draw a memory usage bar"
`(let* (
(total (the float ,total))
(remain (the float ,remain))
(bar-width (the int (/ (the float MEM_BAR_WIDTH) (-> *pc-settings* aspect-ratio-scale))))
(bar-x (- MEM_BAR_RIGHT bar-width MEM_BAR_HORZ_PAD)) ;; x coord for left side of the bar list
(used-p (if (zero? total) 0.5 (/ (- total remain) total)))
(used-x (the int (* used-p bar-width)))
(used-y (+ MEM_BAR_Y (* ,idx MEM_BAR_HEIGHT)))
)
(draw-sprite2d-xy ,buf bar-x used-y used-x MEM_BAR_HEIGHT ,color)
(draw-sprite2d-xy ,buf (+ bar-x used-x) used-y (- bar-width used-x) MEM_BAR_HEIGHT MEM_BAR_BG_COL)
(draw-string-xy ,name ,buf (- bar-x MEM_BAR_HORZ_PAD) used-y (font-color red) (font-flags shadow kerning right))
(draw-string-xy (if (zero? total) "NO HEAP" (string-format "~,,2f%" (* used-p 100))) ,buf (+ bar-x used-x) used-y (font-color default) (font-flags shadow kerning middle))
(draw-string-xy (string-format "~,,1fM" (/ total (* 1024 1024))) ,buf (+ bar-x bar-width MEM_BAR_HORZ_PAD) used-y (font-color red) (font-flags shadow kerning middle-vert))
)
)
(defmacro draw-memory-bar-kheap (buf heap &key (name #f) &key idx &key color)
"draw a memory usage bar for a kheap"
`(let ((heap ,heap))
(draw-memory-bar-generic ,buf
:remain (&- (-> heap top) (-> heap current))
:total (&- (-> heap top-base) (-> heap base))
:name ,(if name name (symbol->string heap))
:idx ,idx
:color ,color)
)
)
(defmacro draw-memory-bar-dead-pool-heap (buf heap &key (name #f) &key idx &key color)
"draw a memory usage bar for a dead-pool-heap (actor heap)"
`(let* ((heap ,heap) (pool-total (memory-total heap)))
(draw-memory-bar-generic ,buf
:remain (- pool-total (memory-used heap))
:total pool-total
:name ,(if name name (symbol->string heap))
:idx ,idx
:color ,color)
)
)