(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
1 changed files with 66 additions and 42 deletions

View File

@ -6,27 +6,59 @@
|000 |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 |100
@on-reset ( -> ) @on-reset ( -> )
( | theme ) ( | theme )
#c2c2 DUP2 .System/r DEO2 #2c2c DUP2 .System/r DEO2
DUP2 .System/g DEO2 DUP2 .System/g DEO2
.System/b DEO2 .System/b DEO2
;on-mouse .Mouse/vector DEO2 ;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
BRK BRK
@on-mouse ( -> ) @on-mouse ( -> )
#c1 ;touch-chr/down ;touch-chr .Mouse/state DEI ?{ SWP2 } #c1 ;touch-chr/down ;touch-chr .Mouse/state DEI ?{ SWP2 }
POP2 <update-cursor> POP2 <update-cursor>
.Mouse/state DEI ?{ BRK }
( | touch )
.Mouse/x DEI2 .Mouse/y DEI2 #0010 #01 <draw-circle>
BRK 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* -- ) @<update-cursor> ( color addr* -- )
;fill-icn .Screen/addr DEO2 ;fill-icn .Screen/addr DEO2
#40 <draw-cursor> #40 <draw-cursor>
@ -42,8 +74,13 @@
.Screen/sprite DEOk DEO .Screen/sprite DEOk DEO
JMP2r JMP2r
@<draw-circle> ( xc* yc* r color -- ) @<draw-particle> ( addr* -- )
( load ) .color STZ 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/r STZ2
.circle/yc STZ2 .circle/yc STZ2
.circle/xc STZ2 .circle/xc STZ2
@ -69,40 +106,25 @@
#8000 ADD2 SWP2 #8000 ADD2 LTH2 JMP2r #8000 ADD2 SWP2 #8000 ADD2 LTH2 JMP2r
@<draw-seg> ( -- ) @<draw-seg> ( -- )
.color LDZ .Screen/pixel .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 .Screen/x DEO2 .circle/xc LDZ2 .circle/x LDZ2 ADD2 .circle/yc LDZ2 .circle/y LDZ2 SUB2 <draw-pixel>
.circle/yc LDZ2 .circle/y LDZ2 ADD2 .Screen/y DEO2 .circle/xc LDZ2 .circle/x LDZ2 SUB2 .circle/yc LDZ2 .circle/y LDZ2 SUB2 <draw-pixel>
DEOk .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/x LDZ2 SUB2 .Screen/x DEO2 .circle/xc LDZ2 .circle/y LDZ2 ADD2 .circle/yc LDZ2 .circle/x LDZ2 SUB2 <draw-pixel>
.circle/yc LDZ2 .circle/y LDZ2 ADD2 .Screen/y DEO2 .circle/xc LDZ2 .circle/y LDZ2 SUB2 .circle/yc LDZ2 .circle/x LDZ2 SUB2
DEOk ( >> )
( | .. )
.circle/xc LDZ2 .circle/x LDZ2 ADD2 .Screen/x DEO2 @<draw-pixel> ( x* y* -- )
.circle/yc LDZ2 .circle/y LDZ2 SUB2 .Screen/y DEO2 DUP2 .Screen/height DEI2 GTH2 ?{
DEOk .Screen/y DEO2
( | .. ) DUP2 .Screen/width DEI2 GTH2 ?{
.circle/xc LDZ2 .circle/x LDZ2 SUB2 .Screen/x DEO2 .Screen/x DEO2
.circle/yc LDZ2 .circle/y LDZ2 SUB2 .Screen/y DEO2 [ LIT2r 01 -Screen/pixel ] DEOr
DEOk JMP2r }
( | .. ) POP2 JMP2r }
.circle/xc LDZ2 .circle/y LDZ2 ADD2 .Screen/x DEO2 POP2 POP2 JMP2r
.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
@touch-chr [ @touch-chr [
0000 0000 0814 1417 0000 0000 0008 0808 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
ffff ffff ffff ffff ffff ffff ffff ffff ] ffff ffff ffff ffff ffff ffff ffff ffff ]
@particles $60 &end