-
Notifications
You must be signed in to change notification settings - Fork 0
/
int.asm
177 lines (118 loc) · 1.83 KB
/
int.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
170
171
172
173
174
175
176
177
EXTERN _tick
EXTERN _pick
EXTERN _music_playing
EXTERN MusicPlay
EXTERN FxPlay
EXTERN UpdateAy
EXTERN letsplay
EXTERN MuteAy
;;;;;;;;;;;;;;;;;;;;;;
; void setup_int(void)
;;;;;;;;;;;;;;;;;;;;;;
SECTION code_user
PUBLIC _setup_int
_setup_int:
; im2 table @ 0xd000
ld hl,0xd000
ld de,0xd001
ld bc,256
ld (hl),0xd1
ldir
; jump to isr
ld a,0xc3
ld (0xd1d1),a
ld hl,isr
ld (0xd1d2),hl
; I register
ld a,0xd0
ld i,a
im 2
ei
ret
;;;;;;;;;;;;;;;;;;;
; interrupt routine
;;;;;;;;;;;;;;;;;;;
SECTION code_crt_common ;; place very low in memory, out of top 16k
PUBLIC isr
PUBLIC isr_skip
isr:
push af
push bc
push de
push hl
exx
ex af,af'
push af
push bc
push de
push hl
push ix
push iy
; update clock
ld a,(_tick)
inc a
ld (_tick),a
isr_skip:
; music
ld a,0x80
ld i,a ; point I at uncontended bank
ld a,h
or l
; FX here
ld a,6
call enable_bank_n
call FxPlay
call MusicPlay
call UpdateAy
call restore_bank_0
ld a,0xd0
ld i,a ; restore I
pop iy
pop ix
pop hl
pop de
pop bc
pop af
ex af,af'
exx
pop hl
pop de
pop bc
pop af
ei
reti
;;;;;;;;;
; banking
;;;;;;;;;
SECTION code_crt_common ;; place very low in memory, out of top 16k
PUBLIC enable_bank_n
PUBLIC enable_bank_6
enable_bank_6:
ld a, 6
enable_bank_n:
; return address
pop hl
; move stack pointer
ld (temp_sp),sp
ld sp,0
; enable bank
and 0x07
or 0x10
ld bc,0x7ffd
out (c),a
; return
jp (hl)
temp_sp: defw 0
;
PUBLIC restore_bank_0
restore_bank_0:
; return address
pop hl
; restore stack pointer
ld sp,(temp_sp)
; restore bank 0
ld a,0x10
ld bc,0x7ffd
out (c),a
; return
jp (hl)