Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Created April 3, 2023 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ismael-VC/5d7c49d91b5b56aaa5df06b3d2c9321e to your computer and use it in GitHub Desktop.
Save Ismael-VC/5d7c49d91b5b56aaa5df06b3d2c9321e to your computer and use it in GitHub Desktop.
( draw.tal
Simple drawing tool. )
(
@|devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
(
@|init )
|0100 @on-reset ( -- )
( set system colors )
#0a5f .System/r DEO2
#0a5f .System/g DEO2
#0c5f .System/b DEO2
( configure screen device )
;on-frame .Screen/vector DEO2
;brush .Screen/addr DEO2
BRK
@on-frame ( -- )
( read mouse coordinates )
( and use as screen coordinates )
.Mouse/x DEI2 .Screen/x DEO2
.Mouse/y DEI2 .Screen/y DEO2
( read mouse state and compare for left click )
.Mouse/state DEI #02 EQU ?&draw-sprite ( jump when mouse is pressed )
.Mouse/state DEI #01 EQU ?&draw-pixel
BRK
&draw-sprite ( -- )
#45 .Screen/sprite DEO
BRK
&draw-pixel ( -- )
#45 .Screen/pixel DEO
BRK
( sprite data )
@brush 84f8 7a02 524a 7c46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment