Remove pixel offset so x,y values are zero based

This commit is contained in:
Travis Shears 2026-01-11 11:21:55 +01:00
parent 762be17704
commit f768942015
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
3 changed files with 23 additions and 21 deletions

View file

@ -43,19 +43,23 @@
#65 EQU ?write-drawing-file-to-disk
BRK
@on-mouse ( -> )
.Mouse/x DEI2 LIT2 =canvas-width SUB2 .x STZ2
.Mouse/y DEI2 LIT2 =canvas-height SUB2 .y STZ2
.Mouse/x DEI2 .Mouse/y DEI2 ( y x )
draw-cursor
add-px-to-drawing
BRK
@add-px-to-drawing
( figure out if px on on canvas )
( x too small )
LIT2 =canvas-width .x LDZ2 GTH2 ?/end
( x too big )
LIT2 =canvas-width #0002 MUL2 .x LDZ2 LTH2 ?/end
( y too small )
LIT2 =canvas-height .y LDZ2 GTH2 ?/end
LIT2 =canvas-width .x LDZ2 LTH2 ?/end
( y too big )
LIT2 =canvas-height #0002 MUL2 .y LDZ2 LTH2 ?/end
LIT2 =canvas-height .y LDZ2 LTH2 ?/end
( draw px to screen )
.x LDZ2 .Screen/x DEO2
.y LDZ2 .Screen/y DEO2
.x LDZ2 LIT2 =canvas-width ADD2 .Screen/x DEO2
.y LDZ2 LIT2 =canvas-height ADD2 .Screen/y DEO2
#01 .Screen/pixel DEO
( set local pt to start of pixels )
!{ &local-pt $2 }
@ -94,21 +98,16 @@
JMP2r
&filename "drawing.1line $1
@on-mouse ( -> )
.Mouse/x DEI2 .x STZ2
.Mouse/y DEI2 .y STZ2
draw-cursor
add-px-to-drawing
BRK
@draw-cursor
@draw-cursor ( y x -- )
( clear fg )
LIT2 0000 .Screen/x DEO2
LIT2 0000 .Screen/y DEO2
#c0 .Screen/pixel DEO
( draw cursor sprite to fg )
.x LDZ2 #0002 SUB2 .Screen/x DEO2
.y LDZ2 #0002 SUB2 .Screen/y DEO2
#0002 SUB2 .Screen/y DEO2 ( x )
#0002 SUB2 .Screen/x DEO2
;cursor-sprite .Screen/addr DEO2
#41 .Screen/sprite DEO
JMP2r
@ -120,7 +119,6 @@
( store vars )
!{ &y $1 &l $1 }
,/y STR ,/l STR
&loop
( set y )
,/y LDR DUP ( y y )
@ -144,7 +142,6 @@
( store vars )
!{ &x $1 &l $1 }
,/x STR ,/l STR
&loop
( set x )
,/x LDR DUP ( x x )