From 149c04a2cc625c662c62231c34c61da8ad4ae943 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 31 May 2024 11:52:32 -0700 Subject: [PATCH] Added eraser --- gui/notepad/spritesheet10x10.chr | Bin 4096 -> 4096 bytes gui/notepad/src/assets.tal | 3 ++ gui/notepad/src/notepad.tal | 56 +++++++++++++++++++------------ 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/gui/notepad/spritesheet10x10.chr b/gui/notepad/spritesheet10x10.chr index d9c4ae00ee3840736a4c80963d7b02ea813d0780..a47455c016cd23b26dc8d54d03a79763bf52a14a 100644 GIT binary patch delta 36 lcmZorXi(Uoz_Qta^#LQt|3(OyEWz@F6~z3%S(NoR2LJ|C4*LKA delta 24 gcmZorXi(Uoz%p5Y?Zd ) - [ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;pen-icn + [ LIT2 00 -Mouse/state ] DEI STHk NEQ #41 ADD ;eraser-icn ;pen-icn STHr #01 GTH ?{ SWP2 } + POP2 ( | handle states ) - [ LIT &last $1 ] .Mouse/state DEI DUP ,&last STR - ( ) DUP2 #0100 NEQ2 ?{ file-save } - ( ) DUP2 #0200 NEQ2 ?{ file-save } - DUP2 #0200 NEQ2 ?{ - ( from ) ,&x1 LDR2 ,&y1 LDR2 - ( to x ) ,&x1 LDR2 .Mouse/x DEI2 snap - ( to y ) ,&y1 LDR2 .Mouse/y DEI2 #0012 SUB2 snap - ( paint ) #01 - } - DUP2 #00 NEQ #0001 NEQ2 ?{ + [ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{ POP #02 } + DUP ,&last STR + ( ) SWPk #00 NEQ #0001 NEQ2 ?{ file-save } + DUP2 #0001 NEQ2 ?{ + ( | down mouse1 ) .Mouse/x DEI2 DUP2 ,&x1 STR2 .Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2 - #01 set-pixel } - DUP2 #0101 NEQ2 ?{ + #01 + } + DUP #01 NEQ ?{ + ( release/drag mouse1 ) ( from* ) [ LIT2 &x1 $2 ] [ LIT2 &y1 $2 ] ( to ) .Mouse/x DEI2 DUP2 ,&x1 STR2 .Mouse/y DEI2 #0012 SUB2 DUP2 ,&y1 STR2 ( paint ) #01 } + DUP #02 NEQ2 ?{ + ( | release/drag mouse2 ) + .Mouse/x DEI2 .Mouse/y DEI2 #0012 SUB2 + } POP2 BRK @on-mouse-foot ( -> ) @@ -201,8 +203,7 @@ @toggle-sketch ( -- ) .selection/sketch LDZk #01 EOR SWP STZ #41 ;pen-icn ;caret-icn .selection/sketch LDZ ?{ SWP2 } - POP2 - JMP2r + POP2 ! @erase-sketch ( -- ) ;&mcpy .System/expansion DEO2 @@ -212,24 +213,37 @@ @get-row ( x* y* -- row* ) STH2k #03 SFT2 SWP2 #03 SFT2 SWP2 #001c MUL2 ADD2 #30 SFT2 STH2r #0007 AND2 ADD2 ;sketch ADD2 JMP2r -@set-pixel ( x* y* color -- ) - ?add-pixel +@ ( x* y* color -- ) + ? ( >> ) -@remove-pixel ( x* y* -- ) +@ ( x* y* -- ) ( keep x* ) OVR2 NIP #07 AND STH ( get byte ) get-row LDAk ( mask ) #0107 STHr SUB #40 SFT SFT #ff EOR AND ( save ) ROT ROT STA JMP2r -@add-pixel ( x* y* -- ) +@ ( x* y* -- ) ( keep x* ) OVR2 NIP #07 AND STH ( get byte ) get-row LDAk ( mask ) #0107 STHr SUB #40 SFT SFT ORA ( save ) ROT ROT STA JMP2r +@ ( 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 + INC2 GTH2k ?&>h + POP2 POP2 POP2r INC2 GTH2k ?&>v + POP2 POP2 JMP2r + @ ( x1* y1* x2* y2* color -- ) ,&color STR ,&y STR2 @@ -242,7 +256,7 @@ #ffff [ LIT2 00 _&y2 ] LDR2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2 [ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 STH2 &>while ( -- ) - ( draw ) ,&x2 LDR2 ,&y2 LDR2 [ LIT &color $1 ] set-pixel + ( draw ) ,&x2 LDR2 ,&y2 LDR2 [ LIT &color $1 ] ( x ) [ LIT2 &x2 $2 ] [ LIT2 &x $2 ] EQU2 ( y ) [ LIT2 &y2 $2 ] [ LIT2 &y $2 ] EQU2 AND ?&end STH2kr DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?{