-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathirqutil.s
More file actions
59 lines (48 loc) · 800 Bytes
/
irqutil.s
File metadata and controls
59 lines (48 loc) · 800 Bytes
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
;;
;; Set a interrupt routine
;;
.macro set_irq_routine rasterline,address
;; Tell vic2 to generate raster IRQ
lda #$01
sta $d01a
;; Just use the first 255 rasterlines.
lda #rasterline
sta $d012
lda $d011 ; so just delete the
and #$7f ; 8th bit of $d011
sta $d011
;; Set the address of the irq routine
lda #<address
sta $fffe
lda #>address
sta $ffff
.endmacro
;;
;; Start a IRQ routine
;;
.macro start_irq_routine
;; Save the registers, so we can use them
;; in the IRQ routine.
pha
tya
pha
txa
pha
;; Clear IRQ condition
lda #$ff
sta $d019
.endmacro
;;
;; End an IRQ routine
;;
.macro end_irq_routine
;; Restore registers from stack
pla
tax
pla
tay
pla
;; Return from interrupt to the main
;; program.
rti
.endmacro