rename current-display-frame and make it less confusing

This commit is contained in:
ManDude 2021-08-17 08:04:33 +01:00
parent 63b408773a
commit 1f15165b33
10 changed files with 42 additions and 42 deletions

View file

@ -58,7 +58,7 @@
(set! (-> pt w) 1.0)
(when (transform-point-qword! (-> s5-0 vector 0) pt)
(with-dma-buffer-add-bucket ((v1-7 (current-display-frame debug-buf)) bucket)
(with-dma-buffer-add-bucket ((v1-7 (-> (current-frame) debug-buf)) bucket)
(with-cnt-vif-block (v1-7)
(dma-buffer-add-gif-tag v1-7
@ -118,7 +118,7 @@
'fade, 'fade-depth, or #f.
second-color can be -1 to just use the same color.
"
(let ((a0-4 (current-display-frame debug-buf)))
(let ((a0-4 (-> (current-frame) debug-buf)))
(if (< (the-as uint (shr (+ (&- (-> a0-4 end) (the-as uint (-> a0-4 base))) 15) 4)) (the-as uint #x8000))
(return (the-as pointer #f))
)
@ -147,7 +147,7 @@
(when (and (transform-point-qword! (-> s4-0 vector 0) p0)
(transform-point-qword! (-> s4-0 vector 1) p1)
)
(with-dma-buffer-add-bucket ((v1-28 (current-display-frame debug-buf)) bucket)
(with-dma-buffer-add-bucket ((v1-28 (-> (current-frame) debug-buf)) bucket)
(with-cnt-vif-block (v1-28)
(dma-buffer-add-gif-tag v1-28 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 4
:prim (gif-prim line))
@ -205,7 +205,7 @@
(set! (-> s2-0 quad) (the-as uint128 0))
(when (transform-point-qword! (the-as vector4w s2-0) location)
(with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf)) bucket)
(with-dma-buffer-add-bucket ((s3-0 (-> (current-frame) debug-buf)) bucket)
(let ((a2-2 (new 'stack 'font-context *font-default-matrix*
(+ (+ (-> offset x) -1792) (/ (-> s2-0 x) 16))
@ -268,7 +268,7 @@
(transform-point-qword! (-> s5-0 vector 1) p1)
(transform-point-qword! (-> s5-0 vector 2) p2)
)
(with-dma-buffer-add-bucket ((v1-9 (current-display-frame debug-buf)) bucket)
(with-dma-buffer-add-bucket ((v1-9 (-> (current-frame) debug-buf)) bucket)
(with-cnt-vif-block (v1-9)
(dma-buffer-add-gif-tag v1-9 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 6 :prim (gif-prim tri))
@ -448,7 +448,7 @@
(if (not arg0)
(return #f)
)
(with-dma-buffer-add-bucket ((s4-0 (current-display-frame debug-buf)) arg1)
(with-dma-buffer-add-bucket ((s4-0 (-> (current-frame) debug-buf)) arg1)
(let ((s2-0 (new 'stack 'vector4w))
(v1-7 (new 'stack 'vector4w))
@ -836,7 +836,7 @@
(if (not arg0)
(return #f)
)
(with-dma-buffer-add-bucket ((s0-0 (current-display-frame debug-buf)) arg1)
(with-dma-buffer-add-bucket ((s0-0 (-> (current-frame) debug-buf)) arg1)
(draw-sprite2d-xy s0-0 arg2 arg3 255 14 (new 'static 'rgba :a #x40))
(draw-sprite2d-xy s0-0 arg2 (+ arg3 2) (the int (* 255.0 arg4)) 10 arg5)
)
@ -869,7 +869,7 @@
(set! (-> gp-0 0 x) (* (sin (-> arg0 stick0-dir)) (-> arg0 stick0-speed)))
(set! (-> gp-0 0 y) (* (cos (-> arg0 stick0-dir)) (-> arg0 stick0-speed)))
(dotimes (s5-1 32)
(let* ((s3-0 (current-display-frame debug-buf))
(let* ((s3-0 (-> (current-frame) debug-buf))
(s4-0 (-> s3-0 base))
)
(draw-sprite2d-xy
@ -888,7 +888,7 @@
(set! (-> s3-0 base) (&+ (the-as pointer v1-12) 16))
)
(dma-bucket-insert-tag
(current-display-frame bucket-group)
(-> (current-frame) bucket-group)
(bucket-id debug-draw0)
s4-0
(the-as (pointer dma-tag) a3-1)

View file

@ -622,7 +622,7 @@
(arg4 (font-color dark-light-blue))
(else (font-color dim-gray))
))
(with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((s3-0 (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-adv (-> arg0 name) s3-0 s5-0)
(draw-string-adv "..." s3-0 s5-0)
@ -651,7 +651,7 @@
)
)
)
(with-dma-buffer-add-bucket ((s4-0 (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((s4-0 (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string (-> arg0 name) s4-0 v1-2)
)
@ -680,7 +680,7 @@
)
)
)
(with-dma-buffer-add-bucket ((s4-0 (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((s4-0 (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string (-> arg0 name) s4-0 v1-2)
)
@ -706,7 +706,7 @@
)
)
)
(with-dma-buffer-add-bucket ((s1-0 (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((s1-0 (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-adv (-> arg0 name) s1-0 s5-0)
(draw-string-adv ":" s1-0 s5-0)
@ -779,7 +779,7 @@
(set! arg2 (- arg2 (* (+ v1-0 -16) 8)))
)
)
(with-dma-buffer-add-bucket ((s0-0 (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((s0-0 (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-sprite2d-xy s0-0 arg1 arg2 (-> arg0 pix-width) (-> arg0 pix-height) (static-rgba #x00 #x00 #x00 #x40))
)
@ -796,7 +796,7 @@
)
)
(set-origin! (-> arg0 context font) s3-1 s2-1)
(with-dma-buffer-add-bucket ((sv-16 (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((sv-16 (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string ">" sv-16 (-> arg0 context font))
)

View file

@ -423,10 +423,10 @@
)
)
(defmacro with-dma-buffer-add-bucket (bindings &key (bucket-group (current-display-frame bucket-group)) &rest body)
(defmacro with-dma-buffer-add-bucket (bindings &key (bucket-group (-> (current-frame) bucket-group)) &rest body)
"Bind a dma-buffer to a variable and use it on a block to allow adding things to a new bucket.
usage: (with-dma-buffer-add-bucket ((buffer-name buffer) bucket-id) &rest body
example: (with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf)) (bucket-id debug-draw1)) ...)"
example: (with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf)) (bucket-id debug-draw1)) ...)"
`(let ((,(caar bindings) ,(cadar bindings)))
(with-dma-bucket (,(caar bindings) ,bucket-group ,(cadr bindings))

View file

@ -395,8 +395,8 @@
(defmacro cpu-usage ()
"print out the cpu usage of the most recently rendered frame"
`(format #t "CPU: ~,,2f%~%frame-time: ~,,1fms~%"
(* 100. (/ (the float (current-display-frame run-time)) *ticks-per-frame*))
(* 1000. (/ 1. 60.) (/ (the float (current-display-frame run-time)) *ticks-per-frame*))
(* 100. (/ (the float (-> (current-frame) run-time)) *ticks-per-frame*))
(* 1000. (/ 1. 60.) (/ (the float (-> (current-frame) run-time)) *ticks-per-frame*))
)
)

View file

@ -19,7 +19,7 @@
(defun letterbox ()
"Draw the letterbox black rectangles"
(with-dma-buffer-add-bucket ((dma-buf (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((dma-buf (-> (current-frame) global-buf))
(bucket-id debug-draw1)) ;; debug-draw1 is one of the last buckets
;; draw the two sprites
(draw-sprite2d-xy dma-buf 0 0 512 25 (new 'static 'rgba :a #x80))
@ -44,7 +44,7 @@
(defun blackout ()
"Draw the blackout rectangle, convering the entire screen in darkness."
(with-dma-buffer-add-bucket ((dma-buf (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((dma-buf (-> (current-frame) global-buf))
(bucket-id debug-draw1)) ;; debug-draw1 is one of the last buckets
(draw-sprite2d-xy dma-buf 0 0 512 224 (new 'static 'rgba :a #x80))
)
@ -849,8 +849,8 @@
(when (nonzero? (logand (-> *cpad-list* cpads 1 button0-abs 0) (pad-buttons r3)))
;; grab a dma buffer
(with-dma-buffer-add-bucket ((dma-buff (if *debug-segment*
(current-display-frame debug-buf)
(current-display-frame global-buf)
(-> (current-frame) debug-buf)
(-> (current-frame) global-buf)
))
(bucket-id debug-draw0))
(show-iop-memory dma-buff)

View file

@ -33,7 +33,7 @@
(let ((s1-0 (-> *generic-foreground-sinks* s4-0)))
(when s1-0
(let ((s3-0 (-> s1-0 bucket)))
(with-dma-buffer-add-bucket ((s0-0 (current-display-frame global-buf)) s3-0)
(with-dma-buffer-add-bucket ((s0-0 (-> (current-frame) global-buf)) s3-0)
(if (>= s4-0 7)
(generic-init-buf s0-0 1 s5-0)
(generic-init-buf s0-0 1 gp-0)

View file

@ -231,8 +231,8 @@
(define *post-draw-hook* (the-as (function dma-buffer none) nothing))
(defmacro current-display-frame (&rest args)
`(-> *display* frames (-> *display* on-screen) frame ,@args)
(defmacro current-frame ()
`(-> *display* frames (-> *display* on-screen) frame)
)
(defmacro current-time ()

View file

@ -820,7 +820,7 @@
;; start of our DMA for all the sprite data
(let ((dma-mem-begin (current-display-frame global-buf base)))
;; draw in global-buf
(with-dma-buffer-add-bucket ((dma-buff (current-display-frame global-buf)) (bucket-id sprite))
(with-dma-buffer-add-bucket ((dma-buff (-> (current-frame) global-buf)) (bucket-id sprite))
;; run the distorters
(sprite-init-distorter dma-buff (-> disp frames (-> disp on-screen) draw frame1 fbp))

View file

@ -800,7 +800,7 @@
(tex-id uint)
)
(let ((total-upload-size 0))
(with-dma-buffer-add-bucket ((dma-buf (current-display-frame global-buf)) ;; the global DMA buffer
(with-dma-buffer-add-bucket ((dma-buf (-> (current-frame) global-buf)) ;; the global DMA buffer
bucket-idx)
;; default to segment 0 only (mode 0)
@ -984,7 +984,7 @@
(need-tex symbol)
)
(let ((total-upload-size 0))
(with-dma-buffer-add-bucket ((dma-buf (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((dma-buf (-> (current-frame) global-buf))
bucket-idx)
(set! tex-data (-> page segment 0 block-data)) ;; data in RAM
@ -1597,7 +1597,7 @@
((zero? (-> obj index))
;; use bucket numbers for the 0th level
;; TFRAG
(with-dma-buffer-add-bucket ((v1-4 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-4 (-> (current-frame) global-buf))
(bucket-id tfrag-tex0))
(dma-buffer-add-cnt-vif2 v1-4 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1606,7 +1606,7 @@
)
;; the rest are the same
;; PRIS
(with-dma-buffer-add-bucket ((v1-12 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-12 (-> (current-frame) global-buf))
(bucket-id pris-tex0))
(dma-buffer-add-cnt-vif2 v1-12 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1614,7 +1614,7 @@
)
)
;; SHRUB
(with-dma-buffer-add-bucket ((v1-20 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-20 (-> (current-frame) global-buf))
(bucket-id shrub-tex0))
(dma-buffer-add-cnt-vif2 v1-20 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1622,7 +1622,7 @@
)
)
;; ALPHA
(with-dma-buffer-add-bucket ((v1-28 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-28 (-> (current-frame) global-buf))
(bucket-id alpha-tex0))
(dma-buffer-add-cnt-vif2 v1-28 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1632,7 +1632,7 @@
)
(else
;; TFRAG
(with-dma-buffer-add-bucket ((v1-36 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-36 (-> (current-frame) global-buf))
(bucket-id tfrag-tex1))
(dma-buffer-add-cnt-vif2 v1-36 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1640,7 +1640,7 @@
)
)
;; PRIS
(with-dma-buffer-add-bucket ((v1-44 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-44 (-> (current-frame) global-buf))
(bucket-id pris-tex1))
(dma-buffer-add-cnt-vif2 v1-44 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1648,7 +1648,7 @@
)
)
;; SHRUB
(with-dma-buffer-add-bucket ((v1-52 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-52 (-> (current-frame) global-buf))
(bucket-id shrub-tex1))
(dma-buffer-add-cnt-vif2 v1-52 0 (new 'static 'vif-tag :cmd (vif-cmd nop))
@ -1656,7 +1656,7 @@
)
)
;; ALPHA
(with-dma-buffer-add-bucket ((v1-60 (current-display-frame global-buf))
(with-dma-buffer-add-bucket ((v1-60 (-> (current-frame) global-buf))
(bucket-id alpha-tex1))
(dma-buffer-add-cnt-vif2 v1-60 0 (new 'static 'vif-tag :cmd (vif-cmd nop))

View file

@ -111,7 +111,7 @@
:code (behavior ()
(set-state-time)
(until (time-passed? PC_PAD_INPUT_NOTICE_TIME)
(with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy (string-format "MAPPED ~D TO ~S!"
(pc-pad-input-key-get) (-> *pc-pad-button-names* (1- (-> self input-index))))
@ -136,7 +136,7 @@
:code (behavior ()
(set-state-time)
(until (time-passed? PC_PAD_INPUT_NOTICE_TIME)
(with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy "CANCELED!" buf 256 96 (font-color red-reverse) (font-flags shadow kerning large middle))
)
@ -152,7 +152,7 @@
(pc-pad-input-map-save!)
(set-state-time)
(until (time-passed? PC_PAD_INPUT_NOTICE_TIME)
(with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy (string-format "MAPPED ~D TO ~S!"
(pc-pad-input-key-get) (-> *pc-pad-button-names* (1- (-> self input-index))))
@ -162,7 +162,7 @@
)
(set-state-time)
(until (time-passed? PC_PAD_INPUT_NOTICE_TIME)
(with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy "KEY MAPPING COMPLETE!" buf 256 96 (font-color green) (font-flags shadow kerning large middle))
)
@ -176,7 +176,7 @@
:code (behavior ()
(set-state-time)
(loop
(with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf))
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(if (< (mod (time-passed) (seconds 2)) (seconds 1))
(draw-string-xy "NOW MAPPING PAD" buf 256 32 (font-color red) (font-flags shadow kerning large middle))