]>
Commit | Line | Data |
---|---|---|
e58a7a25 L |
1 | ;CPXTM4.ASM\r |
2 | ; KERMIT - (Celtic for "FREE")\r | |
3 | ;\r | |
4 | ; This is the CP/M-80 implementation of the Columbia University\r | |
5 | ; KERMIT file transfer protocol.\r | |
6 | ;\r | |
7 | ; Version 4.0\r | |
8 | ;\r | |
9 | ; Copyright June 1981,1982,1983,1984,1985\r | |
10 | ; Columbia University\r | |
11 | ;\r | |
12 | ; Originally written by Bill Catchings of the Columbia University Center for\r | |
13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025.\r | |
14 | ;\r | |
15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,\r | |
16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many\r | |
17 | ; others.\r | |
18 | ;\r | |
19 | ; This file contains the system-dependent code and data for various\r | |
20 | ; Tandy Model 4 running under Montezuma Micro CPM\r | |
21 | ;\r | |
22 | ; This has the Family name of CPXTM4.ASM.\r | |
23 | ;\r | |
24 | ; revision history (last edit first)\r | |
25 | ;\r | |
26 | ; edit 5, 8-Feb-1991 by Lance Tagliapietra of the University of Wisconsin-\r | |
27 | ; Platteville. Corrected error in the VT52 translation table for\r | |
28 | ; clearing from the cursor to the end of the line.\r | |
29 | ;\r | |
30 | ; edit 4, 27 October, 1987 by OBSchou. Massaged into format suitable\r | |
31 | ; for overlay version 4.09\r | |
32 | ;\r | |
33 | ; Edit 3: Sept 5 1987 GDS Transformed code from Genie III to Tandy Model 4\r | |
34 | ;\r | |
35 | ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out\r | |
36 | ; a lot of unnecessary IF's\r | |
37 | ;\r | |
38 | ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK.\r | |
39 | \r | |
40 | \r | |
41 | .printx * Assembling for Tandy Model 4*\r | |
42 | ;\r | |
43 | drtime EQU 05H ;Default receive time out interval.\r | |
44 | ;\r | |
45 | ; the basics...\r | |
46 | ;\r | |
47 | mnport EQU 0EBH\r | |
48 | mnprts EQU 0EAH\r | |
49 | output EQU 40H\r | |
50 | input EQU 80H\r | |
51 | lctrl EQU 0E8H\r | |
52 | baudpt EQU 0E9H\r | |
53 | z80 EQU TRUE\r | |
54 | brkval EQU 0H\r | |
55 | inout EQU TRUE\r | |
56 | \r | |
57 | defesc EQU 'X'-100O ;The default escape character.\r | |
58 | \r | |
59 | \r | |
60 | ;Select initial setting for VT-52 emulation flag.\r | |
61 | \r | |
62 | ; default to VT52-EMULATION ON.\r | |
63 | ;\r | |
64 | vtval EQU 1\r | |
65 | ;\r | |
66 | ;\r | |
67 | \r | |
68 | \r | |
69 | \r | |
70 | \r | |
71 | \r | |
72 | \r | |
73 | \r | |
74 | \r | |
75 | \r | |
76 | ; Family is the string used in VERSION to say which of several\r | |
77 | ; smaller overlay files are used. These are (will be) derived from\r | |
78 | ; the huge CP4SYS.ASM file, in which case we will never get here.\r | |
79 | ; Just a Dollar, but put a sting in for a family of machines.\r | |
80 | ;\r | |
81 | family: db 'CPXTM4.ASM (5) 8-Feb-91$' ; Used for family versions....\r | |
82 | \r | |
83 | \r | |
84 | ;\r | |
85 | ; System-dependent initialization\r | |
86 | ; Called once at program start.\r | |
87 | sysxin:\r | |
88 | ;\r | |
89 | ;Set up 9600 bd, 8bit words, no parity 1stop bit\r | |
90 | \r | |
91 | mvi a,0EEH ;Get byte for desired baud (9600 = CC) and\r | |
92 | out baudpt ;and put it out of baud port\r | |
93 | out lctrl ;latch control port with anything\r | |
94 | lda pstore ;get parity etc and put it out of\r | |
95 | out mnprts ;port\r | |
96 | ret ; return from system-dependent routine\r | |
97 | \r | |
98 | ;\r | |
99 | \r | |
100 | \r | |
101 | \r | |
102 | \r | |
103 | \r | |
104 | \r | |
105 | \r | |
106 | \r | |
107 | \r | |
108 | ;\r | |
109 | ; system-dependent termination processing\r | |
110 | ; If we've changed anything, this is our last chance to put it back.\r | |
111 | sysexit:\r | |
112 | ret\r | |
113 | ;\r | |
114 | ; system-dependent processing for start of CONNECT command\r | |
115 | ;\r | |
116 | syscon:\r | |
117 | ret\r | |
118 | \r | |
119 | conmsg: ; Messages printed when entering transparent (CONNECT) mode:\r | |
120 | ;-------------------------------------------------------------------------------\r | |
121 | ; --\r | |
122 | ;\r | |
123 | ; syscls - system-dependent close routine\r | |
124 | ; called when exiting transparent session.\r | |
125 | ;\r | |
126 | syscls:\r | |
127 | ret\r | |
128 | ;-------------------------------------------------------------------------------\r | |
129 | ; ---\r | |
130 | ;\r | |
131 | ; sysinh - help for system-dependent special functions.\r | |
132 | ; called in response to <escape>?, after listing all the\r | |
133 | ; system-independent escape sequences.\r | |
134 | ;\r | |
135 | sysinh:\r | |
136 | lxi d,inhlps ; we got options...\r | |
137 | call prtstr ; print them.\r | |
138 | ret\r | |
139 | \r | |
140 | \r | |
141 | ;additional, system-dependent help for transparent mode\r | |
142 | ; (two-character escape sequences)\r | |
143 | inhlps:\r | |
144 | \r | |
145 | db cr,lf,'B Transmit a BREAK'\r | |
146 | \r | |
147 | db '$' ;[hh] table terminator\r | |
148 | \r | |
149 | ;\r | |
150 | ; sysint - system dependent special functions\r | |
151 | ; called when transparent escape character has been typed;\r | |
152 | ; the second character of the sequence is in A (and in B).\r | |
153 | ; returns:\r | |
154 | ; non-skip: sequence has been processed\r | |
155 | ; skip: sequence was not recognized\r | |
156 | sysint: ani 137O ; convert lower case to upper, for testing...\r | |
157 | cpi 'B' ; send break?\r | |
158 | jz sendbr ; yes, go do it. return nonskip when through.\r | |
159 | \r | |
160 | jmp rskp ; take skip return - command not recognized.\r | |
161 | \r | |
162 | \r | |
163 | ;-------------------------------------------------------------------------------\r | |
164 | sendbr:\r | |
165 | ;\r | |
166 | ; Ensure that the transmitter has finished sending buffered chars\r | |
167 | sndbr1: in mnprts ; get UART status\r | |
168 | ani output ; everything sent?\r | |
169 | jz sndbr1 ; no, wait a bit more\r | |
170 | ;\r | |
171 | ; Begin sending a break by setting bit in UART command register\r | |
172 | mvi a,brkval ; SBreak,\r | |
173 | out lctrl\r | |
174 | out mnprts\r | |
175 | ;\r | |
176 | \r | |
177 | ; Wait for 250 milliseconds (using hundredths second delay routine)\r | |
178 | mvi a,25\r | |
179 | call delay\r | |
180 | ;\r | |
181 | ; Resume normal operation by clearing the SendBreak command bit\r | |
182 | lda pstore ;get parity etc value\r | |
183 | out lctrl ;latch control port\r | |
184 | out mnprts ;and set values\r | |
185 | ;\r | |
186 | ret ;done\r | |
187 | \r | |
188 | ;\r | |
189 | ;\r | |
190 | \r | |
191 | \r | |
192 | \r | |
193 | \r | |
194 | \r | |
195 | \r | |
196 | \r | |
197 | \r | |
198 | \r | |
199 | ;\r | |
200 | ; sysflt - system-dependent filter\r | |
201 | ; called with character in E.\r | |
202 | ; if this character should not be printed, return with A = zero.\r | |
203 | ; preserves bc, de, hl.\r | |
204 | ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.\r | |
205 | sysflt:\r | |
206 | mov a,e ; get character for testing\r | |
207 | ret\r | |
208 | \r | |
209 | ; mdmflt - modem filter [30]\r | |
210 | ; called with character to be sent to modem in E\r | |
211 | ; with parity set as appropriate.\r | |
212 | ; return with accumulator = 0 do do nothing,\r | |
213 | ; <> 0 to send char in E.\r | |
214 | mdmflt: mov a,e\r | |
215 | ret\r | |
216 | \r | |
217 | \r | |
218 | \r | |
219 | ; prtflt - printer filter [30]\r | |
220 | ; called with character to be sent to printer in E\r | |
221 | ; returns with a = 0 to do nothing\r | |
222 | ; a <> 0 to print it.\r | |
223 | ;\r | |
224 | ; this routine for those printer that automatically insert\r | |
225 | ; a lf on cr, or cr for lf. Should this be shifted to\r | |
226 | ; the system indep. stuff, in say 4.06?\r | |
227 | prtflt:\r | |
228 | mov a,e ; [30] get character to test\r | |
229 | ret\r | |
230 | \r | |
231 | \r | |
232 | ;\r | |
233 | \r | |
234 | \r | |
235 | \r | |
236 | \r | |
237 | \r | |
238 | \r | |
239 | \r | |
240 | \r | |
241 | \r | |
242 | \r | |
243 | ;\r | |
244 | ; system-dependent processing for BYE command.\r | |
245 | ; for apmmdm, heath, and lobo, hang up the phone.\r | |
246 | sysbye:\r | |
247 | ret\r | |
248 | ;\r | |
249 | \r | |
250 | \r | |
251 | \r | |
252 | \r | |
253 | \r | |
254 | \r | |
255 | \r | |
256 | \r | |
257 | \r | |
258 | \r | |
259 | ; This is the system-dependent command to change the baud rate.\r | |
260 | ; DE contains the two-byte value from the baud rate table; this\r | |
261 | ; value is also stored in 'speed'.\r | |
262 | sysspd:\r | |
263 | ;Set up baud rate 8bit words, no parity 1stop bit\r | |
264 | \r | |
265 | mov a,e ;get get speed into a\r | |
266 | out baudpt ;output it as well\r | |
267 | lda pstore ;get parity etc\r | |
268 | out lctrl ;do it resetting DLAB at same time\r | |
269 | out mnprts\r | |
270 | ret\r | |
271 | \r | |
272 | pstore: db 6CH ;Default value for parity word length and stop bits\r | |
273 | \r | |
274 | spdtbl: db 10h ;17 entries\r | |
275 | db 03h,'110$', 22H,22H\r | |
276 | db 04h,'1200$', 77H,77H\r | |
277 | db 05h,'134.5$', 33H,33H\r | |
278 | db 03h,'150$', 44H,44H\r | |
279 | db 04h,'1800$', 88H,88H\r | |
280 | db 05h,'19200$', 0FFH,0FFH\r | |
281 | db 04h,'2000$', 99H,99H\r | |
282 | db 04h,'2400$', 0AAH,0AAH\r | |
283 | db 03h,'300$', 55H,55H\r | |
284 | db 04h,'3600$', 0BBH,0BBH\r | |
285 | db 04h,'4800$', 0CCH,0CCH\r | |
286 | db 02h,'50$', 00H,00H\r | |
287 | db 03h,'600$', 66H,66H\r | |
288 | db 04h,'7200$', 0DDH,0DDH\r | |
289 | db 02h,'75$', 11H,11H\r | |
290 | db 04h,'9600$', 0EEH,0EEH\r | |
291 | \r | |
292 | sphtbl: db cr,lf,' 50 75 110 134.5 150 300 600 1200'\r | |
293 | db cr,lf,' 1800 2000 2400 3600 4800 7200 9600 19200 $'\r | |
294 | \r | |
295 | ; This is the system-dependent SET PORT command.\r | |
296 | ; HL contains the argument from the command table.\r | |
297 | sysprt:\r | |
298 | ret\r | |
299 | ;\r | |
300 | prttbl equ 0 ; SET PORT not supported\r | |
301 | prhtbl equ 0\r | |
302 | \r | |
303 | ;\r | |
304 | \r | |
305 | \r | |
306 | \r | |
307 | \r | |
308 | \r | |
309 | \r | |
310 | \r | |
311 | \r | |
312 | \r | |
313 | ;\r | |
314 | ; selmdm - select modem port\r | |
315 | ; selcon - select console port\r | |
316 | ; selmdm is called before using inpmdm or outmdm;\r | |
317 | ; selcon is called before using inpcon or outcon.\r | |
318 | ; For iobyt systems, diddle the I/O byte to select console or comm port;\r | |
319 | ; For Decision I, switches Multi I/O board to console or modem serial\r | |
320 | ; port. [Toad Hall]\r | |
321 | ; For the rest, does nothing.\r | |
322 | ; preserves bc, de, hl.\r | |
323 | selmdm:\r | |
324 | ret\r | |
325 | \r | |
326 | selcon:\r | |
327 | ret\r | |
328 | ;\r | |
329 | \r | |
330 | \r | |
331 | \r | |
332 | \r | |
333 | \r | |
334 | \r | |
335 | \r | |
336 | \r | |
337 | \r | |
338 | ; Get character from console, or return zero.\r | |
339 | ; result is returned in A. destroys bc, de, hl.\r | |
340 | ;\r | |
341 | inpcon:\r | |
342 | mvi c,dconio ;Direct console I/O BDOS call.\r | |
343 | mvi e,0FFH ;Input.\r | |
344 | call BDOS\r | |
345 | \r | |
346 | ret\r | |
347 | ;\r | |
348 | ; Output character in E to the console.\r | |
349 | ; destroys bc, de, hl\r | |
350 | ;\r | |
351 | outcon:\r | |
352 | \r | |
353 | mvi c,dconio ;Console output bdos call.\r | |
354 | call bdos ;Output the char to the console.\r | |
355 | \r | |
356 | ret\r | |
357 | ;\r | |
358 | ;\r | |
359 | ; outmdm - output a char from E to the modem.\r | |
360 | ; the parity bit has been set as necessary.\r | |
361 | ; returns nonskip; bc, de, hl preserved.\r | |
362 | outmdm:\r | |
363 | \r | |
364 | in mnprts ;Get the output done flag.\r | |
365 | ani output ;Is it set?\r | |
366 | jz outmdm ;If not, loop until it is.\r | |
367 | mov a,e\r | |
368 | out mnport ;Output it.\r | |
369 | ret\r | |
370 | \r | |
371 | ;--------------------------------------------------------------------------\r | |
372 | ;\r | |
373 | ; get character from modem; return zero if none available.\r | |
374 | ; for IOBYT systems, the modem port has already been selected.\r | |
375 | ; destroys bc, de, hl.\r | |
376 | inpmdm:\r | |
377 | ;Note: modem port should already be selected for mdI. [Toad Hall]\r | |
378 | in mnprts ;Get the port status into A.\r | |
379 | ani input ;See if the input ready bit is on.\r | |
380 | rz ;If not then return.\r | |
381 | in mnport ;If so, get the char.\r | |
382 | ret ; return with character in A\r | |
383 | \r | |
384 | \r | |
385 | ;\r | |
386 | ; flsmdm - flush comm line.\r | |
387 | ; Modem is selected.\r | |
388 | ; Currently, just gets characters until none are available.\r | |
389 | \r | |
390 | flsmdm: call inpmdm ; Try to get a character\r | |
391 | ora a ; Got one?\r | |
392 | jnz flsmdm ; If so, try for another\r | |
393 | ret ; Receiver is drained. Return.\r | |
394 | ;-----------------------------------------------------------------------------\r | |
395 | ;\r | |
396 | ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.\r | |
397 | lptstat:\r | |
398 | xra a ; assume it is ok.. this may not be necessary\r | |
399 | ret\r | |
400 | \r | |
401 | ;\r | |
402 | ; outlpt - output character in E to printer\r | |
403 | ; console is selected.\r | |
404 | ; preserves de.\r | |
405 | outlpt:\r | |
406 | push d ; save DE in either case\r | |
407 | call prtflt ; go through printer filter [30]\r | |
408 | ana a ; if A = 0 do nothing,\r | |
409 | jz outlp1 ; [30] if a=0 do nothing\r | |
410 | \r | |
411 | mvi c,lstout\r | |
412 | call bdos ;Char to printer\r | |
413 | outlp1: pop d ; restore saved register pair\r | |
414 | ret\r | |
415 | ;------------------------------------------------------------------------------\r | |
416 | ;\r | |
417 | ; Screen manipulation routines\r | |
418 | ; csrpos - move to row B, column C\r | |
419 | ;\r | |
420 | ; csrpos for terminals that use a leadin sequence followed\r | |
421 | ; by (row + 31.) and (column + 31.)\r | |
422 | ;\r | |
423 | csrpos: push b ; save coordinates\r | |
424 | lxi d,curldn ; get cursor leadin sequence\r | |
425 | call prtstr ; print it\r | |
426 | pop h ; restore coordinates\r | |
427 | mov a,h ; get row\r | |
428 | adi (' '-1) ; space is row one\r | |
429 | mov e,a\r | |
430 | push h\r | |
431 | call outcon ; output row\r | |
432 | pop h\r | |
433 | mov a,l ; get column\r | |
434 | adi (' '-1) ; space is column one\r | |
435 | mov e,a\r | |
436 | jmp outcon ; output it and return\r | |
437 | \r | |
438 | ;\r | |
439 | ; delchr - make delete look like a backspace. Unless delete is a printing\r | |
440 | ; character, we just need to print a backspace. (we'll output clrspc\r | |
441 | ; afterwards)\r | |
442 | ; For Kaypro and Vector General, delete puts a blotch on the screen.\r | |
443 | ; For Apple and Osborne 1, delete moves but doesn't print.\r | |
444 | delchr:\r | |
445 | \r | |
446 | mvi e,bs ;get a backspace\r | |
447 | jmp outcon\r | |
448 | \r | |
449 | ; erase the character at the current cursor position\r | |
450 | clrspc: mvi e,' '\r | |
451 | call outcon\r | |
452 | mvi e,bs ;get a backspace\r | |
453 | jmp outcon\r | |
454 | \r | |
455 | ; erase the current line\r | |
456 | clrlin: lxi d,eralin\r | |
457 | jmp prtstr\r | |
458 | \r | |
459 | ; erase the whole screen, and go home. preserves b (but not c)\r | |
460 | clrtop: lxi d,erascr\r | |
461 | jmp prtstr\r | |
462 | \r | |
463 | ;[2] I see no real saving in having all screens in separate file and\r | |
464 | ;therefore have included screen definition here and commented out\r | |
465 | ;the link to VDU file\r | |
466 | ;\r | |
467 | ;\r | |
468 | ;Specific definitions for the Model IV screen\r | |
469 | ;\r | |
470 | sysver: db 'Tandy Model IV$'\r | |
471 | outlin: db 1aH,cr,lf,' $'\r | |
472 | erascr: db 1AH,'$'\r | |
473 | eralin: db cr,15H,'$'\r | |
474 | curldn: db esc,'=$'\r | |
475 | ttab:\r | |
476 | ta: db 0BH,'$',0,0 ;Cursor up\r | |
477 | tb: db 0AH,'$',0,0 ;Cursor down\r | |
478 | tc: db 0CH,'$',0,0 ;Cursor right\r | |
479 | td: db 08H,'$',0,0 ;Cursor left\r | |
480 | te: db 1AH,'$',0,0 ;Clear display\r | |
481 | tf: db 0FH,'$',0,0 ;Reverse on\r | |
482 | tg: db 0EH,'$',0,0 ;Reverse off\r | |
483 | th: db 1EH,'$',0,0 ;Cursor home\r | |
484 | ti: db 0BH,'$',0,0 ;Reverse linefeed\r | |
485 | tj: db 19H,'$',0,0 ;Clear to end of screen\r | |
486 | tk: db 15H,'$',0,0 ;Clear to end of line\r | |
487 | \r | |
488 | ovlend equ $ ;End of overlay\r | |
489 | \r | |
490 | END\r |