mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-27 04:49:20 +00:00
325 lines
6.4 KiB
Plaintext
325 lines
6.4 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF DRV/MOUSE.DRV
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/MLI.ERR.I
|
||
.INB INC/XY.MOUSE.I
|
||
.INB INC/LIBGUI.I
|
||
*--------------------------------------
|
||
ZPTmpPtr1 .EQ ZPDRV
|
||
*--------------------------------------
|
||
* 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
|
||
|
||
stz ZPTmpPtr1
|
||
lda #$C1
|
||
.1 sta ZPTmpPtr1+1
|
||
|
||
ldx #DEVSIG.Value-DEVSIG.Offset-1
|
||
|
||
.2 ldy DEVSIG.Offset,x
|
||
lda (ZPTmpPtr1),y
|
||
cmp DEVSIG.Value,x
|
||
bne .3
|
||
dex
|
||
bpl .2
|
||
|
||
lda ZPTmpPtr1+1
|
||
sta GOMOUSE+2
|
||
sta GOMOUSE.Cn+1
|
||
sta GOMOUSE.JMP+2
|
||
and #$0F
|
||
sta DEVSLOT0n
|
||
ora #$30
|
||
sta DEV.HEADER.NAME+3
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
sta GOMOUSE.n0+1
|
||
|
||
>PUSHW L.DEV.HEADER.NAME
|
||
>LDYA L.MSG.DETECT.OK
|
||
>SYSCALL printf
|
||
clc
|
||
rts
|
||
|
||
.3 lda ZPTmpPtr1+1 no match, try next slot....
|
||
inc
|
||
cmp #$C8
|
||
bne .1
|
||
|
||
>LDYA L.MSG.DETECT.KO
|
||
>SYSCALL printf
|
||
|
||
lda #MLI.E.NODEV
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.DETECT .AZ "Apple Mouse Driver.\r\n"
|
||
MSG.DETECT.OK .AZ "Mouse Installed As Device : %s\r\n"
|
||
MSG.DETECT.KO .AZ "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 .AZ "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
|
||
|
||
stz READBLOCK.S+1 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
|
||
sta (ZPTmpPtr1),y
|
||
|
||
iny
|
||
lda MOUSEYHIx,x
|
||
sta (ZPTmpPtr1),y
|
||
|
||
lda #S.MOUSE.S.MOVE
|
||
tsb READBLOCK.S+1
|
||
|
||
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
|
||
|
||
lda #S.MOUSE.S.DOWN
|
||
tsb READBLOCK.S+1 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 lda READBLOCK.S+1
|
||
|
||
pha save move state
|
||
|
||
ora #S.MOUSE.S.UP
|
||
sta READBLOCK.S+1
|
||
|
||
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
|
||
|
||
tsb READBLOCK.S+1
|
||
bra .8
|
||
|
||
.4 lda #S.MOUSE.S.DRAG
|
||
tsb READBLOCK.S+1
|
||
|
||
ldy #S.MOUSE.X2+3
|
||
|
||
.5 lda SrcDrag-S.MOUSE.X2,y
|
||
sta (ZPTmpPtr1),y
|
||
dey
|
||
bpl .5
|
||
|
||
.8 plp
|
||
|
||
READBLOCK.S lda #$ff SELF MODIFIED
|
||
beq .9
|
||
|
||
ldy #S.MOUSE.S
|
||
sta (ZPTmpPtr1),y
|
||
clc
|
||
rts
|
||
|
||
.9 lda #MLI.E.EOF
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CONTROL >STYA ZPTmpPtr1
|
||
|
||
php
|
||
sei
|
||
|
||
ldy #0
|
||
ldx #0 set X
|
||
jsr SETCLAMP
|
||
|
||
ldy #4
|
||
ldx #1 set Y
|
||
jsr SETCLAMP
|
||
|
||
ldy #HOMEMOUSE
|
||
jsr GOMOUSE
|
||
|
||
plp
|
||
clc
|
||
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
|
||
*--------------------------------------
|
||
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
|
||
*--------------------------------------
|
||
GOMOUSE ldx $FF00,y SELF MODIFIED
|
||
stx GOMOUSE.JMP+1
|
||
GOMOUSE.Cn ldx #$ff SELF MODIFIED
|
||
GOMOUSE.n0 ldy #$ff SELF MODIFIED
|
||
GOMOUSE.JMP jmp $FFFF SELF MODIFIED
|
||
*--------------------------------------
|
||
DRV.CS.END
|
||
DEVSLOT0n .BS 1
|
||
bDblClick .BS 1
|
||
SrcDrag .BS 4
|
||
*--------------------------------------
|
||
DEVSTAT .DA #0
|
||
.DA #0,#0,#0
|
||
>PSTR "Apple II Mouse"
|
||
.BS 2
|
||
.DA #S.DIB.T.XY
|
||
.DA #0
|
||
.DA #0
|
||
.DA #91
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/DRV/MOUSE.DRV.S
|
||
ASM
|