2 ; KERMIT - (Celtic for "FREE")
4 ; This is the CP/M-80 implementation of the Columbia University
5 ; KERMIT file transfer protocol.
9 ; Copyright June 1981,1982,1983,1984,1985
12 ; Originally written by Bill Catchings of the Columbia University Center for
13 ; Computing Activities, 612 W. 115th St., New York, NY 10025.
15 ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
16 ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
19 ; This file contains the system-dependent code and data for various
20 ; Tandy Model 4 running under Montezuma Micro CPM
22 ; This has the Family name of CPXTM4.ASM.
24 ; revision history (last edit first)
26 ; edit 5, 8-Feb-1991 by Lance Tagliapietra of the University of Wisconsin-
27 ; Platteville. Corrected error in the VT52 translation table for
28 ; clearing from the cursor to the end of the line.
30 ; edit 4, 27 October, 1987 by OBSchou. Massaged into format suitable
31 ; for overlay version 4.09
33 ; Edit 3: Sept 5 1987 GDS Transformed code from Genie III to Tandy Model 4
35 ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out
36 ; a lot of unnecessary IF's
38 ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK.
41 .printx * Assembling for Tandy Model 4*
43 drtime EQU 05H ;Default receive time out interval.
57 defesc EQU 'X'-100O ;The default escape character.
60 ;Select initial setting for VT-52 emulation flag.
62 ; default to VT52-EMULATION ON.
76 ; Family is the string used in VERSION to say which of several
77 ; smaller overlay files are used. These are (will be) derived from
78 ; the huge CP4SYS.ASM file, in which case we will never get here.
79 ; Just a Dollar, but put a sting in for a family of machines.
81 family: db 'CPXTM4.ASM (5) 8-Feb-91$' ; Used for family versions....
85 ; System-dependent initialization
86 ; Called once at program start.
89 ;Set up 9600 bd, 8bit words, no parity 1stop bit
91 mvi a,0EEH ;Get byte for desired baud (9600 = CC) and
92 out baudpt ;and put it out of baud port
93 out lctrl ;latch control port with anything
94 lda pstore ;get parity etc and put it out of
96 ret ; return from system-dependent routine
109 ; system-dependent termination processing
110 ; If we've changed anything, this is our last chance to put it back.
114 ; system-dependent processing for start of CONNECT command
119 conmsg: ; Messages printed when entering transparent (CONNECT) mode:
120 ;-------------------------------------------------------------------------------
123 ; syscls - system-dependent close routine
124 ; called when exiting transparent session.
128 ;-------------------------------------------------------------------------------
131 ; sysinh - help for system-dependent special functions.
132 ; called in response to <escape>?, after listing all the
133 ; system-independent escape sequences.
136 lxi d,inhlps ; we got options...
137 call prtstr ; print them.
141 ;additional, system-dependent help for transparent mode
142 ; (two-character escape sequences)
145 db cr,lf,'B Transmit a BREAK'
147 db '$' ;[hh] table terminator
150 ; sysint - system dependent special functions
151 ; called when transparent escape character has been typed;
152 ; the second character of the sequence is in A (and in B).
154 ; non-skip: sequence has been processed
155 ; skip: sequence was not recognized
156 sysint: ani 137O ; convert lower case to upper, for testing...
157 cpi 'B' ; send break?
158 jz sendbr ; yes, go do it. return nonskip when through.
160 jmp rskp ; take skip return - command not recognized.
163 ;-------------------------------------------------------------------------------
166 ; Ensure that the transmitter has finished sending buffered chars
167 sndbr1: in mnprts ; get UART status
168 ani output ; everything sent?
169 jz sndbr1 ; no, wait a bit more
171 ; Begin sending a break by setting bit in UART command register
172 mvi a,brkval ; SBreak,
177 ; Wait for 250 milliseconds (using hundredths second delay routine)
181 ; Resume normal operation by clearing the SendBreak command bit
182 lda pstore ;get parity etc value
183 out lctrl ;latch control port
184 out mnprts ;and set values
200 ; sysflt - system-dependent filter
201 ; called with character in E.
202 ; if this character should not be printed, return with A = zero.
203 ; preserves bc, de, hl.
204 ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.
206 mov a,e ; get character for testing
209 ; mdmflt - modem filter [30]
210 ; called with character to be sent to modem in E
211 ; with parity set as appropriate.
212 ; return with accumulator = 0 do do nothing,
213 ; <> 0 to send char in E.
219 ; prtflt - printer filter [30]
220 ; called with character to be sent to printer in E
221 ; returns with a = 0 to do nothing
222 ; a <> 0 to print it.
224 ; this routine for those printer that automatically insert
225 ; a lf on cr, or cr for lf. Should this be shifted to
226 ; the system indep. stuff, in say 4.06?
228 mov a,e ; [30] get character to test
244 ; system-dependent processing for BYE command.
245 ; for apmmdm, heath, and lobo, hang up the phone.
259 ; This is the system-dependent command to change the baud rate.
260 ; DE contains the two-byte value from the baud rate table; this
261 ; value is also stored in 'speed'.
263 ;Set up baud rate 8bit words, no parity 1stop bit
265 mov a,e ;get get speed into a
266 out baudpt ;output it as well
267 lda pstore ;get parity etc
268 out lctrl ;do it resetting DLAB at same time
272 pstore: db 6CH ;Default value for parity word length and stop bits
274 spdtbl: db 10h ;17 entries
275 db 03h,'110$', 22H,22H
276 db 04h,'1200$', 77H,77H
277 db 05h,'134.5$', 33H,33H
278 db 03h,'150$', 44H,44H
279 db 04h,'1800$', 88H,88H
280 db 05h,'19200$', 0FFH,0FFH
281 db 04h,'2000$', 99H,99H
282 db 04h,'2400$', 0AAH,0AAH
283 db 03h,'300$', 55H,55H
284 db 04h,'3600$', 0BBH,0BBH
285 db 04h,'4800$', 0CCH,0CCH
286 db 02h,'50$', 00H,00H
287 db 03h,'600$', 66H,66H
288 db 04h,'7200$', 0DDH,0DDH
289 db 02h,'75$', 11H,11H
290 db 04h,'9600$', 0EEH,0EEH
292 sphtbl: db cr,lf,' 50 75 110 134.5 150 300 600 1200'
293 db cr,lf,' 1800 2000 2400 3600 4800 7200 9600 19200 $'
295 ; This is the system-dependent SET PORT command.
296 ; HL contains the argument from the command table.
300 prttbl equ 0 ; SET PORT not supported
314 ; selmdm - select modem port
315 ; selcon - select console port
316 ; selmdm is called before using inpmdm or outmdm;
317 ; selcon is called before using inpcon or outcon.
318 ; For iobyt systems, diddle the I/O byte to select console or comm port;
319 ; For Decision I, switches Multi I/O board to console or modem serial
321 ; For the rest, does nothing.
322 ; preserves bc, de, hl.
338 ; Get character from console, or return zero.
339 ; result is returned in A. destroys bc, de, hl.
342 mvi c,dconio ;Direct console I/O BDOS call.
348 ; Output character in E to the console.
349 ; destroys bc, de, hl
353 mvi c,dconio ;Console output bdos call.
354 call bdos ;Output the char to the console.
359 ; outmdm - output a char from E to the modem.
360 ; the parity bit has been set as necessary.
361 ; returns nonskip; bc, de, hl preserved.
364 in mnprts ;Get the output done flag.
365 ani output ;Is it set?
366 jz outmdm ;If not, loop until it is.
368 out mnport ;Output it.
371 ;--------------------------------------------------------------------------
373 ; get character from modem; return zero if none available.
374 ; for IOBYT systems, the modem port has already been selected.
375 ; destroys bc, de, hl.
377 ;Note: modem port should already be selected for mdI. [Toad Hall]
378 in mnprts ;Get the port status into A.
379 ani input ;See if the input ready bit is on.
380 rz ;If not then return.
381 in mnport ;If so, get the char.
382 ret ; return with character in A
386 ; flsmdm - flush comm line.
388 ; Currently, just gets characters until none are available.
390 flsmdm: call inpmdm ; Try to get a character
392 jnz flsmdm ; If so, try for another
393 ret ; Receiver is drained. Return.
394 ;-----------------------------------------------------------------------------
396 ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
398 xra a ; assume it is ok.. this may not be necessary
402 ; outlpt - output character in E to printer
403 ; console is selected.
406 push d ; save DE in either case
407 call prtflt ; go through printer filter [30]
408 ana a ; if A = 0 do nothing,
409 jz outlp1 ; [30] if a=0 do nothing
412 call bdos ;Char to printer
413 outlp1: pop d ; restore saved register pair
415 ;------------------------------------------------------------------------------
417 ; Screen manipulation routines
418 ; csrpos - move to row B, column C
420 ; csrpos for terminals that use a leadin sequence followed
421 ; by (row + 31.) and (column + 31.)
423 csrpos: push b ; save coordinates
424 lxi d,curldn ; get cursor leadin sequence
425 call prtstr ; print it
426 pop h ; restore coordinates
428 adi (' '-1) ; space is row one
431 call outcon ; output row
434 adi (' '-1) ; space is column one
436 jmp outcon ; output it and return
439 ; delchr - make delete look like a backspace. Unless delete is a printing
440 ; character, we just need to print a backspace. (we'll output clrspc
442 ; For Kaypro and Vector General, delete puts a blotch on the screen.
443 ; For Apple and Osborne 1, delete moves but doesn't print.
446 mvi e,bs ;get a backspace
449 ; erase the character at the current cursor position
452 mvi e,bs ;get a backspace
455 ; erase the current line
459 ; erase the whole screen, and go home. preserves b (but not c)
463 ;[2] I see no real saving in having all screens in separate file and
464 ;therefore have included screen definition here and commented out
465 ;the link to VDU file
468 ;Specific definitions for the Model IV screen
470 sysver: db 'Tandy Model IV$'
471 outlin: db 1aH,cr,lf,' $'
473 eralin: db cr,15H,'$'
476 ta: db 0BH,'$',0,0 ;Cursor up
477 tb: db 0AH,'$',0,0 ;Cursor down
478 tc: db 0CH,'$',0,0 ;Cursor right
479 td: db 08H,'$',0,0 ;Cursor left
480 te: db 1AH,'$',0,0 ;Clear display
481 tf: db 0FH,'$',0,0 ;Reverse on
482 tg: db 0EH,'$',0,0 ;Reverse off
483 th: db 1EH,'$',0,0 ;Cursor home
484 ti: db 0BH,'$',0,0 ;Reverse linefeed
485 tj: db 19H,'$',0,0 ;Clear to end of screen
486 tk: db 15H,'$',0,0 ;Clear to end of line
488 ovlend equ $ ;End of overlay