A2osX/DRV/MOUSE.DRV.S.txt

343 lines
6.7 KiB
Plaintext
Raw Normal View History

2015-03-17 22:05:33 +00:00
NEW
2017-12-22 21:24:30 +00:00
PREFIX /A2OSX.BUILD
AUTO 4,1
2015-03-17 22:05:33 +00:00
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/DRV/MOUSE.DRV
2015-03-17 22:05:33 +00:00
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/MLI.ERR.I
.INB /A2OSX.BUILD/INC/XY.MOUSE.I
.INB /A2OSX.BUILD/INC/LIBGUI.I
2015-03-17 22:05:33 +00:00
*--------------------------------------
ZPGoMouse .EQ ZPDRV
ZPTmpPtr1 .EQ ZPDRV+2
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
2015-03-17 22:05:33 +00:00
*--------------------------------------
CS.START cld
2015-06-03 18:30:57 +00:00
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
2015-03-17 22:05:33 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
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
2015-06-03 18:30:57 +00:00
stz ZPTmpPtr1
2015-03-17 22:05:33 +00:00
lda #$C1
sta ZPTmpPtr1+1
.1 ldx #DEVSIG.Value-DEVSIG.Offset-1
2015-03-17 22:05:33 +00:00
.2 ldy DEVSIG.Offset,x
lda (ZPTmpPtr1),y
cmp DEVSIG.Value,x
bne .3
dex
bpl .2
2015-03-17 22:05:33 +00:00
lda ZPTmpPtr1+1
2015-06-03 18:30:57 +00:00
sta DEVSLOTCn
2015-03-17 22:05:33 +00:00
and #$0F
sta DEVSLOT0n
2015-03-17 22:05:33 +00:00
ora #$30
2017-11-15 16:29:23 +00:00
sta DEV.HEADER.NAME+3
2015-03-17 22:05:33 +00:00
asl
asl
asl
asl
sta DEVSLOTn0
>PUSHW L.DEV.HEADER.NAME
2015-06-03 18:30:57 +00:00
>LDYA L.MSG.DETECT.OK
>SYSCALL PrintF.YA
2015-06-03 18:30:57 +00:00
clc
rts
2017-11-17 07:09:39 +00:00
.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
2015-06-03 18:30:57 +00:00
*--------------------------------------
CS.END
2017-11-17 07:09:39 +00:00
MSG.DETECT >CSTR "Apple Mouse Driver.\r\n"
2017-11-15 16:29:23 +00:00
MSG.DETECT.OK >CSTR "Mouse Installed As Device : %s\r\n"
MSG.DETECT.KO >CSTR "No Mouse Found.\r\n"
2016-06-07 06:10:18 +00:00
DEVSIG.Offset .HS 05070B0CFB
DEVSIG.Value .HS 38180120D6
2015-06-03 18:30:57 +00:00
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
DEV.HEADER cld
jmp (DRV.CS.START,x)
.DA #0
.BS 6
2017-11-15 16:29:23 +00:00
DEV.HEADER.NAME >CSTR "MOUX"
2015-06-03 18:30:57 +00:00
*--------------------------------------
* Driver Code
*--------------------------------------
DRV.CS.START .DA STATUS
.DA READBLOCK
.DA A2osX.BADCALL
.DA A2osX.BADCALL
.DA CONTROL
.DA A2osX.BADCALL
.DA OPEN
2015-06-03 18:30:57 +00:00
.DA CLOSE
.DA A2osX.BADCALL
.DA A2osX.BADCALL
L.DEVSTAT .DA DEVSTAT
2015-06-03 18:30:57 +00:00
.DA 0 end or relocation
*--------------------------------------
STATUS >LDYA L.DEVSTAT
clc
rts
*--------------------------------------
READBLOCK >STYA ZPTmpPtr1
ldy #S.MOUSE.S
lda #0
sta (ZPTmpPtr1),y Reset Flags
php
sei
* ldy #READMOUSE DONE BY IRQ MANAGER
* jsr GOMOUSE
ldx DEVSLOT0n
lda MOUSESTSx,x
and #MOUSESTSx.MOVED
beq .1
ldy #S.MOUSE.X1
lda MOUSEXLOx,x
sta (ZPTmpPtr1),y
iny
lda MOUSEXHIx,x
sta (ZPTmpPtr1),y
iny
lda MOUSEYLOx,x
2017-11-17 07:09:39 +00:00
sta (ZPTmpPtr1),y
iny
lda MOUSEYHIx,x
sta (ZPTmpPtr1),y
ldy #S.MOUSE.S
lda #S.MOUSE.S.MOVE
sta (ZPTmpPtr1),y
stz bDblClick Reset DblClick flag
.1 lda MOUSESTSx,x
and #MOUSESTSx.DOWN+MOUSESTSx.LDOWN
beq .8 no button state change:up & previously up
cmp #MOUSESTSx.DOWN+MOUSESTSx.LDOWN
beq .8 no button state change:down & previously down
asl if CS, down & previously up
bcc .2
ldy #S.MOUSE.S
lda #S.MOUSE.S.DOWN
ora (ZPTmpPtr1),y
sta (ZPTmpPtr1),y button has been pressed, start drag...
lda MOUSEXLOx,x
sta SrcDrag
lda MOUSEXHIx,x
sta SrcDrag+1
lda MOUSEYLOx,x
sta SrcDrag+2
lda MOUSEYHIx,x
sta SrcDrag+3
bra .8
.2 ldy #S.MOUSE.S
lda (ZPTmpPtr1),y
pha save move state
ora #S.MOUSE.S.UP
sta (ZPTmpPtr1),y
pla get back move state
bne .4 no move...click!
lda #S.MOUSE.S.CLK
bit bDblClick
bpl .3
lda #S.MOUSE.S.DCLK
ldy #1
sty bDblClick
.3 dec bDblClick
ldy #S.MOUSE.S
ora (ZPTmpPtr1),y
sta (ZPTmpPtr1),y
bra .8
.4 lda #S.MOUSE.S.DRAG
ldy #S.MOUSE.S
ora (ZPTmpPtr1),y
sta (ZPTmpPtr1),y
ldy #S.MOUSE.X2+3
.5 lda SrcDrag-S.MOUSE.X2,y
sta (ZPTmpPtr1),y
dey
bpl .5
.8 plp
ldy #S.MOUSE.S
lda (ZPTmpPtr1),y
beq .9
clc
rts
.9 lda #MLI.E.EOF
sec
rts
2015-03-17 22:05:33 +00:00
*--------------------------------------
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
2015-03-17 22:05:33 +00:00
rts
*--------------------------------------
* PRIVATE
2015-06-03 18:30:57 +00:00
*--------------------------------------
2015-03-17 22:05:33 +00:00
GOMOUSE pha
stz ZPGoMouse
ldx DEVSLOTCn
stx ZPGoMouse+1
2015-03-17 22:05:33 +00:00
lda (ZPGoMouse),y
sta ZPGoMouse
ldy DEVSLOTn0
2015-03-17 22:05:33 +00:00
pla
jmp (ZPGoMouse)
*--------------------------------------
2015-06-03 18:30:57 +00:00
DRV.CS.END
DEVSLOT0n .BS 1
2015-03-17 22:05:33 +00:00
DEVSLOTn0 .BS 1
DEVSLOTCn .BS 1
bDblClick .BS 1
SrcDrag .BS 4
2015-03-17 22:05:33 +00:00
*--------------------------------------
DEVSTAT .DA #0
.DA #0,#0,#0 size
>PSTR "Apple II Mouse"
.BS 2
.DA #S.DSTAT.T.XY
.DA #0
.DA #0
.DA #91
*--------------------------------------
2015-03-17 22:05:33 +00:00
MAN
SAVE /A2OSX.SRC/DRV/MOUSE.DRV.S
2015-03-17 22:05:33 +00:00
ASM