]> git.sur5r.net Git - cc65/commitdiff
Fix timer IRQ hooking for atarixl target.
authorChristian Groessler <chris@groessler.org>
Tue, 14 Jan 2014 10:43:34 +0000 (11:43 +0100)
committerChristian Groessler <chris@groessler.org>
Mon, 20 Jan 2014 22:04:30 +0000 (23:04 +0100)
libsrc/atari/libref.s
libsrc/atari/mou/atrst.s
libsrc/atari/shadow_ram_timerirq1.s [new file with mode: 0644]

index e6b9df6a5b7cb848ba3e33a10194a351b4d21cfd..4f7cbbef6056a95066b834b43992ede19b81f50e 100644 (file)
@@ -8,11 +8,13 @@
 
 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
index 72808ad161d5a715d76f0250c93f1c94bfc69efa..04580f31a3736514ac5151717216e75b22bc02e0 100644 (file)
@@ -35,7 +35,7 @@ HEADER:
 
 ; Library reference
 
-        .addr   $0000
+libref: .addr   $0000
 
 ; Jump table
 
@@ -96,7 +96,6 @@ Buttons:        .res    1               ; Button mask
 XPosWrk:        .res    2
 YPosWrk:        .res    2
 
-OldT1:          .res    2
 visible:        .res    1
 
 .if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
@@ -108,11 +107,18 @@ dumy:           .res    1
 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
@@ -182,7 +188,23 @@ INSTALL:
         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
@@ -197,6 +219,8 @@ INSTALL:
         sta     VTIMR1+1
         plp
 
+.endif
+
         lda     #%00000001
         sta     AUDCTL
 
@@ -231,6 +255,13 @@ UNINSTALL:
         sta     IRQEN
         sta     POKMSK
 
+.ifdef __ATARIXL__
+
+        clc
+        jsr     set_VTIMR1_handler
+
+.else
+
         php
         sei
         lda     OldT1
@@ -239,6 +270,7 @@ UNINSTALL:
         sta     VTIMR1+1
         plp
 
+.endif
         ; fall thru...
 
 ;----------------------------------------------------------------------------
@@ -354,7 +386,7 @@ MOVE:   php
 
         lda     visible
         beq     @Ret
-        
+
         jsr     CSHOW
 
 @Ret:   plp                             ; Restore interrupt flag
@@ -520,7 +552,7 @@ IRQ:
 T1Han:  tya
         pha
         txa
-        pha     
+        pha
 
 .ifdef DEBUG
         lda     RANDOM
@@ -692,6 +724,9 @@ mmexit: sty     oldval
         tax
         pla
         tay
+.ifdef  __ATARIXL__
+        rts
+.else
         pla
         rti
-
+.endif
diff --git a/libsrc/atari/shadow_ram_timerirq1.s b/libsrc/atari/shadow_ram_timerirq1.s
new file mode 100644 (file)
index 0000000..f8a3e9b
--- /dev/null
@@ -0,0 +1,81 @@
+;
+; 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__