4 ; KERMIT - (Celtic for "FREE")
6 ; This is the CP/M-80 implementation of the Columbia University
7 ; KERMIT file transfer protocol.
11 ; Copyright June 1981,1982,1983,1984,1985
14 ; Originally written by Bill Catchings of the Columbia University Center for
15 ; Computing Activities, 612 W. 115th St., New York, NY 10025.
17 ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
18 ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
21 ; This file contains the system-dependent code and data for various
22 ; NorthStar KERMITs. This has the Family name of CPXNOR.ASM.
24 ; revision history (last edit first)
26 ;edit 4, 16-Jan-1991 by MF. Fixed a bug in OUTCON wherein the final RET
27 ; was missing (bug reported by David P. Arnot of Scottish
28 ; Agricultural College).
29 ;edit 3, 12-Oct-1990 by MF. Added a semicolon before the comment
30 ; beginning "Family is the string so we don't get errors
31 ; edit 2, 23 July, 1987 by OBSchou to massage file to suit CPXCOM.ASM.
33 ; edit 1: 1 June, 1986 by OBSchou, Loughborogh University, UK.
34 ; Hived off northstar and Comart system dependent modules from
35 ; CPXSYS.ASM. This assembles ok, but I cannot test it. Any comments?
39 .printx * Assembling for NorthStar Horizon with HSIO-4 board *
43 .printx * Assembling KERMIT-80 for the NorthStar Horizon *
47 .printx * Assembling kermit-80 for North Star Advantage *
51 .printx * Assembling KERMIT-80 for the Northstar Horizon using printer port *
55 .printx * Assembling KERMIT-80 for Comart Communicator *
59 IF norths ;The basic Northstar Horizon BIOS does not access ports 2-5
60 port0d equ 02h ;Port 0 data (console)
61 port0s equ 03h ;Port 0 status
62 port1d equ 04h ;Port 1 data (printer)
63 port1s equ 05h ;Port 1 status
65 port2b equ 10h ;Port 2 baud
66 port2i equ 11h ;Port 2 interrupt mask
67 port2d equ 12h ;Port 2 data
68 port2s equ 13h ;Port 2 status
70 port3b equ 14h ;Port 3 baud
71 port3i equ 15h ;Port 3 interrupt mask
72 port3d equ 16h ;Port 3 data
73 port3s equ 17h ;Port 3 status
75 port4b equ 18h ;Port 4 baud
76 port4i equ 19h ;Port 4 interrupt mask
77 port4d equ 1Ah ;Port 4 data
78 port4s equ 1Bh ;Port 4 status
80 port5b equ 1Ch ;Port 5 baud
81 port5i equ 1Dh ;Port 5 interrupt mask
82 port5d equ 1Eh ;Port 5 data
83 port5s equ 1Fh ;Port 5 status
85 NS19K2 EQU 00H ;19.2 kilobaud
86 NS9600 EQU 01H ;9600 baud
87 NS4800 EQU 02H ;4800 baud
88 NS2400 EQU 03H ;2400 baud
89 NS1200 EQU 04H ;1200 baud
90 NS0600 EQU 05H ; 600 baud
91 NS0300 EQU 06H ; 300 baud
92 NS0110 EQU 07H ; 110 baud
93 ;; Set to use port 5 at 1200 baud
94 mnport equ port5d ;Data port
95 mnprts equ port5s ;Status port
96 baudrt equ port5b ;Baud rate port
97 baudini equ ns1200 ;Initial baud rate
98 output EQU 1 ;Bit of UART status for transmitter ready
99 input EQU 2 ;Bit of UART status for receiver ready
100 z80 EQU TRUE ;This one's a Z80.
104 mnport equ 04h ;printer port data
105 mnprts equ 05h ; printer port status
106 output equ 1 ;transmitter ready
107 input equ 2 ;receiver ready
108 z80 equ FALSE ; not important
112 mnport EQU 004H ;Modem data port
113 mnprts EQU 005H ;Modem status port
114 output EQU 01H ;Transmitter empty
115 input EQU 02H ;Input data available
116 TxEmpty EQU 04h ;Transmitter empty
117 ;Note: Needs terminal definition (vt100, vt52, tvi925, adm3a or crt above)
118 z80 EQU TRUE ;This one's a Z80.
122 vtval EQU 1 ; we do emulation of VT52s
123 slot EQU 1 ;SIO card slot
124 mnport EQU (6-slot)*16 ;Modem data port
125 mnprts EQU mnport+1 ;Modem status port
126 baudrt EQU mnport+8 ;Baud rate register
127 output EQU 01H ;Transmitter buffer empty
128 input EQU 02H ;Input data available
129 TxEmpty EQU 04h ;Transmitter empty flag
134 mnport EQU 002H ;Modem data port
135 mnprts EQU 003H ;Modem status port
136 output EQU 01H ;Transmitter empty
137 input EQU 02H ;Input data available
138 TxEmpty EQU 04h ;Transmitter empty
139 ;Note: Needs terminal definition (vt100, vt52, tvi925, adm3a or crt above)
140 z80 EQU TRUE ;This one's a Z80.
149 ; Family is the string used in VERSION to say which of several
150 ; smaller overlay files are used. These are (will be) derived from
151 ; the juge CP4SYS.ASM file, in which case we will never get here.
152 ; Just a Dollar, but put a sting in for a family of machines.
154 family: db 'CPXNOR.ASM (4) 16-Jan-1991$' ; Used for family versions....
158 sysxin: ; continuation of system dependent initialisation code
161 out mnprts ; Reset USART
162 lxi h,7070h ; Default to 1200 baud
163 shld speed ; store current speed
165 call sysspd ; set default baud rate
166 mvi a,4Eh ; Set UART mode to async 16x clock, 8 data
167 out mnprts ; bits, no parity, and 1 stop bit
168 mvi a,37h ; Set command to Tx enable, DTR on, Rx enable,
169 out mnprts ; break off, error reset, and RTS on
173 mvi a,baudini ;Get initial speed
175 sta speed ;save for status display
179 IF comart OR horizon ;[25]
180 ; The PD8251/PD8251A is reset by three successive 00 Hex or two
181 ; successive 80 Hex command instructions followed by a software
182 ; reset command instruction (40 Hex).
183 mvi a,80h ; Send UART reset
189 mvi a,4Eh ; Set UART mode to async 16x clock, 8 data
190 out mnprts ; bits, no parity, and 1 stop bit
191 mvi a,37h ; Set command to Tx enable, DTR on, Rx enable,
192 out mnprts ; break off, error reset, and RTS on
193 ENDIF;comart OR horizon
196 ret ; return from system-dependent routine
200 ; system-dependent termination processing
201 ; If we've changed anything, this is our last chance to put it back.
207 ; system-dependent processing for start of CONNECT command
212 conmsg: ; Messages printed when entering transparent (CONNECT) mode:
216 ; syscls - system-dependent close routine
217 ; called when exiting transparent session.
224 ; sysinh - help for system-dependent special functions.
225 ; called in response to <escape>?, after listing all the
226 ; system-independent escape sequences.
229 IF advant OR comart OR horizon ; some more
230 lxi d,inhlps ; we got options...
231 call prtstr ; print them.
232 ENDIF;[22] advant OR comart OR horizon [29]
237 ;additional, system-dependent help for transparent mode
238 ; (two-character escape sequences)
241 ; [16] [18] have added super brain and Torch to the list of Breaking machines.
242 IF advant OR comart OR horizon ; ... some more
243 db cr,lf,'B Transmit a BREAK'
244 ENDIF;[22] advant OR comart OR horizon
246 db '$' ;[hh] table terminator
249 ; sysint - system dependent special functions
250 ; called when transparent escape character has been typed;
251 ; the second character of the sequence is in A (and in B).
253 ; non-skip: sequence has been processed
254 ; skip: sequence was not recognized
255 sysint: ani 137O ; convert lower case to upper, for testing...
256 IF advant OR comart OR horizon ; [22] [25] ... some more
257 cpi 'B' ; send break?
258 jz sendbr ; yes, go do it. return nonskip when through.
259 ENDIF;advant OR comart OR horizon [32]
261 jmp rskp ; take skip return - command not recognized.
266 IF advant OR comart OR horizon ;[lmj]
269 ; Ensure that the transmitter has finished sending buffered chars
270 sndbr1: in mnprts ; get UART status
271 ani TxEmpty ; everything sent?
272 jz sndbr1 ; no, wait a bit more
274 ; Begin sending a break by setting bit in UART command register
275 mvi a,3Fh ; Set TxEna, DTR, RxEna, SBreak, ErrRst, RTS
278 ; Wait for 250 milliseconds (using hundredths second delay routine)
282 ; Resume normal operation by clearing the SendBreak command bit
283 mvi a,37h ;Set TxEna, DTR, RxEna, ErrRst, RTS
287 ENDIF;advant OR comart OR horizon
292 ; sysflt - system-dependent filter
293 ; called with character in E.
294 ; if this character should not be printed, return with A = zero.
295 ; preserves bc, de, hl.
296 ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.
298 mov a,e ; get character for testing
300 cpi 'D'-100O ;Control-D's reset video
301 rnz ; if not control-D, it's ok.
302 xra a ; don't allow control-D out.
306 ; mdmflt - modem filter [30]
307 ; called with character to be sent to printer in E
308 ; with parity set as appropriate.
309 ; return with accumulator = 0 do do nothing,
310 ; <> 0 to send char in E.
312 mov a,e ;[30] get character to test
317 ; prtflt - printer filter [30]
318 ; called with character to be sent to printer in E
319 ; returns with a = 0 to do nothing
320 ; a <> 0 to print it.
322 ; this routine for those printer that automatically insert
323 ; a lf on cr, or cr for lf. Should this be shifted to
324 ; the system indep. stuff, in say 4.06?
326 mov a,e ; [30] get character to test
333 ; system-dependent processing for BYE command.
334 ; for apmmdm, heath, and lobo, hang up the phone.
339 ; This is the system-dependent command to change the baud rate.
340 ; DE contains the two-byte value from the baud rate table; this
341 ; value is also stored in 'speed'.
343 IF norths OR advant ;
344 mov a,e ; get the parsed value
345 out baudrt ; Tell the baud rate generator.
347 ENDIF;norths OR advant
350 spdtbl: db 6 ; 6 entries
351 db 04,'1200$', 70h,70h
352 db 04,'2400$', 78h,78h
353 db 03,'300$', 40h,40h
354 db 04,'4800$', 7Ch,7Ch
355 db 03,'600$', 60h,60h
356 db 04,'9600$', 7Eh,7Eh
358 sphtbl: db cr,lf,' 300 600 1200 2400 4800 9600$'
363 spdtbl: db 8 ; 8 entries
365 db 4,'1200$', 04H,04H
366 db 5,'19200$', 00H,00H
367 db 4,'2400$', 03H,03H
369 db 4,'4800$', 02H,02H
371 db 4,'9600$', 01H,01H
375 db ' 110 300 600 12000 2400 4800 9600 19200$'
378 ; The following conditionals were once a huge if not statement. There
379 ; wasn't enough room to add the lobo to the list, so it had to be broken
380 ; into 2, which you can't do with an if not. I redid it as two ifs and
381 ; applied them to those that wouldn't set baud. [Hal Hostetler]
382 IF NOT (advant OR norths)
383 spdtbl EQU 0 ;[hh] SET BAUD not supported.
384 sphtbl EQU 0 ;[hh] ran out of room above...
385 ENDIF ;NOT (advant OR norths)
389 ; This is the system-dependent SET PORT command.
390 ; HL contains the argument from the command table.
394 prttbl equ 0 ; SET PORT not supported
399 ; selmdm - select modem port
400 ; selcon - select console port
401 ; selmdm is called before using inpmdm or outmdm;
402 ; selcon is called before using inpcon or outcon.
403 ; For iobyt systems, diddle the I/O byte to select console or comm port;
404 ; For Decision I, switches Multi I/O board to console or modem serial
406 ; For the rest, does nothing.
407 ; preserves bc, de, hl.
413 ; Get character from console, or return zero.
414 ; result is returned in A. destroys bc, de, hl.
417 mvi c,dconio ;Direct console I/O BDOS call.
424 ; Output character in E to the console.
425 ; destroys bc, de, hl
428 mvi c,dconio ;Console output bdos call.
429 call bdos ;Output the char to the console.
430 ret ;[MF]per David P. Arnot
434 ; outmdm - output a char from E to the modem.
435 ; the parity bit has been set as necessary.
436 ; returns nonskip; bc, de, hl preserved.
438 in mnprts ;Get the output done flag.
439 ani output ;Is it set?
440 jz outmdm ;If not, loop until it is.
442 out mnport ;Output it.
447 ; get character from modem; return zero if none available.
448 ; for IOBYT systems, the modem port has already been selected.
449 ; destroys bc, de, hl.
451 ;Note: modem port should already be selected for mdI. [Toad Hall]
452 in mnprts ;Get the port status into A.
453 ani input ;See if the input ready bit is on.
454 rz ;If not then return.
455 in mnport ;If so, get the char.
456 ret ; return with character in A
460 ; flsmdm - flush comm line.
462 ; Currently, just gets characters until none are available.
464 flsmdm: call inpmdm ; Try to get a character
466 jnz flsmdm ; If so, try for another
467 ret ; Receiver is drained. Return.
471 ; lptstat - get the printer status. Return a=0ffh if ok, or 0 if not.
473 xra a ; assume it is ok.. this may not be necessary
477 ; outlpt - output character in E to printer
478 ; console is selected.
481 push d ; save DE in either case
482 call prtflt ; go through printer filter [30]
483 ana a ; if A = 0 do nothing,
484 jz outlp1 ; [30] if a=0 do nothing
486 call bdos ;Char to printer
487 outlp1: pop d ; restore saved register pair
489 IF advant ; all others require terminals
493 ; Screen manipulation routines
494 ; csrpos - move to row B, column C
496 ; csrpos for terminals that use a leadin sequence followed
497 ; by (row + 31.) and (column + 31.)
499 csrpos: push b ; save coordinates
500 lxi d,curldn ; get cursor leadin sequence
501 call prtstr ; print it
502 pop h ; restore coordinates
504 adi (' '-1) ; space is row one
507 call outcon ; output row
510 adi (' '-1) ; space is column one
512 jmp outcon ; output it and return
516 ; delchr - make delete look like a backspace. Unless delete is a printing
517 ; character, we just need to print a backspace. (we'll output clrspc
519 ; For Kaypro and Vector General, delete puts a blotch on the screen.
520 ; For Apple and Osborne 1, delete moves but doesn't print.
525 IF NOT (advant );[22]
526 mvi e,bs ;get a backspace
528 ENDIF;NOT (advant) [22]
530 ; erase the character at the current cursor position
533 mvi e,bs ;get a backspace
536 ; erase the current line
540 ; erase the whole screen, and go home. preserves b (but not c)
546 sysver: db 'Northstar Horizon$'
550 sysver: db 'Northstar using printer port$'
554 sysver: db 'Comart Communicator$'
558 sysver: db 'Northstar Horizon$'
562 sysver: db 'North Star Advantage$'
563 outlin: db 04H,cr,lf,tab,'$'
564 erascr: db 04H,'$' ;Clear screen and go home.
565 eralin: db cr,0EH,'$' ;Clear line.
566 curldn: db esc,'=$' ;cursor leadin
567 ttab: ;Table start location.
568 ta: db 0BH,'$',0,0 ;Cursor up.
569 tb: db 0AH,'$',0,0 ;Cursor down.
570 tc: db 0CH,'$',0,0 ;Cursor right.
571 td: db bs,'$',0,0 ;Cursor left
572 te: db 04H,'$',0,0 ;Clear display
573 tf: db 12H,'$',0,0 ;Enter Graphics Mode
574 tg: db 13H,'$',0,0 ;Exit Graphics mode
575 th: db 1EH,'$',0,0 ;Cursor home.
576 ti: db 0BH,'$',0,0 ;Reverse linefeed.
577 tj: db 0FH,'$',0,0 ;Clear to end of screen.
578 tk: db 0EH,'$',0,0 ;Clear to end of line.
580 IF lasm AND (NOT advant)
582 ENDIF ;lasm - m80 will INCLUDE CPXVDU.ASM
584 IF lasm ; here if not a terminal selected and in LASM