]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | global add_hla | |
3 | global ioiniml,ioini1l | |
4 | global intinit | |
5 | global bufinit | |
6 | ||
7 | global fifolst | |
8 | ||
9 | extrn ?pmsg | |
10 | extrn msg.sm,hwl2phy | |
11 | ||
12 | include config.inc | |
13 | include z180reg.inc | |
14 | ||
15 | ;-------------------------------------------------------------- | |
16 | ; | |
17 | ; add a to hl | |
18 | ; | |
19 | ; return: | |
20 | ; hl = hl + a | |
21 | ; Flags undefined | |
22 | ||
23 | cseg ; (common. TODO: check for banked) | |
24 | ||
25 | add_hla: | |
26 | add a,l | |
27 | ld l,a | |
28 | ret nc | |
29 | inc h | |
30 | ret | |
31 | ||
32 | ;---------------------------------------------------------------------- | |
33 | ||
34 | ; output bytes to consecutive portaddresses | |
35 | ; | |
36 | ; hl: table with following structure: | |
37 | ; db n, port1, val1, val2,... valn | |
38 | ; db m, port1, val1, val2,... valm | |
39 | ; ... | |
40 | ; db 0 ; Terminate table | |
41 | ||
42 | ||
43 | cseg ; (common for now) | |
44 | ||
45 | ioiniml: | |
46 | push bc | |
47 | xor a | |
48 | ioml_lp: | |
49 | ld b,(hl) | |
50 | inc hl | |
51 | cp b | |
52 | jr z,ioml_e | |
53 | ||
54 | ld c,(hl) | |
55 | inc hl | |
56 | otimr | |
57 | jr ioml_lp | |
58 | ioml_e: | |
59 | pop bc | |
60 | ret | |
61 | ||
62 | ;---------------------------------------------------------------------- | |
63 | ||
64 | ; output bytes to ports | |
65 | ; | |
66 | ; hl: tables of port,value pairs: | |
67 | ; db n, port1,val1, port2,val2,... portn,valn | |
68 | ; ... | |
69 | ; db 0 ; Terminate table | |
70 | ||
71 | cseg ; (common for now) | |
72 | ||
73 | ioini1l: | |
74 | push bc | |
75 | jr io1_nxt | |
76 | io1_lp: | |
77 | ld c,(hl) ;port address | |
78 | inc hl | |
79 | otim | |
80 | jr nz,io1_lp | |
81 | io1_nxt: | |
82 | ld b,(hl) ;count | |
83 | inc hl | |
84 | inc b | |
85 | djnz io1_lp | |
86 | ||
87 | pop bc | |
88 | ret | |
89 | ||
90 | ;---------------------------------------------------------------------- | |
91 | ||
92 | dseg | |
93 | ||
94 | intinit: | |
95 | ld hl,ivtab ; | |
96 | ld a,h ; | |
97 | ld i,a ; | |
98 | out0 (il),l ; | |
99 | im 2 | |
100 | ||
101 | ; Let all vectors point to spurious int routines. | |
102 | ||
103 | ld de,sp.int0 | |
104 | ld bc,sp.int.len | |
105 | ld a,9 | |
106 | ivt_i1: | |
107 | ld (hl),e | |
108 | inc l | |
109 | ld (hl),d | |
110 | inc l | |
111 | ex de,hl | |
112 | add hl,bc | |
113 | ex de,hl | |
114 | dec a | |
115 | jr nz,ivt_i1 | |
116 | ret | |
117 | ||
118 | ||
119 | ;-------------------------------------------------------------------- | |
120 | ; Spurious interrupt handler | |
121 | ||
122 | cseg ; common area | |
123 | sp.int0: | |
124 | ld a,00h | |
125 | jr sp.i.1 | |
126 | sp.int.len equ $-sp.int0 | |
127 | ld a,01h | |
128 | jr sp.i.1 | |
129 | ld a,02h | |
130 | jr sp.i.1 | |
131 | ld a,03h | |
132 | jr sp.i.1 | |
133 | ld a,04h | |
134 | jr sp.i.1 | |
135 | ld a,05h | |
136 | jr sp.i.1 | |
137 | ld a,06h | |
138 | jr sp.i.1 | |
139 | ld a,07h | |
140 | jr sp.i.1 | |
141 | ld a,08h | |
142 | sp.i.1: | |
143 | ; out (80h),a | |
144 | ||
145 | add a,'0' | |
146 | ld (spi$nr),a | |
147 | ld hl,spi$msg | |
148 | call ?pmsg | |
149 | sp.i.2: | |
150 | halt | |
151 | jr sp.i.2 | |
152 | ||
153 | spi$msg: | |
154 | db 13,10,'Spurious Int: ' | |
155 | spi$nr: db '0' | |
156 | db 0 | |
157 | ||
158 | ||
159 | ;-------------------------------------------------------------------- | |
160 | ||
161 | cseg | |
162 | ||
163 | fifolst: | |
164 | rept 4 | |
165 | dw 0 | |
166 | db 0 | |
167 | endm | |
168 | ||
169 | ;-------------------------------------------------------------------- | |
170 | ||
171 | dseg | |
172 | ||
173 | bufinit: | |
174 | ld c,a | |
175 | ld a,(ix+o.id) | |
176 | cp 4 | |
177 | jr nc,bfi_doit2 | |
178 | ||
179 | ld hl,fifolst | |
180 | ld e,a | |
181 | ld d,0 | |
182 | add hl,de | |
183 | add hl,de | |
184 | add hl,de | |
185 | ||
186 | if 0 | |
187 | ld e,(hl) | |
188 | inc hl | |
189 | ld d,(hl) | |
190 | dec hl | |
191 | ld a,e | |
192 | or d | |
193 | jr z,bfi_doit | |
194 | ||
195 | ; TODO: address translation | |
196 | push de | |
197 | pop ix | |
198 | ret | |
199 | endif | |
200 | ||
201 | bfi_doit: | |
202 | push ix | |
203 | pop de | |
204 | ; TODO: address translation | |
205 | ld (hl),e | |
206 | inc hl | |
207 | ld (hl),d | |
208 | ld a,(ix+o.id) | |
209 | or a | |
210 | jr nz,bfi_doit2 | |
211 | ||
212 | ld hl,fifolst | |
213 | ld (040h),hl | |
214 | ld (040h+2),a | |
215 | ||
216 | bfi_doit2: | |
217 | ld (ix+o.in_idx),0 ;reset pointers | |
218 | ld (ix+o.out_idx),0 | |
219 | ld (ix+o.mask),c ;reset "size" | |
220 | ||
221 | push ix ;get phys. address of fifo | |
222 | pop hl | |
223 | call hwl2phy | |
224 | ex de,hl | |
225 | ld c,a | |
226 | ld a,(ix+o.id) ;fifo id | |
227 | or a ;test if fifo 0 | |
228 | jr nz,bfi_1 | |
229 | ||
230 | out (AVRINT5),a | |
231 | ret | |
232 | ||
233 | bfi_1: | |
234 | ld hl,bfi_msg_end | |
235 | ld (hl),c | |
236 | dec hl | |
237 | ld (hl),d | |
238 | dec hl | |
239 | ld (hl),e | |
240 | dec hl | |
241 | ld (hl),a | |
242 | dec hl | |
243 | ld b,bfi_msg_len | |
244 | call msg.sm | |
245 | ret | |
246 | ||
247 | bfi_msg: | |
248 | db 0 ;function: 0 | |
249 | db 0 ;subfunc: gets overwritten with buf id | |
250 | dw 0 ;physical | |
251 | db 0 ; address | |
252 | bfi_msg_len equ $ - bfi_msg | |
253 | bfi_msg_end equ $ - 1 | |
254 | ||
255 | ;---------------------------------------------------------------------- | |
256 | ||
257 | ||
258 | end |