Better mouse picking

This commit is contained in:
Devine Lu Linvega 2023-04-26 20:52:44 -07:00
parent fe0d461997
commit c87ade3404
1 changed files with 16 additions and 17 deletions

View File

@ -302,14 +302,6 @@ JMP2r
JMP2r JMP2r
@walk-on ( -- f )
.Screen/x DEI2 .Mouse/x DEI2 LTH2
.Screen/y DEI2 .Mouse/y DEI2 #0008 SUB2 LTH2 ORA #00 NEQ
#ff MUL
JMP2r
@pos-to-line ( y* -- line ) @pos-to-line ( y* -- line )
#0018 SUB2 #04 SFT2 NIP #0018 SUB2 #04 SFT2 NIP
@ -323,33 +315,40 @@ JMP2r
( walk to line ) ( walk to line )
.Mouse/y DEI2 pos-to-line ,&line STR .Mouse/y DEI2 pos-to-line ,&line STR
;mem ;mem
&while &walk-line
.Screen/y DEI2 pos-to-line [ LIT &line $1 ] EQU ?&end .Screen/y DEI2 pos-to-line [ LIT &line $1 ] EQU ?&end-line
walk-char walk-char POP
INC2 LDAk ?&while INC2 LDAk ?&walk-line
&end &end-line
( walk to char ) ( walk to char )
.Mouse/x DEI2 #0001 SUB2 ,&x STR2
&walk-char
.Screen/x DEI2 [ LIT2 &x $2 ] GTH2 ?&end-char
walk-char ?&end-char
INC2 LDAk ?&walk-char
&end-char
JMP2r JMP2r
@walk-char ( addr* -- addr* ) @walk-char ( addr* -- addr* lb )
( wrap ) ( wrap )
LDAk #20 GTH ?&no-wrap LDAk #20 GTH ?&no-wrap
DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap DUP2 word-length .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap
!draw-linebreak #01 !draw-linebreak
&no-wrap &no-wrap
( char ) ( char )
LDAk #20 SUB #00 SWP ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2 LDAk #20 SUB #00 SWP ;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
.Screen/x DEO2 .Screen/x DEO2
( tab ) ( tab )
LDAk #09 NEQ ?&no-tab LDAk #09 NEQ ?&no-tab
!draw-tab #01 !draw-tab
&no-tab &no-tab
( linebreak ) ( linebreak )
LDAk #0a NEQ ?&no-lb LDAk #0a NEQ ?&no-lb
!draw-linebreak #01 !draw-linebreak
&no-lb &no-lb
#00
JMP2r JMP2r