88 lines
1.8 KiB
Tal
88 lines
1.8 KiB
Tal
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
|
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|
|
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|
|
|
|
|0000
|
|
@pointer &x $2 &y $2
|
|
@heap &a $1 &b $1 &c $1 &d $1
|
|
|
|
|0100
|
|
@on-reset
|
|
( set the screen size )
|
|
#00c8 .Screen/width DEO2
|
|
#00c8 .Screen/height DEO2
|
|
( set system colors )
|
|
#29bd .System/r DEO2
|
|
#29a7 .System/g DEO2
|
|
#297a .System/b DEO2
|
|
|
|
;on-mouse .Mouse/vector DEO2
|
|
( step 1 - fill the heaps )
|
|
draw-game
|
|
BRK
|
|
|
|
@draw-game
|
|
draw-heaps
|
|
JMP2r
|
|
|
|
@draw-heaps
|
|
LIT2r 0000
|
|
&l
|
|
#0014 #0014 STH2kr #0028 MUL2 ADD2 draw-heap-row
|
|
INC2r
|
|
STH2kr #0004 NEQ2 ?&l
|
|
POP2r
|
|
JMP2r
|
|
|
|
@draw-heap-row ( x* y* -- )
|
|
LITr 00
|
|
&l
|
|
SWP2 ( y* x* )
|
|
#0014 ADD2 ( y* x* + 20 )
|
|
SWP2 ( x* + 20 y* )
|
|
OVR2 OVR2 ( x* + 20 y* x* + 20 y* )
|
|
draw-el-outline
|
|
INCr
|
|
STHkr #07 NEQ ?&l
|
|
POPr
|
|
POP2 POP2
|
|
JMP2r
|
|
|
|
@draw-el-outline ( x* y* -- )
|
|
SWP2 #0090 draw-h-line
|
|
JMP2r
|
|
|
|
@draw-h-line ( y* x* w* -- )
|
|
ROT2 ( x* w* y* )
|
|
.Screen/y DEO2 ( x* w* )
|
|
ADD2k NIP2 ( x* mx* )
|
|
SWP2 ( mx* x* )
|
|
&l
|
|
.Screen/x DEO2k POP2 ( mx* x* )
|
|
#01 .Screen/pixel DEO
|
|
INC2 ( mx* x* + 1 )
|
|
NEQ2k ( mx* x* + 1 01 ) ?&l
|
|
POP2 POP2
|
|
JMP2r
|
|
|
|
|
|
@on-mouse ( -> )
|
|
( draw the pixel )
|
|
.Mouse/x DEI2 .Screen/x DEO2
|
|
.Mouse/y DEI2 .Screen/y DEO2
|
|
#41 .Screen/pixel DEO
|
|
( clear the old pixel )
|
|
.pointer/x LDZ2 .Screen/x DEO2
|
|
.pointer/y LDZ2 .Screen/y DEO2
|
|
#40 .Screen/pixel DEO
|
|
|
|
( store current pos )
|
|
.Mouse/x DEI2 .pointer/x STZ2
|
|
.Mouse/y DEI2 .pointer/y STZ2
|
|
BRK
|
|
|
|
( draw a pixel in the screen )
|
|
( #0032 .Screen/x DEO2 )
|
|
( #0032 .Screen/y DEO2 )
|
|
( #41 .Screen/pixel DEO ( fg layer, color1 ) )
|