1;
2;  Disassembly of Cromemco's RDOS 2.52 ROM for the 16FDC Disk Controller
3;      it normally resides at C000H to CFFFH
4;
5        ORG     0C000H
6;
7CR	EQU	0DH
8SPACE	EQU	20H
9BS	EQU	08H
10ESC	EQU	1BH
11squote	equ	27h
12msbon	EQU	80H
13;
14start:	DI
15	JR	cldst
16;
17C003:	JP	C030
18	JP	C504
19	JP	C037
20	JP	C03B
21	JP	CB9E
22	JP	CD37
23	JP	C4D4
24	JP	CD52
25	JP	C5AB
26	JP	seturt	; set up UART
27	JP	inchr	; input
28	JP	ckinst	; inp. status
29	JP	CBEA
30	JP	pt7ba	; output
31	JP	crlf
32;
33C030:	LD	(77H),A
34	LD	A,B
35	JP	C387
36;
37C037:	LD	(75H),A
38	RET
39;
40C03B:	LD	(76H),A
41	RET
42;
43cldst:	XOR	A	;inhibit 5501 interrupts
44	OUT	(3),A
45	LD	B,A
46	EXX
47	CPL		;turn off PerSci and voice
48	OUT	(4),A	;    coil options
49	LD	A,0D0H
50	OUT	(30H),A	;force interrupt on FDC
51	LD	HL,2EH
52	LD	SP,HL
53clp1:	DEC	H
54	JR	NZ,clp1
55clp2:	LD	(HL),H
56	INC	L
57	JR	NZ,clp2
58	INC	H
59	LD	(62H),HL
60	LD	(64H),HL
61	CALL	seturt
62	IN	A,(34H)	; sw 3 set for autoboot?
63	AND	40H
64	JP	NZ,gomon ; no
65getsw:	IN	A,(04H)	;read sense switches
66	CPL		;on = 1
67	AND	3	;bits 7 & 8 (unused??)
68boot:	LD	(77H),A
69	CALL	ptfol
70        DEFB    'Preparing to boot, ESC to abort'
71        DEFB    CR+msbon
72	CALL	setsel
73	LD	D,A
74	OUT	(34H),A
75	LD	B,64H
76esclp:	CALL	ckesc	; look for escape
77	LD	HL,64H
78	CALL	dela1
79	DJNZ	esclp
80	LD	(75H),A
81	LD	(7DH),A
82	LD	(78H),A
83	INC	A
84	LD	(76H),A
85	CALL	C1F7
86	LD	(7EH),A
87	LD	HL,80H
88	LD	(7BH),HL
89	LD	(79H),HL
90	LD	A,'B'
91	LD	(70H),A
92	LD	B,2
93C0C8:	PUSH	BC
94	CALL	CD37
95	CALL	NC,CDCB
96	CALL	NC,CD52
97	POP	BC
98	JR	NC,C0E8
99	CALL	ckesc	; look for escape
100	DJNZ	C0C8
101	CALL	ptfol
102	DEFB    CR,'Unable ','t'+msbon
103	JR	C115
104;
105C0E8:	LD	A,(80H)
106	CP	40H
107	JR	Z,C0F3
108	CP	0E5H
109	JR	NZ,C0FA
110C0F3:	CALL	ptfol
111        DEFB    CR,'N'+msbon
112    	JR      C115
113;
114C0FA:	CALL	ckesc	; look for escape
115	CALL	setsel
116	LD	D,A
117	LD	A,(77H)
118	EX	AF,AF'
119	CALL	ptfol
120	DEFB    CR,'Standby',CR+msbon
121	SCF
122	JP	80H
123;
124C115:	CALL	ptfol
125	DEFB    'o boot',CR+msbon
126	LD	A,(71H)
127	OR	A
128	CALL	NZ,C359
129	JR	C131
130;
131ckesc:	CALL	ckinst
132	CALL	NZ,inchr
133	CP	esc
134	RET	NZ
135C131:	LD	A,0D0H	;force FDC interrupt
136	OUT	(30H),A
137	LD	A,7CH	;select side 1
138	OUT	(4),A
139gomon:	CALL	ptfol
140	DEFB    CR,'Cromemco RDOS 02.52',CR+msbon
141C151:	XOR     A
142	LD	(6CH),A
143inlp:	LD	A,(7EH)
144	LD	B,A
145	CALL	C1E2
146	LD	SP,2EH
147	CALL	ptfol
148        DEFB    ';'+msbon
149	CALL	C7A3
150	CALL	loctok
151	AND	A
152	JR	Z,C151
153	CALL	C2C1
154	JR	Z,inlp
155	LD	A,B
156	CP	17H
157	JR	NC,inper
158	ADD	A,A
159	LD	HL,table
160	CALL	C186
161	LD	A,(HL)
162	INC	HL
163	LD	H,(HL)
164	LD	L,A
165	CALL	C1C7   ; go there
166	JR	inlp
167;
168C186:	ADD	A,L
169	LD	L,A
170	RET	NC
171	INC	H
172	RET
173;
174table:  DEFW	CCFD	; Align
175	DEFW	C1C8	; Boot
176	DEFW	inper	; ?
177	DEFW	C72B	; Display
178	DEFW	C62A	; Examine
179	DEFW	inper	; ?
180	DEFW	C1C4	; Go
181	DEFW	inper	; ?
182	DEFW	C245	; Init
183	DEFW	inper	; ?
184	DEFW	inper	; ?
185	DEFW	C439	; Logged disks
186	DEFW	C645	; Move
187	DEFW	inper	; ?
188	DEFW	C636	; Output
189	DEFW	inper	; ?
190	DEFW	C6C2	; Query
191	DEFW	C516	; Read disk
192	DEFW	C67A	; Set
193	DEFW	C941	; Test
194	DEFW	inper	; ?
195	DEFW	C652	; Verify
196	DEFW	C51A	; Write disk
197;
198C1B9:	XOR	A
199	LD	(6CH),A
200inper:	CALL	ptfol
201	DEFB    '?',CR+msbon
202	JR	inlp
203;
204C1C4:	CALL	C853
205C1C7:	JP	(HL)
206;
207C1C8:	CALL	loctok
208	OR	A
209	JP	Z,getsw
210	CP	'E'
211	JP	NC,C42A
212	SUB	'A'
213	JP	C,C42A
214	PUSH	AF
215	INC	DE
216	CALL	fndeol
217	POP	AF
218	JP	boot
219;
220C1E2:	LD	A,(6CH)
221	OR	A
222	RET	Z
223	CALL	pt7ba
224	BIT	3,B
225	RET	NZ
226	BIT	7,B
227	LD	A,';'
228	CALL	NZ,pt7ba
229	JP	pt7ba
230;
231C1F7:	LD	A,D
232	OUT	(34H),A
233	LD	A,0DFH
234	OUT	(4),A
235	LD	A,0D4H
236	OUT	(30H),A
237C202:	IN	A,(34H)
238	RRCA
239	JR	NC,C202
240	IN	A,(30H)
241	LD	BC,200H
242	CALL	C23B
243C20F:	LD	A,0D4H
244	OUT	(30H),A
245C213:	CALL	C234
246	JR	Z,C1F7
247	IN	A,(34H)
248	RRCA
249	JR	NC,C213
250	IN	A,(30H)
251	DJNZ	C20F
252	XOR	A
253	OUT	(3),A
254	LD	A,C
255	CP	'Z'
256	JR	NC,C22C
257	ADD	A,A
258	ADD	A,A
259	ADD	A,A
260C22C:	CP	0B7H
261	LD	A,80H
262	RET	NC
263	LD	A,4
264	RET
265;
266C234:	IN	A,(3)
267	CP	0C7H
268	RET	NZ
269	INC	C
270	RET	Z
271C23B:	LD	A,1
272	OUT	(3),A
273	LD	A,0FAH
274	OUT	(5),A
275	JR	C234
276;
277C245:	CALL	fndeol
278	CALL	crlf
279seturt:	IN	A,(4)	; aux. disk status
280	AND	8
281	JR	Z,C2AE	; baud rate preset
282C251:	LD	A,0AH
283	OUT	(2),A	; UART command register
284	LD	HL,7D0H
285	CALL	dela1
286	LD	A,8
287	OUT	(2),A
288	LD	D,64H
289C261:	DEC	D
290	JR	Z,C251
291C264:	LD	HL,0C2B9H
292	LD	C,0
293	LD	A,19H
294	LD	B,9
295C26D:	OUT	(2),A
296	OUTI
297	JR	Z,C261
298	CALL	C298
299	CALL	C298
300	JR	C,C264
301	CP	0DH
302	LD	A,9
303	JR	NZ,C26D
304C281:	LD	A,0DH
305	OUT	(1),A
306	LD	HL,0FA0H
307	CALL	dela1
308	CALL	ckinst
309	CALL	NZ,inchr
310	CP	0DH
311	JR	Z,C281
312	JP	crlf
313;
314C298:	PUSH	DE
315	LD	DE,8CA0H
316C29C:	CALL	ckinst
317	JR	Z,C2A6
318	CALL	inchr
319	JR	C2AC
320;
321C2A6:	DEC	DE
322	LD	A,D
323	OR	E
324	JR	NZ,C29C
325	SCF
326C2AC:	POP	DE
327	RET
328;
329C2AE:	LD	A,9
330	OUT	(2),A
331	LD	A,84H
332	OUT	(0),A
333	JP	crlf
334;
335C2B9:	DEFB	90H,0C0H,0A0H,90H
336	DEFB	88H,84H,82H,1
337;
338C2C1:	SUB	'A'
339	JP	C,inper
340	LD	B,A
341	INC	DE
342	LD	A,(DE)
343	CP	';'
344	RET	NZ
345	LD	A,B
346	CP	4
347	JP	NC,C42A
348	ADD	A,'A'
349	LD	(6CH),A
350	CALL	C3F6
351	INC	DE
352	LD	A,(DE)
353	CP	';'
354	LD	B,0CH
355	JR	NZ,C2ED
356	INC	DE
357	LD	A,(DE)
358	CP	';'
359	LD	B,4
360	JR	NZ,C2ED
361	LD	B,80H
362	INC	DE
363C2ED:	PUSH	BC
364	CALL	C3B7
365	POP	BC
366	LD	(HL),B
367	JR	NC,C2FB
368	LD	A,(6DH)
369	OR	B
370	LD	(HL),A
371	SCF
372C2FB:	PUSH	AF
373	CALL	C384
374	LD	(78H),A
375	LD	(7DH),A
376	INC	A
377	LD	(76H),A
378	CALL	C604
379	LD	A,'H'
380	LD	(70H),A
381	CALL	CD37
382	PUSH	AF
383	CALL	C61E
384	POP	AF
385	JP	C,C40D
386	POP	AF
387	JP	C,C3B5
388C320:	CALL	C604
389	LD	HL,100H
390	LD	(7BH),HL
391	CALL	CDCB
392	CALL	CD52
393	PUSH	AF
394	CALL	C61E
395	POP	AF
396	JR	NC,C363
397	LD	A,(71H)
398	OR	A
399	JP	P,C345
400	LD	HL,64H
401	CALL	dela1
402	JR	C320
403;
404C345:	CALL	ptfol
405	DEFB    'Can',squote
406	DEFB	't read Label',CR+msbon
407C359:	LD	E,1
408	CALL	C5F2
409	CALL	C413
410	XOR	A
411	RET
412;
413C363:	LD	BC,10H
414	LD	DE,17AH
415	CALL	C3EE
416	LD	C,1
417	CALL	C3EE
418	LD	A,(178H)
419	CP	'C'
420	JR	NZ,C37A
421	SET	1,B
422C37A:	LD	A,(7EH)
423	AND	0CCH
424	OR	B
425	LD	HL,(6AH)
426	LD	(HL),A
427C384:	CALL	C3F6
428C387:	LD	(7EH),A
429	BIT	0,A
430	LD	DE,100AH
431	LD	HL,200H
432	JR	NZ,C3A1
433	BIT	1,A
434	LD	DE,805H
435	JR	NZ,C3A1
436C39B:	LD	DE,1A12H
437	LD	HL,80H
438C3A1:	LD	(79H),HL
439	BIT	7,A
440	LD	A,'L'
441	LD	B,D
442	JR	Z,C3AE
443	LD	A,squote
444	LD	B,E
445C3AE:	LD	(6FH),A
446	LD	A,B
447	LD	(6EH),A
448C3B5:	XOR	A
449	RET
450;
451C3B7:	CALL	loctok
452	OR	A
453	RET	Z
454	LD	BC,10H
455	CALL	C3DE
456	LD	C,1
457	CALL	C3DE
458	CALL	loctok
459	CP	'C'
460	JR	NZ,C3D4
461	SET	1,B
462	INC	DE
463	CALL	loctok
464C3D4:	OR	A
465	JP	NZ,C1B9
466	LD	A,B
467	LD	(6DH),A
468	SCF
469	RET
470;
471C3DE:	CALL	loctok
472	INC	DE
473	CP	'S'
474	RET	Z
475	CP	'D'
476	JP	NZ,C1B9
477C3EA:	LD	A,B
478	OR	C
479	LD	B,A
480	RET
481;
482C3EE:	LD	A,(DE)
483	INC	DE
484	INC	DE
485	CP	'D'
486	RET	NZ
487	JR	C3EA
488;
489C3F6:	LD	A,(6CH)
490	SUB	'A'
491	LD	(77H),A
492	LD	HL,66H
493	CALL	C186
494	LD	(6AH),HL
495	LD	A,(HL)
496	OR	A
497	RET
498;
499C40A:	CALL	C5F2
500C40D:	CALL	C413
501	JP	inlp
502;
503C413:	CALL	ptfol
504	DEFB    ' Err','-'+msbon
505	LD	A,(70H)
506	CALL	pt7ba
507	LD	A,(71H)
508	CALL	pspa
509	JP	crlf
510;
511C42A:	CALL	ptfol
512	DEFB    'A-D only',CR+msbon
513	JP	inlp
514;
515C439:	CALL	fndeol
516	LD	A,(77H)
517	PUSH	AF
518	LD	A,(6CH)
519	PUSH	AF
520	LD	A,'A'
521C446:	PUSH	AF
522	LD	(6CH),A
523	CALL	C3F6
524	LD	HL,(6AH)
525	LD	B,(HL)
526	CALL	NZ,C463
527	POP	AF
528	INC	A
529	CP	'E'
530	JR	C,C446
531	POP	AF
532	LD	(6CH),A
533	POP	AF
534	LD	(77H),A
535	RET
536;
537C463:	CALL	ptfol
538	DEFB	' ',SPACE+msbon
539	CALL	C1E2
540	CALL	ptfol
541	DEFB	';',SPACE+msbon
542	BIT	3,B
543	CALL	NZ,ptspc
544	BIT	7,B
545	CALL	Z,ptspc
546	BIT	4,B
547	CALL	C498
548	CALL	ptspc
549	BIT	0,B
550	CALL	C498
551	BIT	1,B
552	JR	Z,C495
553	CALL	ptfol
554	DEFB	' Cromi','x'+msbon
555C495:	JP	crlf
556;
557C498:	LD	A,'D'
558	JR	NZ,C49E
559	LD	A,'S'
560C49E:	JP	pt7ba
561C4A1:	LD	B,A
562	LD	A,(6CH)
563	OR	A
564	JP	Z,inper
565	LD	A,B
566	CP	'S'
567	JR	Z,C4DA
568	CALL	C8B0
569C4B1:	JP	C,inper
570	PUSH	HL
571	CALL	C4E1
572	LD	A,'S'
573	LD	(70H),A
574	POP	HL
575	XOR	A
576	OR	H
577	JP	NZ,inper
578	LD	A,(6FH)
579	CP	L
580	JR	C,C4B1
581	LD	A,L
582	LD	(75H),A
583	CALL	C4D4
584	RET	NC
585	JP	C40D
586;
587C4D4:	CALL	C5F8
588	JP	CDCB
589;
590C4DA:	INC	DE
591	CALL	C4E1
592	JP	CDCB
593;
594C4E1:	LD	A,(75H)
595	LD	(7DH),A
596	CALL	C8AD
597	RET	C
598	XOR	A
599	OR	H
600C4ED:	JP	NZ,inper
601	LD	A,L
602	OR	A
603	JR	NZ,C4F8
604	LD	(78H),A
605	RET
606;
607C4F8:	DEC	A
608	JR	NZ,C4ED
609	CALL	C3F6
610	BIT	4,A
611	JR	Z,C508
612	LD	A,1
613C504:	LD	(78H),A
614	RET
615;
616C508:	CALL	ptfol
617	DEFB	'S.Sided',CR+msbon
618	JP	inlp
619;
620C516:	LD	B,'R'
621	JR	C51C
622;
623C51A:	LD	B,'W'
624C51C:	LD	A,(DE)
625	CP	'D'
626	JP	NZ,inper
627	LD	A,B
628	LD	(70H),A
629	CALL	C5BB
630	PUSH	HL
631	POP	IY
632	LD	H,B
633	LD	L,C
634C52E:	PUSH	DE
635	PUSH	HL
636	LD	A,E
637	LD	(76H),A
638	LD	(7BH),IY
639	CALL	C4D4
640	LD	A,(70H)
641	CP	'W'
642	SCF
643	CCF
644	CALL	Z,C5AB
645	JR	C,C54F
646	LD	A,(70H)
647	CP	'R'
648	CALL	Z,CD52
649C54F:	POP	HL
650	POP	DE
651	JP	C,C40A
652	LD	BC,(79H)
653	ADD	IY,BC
654	INC	BC
655	SBC	HL,BC
656	INC	HL
657	JP	C,C5F2
658	INC	E
659	LD	A,(6EH)
660	CP	E
661	JR	NC,C52E
662	LD	A,(75H)
663	LD	(7DH),A
664	INC	A
665	LD	B,A
666	LD	A,(6FH)
667	CP	B
668	JR	C,C57E
669	LD	A,B
670	LD	(75H),A
671	LD	E,1
672	JR	C52E
673;
674C57E:	DEC	E
675	CALL	C5F2
676	CALL	ptfol
677	DEFB	'Next memory:',SPACE+msbon
678	PUSH	IY
679	POP	HL
680	CALL	hxphl
681	CALL	ptfol
682	DEFB	CR,'End of Disk',CR+msbon
683	JP	inlp
684;
685C5AB:	LD	HL,7EH
686	LD	B,(HL)
687	PUSH	BC
688	SET	1,(HL)
689	CALL	CD5F
690	POP	BC
691	LD	A,B
692	LD	(7EH),A
693	RET
694;
695C5BB:	LD	A,(6CH)
696	OR	A
697	JP	Z,inper
698	INC	DE
699	CALL	C82F
700	XOR	A
701	OR	D
702C5C8:	JP	NZ,inper
703	OR	E
704	JP	Z,inper
705	PUSH	BC
706	PUSH	DE
707	PUSH	HL
708	CALL	C5F8
709	POP	HL
710	POP	DE
711	POP	BC
712	LD	A,(6EH)
713	CP	E
714	JR	C,C5C8
715C5DE:	IN	A,(31H)
716	LD	D,A
717	EX	DE,HL
718	CALL	ptspc
719	CALL	hxphl
720	EX	DE,HL
721	CALL	ptspc
722	LD	A,(78H)
723	JP	ptchr
724;
725C5F2:	CALL	C5DE
726	JP	crlf
727;
728C5F8:	LD	A,(75H)
729	OR	A
730	JR	NZ,C61E
731	LD	A,(78H)
732	OR	A
733	JR	NZ,C61E
734C604:	LD	A,(7EH)
735	BIT	5,A
736	RET	NZ
737	BIT	1,A
738	JR	NZ,C611
739	BIT	0,A
740	RET	Z
741C611:	LD	(7FH),A
742	SET	5,A
743	RES	0,A
744	LD	(7EH),A
745	JP	C39B
746;
747C61E:	LD	A,(7EH)
748	BIT	5,A
749	RET	Z
750	LD	A,(7FH)
751	JP	C387
752;
753C62A:	CALL	C853
754	LD	C,L
755	IN	A,(C)
756	CALL	hxpa
757	JP	crlf
758;
759C636:	CALL	C8AD
760	PUSH	HL
761	CALL	rmcom
762	CALL	C853
763	POP	DE
764	LD	C,L
765	OUT	(C),E
766	RET
767;
768C645:	CALL	C82F
769	PUSH	BC
770	PUSH	DE
771	PUSH	HL
772	LDIR
773	POP	HL
774	POP	DE
775	POP	BC
776	JR	C655
777;
778C652:	CALL	C82F
779C655:	LD	A,(DE)
780	CP	(HL)
781	JR	Z,C672
782	CALL	hxphl
783	LD	A,(HL)
784	CALL	pspa
785	CALL	ptspc
786	LD	A,(DE)
787	CALL	pspa
788	CALL	ptspc
789	EX	DE,HL
790	CALL	hxphl
791	EX	DE,HL
792	CALL	crlf
793C672:	INC	DE
794	INC	HL
795	DEC	BC
796	LD	A,B
797	OR	C
798	JR	NZ,C655
799	RET
800;
801C67A:	CALL	loctok
802	CP	'M'
803	JP	NZ,C4A1
804	INC	DE
805	LD	HL,(64H)
806	CALL	C85B
807C689:	CALL	hxphl
808	LD	A,(HL)
809	CALL	pspa
810	CALL	ptspc
811	CALL	C7A3
812	CALL	loctok
813	CP	'.'
814	RET	Z
815	CP	'-'
816	JR	NZ,C6A3
817	DEC	HL
818	JR	C6BD
819;
820C6A3:	CALL	C6F1
821	JR	NC,C6AF
822	CALL	ptfol
823	DEFB	'?',CR+msbon
824	JR	C689
825;
826C6AF:	XOR	A
827	ADD	A,B
828	JR	NZ,C6B6
829	INC	HL
830	JR	C6BD
831;
832C6B6:	LD	C,B
833	LD	B,0
834	EX	DE,HL
835	LDIR
836	EX	DE,HL
837C6BD:	LD	(64H),HL
838	JR	C689
839;
840C6C2:	CALL	C865
841	PUSH	BC
842	CALL	C6F1
843	POP	DE
844	JP	C,inper
845	XOR	A
846	ADD	A,B
847	JP	Z,inper
848C6D2:	PUSH	BC
849	PUSH	DE
850	PUSH	HL
851	LD	DE,2EH
852C6D8:	LD	A,(DE)
853	CP	(HL)
854	JR	NZ,C6E0
855	INC	DE
856	INC	HL
857	DJNZ	C6D8
858C6E0:	POP	HL
859	PUSH	HL
860	LD	B,10H
861	CALL	Z,C760
862	POP	HL
863	POP	DE
864	POP	BC
865	INC	HL
866	DEC	DE
867	LD	A,D
868	OR	E
869	JR	NZ,C6D2
870	RET
871;
872C6F1:	PUSH	HL
873	LD	B,0
874	LD	HL,2EH
875C6F7:	CALL	loctok
876	OR	A
877	JR	Z,C726
878	CP	','
879	INC	DE
880	JR	Z,C6F7
881	LD	C,A
882	CP	squote
883	JR	Z,C719
884	CP	'"'
885	JR	Z,C719
886	DEC	DE
887	PUSH	HL
888	CALL	C8AD
889	LD	A,L
890	POP	HL
891	JR	C,C726
892	LD	(HL),A
893	INC	HL
894	INC	B
895	JR	C6F7
896C719:	LD	A,(DE)
897	INC	DE
898	OR	A
899	JR	Z,C726
900	CP	C
901	JR	Z,C6F7
902	LD	(HL),A
903	INC	HL
904	INC	B
905	JR	C719
906;
907C726:	LD	DE,2EH
908	POP	HL
909	RET
910;
911C72B:	CALL	loctok
912	CP	'M'
913	JR	NZ,C733
914	INC	DE
915C733:	LD	BC,80H
916	LD	HL,(62H)
917	CALL	C84E
918C73C:	LD	E,10H
919	XOR	A
920	OR	B
921	JR	NZ,C74C
922	LD	A,0FH
923	CP	C
924	JR	C,C74C
925	XOR	A
926	OR	C
927	JR	Z,C74C
928	LD	E,C
929C74C:	PUSH	BC
930	LD	B,E
931	CALL	C760
932	LD	(62H),HL
933	POP	BC
934	LD	A,C
935	SUB	E
936	LD	C,A
937	JR	NC,C75B
938	DEC	B
939C75B:	LD	A,B
940	OR	C
941	JR	NZ,C73C
942	RET
943;
944C760:	CALL	hxphl
945	PUSH	BC
946	PUSH	HL
947	PUSH	DE
948	LD	C,0
949	LD	E,4
950C76A:	LD	A,3
951	AND	C
952	CALL	Z,C7A0
953	CALL	C7A0
954	LD	A,(HL)
955	CALL	hxpa
956	INC	E
957	INC	E
958	INC	HL
959	INC	C
960	DJNZ	C76A
961C77D:	CALL	C7A0
962	LD	A,':'
963	CP	E
964	JR	NZ,C77D
965	POP	DE
966	POP	HL
967	POP	BC
968C788:	LD	A,(HL)
969	INC	HL
970	CALL	C792
971	DJNZ	C788
972	JP	crlf
973;
974C792:	AND	7FH
975	CP	7FH
976	JR	Z,C79C
977	CP	' '
978	JR	NC,pt7ba
979C79C:	LD	A,'.'
980	JR	pt7ba
981C7A0:	INC	E
982	JR	ptspc
983C7A3:	LD	A,'1'
984	LD	DE,2EH
985	LD	(DE),A
986	PUSH	DE
987	CALL	CBEA
988	EX	(SP),HL
989	INC	HL
990	LD	B,(HL)
991	INC	B
992	INC	HL
993	PUSH	HL
994C7B3:	DEC	B
995	JR	Z,C7CD
996	LD	A,(HL)
997	CALL	lc2uc
998	LD	(HL),A
999	INC	HL
1000	CP	'"'
1001	JR	Z,C7C4
1002	CP	squote
1003	JR	NZ,C7B3
1004C7C4:	DEC	B
1005	JR	Z,C7CD
1006	CP	(HL)
1007	INC	HL
1008	JR	NZ,C7C4
1009	JR	C7B3
1010;
1011C7CD:	LD	(HL),0
1012	POP	DE
1013	POP	HL
1014	RET
1015;
1016lc2uc:	CP	'a'	;switch low. case to u.c.
1017	RET	C
1018	CP	'z'+1
1019	RET	NC
1020	SUB	' '
1021	RET
1022;
1023pspa:	PUSH	AF	;print space, c(A)
1024	CALL	ptspc
1025	POP	AF
1026	JR	hxpa
1027;
1028hxphl:	LD	A,H	;hex print c(HL)
1029	CALL	hxpa
1030	LD	A,L
1031hxpa:	PUSH	AF	;hex print c(A)
1032	RRA
1033	RRA
1034	RRA
1035	RRA
1036	CALL	ptchr
1037	POP	AF
1038ptchr:	AND	0FH
1039	CP	0AH
1040	JR	C,ptnum
1041	ADD	A,7
1042ptnum:	ADD	A,'0'
1043	JR	pt7ba
1044
1045ptspc:	LD	A,' '
1046pt7ba:	PUSH	AF	; print 7-bit char.
1047	AND	7FH
1048	CALL	CC99
1049	POP	AF
1050	RET
1051;
1052ptfol:	EX	(SP),HL	; print string
1053ptchl:	LD	A,(HL)
1054	INC	HL
1055	OR	A
1056	JR	Z,endpts
1057	CALL	pt7ba
1058	JP	P,ptchl
1059endpts:	EX	(SP),HL
1060	RET
1061;
1062loctok:	LD	A,(DE)	; locate next non-blank (DE)
1063	CP	' '
1064	RET	NZ
1065	INC	DE
1066	JR	loctok
1067;
1068rmcom:	CALL	loctok	; remove comma & spaces (DE)
1069	CP	','
1070	RET	NZ
1071	INC	DE
1072	CALL	loctok
1073	XOR	A
1074	RET
1075;
1076fndeol:	CALL	loctok
1077	OR	A
1078	RET	Z
1079	JP	inper
1080;
1081C82F:	LD	HL,80H
1082	LD	B,H
1083	LD	C,L
1084	CALL	C868
1085	PUSH	HL
1086	PUSH	BC
1087	CALL	rmcom
1088	CALL	C8AD
1089	JP	C,inper
1090	CALL	fndeol
1091	EX	DE,HL
1092	POP	BC
1093	POP	HL
1094	RET
1095;
1096	CALL	C865
1097	JR	fndeol
1098;
1099C84E:	CALL	C868
1100	JR	fndeol
1101;
1102C853:	CALL	C8AD
1103	JP	C,inper
1104	JR	fndeol
1105;
1106C85B:	PUSH	HL
1107	CALL	C8AD
1108	JR	C,C862
1109	EX	(SP),HL
1110C862:	POP	HL
1111	JR	fndeol
1112;
1113C865:	SCF
1114	JR	C869
1115C868:	OR	A
1116C869:	EX	AF,AF'
1117	PUSH	BC
1118	PUSH	HL
1119	CALL	C8AD
1120	JR	NC,C879
1121	EX	AF,AF'
1122	JP	C,inper
1123	EX	AF,AF'
1124	POP	HL
1125	JR	C87A
1126;
1127C879:	POP	AF
1128C87A:	CALL	C887
1129	JR	NC,C885
1130	EX	AF,AF'
1131	POP	BC
1132	RET	NC
1133	JP	inper
1134;
1135C885:	POP	AF
1136	RET
1137;
1138C887:	CALL	rmcom
1139	LD	A,(DE)
1140	CP	'S'
1141	JR	NZ,C890
1142	INC	DE
1143C890:	PUSH	HL
1144	PUSH	AF
1145	CALL	C8AD
1146	JR	C,C8A6
1147	LD	B,H
1148	LD	C,L
1149	POP	AF
1150	POP	HL
1151	JR	Z,C8A4
1152	LD	A,C
1153	SUB	L
1154	LD	C,A
1155	LD	A,B
1156	SBC	A,H
1157	LD	B,A
1158	INC	BC
1159C8A4:	OR	A
1160	RET
1161;
1162C8A6:	POP	AF
1163	POP	HL
1164	JP	Z,inper
1165	SCF
1166	RET
1167;
1168C8AD:	CALL	loctok
1169C8B0:	CALL	C8E0
1170	RET	C
1171	PUSH	DE
1172C8B5:	INC	DE
1173	CALL	C8E0
1174	JR	NC,C8B5
1175	POP	DE
1176	CP	'.'
1177	JR	Z,C8C5
1178	CALL	C8CA
1179	AND	A
1180	RET
1181;
1182C8C5:	CALL	C8F4
1183	AND	A
1184	RET
1185;
1186C8CA:	LD	HL,0
1187C8CD:	CALL	C8E0
1188	JR	C,C8DB
1189	ADD	HL,HL
1190	ADD	HL,HL
1191	ADD	HL,HL
1192	ADD	HL,HL
1193	ADD	A,L
1194	LD	L,A
1195	INC	DE
1196	JR	C8CD
1197C8DB:	CP	'H'
1198	RET	NZ
1199	INC	DE
1200	RET
1201;
1202C8E0:	LD	A,(DE)
1203	CP	'0'
1204	RET	C
1205	CP	':'
1206	JR	C,C8F1
1207	CP	'A'
1208	RET	C
1209	CP	'G'
1210	CCF
1211	RET	C
1212	SUB	7
1213C8F1:	SUB	'0'
1214	RET
1215;
1216C8F4:	LD	HL,0
1217C8F7:	CALL	C910
1218	INC	DE
1219	JR	C,C90A
1220	PUSH	BC
1221	ADD	HL,HL
1222	LD	B,H
1223	LD	C,L
1224	ADD	HL,HL
1225	ADD	HL,HL
1226	ADD	HL,BC
1227	POP	BC
1228	CALL	C186
1229	JR	C8F7
1230;
1231C90A:	CP	'.'
1232	RET	Z
1233	JP	inper
1234C910:	LD	A,(DE)
1235	CP	'0'
1236	RET	C
1237	CP	':'
1238	CCF
1239	RET	C
1240	SUB	'0'
1241	RET
1242;
1243C91B:	LD	BC,18H
1244	LD	DE,100H
1245	LD	HL,0C929H
1246	LDIR
1247	JP	0100H
1248;
1249C929:	LD	BC,1000H
1250	LD	DE,1000H
1251	LD	HL,start
1252	PUSH	BC
1253	PUSH	DE
1254	PUSH	HL
1255	LDIR
1256	LD	A,1
1257	OUT	(40H),A
1258	POP	DE
1259	POP	HL
1260	POP	BC
1261	LDIR
1262	RET
1263;
1264C941:	CALL	loctok	; "T"est
1265	CP	'Z'
1266	PUSH	AF
1267	JR	NZ,C94A
1268	INC	DE
1269C94A:	CALL	fndeol
1270	POP	AF
1271	CALL	NZ,C91B
1272	CALL	ptfol
1273	DEFB	CR,'Memory',':'+msbon
1274	LD	BC,1000H
1275C95F:	CALL	ptspc
1276	LD	A,C
1277	CALL	ptchr
1278	INC	C
1279	DJNZ	C95F
1280	CALL	crlf
1281	LD	B,7
1282C96E:	CALL	ptspc
1283	DJNZ	C96E
1284	LD	H,B
1285	LD	L,B
1286C975:	CALL	ptspc
1287	PUSH	HL
1288	LD	DE,1000H
1289C97C:	LD	A,H
1290	CP	0C9H
1291	JR	NZ,C98A
1292	LD	A,L
1293	CP	8DH
1294	JR	C,C98A
1295	CP	9CH
1296	JR	C,C99C
1297C98A:	LD	B,(HL)
1298	LD	A,'U'
1299	LD	(HL),A
1300	CP	(HL)
1301	JR	NZ,C996
1302	CPL
1303	LD	(HL),A
1304	CP	(HL)
1305	JR	Z,C99B
1306C996:	LD	(HL),B
1307	LD	A,'X'
1308	JR	C9A4
1309;
1310C99B:	LD	(HL),B
1311C99C:	INC	HL
1312	DEC	DE
1313	LD	A,D
1314	OR	E
1315	JR	NZ,C97C
1316	LD	A,'^'
1317C9A4:	CALL	pt7ba
1318	POP	HL
1319	LD	A,10H
1320	ADD	A,H
1321	LD	H,A
1322	JR	NZ,C975
1323	CALL	ptfol
1324	DEFB	CR,'Specify disk (eg, A; or A;; or A;;;)',SPACE+msbon
1325	CALL	C7A3
1326	CALL	loctok
1327	OR	A
1328	JP	Z,crlf
1329	CALL	C2C1
1330	JP	NZ,C1B9
1331	CALL	ptfol
1332	DEFB	'Seek tests:',CR+msbon
1333	LD	B,15H
1334	LD	HL,sektab
1335seklp:	IN	A,(31H)
1336	LD	(7DH),A
1337	LD	A,(HL)
1338	PUSH	BC
1339	PUSH	HL
1340	CP	0FFH
1341	JR	NZ,CA35
1342	CALL	ptfol
1343	DEFB	SPACE,'Restore',':'+msbon
1344	CALL	C604
1345	CALL	CD37
1346	EX	AF,AF'
1347	CALL	C61E
1348	EX	AF,AF'
1349	JR	CA4C
1350;
1351; seek test targets
1352;
1353sektab:	DEFB	1,2,3,4,5,0feh
1354	DEFB	6,7,8,9,0,0feh
1355	DEFB	27h,0,15h,0,1,0feh
1356	DEFB	0ffh,0feh
1357	DEFB	27h
1358;
1359CA35:	CP	0FEH
1360	JR	NZ,CA3F
1361	CALL	crlf
1362	OR	A
1363	JR	CA51
1364;
1365CA3F:	LD	(75H),A
1366	CALL	pspa
1367	CALL	ptfol
1368	DEFB	':'+msbon
1369	CALL	C4D4
1370CA4C:	PUSH	AF
1371	CALL	ckcry
1372	POP	AF
1373CA51:	POP	HL
1374	POP	BC
1375	JP	C,crlf
1376	INC	HL
1377	DJNZ	seklp
1378	CALL	ptfol
1379	DEFB	CR,'Read/Write tests',CR+msbon
1380	CALL	CB94
1381	CALL	CBB0
1382	JP	C,crlf
1383	CALL	ptfol
1384	DEFB	'Write test MAY DESTROY data'
1385	DEFB	CR,'ESC=abort RETURN=proceed',SPACE+msbon
1386	CALL	C7A3
1387	LD	HL,900H
1388	CALL	setpat
1389	LD	BC,200H
1390CABB:	LD	(HL),L
1391	INC	HL
1392	DEC	BC
1393	LD	A,B
1394	OR	C
1395	JR	NZ,CABB
1396	CALL	CBC1
1397	JR	NC,CB35
1398CAC7:	CALL	ptfol
1399	DEFB	'Test failed!',CR
1400	DEFB    'Disk data a','t'+msbon
1401	LD	E,1
1402	CALL	C5DE
1403	CALL	ptfol
1404	DEFB	' may have been destroyed'
1405	DEFB	CR,'Original is located at 0D00','s'+msbon
1406	LD	HL,(79H)
1407	CALL	hxphl
1408	CALL	ptfol
1409	DEFB	' in memory',CR+msbon
1410	RET
1411;
1412CB35:	LD	HL,0B00H
1413	CALL	setpat
1414	CALL	CBB0
1415	JR	C,CAC7
1416	CALL	ptfol
1417	DEFB	'Pattern compare',SPACE+msbon
1418	LD	BC,(79H)
1419	LD	DE,900H
1420	LD	HL,0B00H
1421CB5D:	LD	A,(DE)
1422	CP	(HL)
1423	JR	NZ,CB6A
1424	INC	DE
1425	INC	HL
1426	DEC	BC
1427	LD	A,B
1428	OR	C
1429	JR	NZ,CB5D
1430	JR	CB6B
1431;
1432CB6A:	SCF
1433CB6B:	CALL	CBD1
1434	CALL	CB94
1435	CALL	CBC1
1436	JP	C,CAC7
1437	JP	crlf
1438;
1439ckcry:	JR	C,ng
1440	CALL	ptfol
1441	DEFB	'O','K'+msbon
1442	RET
1443;
1444ng:	CALL	ptfol
1445	DEFB	'error',SPACE+msbon
1446	LD	A,(71H)
1447	CALL	hxpa
1448	JP	crlf
1449;
1450CB94:	CALL	ptfol
1451	DEFB	'Dat','a'+msbon
1452	LD	HL,0D00H
1453CB9E:	LD	(7BH),HL
1454	RET
1455;
1456setpat:	LD	(7BH),HL
1457	CALL	ptfol
1458	DEFB	'Patter','n'+msbon
1459	RET
1460;
1461CBB0:	CALL	CBDA
1462	CALL	ptfol
1463	DEFB	' read',SPACE+msbon
1464	CALL	CD52
1465	JR	CBD1
1466;
1467CBC1:	CALL	CBDA
1468	CALL	ptfol
1469	DEFB	' write',SPACE+msbon
1470	CALL	C5AB
1471CBD1:	PUSH	AF
1472	CALL	ckcry
1473	CALL	crlf
1474	POP	AF
1475	RET
1476;
1477CBDA:	LD	A,squote
1478	LD	(75H),A
1479	LD	(7DH),A
1480	LD	A,1
1481	LD	(76H),A
1482	JP	CDCB
1483CBEA:	PUSH	BC
1484	PUSH	HL
1485CBEC:	LD	B,0
1486	LD	HL,2
1487	ADD	HL,DE
1488CBF2:	CALL	CC64
1489	CP	10H
1490	CALL	Z,CCBB
1491	JR	Z,CBF2
1492	CP	esc
1493	JP	Z,CC8E
1494	CP	8
1495	JR	Z,CC09
1496	CP	7FH
1497	JR	NZ,CC1A
1498CC09:	XOR	A
1499	OR	B
1500	JR	Z,CBF2
1501	DEC	HL
1502	DEC	B
1503	CALL	CC4B
1504	LD	A,(HL)
1505	CP	' '
1506	CALL	C,CC4B
1507	JR	CBF2
1508;
1509CC1A:	CP	0DH
1510	CALL	Z,CC45
1511	JR	Z,CC3C
1512	CP	15H
1513	JR	NZ,CC2D
1514	CALL	CC45
1515	CALL	crlf
1516	JR	CBEC
1517CC2D:	LD	C,A
1518	LD	A,(DE)
1519	DEC	A
1520	CP	B
1521	JR	Z,CBF2
1522	LD	A,C
1523	CALL	CC45
1524	LD	(HL),A
1525	INC	HL
1526	INC	B
1527	JR	CBF2
1528CC3C:	LD	(HL),0
1529	LD	A,B
1530	INC	DE
1531	LD	(DE),A
1532	DEC	DE
1533	POP	HL
1534	POP	BC
1535	RET
1536;
1537CC45:	PUSH	AF
1538	CALL	CC52
1539	POP	AF
1540	RET
1541;
1542CC4B:	CALL	ptfol
1543	DEFB	BS,' ',BS+msbon
1544	RET
1545;
1546CC52:	CP	' '
1547	JR	NC,CC99
1548	CP	0DH
1549	JR	Z,CC99
1550	PUSH	AF
1551	CALL	ptfol
1552	DEFB	'^'+msbon
1553	POP	AF
1554	ADD	A,'@'
1555	JR	CC99
1556;
1557CC64:	CALL	CD23
1558	CALL	ckinst
1559	JR	Z,CC64
1560inchr:	CALL	ckinst
1561	JR	Z,inchr
1562	IN	A,(1)
1563	AND	7FH
1564	RET
1565;
1566ckinst:	IN	A,(0)
1567	AND	'@'
1568	RET
1569;
1570CC7B:	CALL	ckinst
1571	RET	Z
1572	CALL	inchr
1573	CP	13H
1574	CALL	Z,inchr
1575	CP	0DH
1576	JR	Z,CC8E
1577	CP	ESC
1578	RET	NZ
1579CC8E:	LD	SP,2EH
1580	CALL	crlf
1581	JP	inlp
1582;
1583crlf:	LD	A,0DH
1584CC99:	PUSH	AF
1585	EXX
1586	BIT	7,B
1587	EXX
1588	CALL	NZ,CCCB
1589	CALL	CD23
1590CCA4:	IN	A,(0)	;check cons. status
1591	AND	80H
1592	JR	Z,CCA4
1593	POP	AF
1594	OUT	(1),A	;print to cons.
1595	CP	0DH
1596	RET	NZ
1597	LD	A,0AH
1598	CALL	CC99
1599	CALL	CC7B
1600	CP	10H
1601	RET	NZ
1602CCBB:	PUSH	AF
1603	EXX
1604	LD	A,80H
1605	XOR	B
1606	LD	B,A
1607	BIT	7,B
1608	EXX
1609	CALL	NZ,CCC9
1610	POP	AF
1611	RET
1612;
1613CCC9:	LD	A,11H
1614CCCB:	PUSH	AF
1615	PUSH	HL
1616	LD	HL,8
1617	CALL	dela1
1618	POP	HL
1619	POP	AF
1620	PUSH	AF
1621	CP	11H
1622	JR	Z,CCED
1623CCDA:	CALL	CC7B
1624	CP	10H
1625	JR	NZ,CCE6
1626	CALL	CCBB
1627	POP	AF
1628	RET
1629;
1630CCE6:	IN	A,(54H)
1631	CPL
1632	AND	' '
1633	JR	Z,CCDA
1634CCED:	POP	AF
1635	SET	7,A
1636	OUT	(54H),A
1637	RES	7,A
1638	OUT	(54H),A
1639	SET	7,A
1640	OUT	(54H),A
1641	RES	7,A
1642	RET
1643;
1644CCFD:	CALL	loctok
1645	CP	'O'
1646	JP	NZ,inper
1647	INC	DE
1648	LD	A,(DE)
1649	CP	'N'
1650	JR	Z,CD19
1651	CP	'F'
1652	JP	NZ,inper
1653	EXX
1654	RES	5,B
1655	EXX
1656	LD	A,0FFH
1657	OUT	(4),A
1658	RET
1659;
1660CD19:	EXX
1661	SET	5,B
1662	EXX
1663	LD	A,1
1664	LD	(72H),A
1665	RET
1666;
1667CD23:	EXX
1668	BIT	5,B
1669	EXX
1670	RET	Z
1671	PUSH	BC
1672	CALL	setsel
1673	POP	BC
1674	OUT	(34H),A
1675	CALL	CFD6
1676	XOR	0A0H
1677	OUT	(4),A
1678	RET
1679;
1680CD37:	LD	D,2
1681CD39:	PUSH	DE
1682	CALL	CD70
1683	POP	DE
1684	RET	NC
1685	PUSH	DE
1686	LD	A,0AH
1687	LD	(75H),A
1688	CALL	CDCB
1689	CALL	CD70
1690	POP	DE
1691	RET	NC
1692	DEC	D
1693	JR	NZ,CD39
1694	JR	CD6A
1695;
1696CD52:	LD	D,0AH
1697CD54:	PUSH	DE
1698	CALL	CE58
1699	POP	DE
1700	RET	NC
1701	DEC	D
1702	JR	NZ,CD54
1703	JR	CD6A
1704;
1705CD5F:	LD	D,4
1706CD61:	PUSH	DE
1707	CALL	CE9F
1708	POP	DE
1709	RET	NC
1710	DEC	D
1711	JR	NZ,CD61
1712CD6A:	LD	A,(71H)
1713	LD	C,A
1714	SCF
1715	RET
1716;
1717CD70:	SUB	A	; restore for
1718	LD	(75H),A	; seek tests
1719	LD	(78H),A
1720	CALL	CF55
1721	OUT	(34H),A
1722	CALL	CE25
1723	JR	C,CD8F
1724	OUT	(30H),A
1725CD83:	IN	A,(34H)
1726	BIT	2,A	; motor timeout
1727	JR	NZ,CDC4
1728	RRA		; EOJ?
1729	JR	NC,CD83	; no
1730	JP	CE3E	; yes
1731;
1732CD8F:	LD	A,0C4H	; read address
1733	OUT	(30H),A
1734	CALL	CFD6	; side select
1735	AND	'W'
1736	OUT	(4),A
1737	CALL	dela	; delay??
1738CD9D:	IN	A,(4)
1739	AND	'@'	; seek in progress?
1740	JR	NZ,CDB9
1741	CALL	CFCF
1742CDA6:	IN	A,(34H)
1743	BIT	2,A
1744	JR	NZ,CDC4
1745	RRA
1746	JR	NC,CDA6
1747	LD	A,0D0H	; force interrupt
1748	OUT	(30H),A
1749	SUB	A
1750	OUT	(31H),A	; track reg.
1751	JP	CE50
1752;
1753CDB9:	IN	A,(34H)
1754	BIT	2,A
1755	JR	NZ,CDC4
1756	RRA
1757	JR	NC,CD9D
1758	JR	CD8F
1759;
1760CDC4:	LD	A,80H
1761	LD	(71H),A
1762	SCF
1763	RET
1764;
1765CDCB:	SUB	A	; seek?
1766	CALL	CF55
1767	OUT	(34H),A
1768	LD	A,(75H)
1769	OUT	(33H),A
1770	LD	C,A
1771	LD	A,(76H)
1772	OUT	(32H),A
1773	LD	A,(7DH)
1774	OUT	(31H),A
1775	SUB	C
1776	JP	Z,CFCF
1777	CALL	CE25
1778	JR	C,CDF9
1779	OR	10H
1780	OUT	(30H),A
1781CDEE:	IN	A,(34H)
1782	BIT	2,A
1783	JR	NZ,CDC4
1784	RRA
1785	JR	NC,CDEE
1786	JR	CE3E
1787;
1788CDF9:	CALL	CFD6	;side???
1789	AND	'O'	;4fh?
1790	OUT	(4),A
1791	LD	A,18H	;FDC seek command
1792	OUT	(30H),A
1793CE04:	IN	A,(34H)
1794	BIT	2,A	;motor timeout?
1795	JR	NZ,CDC4
1796	RRA
1797	JR	NC,CE04
1798	IN	A,(30H)	;read disk status
1799	LD	L,'2'
1800CE11:	IN	A,(4)	;read aux disk status
1801	AND	40h	;seek in progress? PerSci only
1802	JR	NZ,CE11
1803	DEC	L
1804	JR	NZ,CE11
1805CE1A:	IN	A,(4)
1806	AND	40h
1807	JR	NZ,CE1A
1808	CALL	CFCF
1809	JR	CE50
1810;
1811CE25:	LD	A,(7EH)
1812	BIT	2,A
1813	JR	NZ,CE36
1814	BIT	3,A
1815	LD	A,0EH
1816	JR	Z,CE34
1817	LD	A,0CH
1818CE34:	AND	A
1819	RET
1820;
1821CE36:	BIT	3,A
1822	LD	A,0FH
1823	JR	Z,CE34
1824	SCF
1825	RET
1826;
1827CE3E:	CALL	CFCF
1828	LD	HL,64H
1829	CALL	dela1
1830	IN	A,(30H)
1831	LD	(71H),A
1832	AND	98H
1833	SCF
1834	RET	NZ
1835CE50:	LD	A,(75H)
1836	LD	(7DH),A
1837	AND	A
1838	RET
1839;
1840CE58:	CALL	CE8F	; READ
1841	OUT	(30H),A
1842CE5D:	IN	A,(34H)	; disk flags
1843	RRA
1844	JR	C,CE78	; finished
1845	INI
1846	INC	B
1847	IN	A,(34H)	; disk flags
1848	RRA
1849	JR	C,CE78	; finished
1850	INI
1851	JP	NZ,CE5D
1852CE6F:	IN	A,(34H)	; disk flags
1853	BIT	1,A
1854	JR	NZ,CE85	; autowait timed out
1855	RRA
1856	JR	NC,CE6F
1857CE78:	CALL	CFCF
1858	IN	A,(30H)	; disk status
1859	LD	(71H),A
1860	AND	9CH	; errors
1861	RET	Z
1862	JR	CE8D
1863;
1864CE85:	CALL	CFCF	; chg. side if (78)#0
1865	LD	A,80H
1866	LD	(71H),A
1867CE8D:	SCF
1868	RET
1869;
1870CE8F:	CALL	CF40
1871	LD	D,A
1872	DI
1873	CALL	CFC6
1874	ADD	A,88H
1875	LD	E,A
1876	LD	A,D
1877	OUT	(34H),A	; disk control
1878	LD	A,E
1879	RET
1880;
1881CE9F:	CALL	dela	; WRITE
1882	CALL	CF40
1883	LD	D,A
1884	DI
1885	CALL	CFC6
1886	ADD	A,0A8H
1887	LD	E,A
1888	LD	A,D
1889	OUT	(34H),A
1890	LD	A,E
1891	OUT	(30H),A
1892CEB3:	IN	A,(34H)
1893	RRA
1894	JR	C,CECA
1895	OUTI
1896	INC	B
1897	IN	A,(34H)
1898	RRA
1899	JR	C,CECA
1900	OUTI
1901	JP	NZ,CEB3
1902CEC5:	IN	A,(34H)
1903	RRA
1904	JR	NC,CEC5
1905CECA:	CALL	CFCF
1906	CALL	dela
1907	IN	A,(30H)
1908	LD	(71H),A
1909	AND	0FCH
1910	SCF
1911	RET	NZ
1912	AND	A
1913	LD	A,(7EH)
1914	BIT	1,A
1915	RET	Z
1916	CALL	CF00
1917	JR	C,CEEF
1918CEE5:	IN	A,(34H)
1919	RRA
1920	JR	C,CEEE
1921	IN	A,(33H)
1922	JR	CEE5
1923CEEE:	INC	E
1924CEEF:	CALL	CFCF
1925	IN	A,(30H)
1926	LD	(71H),A
1927	AND	9CH
1928	SCF
1929	RET	NZ
1930	LD	A,E
1931	AND	A
1932	RET	Z
1933	SCF
1934	RET
1935;
1936CF00:	CALL	CE8F
1937	LD	BC,(79H)
1938	SRL	B
1939	RR	C
1940	SRL	B
1941	RR	C
1942	LD	B,C
1943	LD	E,0
1944	OUT	(30H),A
1945CF14:	IN	A,(34H)
1946	RRA
1947	RET	C
1948	IN	A,(33H)
1949	XOR	(HL)
1950	RET	NZ
1951	INC	HL
1952	IN	A,(34H)
1953	RRA
1954	RET	C
1955	IN	A,(33H)
1956	XOR	(HL)
1957	RET	NZ
1958	INC	HL
1959	IN	A,(34H)
1960	RRA
1961	RET	C
1962	IN	A,(33H)
1963	XOR	(HL)
1964	RET	NZ
1965	INC	HL
1966	IN	A,(34H)
1967	RRA
1968	RET	C
1969	IN	A,(33H)
1970	XOR	(HL)
1971	RET	NZ
1972	INC	HL
1973	DJNZ	CF14
1974CF3A:	IN	A,(34H)
1975	RRA
1976	JR	NC,CF3A
1977	RET
1978;
1979CF40:	IN	A,(33H)
1980	LD	A,80H
1981	CALL	CF55
1982	LD	HL,(79H)
1983	RR	H
1984	RR	L
1985	LD	B,L
1986	LD	C,'3'
1987	LD	HL,(7BH)
1988	RET
1989;
1990CF55:	LD	C,A
1991	IN	A,(34H)
1992	AND	4	; motor timeout
1993	JR	Z,CF60	; motor on
1994	SUB	A	; motor off
1995	LD	(72H),A
1996CF60:	CALL	setsel
1997	OUT	(34H),A
1998	PUSH	AF
1999	PUSH	HL
2000	CALL	CFD6
2001	AND	5FH
2002	OUT	(4),A
2003	LD	A,(72H)
2004	AND	A
2005	JR	Z,CF95
2006	LD	HL,190H
2007	LD	A,(73H)
2008	CP	B
2009	JR	NZ,CF98
2010	LD	A,(74H)
2011	LD	H,A
2012	LD	A,(78H)
2013	LD	(74H),A
2014	CP	H
2015	JR	NZ,CF90
2016	IN	A,(34H)
2017	AND	' '
2018	JR	NZ,CF9B
2019CF90:	CALL	dela
2020	JR	CF9B
2021;
2022CF95:	LD	HL,4E20H
2023CF98:	CALL	dela1
2024CF9B:	POP	HL
2025	LD	A,B
2026	LD	(73H),A
2027	LD	A,1
2028	LD	(72H),A
2029	POP	AF
2030	OR	C
2031	RET
2032;
2033setsel:	LD	A,(77H)
2034	LD	B,A
2035	INC	B
2036	SUB	A
2037	SCF
2038rotlp:	RLA
2039	DJNZ	rotlp
2040	LD	B,A
2041	LD	A,(7EH)
2042	BIT	2,A
2043	JR	Z,notmx
2044	SET	4,B	;set 'maxi'
2045notmx:	BIT	0,A
2046	JR	Z,notdd
2047	SET	6,B	;set 'double density'
2048notdd:	LD	A,B
2049	OR	20H	;set 'motor on'
2050	RET
2051;
2052CFC6:	IN	A,(34H)
2053	CPL
2054	AND	' '
2055	RET	Z
2056	LD	A,4
2057	RET
2058;
2059CFCF:	CALL	CFD6
2060	OUT	(4),A	; aux. disk cmd.
2061	XOR	A
2062	RET
2063;
2064CFD6:	PUSH	BC
2065	LD	B,7FH	; no action
2066	LD	A,(78H)
2067	AND	A
2068	JR	Z,CFE1
2069	LD	B,7DH	; opposite side
2070CFE1:	LD	A,B
2071	POP	BC
2072	RET
2073;
2074dela:	LD	HL,8
2075	LD	A,(7EH)
2076	BIT	2,A
2077	JR	NZ,dela1
2078	LD	HL,0CH
2079dela1:	PUSH	BC
2080dela2:	DEC	HL
2081	LD	B,1CH
2082dela3:	DJNZ	dela3
2083	NOP
2084	NOP
2085	LD	A,L
2086	OR	H
2087	JR	NZ,dela2
2088	POP	BC
2089	RET
2090;
2091	DEFB	0FFH
2092	END
2093