2023-03-13 01:10:28 -04:00
|
|
|
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &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
|
|
|
|
|
|
|
|
|0100
|
|
|
|
|
2023-03-13 01:24:25 -04:00
|
|
|
#6f0b .System/r DEO2
|
|
|
|
#7f0a .System/g DEO2
|
|
|
|
#8e0a .System/b DEO2
|
2023-03-13 01:10:28 -04:00
|
|
|
( screen size )
|
2023-03-13 13:22:19 -04:00
|
|
|
#00c0
|
|
|
|
DUP2 .Screen/width DEO2
|
|
|
|
.Screen/height DEO2
|
|
|
|
( vector )
|
|
|
|
;on-frame .Screen/vector DEO2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-frame ( -> )
|
|
|
|
|
|
|
|
[ LIT2 &f $2 ] INC2k ,&f STR2
|
2023-12-18 17:44:36 -05:00
|
|
|
INC2k d2xy ROT2 d2xy #01 <draw-line>
|
2023-03-13 01:10:28 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@d2xy ( d* -- x* y* )
|
|
|
|
|
|
|
|
,&t STR2
|
|
|
|
#0000
|
|
|
|
DUP2 ,&x STR2
|
|
|
|
,&y STR2
|
2023-03-13 13:22:19 -04:00
|
|
|
#2001
|
2023-03-13 01:10:28 -04:00
|
|
|
&l
|
2023-03-13 13:22:19 -04:00
|
|
|
#00 OVR STH2
|
2023-03-13 01:10:28 -04:00
|
|
|
[ LIT2 &t $2 ]
|
2023-03-13 01:24:25 -04:00
|
|
|
DUP2 DUP2 #01 SFT2 #0001 AND2 DUP2 ,&rx STR2
|
2023-03-13 01:10:28 -04:00
|
|
|
EOR2 #0001 AND2 ,&ry STR2
|
2023-03-13 01:24:25 -04:00
|
|
|
#02 SFT2 ,&t STR2
|
2023-03-13 01:10:28 -04:00
|
|
|
[ LIT2 &x $2 ] [ LIT2 &y $2 ] [ LIT2 &rx $2 ] [ LIT2 &ry $2 ]
|
2023-03-13 13:22:19 -04:00
|
|
|
STH2kr rot
|
2023-03-13 01:24:25 -04:00
|
|
|
STH2kr ,&ry LDR2 MUL2 ADD2 ,&y STR2
|
|
|
|
STH2r ,&rx LDR2 MUL2 ADD2 ,&x STR2
|
2023-03-13 13:22:19 -04:00
|
|
|
DUP ADD GTHk ?&l
|
|
|
|
POP2
|
|
|
|
,&x LDR2 #20 SFT2 #0020 ADD2
|
|
|
|
,&y LDR2 #20 SFT2 #0020 ADD2
|
2023-03-13 01:10:28 -04:00
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@rot ( x* y* rx* ry* n* -- x* y* )
|
|
|
|
|
2023-03-13 13:22:19 -04:00
|
|
|
#0001 SUB2 STH2
|
2023-03-13 01:10:28 -04:00
|
|
|
SWP2 ,&rx STR2
|
2023-03-13 01:24:25 -04:00
|
|
|
ORA ?&skipy
|
2023-03-13 01:10:28 -04:00
|
|
|
[ LIT2 &rx $2 ] #0001 NEQ2 ?&skipx
|
|
|
|
( rx-n-1 ) SWP2 STH2kr SWP2 SUB2
|
|
|
|
( ry-n-1 ) SWP2 STH2kr SWP2 SUB2
|
|
|
|
&skipx
|
|
|
|
( swap ) SWP2
|
|
|
|
&skipy
|
|
|
|
POP2r
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2023-12-18 17:44:36 -05:00
|
|
|
@<draw-line> ( x1* y1* x2* y2* color -- )
|
2023-03-13 01:10:28 -04:00
|
|
|
,&color STR
|
|
|
|
,&y STR2
|
|
|
|
,&x STR2
|
2023-12-18 17:44:36 -05:00
|
|
|
,&y2 STR2
|
|
|
|
,&x2 STR2
|
|
|
|
,&x LDR2 ,&x2 LDR2 SUB2 abs2 ,&dx STR2
|
|
|
|
#0000 ,&y LDR2 ,&y2 LDR2 SUB2 abs2 SUB2 ,&dy STR2
|
|
|
|
#ffff [ LIT2 00 _&x2 ] LDR2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2
|
|
|
|
#ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
|
|
|
|
[ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2
|
|
|
|
&while ( -- )
|
|
|
|
[ LIT2 &x2 $2 ] DUP2 .Screen/x DEO2
|
|
|
|
[ LIT2 &x $2 ] EQU2 [ LIT2 &y2 $2 ] DUP2 .Screen/y DEO2
|
|
|
|
[ LIT2 &y $2 ] EQU2 [ LIT2 &color $1 -Screen/pixel ] DEO
|
|
|
|
AND ?&end
|
|
|
|
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy
|
|
|
|
STH2r ,&dy LDR2 ADD2 STH2
|
|
|
|
,&x2 LDR2 [ LIT2 &sx $2 ] ADD2 ,&x2 STR2
|
|
|
|
&skipy ( -- )
|
|
|
|
,&dx LDR2 gts2 ?&while
|
|
|
|
STH2r ,&dx LDR2 ADD2 STH2
|
|
|
|
,&y2 LDR2 [ LIT2 &sy $2 ] ADD2 ,&y2 STR2
|
|
|
|
!&while
|
|
|
|
&end POP2r JMP2r
|
|
|
|
|
|
|
|
@abs2 ( a* -- f )
|
|
|
|
DUP2 #0f SFT2 EQU ?{ #0000 SWP2 SUB2 }
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@lts2 ( a* b* -- f )
|
|
|
|
#8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
|
|
|
|
|
|
|
|
@gts2 ( a* b* -- f )
|
|
|
|
#8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
|
2023-03-13 01:10:28 -04:00
|
|
|
|