Changed the mouse API: Introduced a new flag byte that contains information
about the driver, the mouse kernel needs to know. Current supported: Two flags to enable interrupts before or after calling the driver INSTALL routine. git-svn-id: svn://svn.cc65.org/cc65/trunk@3741 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
;/* */
|
||||
;/* */
|
||||
;/* */
|
||||
;/* (C) 2003-2004 Ullrich von Bassewitz */
|
||||
;/* (C) 2003-2006 Ullrich von Bassewitz */
|
||||
;/* R<>merstra<72>e 52 */
|
||||
;/* D-70794 Filderstadt */
|
||||
;/* EMail: uz@cc65.org */
|
||||
@@ -69,6 +69,7 @@
|
||||
IOCTL .addr
|
||||
IRQ .addr
|
||||
.endstruct
|
||||
FLAGS .byte ; Mouse driver flags
|
||||
CALLBACKS .struct ; Jump instructions
|
||||
.byte ; JMP opcode
|
||||
CHIDE .addr ; Jump address
|
||||
@@ -94,7 +95,16 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; The mouse API version, stored in MOUSE_HDR::VERSION
|
||||
|
||||
MOUSE_API_VERSION = $00
|
||||
MOUSE_API_VERSION = $01
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS.
|
||||
; Note: If neither of MOUSE_FLAG_XXX_IRQ is set, no interrupts are supplied
|
||||
; to the driver. If one of the bits is set, the interrupt vector MUST be
|
||||
; valid.
|
||||
|
||||
MOUSE_FLAG_EARLY_IRQ = $40 ; Enable IRQ *before* calling INSTALL
|
||||
MOUSE_FLAG_LATE_IRQ = $80 ; Enable IRQ *after* calling INSTALL
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Mouse button definitions
|
||||
|
||||
@@ -46,6 +46,9 @@ status := $0778
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Mouse driver flags
|
||||
.byte MOUSE_FLAG_EARLY_IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
CSHOW: jmp $0000 ; Show the cursor
|
||||
|
||||
@@ -37,6 +37,10 @@ HEADER:
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Mouse driver flags
|
||||
|
||||
.byte MOUSE_FLAG_LATE_IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
|
||||
@@ -36,6 +36,10 @@ HEADER:
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Mouse driver flags
|
||||
|
||||
.byte MOUSE_FLAG_LATE_IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
|
||||
@@ -37,6 +37,10 @@ HEADER:
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Mouse driver flags
|
||||
|
||||
.byte MOUSE_FLAG_LATE_IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
|
||||
@@ -36,6 +36,10 @@ HEADER:
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Mouse driver flags
|
||||
|
||||
.byte MOUSE_FLAG_LATE_IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
|
||||
@@ -35,6 +35,7 @@ mouse_pos: jmp return0
|
||||
mouse_info: jmp return0
|
||||
mouse_ioctl: jmp return0
|
||||
mouse_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
|
||||
mouse_flags: .byte $00
|
||||
|
||||
; Driver header signature
|
||||
.rodata
|
||||
@@ -77,6 +78,12 @@ _mouse_install:
|
||||
cpy #(MOUSE_HDR::JUMPTAB + .sizeof(MOUSE_HDR::JUMPTAB))
|
||||
bne @L1
|
||||
|
||||
; Copy the flags byte. It is located directly behind the jump vectors, so Y
|
||||
; is already correct when we come here. To save code, we use copyjv - crude
|
||||
; but effective.
|
||||
|
||||
jsr copyjv
|
||||
|
||||
; Copy the callback vectors into the driver space
|
||||
|
||||
jsr popsreg
|
||||
@@ -94,23 +101,34 @@ _mouse_install:
|
||||
|
||||
; Install the IRQ vector if the driver needs it
|
||||
|
||||
lda mouse_irq+2 ; Check high byte of IRQ vector
|
||||
beq @L3 ; Jump if vector invalid
|
||||
lda #$4C ; Jump opcode
|
||||
sta mouse_irq ; Activate IRQ routine
|
||||
bit mouse_flags ; Test MOUSE_FLAG_EARLY_IRQ
|
||||
bvc @L3 ; Jump if no interrupts at this time
|
||||
jsr install_irq ; Activate IRQ routine
|
||||
|
||||
; Call driver install routine and check for errors
|
||||
|
||||
@L3: jsr mouse_install
|
||||
tay ; Test error code
|
||||
beq @L4 ; Jump if no error
|
||||
bne uninstall_irq ; Jump on error
|
||||
|
||||
; Uninstall IRQ vector if install routine had errors. A/X contains the error
|
||||
; code from mouse_install, so don't use it.
|
||||
; No errors on INSTALL. If the driver needs late IRQs, enable them now. Be
|
||||
; careful not to use A/X since these registers contain the error code from
|
||||
; INSTALL.
|
||||
|
||||
bit mouse_flags ; Test MOUSE_FLAG_LATE_IRQ
|
||||
bpl Exit ; Jump if vector not needed
|
||||
install_irq:
|
||||
ldy #$4C ; Jump opcode
|
||||
sty mouse_irq ; Activate IRQ routine
|
||||
Exit: rts
|
||||
|
||||
; Uninstall IRQ vector if install routine had errors. A/X may contain the
|
||||
; error code from mouse_install, so don't use it.
|
||||
|
||||
uninstall_irq:
|
||||
ldy #$60 ; RTS opcode
|
||||
sty mouse_irq ; Disable IRQ entry point
|
||||
@L4: rts
|
||||
rts
|
||||
|
||||
; Driver signature invalid. One word is still on the stack
|
||||
|
||||
@@ -141,9 +159,7 @@ copycb: lda (sreg),y
|
||||
; /* Uninstall the currently loaded driver. Returns an error code. */
|
||||
|
||||
_mouse_uninstall:
|
||||
lda #$60 ; RTS opcode
|
||||
sta mouse_irq ; Disable IRQ entry point
|
||||
|
||||
jsr uninstall_irq ; Disable driver interrupts
|
||||
jsr mouse_uninstall ; Call driver routine
|
||||
|
||||
mouse_clear_ptr: ; External entry point
|
||||
|
||||
Reference in New Issue
Block a user