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
22 ; This has the Family name of CPXGNI.ASM.
24 ; revision history (last edit first)
25 ; edit 3: 27 October, a987 by OBSchou. Massaged file to suit V4.09 structure.
27 ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out
28 ; a lot of unnecessary IF's
30 ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK.
32 .printx * Assembling for Eaca Genie 3 *
34 drtime EQU 05H ;Default receive time out interval.
48 defesc EQU ']'-100O ;The default escape character.
51 ;Select initial setting for VT-52 emulation flag.
53 ; default to VT52-EMULATION ON.
59 ; Family is the string used in VERSION to say which of several
60 ; smaller overlay files are used. These are (will be) derived from
61 ; the huge CP4SYS.ASM file, in which case we will never get here.
62 ; Just a Dollar, but put a sting in for a family of machines.
64 family:db 'CPXGNI.ASM (3) 27-Oct-87$' ; Used for family versions....
69 ; System-dependent initialization
70 ; Called once at program start.
73 ;Set up 9600 bd, 8bit words, no parity 1stop bit
75 mvi a,83H ;enable DLAB by setting bit 7
76 out lctrl ;and outputting to control port
77 mvi a,14H ;get word = 20 decimal
78 out divlsb ;and put it out
79 mvi a,00H ;as two separate
81 lda pstore ;get parity etc
82 out lctrl ;do it resetting DLAB at same time
84 ret ; return from system-dependent routine
88 ; system-dependent termination processing
89 ; If we've changed anything, this is our last chance to put it back.
95 ; system-dependent processing for start of CONNECT command
100 conmsg: ; Messages printed when entering transparent (CONNECT) mode:
105 ; syscls - system-dependent close routine
106 ; called when exiting transparent session.
114 ; sysinh - help for system-dependent special functions.
115 ; called in response to <escape>?, after listing all the
116 ; system-independent escape sequences.
119 lxi d,inhlps ; we got options...
120 call prtstr ; print them.
124 ;additional, system-dependent help for transparent mode
125 ; (two-character escape sequences)
128 db cr,lf,'B Transmit a BREAK'
130 db '$' ;[hh] table terminator
133 ; sysint - system dependent special functions
134 ; called when transparent escape character has been typed;
135 ; the second character of the sequence is in A (and in B).
137 ; non-skip: sequence has been processed
138 ; skip: sequence was not recognized
139 sysint: ani 137O ; convert lower case to upper, for testing...
140 cpi 'B' ; send break?
141 jz sendbr ; yes, go do it. return nonskip when through.
143 jmp rskp ; take skip return - command not recognized.
146 ;-------------------------------------------------------------------------------
149 ; Ensure that the transmitter has finished sending buffered chars
150 sndbr1: in mnprts ; get UART status
151 ani output ; everything sent?
152 jz sndbr1 ; no, wait a bit more
154 ; Begin sending a break by setting bit in UART command register
155 mvi a,brkval ; SBreak,
158 ; Wait for 250 milliseconds (using hundredths second delay routine)
162 ; Resume normal operation by clearing the SendBreak command bit
163 lda pstore ;and restoring value from parity store
172 ; sysflt - system-dependent filter
173 ; called with character in E.
174 ; if this character should not be printed, return with A = zero.
175 ; preserves bc, de, hl.
176 ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.
178 mov a,e ; get character for testing
181 ; mdmflt - modem filter [30]
182 ; called with character to be sent to modem in E
183 ; with parity set as appropriate.
184 ; return with accumulator = 0 do do nothing,
185 ; <> 0 to send char in E.
186 mdmflt: mov a,e ; get character to a
191 ; prtflt - printer filter [30]
192 ; called with character to be sent to printer in E
193 ; returns with a = 0 to do nothing
194 ; a <> 0 to print it.
196 ; this routine for those printer that automatically insert
197 ; a lf on cr, or cr for lf. Should this be shifted to
198 ; the system indep. stuff, in say 4.06?
200 mov a,e ; [30] get character to test
208 ; system-dependent processing for BYE command.
209 ; for apmmdm, heath, and lobo, hang up the phone.
215 ; This is the system-dependent command to change the baud rate.
216 ; DE contains the two-byte value from the baud rate table; this
217 ; value is also stored in 'speed'.
220 ;Set up baud rate 8bit words, no parity 1stop bit
221 mvi a,83H ;enable DLAB by setting bit 7
222 out lctrl ;and outputting to control port
224 out divlsb ;and put it out
226 out divmsb ;output it as well
227 lda pstore ;get parity etc
228 out lctrl ;do it resetting DLAB at same time
231 pstore: db 03H ;Default value for parity word length and stop bits
233 spdtbl: db 11h ;17 entries
234 db 03h,'110$', 06H,0D1H
235 db 04h,'1200$', 00H,0A0H
236 db 05h,'134.5$', 05H,94H
237 db 03h,'150$', 05H,00H
238 db 04h,'1800$', 00H,6BH
239 db 05h,'19200$', 00H,0AH
240 db 04h,'2000$', 00H,60H
241 db 04h,'2400$', 00H,50H
242 db 03h,'300$', 02H,80H
243 db 04h,'3600$', 00H,35H
244 db 05h,'38400$', 00H,05H
245 db 04h,'4800$', 00H,28H
246 db 02h,'50$', 0FH,00H
247 db 03h,'600$', 01H,40H
248 db 04h,'7200$', 00H,1BH
249 db 02h,'75$', 0AH,00H
250 db 04h,'9600$', 00H,14H
252 sphtbl: db cr,lf,' 50 75 110 134.5 150 300 600 1200'
253 db cr,lf,' 1800 2000 2400 3600 4800 7200 9600 19200 38400$'
255 ; This is the system-dependent SET PORT command.
256 ; HL contains the argument from the command table.
261 prttbl equ 0 ; SET PORT not supported
267 ; selmdm - select modem port
268 ; selcon - select console port
269 ; selmdm is called before using inpmdm or outmdm;
270 ; selcon is called before using inpcon or outcon.
271 ; For iobyt systems, diddle the I/O byte to select console or comm port;
272 ; For Decision I, switches Multi I/O board to console or modem serial
274 ; For the rest, does nothing.
275 ; preserves bc, de, hl.
284 ; Get character from console, or return zero.
285 ; result is returned in A. destroys bc, de, hl.
288 mvi c,dconio ;Direct console I/O BDOS call.
294 ; Output character in E to the console.
295 ; destroys bc, de, hl
299 mvi c,dconio ;Console output bdos call.
300 call bdos ;Output the char to the console.
305 ; outmdm - output a char from E to the modem.
306 ; the parity bit has been set as necessary.
307 ; returns nonskip; bc, de, hl preserved.
310 in mnprts ;Get the output done flag.
311 ani output ;Is it set?
312 jz outmdm ;If not, loop until it is.
314 out mnport ;Output it.
317 ;--------------------------------------------------------------------------
319 ; get character from modem; return zero if none available.
320 ; for IOBYT systems, the modem port has already been selected.
321 ; destroys bc, de, hl.
323 ;Note: modem port should already be selected for mdI. [Toad Hall]
324 in mnprts ;Get the port status into A.
325 ani input ;See if the input ready bit is on.
326 rz ;If not then return.
327 in mnport ;If so, get the char.
328 ret ; return with character in A
332 ; flsmdm - flush comm line.
334 ; Currently, just gets characters until none are available.
336 flsmdm: call inpmdm ; Try to get a character
338 jnz flsmdm ; If so, try for another
339 ret ; Receiver is drained. Return.
340 ;-----------------------------------------------------------------------------
342 ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
344 xra a ; assume it is ok.. this may not be necessary
348 ; outlpt - output character in E to printer
349 ; console is selected.
352 push d ; save DE in either case
353 call prtflt ; go through printer filter [30]
354 ana a ; if A = 0 do nothing,
355 jz outlp1 ; [30] if a=0 do nothing
358 call bdos ;Char to printer
359 outlp1: pop d ; restore saved register pair
361 ;------------------------------------------------------------------------------
363 ; Screen manipulation routines
364 ; csrpos - move to row B, column C
366 ; csrpos for terminals that use a leadin sequence followed
367 ; by (row + 31.) and (column + 31.)
369 csrpos: push b ; save coordinates
370 lxi d,curldn ; get cursor leadin sequence
371 call prtstr ; print it
372 pop h ; restore coordinates
374 adi (' '-1) ; space is row one
377 call outcon ; output row
380 adi (' '-1) ; space is column one
382 jmp outcon ; output it and return
385 ; delchr - make delete look like a backspace. Unless delete is a printing
386 ; character, we just need to print a backspace. (we'll output clrspc
388 ; For Kaypro and Vector General, delete puts a blotch on the screen.
389 ; For Apple and Osborne 1, delete moves but doesn't print.
392 mvi e,bs ;get a backspace
395 ; erase the character at the current cursor position
398 mvi e,bs ;get a backspace
401 ; erase the current line
405 ; erase the whole screen, and go home. preserves b (but not c)
409 ;[2] I see no real saving in having all screens in separate file and
410 ;therefore have included screen definition here and commented out
411 ;the link to VDU file
413 ;Specific definitions for the Genie III screen
415 sysver: db 'Eaca Genie III$'
416 outlin: db 1aH,cr,lf,' $'
418 eralin: db cr,18H,'$'
421 ta: db 0BH,'$',0,0 ;Cursor up
422 tb: db 0AH,'$',0,0 ;Cursor down
423 tc: db 0CH,'$',0,0 ;Cursor right
424 td: db 08H,'$',0,0 ;Cursor left
425 te: db 1AH,'$',0,0 ;Clear display
426 tf: db esc,'R$',0 ;Reverse on
427 tg: db esc,'S$',0 ;Reverse off
428 th: db 1EH,'$',0,0 ;Cursor home
429 ti: db 0BH,'$',0,0 ;Reverse linefeed
430 tj: db 19H,'$',0,0 ;Clear to end of screen
431 tk: db 18H,'$',0,0 ;Clear to end of line
433 ovlend equ $ ;End of overlay