]> git.sur5r.net Git - cc65/blob - libsrc/c128/irq.s
Adjusted C declarations to the changed static driver names.
[cc65] / libsrc / c128 / irq.s
1 ;
2 ; IRQ handling (C128 version)
3 ;
4
5         .export         initirq, doneirq
6         .import         callirq
7
8         .include        "c128.inc"
9
10 IRQInd  = $2FD          ; JMP $0000 - used as indirect IRQ vector
11
12 ; ------------------------------------------------------------------------
13
14 .segment        "INIT"
15
16 initirq:
17         lda     IRQVec
18         ldx     IRQVec+1
19         sta     IRQInd+1
20         stx     IRQInd+2
21         lda     #<IRQStub
22         ldx     #>IRQStub
23         jmp     setvec
24
25 ; ------------------------------------------------------------------------
26
27 .code
28
29 doneirq:
30         lda     IRQInd+1
31         ldx     IRQInd+2
32 setvec: sei
33         sta     IRQVec
34         stx     IRQVec+1
35         cli
36         rts
37
38 ; ------------------------------------------------------------------------
39 ; The C128 has ROM parallel to the RAM starting from $4000. The startup code
40 ; above will change this setting so that we have RAM from $0000-$BFFF. This
41 ; works quite well with the exception of interrupts: The interrupt handler
42 ; is in ROM, and the ROM switches back to the ROM configuration, which means
43 ; that parts of our program may not be accessible. To solve this, we place
44 ; the following code into a special segment called "LOWCODE" which will be
45 ; placed just above the startup code, so it goes into a RAM area that is
46 ; not banked.
47
48 .segment        "LOWCODE"
49
50 IRQStub:
51         cld                             ; Just to be sure
52         lda     MMU_CR                  ; Get old register value
53         pha                             ; And save on stack
54         lda     #MMU_CFG_CC65           ; Bank 0 with kernal ROM
55         sta     MMU_CR
56         jsr     callirq                 ; Call the functions
57         pla                             ; Get old register value
58         sta     MMU_CR
59         jmp     IRQInd                  ; Jump to the saved IRQ vector