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
!draw-cell
@draw-cursor
@screen-to-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
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
.tcem LDZ #00 EQU ?&skip
SWP reverse-tint SWP
@ -317,18 +323,27 @@
@on-click-up ( unclick^ -> )
POP JMP2r
( @on-move
.Mouse/x DEI2 .lastmouse-x LDZ2 NEQ2 ?&redraw
.Mouse/y DEI2 .lastmouse-y LDZ2 NEQ2 ?&redraw
JMP2r
&redraw
.Mouse/x DEI2 .Screen/x DEO2
.Mouse/y DEI2 .Screen/y DEO2
#02f0 ;ascii ADD2 .Screen/addr DEO2
#43 .Screen/sprite DEO
.Mouse/x DEI2 .lastmouse-x STZ2
.Mouse/y DEI2 .lastmouse-y STZ2
JMP2r )
@draw-at ( x* y* addr* -> )
STH2k .Screen/addr DEO2 ( x* y* [addr*] )
STH2k .Screen/y DEO2 ( x [addr* y*] )
.Screen/x DEO2 ( [addr* y* x*] )
#43 .Screen/sprite DEOk ( 43 sprite^ [addr* y* x*] )
STH2r #0008 ADD2 .Screen/y DEO2 ( 43 sprite^ [addr*] )
STH2r #0008 ADD2 .Screen/addr DEO2 ( 43 sprite^ )
DEO JMP2r ( )
@on-move ( -> )
.Mouse/x DEI2 .lastmouse-x LDZ2 NEQ2 ?&redraw ( )
.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 ( -> )
.lastmouse-st LDZ ( last )
@ -338,7 +353,7 @@
DUP STHkr EOR AND ( last&(last^st) [st] )
on-click-up ( [st] )
STHr .lastmouse-st STZ ( )
( on-move ) BRK ( )
on-move BRK ( )
@on-key ( -> )
.Controller/key DEI ?&ok !on-button