]> git.sur5r.net Git - cc65/blob - libsrc/atari/irq.s
Merge remote-tracking branch 'upstream/master' into creativision
[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        "ONCE"
17
18 initirq:
19         lda     VVBLKD
20         ldx     VVBLKD+1
21         sta     IRQInd+1
22         stx     IRQInd+2
23         lda     #7
24         ldy     #<IRQStub
25         ldx     #>IRQStub
26         jmp     SETVBV
27
28 ; ------------------------------------------------------------------------
29
30 .code
31
32 doneirq:
33         lda     #7
34         ldy     IRQInd+1
35         ldx     IRQInd+2
36         jmp     SETVBV
37
38 ; ------------------------------------------------------------------------
39
40 .segment        "LOWCODE"
41
42 IRQStub:
43         cld                             ; Just to be sure
44 .ifdef __ATARIXL__
45 .ifdef CHARGEN_RELOC
46         lda     CHBAS
47         pha
48 .endif
49         lda     PORTB
50         pha
51         and     #$FE
52         sta     PORTB                   ; disable ROM
53         set_chbase >__CHARGEN_START__
54 .endif
55         jsr     callirq                 ; Call the functions
56 .ifdef __ATARIXL__
57         pla
58         sta     PORTB                   ; restore old ROM setting
59 .ifdef CHARGEN_RELOC
60         pla
61         sta     CHBAS
62         sta     CHBASE
63 .endif
64 .endif
65         jmp     IRQInd                  ; Jump to the saved IRQ vector
66
67 ; ------------------------------------------------------------------------
68
69 .data
70
71 IRQInd: jmp     $0000