em_libref := _exit
joy_libref := _exit
-mouse_libref := _exit
ser_libref := atari_ser_libref
.ifdef __ATARIXL__
.import CIO_handler
tgi_libref := CIO_handler
+ .import set_VTIMR1_handler
+mouse_libref := set_VTIMR1_handler
.else
+mouse_libref := _exit
tgi_libref := _exit
.endif
; Library reference
- .addr $0000
+libref: .addr $0000
; Jump table
XPosWrk: .res 2
YPosWrk: .res 2
-OldT1: .res 2
visible: .res 1
.if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
oldval: .res 1
.endif
+.ifndef __ATARIXL__
+OldT1: .res 2
+.else
-; Default values for some of the above variables
+.data
+set_VTIMR1_handler:
+ .byte $4C, 0, 0
+.endif
.rodata
+; Default values for some of the above variables
; (We use ".proc" because we want to define both a label and a scope.)
.proc DefVars
jsr CMOVEY
cli
-; install timer irq routine to poll mouse
+; Install timer irq routine to poll mouse.
+
+.ifdef __ATARIXL__
+
+ ; Setup pointer to wrapper install/deinstall function.
+ lda libref
+ sta set_VTIMR1_handler+1
+ lda libref+1
+ sta set_VTIMR1_handler+2
+
+ ; Install my handler.
+ sec
+ lda #<T1Han
+ ldx #>T1Han
+ jsr set_VTIMR1_handler
+
+.else
lda VTIMR1
sta OldT1
sta VTIMR1+1
plp
+.endif
+
lda #%00000001
sta AUDCTL
sta IRQEN
sta POKMSK
+.ifdef __ATARIXL__
+
+ clc
+ jsr set_VTIMR1_handler
+
+.else
+
php
sei
lda OldT1
sta VTIMR1+1
plp
+.endif
; fall thru...
;----------------------------------------------------------------------------
lda visible
beq @Ret
-
+
jsr CSHOW
@Ret: plp ; Restore interrupt flag
T1Han: tya
pha
txa
- pha
+ pha
.ifdef DEBUG
lda RANDOM
tax
pla
tay
+.ifdef __ATARIXL__
+ rts
+.else
pla
rti
-
+.endif
--- /dev/null
+;
+; Atari XL shadow RAM timer IRQ #1 handler
+;
+; Christian Groessler, chris@groessler.org, 2014
+;
+
+;DEBUG = 1
+
+.ifdef __ATARIXL__
+
+SHRAM_HANDLERS = 1
+ .include "atari.inc"
+ .include "romswitch.inc"
+ .export set_VTIMR1_handler
+
+
+.segment "LOWBSS"
+
+VTIMR1_handler: .res 3
+
+
+.segment "BSS"
+
+old_VTIMR1_handler:
+ .res 2
+
+
+.segment "LOWCODE"
+
+; timer interrupt handler:
+; disable ROM, call user handler, enable ROM again
+
+my_VTIMR1_handler:
+ disable_rom_quick
+ jsr VTIMR1_handler
+ enable_rom_quick
+ pla
+ rti
+
+.segment "CODE"
+
+; install or remove VTIMR1 handler
+; input: CF - 0/1 for remove/install handler
+; AX - pointer to handler (if CF=1)
+; registers destroyed
+
+set_VTIMR1_handler:
+
+ bcc @remove
+
+; install vector
+
+ stx VTIMR1_handler+2
+ sta VTIMR1_handler+1 ; save passed vector in low memory
+ lda #$4C ; "JMP" opcode
+ sta VTIMR1_handler
+
+ lda VTIMR1
+ sta old_VTIMR1_handler
+ lda VTIMR1+1
+ sta old_VTIMR1_handler+1
+
+ lda #<my_VTIMR1_handler
+ php
+ sei
+ sta VTIMR1
+ lda #>my_VTIMR1_handler
+ sta VTIMR1+1
+ plp
+ rts
+
+@remove: php
+ sei
+ lda old_VTIMR1_handler
+ sta VTIMR1
+ lda old_VTIMR1_handler+1
+ sta VTIMR1+1
+ plp
+ rts
+
+.endif ; .ifdef __ATARIXL__