]>
Commit | Line | Data |
---|---|---|
1 | title 'Character I/O Module for the Modular CP/M 3 BIOS'\r | |
2 | page 255\r | |
3 | .z80\r | |
4 | \r | |
5 | \r | |
6 | \r | |
7 | public ?cinit,?ci,?co,?cist,?cost\r | |
8 | public @ctbl\r | |
9 | \r | |
10 | \r | |
11 | extrn ff.init,ff.ist,ff.in,ff.ost,ff.out\r | |
12 | extrn as0init,as0ista,as0inp,as0osta,as0out\r | |
13 | extrn as1init,as1ista,as1inp,as1osta,as1out\r | |
14 | \r | |
15 | \r | |
16 | include config.inc\r | |
17 | include z180reg.inc\r | |
18 | \r | |
19 | include modebaud.inc ; define mode bits and baud equates\r | |
20 | \r | |
21 | max$devices equ 3\r | |
22 | \r | |
23 | cseg\r | |
24 | \r | |
25 | ;--------------------------------------------------------------\r | |
26 | ; Init character device\r | |
27 | ; c: device\r | |
28 | \r | |
29 | ?cinit: ; init devices\r | |
30 | ld b,c\r | |
31 | call vector$io\r | |
32 | dw ff.init\r | |
33 | dw as0init\r | |
34 | dw as1init\r | |
35 | dw rret\r | |
36 | \r | |
37 | ;--------------------------------------------------------------\r | |
38 | ; Character input\r | |
39 | ; b: device\r | |
40 | ; return:\r | |
41 | ; a: input char\r | |
42 | \r | |
43 | ?ci: ; character input\r | |
44 | call vector$io\r | |
45 | dw ff.in\r | |
46 | dw as0inp\r | |
47 | dw as1inp\r | |
48 | dw null$input\r | |
49 | \r | |
50 | ;--------------------------------------------------------------\r | |
51 | ; Input status\r | |
52 | ; b: device\r | |
53 | ; return:\r | |
54 | ; a: 0ffh if char available, else 0\r | |
55 | \r | |
56 | ?cist: ; character input status\r | |
57 | call vector$io\r | |
58 | dw ff.ist\r | |
59 | dw as0ista\r | |
60 | dw as1ista\r | |
61 | dw null$status\r | |
62 | \r | |
63 | ;--------------------------------------------------------------\r | |
64 | ; Character output\r | |
65 | ; b: device\r | |
66 | ; c: output char\r | |
67 | ; return:\r | |
68 | ; a: output char\r | |
69 | \r | |
70 | ?co: ; character output\r | |
71 | call vector$io\r | |
72 | dw ff.out\r | |
73 | dw as0out\r | |
74 | dw as1out\r | |
75 | dw rret\r | |
76 | \r | |
77 | \r | |
78 | ;--------------------------------------------------------------\r | |
79 | ; Output status\r | |
80 | ; b: device\r | |
81 | ; return:\r | |
82 | ; a: 0ffh if device ready for next output char, else 0\r | |
83 | \r | |
84 | \r | |
85 | ?cost: ; character output status\r | |
86 | call vector$io\r | |
87 | dw ff.ost\r | |
88 | dw as0osta\r | |
89 | dw as1osta\r | |
90 | dw ret$true\r | |
91 | \r | |
92 | ;--------------------------------------------------------------\r | |
93 | \r | |
94 | vector$io:\r | |
95 | ld a,max$devices\r | |
96 | ld e,b\r | |
97 | vector:\r | |
98 | pop hl\r | |
99 | ld d,0\r | |
100 | cp e\r | |
101 | jr nc,exist\r | |
102 | ld e,a ; use null device if a >= max$devices\r | |
103 | exist: add hl,de\r | |
104 | add hl,de\r | |
105 | ld a,(hl)\r | |
106 | inc hl\r | |
107 | ld h,(hl)\r | |
108 | ld l,a\r | |
109 | jp (hl)\r | |
110 | \r | |
111 | \r | |
112 | null$input:\r | |
113 | ld a,1Ah\r | |
114 | rret:\r | |
115 | ret\r | |
116 | ret$true:\r | |
117 | or 0FFh\r | |
118 | ret\r | |
119 | \r | |
120 | null$status:\r | |
121 | xor a\r | |
122 | ret\r | |
123 | \r | |
124 | ;--------------------------------------------------------------\r | |
125 | \r | |
126 | @ctbl:\r | |
127 | db 'AVRCON' ; device 0\r | |
128 | db mb$in$out\r | |
129 | db baud$none\r | |
130 | \r | |
131 | db 'ASCI0 ' ; device 1\r | |
132 | db mb$in$out+mb$serial+mb$soft$baud\r | |
133 | ser0$baud:\r | |
134 | db baud$19200\r | |
135 | \r | |
136 | db 'ASCI1 ' ; device 2\r | |
137 | db mb$in$out+mb$serial+mb$soft$baud\r | |
138 | ser1$baud:\r | |
139 | db baud$19200\r | |
140 | \r | |
141 | db 0 ; table terminator\r | |
142 | \r | |
143 | ;--------------------------------------------------------------\r | |
144 | \r | |
145 | \r | |
146 | \r | |
147 | \r | |
148 | \r | |
149 | end\r |