A2osX/DRV/MOUSE.DRV.S.txt

323 lines
7.1 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/DRV/MOUSE.DRV
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/MLI.ERR.I
*--------------------------------------
ZPGoMouse .EQ ZPDRV
ZPTmpPtr1 .EQ ZPDRV+2
*--------------------------------------
EVENT.MOUSEUP .EQ %00000001
EVENT.MOUSEDOWN .EQ %00000010
EVENT.MOUSEMOVE .EQ %00000100
EVENT.MOUSEDRAG .EQ %00001000
EVENT.MOUSECLK .EQ %00010000
EVENT.MOUSEDCLK .EQ %00100000
*--------------------------------------
SETMOUSE .EQ $12 Sets mouse mode
SERVEMOUSE .EQ $13 Services mouse interrupt
READMOUSE .EQ $14 Reads mouse position
CLEARMOUSE .EQ $15 Clears mouse position to 0 (for delta mode)
POSMOUSE .EQ $16 Sets mouse position to a user-defined pos
CLAMPMOUSE .EQ $17 Sets mouse bounds in a window
HOMEMOUSE .EQ $18 Sets mouse to upper-left corner of clamp win
INITMOUSE .EQ $19 Resets mouse clamps to default values,sets mouse position to 0,0
LOCLAMPLO .EQ $0478 low byte of low clamp.
HICLAMPLO .EQ $04F8 low byte of high clamp.
LOCLAMPHI .EQ $0578 high byte of low clamp.
HICLAMPHI .EQ $05F8 high byte of high clamp.
MOUSEXLOx .EQ $0478
MOUSEYLOx .EQ $04F8
MOUSEXHIx .EQ $0578
MOUSEYHIx .EQ $05F8
* .EQ $0678
* .EQ $06F8
MOUSESTSx .EQ $0778
MOUSESTSx.DOWN .EQ %10000000
MOUSESTSx.LDOWN .EQ %01000000
MOUSESTSx.MOVED .EQ %00100000
MOUSESTSx.INTVBL .EQ %00001000
MOUSESTSx.INTBUT .EQ %00000100
MOUSESTSx.INTMOVE .EQ %00000010
MOUSEMODx .EQ $07F8
MOUSEMODx.INTVBL .EQ %00001000
MOUSEMODx.INTBUT .EQ %00000100
MOUSEMODx.INTMOVE .EQ %00000010
MOUSEMODx.ACTIVE .EQ %00000001
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp Dev.Detect cld,jmp abs=DRV
.DA #$61 6502,Level 1 (65c02)
.DA #1 DRV Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length
.DA DEV.HEADER-CS.START Device Header Offset
.DA DRV.CS.START-CS.START Driver Code Offset
.DA DRV.CS.END-DRV.CS.START Drv Code Length
*--------------------------------------
* Relocation Table
*--------------------------------------
L.MSG.DETECT .DA MSG.DETECT
L.MSG.DETECT.OK .DA MSG.DETECT.OK
L.MSG.DETECT.KO .DA MSG.DETECT.KO
L.DEV.HEADER.NAME .DA DEV.HEADER.NAME
.DA 0 End Of Reloc Table
*--------------------------------------
Dev.Detect >LDYA L.MSG.DETECT
>SYSCALL PrintF.YA
stz ZPTmpPtr1
lda #$C1
sta ZPTmpPtr1+1
.1 ldx #DEVSIG.Value-DEVSIG.Offset-1
.2 ldy DEVSIG.Offset,x
lda (ZPTmpPtr1),y
cmp DEVSIG.Value,x
bne .3
dex
bpl .2
bra .4
.3 inc ZPTmpPtr1+1 no match, try next slot....
lda ZPTmpPtr1+1
cmp #$C8
bne .1
>LDYA L.MSG.DETECT.KO
>SYSCALL PrintF.YA
lda #MLI.E.NODEV
sec
rts
.4 lda ZPTmpPtr1+1
sta DEVSLOTCn
and #$0F
sta DEVSLOT0n
ora #$30
sta DEV.HEADER.NAME+4
asl
asl
asl
asl
sta DEVSLOTn0
>PUSHW L.DEV.HEADER.NAME
>LDYA L.MSG.DETECT.OK
>SYSCALL PrintF.YA
clc
rts
*--------------------------------------
CS.END
MSG.DETECT >CSTR "Apple Mouse Card/IIc Mouse Driver.\r\n"
MSG.DETECT.OK >CSTR "Mouse Installed As Device : %S\r\n"
MSG.DETECT.KO >CSTR "No Mouse Found.\r\n"
DEVSIG.Offset .HS 05070B0CFB
DEVSIG.Value .HS 38180120D6
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
DEV.HEADER cld
jmp (DRV.CS.START,x)
.DA #0
.BS 6
DEV.HEADER.NAME >PSTR "MOUX"
*--------------------------------------
* Driver Code
*--------------------------------------
DRV.CS.START .DA STATUS
.DA READBLOCK
.DA A2osX.BADCALL
.DA A2osX.BADCALL
.DA CONTROL
.DA A2osX.BADCALL
.DA OPEN
.DA CLOSE
.DA A2osX.BADCALL
.DA A2osX.BADCALL
L.DEVSTAT .DA DEVSTAT
.DA 0 end or relocation
*--------------------------------------
STATUS >LDYA L.DEVSTAT
clc
rts
*--------------------------------------
READBLOCK >STYA ZPTmpPtr1
lda #0
sta (ZPTmpPtr1) Reset Flags
php
sei
* ldy #READMOUSE DONE BY IRQ MANAGER
* jsr GOMOUSE
ldx DEVSLOT0n
lda MOUSESTSx,x
and #MOUSESTSx.DOWN+MOUSESTSx.LDOWN
beq .3 no button state change:up & previously up
cmp #MOUSESTSx.DOWN+MOUSESTSx.LDOWN
beq .3 no button state change:down & previously down
asl if CS, down & previously up
bcc .1
lda #EVENT.MOUSEUP
bra .2
.1 lda #EVENT.MOUSEDOWN
.2 sta (ZPTmpPtr1)
.3 lda MOUSESTSx,x
and #MOUSESTSx.MOVED
beq .4
lda (ZPTmpPtr1)
ora #EVENT.MOUSEMOVE
sta (ZPTmpPtr1)
.4 ldy #1
lda MOUSEXLOx,x
sta (ZPTmpPtr1),y
iny
lda MOUSEXHIx,x
sta (ZPTmpPtr1),y
iny
lda MOUSEYLOx,x
sta (ZPTmpPtr1),y
iny
lda MOUSEYHIx,x
sta (ZPTmpPtr1),y
plp
lda (ZPTmpPtr1)
beq .9
clc
rts
.9 lda #MLI.E.EOF
sec
rts
*--------------------------------------
CONTROL >STYA ZPTmpPtr1
php
sei
ldy #0
ldx #0 set X
jsr CONTROL.SETCLAMP
ldy #4
ldx #1 set Y
jsr CONTROL.SETCLAMP
ldy #HOMEMOUSE
jsr GOMOUSE
plp
clc
rts
*--------------------------------------
CONTROL.SETCLAMP
lda (ZPTmpPtr1),y
sta LOCLAMPLO
iny
lda (ZPTmpPtr1),y
sta LOCLAMPHI
iny
lda (ZPTmpPtr1),y
sta HICLAMPLO
iny
lda (ZPTmpPtr1),y
sta HICLAMPHI
txa
ldy #CLAMPMOUSE
jsr GOMOUSE
rts
*--------------------------------------
OPEN php
sei
ldx DEVSLOT0n
lda MOUSEMODx,x keep if VBLInt already activated by kernel
and #MOUSEMODx.INTVBL
ora #MOUSEMODx.ACTIVE Enable, Polling mode
ldy #SETMOUSE
jsr GOMOUSE
ldy #INITMOUSE Reset
jsr GOMOUSE
plp
clc
rts
*--------------------------------------
CLOSE php
sei
ldx DEVSLOT0n
lda MOUSEMODx,x keep if VBLInt already activated by kernel
and #MOUSEMODx.INTVBL Disable ALL but VBLInt if previously active
ldy #SETMOUSE
jsr GOMOUSE
plp
clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
GOMOUSE pha
stz ZPGoMouse
ldx DEVSLOTCn
stx ZPGoMouse+1
lda (ZPGoMouse),y
sta ZPGoMouse
ldy DEVSLOTn0
pla
jmp (ZPGoMouse)
*--------------------------------------
DRV.CS.END
DEVSLOT0n .BS 1
DEVSLOTn0 .BS 1
DEVSLOTCn .BS 1
*--------------------------------------
DEVSTAT .DA #0
.DA #0,#0,#0 size
>PSTR "Apple II Mouse"
.BS 2
.DA #S.DSTAT.T.XY
.DA #0
.DA $0900
*--------------------------------------
MAN
SAVE /A2OSX.SRC/DRV/MOUSE.DRV.S
ASM