]>
Commit | Line | Data |
---|---|---|
072e0f3b L |
1 | ; CP/M BIOS for avrcpm\r |
2 | ; Copyright (C) 2010 Sprite_tm\r | |
3 | ;\r | |
4 | ; This program is free software: you can redistribute it and/or modify\r | |
5 | ; it under the terms of the GNU General Public License as published by\r | |
6 | ; the Free Software Foundation, either version 3 of the License, or\r | |
7 | ; (at your option) any later version.\r | |
8 | ;\r | |
9 | ; This program is distributed in the hope that it will be useful,\r | |
10 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
11 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
12 | ; GNU General Public License for more details.\r | |
13 | ;\r | |
14 | ; You should have received a copy of the GNU General Public License\r | |
15 | ; along with this program. If not, see <http://www.gnu.org/licenses/>.\r | |
16 | ;\r | |
17 | ; $Id: bios.asm 71 2010-08-06 19:38:10Z leo $\r | |
18 | ;\r | |
19 | \r | |
2396f399 | 20 | maclib CFGACPM.LIB\r |
072e0f3b L |
21 | \r |
22 | aseg\r | |
23 | org 100h\r | |
24 | .phase bios\r | |
25 | .z80\r | |
26 | \r | |
27 | nsects equ ($-ccp)/128 ;warm start sector count\r | |
28 | \r | |
29 | jp boot\r | |
30 | wboote: \r | |
31 | jp wboot\r | |
32 | jp const\r | |
33 | jp conin\r | |
34 | jp conout\r | |
35 | jp list\r | |
36 | jp punch\r | |
37 | jp reader\r | |
38 | jp home\r | |
39 | jp seldsk\r | |
40 | jp settrk\r | |
41 | jp setsec\r | |
42 | jp setdma\r | |
43 | jp read\r | |
44 | jp write\r | |
45 | jp listst\r | |
46 | jp sectran\r | |
47 | \r | |
48 | .8080\r | |
49 | maclib AVRCPM.LIB\r | |
50 | \r | |
51 | ;Drive A B C D E F G H I J K L\r | |
2396f399 L |
52 | ;drvtbl: dtbl <dpha,dphb,dphc,dphd, , , , ,dphi,dphj,dphk,dphl>\r |
53 | drvtbl: dtbl <dpha, , , , , , , ,dphi,dphj,dphk,dphl>\r | |
072e0f3b L |
54 | \r |
55 | ; Name spt bls dks dir cks off\r | |
2396f399 | 56 | dpb dpb243, 26, 1024, 243, 64, 64, 2\r |
072e0f3b L |
57 | dpb dp8192s,32, 4096,2046, 512, 512, 2\r |
58 | dpb dp8192, 32, 4096,2046,1024,1024, 2\r | |
59 | ; dpb dpbrd, 32, 1024, 56, 32, 0, 2\r | |
60 | dpb rd1016, 32, 2048, 508, 192, 0, 2\r | |
61 | dpb rd1024, 32, 2048, 512, 192, 0, 0\r | |
62 | dpb rd0960, 32, 2048, 480, 192, 0, 0\r | |
63 | \r | |
2396f399 | 64 | dpha: dph dpb243\r |
072e0f3b L |
65 | ;dphb: dph dpb243\r |
66 | ;dphc: dph dpb243\r | |
67 | ;dphd: dph dpb243\r | |
2396f399 L |
68 | ;dpha: dph dp8192s\r |
69 | ;dphb: dph dp8192s\r | |
70 | ;dphc: dph dp8192\r | |
71 | ;dphd: dph dp8192\r | |
072e0f3b L |
72 | dphi: dph rd1016\r |
73 | dphj: dph rd1024\r | |
74 | dphk: dph rd1024\r | |
75 | dphl: dph rd0960\r | |
76 | \r | |
77 | .z80\r | |
78 | \r | |
79 | signon:\r | |
80 | db cr,lf\r | |
81 | db msize/10+'0'\r | |
82 | db msize - (msize/10)*10 + '0' ;modulo doesn't work?\r | |
83 | db "k cp/m vers 2.2"\r | |
84 | msgnl: db cr,lf,0\r | |
85 | \r | |
2396f399 L |
86 | msgnodisk:\r |
87 | db "No disk!"\r | |
88 | db cr,lf,0\r | |
89 | \r | |
072e0f3b L |
90 | const:\r |
91 | in a,(0)\r | |
92 | ret\r | |
93 | \r | |
94 | conin:\r | |
95 | in a,(0)\r | |
96 | cp 0ffh\r | |
97 | jp nz,conin\r | |
98 | \r | |
99 | in a,(1)\r | |
100 | ret\r | |
101 | \r | |
102 | conout:\r | |
103 | ld a,c\r | |
2396f399 | 104 | out (1),a\r |
072e0f3b L |
105 | ret\r |
106 | \r | |
107 | list:\r | |
108 | ret\r | |
109 | \r | |
110 | listst:\r | |
111 | ld a,0\r | |
112 | ret\r | |
113 | \r | |
114 | punch:\r | |
115 | ret\r | |
116 | \r | |
117 | reader:\r | |
118 | ld a,01Fh\r | |
119 | ret\r | |
120 | \r | |
121 | prmsg:\r | |
122 | ld a,(hl)\r | |
123 | or a\r | |
124 | ret z\r | |
125 | push hl\r | |
126 | ld c,a\r | |
127 | call conout\r | |
128 | pop hl\r | |
129 | inc hl\r | |
130 | jp prmsg\r | |
131 | \r | |
132 | prhex:\r | |
133 | ld a,c\r | |
134 | push af\r | |
135 | rra \r | |
136 | rra \r | |
137 | rra \r | |
138 | rra \r | |
139 | call prhexdigit\r | |
140 | pop af\r | |
141 | ; fall thru\r | |
142 | \r | |
143 | prhexdigit:\r | |
144 | and 00fh\r | |
145 | cp 10\r | |
146 | jp c,prd1\r | |
147 | add a,7\r | |
148 | prd1:\r | |
149 | add a,'0'\r | |
150 | ld c,a\r | |
151 | jp conout\r | |
152 | \r | |
072e0f3b L |
153 | boot:\r |
154 | ld sp,buff\r | |
155 | ld hl,signon\r | |
156 | call prmsg\r | |
157 | \r | |
2396f399 L |
158 | ld a,low bcb\r |
159 | out (13),a\r | |
160 | ld a, high bcb\r | |
161 | out (14),a\r | |
162 | \r | |
072e0f3b L |
163 | xor a\r |
164 | ld (bootdsk),a\r | |
165 | ld e,a\r | |
2396f399 L |
166 | ld c,a\r |
167 | call seldsk\r | |
168 | jp nz,boot0\r | |
169 | ld hl,msgnodisk\r | |
170 | call prmsg\r | |
171 | halt\r | |
172 | boot0:\r | |
173 | call getdpb\r | |
174 | ld a,(de) ;dpb[0] is sectors_per_track\r | |
072e0f3b | 175 | ld (bootspt),a\r |
2396f399 | 176 | ld e,0\r |
072e0f3b L |
177 | ld c,'I'-'A'\r |
178 | call seldsk\r | |
92202636 | 179 | jp z,boot1 ;no ram disk\r |
072e0f3b | 180 | \r |
2396f399 | 181 | call getdpb ;de = dpb of first ram disk\r |
072e0f3b L |
182 | \r |
183 | ; Check, if we have reserved tracks.\r | |
184 | \r | |
185 | ld hl,13\r | |
186 | add hl,de\r | |
187 | \r | |
188 | ld a,(hl) ;# of reserved tracks \r | |
189 | inc hl\r | |
190 | or (hl)\r | |
191 | jp z,boot1 ;Skip if not.\r | |
192 | \r | |
193 | ; Save CPM to ram disk.\r | |
194 | \r | |
195 | ld a,(de) ;sectors per track\r | |
196 | ld (bootspt),a\r | |
197 | ld a,'I'-'A'\r | |
198 | ld (bootdsk),a\r | |
199 | call home\r | |
200 | ld b,nsects\r | |
201 | ld c,0 ;track\r | |
202 | ld d,1 ;sektor (0 based, skip ipl)\r | |
203 | ld hl,ccp\r | |
204 | store1:\r | |
205 | push bc\r | |
206 | push de\r | |
207 | push hl\r | |
208 | ld c,d\r | |
209 | ld b,0\r | |
210 | call setsec\r | |
211 | pop bc ;dma\r | |
212 | push bc\r | |
213 | call setdma\r | |
214 | ld c,0\r | |
215 | call write\r | |
216 | \r | |
217 | pop hl ;dma\r | |
218 | ld de,128\r | |
219 | add hl,de\r | |
220 | pop de ;d = sec\r | |
221 | pop bc ;b = # of secs, c = track\r | |
222 | dec b\r | |
223 | jp z,boot1\r | |
224 | \r | |
225 | inc d\r | |
226 | ld a,(bootspt)\r | |
227 | dec a\r | |
228 | cp d ;if sector >= spt then change tracks\r | |
229 | jp nc,store1\r | |
230 | \r | |
231 | ld d,0\r | |
232 | inc c\r | |
233 | push bc\r | |
234 | push de\r | |
235 | push hl\r | |
236 | ld b,0\r | |
237 | call settrk \r | |
238 | pop hl\r | |
239 | pop de\r | |
240 | pop bc\r | |
241 | jp store1\r | |
242 | \r | |
243 | boot1: \r | |
244 | xor a\r | |
245 | ld (iobyte),a\r | |
246 | ld (cdisk),a\r | |
247 | jp gocpm \r | |
248 | \r | |
249 | wboot: ;re-load CP/M\r | |
250 | ld sp,buff\r | |
251 | ld a,1 shl BOOT_FUNC ;init (de)blocking\r | |
252 | out (22),a\r | |
253 | ld a,(bootdsk)\r | |
254 | ld c,a\r | |
255 | call seldsk\r | |
256 | call home\r | |
257 | ld b,nsects\r | |
258 | ld c,0 ;track\r | |
259 | ld d,1 ;sektor (0 based)\r | |
260 | ld hl,ccp\r | |
261 | load1:\r | |
262 | push bc\r | |
263 | push de\r | |
264 | push hl\r | |
265 | ld c,d\r | |
266 | ld b,0\r | |
267 | call setsec\r | |
268 | pop bc\r | |
269 | push bc\r | |
270 | call setdma\r | |
271 | call read\r | |
272 | cp 0 ;read error?\r | |
273 | jp nz,wboot\r | |
274 | \r | |
275 | pop hl\r | |
276 | ld de,128\r | |
277 | add hl,de\r | |
278 | pop de\r | |
279 | pop bc\r | |
280 | dec b\r | |
281 | jp z,gocpm\r | |
282 | \r | |
283 | inc d\r | |
284 | ld a,(bootspt)\r | |
285 | dec a\r | |
286 | cp d ;if sector >= spt then change tracks\r | |
287 | jp nc,load1\r | |
288 | \r | |
289 | ld d,0\r | |
290 | inc c\r | |
291 | push bc\r | |
292 | push de\r | |
293 | push hl\r | |
294 | ld b,0\r | |
295 | call settrk \r | |
296 | pop hl\r | |
297 | pop de\r | |
298 | pop bc\r | |
299 | jp load1\r | |
300 | \r | |
301 | gocpm:\r | |
302 | ld a,0c3h\r | |
303 | ld (0),a\r | |
304 | ld hl,wboote\r | |
305 | ld (1),hl\r | |
306 | ld (5),a\r | |
307 | ld hl,bdos\r | |
308 | ld (6),hl\r | |
309 | \r | |
310 | ld bc,buff\r | |
311 | call setdma\r | |
312 | ld a,(cdisk)\r | |
313 | ld c,a\r | |
314 | jp ccp\r | |
315 | \r | |
316 | msgSel: db 13,10,"Sel: ",0\r | |
317 | \r | |
2396f399 L |
318 | getdpb:\r |
319 | ld de,10\r | |
320 | add hl,de\r | |
321 | ld e,(hl)\r | |
322 | inc hl\r | |
323 | ld d,(hl) ;de = dpb\r | |
324 | ret\r | |
325 | \r | |
072e0f3b | 326 | seldsk:\r |
2396f399 L |
327 | ld a,c\r |
328 | out (15),a\r | |
329 | \r | |
330 | ld a,e ;reselection bit\r | |
331 | rrca\r | |
332 | jp c,getdph ;skip, if disk already active\r | |
2396f399 | 333 | ld hl,0\r |
92202636 | 334 | in a,(15) ;querry, if disk exists\r |
2396f399 | 335 | or a\r |
92202636 | 336 | ret z\r |
2396f399 L |
337 | getdph:\r |
338 | ld hl,drvtbl\r | |
072e0f3b L |
339 | ld b,0\r |
340 | add hl,bc\r | |
341 | add hl,bc\r | |
342 | ld a,(hl) ;get table entry for selected disk\r | |
343 | inc hl\r | |
344 | ld h,(hl)\r | |
345 | ld l,a \r | |
2396f399 | 346 | or h ;return zero, if no entry (no disk)\r |
072e0f3b | 347 | ret\r |
2396f399 | 348 | \r |
072e0f3b L |
349 | \r |
350 | home:\r | |
351 | ld a,1 shl HOME_FUNC\r | |
352 | out (22),a\r | |
353 | \r | |
354 | ld bc,0 ; same as seek to track 0\r | |
355 | settrk:\r | |
356 | ld a,c\r | |
357 | out (16),a\r | |
358 | ld a,b\r | |
359 | out (17),a\r | |
360 | ret\r | |
361 | \r | |
362 | setsec:\r | |
363 | ld a,c\r | |
364 | out (18),a\r | |
365 | ret\r | |
366 | \r | |
367 | setdma:\r | |
368 | ld a,c\r | |
369 | out (20),a\r | |
370 | ld a,b\r | |
371 | out (21),a\r | |
372 | ret\r | |
373 | \r | |
374 | read:\r | |
375 | ld a,1 shl READ_FUNC\r | |
376 | out (22),a\r | |
377 | in a,(22)\r | |
378 | and 1\r | |
379 | ret\r | |
380 | \r | |
381 | write:\r | |
382 | ld a,c\r | |
383 | and 3 ;mask write type\r | |
384 | or 1 shl WRITE_FUNC\r | |
385 | out (22),a\r | |
386 | in a,(22)\r | |
387 | and 1\r | |
388 | ret\r | |
389 | \r | |
390 | sectran:\r | |
391 | ;translate sector bc using table at de, res into hl\r | |
392 | ld h,b\r | |
393 | ld l,c\r | |
394 | ld a,d\r | |
395 | or e\r | |
396 | ret z\r | |
397 | ex de,hl\r | |
398 | add hl,bc\r | |
399 | ld l,(hl)\r | |
400 | ld h,0\r | |
401 | ret\r | |
402 | \r | |
2396f399 L |
403 | bcb: dw drvtbl\r |
404 | dw dirbuf\r | |
405 | dw enddat\r | |
406 | \r | |
072e0f3b L |
407 | bootdsk:ds 1\r |
408 | bootspt:ds 1\r | |
409 | \r | |
410 | .8080\r | |
411 | endef\r | |
412 | \r | |
413 | end\r | |
414 | \r |