-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterrupts.asm
71 lines (49 loc) · 2.03 KB
/
interrupts.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
!zone setInterrupt
; **********************************************************************
; RASTER INTERRUPTS
; **********************************************************************
setInterrupt
sei ; set interrupt bit, make the CPU ignore interrupt requests
lda #$7f ; switch off interrupt signals from CIA-1
sta $dc0d
sta $dd0d
and CONTROL_REG_1 ; clear most significant bit of VIC's raster register
sta CONTROL_REG_1
lda $dc0d ; acknowledge pending interrupts from CIA-1
lda $dd0d ; acknowledge pending interrupts from CIA-2
lda #151 ; set rasterline where interrupt shall occur
sta RASTER_POS
lda #<irq1 ; set interrupt vectors, pointing to interrupt service routine below
sta $0314
lda #>irq1
sta $0315
lda #$01 ; enable raster interrupt signals from VIC
sta IMR
cli ; clear interrupt flag, allowing the CPU to respond to interrupt requests
rts
irq1 asl IRR ; acknowledge the interrupt by clearing the VIC's interrupt flag
lda .scanColor2
sta BCKGRND_COLOR_0
lda #<irq2 ; set interrupt vectors to the second interrupt service routine at Irq2
sta $0314
lda #>irq2
sta $0315
lda .scanLine1
sta RASTER_POS ; next interrupt will occur at line no. 0
jmp $ea81 ; jump into shorter ROM routine to only restore registers from the stack etc
irq2 asl IRR ; acknowledge the interrupt by clearing the VIC's interrupt flag
lda .scanColor1
sta BCKGRND_COLOR_0
lda #<irq1 ; set interrupt vectors back to the first interrupt service routine at Irq
sta $0314
lda #>irq1
sta $0315
lda .scanLine2
sta RASTER_POS ; next interrupt will occur at line no. 210
jmp $ea31 ; jump into KERNAL's standard interrupt service routine to handle keyboard scan, cursor display etc.j
; Local variables
.scanLine1: !byte 0
.scanLine2: !byte 0
.scanColor1: !byte 0
.scanColor2: !byte 0