basic cursor support

This commit is contained in:
~d6 2023-02-06 22:49:35 -05:00
parent 6ef2e4326a
commit 6be81b66bf
1 changed files with 29 additions and 14 deletions

View File

@ -251,9 +251,15 @@
cur-addr LDA2 cur-addr LDA2
!draw-cell !draw-cell
@draw-cursor @screen-to-cursor
.cur-x LDZ2 #30 SFT2 ( width ) #0008 ( border ) ADD2 .Screen/x DEO2 .cur-x LDZ2 #30 SFT2 ( width ) #0008 ( border ) ADD2 .Screen/x DEO2
.cur-y LDZ2 #000c MUL2 ( height ) #0008 ( border ) ADD2 .Screen/y DEO2 .cur-y LDZ2 #000c MUL2 ( height ) #0008 ( border ) ADD2 .Screen/y DEO2
JMP2r
@draw-cursor
( .cur-x LDZ2 #30 SFT2 ( width ) #0008 ( border ) ADD2 .Screen/x DEO2
.cur-y LDZ2 #000c MUL2 ( height ) #0008 ( border ) ADD2 .Screen/y DEO2 )
screen-to-cursor
cur-addr LDA2 cur-addr LDA2
.tcem LDZ #00 EQU ?&skip .tcem LDZ #00 EQU ?&skip
SWP reverse-tint SWP SWP reverse-tint SWP
@ -317,18 +323,27 @@
@on-click-up ( unclick^ -> ) @on-click-up ( unclick^ -> )
POP JMP2r POP JMP2r
( @on-move @draw-at ( x* y* addr* -> )
.Mouse/x DEI2 .lastmouse-x LDZ2 NEQ2 ?&redraw STH2k .Screen/addr DEO2 ( x* y* [addr*] )
.Mouse/y DEI2 .lastmouse-y LDZ2 NEQ2 ?&redraw STH2k .Screen/y DEO2 ( x [addr* y*] )
JMP2r .Screen/x DEO2 ( [addr* y* x*] )
&redraw #43 .Screen/sprite DEOk ( 43 sprite^ [addr* y* x*] )
.Mouse/x DEI2 .Screen/x DEO2 STH2r #0008 ADD2 .Screen/y DEO2 ( 43 sprite^ [addr*] )
.Mouse/y DEI2 .Screen/y DEO2 STH2r #0008 ADD2 .Screen/addr DEO2 ( 43 sprite^ )
#02f0 ;ascii ADD2 .Screen/addr DEO2 DEO JMP2r ( )
#43 .Screen/sprite DEO
.Mouse/x DEI2 .lastmouse-x STZ2 @on-move ( -> )
.Mouse/y DEI2 .lastmouse-y STZ2 .Mouse/x DEI2 .lastmouse-x LDZ2 NEQ2 ?&redraw ( )
JMP2r ) .Mouse/y DEI2 .lastmouse-y LDZ2 NEQ2 ?&redraw ( )
JMP2r ( )
&redraw ( )
.lastmouse-x LDZ2 .lastmouse-y LDZ2 ( lx* ly* )
#0200 ;cp437 ADD2 draw-at ( )
.Mouse/x DEI2 .Mouse/y DEI2 ( x* y* )
OVR2 OVR2 #01e0 ;cp437 ADD2 draw-at ( x* y* )
.lastmouse-y STZ2 .lastmouse-x STZ2 ( )
screen-to-cursor ( )
JMP2r ( )
@on-mouse ( -> ) @on-mouse ( -> )
.lastmouse-st LDZ ( last ) .lastmouse-st LDZ ( last )
@ -338,7 +353,7 @@
DUP STHkr EOR AND ( last&(last^st) [st] ) DUP STHkr EOR AND ( last&(last^st) [st] )
on-click-up ( [st] ) on-click-up ( [st] )
STHr .lastmouse-st STZ ( ) STHr .lastmouse-st STZ ( )
( on-move ) BRK ( ) on-move BRK ( )
@on-key ( -> ) @on-key ( -> )
.Controller/key DEI ?&ok !on-button .Controller/key DEI ?&ok !on-button