Use Timer2 for mouse polling.

This follows a suggestion by Sijmen Schouten in issue #818.
Platoterm64 now works with mouse at 1200 baud.

Bump MOUSE_API_VERSION in asminc/mouse-kernel.inc.

Fix typo in testcode/lib/mouse-test.c.
This commit is contained in:
Christian Groessler
2019-01-29 22:00:55 +01:00
parent 7a034f505b
commit 055c294ac0
5 changed files with 122 additions and 41 deletions

View File

@@ -134,6 +134,7 @@ YPosWrk: .res 2
irq_enabled: .res 1 ; flag indicating that the high frequency polling interrupt is enabled
old_porta_vbi: .res 1 ; previous PORTA value of the VBI interrupt (IRQ)
how_long: .res 1 ; counter for how many VBI interrupts the mouse hasn't been moved
in_irq: .res 1 ; flag indicating high-frequency polling interrupt is active
.if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
dumx: .res 1
@@ -145,11 +146,11 @@ oldval: .res 1
.endif
.ifndef __ATARIXL__
OldT1: .res 2
OldT2: .res 2
.else
.data
set_VTIMR1_handler:
set_VTIMR2_handler:
.byte $4C, 0, 0
.endif
@@ -226,29 +227,29 @@ INSTALL:
; Setup pointer to wrapper install/deinstall function.
lda libref
sta set_VTIMR1_handler+1
sta set_VTIMR2_handler+1
lda libref+1
sta set_VTIMR1_handler+2
sta set_VTIMR2_handler+2
; Install my handler.
sec
lda #<T1Han
ldx #>T1Han
jsr set_VTIMR1_handler
lda #<T2Han
ldx #>T2Han
jsr set_VTIMR2_handler
.else
lda VTIMR1
sta OldT1
lda VTIMR1+1
sta OldT1+1
lda VTIMR2
sta OldT2
lda VTIMR2+1
sta OldT2+1
php
sei
lda #<T1Han
sta VTIMR1
lda #>T1Han
sta VTIMR1+1
lda #<T2Han
sta VTIMR2
lda #>T2Han
sta VTIMR2+1
plp
.endif
@@ -257,20 +258,12 @@ INSTALL:
sta AUDCTL
lda #0
sta AUDC1
sta AUDC2
lda #15
sta AUDF1
sta AUDF2
sta STIMER
.if 0 ; the IRQ will now be dynamically enabled when the mouse is moved
lda POKMSK
ora #%00000001 ; timer 1 enable
sta POKMSK
sta IRQEN
sta irq_enabled
.endif
lda PORTA
and #$0f
sta old_porta_vbi
@@ -290,23 +283,23 @@ UNINSTALL:
; uninstall timer irq routine
lda POKMSK
and #%11111110 ; timer 1 disable
and #%11111101 ; timer 2 disable
sta IRQEN
sta POKMSK
.ifdef __ATARIXL__
clc
jsr set_VTIMR1_handler
jsr set_VTIMR2_handler
.else
php
sei
lda OldT1
sta VTIMR1
lda OldT1+1
sta VTIMR1+1
lda OldT2
sta VTIMR2
lda OldT2+1
sta VTIMR2+1
plp
.endif
@@ -503,7 +496,7 @@ IRQ: lda PORTA ; mouse port contents
; Turn mouse polling IRQ back on
lda POKMSK
ora #%00000001 ; timer 1 enable
ora #%00000010 ; timer 2 enable
sta POKMSK
sta IRQEN
sta irq_enabled
@@ -533,7 +526,7 @@ IRQ: lda PORTA ; mouse port contents
sta irq_enabled
lda POKMSK
and #%11111110 ; timer 1 disable
and #%11111101 ; timer 2 disable
sta IRQEN
sta POKMSK
@@ -620,13 +613,18 @@ IRQ: lda PORTA ; mouse port contents
;----------------------------------------------------------------------------
; T1Han: Local IRQ routine to poll mouse
; T2Han: Local IRQ routine to poll mouse
;
T1Han: lda CRITIC ; if CRITIC flag is set, disable the
T2Han: lda CRITIC ; if CRITIC flag is set, disable the
bne disable_me ; high frequency polling IRQ, in order
; not to interfere with SIO I/O (e.g.
; floppy access)
; floppy access or serial I/O)
lda in_irq ; handler entered again?
bne skip ; yes, ignore this interrupt
inc in_irq
cli ; enable IRQs so that we don't block them for too long
tya
pha
@@ -803,6 +801,8 @@ mmexit: sty oldval
tax
pla
tay
dec in_irq
skip:
.ifdef __ATARIXL__
rts
.else
@@ -819,7 +819,7 @@ mmexit: sty oldval
disable_me:
lda POKMSK
and #%11111110 ; timer 1 disable
and #%11111101 ; timer 2 disable
sta IRQEN
sta POKMSK
lda #0