-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from paulscottrobson/mouse
Added Mouse commands to BASIC
- Loading branch information
Showing
10 changed files
with
227 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
; ************************************************************************************************ | ||
; ************************************************************************************************ | ||
; | ||
; Name: mouse.asm | ||
; Purpose: Return mouse state | ||
; Created: 9th April 2024 | ||
; Reviewed: No | ||
; Author: Paul Robson ([email protected]) | ||
; | ||
; ************************************************************************************************ | ||
; ************************************************************************************************ | ||
|
||
; ************************************************************************************************ | ||
; | ||
; MOUSE(x,y) Sets X,Y to mouse position, returns buttons (bit 0 left, bit 1 right) | ||
; MOUSE(x,y,s) Same but returns scroll wheel. | ||
; | ||
; ************************************************************************************************ | ||
|
||
.section code | ||
|
||
EXPUnaryMouse: ;; [mouse(] | ||
jsr EvaluateTerm ; first parameter. | ||
jsr ERRCheckComma | ||
inx | ||
jsr EvaluateTerm ; second parameter. | ||
inx | ||
lda #$FF ; default 3rd parameter (don't use if $FF) | ||
sta XSControl,x | ||
|
||
lda (codePtr),y ; , follows ? | ||
cmp #KWD_COMMA ; we have three parameters | ||
bne _EUMNoScroll | ||
iny ; consume it | ||
jsr EvaluateTerm ; third parameter | ||
_EUMNoScroll: | ||
dex ; restore stack position. | ||
dex | ||
jsr ERRCheckRParen ; check closing ) | ||
|
||
.DoSendMessage ; read the mouse state | ||
.byte 11,3 | ||
.DoWaitMessage | ||
|
||
phx ; save stack pos | ||
phy ; save code pos | ||
|
||
ldy #0 ; control parameter 0,1 | ||
jsr EMOCopyToVariable ; copy to first | ||
|
||
ldy #2 ; control parameter 2,3 | ||
inx ; copy to second | ||
jsr EMOCopyToVariable | ||
|
||
inx ; check third reference exists | ||
lda XSControl,x | ||
cmp #$FF | ||
beq _EUMNoScroll2 | ||
stz ControlParameters+6 ; it's in 5, make it 16 bit value | ||
ldy #5 ; copy to third | ||
jsr EMOCopyToVariable | ||
_EUMNoScroll2: | ||
ply | ||
plx ; restore stack pos. | ||
lda ControlParameters+4 ; get the button bits. | ||
jmp EXPUnaryReturnA ; and return that value. | ||
|
||
EMOCopyToVariable: | ||
lda XSControl,x ; check integer variable reference | ||
and #(XS_TYPEBIT|XS_ISVARIABLE) | ||
cmp #XS_ISVARIABLE | ||
bne _EMOCTJError | ||
|
||
lda XSNumber0,x ; make zTemp0 point to the variable | ||
sta zTemp0 | ||
lda XSNumber1,x | ||
sta zTemp0+1 | ||
|
||
phy ; copy the value over | ||
lda ControlParameters,y | ||
sta (zTemp0) | ||
lda ControlParameters+1,y | ||
ldy #1 | ||
sta (zTemp0),y | ||
ply | ||
|
||
rts | ||
|
||
_EMOCTJError: | ||
.error_type | ||
|
||
|
||
.send code | ||
|
||
; ************************************************************************************************ | ||
; | ||
; Changes and Updates | ||
; | ||
; ************************************************************************************************ | ||
; | ||
; Date Notes | ||
; ==== ===== | ||
; | ||
; ************************************************************************************************ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
; ************************************************************************************************ | ||
; ************************************************************************************************ | ||
; | ||
; Name: mouse.asm | ||
; Purpose: Control Mouse | ||
; Created: 9th April 2024 | ||
; Reviewed: No | ||
; Author: Paul Robson ([email protected]) | ||
; | ||
; ************************************************************************************************ | ||
; ************************************************************************************************ | ||
|
||
; ************************************************************************************************ | ||
; | ||
; MOUSE Command | ||
; | ||
; ************************************************************************************************ | ||
|
||
.section code | ||
|
||
Command_Mouse: ;; [mouse] | ||
lda (codePtr),y ; check for TO. | ||
cmp #KWD_TO | ||
beq _MOTo | ||
; | ||
; MOUSE SHOW|HIDE | ||
; | ||
cmp #KWD_SYS_SH1 ; check for SHOW and HIDE, shifted | ||
bne _MOError | ||
iny | ||
lda (codePtr),y ; check SHOW/HIDE | ||
iny | ||
cmp #KWD_SHOW-$100 | ||
beq _MOControl | ||
cmp #KWD_HIDE-$100 | ||
beq _MOControl | ||
_MOError: | ||
.error_syntax | ||
|
||
_MOControl: | ||
eor #KWD_HIDE-$100 ; 0 HIDE <>0 SHOW | ||
sta ControlParameters+0 | ||
.DoSendMessage ; set mouse visibility | ||
.byte 11,2 | ||
.DoWaitMessage | ||
|
||
rts | ||
|
||
; | ||
; MOUSE TO x,y | ||
; | ||
_MOTo: | ||
iny ; get coordinates | ||
ldx #0 | ||
jsr EXPEvalInteger16 | ||
inx | ||
jsr ERRCheckComma | ||
jsr EXPEvalInteger16 | ||
|
||
lda XSNumber0 ; set up for call. | ||
sta ControlParameters+0 | ||
lda XSNumber1 | ||
sta ControlParameters+1 | ||
lda XSNumber0+1 | ||
sta ControlParameters+2 | ||
lda XSNumber1+2 | ||
sta ControlParameters+3 | ||
|
||
.DoSendMessage ; set mouse position. | ||
.byte 11,1 | ||
.DoWaitMessage | ||
|
||
rts | ||
|
||
.send code | ||
|
||
; ************************************************************************************************ | ||
; | ||
; Changes and Updates | ||
; | ||
; ************************************************************************************************ | ||
; | ||
; Date Notes | ||
; ==== ===== | ||
; | ||
; ************************************************************************************************ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,16 @@ | ||
0 ' library #1 | ||
0 ' library #2 | ||
edit | ||
dim j0w(1,1) | ||
dim w7u$(2) | ||
print "This line" | ||
dim a7h$(5,4) | ||
dim f9$(1) | ||
dim j(7) | ||
dim g6(6) | ||
dim f5$(1) | ||
dim u1b(3) | ||
dim u6h8b(1) | ||
dim x6e9(4) | ||
dim u2$(4,3) | ||
dim r2$(4) | ||
dim v1u4v(1) | ||
dim h2i(4,2) | ||
dim m7p0i$(5) | ||
dim g2y(5,3) | ||
dim y3d0v$(5,4) | ||
dim w6(4,4) | ||
dim j$(3) | ||
dim k9e8h(4) | ||
w7u$(2) = "K" | ||
x6e9(2) = -377 | ||
g6(1) = 310.58 | ||
j0w(0,1) = 492 | ||
a7h$(1,3) = "CFFS" | ||
f5$(0) = "SBTCRBKC" | ||
j$(3) = "MMNPJTR" | ||
r2$(0) = "YMMACX" | ||
h2i(4,1) = -29.41 | ||
j0w(0,1) = 846.3 | ||
u2$(0,2) = "TNVDWXI" | ||
y3d0v$(3,0) = "ZZJYUF" | ||
k9e8h(0) = 742 | ||
u2$(1,3) = "QKPC" | ||
' | ||
' BASIC Mouse cursor manipulation | ||
' | ||
mouse show | ||
mouse to 260,180 | ||
repeat | ||
b = mouse(x,y,s) | ||
print chr$(20);x;" ";y;" ";b;" ";s;" " | ||
until false | ||
end | ||
' | ||
proc send.message(g,f) | ||
while peek($FF00):wend | ||
poke $FF01,f:poke $FF00,g | ||
while peek($FF00):wend | ||
endproc |
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
' | ||
' BASIC Mouse cursor manipulation | ||
' | ||
mouse show | ||
mouse to 260,180 | ||
repeat | ||
b = mouse(x,y,s) | ||
print chr$(20);x;" ";y;" ";b;" ";s;" " | ||
until false | ||
end | ||
' | ||
proc send.message(g,f) | ||
while peek($FF00):wend | ||
poke $FF01,f:poke $FF00,g | ||
while peek($FF00):wend | ||
endproc |