home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / cpm80 / cpxtm4.asm < prev    next >
Assembly Source File  |  2020-01-01  |  14KB  |  491 lines

  1. ;CPXTM4.ASM
  2. ;       KERMIT - (Celtic for "FREE")
  3. ;
  4. ;       This is the CP/M-80 implementation of the Columbia University
  5. ;       KERMIT file transfer protocol.
  6. ;
  7. ;       Version 4.0
  8. ;
  9. ;       Copyright June 1981,1982,1983,1984,1985
  10. ;       Columbia University
  11. ;
  12. ; Originally written by Bill Catchings of the Columbia University Center for
  13. ; Computing Activities, 612 W. 115th St., New York, NY 10025.
  14. ;
  15. ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
  16. ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
  17. ; others.
  18. ;
  19. ;       This file contains the system-dependent code and data for various
  20. ;       Tandy Model 4 running under Montezuma Micro CPM
  21. ;
  22. ; This has the Family name of CPXTM4.ASM.
  23. ;
  24. ; revision history (last edit first)
  25. ;
  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.
  29. ;
  30. ; edit 4, 27 October, 1987 by OBSchou.  Massaged into format suitable
  31. ;       for overlay version 4.09
  32. ;
  33. ; Edit 3: Sept 5 1987 GDS Transformed code from Genie III to Tandy Model 4
  34. ;
  35. ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out
  36. ;         a lot of unnecessary IF's
  37. ;
  38. ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK.
  39.  
  40.  
  41. .printx * Assembling for Tandy Model 4*
  42. ;
  43. drtime  EQU     05H     ;Default receive time out interval.
  44. ;
  45. ; the basics...
  46. ;
  47. mnport EQU 0EBH
  48. mnprts EQU 0EAH
  49. output EQU 40H
  50. input  EQU 80H
  51. lctrl  EQU 0E8H
  52. baudpt EQU 0E9H
  53. z80    EQU TRUE
  54. brkval EQU 0H
  55. inout  EQU TRUE
  56.  
  57. defesc EQU 'X'-100O ;The default escape character.
  58.  
  59.  
  60. ;Select initial setting for VT-52 emulation flag.
  61.  
  62. ; default to VT52-EMULATION ON.
  63. ;
  64. vtval   EQU     1
  65. ;
  66. ;
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  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.
  80. ;
  81. family: db      'CPXTM4.ASM  (5) 8-Feb-91$'     ; Used for family versions....
  82.  
  83.  
  84. ;
  85. ;       System-dependent initialization
  86. ;       Called once at program start.
  87. sysxin:
  88. ;
  89.                         ;Set up 9600 bd, 8bit words, no parity 1stop bit
  90.  
  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
  95.         out     mnprts          ;port
  96.         ret                     ; return from system-dependent routine
  97.  
  98. ;
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108. ;
  109. ;       system-dependent termination processing
  110. ;       If we've changed anything, this is our last chance to put it back.
  111. sysexit:
  112.         ret
  113. ;
  114. ;       system-dependent processing for start of CONNECT command
  115. ;
  116. syscon:
  117.         ret
  118.  
  119. conmsg:         ; Messages printed when entering transparent (CONNECT) mode:
  120. ;-------------------------------------------------------------------------------
  121. ;   --
  122. ;
  123. ;       syscls - system-dependent close routine
  124. ;       called when exiting transparent session.
  125. ;
  126. syscls:
  127.        ret
  128. ;-------------------------------------------------------------------------------
  129. ;   ---
  130. ;
  131. ;       sysinh - help for system-dependent special functions.
  132. ;       called in response to <escape>?, after listing all the
  133. ;       system-independent escape sequences.
  134. ;
  135. sysinh:
  136.         lxi     d,inhlps        ; we got options...
  137.         call    prtstr          ; print them.
  138.         ret
  139.  
  140.  
  141. ;additional, system-dependent help for transparent mode
  142. ; (two-character escape sequences)
  143. inhlps:
  144.  
  145.         db      cr,lf,'B  Transmit a BREAK'
  146.  
  147.         db      '$'                     ;[hh] table terminator
  148.  
  149. ;
  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).
  153. ;       returns:
  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.
  159.  
  160.         jmp     rskp            ; take skip return - command not recognized.
  161.  
  162.  
  163. ;-------------------------------------------------------------------------------
  164. sendbr:
  165. ;
  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
  170. ;
  171. ;       Begin sending a break by setting bit in UART command register
  172.         mvi     a,brkval           ;  SBreak,
  173.         out     lctrl
  174.         out     mnprts
  175. ;
  176.  
  177. ;       Wait for 250 milliseconds (using hundredths second delay routine)
  178.         mvi     a,25
  179.         call    delay
  180. ;
  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
  185. ;
  186.         ret                     ;done
  187.  
  188. ;
  189. ;
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. ;
  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.
  205. sysflt:
  206.         mov     a,e             ; get character for testing
  207.         ret
  208.  
  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.
  214. mdmflt: mov     a,e
  215.         ret
  216.  
  217.  
  218.  
  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.
  223. ;
  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?
  227. prtflt:
  228.         mov     a,e             ; [30] get character to test
  229.         ret
  230.  
  231.  
  232. ;
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. ;
  244. ; system-dependent processing for BYE command.
  245. ;  for apmmdm, heath, and lobo, hang up the phone.
  246. sysbye:
  247.         ret
  248. ;
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  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'.
  262. sysspd:
  263.                         ;Set up baud rate 8bit words, no parity 1stop bit
  264.  
  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
  269.         out     mnprts
  270.         ret
  271.  
  272. pstore:     db 6CH  ;Default value for parity word length and stop bits
  273.  
  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
  291.  
  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  $'
  294.  
  295. ;       This is the system-dependent SET PORT command.
  296. ;       HL contains the argument from the command table.
  297. sysprt:
  298.         ret
  299. ;
  300. prttbl  equ     0               ; SET PORT not supported
  301. prhtbl  equ     0
  302.  
  303. ;
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313. ;
  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
  320. ;       port.  [Toad Hall]
  321. ;       For the rest, does nothing.
  322. ;       preserves bc, de, hl.
  323. selmdm:
  324.         ret
  325.  
  326. selcon:
  327.         ret
  328. ;
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338. ;       Get character from console, or return zero.
  339. ;       result is returned in A.  destroys bc, de, hl.
  340. ;
  341. inpcon:
  342.         mvi     c,dconio        ;Direct console I/O BDOS call.
  343.         mvi     e,0FFH          ;Input.
  344.         call    BDOS
  345.  
  346.         ret
  347. ;
  348. ;       Output character in E to the console.
  349. ;       destroys bc, de, hl
  350. ;
  351. outcon:
  352.  
  353.         mvi     c,dconio        ;Console output bdos call.
  354.         call    bdos            ;Output the char to the console.
  355.  
  356.         ret
  357. ;
  358. ;
  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.
  362. outmdm:
  363.  
  364.         in      mnprts          ;Get the output done flag.
  365.         ani     output          ;Is it set?
  366.         jz      outmdm          ;If not, loop until it is.
  367.         mov     a,e
  368.         out     mnport          ;Output it.
  369.         ret
  370.  
  371. ;--------------------------------------------------------------------------
  372. ;
  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.
  376. inpmdm:
  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
  383.  
  384.  
  385. ;
  386. ;       flsmdm - flush comm line.
  387. ;       Modem is selected.
  388. ;       Currently, just gets characters until none are available.
  389.  
  390. flsmdm: call    inpmdm          ; Try to get a character
  391.         ora     a               ; Got one?
  392.         jnz     flsmdm          ; If so, try for another
  393.         ret                     ; Receiver is drained.  Return.
  394. ;-----------------------------------------------------------------------------
  395. ;
  396. ;       lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
  397. lptstat:
  398.         xra     a               ; assume it is ok.. this may not be necessary
  399.         ret
  400.  
  401. ;
  402. ;       outlpt - output character in E to printer
  403. ;       console is selected.
  404. ;       preserves de.
  405. outlpt:
  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
  410.  
  411.         mvi     c,lstout
  412.         call    bdos            ;Char to printer
  413. outlp1: pop     d               ; restore saved register pair
  414.         ret
  415. ;------------------------------------------------------------------------------
  416. ;
  417. ;       Screen manipulation routines
  418. ;       csrpos - move to row B, column C
  419. ;
  420. ;       csrpos for terminals that use a leadin sequence followed
  421. ;        by (row + 31.) and (column + 31.)
  422. ;
  423. csrpos: push    b               ; save coordinates
  424.         lxi     d,curldn        ; get cursor leadin sequence
  425.         call    prtstr          ; print it
  426.         pop     h               ; restore coordinates
  427.         mov     a,h             ; get row
  428.         adi     (' '-1)         ; space is row one
  429.         mov     e,a
  430.         push    h
  431.         call    outcon          ; output row
  432.         pop     h
  433.         mov     a,l             ; get column
  434.         adi     (' '-1)         ; space is column one
  435.         mov     e,a
  436.         jmp     outcon          ; output it and return
  437.  
  438. ;
  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
  441. ;       afterwards)
  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.
  444. delchr:
  445.  
  446.         mvi     e,bs            ;get a backspace
  447.         jmp     outcon
  448.  
  449. ; erase the character at the current cursor position
  450. clrspc: mvi     e,' '
  451.         call    outcon
  452.         mvi     e,bs            ;get a backspace
  453.         jmp     outcon
  454.  
  455. ; erase the current line
  456. clrlin: lxi     d,eralin
  457.         jmp     prtstr
  458.  
  459. ; erase the whole screen, and go home. preserves b (but not c)
  460. clrtop: lxi     d,erascr
  461.         jmp     prtstr
  462.  
  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
  466. ;
  467. ;
  468. ;Specific definitions for the Model IV screen
  469. ;
  470. sysver: db 'Tandy Model IV$'
  471. outlin: db 1aH,cr,lf,'            $'
  472. erascr: db 1AH,'$'
  473. eralin: db cr,15H,'$'
  474. curldn: db esc,'=$'
  475. ttab:
  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
  487.  
  488. ovlend equ $           ;End of overlay
  489.  
  490.         END
  491.