]> git.sur5r.net Git - cc65/blob - libsrc/atari/irq.s
Merge pull request #56 from groessler/something_to_pull
[cc65] / libsrc / atari / irq.s
1 ;
2 ; IRQ handling (ATARI version)
3 ;
4
5         .export         initirq, doneirq
6         .import         callirq
7
8         .include        "atari.inc"
9 .ifdef __ATARIXL__
10         .import         __CHARGEN_START__
11         .include        "romswitch.inc"
12 .endif
13
14 ; ------------------------------------------------------------------------
15
16 .segment        "INIT"
17
18 initirq:
19         lda     VVBLKI
20         ldx     VVBLKI+1
21         sta     IRQInd+1
22         stx     IRQInd+2
23         lda     #6
24         ldy     #<IRQStub
25         ldx     #>IRQStub
26         jsr     SETVBV
27         rts
28
29 ; ------------------------------------------------------------------------
30
31 .code
32
33 doneirq:
34         lda     #6
35         ldy     IRQInd+1
36         ldx     IRQInd+2
37         jsr     SETVBV
38         rts
39
40 ; ------------------------------------------------------------------------
41
42 .segment        "LOWCODE"
43
44 IRQStub:
45         cld                             ; Just to be sure
46 .ifdef __ATARIXL__
47         pha
48 .ifdef CHARGEN_RELOC
49         lda     CHBAS
50         pha
51 .endif
52         lda     PORTB
53         pha
54         and     #$FE
55         sta     PORTB                   ; disable ROM
56         set_chbase >__CHARGEN_START__
57 .endif
58         jsr     callirq                 ; Call the functions
59 .ifdef __ATARIXL__
60         pla
61         sta     PORTB                   ; restore old ROM setting
62 .ifdef CHARGEN_RELOC
63         pla
64         sta     CHBAS
65         sta     CHBASE
66 .endif
67         pla
68 .endif
69         jmp     IRQInd                  ; Jump to the saved IRQ vector
70
71 ; ------------------------------------------------------------------------
72
73 .data
74
75 IRQInd: jmp     $0000