-
Notifications
You must be signed in to change notification settings - Fork 1
/
funkyirq.asm
170 lines (137 loc) · 2.1 KB
/
funkyirq.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
.org $0834
;; install the 1st interrupt routine
;; turn off interrupt requests
SEI
;; turn off CIA interrupt requests
LDA #$7F
STA $DC0D
STA $DD0D
;; ACK CIA IRQs
LDA $DC0D
LDA $DD0D
;; Enable the Raster Interrupt Requests
LDA #$01
STA $D01A
;; 69th raster line
LDA #$45
STA $D012
;; zero out the high bit of D011
LDA $D011
AND #$7F
STA $D011
;; put the address of the routine into the
;; the address that normally gets called
LDA #<IRQ1
STA $0314
LDA #>IRQ1
STA $0315
;; turn interrupts back on
CLI
;; return to caller
rts
IRQ1:
;;
;; routine goes here
;; vvvv ----- vvvv
;; delay for timing
NOP
NOP
NOP
NOP
NOP
NOP
NOP
;; SAVE THE SCREEN BG COLOUR
LDA $D021
STA OLDBG
;; CHANGE THE SCREEN BG COLOUR
LDA #$00
STA $D021
;; SAVE THE CURRENT D016
LDA $D016
STA OLDSHIFT
;; shift the screen 7 bits to the right
AND #$F8
ORA #$07
STA $D016
;;
;; INSTALL THE 2ND INT ROUTINE
;;
LDA #$7F
STA $DC0D
STA $DD0D
LDA $DC0D
LDA $DD0D
LDA #$01
STA $D01A
;; 133rd raster line
;; LDA #$85
LDA #$4A
STA $D012
;; zero out the high bit of D011
;; LDA $D011
;; AND #$7F
;; STA $D011
LDA #<IRQ2
STA $0314
LDA #>IRQ2
STA $0315
;;
;; ^^^^ ----- ^^^^
;;
;; ACK INT
LDA #$FF
STA $D019
;; CALL AN INTERRUPT ROUTINE THAT
;; DOES VERY LITTLE
;; JMP $EA81
JMP $EA7E
IRQ2:
;;
;; routine goes here
;; vvvv ----- vvvv
;; delay for timing
NOP
NOP
NOP
NOP
NOP
NOP
NOP
;; RESTORE SCREEN COLOUR
;; LDA OPCODE
.BYTE #$A9
OLDBG:
.BYTE #$06
STA $D021
.BYTE #$A9
OLDSHIFT:
.BYTE #$C8
STA $D016
;; RE-INSTALL 1ST ROUTINE
LDA #$7F
STA $DC0D
STA $DD0D
LDA $DC0D
LDA $DD0D
LDA #$01
STA $D01A
;; 69th raster line
LDA #$45
STA $D012
;; zero out the high bit of D011
;; LDA $D011
;; AND #$7F
;; STA $D011
LDA #<IRQ1
STA $0314
LDA #>IRQ1
STA $0315
;;
;; ^^^^ ----- ^^^^
;;
;; ACK INT
LDA #$FF
STA $D019
;; CALL THE NORMAL INT ROUTINE
JMP $EA31