]>
Commit | Line | Data |
---|---|---|
ea5293bb L |
1 | title 'Root module of relocatable BIOS for CP/M 3.0'\r |
2 | \r | |
3 | ; version 1.0 15 Sept 82\r | |
4 | \r | |
5 | include config.inc\r | |
6 | include z180reg.inc\r | |
7 | \r | |
8 | \r | |
9 | ; Copyright (C), 1982\r | |
10 | ; Digital Research, Inc\r | |
11 | ; P.O. Box 579\r | |
12 | ; Pacific Grove, CA 93950\r | |
13 | \r | |
14 | \r | |
15 | ; This is the invariant portion of the modular BIOS and is\r | |
16 | ; distributed as source for informational purposes only.\r | |
17 | ; All desired modifications should be performed by\r | |
18 | ; adding or changing externally defined modules.\r | |
19 | ; This allows producing "standard" I/O modules that\r | |
20 | ; can be combined to support a particular system\r | |
21 | ; configuration.\r | |
22 | \r | |
23 | cr equ 13\r | |
24 | lf equ 10\r | |
25 | bell equ 7\r | |
26 | ctlQ equ 'Q'-'@'\r | |
27 | ctlS equ 'S'-'@'\r | |
28 | \r | |
b27f7b99 L |
29 | ccp equ 0100h ; Console Command Processor gets loaded\r |
30 | ; into the TPA\r | |
ea5293bb | 31 | \r |
b27f7b99 | 32 | cseg ; GENCPM puts CSEG stuff in common memory\r |
ea5293bb L |
33 | \r |
34 | \r | |
35 | ; variables in system data page\r | |
36 | \r | |
37 | extrn @covec,@civec,@aovec,@aivec,@lovec ; I/O redirection vectors\r | |
38 | extrn @mxtpa ; addr of system entry point\r | |
39 | extrn @bnkbf ; 128 byte scratch buffer\r | |
40 | \r | |
41 | ; initialization\r | |
42 | \r | |
b27f7b99 | 43 | extrn hwinit,?init ; general initialization and signon\r |
ea5293bb L |
44 | extrn ?ldccp,?rlccp ; load & reload CCP for BOOT & WBOOT\r |
45 | \r | |
46 | ; user defined character I/O routines\r | |
47 | \r | |
48 | extrn ?ci,?co,?cist,?cost ; each take device in <B>\r | |
49 | extrn ?cinit ; (re)initialize device in <C>\r | |
50 | extrn @ctbl ; physical character device table\r | |
51 | \r | |
52 | ; disk communication data items\r | |
53 | \r | |
54 | extrn @dtbl ; table of pointers to XDPHs\r | |
55 | public @adrv,@rdrv,@trk,@sect ; parameters for disk I/O\r | |
56 | public @dma,@dbnk,@cnt ; '' '' '' ''\r | |
57 | \r | |
58 | ; memory control\r | |
59 | \r | |
b27f7b99 L |
60 | public @cbnk ; current bank\r |
61 | extrn ?xmove,?move ; select move bank, and block move\r | |
62 | extrn ?bank ; select CPU bank\r | |
ea5293bb L |
63 | \r |
64 | ; clock support\r | |
65 | \r | |
b27f7b99 | 66 | extrn ?time ; signal time operation\r |
ea5293bb L |
67 | \r |
68 | ; general utility routines\r | |
69 | \r | |
70 | public ?pmsg,?pdec ; print message, print number from 0 to 65535\r | |
71 | public ?pderr ; print BIOS disk error message header\r | |
5f701f3a L |
72 | public pmsg.in ; print message inline\r |
73 | public phex4,phex2 ; print 4 digit hex (HL), or 2 digit hex (A)\r | |
ea5293bb | 74 | \r |
b27f7b99 | 75 | include modebaud.inc ; define mode bits\r |
ea5293bb L |
76 | \r |
77 | \r | |
78 | ; External names for BIOS entry points\r | |
79 | \r | |
80 | public ?boot,?wboot,?const,?conin,?cono,?list,?auxo,?auxi\r | |
81 | public ?home,?sldsk,?sttrk,?stsec,?stdma,?read,?write\r | |
82 | public ?lists,?sctrn\r | |
83 | public ?conos,?auxis,?auxos,?dvtbl,?devin,?drtbl\r | |
84 | public ?mltio,?flush,?mov,?tim,?bnksl,?stbnk,?xmov\r | |
85 | \r | |
86 | public bs$stack\r | |
87 | \r | |
88 | \r | |
89 | ; BIOS Jump vector.\r | |
90 | \r | |
b27f7b99 L |
91 | ; All BIOS routines are invoked by calling these\r |
92 | ; entry points.\r | |
93 | \r | |
94 | ?boot: jp boot ; initial entry on cold start\r | |
95 | ?wboot: jp wboot ; reentry on program exit, warm start\r | |
96 | \r | |
97 | ?const: jp const ; return console input status\r | |
98 | ?conin: jp conin ; return console input character\r | |
99 | ?cono: jp conout ; send console output character\r | |
100 | ?list: jp list ; send list output character\r | |
101 | ?auxo: jp auxout ; send auxiliary output character\r | |
102 | ?auxi: jp auxin ; return auxiliary input character\r | |
103 | \r | |
104 | ?home: jp home ; set disks to logical home\r | |
105 | ?sldsk: jp seldsk ; select disk drive, return disk parameter info\r | |
106 | ?sttrk: jp settrk ; set disk track\r | |
107 | ?stsec: jp setsec ; set disk sector\r | |
108 | ?stdma: jp setdma ; set disk I/O memory address\r | |
109 | ?read: jp read ; read physical block(s)\r | |
110 | ?write: jp write ; write physical block(s)\r | |
111 | \r | |
112 | ?lists: jp listst ; return list device status\r | |
113 | ?sctrn: jp sectrn ; translate logical to physical sector\r | |
114 | \r | |
115 | ?conos: jp conost ; return console output status\r | |
116 | ?auxis: jp auxist ; return aux input status\r | |
117 | ?auxos: jp auxost ; return aux output status\r | |
118 | ?dvtbl: jp devtbl ; return address of device def table\r | |
119 | ?devin: jp ?cinit ; change baud rate of device\r | |
120 | \r | |
121 | ?drtbl: jp getdrv ; return address of disk drive table\r | |
122 | ?mltio: jp multio ; set multiple record count for disk I/O\r | |
123 | ?flush: jp flush ; flush BIOS maintained disk caching\r | |
124 | \r | |
125 | ?mov: jp ?move ; block move memory to memory\r | |
126 | ?tim: jp ?time ; Signal Time and Date operation\r | |
127 | ?bnksl: jp bnksel ; select bank for code execution and default DMA\r | |
128 | ?stbnk: jp setbnk ; select different bank for disk I/O DMA operations\r | |
129 | ?xmov: jp ?xmove ; set source and destination banks for one operation\r | |
ea5293bb L |
130 | \r |
131 | jp 0 ; reserved for future expansion\r | |
132 | jp 0 ; reserved for future expansion\r | |
133 | jp 0 ; reserved for future expansion\r | |
134 | \r | |
135 | \r | |
136 | ; BOOT\r | |
137 | ; Initial entry point for system startup.\r | |
138 | \r | |
b27f7b99 | 139 | dseg ; this part can be banked\r |
ea5293bb L |
140 | \r |
141 | boot:\r | |
142 | ld sp,bs$stack\r | |
143 | \r | |
b27f7b99 | 144 | call hwinit ; first time hardware initialisation\r |
ea5293bb | 145 | \r |
b27f7b99 | 146 | ld c,15 ; initialize all 16 character devices\r |
ea5293bb L |
147 | c$init$loop:\r |
148 | push bc\r | |
149 | call ?cinit\r | |
150 | pop bc\r | |
151 | dec c\r | |
152 | jp p,c$init$loop\r | |
153 | \r | |
b27f7b99 L |
154 | call ?init ; perform any additional system initialization\r |
155 | ; and print signon message\r | |
ea5293bb L |
156 | \r |
157 | ld bc,16*256+0\r | |
b27f7b99 | 158 | ld hl,@dtbl ; init all 16 logical disk drives\r |
ea5293bb | 159 | d$init$loop:\r |
b27f7b99 | 160 | push bc ; save remaining count and abs drive\r |
ea5293bb L |
161 | ld e,(hl)\r |
162 | inc hl\r | |
163 | ld d,(hl)\r | |
b27f7b99 | 164 | inc hl ; grab @drv entry\r |
ea5293bb L |
165 | ld a,e\r |
166 | or d\r | |
b27f7b99 L |
167 | jr z,d$init$next ; if null, no drive\r |
168 | push hl ; save @drv pointer\r | |
ea5293bb | 169 | if 0\r |
b27f7b99 | 170 | ex de,hl ; XDPH address in <HL>\r |
ea5293bb L |
171 | dec hl\r |
172 | dec hl\r | |
b27f7b99 L |
173 | ld b,(hl) ; get relative drive code\r |
174 | ld (@ADRV),bc ; save absolute and relative drive code\r | |
175 | dec hl ; point to init pointer\r | |
ea5293bb L |
176 | ld d,(hl)\r |
177 | dec hl\r | |
b27f7b99 | 178 | ld e,(hl) ; get init pointer\r |
ea5293bb | 179 | ex de,hl\r |
b27f7b99 | 180 | call ipchl ; call init routine\r |
ea5293bb L |
181 | else\r |
182 | push de\r | |
183 | pop ix\r | |
184 | ld b,(ix-2)\r | |
b27f7b99 | 185 | ld (@ADRV),bc ; save absolute and relative drive code\r |
ea5293bb | 186 | ld l,(ix-4)\r |
b27f7b99 L |
187 | ld h,(ix-3) ; get init pointer\r |
188 | call ipchl ; call init routine\r | |
ea5293bb | 189 | endif\r |
b27f7b99 | 190 | pop hl ; recover @drv pointer\r |
ea5293bb | 191 | d$init$next:\r |
b27f7b99 | 192 | pop bc ; recover counter and drive #\r |
ea5293bb | 193 | inc c\r |
b27f7b99 | 194 | djnz d$init$loop ; and loop for each drive\r |
ea5293bb L |
195 | jp boot$1\r |
196 | \r | |
197 | cseg ; following in resident memory\r | |
198 | \r | |
199 | boot$1:\r | |
200 | call set$jumps\r | |
b27f7b99 | 201 | call ?ldccp ; fetch CCP for first time\r |
ea5293bb L |
202 | jp ccp\r |
203 | \r | |
204 | \r | |
205 | ; WBOOT\r | |
206 | ; Entry for system restarts.\r | |
207 | \r | |
208 | wboot:\r | |
209 | ld sp,bs$stack\r | |
b27f7b99 L |
210 | call set$jumps ; initialize page zero\r |
211 | call ?rlccp ; reload CCP\r | |
212 | jp ccp ; then reset jmp vectors and exit to ccp\r | |
ea5293bb L |
213 | \r |
214 | \r | |
215 | set$jumps:\r | |
216 | \r | |
217 | if banked\r | |
218 | ld a,1\r | |
219 | call ?bnksl\r | |
220 | endif\r | |
221 | \r | |
222 | ld a,0C3h ; jp opcode\r | |
223 | ld (0),a\r | |
224 | ld (5),a ; set up jumps in page zero\r | |
225 | ld hl,?wboot\r | |
226 | ld (1),hl ; BIOS warm start entry\r | |
227 | ld hl,(@MXTPA)\r | |
228 | ld (6),hl ; BDOS system call entry\r | |
229 | ret\r | |
230 | \r | |
231 | \r | |
232 | ds 64\r | |
233 | bs$stack equ $\r | |
234 | \r | |
235 | \r | |
236 | ; DEVTBL\r | |
237 | ; Return address of character device table\r | |
238 | \r | |
239 | devtbl:\r | |
240 | ld hl,@ctbl\r | |
241 | ret\r | |
242 | \r | |
243 | \r | |
244 | ; GETDRV\r | |
245 | ; Return address of drive table\r | |
246 | \r | |
247 | getdrv:\r | |
248 | ld hl,@dtbl\r | |
249 | ret\r | |
250 | \r | |
251 | \r | |
252 | \r | |
253 | ; CONOUT\r | |
254 | ; Console Output. Send character in <C>\r | |
255 | ; to all selected devices\r | |
256 | \r | |
257 | conout:\r | |
258 | \r | |
259 | ld hl,(@covec) ; fetch console output bit vector\r | |
260 | jr out$scan\r | |
261 | \r | |
262 | \r | |
263 | ; AUXOUT\r | |
264 | ; Auxiliary Output. Send character in <C>\r | |
265 | ; to all selected devices\r | |
266 | \r | |
267 | auxout:\r | |
268 | ld hl,(@aovec) ; fetch aux output bit vector\r | |
269 | jr out$scan\r | |
270 | \r | |
271 | \r | |
272 | ; LIST\r | |
273 | ; List Output. Send character in <C>\r | |
274 | ; to all selected devices.\r | |
275 | \r | |
276 | list:\r | |
277 | ld hl,(@lovec) ; fetch list output bit vector\r | |
278 | \r | |
279 | out$scan:\r | |
280 | ld b,0 ; start with device 0\r | |
281 | co$next:\r | |
282 | add hl,hl ; shift out next bit\r | |
283 | jr nc,not$out$device\r | |
284 | push hl ; save the vector\r | |
285 | push bc ; save the count and character\r | |
286 | not$out$ready:\r | |
287 | call coster\r | |
288 | or a\r | |
289 | jp z,not$out$ready\r | |
290 | pop bc\r | |
b27f7b99 L |
291 | push bc ; restore and resave the character and device\r |
292 | call ?co ; if device selected, print it\r | |
ea5293bb L |
293 | pop bc ; recover count and character\r |
294 | pop hl ; recover the rest of the vector\r | |
295 | not$out$device:\r | |
296 | inc b ; next device number\r | |
297 | ld a,h\r | |
b27f7b99 | 298 | or l ; see if any devices left\r |
ea5293bb L |
299 | jr nz,co$next ; and go find them...\r |
300 | ret\r | |
301 | \r | |
302 | \r | |
303 | ; CONOST\r | |
304 | ; Console Output Status. Return true if\r | |
305 | ; all selected console output devices\r | |
306 | ; are ready.\r | |
307 | \r | |
308 | conost:\r | |
309 | ld hl,(@covec) ; get console output bit vector\r | |
310 | jr ost$scan\r | |
311 | \r | |
312 | \r | |
313 | ; AUXOST\r | |
314 | ; Auxiliary Output Status. Return true if\r | |
315 | ; all selected auxiliary output devices\r | |
316 | ; are ready.\r | |
317 | \r | |
318 | auxost:\r | |
319 | ld hl,(@aovec) ; get aux output bit vector\r | |
320 | jr ost$scan\r | |
321 | \r | |
322 | \r | |
323 | ; LISTST\r | |
324 | ; List Output Status. Return true if\r | |
325 | ; all selected list output devices\r | |
326 | ; are ready.\r | |
327 | \r | |
328 | listst:\r | |
329 | ld hl,(@lovec) ; get list output bit vector\r | |
330 | \r | |
331 | ost$scan:\r | |
332 | ld b,0 ; start with device 0\r | |
333 | cos$next:\r | |
334 | add hl,hl ; check next bit\r | |
335 | push hl ; save the vector\r | |
336 | push bc ; save the count\r | |
b27f7b99 | 337 | ld a,0FFh ; assume device ready\r |
ea5293bb L |
338 | call c,coster ; check status for this device\r |
339 | pop bc ; recover count\r | |
340 | pop hl ; recover bit vector\r | |
341 | or a ; see if device ready\r | |
342 | ret z ; if any not ready, return false\r | |
343 | inc b ; drop device number\r | |
344 | ld a,h\r | |
b27f7b99 | 345 | or l ; see if any more selected devices\r |
ea5293bb | 346 | jr nz,cos$next\r |
b27f7b99 | 347 | or 0FFh ; all selected were ready, return true\r |
ea5293bb L |
348 | ret\r |
349 | \r | |
b27f7b99 L |
350 | ; check for output device ready, including optional\r |
351 | ; xon/xoff support\r | |
352 | coster:\r | |
ea5293bb | 353 | ld l,b\r |
b27f7b99 L |
354 | ld h,0 ; make device code 16 bits\r |
355 | push hl ; save it in stack\r | |
ea5293bb L |
356 | add hl,hl\r |
357 | add hl,hl\r | |
b27f7b99 | 358 | add hl,hl ; create offset into device characteristics tbl\r |
ea5293bb | 359 | ld de,@ctbl+6\r |
b27f7b99 | 360 | add hl,de ; make address of mode byte\r |
ea5293bb L |
361 | ld a,(hl)\r |
362 | and mb$xon$xoff\r | |
b27f7b99 | 363 | pop hl ; recover console number in <HL>\r |
ea5293bb L |
364 | jp z,?cost ; not a xon device, go get output status direct\r |
365 | ld de,xofflist\r | |
b27f7b99 | 366 | add hl,de ; make pointer to proper xon/xoff flag\r |
ea5293bb L |
367 | call cist1 ; see if this keyboard has character\r |
368 | ld a,(hl)\r | |
b27f7b99 | 369 | call nz,ci1 ; get flag or read key if any\r |
ea5293bb L |
370 | cp ctlq\r |
371 | jr nz,not$q ; if its a ctl-Q,\r | |
372 | ld a,0FFh ; set the flag ready\r | |
373 | not$q:\r | |
374 | cp ctls\r | |
375 | jr nz,not$s ; if its a ctl-S,\r | |
376 | ld a,00h ; clear the flag\r | |
377 | not$s:\r | |
b27f7b99 | 378 | ld (hl),a ; save the flag\r |
ea5293bb | 379 | call cost1 ; get the actual output status,\r |
b27f7b99 | 380 | and (hl) ; and mask with ctl-Q/ctl-S flag\r |
ea5293bb L |
381 | ret ; return this as the status\r |
382 | \r | |
b27f7b99 | 383 | cist1: ; get input status with <BC> and <HL> saved\r |
ea5293bb L |
384 | push bc\r |
385 | push hl\r | |
386 | call ?cist\r | |
387 | pop hl\r | |
388 | pop bc\r | |
389 | or a\r | |
390 | ret\r | |
391 | \r | |
b27f7b99 | 392 | cost1: ; get output status, saving <BC> & <HL>\r |
ea5293bb L |
393 | push bc\r |
394 | push hl\r | |
395 | call ?cost\r | |
396 | pop hl\r | |
397 | pop bc\r | |
398 | or a\r | |
399 | ret\r | |
400 | \r | |
b27f7b99 | 401 | ci1: ; get input, saving <BC> & <HL>\r |
ea5293bb L |
402 | push bc\r |
403 | push hl\r | |
404 | call ?ci\r | |
405 | pop hl\r | |
406 | pop bc\r | |
407 | ret\r | |
408 | \r | |
409 | \r | |
410 | ; CONST\r | |
411 | ; Console Input Status. Return true if\r | |
412 | ; any selected console input device\r | |
413 | ; has an available character.\r | |
414 | \r | |
415 | const:\r | |
416 | ld hl,(@civec) ; get console input bit vector\r | |
417 | jr ist$scan\r | |
418 | \r | |
419 | \r | |
420 | ; AUXIST\r | |
421 | ; Auxiliary Input Status. Return true if\r | |
422 | ; any selected auxiliary input device\r | |
423 | ; has an available character.\r | |
424 | \r | |
425 | auxist:\r | |
426 | ld hl,(@aivec) ; get aux input bit vector\r | |
427 | \r | |
428 | ist$scan:\r | |
429 | ld b,0 ; start with device 0\r | |
430 | cis$next:\r | |
431 | add hl,hl ; check next bit\r | |
432 | ld a,0 ; assume device not ready\r | |
433 | call c,cist1 ; check status for this device\r | |
434 | or a\r | |
435 | ret nz ; if any ready, return true\r | |
436 | inc b ; next device number\r | |
437 | ld a,h\r | |
b27f7b99 | 438 | or l ; see if any more selected devices\r |
ea5293bb L |
439 | jr nz,cis$next\r |
440 | xor a ; all selected were not ready, return false\r | |
441 | ret\r | |
442 | \r | |
443 | \r | |
444 | ; CONIN\r | |
445 | ; Console Input. Return character from first\r | |
446 | ; ready console input device.\r | |
447 | \r | |
448 | conin:\r | |
449 | ld hl,(@civec)\r | |
450 | jr in$scan\r | |
451 | \r | |
452 | \r | |
453 | ; AUXIN\r | |
454 | ; Auxiliary Input. Return character from first\r | |
455 | ; ready auxiliary input device.\r | |
456 | \r | |
457 | auxin:\r | |
458 | ld hl,(@aivec)\r | |
459 | \r | |
460 | in$scan:\r | |
461 | push hl ; save bit vector\r | |
462 | ld b,0\r | |
463 | ci$next:\r | |
464 | add hl,hl ; shift out next bit\r | |
465 | ld a,0 ; insure zero a (nonexistant device not ready).\r | |
466 | call c,cist1 ; see if the device has a character\r | |
467 | or a\r | |
468 | jr nz,ci$rdy ; this device has a character\r | |
469 | inc b ; else, next device\r | |
470 | ld a,h\r | |
471 | or l ; see if any more devices\r | |
472 | jr nz,ci$next ; go look at them\r | |
473 | pop hl ; recover bit vector\r | |
474 | jr in$scan ; loop til we find a character\r | |
475 | \r | |
476 | ci$rdy:\r | |
477 | pop hl ; discard extra stack\r | |
478 | jp ?ci\r | |
479 | \r | |
480 | \r | |
5f701f3a L |
481 | ;-------------------------------------------------------------------------------\r |
482 | ; Utility Subroutines\r | |
ea5293bb L |
483 | \r |
484 | \r | |
485 | ipchl: ; vectored CALL point\r | |
486 | jp (hl)\r | |
487 | \r | |
488 | \r | |
5f701f3a L |
489 | ;-------------------------------------------------------------------------------\r |
490 | ; print message @<HL> up to a null\r | |
491 | ; saves <BC> & <DE>\r | |
492 | \r | |
493 | ?pmsg:\r | |
ea5293bb L |
494 | push bc\r |
495 | push de\r | |
496 | pmsg$loop:\r | |
497 | ld a,(hl)\r | |
498 | or a\r | |
499 | jr z,pmsg$exit\r | |
500 | ld c,a\r | |
501 | push hl\r | |
502 | call ?cono\r | |
503 | pop hl\r | |
504 | inc hl\r | |
505 | jr pmsg$loop\r | |
506 | pmsg$exit:\r | |
507 | pop de\r | |
508 | pop bc\r | |
509 | ret\r | |
510 | \r | |
5f701f3a L |
511 | ;-------------------------------------------------------------------------------\r |
512 | ; print message inline up to a null\r | |
513 | ; saves all registers\r | |
514 | \r | |
515 | pmsg.in:\r | |
516 | ex (sp),hl\r | |
517 | push af\r | |
518 | call ?pmsg\r | |
519 | pop af\r | |
520 | ex (sp),hl\r | |
521 | ret\r | |
522 | \r | |
523 | ;-------------------------------------------------------------------------------\r | |
524 | ; print hl as a 4 digit hexadecimal number\r | |
525 | ; saves all registers\r | |
526 | \r | |
527 | phex4:\r | |
528 | ld a,h\r | |
529 | call phex2\r | |
530 | ld a,l\r | |
531 | ; fall thru\r | |
532 | \r | |
533 | ;-------------------------------------------------------------------------------\r | |
534 | ; print a as a 2 digit hexadecimal number\r | |
535 | ; saves all registers\r | |
536 | \r | |
537 | phex2:\r | |
538 | push af\r | |
539 | rra\r | |
540 | rra\r | |
541 | rra\r | |
542 | rra\r | |
543 | call print.digit\r | |
544 | pop af\r | |
545 | \r | |
546 | print.digit:\r | |
547 | push hl\r | |
548 | push de\r | |
549 | push bc\r | |
550 | push af\r | |
551 | and 00fh\r | |
552 | cp 10\r | |
553 | jr c,prd_1\r | |
554 | add a,007h\r | |
555 | prd_1:\r | |
556 | add a,'0'\r | |
557 | \r | |
558 | ld c,a\r | |
559 | call ?cono\r | |
560 | pop af\r | |
561 | pop bc\r | |
562 | pop de\r | |
563 | pop hl\r | |
564 | ret\r | |
565 | \r | |
566 | ;-------------------------------------------------------------------------------\r | |
567 | \r | |
ea5293bb L |
568 | ?pdec: ; print binary number 0-65535 from <HL>\r |
569 | ld bc,table10\r | |
570 | ld de,-10000\r | |
571 | next:\r | |
572 | ld a,'0'-1\r | |
573 | pdecl:\r | |
574 | push hl\r | |
575 | inc a\r | |
576 | add hl,de\r | |
577 | jp nc,stoploop\r | |
578 | inc sp\r | |
579 | inc sp\r | |
580 | jp pdecl\r | |
581 | stoploop:\r | |
582 | push de\r | |
583 | push bc\r | |
584 | ld c,a\r | |
585 | call ?cono\r | |
586 | pop bc\r | |
587 | pop de\r | |
588 | nextdigit:\r | |
589 | pop hl\r | |
590 | ld a,(bc)\r | |
591 | ld e,a\r | |
592 | inc bc\r | |
593 | ld a,(bc)\r | |
594 | ld d,a\r | |
595 | inc bc\r | |
596 | ld a,e\r | |
597 | or d\r | |
598 | jp nz,next\r | |
599 | ret\r | |
600 | \r | |
601 | table10:\r | |
602 | dw -1000,-100,-10,-1,0\r | |
603 | \r | |
604 | ?pderr:\r | |
605 | ld hl,drive$msg\r | |
b27f7b99 | 606 | call ?pmsg ; error header\r |
ea5293bb L |
607 | ld a,(@adrv)\r |
608 | add a,'A'\r | |
609 | ld c,a\r | |
b27f7b99 | 610 | call ?cono ; drive code\r |
ea5293bb | 611 | ld hl,track$msg\r |
b27f7b99 | 612 | call ?pmsg ; track header\r |
ea5293bb | 613 | ld hl,(@trk)\r |
b27f7b99 | 614 | call ?pdec ; track number\r |
ea5293bb | 615 | ld hl,sector$msg\r |
b27f7b99 | 616 | call ?pmsg ; sector header\r |
ea5293bb | 617 | ld hl,(@sect)\r |
b27f7b99 | 618 | call ?pdec ; sector number\r |
ea5293bb L |
619 | ret\r |
620 | \r | |
621 | \r | |
622 | ; BNKSEL\r | |
623 | ; Bank Select. Select CPU bank for further execution.\r | |
624 | \r | |
625 | bnksel:\r | |
b27f7b99 L |
626 | ld (@cbnk),a ; remember current bank\r |
627 | jp ?bank ; and go exit through users\r | |
628 | ; physical bank select routine\r | |
ea5293bb L |
629 | \r |
630 | \r | |
631 | xofflist:\r | |
632 | db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero\r | |
633 | db -1,-1,-1,-1,-1,-1,-1,-1\r | |
634 | \r | |
635 | \r | |
636 | \r | |
637 | dseg ; following resides in banked memory\r | |
638 | \r | |
639 | \r | |
640 | \r | |
641 | ; Disk I/O interface routines\r | |
642 | \r | |
643 | \r | |
644 | ; SELDSK\r | |
645 | ; Select Disk Drive. Drive code in <C>.\r | |
646 | ; Invoke login procedure for drive\r | |
647 | ; if this is first select. Return\r | |
648 | ; address of disk parameter header\r | |
649 | ; in <HL>\r | |
650 | \r | |
651 | seldsk:\r | |
b27f7b99 | 652 | ld a,c ; save drive select code\r |
ea5293bb | 653 | ld (@adrv),a\r |
b27f7b99 | 654 | ld b,0 ; create index from drive code\r |
ea5293bb | 655 | ld hl,@dtbl\r |
b27f7b99 | 656 | add hl,bc ; get pointer to dispatch table\r |
ea5293bb L |
657 | add hl,bc\r |
658 | ld a,(hl)\r | |
659 | inc hl\r | |
660 | ld h,(hl)\r | |
b27f7b99 L |
661 | ld l,a ; point at disk descriptor\r |
662 | ld (@xdph),hl ; save descriptor pointer\r | |
ea5293bb | 663 | or h\r |
b27f7b99 | 664 | ret z ; if no entry in table, no disk\r |
ea5293bb | 665 | \r |
b27f7b99 | 666 | ld a,e ; examine login bit\r |
ea5293bb L |
667 | and 1\r |
668 | ret nz\r | |
669 | \r | |
670 | push ix\r | |
671 | ld ix,(@xdph)\r | |
672 | ld a,(ix-2)\r | |
b27f7b99 L |
673 | ld (@RDRV),a ; get relative drive\r |
674 | ld l,(ix-6) ; get address of LOGIN routine\r | |
ea5293bb L |
675 | ld h,(ix-5)\r |
676 | ex (sp),ix\r | |
677 | pop de\r | |
b27f7b99 L |
678 | call ipchl ; call LOGIN\r |
679 | ld hl,(@xdph) ; recover DPH pointer\r | |
ea5293bb L |
680 | ret\r |
681 | \r | |
682 | \r | |
683 | ; HOME\r | |
684 | ; Home selected drive. Treated as SETTRK(0).\r | |
685 | \r | |
686 | home:\r | |
687 | ld bc,0 ; same as set track zero\r | |
688 | \r | |
689 | \r | |
690 | ; SETTRK\r | |
691 | ; Set Track. Saves track address from <BC>\r | |
692 | ; in @TRK for further operations.\r | |
693 | \r | |
694 | settrk:\r | |
695 | ld (@trk),bc\r | |
696 | ret\r | |
697 | \r | |
698 | \r | |
699 | ; SETSEC\r | |
700 | ; Set Sector. Saves sector number from <BC>\r | |
701 | ; in @sect for further operations.\r | |
702 | \r | |
703 | setsec:\r | |
704 | ld (@sect),bc\r | |
705 | ret\r | |
706 | \r | |
707 | \r | |
708 | ; SETDMA\r | |
709 | ; Set Disk Memory Address. Saves DMA address\r | |
710 | ; from <BC> in @DMA and sets @DBNK to @CBNK\r | |
711 | ; so that further disk operations take place\r | |
712 | ; in current bank.\r | |
713 | \r | |
714 | setdma:\r | |
715 | ld (@dma),bc\r | |
716 | \r | |
717 | ld a,(@cbnk) ; default DMA bank is current bank\r | |
718 | ; fall through to set DMA bank\r | |
719 | \r | |
720 | ; SETBNK\r | |
721 | ; Set Disk Memory Bank. Saves bank number\r | |
722 | ; in @DBNK for future disk data\r | |
723 | ; transfers.\r | |
724 | \r | |
725 | setbnk:\r | |
726 | ld (@dbnk),a\r | |
727 | ret\r | |
728 | \r | |
729 | \r | |
730 | ; SECTRN\r | |
731 | ; Sector Translate. Indexes skew table in <DE>\r | |
732 | ; with sector in <BC>. Returns physical sector\r | |
733 | ; in <HL>. If no skew table (<DE>=0) then\r | |
734 | ; returns physical=logical.\r | |
735 | \r | |
736 | sectrn:\r | |
737 | ld l,c\r | |
738 | ld h,b\r | |
739 | ld a,d\r | |
740 | or e\r | |
741 | ret z\r | |
742 | ex de,hl\r | |
743 | add hl,bc\r | |
744 | ld l,(hl)\r | |
745 | ld h,0\r | |
746 | ret\r | |
747 | \r | |
748 | \r | |
749 | ; READ\r | |
750 | ; Read physical record from currently selected drive.\r | |
751 | ; Finds address of proper read routine from\r | |
752 | ; extended disk parameter header (XDPH).\r | |
753 | \r | |
754 | read:\r | |
b27f7b99 L |
755 | ld ix,(@xdph) ; get drive descriptor pointer\r |
756 | ld l,(ix-8) ; get read routine entry\r | |
ea5293bb L |
757 | ld h,(ix-7)\r |
758 | jp (hl)\r | |
759 | \r | |
760 | \r | |
761 | ; WRITE\r | |
762 | ; Write physical sector from currently selected drive.\r | |
763 | ; Finds address of proper write routine from\r | |
764 | ; extended disk parameter header (XDPH).\r | |
765 | \r | |
766 | write:\r | |
b27f7b99 L |
767 | ld ix,(@xdph) ; get drive descriptor pointer\r |
768 | ld l,(ix-10) ; get write routine entry\r | |
ea5293bb L |
769 | ld h,(ix- 9)\r |
770 | jp (hl)\r | |
771 | \r | |
772 | \r | |
773 | \r | |
774 | ; MULTIO\r | |
775 | ; Set multiple sector count. Saves passed count in\r | |
776 | ; @CNT\r | |
777 | \r | |
778 | multio:\r | |
779 | ld (@cnt),a\r | |
780 | ret\r | |
781 | \r | |
782 | \r | |
783 | ; FLUSH\r | |
784 | ; BIOS deblocking buffer flush. Not implemented.\r | |
785 | \r | |
786 | flush:\r | |
787 | xor a\r | |
b27f7b99 | 788 | ret ; return with no error\r |
ea5293bb L |
789 | \r |
790 | \r | |
791 | \r | |
792 | ; error message components\r | |
793 | drive$msg: db cr,lf,bell,'BIOS Error on ',0\r | |
794 | track$msg: db ': T-',0\r | |
795 | sector$msg: db ', S-',0\r | |
796 | \r | |
797 | \r | |
798 | ; disk communication data items\r | |
799 | ; do not change order. sd driver depends on this\r | |
800 | \r | |
801 | @xdph: ds 2 ; pointer to currently selected drives dph\r | |
802 | @adrv: ds 1 ; currently selected disk drive\r | |
803 | @rdrv: ds 1 ; controller relative disk drive\r | |
ea5293bb L |
804 | @trk: ds 2 ; current track number\r |
805 | @sect: ds 2 ; current sector number\r | |
806 | @dma: ds 2 ; current DMA address\r | |
807 | @dbnk: db 0 ; bank for DMA operations\r | |
1d26b866 | 808 | @cnt: db 0 ; record count for multisector transfer\r |
ea5293bb L |
809 | \r |
810 | \r | |
811 | cseg ; common memory\r | |
812 | \r | |
813 | @cbnk: db 0 ; bank for processor operations\r | |
814 | \r | |
815 | \r | |
816 | end\r |