0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-16 03:05:06 +00:00

(pond.tal) Added a little demo that draws circles

This commit is contained in:
Devine Lu Linvega 2024-08-24 16:31:37 -07:00
parent 2d851369ec
commit 14ff615b8d

View file

@ -6,27 +6,59 @@
|000
@color $1
@circle [ &xc $2 &yc $2 &x $2 &y $2 &r $2 &d $2 ]
@circle &xc $2 &yc $2 &x $2 &y $2 &r $2 &d $2
|100
@on-reset ( -> )
( | theme )
#c2c2 DUP2 .System/r DEO2
#2c2c DUP2 .System/r DEO2
DUP2 .System/g DEO2
.System/b DEO2
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
BRK
@on-mouse ( -> )
#c1 ;touch-chr/down ;touch-chr .Mouse/state DEI ?{ SWP2 }
POP2 <update-cursor>
.Mouse/state DEI ?{ BRK }
( | touch )
.Mouse/x DEI2 .Mouse/y DEI2 #0010 #01 <draw-circle>
BRK
@on-frame ( -> )
( | 30 fps )
[ LIT &f $1 ] INCk ,&f STR
?{ BRK }
( | clear )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
[ LIT2 80 -Screen/pixel ] DEO
( | draw )
;particles/end ;particles
&>l ( -- )
( | animate particle )
DUP2 <draw-particle>
( | increase size )
DUP2 #0004 ADD2 LDA2k INC2 SWP2 STA2
#0006 ADD2 GTH2k ?&>l
POP2 POP2
( | add particle )
[ LIT &lock $1 ] DUP ?{
.Mouse/state DEI ?{ POP BRK }
( | touch )
.Mouse/x DEI2 #0004 ADD2 .Mouse/y DEI2 #0004 ADD2 <add-particle>
[ LIT2 08 _&lock ] STR
POP BRK }
#01 SUB ,&lock STR
BRK
@<add-particle> ( x* y* -- )
SWP2 [ LIT2r &ptr =particles ] STH2kr INC2r INC2r STA2
STH2kr INC2r INC2r STA2
#0001 STH2kr INC2r INC2r STA2
STH2r DUP2 ;particles/end LTH2 ?{ POP2 ;particles }
,&ptr STR2
JMP2r
@<update-cursor> ( color addr* -- )
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
@ -42,8 +74,13 @@
.Screen/sprite DEOk DEO
JMP2r
@<draw-circle> ( xc* yc* r color -- )
( load ) .color STZ
@<draw-particle> ( addr* -- )
LDA2k ,&x STR2
INC2 INC2 LDA2k ,&y STR2
INC2 INC2 LDA2 [ LIT2 &x $2 ] [ LIT2 &y $2 ] ROT2
( >> )
@<draw-circle> ( xc* yc* r* -- )
.circle/r STZ2
.circle/yc STZ2
.circle/xc STZ2
@ -69,40 +106,25 @@
#8000 ADD2 SWP2 #8000 ADD2 LTH2 JMP2r
@<draw-seg> ( -- )
.color LDZ .Screen/pixel
( | .. )
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .Screen/x DEO2
.circle/yc LDZ2 .circle/y LDZ2 ADD2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .Screen/x DEO2
.circle/yc LDZ2 .circle/y LDZ2 ADD2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .Screen/x DEO2
.circle/yc LDZ2 .circle/y LDZ2 SUB2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .Screen/x DEO2
.circle/yc LDZ2 .circle/y LDZ2 SUB2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .Screen/x DEO2
.circle/yc LDZ2 .circle/x LDZ2 ADD2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .Screen/x DEO2
.circle/yc LDZ2 .circle/x LDZ2 ADD2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .Screen/x DEO2
.circle/yc LDZ2 .circle/x LDZ2 SUB2 .Screen/y DEO2
DEOk
( | .. )
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .Screen/x DEO2
.circle/yc LDZ2 .circle/x LDZ2 SUB2 .Screen/y DEO2
DEO
JMP2r
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .circle/yc LDZ2 .circle/y LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .circle/yc LDZ2 .circle/y LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .circle/yc LDZ2 .circle/y LDZ2 SUB2 <draw-pixel>
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .circle/yc LDZ2 .circle/y LDZ2 SUB2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .circle/yc LDZ2 .circle/x LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .circle/yc LDZ2 .circle/x LDZ2 ADD2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .circle/yc LDZ2 .circle/x LDZ2 SUB2 <draw-pixel>
.circle/xc LDZ2 .circle/y LDZ2 SUB2 .circle/yc LDZ2 .circle/x LDZ2 SUB2
( >> )
@<draw-pixel> ( x* y* -- )
DUP2 .Screen/height DEI2 GTH2 ?{
.Screen/y DEO2
DUP2 .Screen/width DEI2 GTH2 ?{
.Screen/x DEO2
[ LIT2r 01 -Screen/pixel ] DEOr
JMP2r }
POP2 JMP2r }
POP2 POP2 JMP2r
@touch-chr [
0000 0000 0814 1417 0000 0000 0008 0808
@ -119,3 +141,5 @@
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff ]
@particles $60 &end