0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-25 23:35:12 +00:00

(bunnymark) Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-01-15 08:30:25 -08:00
parent 950a5085ee
commit 362dee8b1b

View file

@ -1,6 +1,6 @@
( bunnymark.tal ) ( bunnymark.tal )
( November 2021, Kira Oakley ) ( November 2021, Kira Oakley )
( March 2022, Devine Lu Linvega ) ( March 2022, Devine Lu Linvega )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 &debug $1 &halt $1 |00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
@ -21,32 +21,36 @@
#2ce5 .System/b DEO2 #2ce5 .System/b DEO2
( | interrupts ) ( | interrupts )
;on-frame .Screen/vector DEO2 ;on-frame .Screen/vector DEO2
( | draw "FPS:" and "BUNNIES:" and instructions labels ) ( | fps label )
.Screen/width DEI2 #0046 SUB2 #0008 ;text/fps #42 <draw-str> .Screen/width DEI2 #0046 SUB2 .Screen/x DEO2
#0004 #0008 ;text/bunnies #42 <draw-str> #0008 .Screen/y DEO2
.Screen/width DEI2 #01 SFT2 #0050 SUB2 #0008 ;text/instructions #43 <draw-str> ;text/fps #42 <draw-str>
( | bunnies label )
#0004 .Screen/x DEO2
;text/bunnies #42 <draw-str>
( | instructions label )
.Screen/width DEI2 #01 SFT2 #0050 SUB2 .Screen/x DEO2
;text/instructions #43 <draw-str>
#0028 #0008 #0000 <draw-dec> #0028 #0008 #0000 <draw-dec>
( seed prng ) prng-init BRK ( | seed prng )
prng-init BRK
@on-frame ( -> ) @on-frame ( -> )
( frames++ ) .frames LDZ2k INC2 ROT STZ2 .frames LDZ2k INC2 ROT STZ2
.DateTime/second DEI .last LDZ EQU ?&post-fps-update .DateTime/second DEI .last LDZ EQU ?{
( fps update ) .DateTime/second DEI .last STZ
( update last-secs ) .DateTime/second DEI .last STZ .Screen/width DEI2 #002b SUB2 #0008 .frames LDZ2 <draw-dec>
( update fps label ) .Screen/width DEI2 #002b SUB2 #0008 .frames LDZ2 <draw-dec> #0000 .frames STZ2 }
( reset frames counter ) #0000 .frames STZ2 ( | mouse handling )
&post-fps-update ( mouse input to add/remove bunnies ) .Mouse/state DEI
.Mouse/state DEI #01 EQU ?&add ( ) DUP #01 NEQ ?{ add-bunny }
.Mouse/state DEI #01 GTH ?&remove ( ) #02 LTH ?{ remove-bunny }
!&done ;sprite/length LDA2 #0000
&add add-bunny !&done
&remove remove-bunny !&done
&done ( loop from 0 to ;sprite/length to make all ;draw-bunny calls )
;sprite/length LDA2 #0000
&loop ( -- ) &loop ( -- )
EQU2k ?&bail EQU2k ?&bail
DUP2 draw-bunny INC2 !&loop DUP2 draw-bunny INC2 !&loop
&bail POP2 POP2 BRK &bail ( -- )
POP2 POP2 BRK
@draw-bunny ( idx -- ) @draw-bunny ( idx -- )
( compute the offset to the beginning of this bunny's data ) #30 SFT2 ;sprite/array ADD2 ( compute the offset to the beginning of this bunny's data ) #30 SFT2 ;sprite/array ADD2
@ -104,16 +108,13 @@
POP2 JMP2r POP2 JMP2r
@<draw-str> ( x* y* text* color -- ) @<draw-str> ( x* y* text* color -- )
,&t STR
[ LIT2 01 -Screen/auto ] DEO [ LIT2 01 -Screen/auto ] DEO
STH
SWP2 .Screen/y DEO2
SWP2 .Screen/x DEO2
&loop ( -- ) &loop ( -- )
LDAk #20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2 LDAk #20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2
STHkr .Screen/sprite DEO [ LIT2 &t $1 -Screen/sprite ] DEO
INC2 LDAk ?&loop INC2 LDAk ?&loop
POP2 STHr POP [ LIT2 00 -Screen/auto ] DEO POP2 JMP2r
JMP2r
@<draw-dec> ( x* y* num* -- ) @<draw-dec> ( x* y* num* -- )
[ LIT2 01 -Screen/auto ] DEO [ LIT2 01 -Screen/auto ] DEO