save pixels of drawing to ordered list

This commit is contained in:
Travis Shears 2025-07-01 18:24:37 +02:00
parent b331fd1a80
commit ed717cd95d
2 changed files with 42 additions and 1 deletions

View file

@ -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
)