From ed717cd95de6d3b36639cc80577601a836059947 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Tue, 1 Jul 2025 18:24:37 +0200 Subject: [PATCH] save pixels of drawing to ordered list --- one_line_canvas.tal | 39 +++++++++++++++++++++++++++++++++++++++ playground.tal | 4 +++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/one_line_canvas.tal b/one_line_canvas.tal index 6ab6553..8b2e8d8 100644 --- a/one_line_canvas.tal +++ b/one_line_canvas.tal @@ -30,6 +30,8 @@ .canvas-height #01 ADD .canvas-width #01 SUB .canvas-height draw-v-line ( right line ) .canvas-height #01 ADD .canvas-width #02 MUL #01 ADD .canvas-height draw-v-line + ( set pxs-pt to start of pixels ) + ;pxs ;pxs-pt STA2 ;on-mouse .Mouse/vector DEO2 BRK @@ -47,6 +49,33 @@ .x LDZ2 .Screen/x DEO2 .y LDZ2 .Screen/y DEO2 #01 .Screen/pixel DEO + ( set local pt to start of pixels ) + !{ &local-pt $2 } + ;pxs ,/local-pt STR2 + &loop + ( is the drawing done? ) + ;pxs-pt LDA2 ( pt* ) + ;pxs #1550 ADD2 ( pt* end-of-px* ) + EQU2 ?/end + ( check if current xy has already been visited ) + ,/local-pt LDR2 LDA2 ( x1 y1 ) + .x LDZ2 NIP ( x1 y1 x ) + .y LDZ2 NIP ( x1 y1 x y ) + EQU2 ?/end + ( have we go through the whole list? ) + ,/local-pt LDR2 ( local-pt* ) + ;pxs #1550 ADD2 ( local-pt* end-of-px* ) + EQU2 ?/save + ( incrment pxs pointer and save it ) + ,/local-pt LDR2 ( local-pt* ) + #0002 ADD2 ( local-pt*+2 ) + ,/local-pt STR2 + !&loop + &save + .x LDZ2 NIP .y LDZ2 NIP ( x y ) + ;pxs-pt LDA2 ( x y pt* ) + STA2 + ;pxs-pt LDA2 INC2 INC2 ;pxs-pt STA2 &end JMP2r @@ -141,3 +170,13 @@ . . . . . . . . 3c . . . . . . . . 18 ) + +@pxs-pt $2 +@pxs $1550 ( 5456 ) +( + pxs are the pixels of the drawing in order they are drawn + 0001 05 <-- x1 + 0002 04 <-- y1 + 0003 05 <-- x2 + 0004 03 <-- y2 +) diff --git a/playground.tal b/playground.tal index e84b6b8..10b2c93 100644 --- a/playground.tal +++ b/playground.tal @@ -4,7 +4,9 @@ |0100 @on-reset - #02 #04 SUB + #0aa8 + #0058 + NIP ( mem-test ) BRK