PR#3 PREFIX /A2OSX.SRC NEW INC 1 AUTO 6 .LIST OFF .OP 65C02 .OR $2000 .TF /A2OSX.BOOT/DRV/MOUSE.DRV *-------------------------------------- .INB INC/MACROS.I .INB INC/IO.I .INB INC/A2OSX.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 MOUSESTSx .EQ $0778 MOUSESTSx.DOWN .EQ %10000000 MOUSESTSx.LDOWN .EQ %01000000 MOUSESTSx.MOVED .EQ %00100000 *-------------------------------------- * 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 SYS.PStrOutYA stz ZPTmpPtr1 lda #$C1 sta ZPTmpPtr1+1 .1 ldx #DEVSIG.Length-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 SYS.PStrOutYA lda #DEVMGR.ERRNOHW Not Found in any slot, exiting 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 >LDYA L.MSG.DETECT.OK >SYSCALL SYS.PStrOutYA >LDYA L.DEV.HEADER.NAME >SYSCALL SYS.PStrOutYA lda #13 >SYSCALL SYS.COutA clc rts *-------------------------------------- CS.END MSG.DETECT >PSTRING "Apple Mouse Card/IIc Mouse Driver.\n" MSG.DETECT.OK >PSTRING "Mouse Installed As Device : " MSG.DETECT.KO >PSTRING "No Mouse Found.\n" DEVSIG.Offset .HS 05070B0CFB DEVSIG.Value .HS 38180120D6 DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset *-------------------------------------- * Device Header (16 Bytes) *-------------------------------------- DEV.HEADER cld jmp (DRV.CS.START,x) .HS 00 DevID .DA #S.DEV.F.EVENT DEV.HEADER.NAME >PSTRING "MOU1" NAME .HS 00 .HS 00.00.00.00 *-------------------------------------- * Driver Code *-------------------------------------- DRV.CS.START .DA OPEN .DA GETEVENT .DA COUT .DA CLOSE .DA GETINFO .DA IRQ .DA SELECT L.DEVINFO .DA DEVINFO .DA 0 end or relocation *-------------------------------------- OPEN * bit RROMBNK2 Renable ROM to allow MOUSE II firmware php to read IIe ROM ID bytes sei lda #1 Enable, Polling mode ldy #SETMOUSE jsr GOMOUSE ldy #INITMOUSE Reset jsr GOMOUSE stz LOCLAMPLO stz LOCLAMPHI lda #559 sta HICLAMPLO lda /559 sta HICLAMPHI lda #0 set X ldy #CLAMPMOUSE jsr GOMOUSE stz LOCLAMPLO stz LOCLAMPHI lda #191 sta HICLAMPLO lda /191 sta HICLAMPHI lda #1 set Y ldy #CLAMPMOUSE jsr GOMOUSE ldy #HOMEMOUSE jsr GOMOUSE plp clc rts *-------------------------------------- GETEVENT lda A2osX.ASCREEN cmp #3 is DHGR screen active? bne .9 php sei ldy #READMOUSE jsr GOMOUSE ldx DEVSLOT0n ldy #S.EVT.DATALO 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 & previoulsy up bcc .1 lda #EVENT.MOUSEUP bra .2 .1 lda #EVENT.MOUSEDOWN .2 sta (pEvent),y .3 lda MOUSESTSx,x and #MOUSESTSx.MOVED beq .4 lda (pEvent),y ora #EVENT.MOUSEMOVE sta (pEvent),y .4 ldy #S.EVT.DATAW1 lda MOUSEXLOx,x sta (pEvent),y iny lda MOUSEXHIx,x sta (pEvent),y iny lda MOUSEYLOx,x sta (pEvent),y iny lda MOUSEYHIx,x sta (pEvent),y plp ldy #S.EVT.DATALO lda (pEvent),y beq .9 lda #S.EVT.F.MOUSE sta (pEvent) clc rts .9 lda #0 Error = no event sec rts *-------------------------------------- COUT IRQ SELECT lda #DEVMGR.ERRUNSUP sec rts *-------------------------------------- CLOSE php sei lda #0 Disable ldy #SETMOUSE jsr GOMOUSE plp clc rts *-------------------------------------- GETINFO >LDYA L.DEVINFO clc rts *-------------------------------------- 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 *-------------------------------------- DEVINFO .DA #S.DEVINFO.TYPE.XY MAN SAVE DRV/MOUSE.DRV.S ASM