Added eraser

This commit is contained in:
Devine Lu Linvega 2024-05-31 11:52:32 -07:00
parent f897d6f5be
commit 149c04a2cc
3 changed files with 38 additions and 21 deletions

Binary file not shown.

View File

@ -16,6 +16,9 @@
@pen-icn [ @pen-icn [
c0e0 9090 4848 2424 1212 0909 0600 0000 ] c0e0 9090 4848 2424 1212 0909 0600 0000 ]
@eraser-icn [
7e81 8181 8181 8181 8181 8181 7e00 0000 ]
@bar-icn &a [ @bar-icn &a [
0000 007e 007e 007e 007e 007e 007e 0000 ] 0000 007e 007e 007e 007e 007e 007e 0000 ]
&b [ &b [

View File

@ -38,7 +38,7 @@
( name ) "Note 20 "Pad 0a ( name ) "Note 20 "Pad 0a
( details ) "Original 20 "by 20 "Donn 20 "Denman 0a ( details ) "Original 20 "by 20 "Donn 20 "Denman 0a
( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a ( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
( date ) "May 20 "30, 20 "2024 00 01 ( date ) "May 20 "31, 20 "2024 00 01
( icon ) 83 =appicon ( icon ) 83 =appicon
( (
@ -117,27 +117,29 @@
POP BRK POP BRK
@on-mouse-sketch ( -> ) @on-mouse-sketch ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;pen-icn <update-cursor> [ LIT2 00 -Mouse/state ] DEI STHk NEQ #41 ADD ;eraser-icn ;pen-icn STHr #01 GTH ?{ SWP2 }
POP2 <update-cursor>
( | handle states ) ( | handle states )
[ LIT &last $1 ] .Mouse/state DEI DUP ,&last STR [ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{ POP #02 }
( ) DUP2 #0100 NEQ2 ?{ file-save } DUP ,&last STR
( ) DUP2 #0200 NEQ2 ?{ file-save } ( ) SWPk #00 NEQ #0001 NEQ2 ?{ file-save }
DUP2 #0200 NEQ2 ?{ DUP2 #0001 NEQ2 ?{
( from ) ,&x1 LDR2 ,&y1 LDR2 ( | down mouse1 )
( to x ) ,&x1 LDR2 .Mouse/x DEI2 snap
( to y ) ,&y1 LDR2 .Mouse/y DEI2 #0012 SUB2 snap
( paint ) #01 <paint-line>
<draw-sketch> }
DUP2 #00 NEQ #0001 NEQ2 ?{
.Mouse/x DEI2 DUP2 ,&x1 STR2 .Mouse/x DEI2 DUP2 ,&x1 STR2
.Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2 .Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2
#01 set-pixel <draw-sketch> } #01 <set-pixel>
DUP2 #0101 NEQ2 ?{ <draw-sketch> }
DUP #01 NEQ ?{
( release/drag mouse1 )
( from* ) [ LIT2 &x1 $2 ] [ LIT2 &y1 $2 ] ( from* ) [ LIT2 &x1 $2 ] [ LIT2 &y1 $2 ]
( to ) .Mouse/x DEI2 DUP2 ,&x1 STR2 ( to ) .Mouse/x DEI2 DUP2 ,&x1 STR2
.Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2 .Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2
( paint ) #01 <paint-line> ( paint ) #01 <paint-line>
<draw-sketch> } <draw-sketch> }
DUP #02 NEQ2 ?{
( | release/drag mouse2 )
.Mouse/x DEI2 .Mouse/y DEI2 #0012 SUB2 <eraser>
<redraw> }
POP2 BRK POP2 BRK
@on-mouse-foot ( -> ) @on-mouse-foot ( -> )
@ -201,8 +203,7 @@
@toggle-sketch ( -- ) @toggle-sketch ( -- )
.selection/sketch LDZk #01 EOR SWP STZ .selection/sketch LDZk #01 EOR SWP STZ
#41 ;pen-icn ;caret-icn .selection/sketch LDZ ?{ SWP2 } #41 ;pen-icn ;caret-icn .selection/sketch LDZ ?{ SWP2 }
POP2 <update-cursor> POP2 !<update-cursor>
JMP2r
@erase-sketch ( -- ) @erase-sketch ( -- )
;&mcpy .System/expansion DEO2 ;&mcpy .System/expansion DEO2
@ -212,24 +213,37 @@
@get-row ( x* y* -- row* ) @get-row ( x* y* -- row* )
STH2k #03 SFT2 SWP2 #03 SFT2 SWP2 #001c MUL2 ADD2 #30 SFT2 STH2r #0007 AND2 ADD2 ;sketch ADD2 JMP2r STH2k #03 SFT2 SWP2 #03 SFT2 SWP2 #001c MUL2 ADD2 #30 SFT2 STH2r #0007 AND2 ADD2 ;sketch ADD2 JMP2r
@set-pixel ( x* y* color -- ) @<set-pixel> ( x* y* color -- )
?add-pixel ?<add-pixel>
( >> ) ( >> )
@remove-pixel ( x* y* -- ) @<remove-pixel> ( x* y* -- )
( keep x* ) OVR2 NIP #07 AND STH ( keep x* ) OVR2 NIP #07 AND STH
( get byte ) get-row LDAk ( get byte ) get-row LDAk
( mask ) #0107 STHr SUB #40 SFT SFT #ff EOR AND ( mask ) #0107 STHr SUB #40 SFT SFT #ff EOR AND
( save ) ROT ROT STA ( save ) ROT ROT STA
JMP2r JMP2r
@add-pixel ( x* y* -- ) @<add-pixel> ( x* y* -- )
( keep x* ) OVR2 NIP #07 AND STH ( keep x* ) OVR2 NIP #07 AND STH
( get byte ) get-row LDAk ( get byte ) get-row LDAk
( mask ) #0107 STHr SUB #40 SFT SFT ORA ( mask ) #0107 STHr SUB #40 SFT SFT ORA
( save ) ROT ROT STA ( save ) ROT ROT STA
JMP2r JMP2r
@<eraser> ( x* y* -- )
,&y STR2
,&x STR2
#000a #0000
&>v ( -- )
STH2k #0006 #0000
&>h ( -- )
( x ) DUP2 [ LIT2 &x $2 ] ADD2
( y ) STH2kr [ LIT2 &y $2 ] ADD2 <remove-pixel>
INC2 GTH2k ?&>h
POP2 POP2 POP2r INC2 GTH2k ?&>v
POP2 POP2 JMP2r
@<paint-line> ( x1* y1* x2* y2* color -- ) @<paint-line> ( x1* y1* x2* y2* color -- )
,&color STR ,&color STR
,&y STR2 ,&y STR2
@ -242,7 +256,7 @@
#ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2 #ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
[ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2 [ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2
&>while ( -- ) &>while ( -- )
( draw ) ,&x2 LDR2 ,&y2 LDR2 [ LIT &color $1 ] set-pixel ( draw ) ,&x2 LDR2 ,&y2 LDR2 [ LIT &color $1 ] <set-pixel>
( x ) [ LIT2 &x2 $2 ] [ LIT2 &x $2 ] EQU2 ( x ) [ LIT2 &x2 $2 ] [ LIT2 &x $2 ] EQU2
( y ) [ LIT2 &y2 $2 ] [ LIT2 &y $2 ] EQU2 AND ?&end ( y ) [ LIT2 &y2 $2 ] [ LIT2 &y $2 ] EQU2 AND ?&end
STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?{ STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?{