home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / modems / modem / cp405src.ark / CP4SYS.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-12-26  |  141.9 KB  |  5,052 lines

  1. ; CP4SYS.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 KERMIT.
  20. ;    It will be probably be broken into independent files to generate
  21. ;    overlays for the various systems, one or more overlay possible
  22. ;    from each file.  For now, we will leave it in one piece.
  23. ;
  24. ; revision history:
  25. ;
  26. ; edit 31 April 17th, 1986 OBSchou.  Bugs in PX8 kermit fixed.
  27. ;
  28. ; edit 30 24th march, 1986 by OBSchou.  Sorting out torch tx and break
  29. ;    problems... AGAIN  
  30. ;
  31. ; edit 29, March 7th, 1986 by OBSchou.  Added in code for Epson PX8
  32. ;    code written by Tony Addyman from Salford University.  This is
  33. ;    really two edits into one, with a final edit of a dollar in the 
  34. ;    help messages.
  35. ;    Also add in code from an Unknown kermiteer, who added code for a
  36. ;    basic Northstar (basicns) (small changes) and also wrote the 
  37. ;    following headers to a list of "changes" to the CP4SYS file.....
  38. ;
  39. ;>     ACCESS-MATRIX
  40. ;>    Note - The following differences in CP4SYS.ASM apply to the
  41. ;>    implementation for the Access-Matrix computer.
  42. ;>    In CP4TYP.ASM, set access to TRUE, inout to TRUE, and crt to FALSE
  43. ;>    Use port J5 of the Access 
  44. ;>
  45. ;>    PMC MICROMATE
  46. ;>    The following applies to the implementation for Personal Micro 
  47. ;>    Computers PMC-101 MicroMate. In CP4TYP.ASM, set mmate to TRUE, 
  48. ;>    inout to TRUE, and crt to TRUE (Don't know what terminal might 
  49. ;>    be used.)
  50. ;>
  51. ;>    U.S. Micro Sales s1008 (out of business)
  52. ;>    Can use the same approach as for the basic NorthStar except set
  53. ;>    crt to FALSE.  (s1008)
  54. ;>
  55. ;>    A. C. E. DISCOVERY
  56. ;>    This implementation is for the Action Computer Enterprise, Inc. 
  57. ;>    "Discovery" multi user computer.  It uses port B on an 83U 
  58. ;>    user board. 
  59. ;>
  60. ;>    In CP4TYP.asm set disc to TRUE, inout to TRUE, and crt to TRUE
  61. ;>
  62. ;
  63. ; edit 28, January 29 1986 by OBSchou
  64. ;    added code to drive a 2651 USART for one of our odd ball
  65. ;    machines.  (Euromicro/Ithica Intersystems VIO (?) board)
  66. ;    (pci2651)  Also split the HUGE cp4sys.asm file into two smaller
  67. ;    ones: this one is still CP4SYS.ASM, the next one is CP4SY2.ASM
  68. ;    The break is just after the BREAK and DELAY routines.. roughly 1/2
  69. ;    way through the file.
  70. ;
  71. ; edit 27, 23rd January, 1986
  72. ;    General tidy up of code and comments
  73. ;
  74. ; edit 26: 10 December by OBSchou Loughborough University.
  75. ;    Edit out nested IF around screen handling code (Shame on me)
  76. ;    Aslo re-inserted code for prtstr for all other machines than Torch
  77. ;    as some (RM380Z is one) throws up when using direct con out.
  78. ;
  79. ; edit 25: 24 November, 1985 by ajcole @ leeds.ai
  80. ;    Merged in support for the following:
  81. ;    North Star Horizon without SIO-4 (horizon)
  82. ;    Comart Communicator (comart)
  83. ;    Cromemco TU-ART interface (cmemco)
  84. ;    TVI912/920 VDUs (tvi912)
  85. ;
  86. ;    Separated initialisation and speed setting for SuperBrain ports,
  87. ;    Main 'brainm' and Aux 'braina' ports are now independent.
  88. ;
  89. ; EDIT 24 14 November, 1985 by OBSchou @ Loughborough.  Tidied up some
  90. ;    aphids wot crept in edit 22.  Thanks to Brian Robertson
  91. ;    for checking the code.
  92. ;
  93. ; Edit 23 9th November, 1985 by OBchou @ Loughborough.
  94. ;    Moved an lxi h,0f0f in the cpt85 and advant code in sysinit.
  95. ;    My crummy merging showing up. (Tut Tut)
  96. ;
  97. ; Edit 22 by OBSchou @ Loughborough.  Merge in code from B Robertson
  98. ;    of Aberdeen University.  He writes:
  99. ;    September 20, 1985 by B Robertson, Aberdeen Univ. Computing Centre.
  100. ;    Add support for Research Machines 380Z, North Star Advantage, Acorn
  101. ;    BBC with Z80 co-processor and APPLE II with Mountain Computers CPS
  102. ;    Multifunction card.
  103. ;
  104. ; Edit 21 by OBSchou at Loughborough   General tidyup of files
  105. ;
  106. ; Edit 20: add in call in sysinit to call inadr etc (for io byte init)
  107. ;    as the modified prtstr requires outcon, ie the bios call.  The code
  108. ;    hase only been moved to be the first thing done by sysinit.
  109. ;    Also added the escape sequences required for the Cifer to be set
  110. ;    correctly.  Comes as part of the Conf. message.
  111. ;    io byte calls.  Code is there, it just does not seem to be called
  112. ;
  113. ; Edit 19, 11 October, 1985 by OBSchou at Loughborough
  114. ;    Added Torch and Brain to conditional IF for sysinh to write
  115. ;    message sayin these can do breaks.  Should have noticed, tut tut
  116. ;
  117. ; edit 18; october 9th, 1985 by OBSchou at Loughborough University.
  118. ;    added in code to generate breaks on Torch range of computers
  119. ;
  120. ; edit 17: October 7th, 1985 OBSchou
  121. ;    added code to set baud rate for Torch.  Also fond that DOS call 9
  122. ;    (Print a string) ruins any embedded control characters.  Have
  123. ;    therefore written an equivalent routine as prtstr using repeated
  124. ;    calls to outcon, which uses direct io (DOS call 6).  This sorts
  125. ;    the TORCH cursor addressing problem.
  126. ;
  127. ;
  128. ; edit 16: 4 september, 1985 by OBSchou
  129. ;    Added Superbrain  Breaks.. similar to cpt85xx as these two seem
  130. ;    use that ever so common 8251 USART.
  131. ;
  132. ; edit 15: 14 August, 1985, by OBSchou.
  133. ;    Try to sort out non-cursor posiotioning on torch.. and bug that
  134. ;    kills xfers after 443 packets. (See edit 17)
  135. ;
  136. ; edit 14: 14 June 12,1985, by OBSchou at Loughborough University
  137. ;       added code to automatically select rs423 port rather than cassette
  138. ;    interface on the BBC Microcomputer (The BASE PROCESSOR) when
  139. ;    driven from a Torchpack /Unicorn 5 etc
  140. ;
  141. ; edit 13: JUNE 11, 1985 by OB Schou, Loughbororugh University, UK
  142. ;    added in code for Torch Unicorn 5 + CP/N (as in Nut) and Cifer
  143. ;    1886.  This will probably cover also 26xx and 28xx series machines.
  144. ;
  145. ; edit 12: February 6, 1985
  146. ;    Add extended H89 support (by Paul Milazzo, Rice University),
  147. ;    support for Northstar Horizon with Northstar CP/M and SIO-4 board
  148. ;    (by Joe Smith, Colorodo School of Mines), and support for Lobo
  149. ;    MAX-80 computer (from Hal Hostetler)
  150. ;
  151. ; edit 11: 13-Jan-85 by Vanya J.Cooper Pima Commun. College Tel: 602-884-6809
  152. ;
  153. ;pcc001    27-Dec-84    vjc    modules: cp4sys,cp4typ
  154. ;    Add conditional for Xerox 820.  I thought at first I could
  155. ;    live with the kaypro conditional, but it's enough of a pain
  156. ;    that I added it back in.  The clear-to-end-of-screen char
  157. ;    is different,  breaking many programs in VT52 mode, and the
  158. ;    default escape char control-\2, is not at all obvious how
  159. ;    to type on the 820 keyboard.  If you muddle through the
  160. ;    key translation table, it turns out to be control-comma.
  161. ;    Rather than OR xer820 all the occurances of kpII conditionals
  162. ;    I added a bbI conditional for all common code for the big
  163. ;    board I based machines that is automatically turned on by
  164. ;    either kpII or xer820.  This will also make it easier in
  165. ;    the future if another flavor of bigboard is added.
  166. ;
  167. ; edit 10: 5 December 1984 by CJC
  168. ;    Add missing ENDIF (tsk, tsk)
  169. ;
  170. ; edit 9: 4 December 1984 by CJC
  171. ;    Add two osborne fixes: missing crlf in outlin:, incorrect opcode in
  172. ;    initialization.
  173. ;
  174. ; edit 8: 13 October 1984 by L M Jones, JCC, for New York Botanical Garden
  175. ;    Add support for CPT-85xx series word processors when running CP/M-80.
  176. ;
  177. ; edit 7: 29 August 1984 by Bdale Garbee @ CMU
  178. ;    Add support for Digicomp Delphi 100 and Netronics Smartvid terminal.
  179. ;
  180. ; edit 6: August 21, 1984
  181. ;    Add flsmdm, to flush comm line on startup.
  182. ;    Support multiple-sector buffering (except for osborne 1).
  183. ;
  184. ; edit 5: August 19, 1984
  185. ;    Add missing RET in outlpt: (*sigh*).  Also preserve DE in case
  186. ;    the BIOS destroys it.  Add version string (sysedt, since sysver
  187. ;    was already taken).
  188. ;
  189. ; edit 4: August 8, 1984
  190. ;    Running terminal output through the BDOS didn't work so well for
  191. ;    the Kaypro.  Remove the special check at outcon:.
  192. ;
  193. ; edit 3: August 3, 1984
  194. ;    move "mover" to CP4SYS from CP4UTL, so we can use Z80 block move.
  195. ;    define Z80 true or false when setting up the rest of the parameters.
  196. ;    (I'm only defining as Z80's the ones I KNOW are Z80's, because I
  197. ;    don't want to break anything by guessing wrong).  Make the values
  198. ;    stored by sysinit in "speed" match the 16-bit values found in the
  199. ;    speed table, so we can find them later.
  200. ;
  201. ; edit 2: July 27, 1984 (CJC)
  202. ;    Add break capability for Kaypro II and bbII.
  203. ;    Merge Toad Hall changes:  Allow assembly with LASM, add support for
  204. ;    Morrow Decision I.
  205. ;
  206. ; edit 1: May, 1984
  207. ;    extracted from CPMBASE.M80 version 3.9; modifications are described
  208. ;    in the accompanying .UPD file.
  209. ;
  210. ; Keep module name, edit number, and last revision date in memory.
  211. sysedt:    db    'CP4SYS.ASM (31) 17-APR-86 $'
  212.  
  213. ; Assembly time message to let me know I'm building the right version.
  214. ; LASM generates an 'S' error along with the message, which is messy, but
  215. ; better than trying to put everything inside a IF m80 OR mac80 conditional,
  216. ; because LASM doesn't like nested IF's, either.
  217.  
  218. IF robin
  219. .printx * Assembling KERMIT-80 for the DEC VT180 *
  220. ENDIF
  221.  
  222. IF brain
  223. .printx * Assembling KERMIT-80 for the Intertec Superbrain *
  224. ENDIF
  225.  
  226. IF brainm    ;[13]
  227. .printx * With main port selected
  228. ENDIF
  229. IF braina
  230. .printx * With Aux port
  231. ENDIF    ;[13]
  232.  
  233. IF vector
  234. .printx * Assembling KERMIT-80 for the Vector Graphics *
  235. ENDIF
  236.  
  237. IF osi
  238. .printx * Assembling KERMIT-80 for the Ohio Scientific *
  239. ENDIF
  240.  
  241. IF heath
  242. .printx * Assembling KERMIT-80 for the Heath/Zenith 89 *
  243. ENDIF
  244.  
  245. IF z100
  246. .printx * Assembling KERMIT-80 for the Heath/Zenith Z100 *
  247. ENDIF
  248.  
  249. IF apple
  250. .printx * Assembling KERMIT-80 for the Apple ][ *
  251. ENDIF;apple
  252. IF apmmdm
  253. .printx *   with Z80 Softcard & Micromodem II   *
  254. ENDIF;apmmdm
  255. IF ap6551
  256. .printx *     with Z80 Softcard & 6551 ACIA     *
  257. ENDIF;ap6551
  258. IF apcps;[22]
  259. .printx *     with Softcard & CPS Multifunction card     *
  260. ENDIF;apcps
  261.  
  262. IF trs80
  263. .printx * Assembling KERMIT-80 for the TRS-80 II *
  264. ENDIF
  265.  
  266. IF osbrn1
  267. .printx * Assembling KERMIT-80 for the Osborne 1 *
  268. ENDIF
  269.  
  270. IF telcon
  271. .printx * Assembling KERMIT-80 for the Telcon Zorba *
  272. ENDIF
  273.  
  274. IF dmII
  275. .printx * Assembling KERMIT-80 for the DECmate II *
  276. ENDIF
  277.  
  278. IF gener
  279. .printx * Assembling Generic KERMIT-80 *
  280. ENDIF
  281.  
  282. IF cpm3
  283. .printx * Assembling Generic KERMIT-80 for CP/M 3.0 *
  284. ENDIF
  285.  
  286. IF kpii
  287. .printx * Assembling Kaypro II KERMIT-80 *
  288. ENDIF
  289. IF xer820            ;[pcc001]
  290. .printx * Assembling Xerox 820 KERMIT-80 *
  291. ENDIF                ;[pcc001]
  292.  
  293. IF bbII
  294. .printx * Assembling BigBoard II KERMIT-80 *
  295. ENDIF
  296.  
  297. IF mdI
  298. .printx * Assembling for Morrow Decision I *
  299. ENDIF    ;mdI  [Toad Hall]
  300.  
  301. IF mmdI
  302. .printx * Assembling for Morrow Micro Decision I *
  303. ENDIF    ;mmdI
  304.  
  305. IF mikko
  306. .printx * Assembling MikroMikko Kermit-80 *
  307. ENDIF
  308.  
  309. IF delphi    ;[7]
  310. .printx * Assembling Digicomp Delphi 100 Kermit-80 *
  311. ENDIF        ;[7]
  312.  
  313. IF cpt85xx
  314. .printx * Assembling CPT-85xx (under CompuPak CP/M) Kermit-80 *
  315. ENDIF
  316.  
  317. IF norths
  318. .printx * Assembling for NorthStar Horizon with HSIO-4 board *
  319. ENDIF;norths
  320.  
  321. IF comart    ;[25]
  322. .printx * Assembling KERMIT-80 for the Comart Communicator *
  323. ENDIF;comart
  324.  
  325. IF horizon    ;[25]
  326. .printx * Assembling KERMIT-80 for the NorthStar Horizon *
  327. ENDIF;horizon
  328.  
  329. IF cmemco    ;[25]
  330. .printx * Assembling KERMIT-80 for the Cromemco (TU-ART) *
  331. ENDIF;cmemco
  332.  
  333. IF pci2651    ;[28]
  334. .printx * assembling Kermit-80 for 2651 PCI as comms device *
  335. ENDIF    ;[28]
  336.  
  337. IF advant    ;[22]
  338. .printx * Assembling kermit-80 for North Star Advantage *
  339. ENDIF    ;[22]
  340.  
  341. IF bbc    ;[22]
  342. .printx * Assembling Kermit-80 for BBC with Z80 co-processor *
  343. ENDIF    ;[22]
  344.  
  345. IF rm380z    ;[22]
  346. .printx * Assembling Kermit-80 for Research Machines 380Z *
  347. ENDIF    ;[22]
  348.  
  349. IF px8        ;[29]
  350. .printx * Assembling Kermit-80 for Epson PX-8 *
  351. ENDIF    ;px8 [29]
  352.  
  353. IF mmate    ;[29]
  354. .printx * Assembling KERMIT-80 for the PMC MicroMate *
  355. ENDIF    ;mmate [29]
  356.  
  357. IF disc    ;[29]
  358. .printx * Assembling KERMIT-80 for the A. C. E. Discovery *
  359. ENDIF    ;disc [29]
  360.  
  361. IF basicns    ;[29]
  362. .printx * Assembling KERMIT-80 for the Northstar Horizon using printer port *
  363. ENDIF    ;basicns [29]
  364.  
  365. IF s1008    ;[29]
  366. .printx * Assembling KERMIT-80 for the MicroSales s1008 *
  367. ENDIF    ;s1008 [29]
  368.  
  369. IF access    ;[29]
  370. .printx * Assembling Kermit-80 for the ACCESS-MATRIX computer *
  371. ENDIF    ;access [29]
  372.  
  373. IF cifer    ;[13]
  374. .printx * Assembling Kermit-80 for Cifer 1886 *
  375. ENDIF
  376.  
  377. IF torch
  378. .printx * Assembling Kermit-80 for Torch Unicorn 5 *
  379. ENDIF;Torch [13]
  380.  
  381. IF lobo        ;[hh]
  382. .printx * Assembling Kermit-80 for the Lobo MAX-80 *
  383. ENDIF;lobo [hh]
  384.  
  385. ; Also tell what kind of terminal, if any, is selected
  386. IF crt
  387. .printx * generic CRT selected *
  388. ENDIF
  389.  
  390. IF adm3a
  391. .printx * ADM3A selected *
  392. ENDIF
  393.  
  394. IF smrtvd    ;[7]
  395. .printx * Netronics Smartvid-80 selected *
  396. ENDIF        ;[7]
  397.  
  398. IF tvi912
  399. .printx * TVI912/920 selected *
  400. ENDIF
  401.  
  402. IF tvi925
  403. .printx * TVI925 selected *
  404. ENDIF
  405.  
  406. IF vt52
  407. .printx * VT52 selected *
  408. ENDIF
  409.  
  410. IF vt100
  411. .printx * VT100 selected *
  412. ENDIF
  413.  
  414. ;=========================================================================
  415. ;    I/O Byte assignments (2-bit fields for 4 devices at loc 3)
  416. ;
  417. ;bits 6+7        LIST field
  418. ;    0        LIST is Teletype device (TTY:)
  419. ;    1        LIST is CRT device (CRT:)
  420. ;    2        LIST is Lineprinter (LPT:)
  421. ;    3        LIST is user defined (UL1:)
  422. ;
  423. ;bits 4+5        PUNCH field
  424. ;    0        PUNCH is Teletype device (TTY:)
  425. ;    1        PUNCH is high speed punch (PUN:)
  426. ;    2        PUNCH is user defined #1 (UP1:)
  427. ;    3        PUNCH is user defined #2 (UP2:)
  428. ;
  429. ;bits 2+3        READER field
  430. ;    0        READER is Teletype device (TTY:)
  431. ;    1        READER is high speed reader (RDR:)
  432. ;    2        READER is user defined #1 (UR1:)
  433. ;    3        READER is user defined #2 (UR2:)
  434. ;
  435. ;bits 0+1        CONSOLE field
  436. ;    0        CONSOLE is console printer (TTY:)
  437. ;    1        CONSOLE is CRT device (CRT:)
  438. ;    2        CONSOLE is in Batch-mode (BAT:);READER = Input,
  439. ;            LIST = Output
  440. ;    3        CONSOLE is user defined (UC1:)
  441. ;
  442. ;=========================================================================
  443.  
  444. iobyte    EQU    03H    ;Location of I/O byte
  445.  
  446. ; the basics...
  447. IF robin OR gener
  448. batio    EQU    056H    ;I/O byte CON=BAT,LIST=CRT,READER=RDR,PUNCH=PTP
  449. defio    EQU    095H    ;I/O byte CON=CRT,LIST=LPT,READER=RDR,PUNCH=PTP
  450. ENDIF;robin OR gener
  451.  
  452. IF gener
  453. crtio    equ    01010101B    ; use CRT: device
  454. ptrio    equ    01010110B    ; use PTR: device
  455. ttyio    equ    00000000B    ; use TTY: device
  456. uc1io    equ    01010111B    ; use UC1: device
  457. ur1io    equ    01101010B    ; use UR1: device
  458. ur2io    equ    01111110B    ; use UR2: device
  459. ENDIF;gener
  460.  
  461. IF cifer    ;[13]
  462. batio    equ    80h        ; tty: as console
  463. defio    equ    81h        ; crt: as console
  464. z80    equ    false        ; although it really is...
  465. ENDIF;cifer [13]
  466.  
  467. IF robin
  468. lptio    EQU    054H    ;I/O byte CON=TTY,LIST=CRT,READER=PTR,PUNCH=PTP
  469. gppio    EQU    057H    ;I/O byte CON=UC1,LIST=CRT,READER=RDR,PUNCH=PTP
  470. ENDIF;robin
  471.  
  472. IF dmII OR bbc    ;[22]
  473. batio    EQU    042H    ;I/O byte CON=BAT,LIST=CRT,READER=RDR
  474. defio    EQU    081H    ;I/O byte CON=CRT,LIST=LPT,READER=RDR
  475. ENDIF;dmII
  476.  
  477. IF mikko
  478. batio    EQU    10110010B ; I/O byte console => serial line
  479. defio    EQU    10000001B ; I/O byte console => CRT and Keyboard
  480. ENDIF;mikko
  481.  
  482. ;
  483. ;    Protocol parameters.  Some of these can be changed with commands.
  484. ;
  485.  
  486. drpsiz    EQU    5EH    ;Default receive packet size. (maximum is 5EH)
  487. dspsiz    EQU    20H    ;Default send packet size. (maximum is 5EH)
  488. dstime    EQU    08H    ;Default send time out interval.
  489.  
  490. IF NOT (apple OR osbrn1)
  491. drtime    EQU    05H    ;Default receive time out interval.
  492. ENDIF;NOT (apple OR osbrn1)
  493. IF apple OR osbrn1
  494. drtime    EQU    0AH    ; Use longer receive timeout on apple and osborne.
  495. ENDIF;apple OR osbrn1
  496.  
  497. dspad    EQU    00H    ;Default send padding.
  498. drpad    EQU    00H    ;Default receive padding.
  499. dspadc    EQU    00H    ;Default send padding char.
  500. drpadc    EQU    00H    ;Default receive padding char.
  501. dseol    EQU    CR    ;Default send EOL char.
  502. dreol    EQU    CR    ;Default receive EOL char.
  503. dsquot    EQU    '#'    ;Default send quote char.
  504. drquot    EQU    '#'    ;Default receive quote char.
  505. dschkt    EQU    '1'    ;Default checksum type
  506.  
  507. IF lobo    ;[hh]
  508. mnport    EQU    0F7E4H    ;Modem data port A
  509. mnprts    EQU    0F7E5H    ;Modem status/conrtol port A
  510. baudrt    EQU    0F7D0H    ;Baud rate port A
  511. output    EQU    04H    ;Transmit buffer empty
  512. input    EQU    01H    ;Receive data available
  513. z80    EQU    TRUE    ;a good z80, here
  514. ENDIF;lobo
  515.  
  516. ; [13] modifed to use either main or aux port.  Should really
  517. ;    be selected by set port, but this is urgent, so no frills
  518. IF brain
  519. baudst    EQU    60H    ;
  520. baudrt    EQU    0EF00H    ;Memory location where baud rates are stored.
  521. output    EQU    01H    ;Transmitter ready
  522. input    EQU    02H    ;Input data available
  523. TxEmpty    EQU    04h    ;Transmitter empty
  524. z80    EQU    TRUE    ;I don't know...
  525. ENDIF;brain
  526. IF brainm        ; Superbrain and main ports
  527. mnport    EQU    58H    ;Modem data port
  528. mnprts  EQU    59H    ;Modem status port
  529. ENDIF    ;brainm
  530. IF braina        ; Superbrain and aux port
  531. mnport    EQU    40H    ;Modem data port
  532. mnprts  EQU    41H    ;Modem status port
  533. ENDIF    ;braina [13]
  534.  
  535. IF osi
  536. mnport    EQU    0CF01H    ;Modem data port
  537. mnprts  EQU    0CF00H    ;Modem status port
  538. output    EQU    02H    ;Transmitter empty
  539. input    EQU    01H    ;Input data available
  540. z80    EQU    FALSE    ;I don't know...
  541. ENDIF;osi
  542.  
  543. IF vector
  544. mnport    EQU    04H    ;Modem data port
  545. mnprts    EQU    05H    ;Modem status port
  546. output    EQU    01H    ;Transmitter empty
  547. input    EQU    02H    ;Input data available
  548. z80    EQU    FALSE    ;I don't know...
  549. ENDIF;vector
  550.  
  551. IF delphi        ;[7]
  552. mnport    EQU    22H    ;[7] Modem data port
  553. mnprts    EQU    23H    ;[7] Modem status port
  554. output    EQU    01H    ;[7] Transmitter empty
  555. input    EQU    02H    ;[7] Input data available
  556. baudrt    equ    29h    ;[7] Baud rate port for channel 2 (default)
  557. z80    EQU    true    ;[7] We're using the z80 side of the dual processor
  558. ENDIF;[7] delphi
  559.  
  560. IF heath
  561.  
  562. ;    Definitions for the 8250 ACE
  563.  
  564. acerbr    EQU    0    ; ACE Receiver Buffer Register offset (R/O) (DLAB = 0)
  565. acethr    EQU    0    ; ACE Transmitter Holding Register offset (W/O)
  566. acedll    EQU    0    ; ACE Divisor Latch (Low)    (DLAB = 1)
  567. acedlh    EQU    1    ; ACE Divisor Latch (High)    (DLAB = 1)
  568. aceier    EQU    1    ; ACE Interrupt Enable Register (DLAB = 0)
  569. aceiir    EQU    2    ; ACE Interrupt Identification Register
  570. acelcr    EQU    3    ; ACE Line Control Register
  571. acemcr    EQU    4    ; ACE Modem Control Register
  572. acelsr    EQU    5    ; ACE Line Status Register offset
  573. acemsr    EQU    6    ; ACE Modem Status Register
  574.  
  575. ace8bw    EQU    00000011b ; 8 bit words
  576. acesb    EQU    01000000b ; set break
  577. acedla    EQU    10000000b ; divisor latch access
  578. acedtr    EQU    00000001b ; data terminal ready
  579. aceloo    EQU    00010000b ; loopback mode
  580. acedr    EQU    00000001b ; data ready
  581. acethe    EQU    00100000b ; transmitter holding register empty
  582.  
  583. mnport    EQU    330O    ;Modem data port
  584. mnprts    EQU    mnport+acelsr    ;Modem status port
  585. output    EQU    acethe    ;Transmitter empty
  586. input    EQU    acedr    ;Input data available
  587. z80    EQU    TRUE    ;H89 uses the Z80
  588. ENDIF;heath
  589.  
  590. IF z100
  591. mnport    EQU    0ECH    ;Modem data port
  592. mnprts    EQU    0EDH    ;Modem status port
  593. output    EQU    01H    ;Transmitter empty
  594. input    EQU    02H    ;Input data available
  595. z80    EQU    FALSE    ;[hh] this one's an 8085.
  596. ENDIF;z100
  597.  
  598. IF trs80
  599. ;NEEDS display definition (e.g. trs80lb or trs80pt)
  600. mnport    EQU    0F4H    ;Modem data port (0F5H for port B)
  601. mnprts    EQU    0F6H    ;Modem status port (0F7H for port B)
  602. output    EQU    04H    ;Transmitter empty
  603. input    EQU    01H    ;Input data available
  604. z80    EQU    TRUE    ;[hh] All TRS-80's but the CoCo
  605. ENDIF;trs80
  606.  
  607. IF apmmdm
  608. ;APPLE Slot 2 contains Micromodem II.
  609. MNPORT    EQU    0E0A7H    ;Communications Port.
  610. mnprts    EQU    0E0A6H    ;Communications Port Status.
  611. mnmodm    EQU    0E0A5H    ;Modem Control Port.
  612. orgmod    EQU    8EH    ;Modem Originate Mode.
  613. OUTPUT    EQU    02H    ;Output Buffer Empty.
  614. INPUT    EQU    01H    ;Input Register Full.
  615. apinc1    EQU    03H    ;First Init Character for 6850 ACIA (Reset)
  616. apinc2    EQU    11H    ;Second Init Character for ACIA (8-bits)
  617. apoffh    EQU    80H    ;Set if OFFHOOK
  618. AP300    EQU    1    ;300 Baud
  619. z80    EQU    TRUE    ;Z80 Softcard
  620. ENDIF;apmmdm
  621.  
  622. IF ap6551        ;jb
  623. mnport    EQU    0E088H+(10H*apslot)    ;jb Communications Port.
  624. mnprts    EQU    0E089H+(10H*apslot)    ;jb Communications Port Status.
  625. mnprtc    EQU    0E08BH+(10H*apslot)    ;jb Communications Control
  626. mnprtm    EQU    0E08AH+(10H*apslot)    ;jb Communications Master (command)
  627. output    EQU    10H        ;jb Output Buffer Empty.
  628. input    EQU    08H        ;jb Input Register Full.
  629. mncinb    EQU    18H        ;jb Control Port Initialization Byte
  630.                 ;jb  (8-bit, no parity, 1-stop, 1200 baud)
  631. mnminb    EQU    0BH        ;jb Master Port Initialization Byte
  632.                 ;jb  (DTR, RTS, no interrupts)
  633. z80    EQU    TRUE        ;Z80 Softcard
  634. ENDIF;ap6551
  635.  
  636. IF apcps        ;[22]
  637. mnport    EQU    0E0FAH+(100H*apslot)    ; Communications Port.
  638. mnprts    EQU    0E0FBH+(100H*apslot)    ; Communications Port Status.
  639. mnprtc    EQU    0E0FEH+(100H*apslot)    ; Communications Control
  640. output    EQU    1        ; Output Buffer Empty.
  641. input    EQU    2        ; Input Register Full.
  642. TxEmpty    EQU    04h        ; Transmitter empty flag
  643. apmod1    EQU    4EH        ; Mode Byte 1 (1 stop, no parity,8-bit, 16x)
  644.                 ; Mode Byte 2 is speed control byte
  645. apcmd    EQU    37H        ; Command Byte (RTS,Error reset,RxE,DTR,TxE)
  646. z80    EQU    TRUE        ;Z80 Softcard
  647. ENDIF;[22] apcps
  648.  
  649. IF osbrn1
  650. ;Osborne 1 uses 6850 ACIA, but memory mapped.  Derived from Apple.
  651. BAUDRT    EQU    0EFC1H    ;Memory location where baud rates are stored.
  652. OSTOP    EQU    4000H    ;Where we move OSMOVE to at startup
  653. OSPORT    EQU    2A01H    ;Communications Port.
  654. OSPRTS    EQU    2A00H    ;Communications Port Status.
  655. OUTPUT    EQU    02H    ;Output Buffer Empty.
  656. INPUT    EQU    01H    ;Input Register Full.
  657. OSBIN1    EQU    57H    ;First Init Character for 6850 ACIA (Reset)
  658. ;(I would have thought 03, but prom code writes 57 there)
  659. OSBI12    EQU    55H    ;Second Init Character for ACIA (8-bits, 1200)
  660. OSBI03    EQU    56H    ;Second init char. for ACIA (8 bits, 300)
  661. ;(don't ask.. I don't know why SETUP writes 55 and 56 either)
  662. z80    EQU    TRUE    ;[hh] a z80 here, also
  663. ENDIF;osbrn1
  664.  
  665. IF telcon
  666. MNPORT    EQU    20H    ;Modem data port
  667. MNPRTS    EQU    21H    ;Modem status port
  668. OUTPUT    EQU    01H    ;Transmitter empty
  669. INPUT    EQU    02H    ;Input data available
  670. z80    EQU    FALSE    ;I don't know...
  671. ENDIF;telcon
  672.  
  673. IF robin
  674. ;Those definitions below that are commented out are just for information
  675. ;***** NOT generally found in distributed documentation ****
  676.  
  677. ;pbausl EQU    90H    ;The Baud-Rate register.
  678. prntst    EQU    49H    ;Printer
  679. ;prndat    EQU    48H
  680. contst    EQU    41H    ;Console
  681. ;condat    EQU    40H
  682. gentst    EQU    51H    ;General port.
  683. ;gendat    EQU    50H
  684. comtst    EQU    59H    ;COMM-Port
  685. ;comdat    EQU    58H
  686. ;output    EQU    01H    ;Output ready bit.
  687. ;input    EQU    02H    ;Input ready bit.
  688. z80    EQU    TRUE    ; This one's a Z80.
  689. ENDIF;robin
  690.  
  691. IF bbI
  692. mnport    equ    04h        ; Modem data port
  693. mnprts    equ    06h        ; Modem status port
  694. output    equ    04h        ; Transmit buffer empty
  695. input    equ    01h        ; Receive data available
  696. baudrt    equ    00h        ; Baud rate port for channel A
  697. z80    EQU    TRUE        ; This one's a Z80.
  698. ENDIF;bbI
  699.  
  700. IF norths ;The basic Northstar Horizon BIOS does not access ports 2-5
  701. port0d  equ     02h             ;Port 0 data (console)
  702. port0s  equ     03h             ;Port 0 status
  703. port1d  equ     04h             ;Port 1 data (printer)
  704. port1s  equ     05h             ;Port 1 status
  705.  
  706. port2b  equ     10h             ;Port 2 baud
  707. port2i  equ     11h             ;Port 2 interrupt mask
  708. port2d  equ     12h             ;Port 2 data
  709. port2s  equ     13h             ;Port 2 status
  710.  
  711. port3b  equ     14h             ;Port 3 baud
  712. port3i  equ     15h             ;Port 3 interrupt mask
  713. port3d  equ     16h             ;Port 3 data
  714. port3s  equ     17h             ;Port 3 status
  715.  
  716. port4b  equ     18h             ;Port 4 baud
  717. port4i  equ     19h             ;Port 4 interrupt mask
  718. port4d  equ     1Ah             ;Port 4 data
  719. port4s  equ     1Bh             ;Port 4 status
  720.  
  721. port5b  equ     1Ch             ;Port 5 baud
  722. port5i  equ     1Dh             ;Port 5 interrupt mask
  723. port5d  equ     1Eh             ;Port 5 data
  724. port5s  equ     1Fh             ;Port 5 status
  725.  
  726. NS19K2    EQU    00H        ;19.2 kilobaud
  727. NS9600    EQU    01H        ;9600 baud
  728. NS4800    EQU    02H        ;4800 baud
  729. NS2400    EQU    03H        ;2400 baud
  730. NS1200    EQU    04H        ;1200 baud
  731. NS0600    EQU    05H        ; 600 baud
  732. NS0300    EQU    06H        ; 300 baud
  733. NS0110    EQU    07H        ; 110 baud
  734. ;; Set to use port 5 at 1200 baud             *****
  735. mnport  equ     port5d        ;Data port
  736. mnprts    equ    port5s        ;Status port
  737. baudrt    equ    port5b        ;Baud rate port
  738. baudini    equ    ns1200        ;Initial baud rate
  739. output    EQU    1        ;Bit of UART status for transmitter ready
  740. input    EQU    2        ;Bit of UART status for receiver ready
  741. z80    EQU    TRUE        ;This one's a Z80.
  742. ENDIF;norths
  743.  
  744. IF basicns    ;[29]
  745. mnport    equ    04h        ;printer port data
  746. mnprts    equ    05h        ; printer port status
  747. output    equ    1        ;transmitter ready
  748. input    equ    2        ;receiver ready
  749. z80    equ    FALSE        ; not important
  750. ENDIF    ;basicns [29]
  751.  
  752. IF s1008    ;[29]
  753. mnport    equ    00        ;printer port data
  754. mnprts    equ    01        ;printer port status
  755. output    equ    4        ;transmitter ready
  756. input    equ    2         ;receiver ready
  757. z80    equ    FALSE         ;not important
  758. ENDIF;s1008 [29]
  759.  
  760. IF mmate    ;[29]
  761. mnport    EQU    89H        ;MODEM data port
  762. mnprts    EQU    8BH        ;MODEM status/control port
  763. output    EQU    04H        ;Transmit buffer empty, ready to send
  764. input    EQU    01H        ;Receive data available
  765. baudrt    EQU    93H        ;MODEM baud rate port
  766.             ;NOTE - also used for console
  767. z80    EQU    TRUE
  768. ENDIF;mmate [29]
  769.  
  770. IF disc    ;[29]
  771. mnport    EQU    05        ;Discovery 83U port B data
  772. mnprts    EQU    04        ;Discovery 83U port B status/command
  773. output    EQU    04        ;Transmit buffer empty
  774. input    EQU    01        ;Receiver ready
  775. z80    EQU    TRUE
  776. ENDIF;disc [29]
  777.  
  778. IF comart        ;[25]
  779. mnport    EQU    002H    ;Modem data port
  780. mnprts    EQU    003H    ;Modem status port
  781. output    EQU    01H    ;Transmitter empty
  782. input    EQU    02H    ;Input data available
  783. TxEmpty    EQU    04h    ;Transmitter empty
  784. ;Note:    Needs terminal definition (vt100, vt52, tvi925, adm3a or crt above)
  785. z80    EQU    TRUE    ;This one's a Z80.
  786. ENDIF;comart
  787.  
  788. IF horizon        ;[25]
  789. mnport    EQU    004H    ;Modem data port
  790. mnprts    EQU    005H    ;Modem status port
  791. output    EQU    01H    ;Transmitter empty
  792. input    EQU    02H    ;Input data available
  793. TxEmpty    EQU    04h    ;Transmitter empty
  794. ;Note:    Needs terminal definition (vt100, vt52, tvi925, adm3a or crt above)
  795. z80    EQU    TRUE    ;This one's a Z80.
  796. ENDIF;horizon
  797.  
  798. IF cmemco        ;[25]
  799. tuart    EQU    020H    ;TU-ART address
  800. mnport    EQU    tuart+1    ;Modem data port
  801. mnprts    EQU    tuart    ;Modem status port
  802. output    EQU    080H    ;Transmitter empty
  803. input    EQU    040H    ;Input data available
  804. baudrt    EQU    tuart    ;Baud rate port
  805. ;Note:    Needs terminal definition (vt100, vt52, tvi925, adm3a or crt above)
  806. z80    EQU    TRUE    ;This one's a Z80.
  807. ENDIF;cmemco
  808.  
  809. IF pci2651            ;[28]
  810. iobase    equ    04h        ; base address of PCI device
  811. mnport    equ    iobase        ; rx and tx data ports
  812. mnprts    equ    iobase+1    ; status port
  813. mnmode    equ    iobase+2    ; mode port
  814. mncmd    equ    iobase+3    ; PCI command port
  815.  
  816. txrdy    equ    1        ; tx ready bit set if free
  817. output    equ    txrdy
  818. rxrdy    equ    2        ; RX ready bit
  819. input    equ    rxrdy
  820. baudini    equ    7        ; 7 => 1200 baud by default
  821. z80    equ    true        ; For Ithica intersystems it is
  822. cpuspd    equ    40        ; and running at four megs
  823. ENDIF                ;[28]
  824.  
  825. IF bbII
  826. mnport    equ    80h        ; Modem data port (SIO channel A)
  827. mnprts    equ    81h        ; Modem status port
  828. output    equ    04h        ; Transmit buffer empty
  829. input    equ    01h        ; Receive data available
  830. baudrt    equ    89h        ; Baud rate port for channel A
  831. z80    EQU    TRUE        ; This one's a Z80.
  832. ENDIF;bbII
  833.  
  834. IF cpt85xx
  835. baudrt    EQU    4Ch        ; Baud rate generater (National MM5307)
  836. mnport    EQU    4Bh        ; Comm port data register (Intel 8251)
  837. mnprts    EQU    4Ah        ; Comm port command/status register
  838. output    EQU    01h        ; Transmitter buffer empty flag
  839. input    EQU    02h        ; Reciver buffer full flag
  840. TxEmpty    EQU    04h        ; Transmitter empty flag
  841. z80    EQU    FALSE        ; It's really an 8080 [or 8085 ... same thing]
  842. ENDIF;cpt85xx
  843.  
  844. IF mmdI    ;Morrow MicroDecision - the single-board one
  845. mnport    EQU    0FEH    ;Morrow Printer UART data port
  846. mnprts    EQU    0FFH    ;Morrow Printer UART command/status
  847. output    EQU    01H    ;Output ready bit.
  848. input    EQU    02H    ;Input  ready bit.
  849. ;Note:    Needs terminal definition (vt100, vt52, tvi925, adm3a or crt above)
  850. z80    EQU    FALSE    ;I don't know...
  851. ENDIF;mmdI
  852.  
  853. IF advant    ;[22]
  854. slot    EQU    1        ;SIO card slot
  855. mnport    EQU    (6-slot)*16    ;Modem data port
  856. mnprts  EQU    mnport+1    ;Modem status port
  857. baudrt    EQU    mnport+8    ;Baud rate register
  858. output    EQU    01H        ;Transmitter buffer empty
  859. input    EQU    02H        ;Input data available
  860. TxEmpty    EQU    04h        ;Transmitter empty flag
  861. z80    EQU    TRUE
  862. ENDIF;[22] advant
  863.  
  864. IF bbc        ;[22]
  865. osbyte    EQU    0FFF4H    ; OS entry point
  866. osword    EQU    0FFF1H    ; "    "     "
  867. term    EQU    0FFC8H    ;Terminal mode OS entry
  868. z80    EQU    TRUE
  869. ENDIF;[22] bbc
  870.  
  871. IF rm380z    ;[22]
  872. mnport    EQU    0E8H    ;Modem data port
  873. mnprts  EQU    0E9H    ;Modem status port
  874. output    EQU    01H    ;Transmitter buffer empty
  875. input    EQU    02H    ;Input data available
  876. TxEmpty    EQU    04h    ;Transmitter empty flag
  877. z80    EQU    TRUE
  878. ENDIF;[22] rm380z
  879.  
  880. IF px8    ; [29]
  881. z80    EQU    TRUE
  882. mnprts    EQU    0dh    ; used in sending a break
  883. ENDIF    ;px8 [29]
  884.  
  885. IF mdI    ;Morrow Decision I - the big sucker
  886. mnport    equ    48H        ; Modem data port.
  887. mnprts    equ    4DH        ; Modem status port.
  888. output    equ    20H        ; Transmitter empty.
  889. input    equ    1        ; Input data available.
  890. mbase    equ    48H        ; Base address of Multi I/O port
  891.                 ;   selector area.
  892. grpsel    equ    4FH        ; Group select port.
  893. rbr    equ    48H        ; Read Data Buffer.
  894. group    equ    1        ; Multi I/O Group byte for serial ports.
  895. congrp    equ    1        ; Serial Port 1 for console
  896. mdmgrp    equ    3        ; Serial Port 3 for modem.
  897.  
  898. ; Following are needed for baud rate changes...[Toad Hall]
  899.  
  900. dlm    equ    49H        ; Baud Rate Divisor (Most Sig Bit)
  901. dll    equ    48H        ; Baud Rate Divisor (Least Sig Bit)
  902. ier    equ    49H        ; Interrupt Enable Register
  903. lcr    equ    4BH        ; Line Control Register
  904. lsr    equ    4DH        ; Line Status Register
  905. msr    equ    4EH        ; Modem Status Register
  906. dlab    equ    80H        ; Divisor Latch Access Bit
  907. wls0    equ    1        ; Word Length Select Bit 0
  908. wls1    equ    2        ; Word Length Select Bit 1 for 8 bit word
  909. stb    equ    4        ; Stop bit count - 2 stop bits
  910. imask    equ    0        ; Interrupt mask (all disabled)
  911. z80    EQU    TRUE        ; This one's a Z80.
  912. ENDIF    ;mdI   NOTE: needs terminal definition. [Toad Hall]
  913.  
  914. IF mikko
  915. sioac    EQU    0FF12H        ;SIO channel A register(s) address
  916. sioo3    EQU    01000001B     ;SIO Write Reg. 3 original setup (?)
  917.                 ;RX 7 bits,synch mode bits 0,RX enable
  918. sion3    EQU    11001111B    ;SIO Write Reg. 3 KERMIT setup
  919.                 ;RX 8 bits,synch mode bits 0,RX enable
  920. sioo4    EQU    01001111B    ;SIO Write Reg. 4 original setup (?)
  921.                 ;X16 clock,8 bit synch(ignored),
  922.                 ;2stop bits,par even(on)
  923. sion4    EQU    01000100B    ;SIO Write Reg. 4 KERMIT setup
  924.                 ;X16 clock,8 bit synch(ignored),
  925.                 ;1stop bit,par off
  926. sioo5    EQU    10101010B    ;SIO Write Reg. 5 original setup (?)
  927.                 ;DTR,TX 7 bits,TX enable,RTS
  928. sion5    EQU    11101010B    ;SIO Write Reg. 5 KERMIT setup
  929.                 ;DTR,TX 8 bits,TX enable,RTS
  930. txclk    EQU    0FF30H    ;Baud rate generator (CTC) for transmitter
  931. rxclk    EQU    0FF31H    ;Baud rate generator (CTC) for receiver
  932. chmask    EQU    0F1F2H    ;Mask byte address for SIO ch. A reception
  933. z80    EQU    TRUE    ;It's got a SIO and a CTC, it must be a Z80
  934. ENDIF;mikko
  935.  
  936. IF torch    ;[13]
  937. z80    equ    TRUE
  938. baudini    equ    404h    ; Initial Baud rate = 1200 baud
  939.             ; Entry to be of form x0xh where x is
  940.             ; the value x in the FX 7,x and FX 8,x
  941.             ; funtion calls.  4= 1200 baud, 7 = 9600
  942.             ; 2 = 300 baud.
  943. ENDIF
  944.  
  945. IF access    ;[29]
  946. mnport    EQU    40H    ;Modem data port A
  947. mnprts    EQU    42H    ;Modem status/conrtol port A
  948. output    EQU    04H    ;Transmit buffer empty
  949. input    EQU    01H    ;Receive data available
  950. z80    EQU    TRUE    ;a good z80, here
  951. ENDIF;access [29]
  952.  
  953.  
  954. IF robin OR dmII
  955. z80    EQU    TRUE    ; This one's a Z80
  956. ENDIF;robin OR dmII
  957.  
  958. IF gener OR cpm3    ; To be truly generic, we must assume 8080.
  959. z80    EQU    FALSE
  960. ENDIF;gener OR cpm3
  961.  
  962. IF brain OR osi OR apple OR telcon OR xer820 OR cifer OR torch;[13]
  963. defesc    EQU    ']'-100O    ;The default escape character.
  964. ENDIF;brain OR osi OR apple OR telcon OR xer820 OR cifer OR torch
  965.  
  966. IF vector
  967. defesc    EQU    '~'        ;Vector can't type ']'.
  968. ENDIF;vector
  969.  
  970. IF robin OR dmII OR mikko OR heath OR z100 OR osbrn1 OR kpII OR lobo
  971. defesc    EQU    '\'-100O    ;The default is Control \ -- it's easier B.E.
  972. ENDIF;robin OR dmII OR mikko OR heath OR z100 OR osbrn1 OR kpII OR lobo
  973.  
  974. IF crt OR vt100 OR vt52 OR tvi912 OR tvi925 OR adm3a OR smrtvd OR cpt85xx
  975. defesc    EQU    '\'-100O    ;Still Control-\ (just ran out of room...)
  976. ENDIF;crt OR vt100 OR vt52 OR tvi912 OR tvi925 OR adm3a OR smrtvd OR cpt85xx
  977.  
  978. IF advant OR bbc OR rm380z OR px8 OR access OR S1008    ;[22] [29]
  979. defesc    EQU    '\'-100O    ;Still Control-\ (just ran out of room...)
  980. ENDIF    ;[22] advant OR bbc OR rm380z OR px8 OR access OR s1008[29]
  981.  
  982. IF trs80
  983. defesc    EQU    '_'-100O    ;CTRL-_ (Down-arrow on TRS-80 keyboard)
  984. ENDIF;trs80
  985.  
  986. ; Select initial setting for VT-52 emulation flag.
  987. IF crt                ; If dumb or unknown console,
  988. vtval    EQU    0FFH        ;  we can't support VT52 emulation
  989. ENDIF;crt
  990.  
  991. IF heath OR z100 OR telcon OR vt52 ; If console looks like (or is) VT52
  992. vtval    EQU    0        ;  we don't need VT52 emulation
  993. ENDIF;heath OR z100 OR telcon OR vt52
  994.  
  995. IF robin OR dmII OR vt100    ; If console looks like VT100
  996. vtval    EQU    0        ; we probably don't want VT52 emulation
  997. ENDIF;robin OR dmII OR vt100
  998.  
  999. ; Select initial setting for VT-52 emulation flag.
  1000. IF access    ; Console can emulate VT-52 [29]
  1001. vtval    EQU    1
  1002. ENDIF;access [29]
  1003.  
  1004. ; If none of the above, default to VT52-EMULATION ON.
  1005. IF NOT (crt OR heath OR z100 OR telcon OR vt52 OR robin OR dmII OR vt100)
  1006. vtval    EQU    1
  1007. ENDIF;NOT (crt OR heath OR z100 OR telcon OR vt52 OR robin OR dmII OR vt100)
  1008.  
  1009. ; Set the fuzzy timeout value.  Range is 1 (VERY short) through 0ffffH to zero
  1010. ; (maximum).  The actual duration is a function of the loop length and the
  1011. ; processor speed.  For now, we'll make it zero for everybody, but feel free
  1012. ; to change it for your system.
  1013. fuzval    EQU    0
  1014.  
  1015.  
  1016. ;
  1017. ;    System-dependent initialization
  1018. ;    Called once at program start.
  1019. sysinit:
  1020. ;
  1021. ; [13]  Had to move this call to here, as the prtstr routine needs this
  1022. ; before the config message is sent out.  It has only been moved.
  1023. ;
  1024. IF iobyt            ; (actually, we ought to do this for everybody)
  1025.     call    iniadr    ;Initialize the BIOS addresses
  1026.     mvi    c,gtiob    ;Get current I/O byte
  1027.     call    bdos    ;From CP/M
  1028.     sta    coniob    ;Remember where console is
  1029. ENDIF    ;iobyte [13]
  1030.  
  1031.     mvi    c,getvnm    ; get the BDOS version number (e.g. 22H, 31H)
  1032.     call    bdos
  1033.     mov    a,l
  1034.     sta    bdosvr        ; and store it away for future reference
  1035. ;
  1036.     lxi    d,cfgmsg    ; "configured for "
  1037.     call    prtstr
  1038.     lxi    d,sysver    ; get configuration we're configured for
  1039.     call    prtstr        ; print it.
  1040. ;
  1041. ;    If we're set up to do special terminal handling, say what kind
  1042. ;    of terminal we expect... (unless it's the generic 'crt')
  1043. IF adm3a OR tvi912 OR tvi925 OR vt52 OR vt100 OR smrtvd    OR access;[7] [29]
  1044.     lxi    d,witmsg    ; " with "
  1045.     call    prtstr
  1046.     lxi    d,ttytyp    ; terminal type
  1047.     call    prtstr
  1048. ENDIF;adm3a OR tvi912 OR tvi925 OR vt52 OR vt100 OR smrtvd OR access;[7] [29]
  1049.     call    prcrlf        ; print CR/LF
  1050. ;
  1051. ; now, to work...
  1052. ;
  1053. IF NOT osbrn1            ; locate large buffer for multi-sector I/O
  1054. ; What we want to do here is find the ccp.  Space between ovlend and the ccp
  1055. ; is available for buffering, except we don't want to use more than maxsec
  1056. ; buffers (if we use too many, the remote end could time out while we're
  1057. ; writing to disk).  maxsec is system-dependent, but for now we'll just
  1058. ; use 8Kbytes.  If you get retransmissions and other protocol errors after
  1059. ; transferring the first maxsec sectors, lower maxsec.
  1060.  
  1061. ; I'm excluding the Osborne 1 for now because it needs code up at 4000H,
  1062. ; so we'd have to start the buffer after that.
  1063.  
  1064. maxsec    EQU    (8*1024)/bufsiz    ; 8K / number of bytes per sector
  1065.  
  1066.     lxi    h,ovlend    ; get start of buffer
  1067.     shld    bufadr        ; store in linkage section
  1068.     mvi    a,maxsec    ; get size of buffer, in sectors
  1069.     sta    bufsec        ; store that, too.
  1070. ENDIF;NOT osbrn1
  1071.  
  1072. IF osbrn1
  1073.     lxi    d,ostop        ;where we're moving it to
  1074.     lxi    h,osmove    ;what we're moving
  1075.     mvi    b,osmct        ;How many bytes we're moving
  1076.     call    mover
  1077.     lda    baudrt        ; Find out what speed is current
  1078.     ani    1
  1079.     mvi    a,osbi03    ; assume 300 baud
  1080.     jz    osstr1
  1081.     mvi    a,osbi12    ; nope, it's 1200.
  1082. osstr1:    sta    speed        ; save initial speed
  1083.     sta    speed+1        ;  as 16 bits, to match speed table entries
  1084.     mov    d,a
  1085.     mov    e,a        ; get initial speed in DE
  1086.     call    sysspd        ;set up parity etc.
  1087. ENDIF;osbrn1
  1088.  
  1089. IF bbI OR bbII
  1090.     lxi    d,siotbl    ; Load the address of the status able
  1091.     mvi    c,siolen    ; Length of status table
  1092. siolup:    ;Loop back here for each command byte
  1093.     ldax    d        ; Load the first byte into A
  1094.     inx    d        ; Index the pointer
  1095.     out    mnprts        ; Send it to the status port
  1096.     dcr    c        ; Decrement the byte counter
  1097.     jnz    siolup        ; Jump back for more commands
  1098. ENDIF;bbI or bbII
  1099.  
  1100. IF cpt85xx
  1101.     mvi    a,80h        ; Send UART reset [force idle] by setting
  1102.     out    baudrt        ;    bit 7 of baud rate I/O port
  1103.     lxi    H,0f0fh        ; Clear reset and default to 9600 baud [23]
  1104. ENDIF ;[22] cpt85xx
  1105. ;
  1106. ; [22] Have diced code for advant and cpt85xx together
  1107. ;**************************************************************************
  1108. ;    mvi    a,0Fh        ; Clear reset bit and default to 9600 baud
  1109. ;    out    baudrt
  1110. ;    mvi    a,4Eh        ; Set UART mode to async 16x clock, 8 data
  1111. ;    out    mnprts        ;    bits, no parity, and 1 stop bit
  1112. ;    mvi    a,37h        ; Set command to Tx enable, DTR on, Rx enable,
  1113. ;    out    mnprts        ;    break off, error reset, and RTS on
  1114. ;ENDIF;cpt85xx
  1115. ;**************************************************************************
  1116.  
  1117. IF advant    ;[22]
  1118.     mvi    a,40h
  1119.     out    mnprts        ; Reset USART
  1120.     lxi    h,7070h        ; Default to 1200 baud
  1121. ENDIF;[22] advant
  1122.  
  1123. IF cpt85xx OR advant    ;[22] both Intel 8251
  1124.     shld    speed        ; store current speed
  1125.     xchg
  1126.     call    sysspd        ; set default baud rate
  1127.     mvi    a,4Eh        ; Set UART mode to async 16x clock, 8 data
  1128.     out    mnprts        ;    bits, no parity, and 1 stop bit
  1129.     mvi    a,37h        ; Set command to Tx enable, DTR on, Rx enable,
  1130.     out    mnprts        ;    break off, error reset, and RTS on
  1131. ENDIF;[22] cpt85xx OR advant
  1132.  
  1133. IF bbc        ;[22]
  1134.     lxi    d,modstr    ; Set MODE 3
  1135.     call    prtstr
  1136.     mvi    a,1        ; Set terminal mode on
  1137.     call    term
  1138.     mvi    a,0F2H        ; Read current transmit speed
  1139.     lxi    h,0FF00H    ; .. 3 lsb of ULA register
  1140.     call    osbyte        ;   FX242,0,255
  1141.     mov    a,l
  1142.     ani    7        ; Mask of 3 lsb
  1143.     xri    7        ; Stored as 2's complement
  1144.     inr    a
  1145.     sta    speed        ; Store 16 bit value
  1146.     sta    speed+1
  1147.     mov    e,a        ; Ensure RX and TX speeds are the same
  1148.     call    sysspd
  1149. ENDIF;[22] bbc
  1150.  
  1151. IF rm380z    ;[22]
  1152.     mvi    e,11h        ;Output ctrl-Q to clear autopaging
  1153.     call    outcon
  1154. ENDIF;[22] rm380z
  1155.  
  1156.  
  1157. IF lobo    ;[hh]
  1158.     lxi    d,siotbl    ;[hh] address of status table
  1159.     mvi    c,siolen    ;[hh] length of the table
  1160. siolup:    ;[hh] loop here for each command byte
  1161.     ldax    d        ;[hh] load first byte into A
  1162.     inx    d        ;[hh] index pointer to next bute
  1163.     sta    mnprts        ;[hh] send it to status port A
  1164.     sta    mnprts+2    ;[hh] and to status port B
  1165.     dcr    c        ;[hh] decrement the counter
  1166.     jnz    siolup        ;[hh] loop back for more commands
  1167.     mvi    a,05H        ;[hh] value for 300 baud
  1168.     sta    baudrt        ;[hh] starting default for port A
  1169.     sta    baudrt+4    ;[hh] and for port B
  1170.     sta    speed        ;[hh] tell program they're set
  1171.     mvi    a,0E4H        ;[hh] value for port A
  1172.     sta    port        ;[hh] tell program we've set this, too
  1173.     mvi    a,0D0H        ;[hh] port A baud rate value
  1174.     sta    port+1        ;[hh] save this as well, for consistancy
  1175. ENDIF    ;lobo
  1176.  
  1177. IF mikko
  1178.     lxi    d,mintbl    ;Address of KERMIT Reg values (what)
  1179.     mvi    c,minlen    ;Length of table (how many)
  1180.     lxi    h,sioac        ;Send data to ch. A SIO registers (to where)
  1181.     call    movmik
  1182.     mvi    a,0FFH        ;Set ch. A mask to use all bits
  1183.     sta    chmask
  1184. ENDIF;mikko
  1185.  
  1186. IF brainm            ;[25]
  1187.     lda    baudrt        ; fetch current baud rate
  1188.     ani    0F0H        ; extract left nibble
  1189.     rrc            ; shift right 4 places
  1190.     rrc
  1191.     rrc
  1192.     rrc
  1193.     sta    speed        ; store as comm port speed
  1194.     sta    speed+1        ;  (16 bits, to match speed table entries)
  1195. ENDIF;brainm
  1196.  
  1197. IF braina            ;[25]
  1198.     lda    baudrt        ; fetch current baud rate
  1199.     ani    00FH        ; extract right nibble
  1200.     sta    speed        ; store as comm port speed
  1201.     sta    speed+1        ;  (16 bits, to match speed table entries)
  1202. ENDIF;braina
  1203.  
  1204. IF mdI
  1205.     lxi    h,96        ;Default 1200 baud modem port speed
  1206.     shld    speed        ;Store as modem port speed
  1207.     call    sysspd        ;Initialize the port
  1208. ENDIF;mdI  [Toad Hall]
  1209.  
  1210. IF ap6551
  1211.     lda    mnprtc        ; read control port
  1212.     ani    0fH        ; extract low order nybble
  1213.     sta    speed        ; store as comm line speed
  1214.     sta    speed+1        ;  (16 bits, to match speed table entries)
  1215.     mvi    a,mnminb    ;jb initialization routine
  1216.     sta    mnprts        ;jb
  1217.     sta    mnprtm        ;jb initialize master (command) port
  1218.     mvi    a,mncinb    ;jb
  1219.     sta    mnprtc        ;jb initialize control port
  1220. ENDIF;ap6551
  1221.  
  1222. IF apcps        ;[22]
  1223.     lxi    h,3737h        ;Default 1200 baud
  1224.     shld    speed        ;Store as port speed
  1225.     xchg
  1226.     call    sysspd        ;Initialise the port
  1227. ENDIF;[22] apcps
  1228.  
  1229. IF cifer    ;[13]
  1230.     lxi    d,ciferi
  1231.     call    prtstr
  1232. ENDIF    ;cifer [13]
  1233.  
  1234. IF torch        ;[13]
  1235.     push    h
  1236.     push    d
  1237.     lxi    d,baudini    ; initial buad rate of form ?0?h
  1238.     mvi    a,7        ; osbyte call 7 = receive rate
  1239.     push    d
  1240.     call    osbyt1
  1241.     pop    d        ; now do transmit rate
  1242.     mvi    a,8        ; osbyte call 8
  1243.     call    osbyt1
  1244.     lxi    h,f31        ; enable rs423
  1245.     call    osbyte
  1246.     lxi    h,f22        ; select keyboard, enable rs423
  1247.     call    osbyte
  1248.     lxi    h,f52        ; fx 5,2 to select printer is serial port [30]
  1249.     call    osbyte        ; [30]
  1250.     lxi    h,f60        ; fx 6,0 to send LF to line [30]
  1251.     call    osbyte        ; [30]
  1252.     pop    d
  1253.     pop    h
  1254.     jmp    over        ; [ for debugging use ] [30]
  1255. ;
  1256. ;[30] This is not used, but it may be used later, depending on the Current 
  1257. ;version of the CCCP.  Leave it in for now
  1258.  
  1259. ; add in code to dump 6502 code to the base processor (6502 based machine)
  1260. ; to generate breaks.  Code works ok, from BBC, but how about is triggered 
  1261. ; from this end of the Tube  (Reg. Trade. Mrk)
  1262.  
  1263.     lxi    h,840h        ; gonna stuff the beebs RAM at 840h
  1264.     mvi    b,codeln    ; (Sound buffer) for code length
  1265.     lxi    d,bbccode
  1266. poklop:    ldax    d        ; get data
  1267.     push    h
  1268.     push    d
  1269.     push    b        ; save in case tx to tube messs these
  1270.     call    poke
  1271.     pop    b
  1272.     pop    d
  1273.     pop    h
  1274.     inx    h
  1275.     inx    d
  1276.     dcr    b        ; adjust pointers
  1277.     jnz    poklop        ; send all bytes
  1278. ;
  1279.     lxi    h,0840h        ; now read em back, to make sure it is there
  1280.     lxi    d,tspace
  1281.     mvi    b,codeln
  1282. peklop:    push    h
  1283.     push    d
  1284.     push    b
  1285.     call    peek
  1286.     pop    b
  1287.     pop    d
  1288.     pop    h
  1289.     stax    d        ; save byte in torch space
  1290.     inx    h
  1291.     inx    d
  1292.     dcr    b
  1293.     jnz    peklop        ; loop until all is done
  1294.  
  1295.     jmp    over
  1296.  
  1297.     call    tx        ; send function 6 => write 40 bytes
  1298.     db    6
  1299.     call    tx        ; address is 0840h, so send 083eh
  1300.     db    3eh        ; as lo high combination
  1301.     call    tx
  1302.     db    08h        ; hi bits of target address
  1303.     lxi    h,bbccode    ; bbc code to send
  1304.     mvi    b,40        ; cout is forty
  1305. tbrkinit:            ; Torch break code initialisation...
  1306.     mov    a,m
  1307.     sta    tbrki1        ; little impure code...
  1308.     push    h
  1309.     push    b        ; just in case
  1310.     call    tx
  1311. tbrki1:    db    0        ; fill this in
  1312.     pop    b
  1313.     pop    h
  1314.     inx    h
  1315.     dcr    b        ; count less one
  1316.     jnz    tbrkinit    ; loop til done
  1317.     jmp    over        ;.. the 6502 code
  1318.  
  1319. bbccode:
  1320.     db    0a9h,09ch    ;.BREAK    LDA    #&9c   get original 6850 regs
  1321.     db    0afh,0ffh    ;    LDY    #&FF   by osbyte call
  1322.     db    0a2h,00h    ;    LDX    #0
  1323.     db    20h,0f4h,0ffh    ;    JSR    OSBYTE
  1324.     db    8ah        ;    TXA        save returned byte
  1325.     db    48h        ;    PHA        on the stack
  1326.     db    0a2h,0dch    ;    LDX    #220    Swiped this from BBC
  1327.     db    0a0h,0dch    ;    LDY    #220    Kermit, Lancaster Uni.
  1328.     db    0a9h,77h    ;.LOOP    LDA    #77    (If it works, use it)
  1329.     db    8dh,08h,0feh    ;.LOOP    STA    &FE08    reset 6850 regs
  1330.     db    88h        ;    DEY        counter
  1331.     db    0d0h,0fah    ;    BNE    LOOP
  1332.     db    0cah        ;    DEX
  1333.     db    0d0h,0f7h    ;    BNE    LOOP    loads of loops
  1334.     db    68h        ;    PLA        get original x back
  1335.     db    0aah        ;    TAX        to x reg
  1336.     db    0a9h,09ch    ;    LDA    #&9c    Osbyte to restore it
  1337.     db    0a0h,00h    ;    LDY    #0    (reg AND Y) EXOR X
  1338.     db    20h,0f4h,0ffh    ;    JSR    OSBYTE
  1339.     db    060h        ;    RTS        hopefully back across
  1340.                 ;            the tube to torch
  1341.     db    '                    '    ; 20 spaces
  1342.     db    '                    '    ; any left over wont be sent
  1343. codeln    equ    $-bbccode
  1344.  
  1345. tspace:    db    '                    '    ; fill space with muck
  1346.     db    '                    '    ; to make sure peeks and pokes work
  1347.  
  1348. over:                ; just a label
  1349. ENDIF ;torch [13]
  1350.  
  1351. IF pci2651        ;[28]
  1352.     in    mncmd        ; clearw command reg counter
  1353.     mvi    a,4eh        ; 1 stop bit, 8 data bits, / by 16 counter
  1354.     out    mnmode
  1355.     mvi    a,30h+baudini    ; baud rate and select internal rate gen.
  1356.     out    mnmode
  1357.     mvi    a,27h        ; enable tx and rx, RTS and DTR low
  1358.     out    mncmd
  1359. ENDIF    ; pci2651 [28]
  1360.  
  1361. IF norths
  1362.     mvi    a,baudini    ;Get initial speed
  1363.     out    baudrt
  1364.     sta    speed        ;save for status display
  1365.     sta    speed+1
  1366. ENDIF;norths
  1367.  
  1368. IF comart OR horizon        ;[25]
  1369. ; The PD8251/PD8251A is reset by three successive 00 Hex or two
  1370. ; successive 80 Hex command instructions followed by a software
  1371. ; reset command instruction (40 Hex).
  1372.     mvi    a,80h        ; Send UART reset
  1373.     out    mnprts
  1374.     mvi    a,80h
  1375.     out    mnprts
  1376.     mvi    a,40h
  1377.     out    mnprts
  1378.     mvi    a,4Eh        ; Set UART mode to async 16x clock, 8 data
  1379.     out    mnprts        ;    bits, no parity, and 1 stop bit
  1380.     mvi    a,37h        ; Set command to Tx enable, DTR on, Rx enable,
  1381.     out    mnprts        ;    break off, error reset, and RTS on
  1382. ENDIF;comart OR horizon
  1383.  
  1384. IF cmemco            ;[25]
  1385.     mvi    a,01h        ; Reset TU-ART
  1386.     out    tuart+2
  1387.     mvi    a,90h        ; Set default baud rate (2400), and 1 stop bit
  1388.     out    tuart
  1389.     sta    speed        ; save for status display
  1390.     sta    speed+1
  1391. ENDIF;cmemco
  1392.  
  1393. IF delphi            ;[7]
  1394. ;
  1395. ;    shove the default baud rate (1200) in to the Delphi port address
  1396. ;    for the baud rate generator on port 2, the default port; save this
  1397. ;    value so we can tell what speed is selected.
  1398. ;
  1399.     mvi    a,07h        ;[7] get value for 1200 baud
  1400.     out    baudrt        ;[7] set it for port 2
  1401.     sta    speed        ;[7] save for status display
  1402.     sta    speed+1
  1403. ENDIF;[7] delphi
  1404.  
  1405. IF px8 ; [29]
  1406.         lda     0f6a9h          ; get baud rate value set by CONFIG
  1407.         sta     px8blk+4        ; put into parameter block
  1408.         mov     h, a            ; initialise global speed indicator
  1409.         mov     l, a
  1410.         shld    speed
  1411.         lhld    6               ; base of CP/M
  1412. ; buffer starts at ovlend+8192, immediately after sector buffer
  1413. ; We must also allow (800h) for the CCP as Kermit exits with a RET
  1414.         lxi     d, ovlend+8192+800h  ; calc buffer length
  1415.         ora     a               ; clear carry
  1416.         db      0edh, 52h       ; sbc hl, de
  1417.         shld    px8blk+2
  1418.         call    rsopen
  1419. ENDIF ; px8 [29]
  1420.  
  1421. IF disc    ;[29]
  1422. ;Initialization sequence for Discovery 83U port B
  1423. ;Sets port to 9600 baud, 8 data bits, 1 stop bit, no parity
  1424.     mvi    a,12        ;Register 12
  1425.     out    mnprts
  1426.     mvi    a,11        ;Low byte of time constant for 9600
  1427.     out    mnprts
  1428.     mvi    a,13        ;Register 13
  1429.     out    mnprts
  1430.     mvi    a,0        ;High byte of time constant for 9600
  1431.     out    mnprts
  1432.     mvi    a,14        ;Register 14
  1433.     out    mnprts
  1434.     mvi    a,3        ;Enable baud rate generator
  1435.     out    mnprts
  1436.     mvi    a,11        ;Register 11
  1437.     out    mnprts
  1438.     mvi    a,52h        ;No Xtal, tclk=rclk=/trxc out=br gen
  1439.     out    mnprts
  1440.     mvi    a,4        ;Register 4
  1441.     out    mnprts
  1442.     mvi    a,44h        ;16x clock, 1 stop, no parity
  1443.     out    mnprts
  1444.     mvi    a,3        ;Register 3
  1445.     out    mnprts
  1446.     mvi    a,71h        ;rx 8 bit/ch, autoenable, rx enable
  1447.     out    mnprts
  1448.     mvi    a,5        ;Register 5
  1449.     out    mnprts
  1450.     mvi    a,0eah        ;tx 8 bit/ch, tx enable, rts
  1451.     out    mnprts
  1452. ENDIF;disc [29]
  1453.  
  1454.  
  1455. IF heath
  1456. ;
  1457. ;    System dependent startup for H89
  1458. ;
  1459.  
  1460.     call    mdmofl        ; keep the line safe from garbage
  1461.  
  1462. ;    First, tell Kermit the modem port's current speed
  1463.     in    mnport+acelcr
  1464.     ori    acedla
  1465.     out    mnport+acelcr    ; access the ACE's divisor latch
  1466.     in    mnport+acedll    ; get the low byte
  1467.     sta    speed
  1468.     in    mnport+acedlh    ; and the high byte
  1469.     sta    speed+1
  1470.  
  1471. ;    Now set up the port for Kermit
  1472.     mvi    a,ace8bw    ; 8 data bits, 1 stop bit, no parity
  1473.     out    mnport+acelcr
  1474.     in    mnport+acemcr
  1475.     ori    acedtr        ; raise DTR (just in case)
  1476.     out    mnport+acemcr
  1477.     call    mdmonl        ; and put the ACE back on line
  1478.     ret
  1479.  
  1480. ;    Take the ACE off line before modifying its state
  1481. mdmofl:
  1482.     in    mnport+aceier    ; save the ACE's interrupt state
  1483.     sta    iersav
  1484.     xra    a
  1485.     out    mnport+aceier    ; and disable ACE interrupts
  1486.     in    mnport+acemcr    ; now put the ACE in loopback mode
  1487.     ori    aceloo
  1488.     out    mnport+acemcr
  1489.     ret
  1490.  
  1491. ;    Put the ACE back on line
  1492. mdmonl:
  1493.     in    mnport        ; flush left-over garbage in the receive buffer
  1494.     mvi    a,7        ; wait about 2 300-baud character times
  1495.     call    delay
  1496.     in    mnport        ; and flush more garbage
  1497.     in    mnport+acemcr    ; take the ACE out of loopback mode
  1498.     ani    0FFH-aceloo
  1499.     out    mnport+acemcr
  1500.     lda    iersav
  1501.     out    mnport+aceier    ; and restore the ACE's interrupt state
  1502.     ret
  1503.  
  1504. iersav:    ds    1
  1505. ENDIF;heath
  1506.  
  1507.     ret            ; return from system-dependent routine
  1508.  
  1509. bdosvr:    ds    1        ; space to save the BDOS version number
  1510.  
  1511.  
  1512. IF iobyt
  1513. ;    This one is hopefully the last "improvement" in view of GENERIC
  1514. ;Kermit. It uses for Character-I/O the BIOS-routines ( instead of the
  1515. ;"normal" BDOS routines. What does it give us (hopefully) : More speed,
  1516. ;higher chance of success ( I/O byte implemented in BIOS [if at all]),
  1517. ;but no "extra" device handling - that's done by BDOS.
  1518. ;
  1519. ;    How do we "get" the call-adresses?  Location 0 has a JMP Warm-Boot
  1520. ;in CP/M which points into the second location of the BIOS JMP-Vector.  The
  1521. ;next three locations of the JMP-Vector point to the CONSTAT,CONIN,CONOUT
  1522. ;BIOS-routines.  CONOUT wants the character in C.
  1523. ;
  1524. ;- Bernie Eiben
  1525.  
  1526. iniadr:    lhld    1        ;get BIOS Warmstart-address
  1527.     lxi    d,3        ;next adress is CONSTAT in BIOS
  1528.     dad    d
  1529.     shld    bconst+1    ;stuff it into the call-instruction
  1530.     lxi    d,3        ;next adress is CONIN in BIOS
  1531.     dad    d
  1532.     shld    bconin+1    ;
  1533.     lxi    d,3        ;next adress is CONOUT in BIOS
  1534.     dad    d
  1535.     shld    bcnout+1
  1536.     lxi    d,3        ;next address is LIST in BIOS
  1537.     dad    d
  1538.     shld    blsout+1
  1539.     ret            ;And return
  1540.  
  1541. bconst:    jmp    $-$        ;Call BIOS directly (filled in by iniadr)
  1542.  
  1543. bconin:    jmp    $-$        ;Call BIOS directly (filled in by iniadr)
  1544.  
  1545. bcnout:    jmp    $-$        ;Call BIOS directly (filled in by iniadr)
  1546.  
  1547. blsout:    jmp    $-$        ; ....
  1548. ENDIF;iobyt
  1549.  
  1550. IF mikko            ;currently for MIKROMIKKO only
  1551. ; copy command block into memory-mapped SIO.
  1552. movmik:    di            ;disable interrupts
  1553. movmk1:    ldax    d        ;Get a register value
  1554.     mov    m,a        ;Output it
  1555.     inx    d        ;Next value
  1556.     dcr    c        ;Decrement counter
  1557.     jnz    movmk1        ;Repeat until done
  1558.     ei
  1559.     ret
  1560. ENDIF;mikko
  1561.  
  1562. IF osbrn1
  1563. osmove:
  1564. osflag    equ    0EF08H        ;Osborne 1 Bank-2 flag
  1565. ;
  1566. ; return modem status in A
  1567. ;
  1568. OSLDST    EQU    ostop-osmove+$
  1569.     DI
  1570.     OUT    0
  1571.     LDA    osprts        ;Read the status port
  1572.     OUT    1
  1573.     EI
  1574.     ret
  1575. ;
  1576. ; set modem status from A
  1577. ;
  1578. OSSTST    equ    ostop-osmove+$
  1579.     DI
  1580.     OUT    0
  1581.     STA    osprts    ;Write the control port
  1582.     jmp    osstex
  1583. ;
  1584. ; read character from modem into A
  1585. ;
  1586. OSLDDA    equ    ostop-osmove+$
  1587.     DI
  1588.     OUT    0
  1589.     LDA    osport
  1590.     OUT    1
  1591.     EI
  1592.     ret
  1593. ;
  1594. ;    output character in A to modem
  1595. ;
  1596. OSSTDA    equ    ostop-osmove+$
  1597.     DI
  1598.     OUT    0
  1599.     STA    osport
  1600. osstex    equ    ostop-osmove+$
  1601.     OUT    1
  1602.     mvi    a,1
  1603.     sta    osflag
  1604.     EI
  1605.     ret
  1606. osmct    equ    $-osmove
  1607. ENDIF;osbrn1
  1608.  
  1609. IF bbI OR bbII OR lobo
  1610. ; List of commands to set up SIO channel A for asynchronous operation.
  1611. siotbl:    DB    18H        ; Channel reset
  1612.     DB    18H        ; another, in case register 0 wasn't selected
  1613.     DB    04H        ; Select register 4
  1614.     DB    44H        ; 1 stop bit, clock*16
  1615.      DB    01H        ; Select register 1
  1616.     DB    00H        ; No interrupts enabled
  1617.      DB    03H        ; Select register 3
  1618.      DB    0C1H        ; Rx enable, 8 bit Rx character
  1619.      DB    05H        ; Select register 5
  1620.      DB    0EAH        ; Tx enable, 8 bit Tx character,
  1621.                  ;  raise DTR and RTS
  1622. siolen    equ    $-siotbl    ; length of command list
  1623. ENDIF;bbI or bbII OR lobo
  1624.  
  1625. IF mikko
  1626. ; command list to set SIO chip back to normal state
  1627. miotbl:    db    3        ;reg. 3
  1628.     db    sioo3
  1629.     db    5        ;reg. 5
  1630.     db    sioo5
  1631.     db    4        ;reg. 4
  1632.     db    sioo4
  1633.     db    0        ;reselect reg. 0
  1634. miolen    equ    $-miotbl    ;MikroMikko SIO table length (original values)
  1635.  
  1636. ; command list to set up SIO chip for operation with Kermit
  1637. mintbl:    db    3        ;reg. 3
  1638.     db    sion3
  1639.     db    5        ;reg. 5
  1640.     db    sion5
  1641.     db    4        ;reg. 4
  1642.     db    sion4
  1643.     db    0        ;reselect reg. 0
  1644. minlen    equ    $-mintbl    ;MikroMikko SIO table length (KERMIT values)
  1645. ENDIF;mikko
  1646.  
  1647.  
  1648. IF bbc        ;[22]
  1649. modstr:    db    16h,03h,'$'    ; String to put screen into MODE 3
  1650. ENDIF
  1651.  
  1652. IF px8 ; [29]
  1653. rsget:  mvi     b, 50h
  1654.         jmp     rsiox
  1655. rsinst: mvi     b, 30h
  1656.         jmp     rsiox
  1657. rsput:  mvi     b, 60h
  1658.         jmp     rsiox
  1659. rsoutst:mvi     b, 40h
  1660.         jmp     rsiox
  1661. rserst: mvi     b, 90h
  1662.         jmp     rsiox
  1663. rsopen: lxi     h, px8blk       ; copy px8blk to px8prm
  1664.         lxi     d, px8prm
  1665.         lxi     b, 9
  1666.         call    mover
  1667.         mvi     b, 10h          ; open code
  1668.         jmp     rsiox
  1669. rsclose:mvi     b, 20h          ; close code
  1670. rsiox:  lxi     h, px8prm
  1671.         lxi     d, 51h          ; offset into BIOS jump table
  1672.         push    h
  1673.         lhld    1               ; start of BIOS
  1674.         dad     d
  1675.         xthl                    ; entry point on stack, px8prm addr in hl
  1676.         ret                     ; jump indirect
  1677.  
  1678. px8prm: dw      0, 0
  1679.         db      0, 0, 0, 0, 0   ; the param area is overwritten in rsopen
  1680. px8blk: dw      ovlend+8192     ; buffer address
  1681.         dw      0               ; buffer size - overwritten
  1682.         db      0               ; baud rate - overwritten
  1683.         db      3               ; 8 bits/char
  1684.         db      0               ; no parity, it is done internally
  1685.         db      1               ; 1 stop bit
  1686.         db      0cfh            ; special bits - activate xon/xoff
  1687. ; The documentation suggests that the xon/xoff bit is bit 4, i.e the pattern
  1688. ; should be 0efh, but the top bit is omitted from the diagram. I will try
  1689. ; clearing both bit 4 and bit 5.
  1690. ENDIF ; px8 [29]
  1691.  
  1692. ;
  1693. ;    system-dependent termination processing
  1694. ;    If we've changed anything, this is our last chance to put it back.
  1695. sysexit:
  1696. IF mikko
  1697.     lxi    d,miotbl    ;Load the adress of original reg values
  1698.     mvi    c,miolen    ;Length of table
  1699.     lxi    h,sioac        ;Send data to ch A SIO registers
  1700.     call    movmik
  1701.     mvi    a,07FH        ;Set ch A mask to use just 7 bits
  1702.     sta    chmask
  1703. ENDIF;mikko
  1704.  
  1705. IF cpt85xx
  1706.     mvi    a,80h        ; Reset (force idle) the 8251 UART via bit 7
  1707.     out    baudrt        ;    of the baud rate generater port
  1708.     mvi    a,00h        ; and turn off the baud rate generater
  1709.     out    baudrt
  1710. ENDIF;cpt85xx
  1711.  
  1712. IF bbc    ;[22]
  1713.     mvi    a,0        ; Turn off terminal mode
  1714.     call    term
  1715. ENDIF;[22] bbc
  1716.  
  1717. IF px8    ;[29]
  1718.     call    rsclose
  1719. ENDIF    ;px8 [29]
  1720.  
  1721.     ret
  1722.  
  1723. ;
  1724. ;    system-dependent processing for start of CONNECT command
  1725. ;
  1726. syscon:
  1727. IF apmmdm
  1728.     call    ckdial        ;See if dialing is required.
  1729.      jmp    kermit        ;Go to command loop if aborted.
  1730. ENDIF;apmmdm
  1731.  
  1732. IF robin OR trs80 OR cpt85xx    ;For Robin/TRS80/CPT-85xx, add some more info
  1733.     lxi    d,conmsg    ; about obscure key combinations
  1734.     call    prtstr
  1735. ENDIF;robin OR trs80 OR cpt85xx
  1736.  
  1737. IF osbrn1            ;*** This is Software dependent ***
  1738.     lhld    1        ;Modify back-arrow code to DELETE
  1739.     mvi    l,0        ;Get BIOS-start address
  1740.     lxi    d,85H        ;Adress for key-code = XX85H
  1741.     dad    d
  1742.     mov    e,m        ;Get it in DE
  1743.     inx    h
  1744.     mov    d,m
  1745.     xchg            ;Memory pointer to HL
  1746.     mvi    m,del        ;modify the code
  1747. ENDIF;osbrn1
  1748.     ret
  1749.  
  1750. conmsg:        ; Messages printed when entering transparent (CONNECT) mode:
  1751. IF robin    ;  for Robin, control-S key is hidden
  1752.     db    ' (Type Left Arrow to send CTRL-S)',cr,lf,'$'
  1753. ENDIF;robin
  1754. IF trs80    ;  for TRS-80, the preferred escape key is hidden
  1755.     db    ' (Control-_ is the Down-Arrow key on the TRS-80 keyboard)'
  1756.     db    cr,lf,'$'
  1757. ENDIF;trs80
  1758. IF cpt85xx    ;  for CPT-85xx, some graphics map "funny" to keyboard in CP/M
  1759.     db    ' (Use  CODE + SHIFT + 1/2  key to generate a Control-\)'
  1760.     db    cr,lf,'$'
  1761. ENDIF;cpt85xx
  1762.  
  1763. IF apmmdm
  1764. ;This code was mostly taken from
  1765. ;    APMODEM.ASM V2.1
  1766. ;    Based on MODEM.ASM by Ward Christensen
  1767. ;    Modified for the Apple ][ by Gordon Banks 1-Jan-81
  1768. ;    Micromodem ][ dialer option by Dav Holle  2-Feb-81
  1769. ;    Code modified for KERMIT by Scott Robinson 14-Oct-82
  1770. ;
  1771. ;Come here to see if we need to dial a number.
  1772. ;
  1773. ckdial:    lda    mnport        ;access the data port
  1774.     lda    mnprts        ;check status
  1775.     ani    4        ;do we already have carrier?
  1776.     jz    rskp        ;Yes, just continue
  1777.     xra     a        ;Hangup Phone for starters
  1778.     sta    mnmodm
  1779.     lxi    b,1000        ;Delay for a second
  1780.     call    delay
  1781.     mvi    a,8FH        ;orgmod+ap300+apoffh
  1782.     sta    holdd        ;storing mode for after dialing
  1783.     mvi    A,8DH        ;Go Offhook to start dialing sequence
  1784.     sta    mnmodm
  1785.     mvi    a,apinc1    ;Init ACIA
  1786.     sta    mnport
  1787.     mvi    a,apinc2    ;Set ACIA bits per character
  1788.     sta    mnport
  1789.  
  1790.     lxi    b,2500        ;wait 2.5 seconds for dial tone
  1791.     call    delay
  1792.     lxi    d,dialms    ;Ask the user for the number
  1793.     call    prtstr
  1794. ;
  1795. gtdial: mvi    c,conin        ;Get a character
  1796.     call    bdos
  1797.     push    psw        ;save it
  1798.     cpi    30H        ;is it big enough to dial?
  1799.     jc    dialed        ;no
  1800.     cpi    3AH        ;is it too big to dial?
  1801.     jnc    dialed        ;yes
  1802.     ani    0FH        ;ok, it's a digit, get its value
  1803.     jnz    dialnz        ;dial nonzero digits as-is
  1804.     mvi    A,10        ;dial zero as ten
  1805. ;
  1806. dialnz:    mov    e,a        ;count pulses in E-reg
  1807. dopuls: mvi    a,0DH        ;put it on-hook
  1808.     sta    mnmodm
  1809.     lxi    b,61        ;61-millisec pulse
  1810.     call    delay
  1811.     mvi    a,8DH        ;take it off-hook again...
  1812.     sta    mnmodm
  1813.     lxi    b,39        ;39-millisec delay between pulses
  1814.     call    delay
  1815.     dcr    e        ;any more pulses to do?
  1816.     jnz    dopuls        ;yep, do 'em
  1817.     lxi    b,600        ;delay 600 msecs between digits
  1818.     call    delay
  1819. ;
  1820. dialed:    pop    psw        ;get back the char
  1821.     cpi    cr        ;do we have a CR (done dialing)?
  1822.     jnz    gtdial        ;no, keep on dialin'
  1823.     lxi    d,dialm2
  1824.     call    prtstr
  1825.  
  1826. tictoc: mvi    c,dconio    ;Direct console input.
  1827.     mvi    e,0FFH
  1828.     call    bdos
  1829.     ora    a        ;Have a charcter?
  1830.     jnz     nodial        ;If so we abort
  1831.     lda    mnport         ;access the data port
  1832.     lda    mnprts        ;get modem status
  1833.     ani    4        ;carrier?
  1834.     jnz    tictoc        ;No
  1835. ;
  1836.     lda    holdd        ;get the old modem control byte
  1837.     sta    mnmodm        ;turn our carrier on
  1838.  
  1839.     lxi    d,dialm3
  1840.     call    prtstr
  1841.     jmp    rskp
  1842. nodial: xra    a        ;Hangup the modem.
  1843.     sta    mnmodm
  1844.     ret            ;Return to abort the command.
  1845. ;
  1846. holdd:    db    0        ;Modem setup code
  1847. dialms:    DB    'Number to Dial: $'
  1848. dialm2:    DB    CR,LF,'Awaiting Carrier....(any key aborts)$'
  1849. dialm3:    DB    cr,lf,'Connected.',CR,LF,'$'
  1850. ;
  1851. ;DELAY wait for the number of millisecs in B,C
  1852. ;
  1853. delay:,    push    b        ;save B,C
  1854.     push    d        ;save D,E
  1855.     inr    b        ;bump B for later DCR
  1856. ;
  1857. delay1:    mvi    e,126        ;delay count for 1 millisec (Apple Z80
  1858.                 ;clock=2.041MHz)
  1859. ;
  1860. delay2:    dcr    e        ;count
  1861.     jnz    delay2        ;down
  1862. ;
  1863.     dcr    c        ;more millisecs?
  1864.     jnz    delay1        ;yes
  1865.     dcr    b        ;no - more in hi byte?
  1866.     jnz    delay1        ;yes
  1867.     pop    d        ;no,    restore D,E
  1868.     pop    b        ;    restore B,C
  1869.     ret
  1870. ENDIF;apmmdm
  1871.  
  1872. ;
  1873. ;    syscls - system-dependent close routine
  1874. ;    called when exiting transparent session.
  1875. ;
  1876. syscls:
  1877. IF osbrn1
  1878.     lhld    1        ;Modify back-arrow code to BACKSPACE
  1879.     mvi    l,0        ;Get BIOS address
  1880.     lxi    d,85H        ;Address for key-code =XX85H
  1881.     dad    d
  1882.     mov    e,m        ;Get it in DE
  1883.     inx    h
  1884.     mov    d,m
  1885.     xchg            ;Address to HL
  1886.     mvi    m,bs        ;Modify code
  1887. ENDIF;osbrn1
  1888.     ret
  1889.  
  1890. ;
  1891. ;    sysinh - help for system-dependent special functions.
  1892. ;    called in response to <escape>?, after listing all the
  1893. ;    system-independent escape sequences.
  1894. ;
  1895. sysinh:
  1896. IF apmmdm OR robin OR dmII OR bbII OR bbI OR cpt85xx OR heath OR lobo OR torch OR brain ;[16] [18]
  1897.     lxi    d,inhlps    ; we got options...
  1898.     call    prtstr        ; print them.
  1899. ENDIF;apmmdm OR robin OR dmII OR bbII OR bbI OR cpt85xx OR heath OR lobo OR torch OR brain [16] [18]
  1900.  
  1901. IF advant OR apcps OR bbc OR rm380z OR comart OR horizon ;[22] [25] [29] some more
  1902.     lxi    d,inhlps    ; we got options...
  1903.     call    prtstr        ; print them.
  1904. ENDIF;[22] advant OR apcps OR bbc OR rm380z OR comart OR horizon [29]
  1905.  
  1906. IF px8 OR pci2651 OR access OR mmate OR disc ;[28] [29] and more...
  1907.     lxi    d,inhlps    ; we got options...
  1908.     call    prtstr        ; print them.
  1909. ENDIF    ;px8 OR pci2651 OR access OR mmate OR disc [28] [29]
  1910.  
  1911.     ret
  1912.  
  1913.  
  1914. ;additional, system-dependent help for transparent mode
  1915. ; (two-character escape sequences)
  1916. inhlps:
  1917.  
  1918. ; [16] [18] have added super brain and Torch to the list of Breaking machines.
  1919. IF robin OR dmII OR bbII OR bbI OR cpt85xx OR heath OR lobo
  1920.     db    cr,lf,'B  Transmit a BREAK'
  1921. ENDIF;robin OR dmII OR bbII OR bbI OR cpt85xx OR heath OR lobo 
  1922.  
  1923. IF advant OR apcps OR bbc OR rm380z OR comart OR horizon ; [22] [25]  ... some more
  1924.     db    cr,lf,'B  Transmit a BREAK'
  1925. ENDIF;[22] advant OR apcps OR bbc OR rm380z OR comart OR horizon
  1926.  
  1927. IF pci2651 OR brain OR torch OR px8 OR access OR mmate ;[28] [29] Breaks also for...
  1928.     db    cr,lf,'B  Transmit a BREAK'
  1929. ENDIF    ;pci2651 OR brain OR torch OR px8 OR access OR mmate [28] [29]
  1930.  
  1931. IF disc    ;[29]
  1932.     db    cr,lf,'B Transmit a 300ms BREAK'
  1933.     db    cr,lf,'L Transmit a 5 second BREAK'
  1934. ENDIF;disc [29]
  1935.  
  1936. IF apmmdm OR heath OR lobo
  1937.     db    cr,lf,'D  Drop the line'
  1938. ENDIF;apmmdm OR heath OR lobo
  1939.  
  1940.     db    '$'            ;[hh] table terminator
  1941.  
  1942. ;
  1943. ;    sysint - system dependent special functions
  1944. ;    called when transparent escape character has been typed;
  1945. ;    the second character of the sequence is in A (and in B).
  1946. ;    returns:
  1947. ;    non-skip: sequence has been processed
  1948. ;    skip:    sequence was not recognized
  1949. sysint:    ani    137O        ; convert lower case to upper, for testing...
  1950. IF apmmdm
  1951.     cpi    'D'        ;Disconnect Modem?
  1952.     jnz    intc00        ;No.
  1953.     xra    a        ;Yes, hangup the modem
  1954.     sta    mnmodm
  1955.     ret            ; command has been executed
  1956. intc00:
  1957. ENDIF;apmmdm
  1958.  
  1959. IF heath
  1960.     cpi    'D'        ; drop line?
  1961.     jnz    intc00        ; no:  try next function character
  1962.  
  1963. mdmdrp:    in    mnport+acemcr    ; (we also get here from sysbye)
  1964.     ani    0FFH-acedtr
  1965.     out    mnport+acemcr    ; yes: drop DTR
  1966.     mvi    a,50        ;      for half a second
  1967.     call    delay
  1968.     in    mnport+acemcr
  1969.     ori    acedtr
  1970.     out    mnport+acemcr    ;      and then restore it
  1971.     ret
  1972. intc00:
  1973. ENDIF;heath
  1974.  
  1975. ; [19] have added superbrain and torch to the list
  1976. IF robin OR dmII OR bbI OR bbII OR cpt85xx OR heath OR lobo OR brain 
  1977.     cpi    'B'        ; send break?
  1978.     jz    sendbr        ; yes, go do it.  return nonskip when through.
  1979. ENDIF;robin OR dmII OR bbI OR bbII OR cpt85xx OR heath OR lobo OR brain
  1980.  
  1981. IF advant OR apcps OR bbc OR rm380z OR comart OR horizon    ; [22] [25] ... some more
  1982.     cpi    'B'        ; send break?
  1983.     jz    sendbr        ; yes, go do it.  return nonskip when through.
  1984. ENDIF;[22] advant OR apcps OR bbc OR rm380z OR comart OR horizon
  1985.  
  1986. IF pci2651 OR torch OR px8 OR access OR mmate ;[28] [29] and anothers
  1987.     cpi    'B'        ; send break?
  1988.     jz    sendbr        ; yes, go do it.  return nonskip when through.
  1989. ENDIF    ;pci2651 OR torch OR px8 OR access OR mmate [28] [29]
  1990.  
  1991. IF lobo    ;[hh]
  1992.     cpi    'D'        ;[hh] disconnect?
  1993.     jz    discon        ;[hh] yes, go do it. nonskip return when done.
  1994. ENDIF    ;lobo
  1995.  
  1996. IF disc    ;[29]
  1997.     cpi    'B'        ;Send short break?
  1998.     jz    sendbr
  1999.     cpi    'L'        ;Send long break?
  2000.     jz    sendlbr
  2001. ENDIF;disc [29]
  2002.  
  2003.     jmp    rskp        ; take skip return - command not recognized.
  2004.  
  2005.  
  2006.  
  2007. IF robin ;Definitions & code to send a BREAK (ungenerically, no other way).
  2008.  
  2009. comctl    equ    59h        ;VT180 communications port
  2010. crtctl    equ    41h        ;VT180 crt port
  2011.  
  2012. ;VT180 serial port command bits
  2013.  
  2014. txe    equ    1        ;transmit enable
  2015. dtr    equ    2        ;dtr on
  2016. rxe    equ    4        ;rx enable
  2017. sndbrk    equ    8
  2018. rerr    equ    10h        ;reset error
  2019. rts    equ    20h        ;RTS on
  2020. reset    equ    40h        ;port reset
  2021.  
  2022. ;Send a break to the communications port.
  2023. ;
  2024.  
  2025. sendbr:    lxi    h,38500        ;250 ms(?)
  2026.     lda    prtadr        ;Get address of selected port
  2027.     mov    c,a        ;Into C
  2028.     mvi    a,sndbrk+dtr
  2029. ;    OUT    C,A        ;Want to send to port addressed by C
  2030.     db    0EDH,079H    ;Op code for above instruction
  2031. sndbr1:    dcx    h        ;timing loop...
  2032.     mov    a,l
  2033.     ora    h
  2034.     jnz    sndbr1        ;...until over
  2035.     lda    prtadr        ;Get the address for the port
  2036.     mov    c,a        ;Into C
  2037.     mvi    a,txe+dtr+rxe+rerr+rts    ;enable tr/rc, dtr, reset error
  2038. ;    out    c,a        ;Z-80 only instruction
  2039.     db    0EDH,079H    ;Op code for above instruction
  2040.     out    contst        ;reset ports
  2041.     ret
  2042. ENDIF;robin
  2043.  
  2044. IF dmII                ;[jd] this added to send break on DECmate
  2045.  
  2046. ; DECmate command codes for 6120 I/O processor
  2047. oboff    equ    3fh        ; offset of outbyt routine for 6120
  2048. prtctl    equ    02h        ; port control
  2049. brdat    equ    06h        ; data to tell 6120 to send a break
  2050. brdur    equ    30        ; duration, 30 = 300 ms.
  2051.  
  2052. sendbr:    lxi    b,(brdat * 100h) + prtctl ; c/prtctl, b/brdat
  2053.     call    outbyt
  2054.     lxi    b,brdur*100h        ; b/duration, c/0
  2055. ;    fall through into outbyt
  2056.  
  2057. outbyt:    lhld    1        ; get warm boot address
  2058.     lxi    d,oboff        ; offset of outbyt routine
  2059.     dad    d        ; compute address
  2060.     pchl            ; branch there (a callret)
  2061.  
  2062. ENDIF;dmII
  2063.  
  2064. IF bbI OR bbII OR access OR mmate ;[cjc] send break on Kaypro and bbII [29]
  2065. ; Officially, a "break" is 300 milliseconds of "space" (idle line is
  2066. ; "mark").  (or maybe 200 milliseconds; I forget.)  The timing isn't
  2067. ; usually that critical, but we'll make an attempt, at least.  Sending
  2068. ; too long a break can cause some modems to hang up.
  2069.  
  2070. sendbr:
  2071. ;    First, make sure the transmitter is really empty.  (The SIO sets
  2072. ;    "transmitter buffer empty" when it can accept another character;
  2073. ;    the previous character is still being shifted onto the line.
  2074. ;    Another status bit, "all done", is set to indicate that the
  2075. ;    transmitter is really idle.
  2076. sndbr1:    mvi    a,1        ; select Read Register 1
  2077.     out    mnprts
  2078.     in    mnprts        ; read the contents
  2079.     ani    1        ; test "all done" flag
  2080.     jz    sndbr1        ; loop until it's nonzero.
  2081. ;
  2082. ;    Next, set the "send break" bit to start the transmitter spacing.
  2083.     mvi    a,5        ; select Write Register 5
  2084.     out    mnprts
  2085.     mvi    a,0FAH        ; Tx enable, 8 bit Tx character, Send Break,
  2086.     out    mnprts        ;  DTR and RTS on.
  2087. ;
  2088. ;    Now, delay for 30 hundredths of a second
  2089.     mvi    a,30        ; delay count
  2090.     call    delay
  2091. ;
  2092. ;    Time's up. Put transmitter back in normal state (data byte is the
  2093. ;    same as the one in siotbl: for Write Register 5) and return.
  2094.     mvi    a,5        ; select Write Register 5
  2095.     out    mnprts
  2096.     mvi    a,0EAH        ; Tx enable, 8 bit Tx character,
  2097.     out    mnprts        ;  DTR and RTS on.
  2098.     ret            ; done.
  2099. ENDIF;bbI OR bbII OR access OR mmate [29]
  2100.  
  2101. IF lobo    ;[hh]     This routine sends a break tone or disconnects a modem
  2102. ;        (those that respond to it) by setting the DTR line low
  2103. ;        for 300 ms.
  2104. ;
  2105. sendbr:    mvi    a,05H        ;[hh] write register 5
  2106.     call    outctl        ;[hh] send it to control port
  2107.     mvi    a,0FAH        ;[hh] value to send break tone
  2108.     jmp    sndbr1        ;[hh]
  2109. ;
  2110. discon:    mvi    a,05H        ;[hh] write register 5
  2111.     call    outctl        ;[hh] send it to the control port
  2112.     mvi    a,06AH        ;[hh] DTR off and break tone on
  2113. sndbr1:    call    outctl        ;[hh] send to control port
  2114.     mvi    a,30        ;[hh] delay count for 300 ms.
  2115.     call    delay        ;[hh] wait a while...
  2116.     mvi    a,05H        ;[hh] write register 5
  2117.     call    outctl        ;[hh] get it's attention
  2118.     mvi    a,0EAH        ;[hh] normal 8 bits, DTR on, RTS on, etc.
  2119.     call    outctl        ;[hh] restore SIO
  2120.     ret
  2121. ;
  2122. outctl:    sta    mnprts        ;[hh]
  2123.     ret
  2124. ENDIF    ;lobo
  2125.  
  2126.  
  2127. IF cpt85xx OR advant OR rm380z OR brain OR comart OR horizon    ;[lmj] [22] [25]
  2128. sendbr:
  2129. ;
  2130. ;    Ensure that the transmitter has finished sending buffered chars
  2131. sndbr1:    in    mnprts        ; get UART status
  2132.     ani    TxEmpty        ; everything sent?
  2133.     jz    sndbr1        ; no, wait a bit more
  2134. ;
  2135. ;    Begin sending a break by setting bit in UART command register
  2136.     mvi    a,3Fh        ; Set TxEna, DTR, RxEna, SBreak, ErrRst, RTS
  2137.     out    mnprts
  2138. ;
  2139. ;    Wait for 250 milliseconds (using hundredths second delay routine)
  2140.     mvi    a,25
  2141.     call    delay
  2142. ;
  2143. ;    Resume normal operation by clearing the SendBreak command bit
  2144.     mvi    a,37h        ;Set TxEna, DTR, RxEna, ErrRst, RTS
  2145.     out    mnprts
  2146. ;
  2147.     ret            ;done
  2148. ENDIF;cpt85xx OR advant OR rm380z OR brain OR comart OR horizon
  2149.  
  2150. IF px8 ; [29]
  2151. sendbr: mvi     a, 3fh  ; set break bit
  2152.         out     mnprts
  2153.         mvi     a, 25
  2154.         call    delay   ; wait 250 msec
  2155.         mvi     a, 37h  ; clear break bit
  2156.         out     mnprts
  2157.         ret
  2158. ENDIF ; px8 [29]
  2159.  
  2160.  
  2161. IF bbc        ;[22]
  2162. sendbr:
  2163. ;
  2164. ;    Ensure that the transmitter has finished sending buffered chars
  2165. sndbr1:    mvi    a,96h        ; get ACIA status
  2166.     mvi    l,8
  2167.     call    osbyte        ; *FX150,8
  2168.     mov    a,h
  2169.     ani    2        ; everything sent?
  2170.     jz    sndbr1        ; no, wait a bit more
  2171. ;
  2172. ;    Disable centisecond clock (system VIA) which interferes with break
  2173.     lxi    h,0FE4Eh    ; system VIA interrupt enable register
  2174.     mvi    a,40H        ; disable timer 1
  2175.     call    wrtiom        ; write to I/O processor memory
  2176. ;
  2177. ;    Begin sending a break by setting bit in ACIA control register
  2178.     mvi    a,9Ch
  2179.     lxi    h,9F60h        ; Set Rxint, Txint, Break, RTS
  2180.     call    osbyte        ; *FX 156,96,159
  2181. ;
  2182. ;    Wait for 250 milliseconds (using hundredths second delay routine)
  2183.     mvi    a,25
  2184.     call    delay
  2185. ;
  2186. ;    Resume normal operation by returning old control byte
  2187.     mvi    a,9Ch
  2188.     mvi    h,0        ;Set TxEna, DTR, RxEna, ErrRst, RTS
  2189.     call    osbyte        ; *FX 156,oldvalue,0
  2190. ;
  2191. ;    Enable centisecond clock (system VIA)
  2192.     lxi    h,0FE4Eh    ; system VIA interrupt enable register
  2193.     mvi    a,0C0H        ; enable timer 1
  2194.     call    wrtiom        ; write to I/O processor memory
  2195. ;
  2196.     ret            ;done
  2197. ;
  2198. ;    Routine to write byte in A to I/O processor memory address
  2199. ;    given by HL
  2200. wrtiom:
  2201.     shld    parblk        ; store address to parameter block
  2202.     sta    parblk+4    ; store data
  2203.     lxi    h,parblk    ; load hl with address of param block
  2204.     mvi    a,6        ; write I/O processor memory
  2205.     call    osword        ; go do it
  2206.     ret
  2207. ;
  2208. parblk:    DS    5        ; reserve space for parameter block
  2209. ENDIF;bbc [22]
  2210.  
  2211. IF apcps        ;[22]
  2212. sendbr:
  2213. ;
  2214. ;    Ensure that the transmitter has finished sending buffered chars
  2215. sndbr1:    lda    mnprts        ; get UART status
  2216.     ani    TxEmpty        ; everything sent?
  2217.     jz    sndbr1        ; no, wait a bit more
  2218. ;
  2219. ;    Unmask command register
  2220.     mvi    a,80h
  2221.     sta    mnprtc
  2222. ;
  2223. ;    Begin sending a break by setting bit in UART command register
  2224.     mvi    a,3Fh        ; Set TxEna, DTR, RxEna, SBreak, ErrRst, RTS
  2225.     sta    mnprts
  2226. ;
  2227. ;    Wait for 250 milliseconds (using hundredths second delay routine)
  2228.     mvi    a,25
  2229.     call    delay
  2230. ;
  2231. ;    Resume normal operation by clearing the SendBreak command bit
  2232.     mvi    a,37h        ;Set TxEna, DTR, RxEna, ErrRst, RTS
  2233.     sta    mnprts
  2234. ;
  2235. ;    Remask command register
  2236.     mvi    a,0
  2237.     sta    mnprtc
  2238. ;
  2239.     ret            ;done
  2240. ENDIF;[22] apcps
  2241.  
  2242. IF torch ; [18] [27] [30]
  2243. ; Send a break.  The Torch computer has to dump some 6502 code to the "Base
  2244. ; processor " (A BBC computer), then do a call subroutine ACROSS THE TUBE
  2245. ; (ie then run that routine in the processor itself)  Use the sound buffer
  2246. ; area in the Beeb, at address 0840h.  How does one return from the routine
  2247. ; in the base processor???
  2248. ;
  2249. ; [30]  Dumping of 6502 code not yet used, but may be for later versions of 
  2250. ; the Torch CCCP Rom in the BBC.  This works, so I leave it for now.
  2251.  
  2252. sendbr:
  2253.     push    h        ;save for a monsoon
  2254.     push    d
  2255.     push    b
  2256.     mvi    a,0e8h
  2257.     lxi    d,0        ; turn interrupts off
  2258.     call    osbyt1
  2259.     push    psw
  2260. ;
  2261.     mvi    a,9ch        ; OSBYTE call 9c is read/write 6850 cntl prt
  2262.     lxi    d,00ffh        ; d= 6502 X reg, e= 6502 Y reg
  2263.     call    osbyt1        ; returned new val. = (old value AND Y)XOR X
  2264.     lda    xx        ; get returned value
  2265.     push    psw        ; save it for return
  2266. ;
  2267.     mvi    a,9ch        ; now send break
  2268.     lxi    d,7700h        ;[30]
  2269.     call    osbyt1
  2270. ;
  2271.     mvi    a,30
  2272.     call    delay        ; do a delay
  2273. ;
  2274. ; now clear rx register
  2275. ;
  2276.     mvi    a,96h        ; do a read sheila address 08h
  2277.     mvi    d,08
  2278.     mvi    e,0
  2279.     call    osbyt1        ; read sheila 08h = 6850 rx reg
  2280. ;
  2281. ; restore 6850 regs...
  2282. ;
  2283.     pop    psw        ; restore previous cntl reg
  2284.     mov    d,a
  2285.     mvi    e,0
  2286.     mvi    a,9ch        ; write previous value to 6850
  2287.     call    osbyt1
  2288. ;
  2289. ; and Beebs interrupt mask
  2290. ;
  2291.     pop    psw        ; get interrupt mask
  2292.     mov    d,a
  2293.     mvi    e,0
  2294.     mvi    a,0e8h
  2295.     call    osbyt1        ; restore interrupts mask
  2296. ;
  2297.     pop    b
  2298.     pop    d
  2299.     pop    h
  2300.     ret            ; its raining again, so exit
  2301. ENDIF    ; torch [18]
  2302.  
  2303. IF pci2651    ;[28]
  2304. sendbr:    in    mnprts
  2305.     ani    04h        ; make sure shift reg is clear
  2306.     jz    sendbr
  2307.  
  2308.     mvi    a,2fh        ; set foe a break
  2309.     out    mncmd
  2310.     mvi    a,100        ; wait a bit
  2311.     call    delay
  2312.     mvi    a,27h        ; restore mode
  2313.     out    mncmd
  2314.  
  2315. ENDIF    ;pci2651 [28]
  2316.  
  2317.  
  2318. IF heath
  2319. ;
  2320. ;    Send BREAK on H89
  2321. ;
  2322. sendbr:    in    mnport+acelcr
  2323.     ori    acesb
  2324.     out    mnport+acelcr    ; set ACE break condition
  2325.     mvi    a,30
  2326.     call    delay        ; wait 300 milliseconds
  2327.     in    mnport+acelcr
  2328.     ani    0FFH-acesb
  2329.     out    mnport+acelcr    ; and clear ACE break condition
  2330.     ret
  2331.  
  2332. ENDIF;heath
  2333.  
  2334. IF disc    ;[29]
  2335. ; This is almost an exact copy of the bbI sendbr routine.
  2336. ; Modifications to include a long break have been made.
  2337. ;
  2338. ; Officially, a "break" is 300 milliseconds of "space" (idle line is
  2339. ; "mark").  (or maybe 200 milliseconds; I forget.)  The timing isn't
  2340. ; usually that critical, but we'll make an attempt, at least.  Sending
  2341. ; too long a break can cause some modems to hang up.
  2342.  
  2343. sendlbr:
  2344.     push    d    ;save d, this may not be necessary, but safe
  2345.     mvi    d,17    ;do short break 17 times (approx. 5 sec.)
  2346.     jmp    sndbr1
  2347. sendbr:
  2348.     push d
  2349.     mvi    d,1    ;On short break, do only once
  2350. ; First, make sure the transmitter is really empty.  (The SIO sets
  2351. ; "transmitter buffer empty" when it can accept another character;
  2352. ; the previous character is still being shifted onto the line.
  2353. ; Another status bit, "all done", is set to indicate that the
  2354. ; transmitter is really idle.
  2355. sndbr1:    mvi    a,1        ; select Read Register 1
  2356.     out    mnprts
  2357.     in    mnprts        ; read the contents
  2358.     ani    1        ; test "all done" flag
  2359.     jz    sndbr1        ; loop until it's nonzero.
  2360. ;
  2361. ; Next, set the "send break" bit to start the transmitter spacing.
  2362.     mvi    a,5        ; select Write Register 5
  2363.     out    mnprts
  2364.     mvi    a,0FAH        ; Tx enable, 8 bit Tx character, Send Break,
  2365.     out    mnprts        ;  DTR and RTS on.
  2366. ;
  2367. ; Now, delay for 30*d hundredths of a second
  2368. sendbr2:
  2369.     mvi    a,30        ; delay count
  2370.     call    delay
  2371. ; The following has been added to allow doing .03 delay d times
  2372.     dcr    d        ; decrement # of times to do loop
  2373.     jnz    sendbr2        ; if not done, do again
  2374.     pop    d        ; reload d
  2375. ;
  2376. ; Time's up. Put transmitter back in normal state (data byte is the
  2377. ; same as the one in siotbl: for Write Register 5) and return.
  2378.     mvi    a,5        ; select Write Register 5
  2379.     out    mnprts
  2380.     mvi    a,0EAH        ; Tx enable, 8 bit Tx character,
  2381.     out    mnprts        ;  DTR and RTS on.
  2382.     ret            ; done.
  2383. ENDIF    ;disc [29]
  2384.  
  2385. IF bbI OR bbII OR cpt85xx OR heath OR lobo OR brain OR torch OR mmate OR disc;[16] [18]
  2386. ;
  2387. ;[cjc]    Delay routine.  Called with time (hundredths of seconds) in A.
  2388. ;    The inner loop delays 1001 T-states, assuming no wait states are
  2389. ;    inserted; this is repeated CPUSPD times, for a total delay of just
  2390. ;    over 0.01 second. (CPUSPD should be set to the system clock rate,
  2391. ;    in units of 100KHz: for an unmodified Kaypro II, that's 25 for
  2392. ;    2.5 MHz.  Some enterprising soul could determine whether or not the
  2393. ;    Kaypro actually inserts a wait state on instruction fetch (a common
  2394. ;    practice); if so, the magic number at delay2 needs to be decreased.
  2395. ;    (We also neglect to consider time spent at interrupt level).
  2396. ;
  2397. ;    called by: sendbr
  2398. ;    destroys BC
  2399.  
  2400. delay:    mvi    c,cpuspd    ; Number of times to wait 1000 T-states to
  2401.                 ;  make .01 second delay
  2402. delay2:    mvi    b,70        ; Number of times to execute inner loop to
  2403.                 ;  make 1000 T-state delay
  2404. delay3:    dcr    b        ; 4 T-states (* 70 * cpuspd)
  2405.     jnz    delay3        ; 10 T-states (* 70 * cpuspd)
  2406.     dcr    c        ; 4 T-states (* cpuspd)
  2407.     jnz    delay2        ; 10 T-states (* cpuspd)
  2408.                 ; total delay: ((14 * 70) + 14) * cpuspd
  2409.                 ;  = 1001 * cpuspd
  2410.     dcr    a        ; 4 T-states
  2411.     jnz    delay        ; 10 T-states
  2412.     ret            ; grand total: ((1001 * cpuspd) + 14) * a
  2413. ENDIF;bbI OR bbII or cpt85xx OR heath OR lobo OR brain OR torch OR mmate OR disc [29]
  2414.  
  2415. IF apcps OR bbc OR advant OR rm380z OR comart OR horizon OR pci2651 OR px8;[16] [18] [28] [29]....
  2416. ;
  2417. ;[cjc]    Delay routine.  Called with time (hundredths of seconds) in A.
  2418. ;    The inner loop delays 1001 T-states, assuming no wait states are
  2419. ;    inserted; this is repeated CPUSPD times, for a total delay of just
  2420. ;    over 0.01 second. (CPUSPD should be set to the system clock rate,
  2421. ;    in units of 100KHz: for an unmodified Kaypro II, that's 25 for
  2422. ;    2.5 MHz.  Some enterprising soul could determine whether or not the
  2423. ;    Kaypro actually inserts a wait state on instruction fetch (a common
  2424. ;    practice); if so, the magic number at delay2 needs to be decreased.
  2425. ;    (We also neglect to consider time spent at interrupt level).
  2426. ;
  2427. ;    called by: sendbr
  2428. ;    destroys BC
  2429.  
  2430. delay:    mvi    c,cpuspd    ; Number of times to wait 1000 T-states to
  2431.                 ;  make .01 second delay
  2432. delay2:    mvi    b,70        ; Number of times to execute inner loop to
  2433.                 ;  make 1000 T-state delay
  2434. delay3:    dcr    b        ; 4 T-states (* 70 * cpuspd)
  2435.     jnz    delay3        ; 10 T-states (* 70 * cpuspd)
  2436.     dcr    c        ; 4 T-states (* cpuspd)
  2437.     jnz    delay2        ; 10 T-states (* cpuspd)
  2438.                 ; total delay: ((14 * 70) + 14) * cpuspd
  2439.                 ;  = 1001 * cpuspd
  2440.     dcr    a        ; 4 T-states
  2441.     jnz    delay        ; 10 T-states
  2442.     ret            ; grand total: ((1001 * cpuspd) + 14) * a
  2443. ENDIF;apcps OR bbc OR advent OR rm380 OR comart OR horizon OR pci2651 OR px8 [16] [18] [28] [29]
  2444. ;
  2445.  
  2446. IF access ;[29] .. ran out of room.. again
  2447. ;[cjc]    Delay routine.  Called with time (hundredths of seconds) in A.
  2448. ;    The inner loop delays 1001 T-states, assuming no wait states are
  2449. ;    inserted; this is repeated CPUSPD times, for a total delay of just
  2450. ;    over 0.01 second. (CPUSPD should be set to the system clock rate,
  2451. ;    in units of 100KHz: for an unmodified Kaypro II, that's 25 for
  2452. ;    2.5 MHz.  Some enterprising soul could determine whether or not the
  2453. ;    Kaypro actually inserts a wait state on instruction fetch (a common
  2454. ;    practice); if so, the magic number at delay2 needs to be decreased.
  2455. ;    (We also neglect to consider time spent at interrupt level).
  2456. ;
  2457. ;    called by: sendbr
  2458. ;    destroys BC
  2459.  
  2460. delay:    mvi    c,cpuspd    ; Number of times to wait 1000 T-states to
  2461.                 ;  make .01 second delay
  2462. delay2:    mvi    b,70        ; Number of times to execute inner loop to
  2463.                 ;  make 1000 T-state delay
  2464. delay3:    dcr    b        ; 4 T-states (* 70 * cpuspd)
  2465.     jnz    delay3        ; 10 T-states (* 70 * cpuspd)
  2466.     dcr    c        ; 4 T-states (* cpuspd)
  2467.     jnz    delay2        ; 10 T-states (* cpuspd)
  2468.                 ; total delay: ((14 * 70) + 14) * cpuspd
  2469.                 ;  = 1001 * cpuspd
  2470.     dcr    a        ; 4 T-states
  2471.     jnz    delay        ; 10 T-states
  2472.     ret            ; grand total: ((1001 * cpuspd) + 14) * a
  2473. ENDIF;access [29]
  2474.  
  2475.  
  2476. ; Had to break the whopping CP4SYS.ASM file onto two.. Sorry folks
  2477. ;IF lasm
  2478. ;    LINK CP4SY2
  2479. ;ENDIF    ; lasm
  2480.  
  2481.  
  2482. ; Asked to string the two files back together again.  Those who 
  2483. ; want to use two files should remove the semicolons in the above IF...ENDIF
  2484. ;  Call the next file CP4SY2.ASM
  2485.  
  2486. ; CP4SY2.ASM
  2487. ;    KERMIT - (Celtic for "FREE")
  2488. ;
  2489. ;    This is the CP/M-80 implementation of the Columbia University
  2490. ;    KERMIT file transfer protocol.
  2491. ;
  2492. ;    Version 4.0
  2493. ;
  2494. ;    Copyright June 1981,1982,1983,1984,1985
  2495. ;    Columbia University
  2496. ;
  2497. ; Originally written by Bill Catchings of the Columbia University Center for
  2498. ; Computing Activities, 612 W. 115th St., New York, NY 10025.
  2499. ;
  2500. ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
  2501. ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
  2502. ; others.
  2503. ;
  2504. ;    This is the second part of the CP4SYS.ASM file, as it got too big.
  2505. ;
  2506. ;    This file contains the system-dependent code and data for KERMIT.
  2507. ;    It will be probably be broken into independent files to generate
  2508. ;    overlays for the various systems, one or more overlay possible
  2509. ;    from each file.  For now, we will leave it in one piece.
  2510. ;
  2511. ; revision history: (Please keep as CP4SYS file: these two really should be
  2512. ;            one, but that would be too big.)
  2513. ;
  2514. ; edit 31 April 7th, 1986 OBSchou.  Bugs in PX8 kermit fixed.
  2515. ;
  2516. ; edit 30 24th march, 1986 by OBSchou.  Sorting out torch tx and break
  2517. ;    problems... AGAIN  
  2518. ;
  2519. ; edit 29, March 7th, 1986 by OBSchou.  Added in code for Epson PX8
  2520. ;    code written by Tony Addyman from Salford University.  This is
  2521. ;    really two edits into one, with a final edit of a dollar in the 
  2522. ;    help messages.
  2523. ;    Also add in code from an Unknown kermiteer, who added code for a
  2524. ;    basic Northstar (basicns) (small changes) and also wrote the 
  2525. ;    following headers to a list of "changes" to the CP4SYS file.....
  2526. ;
  2527. ;>     ACCESS-MATRIX
  2528. ;>    Note - The following differences in CP4SYS.ASM apply to the
  2529. ;>    implementation for the Access-Matrix computer.
  2530. ;>    In CP4TYP.ASM, set access to TRUE, inout to TRUE, and crt to FALSE
  2531. ;>    Use port J5 of the Access 
  2532. ;>
  2533. ;>    PMC MICROMATE
  2534. ;>    The following applies to the implementation for Personal Micro 
  2535. ;>    Computers PMC-101 MicroMate. In CP4TYP.ASM, set mmate to TRUE, 
  2536. ;>    inout to TRUE, and crt to TRUE (Don't know what terminal might 
  2537. ;>    be used.)
  2538. ;>
  2539. ;>    U.S. Micro Sales s1008 (out of business)
  2540. ;>    Can use the same approach as for the basic NorthStar except set
  2541. ;>    crt to FALSE.  (s1008)
  2542. ;>
  2543. ;>    A. C. E. DISCOVERY
  2544. ;>    This implementation is for the Action Computer Enterprise, Inc. 
  2545. ;>    "Discovery" multi user computer.  It uses port B on an 83U 
  2546. ;>    user board. 
  2547. ;>
  2548. ;>    In CP4TYP.asm set disc to TRUE, inout to TRUE, and crt to TRUE
  2549. ;>
  2550. ;
  2551. ; edit 28, January 29 1986 by OBSchou
  2552. ;    added code to drive a 2651 USART for one of our odd ball
  2553. ;    machines.  (Euromicro/Ithica Intersystems VIO (?) board)
  2554. ;    (pci2651)  Also split the HUGE cp4sys.asm file into two smaller
  2555. ;    ones: this one is still CP4SYS.ASM, the next one is CP4SY2.ASM
  2556. ;    The break is just after the BREAK and DELAY routines.. roughly 1/2
  2557. ;    way through the file.
  2558. ;
  2559. ;
  2560.  
  2561. ;
  2562. ;    sysflt - system-dependent filter
  2563. ;    called with character in E.
  2564. ;    if this character should not be printed, return with A = zero.
  2565. ;    preserves bc, de, hl.
  2566. ;    note: <xon>,<xoff>,<del>, and <nul> are always discarded.
  2567. sysflt:
  2568.     mov    a,e        ; get character for testing
  2569. IF mikko
  2570.     cpi    'O'-100O    ;Control-O's lock keyboard
  2571.     rnz            ; if not control-O, it's ok.
  2572.     xra    a        ; don't allow control-O out.
  2573. ENDIF;mikko
  2574.  
  2575. IF advant    ;[22]
  2576.     cpi    'D'-100O    ;Control-D's reset video
  2577.     rnz            ; if not control-D, it's ok.
  2578.     xra    a        ; don't allow control-D out.
  2579. ENDIF;[22] advant
  2580.     ret
  2581.  
  2582. ;    mdmflt - modem filter [30]
  2583. ;    called with character to be sent to printer in E
  2584. ;    with parity set as appropriate.
  2585. ;    return with accumulator = 0 do do nothing,
  2586. ;                <> 0 to send char in E.
  2587. mdmflt:
  2588.     mov    a,e        ;[30] get character to test
  2589. IF torch    ;[30] map del to bs,space,bs
  2590.     ani    7fh        ; strip parity
  2591.     cpi    7fh        ; is it the delete character
  2592.     rnz            ; no, then a <> 0 so print it
  2593.     mvi    e,bs        ; else load a backspace
  2594.     call    outmdm        ; little recursion...
  2595.     mvi    e,' '        ; then a space
  2596.     call    outmdm        ; backspace, space, now another...
  2597.     mvi    e,bs        ; backspace
  2598.     call    outmdm        ;
  2599.     xra    a        ; clear a => on return do nowt.
  2600. ENDIF    ;torch [30]
  2601.     ret
  2602.  
  2603.  
  2604.  
  2605. ;    prtflt - printer filter [30]
  2606. ;    called with character to be sent to printer in E
  2607. ;    returns with a = 0 to do nothing
  2608. ;             a <> 0 to print it.
  2609. ;
  2610. ;    this routine for those printer that automatically insert
  2611. ;    a lf on cr, or cr for lf.  Should this be shifted to 
  2612. ;    the system indep. stuff, in say 4.06?
  2613. prtflt:
  2614.     mov    a,e        ; [30] get character to test
  2615. IF torch    ; strip out lf from printer stream
  2616.     ani    7fh        ; make sure it is parity less
  2617.     cpi    lf        ; is it a line feed?
  2618.     rnz            ; no, print it
  2619. ;    xra    a        ; yes, don't.
  2620.     
  2621. ENDIF     ;torch [30]
  2622.     ret
  2623.  
  2624.  
  2625.  
  2626. ;
  2627. ; system-dependent processing for BYE command.
  2628. ;  for apmmdm, heath, and lobo, hang up the phone.
  2629. sysbye:
  2630. IF apmmdm
  2631.     xra    a        ;Hangup our end, too.
  2632.     sta    mnmodm
  2633. ENDIF;apmmdm
  2634.  
  2635. IF heath
  2636.     call    mdmdrp        ;  Sleazy but effective
  2637. ENDIF;heath
  2638.  
  2639. IF lobo    ;[hh]
  2640.     call    discon        ;[hh] force modem to hang up
  2641. ENDIF;lobo
  2642.     ret
  2643.  
  2644. ;    This is the system-dependent command to change the baud rate.
  2645. ;    DE contains the two-byte value from the baud rate table; this
  2646. ;    value is also stored in 'speed'.
  2647. sysspd:
  2648.  
  2649. ; Set the speed for the Brain (Main Port)
  2650. IF brainm            ;[25]
  2651.     lda    baudrt        ;Get the present baud rates.
  2652.     ani    0fH        ;turn off the left
  2653.     mov    d,a        ;Set it aside.
  2654.     mov    a,e        ;Get the new baud rate.
  2655.     rlc            ;Shift left 4 places.
  2656.     rlc
  2657.     rlc
  2658.     rlc
  2659.     ora    d        ; combine with the old baud rate
  2660.     sta    baudrt        ;Store the new baud rates.
  2661.     out    baudst        ;Set the baud rates.
  2662.     ret
  2663. ENDIF;brainm
  2664.  
  2665. ; Set the speed for the Brain (Aux Port)
  2666. IF braina            ;[25]
  2667.     lda    baudrt        ;Get the present baud rates.
  2668.     ani    0f0H        ;turn off the right
  2669.     ora    e        ; combine with the new baud rate
  2670.     sta    baudrt        ;Store the new baud rates.
  2671.     out    baudst        ;Set the baud rates.
  2672.     ret
  2673. ENDIF;braina
  2674.  
  2675. IF px8 ; [29]
  2676.         push    d
  2677.         call    rsclose        ; baud rate can only be set on opening rs232
  2678.         pop     d
  2679.         mov     a, e
  2680.         sta     px8blk+4       ; set param block
  2681.         call    rsopen         ; to set rate
  2682.         ret
  2683. ENDIF ; px8 [29]
  2684.  
  2685. ; Set the speed for the Osborne I
  2686. IF osbrn1
  2687.     mvi    a,osbin1    ;Reset the ACIA
  2688.     call    osstst        ;Write the control port
  2689. osbs1:    inr    c        ;Waiting loop
  2690.     jnz    osbs1
  2691.     mov    a,e        ; get the specified speed
  2692.     jmp    osstst        ;Write the control reg.
  2693. ENDIF;osbrn1
  2694.  
  2695. ; Set the speed for bigboard II
  2696. IF bbII
  2697.     di            ; don't let anything between the data bytes
  2698.     mvi    a,01000111b    ; get the command byte (load time constant)
  2699.     out    baudrt        ; output it to CTC
  2700.     mov    a,e        ; Get the parsed value.
  2701.     out    baudrt        ; Tell the baud rate generator.
  2702.     ei            ; end of critical section
  2703.     ret
  2704. ENDIF;bbII
  2705.  
  2706. ;[hh] set the speed for a lobo MAX-80
  2707. IF lobo
  2708.     mov    a,e        ;[hh] get the parsed value
  2709. setbd:    sta    baudrt        ;[hh] and send it to the baud rate port
  2710.     ret            ;[hh]
  2711. ENDIF;lobo
  2712.  
  2713. ; Set the speed for bigboard I or the delphi or the CPT-85xx or Northstar
  2714. ; or Cromemco (TU-ART)
  2715. IF bbI OR delphi OR cpt85xx OR norths OR cmemco OR advant OR mmate ;[22] [29]
  2716.     mov    a,e        ; get the parsed value
  2717.     out    baudrt        ; Tell the baud rate generator.
  2718.     ret
  2719. ENDIF;bbI OR delphi OR cpt85xx OR norths OR cmemco OR advant OR mmate [22] [29]
  2720.  
  2721. ;[22] Set the speed for Acorn BBC
  2722. IF bbc
  2723.     mov    l,e
  2724.     mvi    a,7        ;Set receive baud rate
  2725.     call    osbyte        ;*FX7,?e
  2726.     mov    l,e
  2727.     mvi    a,8        ;Set transmit baud rate
  2728.     call    osbyte        ;*FX8,?e
  2729.     ret
  2730. ENDIF;[22] bbc
  2731.  
  2732. ;[22] Set speed for RM 380Z
  2733. IF rm380z
  2734.     mvi    a,4        ;device type (SI/O4) in A
  2735.     rst    6        ; EMT
  2736.     db    29h        ;     SETLST
  2737.     ret
  2738. ENDIF;[22] rm380z
  2739.  
  2740. ; Set the speed for MicroMikko.  DE is baud rate multiplier
  2741. IF mikko
  2742.     di
  2743.     lxi    h,txclk
  2744.     mov    m,d        ;LSB first (swapped in memory)
  2745.     mov    m,e        ;MSB last
  2746.     lxi    h,rxclk
  2747.     mov    m,d
  2748.     mov    m,e
  2749.     mvi    b,0        ;"modifier" for 1 stop bit
  2750.     mvi    a,2        ;Test MSB of speed >2 (110 bps or less)
  2751.     cmp    e
  2752.     jp    miksp1
  2753.     mvi    b,00001000B    ;"modifier" for 2 stop bits
  2754. miksp1:    mvi    a,4        ;Select SIO Reg 4
  2755.     lxi    h,sioac
  2756.     mov    m,a
  2757.     mvi    a,sion4        ;Get values
  2758.     ora    b        ;Add modifier
  2759.     mov    m,a        ;Set value (stop bits)
  2760.     ei
  2761.     ret
  2762. ENDIF;mikko
  2763.  
  2764. ; Set the speed for Apple with 6551 ACIA
  2765. IF ap6551
  2766.     lda    mnprtc        ;jb read control port
  2767.     ani    0F0H        ;jb zap low order nybble
  2768.     ora    e        ;jb put rate in low order nybble
  2769.     sta    mnprtc        ;jb send to control port
  2770.     ret
  2771. ENDIF;ap6551
  2772.  
  2773. ; Set the speed for Apple with CPS Multifunction card
  2774. IF apcps        ;[22]
  2775.     mvi    a,80h
  2776.     sta    mnprtc
  2777.     lda    mnprts        ;read command register to reset 2651
  2778.     mvi    a,apmod1    ;first mode byte
  2779.     sta    mnport
  2780.     mvi    a,4        ;waste some time before sending second byte
  2781. spdwt:    dcr    a        ; 4 T-states
  2782.     jnz    spdwt        ; 10 T-states
  2783.     mov    a,e        ;second mode byte is speed byte
  2784.     sta    mnport
  2785.     mvi    a,apcmd        ;command byte
  2786.     sta    mnprts
  2787.     xra    a
  2788.     sta    mnprtc
  2789.     ret
  2790. ENDIF;[22] apcps
  2791.  
  2792. ; Set the speed for the Decision I
  2793. IF mdI
  2794.     call    selmdm        ;Let's be absolutely sure, huh?
  2795.     mvi    a,dlab+wls1+wls0+stb ;Set data latch access bit
  2796.     out    lcr        ;Out to Line Control Register
  2797.     lhld    speed        ;Load baudrate multiplier
  2798.     xchg
  2799.     mov    a,d        ;Get low order byte for baud rate
  2800.     out    dlm        ;Out to the MSB divisor port
  2801.     mov    a,e        ;...and the high order byte
  2802.     out    dll        ;Out to the LSB divisor port
  2803.     mvi    a,wls1+wls0+stb    ;Enable Divisor Access Latch
  2804.     out    lcr        ;Out to ACE Line Control Register
  2805.     xra    a        ;Clear A
  2806.     out    ier        ;Set no interrupts
  2807.     out    lsr        ;Clear status
  2808.     in    msr        ;Clear Modem Status Register
  2809.     in    lsr        ;Clear Line Status Register
  2810.     in    rbr        ;Clear Receiver Buffers
  2811.     in    rbr
  2812.     ret
  2813. ENDIF    ;mdI    [Toad Hall]
  2814.  
  2815. IF heath
  2816. ;
  2817. ;    Set speed for H89
  2818. ;
  2819.     call    mdmofl        ; keep the line safe from garbage
  2820.     in    mnport+acelcr
  2821.     ori    acedla
  2822.     out    mnport+acelcr    ; access the ACE's divisor latch
  2823.     mov    a,e        ; low byte of speed is in E
  2824.     out    mnport+acedll    ; set the low byte
  2825.     mov    a,d        ; high byte of speed is in D
  2826.     out    mnport+acedlh    ; set the high byte
  2827.     in    mnport+acelcr
  2828.     ani    0FFH-acedla
  2829.     out    mnport+acelcr    ; de-access the ACE's divisor latch
  2830.     call    mdmonl        ; and put the ACE back on line
  2831.     ret
  2832. ENDIF;heath
  2833.  
  2834. If torch    ; Set speed for Torch [14]
  2835.     push    psw        ; save for a rainy day
  2836.     push    d        ; it may be monsoon
  2837.     mvi    a,rxrate    ; set up for osbyte call to set rx rate
  2838.     call    osbyt1        ; similar call to osbyte, which is near io stuff
  2839.     pop    d        ; it is raining
  2840.     mvi    a,txrate    ; set up for tx rate to be set
  2841.     call    osbyt1
  2842.     pop    psw        ; its pouring
  2843.     ret            ; and now, all rates should be different
  2844.  
  2845. rxrate    equ    7h        ; osbyte or fx call 7 is set rx rate
  2846. txrate    equ    8h        ; osbyte or fx call 8 is set tx rate
  2847. ENDIF    ;torch  [14]
  2848.  
  2849. IF pci2651    ; Set baud for PCI [28]
  2850.     in    mncmd        ; Clear register counter
  2851.     mvi    a,4eh        ; set for 1 stop, 8 data bits
  2852.     out    mnmode        ; save in mode 1 port
  2853.     mvi    a,30h        ; set bits for rate etc..
  2854.     add    e        ; add baud rate (bits 0 - 3)
  2855.     out    mnmode        ; set mode port 2
  2856.     mvi    a,27h        ; set tx/rx ready, RTS CTS active
  2857.     out    mncmd
  2858.     ret
  2859. ENDIF    ;pci2651 [28]
  2860.  
  2861. IF access    ;[29]
  2862.     mov    a,e        ;Get the parsed time constant
  2863. ;The following code is derived from the Access  initialization code
  2864.     sta    savspd        ;Save  the time constant
  2865.     mvi    a,14h        ;Code for 'monitor' to set channel A baudrate
  2866.     call    monitor
  2867.     lda    savspd        ;Get the time constant
  2868.     call    monitor        ; and send it to the CRT
  2869.     ret
  2870. savspd:    ds    1
  2871. monitor:            ;Routine to do CRT functions
  2872.     out    90h        ;Output the data to the CRT
  2873.     mvi    a,1        ;Set DRDY true
  2874.     out    23h
  2875. mon1:    in    0a0h        ;Wait for CACK* true
  2876.     rlc
  2877.     jc    mon1
  2878.     in    80h        ;Read the input data latch
  2879.     push    psw        ;Save the input data
  2880.     xra    a        ;Set DRDY false
  2881.     out    23h
  2882. mon2:    in    0a0h        ;Wait for CACK* false
  2883.     rlc
  2884.     jc    mon2
  2885.     pop    psw
  2886.     sta    0ee02h        ;Save the input data
  2887.     ret
  2888. ENDIF;access [29]
  2889.  
  2890.  
  2891. IF disc    ;[29]
  2892. ; Assuming that parsing of value from speed table puts low order
  2893. ; byte of time constant in the e register and high byte in d.
  2894.     mvi    a,12        ;Register 12
  2895.     out    mnprts
  2896.     mov    a,e        ;Low order byte of time constant
  2897.     out    mnprts
  2898.     mvi    a,13        ;Register 13
  2899.     out    mnprts
  2900.     mov    a,d        ;High order byte of time constant
  2901.     out    mnprts
  2902.     mvi    a,14        ;Register 14
  2903.     out    mnprts
  2904.     mvi    a,3        ;Enable baud rate generator
  2905.     out    mnprts
  2906.     mvi    a,11        ;Register 11
  2907.     out    mnprts
  2908.     mvi    a,52h        ;no Xtal, tclk=rclk=/trxc out=br gen
  2909.     out    mnprts
  2910.     ret
  2911. ENDIF;disc [29]
  2912.  
  2913. ;    Speed tables
  2914. ; (Note that speed tables MUST be in alphabetical order for later
  2915. ; lookup procedures, and must begin with a value showing the total
  2916. ; number of entries.  The speed help tables are just for us poor
  2917. ; humans.
  2918.  
  2919. ;    db    string length,string,divisor (2 identical bytes or 1 word)
  2920. ; [Toad Hall]
  2921.  
  2922. IF bbI OR brain OR delphi OR lobo    ;[hh]
  2923. spdtbl:    db    10h            ;16 entries
  2924.     db    03h,'110$',    02h,02h
  2925.     db    04h,'1200$',    07h,07h
  2926.     db    05h,'134.5$',    03h,03h
  2927.     db    03h,'150$',    04h,04h
  2928.     db    04h,'1800$',    08h,08h
  2929.     db    05h,'19200$',    0fh,0fh
  2930.     db    04h,'2000$',    09h,09h
  2931.     db    04h,'2400$',    0ah,0ah
  2932.     db    03h,'300$',    05h,05h
  2933.     db    04h,'3600$',    0bh,0bh
  2934.     db    04h,'4800$',    0ch,0ch
  2935.     db    02h,'50$',    00h,00h
  2936.     db    03h,'600$',    06h,06h
  2937.     db    04h,'7200$',    0dh,0dh
  2938.     db    02h,'75$',    01h,01h
  2939.     db    04h,'9600$',    0eh,0eh
  2940.  
  2941. sphtbl: db    cr,lf,'   50     75    110    134.5  150    300    600   1200'
  2942.     db    cr,lf,' 1800   2000   2400   3600   4800   7200   9600  19200$'
  2943. ENDIF;bbI OR brain OR delphi OR lobo    ;[hh]
  2944.  
  2945. IF bbII
  2946. spdtbl:    db    8            ; 8 entries
  2947.     db    04h,'1200$',    20h,20h
  2948.     db    05h,'19200$',    02h,02h
  2949.     db    04h,'2400$',    10h,10h
  2950.     db    03h,'300$',    80h,80h
  2951.     db    05h,'38400$',    01h,01h
  2952.     db    04h,'4800$',    08h,08h
  2953.     db    03h,'600$',    40h,40h
  2954.     db    04h,'9600$',    04h,04h
  2955.  
  2956. sphtbl: db    cr,lf,'   300   600  1200  2400  4800  9600 19200 38400$'
  2957. ENDIF;bbII
  2958.  
  2959. IF cpt85xx
  2960. spdtbl:    db    15            ; 15 entries
  2961.     db    03,'110$',    03h,03h
  2962.     db    04,'1200$',    09h,09h
  2963.     db    05,'134.5$',    04h,04h
  2964.     db    03,'150$',    05h,05h
  2965.     db    04,'1800$',    0Ah,0Ah
  2966.     db    04,'2400$',    0Bh,0Bh
  2967.     db    03,'300$',    06h,06h
  2968.     db    04,'3600$',    0Ch,0Ch
  2969.     db    04,'4800$',    0Dh,0Dh
  2970.     db    02,'50$',    01h,01h
  2971.     db    03,'600$',    07h,07h
  2972.     db    04,'7200$',    0Eh,0Eh
  2973.     db    02,'75$',    02h,02h
  2974.     db    03,'900$',    08h,08h
  2975.     db    04,'9600$',    0Fh,0Fh
  2976.  
  2977. sphtbl: db    cr,lf,'   50     75    110    134.5  150    300    600    900'
  2978.     db    cr,lf,' 1200   1800   2400   3600   4800   7200   9600$'
  2979. ENDIF;cpt85xx
  2980.  
  2981. IF advant    ;[22]
  2982. spdtbl:    db    6            ; 6 entries
  2983.     db    04,'1200$',    70h,70h
  2984.     db    04,'2400$',    78h,78h
  2985.     db    03,'300$',    40h,40h
  2986.     db    04,'4800$',    7Ch,7Ch
  2987.     db    03,'600$',    60h,60h
  2988.     db    04,'9600$',    7Eh,7Eh
  2989.  
  2990. sphtbl: db    cr,lf,'   300    600    1200    2400    4800    9600$'
  2991. ENDIF;[22] advant
  2992.  
  2993. IF bbc        ;[22]
  2994. spdtbl:    db    8            ; 8 entries
  2995.     db    04,'1200$',    04h,04h
  2996.     db    03,'150$',    02h,02h
  2997.     db    05,'19200$',    08h,08h
  2998.     db    04,'2400$',    05h,05h
  2999.     db    03,'300$',    03h,03h
  3000.     db    04,'4800$',    06h,06h
  3001.     db    02,'75$',    01h,01h
  3002.     db    04,'9600$',    07h,07h
  3003.  
  3004. sphtbl: db    cr,lf,'   75   150   300   1200   2400   4800   9600   19200$'
  3005. ENDIF;[22] bbc
  3006.  
  3007. IF rm380z    ;[22]
  3008. spdtbl:    db    7            ; 7 entries
  3009.     db    03,'110$',    00h,00h
  3010.     db    04,'1200$',    03h,03h
  3011.     db    04,'2400$',    04h,04h
  3012.     db    03,'300$',    01h,01h
  3013.     db    04,'4800$',    05h,05h
  3014.     db    03,'600$',    02h,02h
  3015.     db    04,'9600$',    06h,06h
  3016.  
  3017. sphtbl: db    cr,lf,'   110   300   600   1200   2400   4800   9600$'
  3018. ENDIF;[22] rm380z
  3019.  
  3020. IF px8 ; [29]
  3021. spdtbl: db      9                       ; 9 entries
  3022.         db      03,'110$',      02h,02h
  3023.         db      04,'1200$',     0ah,0ah
  3024.         db      03,'150$',      04h,04h
  3025.         db      05,'19200$',    0fh,0fh
  3026.         db      04,'2400$',     0ch,0ch
  3027.         db      03,'300$',      06h,06h
  3028.         db      04,'4800$',     0dh,0dh
  3029.         db      03,'600$',      08h,08h
  3030.         db      04,'9600$',     0eh,0eh
  3031. sphtbl: db      cr, lf
  3032.         db  '   100   150   300   600   1200   2400   4800   9600   19200$'
  3033. ENDIF ; px8 [29]
  3034.  
  3035. IF mikko
  3036. spdtbl:    db    9h            ;9 entries
  3037.     db    03h,'110$'
  3038.     dw    0369h
  3039.     db    04h,'1200$'
  3040.     dw    0050h
  3041.     db    03h,'150$'
  3042.     dw    0280h
  3043.     db    04h,'2400$'
  3044.     dw    0028h
  3045.     db    03h,'300$'
  3046.     dw    0140h
  3047.     db    04h,'4800$'
  3048.     dw    0014h
  3049.     db    03h,'600$'
  3050.     dw    00A0H
  3051.     db    02h,'75$'
  3052.     dw    0500h
  3053.     db    04h,'9600$'
  3054.     dw    000ah
  3055.  
  3056. sphtbl:    db    cr,lf,'  75  110  150  300  600  1200  2400  4800  9600$'
  3057. ENDIF;mikko
  3058.  
  3059. IF osbrn1
  3060. spdtbl:    db    02h            ;2 entries
  3061.     db    04h,'1200$',    OSBI12,OSBI12
  3062.     db    03h,'300$',    OSBI03,OSBI03
  3063.  
  3064. sphtbl:    db    cr,lf,'  300',cr,lf,' 1200$'
  3065. ENDIF;osbrn1
  3066.  
  3067. IF ap6551                    ;jb
  3068. spdtbl:    db    0DH                ;jb 13 entries
  3069.     db    03H,'110$',    03H,03H    ;jb
  3070.     db    04H,'1200$',    08H,08H    ;jb
  3071.     db    05H,'134.5$',    04H,04H    ;jb
  3072.     db    03H,'150$',    05H,05H    ;jb
  3073.     db    04H,'1800$',    09H,09H    ;jb
  3074.     db    05H,'19200$',    0FH,0FH    ;jb
  3075.     db    04H,'2400$',    0AH,0AH    ;jb
  3076.     db    03H,'300$',    06H,06H    ;jb
  3077.     db    04H,'3600$',    0BH,0BH    ;jb
  3078.     db    04H,'4800$',    0CH,0CH    ;jb
  3079.     db    03H,'600$',    07H,07H    ;jb
  3080.     db    04H,'7200$',    0DH,0DH    ;jb
  3081.     db    04H,'9600$',    0EH,0EH    ;jb
  3082.  
  3083. sphtbl:    db    cr,lf,'  110    134.5  150    300    600   1200   1800'
  3084.     db    cr,lf,' 2400   3600   4800   7200   9600  19200$'
  3085. ENDIF;ap6551
  3086.  
  3087. IF apcps        ;[22]
  3088. spdtbl:    db    10H                ; 16 entries
  3089.     db    03H,'110$',    32h,32h
  3090.     db    04H,'1200$',    37h,37h
  3091.     db    05H,'134.5$',    33h,33h
  3092.     db    03H,'150$',    34h,34h
  3093.     db    04H,'1800$',    38h,38h
  3094.     db    05H,'19200$',    3fh,3fh
  3095.     db    04H,'2000$',    39h,39h
  3096.     db    04H,'2400$',    3ah,3ah
  3097.     db    03H,'300$',    35h,35h
  3098.     db    04H,'3600$',    3bh,3bh
  3099.     db    04H,'4800$',    3ch,3ch
  3100.     db    02H,'50$',    30h,30h
  3101.     db    03H,'600$',    36h,36h
  3102.     db    04H,'7200$',    3dh,3dh
  3103.     db    02H,'75$',    31h,31h
  3104.     db    04H,'9600$',    3eh,3eh
  3105.  
  3106. sphtbl:    db    cr,lf,'   50    75   110    134.5  150    300    600   1200'
  3107.     db    cr,lf,' 1800  2000  2400   3600   4800   7200   9600  19200$'
  3108. ENDIF;[22] apcps
  3109.  
  3110. IF mdI
  3111. spdtbl:    db    0dh            ; 13 entries
  3112.     db    03h,  '110$'
  3113.         dw        1047
  3114.     db    04h, '1200$'
  3115.         dw        96
  3116.     db    03h,  '150$'
  3117.         dw        768
  3118.     db    05h,'19200$'
  3119.         dw        6
  3120.     db    04h, '2400$'
  3121.         dw        48
  3122.     db    03h,  '300$'
  3123.         dw        384
  3124.     db    05h,'38400$'
  3125.         dw        3
  3126.     db    03h,  '450$'
  3127.         dw        288
  3128.     db    04h, '4800$'
  3129.         dw        24
  3130.     db    05h,'56000$'
  3131.         dw        2
  3132.     db    03h,  '600$'
  3133.         dw        192
  3134.     db    02h,   '75$'
  3135.         dw        1536
  3136.     db    04h, '9600$'
  3137.         dw        12
  3138.  
  3139. sphtbl:    db    cr,lf,'   75    110    150    300    450    600   1200'
  3140.     db    cr,lf,' 2400   4800   9600  19200  38400  56000$'
  3141.  
  3142. ;(Lord knows what you'll be communicating with at 56000 baud, but the
  3143. ;Multi-I/O board literature says it'll do it, so what the heck....
  3144. ;might as well throw it in here just to show off...sure hope the
  3145. ;port don't melt...)
  3146.  
  3147. ENDIF    ;mdI    [Toad Hall]
  3148.  
  3149. IF heath
  3150. ;
  3151. ;    Speed selection table for H89  (OK, so I got a little carried away...)
  3152. ;
  3153.  
  3154. spdtbl:    db    19        ; 19 entries
  3155.     db    3,'110$'
  3156.     dw    1047
  3157.     db    4,'1200$'
  3158.     dw    96
  3159.     db    5,'134.5$'
  3160.     dw    857
  3161.     db    4,'1800$'
  3162.     dw    64
  3163.     db    5,'19200$'
  3164.     dw    6
  3165.     db    3,'200$'
  3166.     dw    576
  3167.     db    4,'2400$'
  3168.     dw    48
  3169.     db    3,'300$'
  3170.     dw    384
  3171.     db    4,'3600$'
  3172.     dw    32
  3173.     db    5,'38400$'
  3174.     dw    3
  3175.     db    3,'450$'
  3176.     dw    256
  3177.     db    4,'4800$'
  3178.     dw    24
  3179.     db    2,'50$'
  3180.     dw    2304
  3181.     db    5,'56000$'
  3182.     dw    2
  3183.     db    3,'600$'
  3184.     dw    192
  3185.     db    4,'7200$'
  3186.     dw    16
  3187.     db    2,'75$'
  3188.     dw    1536
  3189.     db    3,'900$'
  3190.     dw    128
  3191.     db    4,'9600$'
  3192.     dw    12
  3193.  
  3194. sphtbl:    db    cr,lf
  3195.     db    '    50    75   110 134.5   200   300   450   600   900  1200'
  3196.     db    cr,lf,'  1800  2400  3600  4800  7200  9600 19200 38400 56000$'
  3197. ENDIF;heath
  3198.  
  3199. IF norths
  3200. spdtbl:    db    8        ; 8 entries
  3201.     db    3,'110$',    07H,07H
  3202.     db    4,'1200$',    04H,04H
  3203.     db    5,'19200$',    00H,00H
  3204.     db    4,'2400$',    03H,03H
  3205.     db    3,'300$',    06H,06H
  3206.     db    4,'4800$',    02H,02H
  3207.     db    3,'600$',    05H,05H
  3208.     db    4,'9600$',    01H,01H
  3209.  
  3210.  
  3211. sphtbl:    db    cr,lf
  3212.     db    '   110   300   600  12000  2400  4800  9600 19200$'
  3213. ENDIF;norths
  3214.  
  3215.  
  3216. IF cmemco            ;[25]
  3217. spdtbl:    db    7        ; 7 entries
  3218.     db    3,'110$',    01H,01H
  3219.     db    4,'1200$',    88H,88H
  3220.     db    3,'150$',    82H,82H
  3221.     db    4,'2400$',    90H,90H
  3222.     db    3,'300$',    84H,84H
  3223.     db    4,'4800$',    0A0H,0A0H
  3224.     db    4,'9600$',    0C0H,0C0H
  3225.  
  3226. sphtbl:    db    cr,lf
  3227.     db    '   110   150   300  1200  2400  4800  9600$'
  3228. ENDIF;cmemco
  3229.  
  3230. IF cifer    ;[17]
  3231. spdtbl    equ    0        ; for the time being.. lets get it working
  3232. sphtbl    equ    0        ; ditto
  3233. ENDIF;cifer
  3234.  
  3235. IF torch    ;[17]
  3236. spdtbl:    db    8        ; 8 entries
  3237.     db    4,'1200$',    4,4
  3238.     db    3,'150$',    2,2
  3239.     db    5,'19200$',    8,8
  3240.     db    4,'2400$',    5,5
  3241.     db    3,'300$',    3,3
  3242.     db    4,'4800$',    6,6
  3243.     db    2,'75$',    1,1
  3244.     db    4,'9600$',    7,7
  3245.  
  3246. sphtbl:    db    cr,lf,'    75    150    300  1200  2400  4800  9600 19200$'
  3247. ENDIF;torch [17]
  3248.  
  3249. IF pci2651
  3250. spdtbl:    db    16        ; sixteen entries for PCI
  3251.     db    3,'110$',    2,2
  3252.     db    4,'1200$',    7,7
  3253.     db    3,'134$',    3,3
  3254.     db    3,'150$',    4,4
  3255.     db    4,'1800$',    8,8
  3256.     db    5,'19200$',    15,15
  3257.     db    4,'2000$',    9,9
  3258.     db    4,'2400$',    10,10
  3259.     db    3,'300$',    5,5
  3260.     db    4,'3600$',    11,11
  3261.     db    4,'4800$',    12,12
  3262.     db    2,'50$',    0,0
  3263.     db    3,'600$',    6,6
  3264.     db    4,'7200$',    13,13
  3265.     db    2,'75$',    1,1
  3266.     db    4,'9600$',    14,14
  3267.  
  3268. sphtbl:    db    '     50     75    110    134    150    300    600   1200   '
  3269.     db    cr,lf,'1800   2000   2400   3600   4800   7200   9600  19200$'
  3270. ENDIF    ;pci2651 [28]
  3271.  
  3272. IF access ;Similar to bbI with different values [29]
  3273. spdtbl:    db    6h            ;6 entries
  3274.     db    04h,'1200$',    28h,28h
  3275.     db    04h,'2400$',    14h,14h
  3276.     db    03h,'300$',    0a0h,0a0h
  3277.     db    04h,'4800$',    0ah,0ah
  3278.     db    03h,'600$',    50h,50h
  3279.     db    04h,'9600$',    5,5
  3280.  
  3281. sphtbl:    db    cr,lf,'  300  600  1200  2400  4800  9600$'
  3282. ENDIF;access [29]
  3283.  
  3284. IF mmate    ;[29]
  3285. spdtbl:    db    10h            ;16 entries
  3286.     db    03h,'110$',    0e2h,0e2h
  3287.     db    04h,'1200$',    0e7h,0e7h
  3288.     db    05h,'134.5$',    0e3h,0e3h
  3289.     db    03h,'150$',    0e4h,0e4h
  3290.     db    04h,'1800$',    0e8h,0e8h
  3291.     db    05h,'19200$',    0efh,0efh
  3292.     db    04h,'2000$',    0e9h,0e9h
  3293.     db    04h,'2400$',    0eah,0eah
  3294.     db    03h,'300$',    0e5h,0e5h
  3295.     db    04h,'3600$',    0ebh,0ebh
  3296.     db    04h,'4800$',    0ech,0ech
  3297.     db    02h,'50$',    0e0h,0e0h
  3298.     db    03h,'600$',    0e6h,0e6h
  3299.     db    04h,'7200$',    0edh,0edh
  3300.     db    02h,'75$',    0e1h,0e1h
  3301.     db    04h,'9600$',    0eeh,0eeh
  3302.  
  3303. sphtbl:    db    cr,lf,'   50  75    110    134.5  150    300    600   1200'
  3304.     db    cr,lf,' 1800   2000   2400   3600   4800   7200   9600  19200$'
  3305. ENDIF;mmate [29]
  3306.  
  3307. IF disc    ;[29]
  3308. ; Similar to mikko table but with different time constant values
  3309. spdtbl:    db    9h            ;9 entries
  3310.     db    03h,'110$'
  3311.     dw    1134
  3312.     db    04h,'1200$'
  3313.     dw    102h
  3314.     db    03h,'150$'
  3315.     dw    831
  3316.     db    04h,'2400$'
  3317.     dw    50
  3318.     db    03h,'300$'
  3319.     dw    415
  3320.     db    04h,'4800$'
  3321.     dw    24
  3322.     db    03h,'600$'
  3323.     dw    206
  3324.     db    02h,'75$'
  3325.     dw    1665
  3326.     db    04h,'9600$'
  3327.     dw    11
  3328.  
  3329. sphtbl:    db    cr,lf,'  75  110  150  300  600  1200  2400  4800  9600$'
  3330. ENDIF;disc    [29]
  3331.  
  3332.  
  3333. ; The following conditionals were once a huge if not statement.  There
  3334. ; wasn't enough room to add the lobo to the list, so it had to be broken
  3335. ; into 2, which you can't do with an if not.  I redid it as two ifs and
  3336. ; applied them to those that wouldn't set baud. [Hal Hostetler]
  3337. IF robin OR gener OR dmII OR vector OR z100 OR trs80 OR telcon
  3338. spdtbl    equ    0        ; SET BAUD not supported.
  3339. sphtbl    equ    0
  3340. ENDIF;robin OR gener OR dmII OR vector OR z100 OR trs80 OR telcon
  3341. ;
  3342. IF mmdI OR osi OR cpm3 OR apmmdm OR comart OR horizon OR basicns OR S1008 ; [29]
  3343. spdtbl    EQU    0        ;[hh] SET BAUD not supported.
  3344. sphtbl    EQU    0        ;[hh] ran out of room above...
  3345. ENDIF;mmdI OR osi OR cpm3 OR apmmdm OR comart OR horizon OR basicns OR S1008 [29]
  3346. ;
  3347.  
  3348. ;    This is the system-dependent SET PORT command.
  3349. ;    HL contains the argument from the command table.
  3350. sysprt:
  3351. IF lobo    ;[hh]
  3352.     mov    a,e        ;[hh] get the data port value and store at
  3353.     sta    outmd3+1    ;[hh] the two places we use...
  3354.     sta    inpmd2+1    ;[hh] MNPORT in the overlay
  3355.     sta    port        ;[hh] inform program of the change in ports
  3356.     inr    a        ;[hh] status port = data port + 1 in the Lobo
  3357.     sta    outmd1+1    ;[hh] store it at the three places...
  3358.     sta    inpmd1+1    ;[hh] we use MNPRTS...
  3359.     sta    outctl+1    ;[hh] in the overlay
  3360.     mov    a,d        ;[hh] now get the baud rate port value
  3361.     sta    getbd+1        ;[hh] store it in the two places we use...
  3362.     sta    setbd+1        ;[hh] BAUDRT in the overlay
  3363.     sta    port+1        ;[hh] don't need to, but keeps it consistant
  3364. getbd:    lda    baudrt        ;[hh] get baud rate value from port
  3365.     sta    speed        ;[hh] tell STAT. baud rate for each port
  3366.                 ;[hh] is independant of the other
  3367. ENDIF    ;lobo
  3368.  
  3369. IF iobyt
  3370.     mov    a,m        ;Get the I/O byte
  3371.     sta    prtiob        ;Save the desired IO byte for this port
  3372.     inx    h        ;Point at next entry
  3373.     mov    a,m        ;Get the output function
  3374.     sta    prtfun        ;Save it
  3375. ENDIF;iobyt
  3376.  
  3377. IF iobyt AND robin
  3378.     inx    h        ;Point at next entry
  3379.     mov    a,m        ;Get the hardware address for the port
  3380.     sta    prtadr        ;Store it
  3381. ENDIF;iobyt AND robin
  3382.     ret
  3383.  
  3384. ;
  3385. ;    Port tables for Lobo MAX-80
  3386. IF lobo    ;[hh]
  3387. ; help text
  3388. prhtbl:    db    cr,lf,'RS-232 port A or B$'
  3389. ;
  3390. ; command table
  3391. prttbl:    db    02H            ;[hh] two entries
  3392.     db    01H,'A$',0E4H,0D0H
  3393.     db    01H,'B$',0E6H,0D4H
  3394. ENDIF    ;lobo
  3395.  
  3396. ;
  3397. ;    Port tables for GENERIC CPM 2.2
  3398. IF gener
  3399. ; help text
  3400. prhtbl:    db    cr,lf,'CRT device'
  3401.     db    cr,lf,'PTR device'
  3402.     db    cr,lf,'TTY device'
  3403.     db    cr,lf,'UC1 device'
  3404.     db    cr,lf,'UR1 device'
  3405.     db    cr,lf,'UR2 device$'
  3406.  
  3407. ; command table
  3408. prttbl:    db    06H        ;Six devices to choose from
  3409.     db    03H,'CRT$'
  3410.         dw    crtptb
  3411.     db    03H,'PTR$'
  3412.         dw    ptrptb
  3413.     db    03H,'TTY$'
  3414.         dw    ttyptb
  3415.     db    03H,'UC1$'
  3416.         dw    uc1ptb
  3417.     db    03H,'UR1$'
  3418.         dw    ur1ptb
  3419.     db    03H,'UR2$'
  3420.         dw    ur2ptb
  3421.  
  3422. ; port entry table
  3423. ; table entries are:
  3424. ;    db    iobyte-value, BDOS output function, reserved
  3425. crtptb:    db    crtio,conout,0
  3426. ptrptb:    db    ptrio,punout,0
  3427. ttyptb:    db    ttyio,conout,0
  3428. uc1ptb:    db    uc1io,conout,0
  3429. ur1ptb:    db    ur1io,punout,0
  3430. ur2ptb:    db    ur2io,punout,0
  3431. ENDIF;gener
  3432.  
  3433.  
  3434. ;
  3435. ;    Port tables for DECmate II or MicroMikko or Acorn BBC
  3436. ;
  3437. IF dmII OR mikko OR bbc    ;[22]
  3438. ; help text
  3439. prhtbl:    db    cr,lf,'COMMUNICATIONS port$'
  3440.  
  3441. ; command table
  3442. prttbl:    db    01H        ;Only one port known at this point
  3443.     db    0EH,'COMMUNICATIONS$'
  3444.         dw    comptb    ;address of info
  3445.  
  3446. ; port entry table
  3447. ; table entries are:
  3448. ;    db    iobyte-value, BDOS output function, reserved
  3449. comptb:    db    batio,punout,0
  3450.  
  3451. ENDIF;[22] dmII OR mikko OR bbc
  3452.  
  3453. ;
  3454. ;    Port tables for Robin
  3455. ;
  3456. IF robin
  3457. ; help text
  3458. prhtbl:    db    cr,lf,'COMMUNICATIONS port'
  3459.     db    cr,lf,'GENERAL purpose port'
  3460.     db    cr,lf,'PRINTER port$'
  3461.  
  3462. ; command table
  3463. prttbl:    db    03H        ;Three entries
  3464.     db    0EH,'COMMUNICATIONS$'
  3465.         dw    comptb
  3466.     db    07H,'GENERAL$'
  3467.         dw    gppptb
  3468.     db    07H,'PRINTER$'
  3469.         dw    prnptb
  3470.  
  3471. ; port entry table
  3472. ; table entries are:
  3473. ;    db    iobyte-value, BDOS output function, hardware port address
  3474. ;                            (control/status)
  3475. ;
  3476. ;At present, the hardware port address is only used for sending a break.
  3477. comptb:    db    batio,punout,comtst
  3478. gppptb:    db    gppio,conout,gentst
  3479. prnptb:    db    lptio,conout,prntst
  3480.  
  3481. prtadr:    db    comtst        ;space for current hardware port address
  3482. ENDIF;robin
  3483.  
  3484. IF cifer            ; no ports yet...
  3485. prttbl    db    0
  3486. prhtbl    db    0        ;
  3487. ENDIF; cifer
  3488.  
  3489. IF iobyt
  3490. prtfun:    db    punout        ;Function to use for output to comm port
  3491. prtiob:    db    batio        ;I/O byte to use for communicating
  3492. coniob:    db    defio        ;I/O byte to use for console
  3493. ENDIF;iobyt
  3494.  
  3495. IF NOT (iobyt OR lobo)        ;[hh]
  3496. prttbl    equ    0        ; SET PORT is not supported
  3497. prhtbl    equ    0
  3498. ENDIF;NOT iobyt OR lobo
  3499.  
  3500. ;
  3501. ;    Set up screen display for file transfer
  3502. ;    called with kermit version in DE
  3503. ;
  3504. sysscr:    push    d        ; save version for a bit
  3505.     lxi    d,outlin    ; clear screen, position cursor
  3506.     call    prtstr        ; do it
  3507.     pop    d        ; get Kermit's version
  3508. IF NOT (osi OR crt)        ; got cursor control?
  3509.     call    prtstr        ; print it
  3510.     mvi    e,'['        ; open bracket
  3511.     call    outcon        ; print it (close bracket is in outln2)
  3512.     lxi    d,sysver    ; get name and version of system module
  3513.     call    prtstr
  3514.     lxi    d,outln2    ; yes, print field names
  3515.     call    prtstr
  3516.     lda    dbgflg        ; is debugging enabled?
  3517.     ora    a
  3518.     rz            ; finished if no debugging
  3519.     lxi    d,outln3    ; set up debugging fields
  3520.     call    prtstr
  3521. ENDIF;NOT (osi OR crt)
  3522.     ret
  3523.  
  3524. ;    Calculate free space for current drive
  3525. ;    returns value in HL
  3526. sysspc:
  3527.     lda    bdosvr        ;cpm3's alloc vect may be in another bank
  3528.     cpi    30H        ;cpm3 or later?
  3529.     jm    cp2spc        ;no: use cp/m 2 algorithm
  3530.     lda    fcb        ;If no drive, get
  3531.     ora    a        ; logged in drive
  3532.     jz    dir180
  3533.     dcr    a        ;FCB drive A=1 normalize to be A=0
  3534.     jmp    dir18a
  3535.  
  3536. dir180:    mvi    c,rddrv
  3537.     call    bdos
  3538. dir18a:    mov    e,a        ;drive in e
  3539.     mvi    c,getfs        ;get free space BDOS funct
  3540.     call    bdos        ;returns free recs (3 bytes in buff..buff+2)
  3541.     mvi    b,3        ;conv recs to K by 3 bit shift
  3542. dir18b:    xra    a        ;clear carry
  3543.     mvi    c,3        ;for 3 bytes
  3544.     lxi    h,buff+3    ;point to addr + 1
  3545. dir18c:    dcx    h        ;point to less sig. byte
  3546.     mov    a,m        ;get byte
  3547.     rar            ;carry -> A -> carry
  3548.     mov    m,a        ;put back byte
  3549.     dcr    c        ;for all bytes (carry not mod)
  3550.     jnz    dir18c
  3551.     dcr    b        ;shift 1 bit 3 times
  3552.     jnz    dir18b
  3553.     mov    e,m        ;get least sig byte
  3554.     inx    h
  3555.     mov    d,m        ;get most sig byte
  3556.     xchg            ;get K free in HL
  3557.     ret
  3558.  
  3559. ; the rest are CP/M 2.2 systems, so use the alloc vector
  3560. cp2spc:    mvi    c,getalv     ;Address of CP/M Allocation Vector
  3561.     call    bdos
  3562.     xchg            ;Get its length
  3563.     lhld    bmax
  3564.     inx    h
  3565.     lxi    b,0        ;Initialize Block count to zero
  3566. dir19:    push    d        ;Save allocation address
  3567.     ldax    d
  3568.     mvi    e,8        ;set to process 8 blocks
  3569. dir20:    ral            ;Test bit
  3570.     jc    dir20a
  3571.     inx    b
  3572. dir20a:    mov    d,a        ;Save bits
  3573.     dcx    h
  3574.     mov    a,l
  3575.     ora    h
  3576.     jz    dir21        ;Quit if out of blocks
  3577.     mov    a,d        ;Restore bits
  3578.     dcr    e        ;count down 8 bits
  3579.     jnz    dir20        ;do another bit
  3580.     pop    d        ;Bump to next count of Allocation Vector
  3581.     inx    d
  3582.     jmp    dir19        ;process it
  3583.  
  3584. dir21:    pop    d        ;Clear Allocation vector from stack
  3585.     mov    l,c        ;Copy block to 'HL'
  3586.     mov    h,b
  3587.     lda    bshiftf        ;Get Block Shift Factor
  3588.     sui    3        ;Convert from records to thousands
  3589.     rz            ;Skip shifts if 1K blocks
  3590. dir22:    dad    h        ;Multiply blocks by 'K per Block'
  3591.     dcr    a
  3592.     jnz    dir22
  3593.     ret
  3594.  
  3595.  
  3596. ;
  3597. ;    selmdm - select modem port
  3598. ;    selcon - select console port
  3599. ;    selmdm is called before using inpmdm or outmdm;
  3600. ;    selcon is called before using inpcon or outcon.
  3601. ;    For iobyt systems, diddle the I/O byte to select console or comm port;
  3602. ;    For Decision I, switches Multi I/O board to console or modem serial
  3603. ;    port.  [Toad Hall]
  3604. ;    For the rest, does nothing.
  3605. ;    preserves bc, de, hl.
  3606. selmdm:
  3607. IF iobyt
  3608.     lda    prtiob        ;Set up for output to go to the comm port
  3609.     sta    iobyte        ;Switch byte directly
  3610. ENDIF;iobyt
  3611.  
  3612. IF mdI
  3613.     lda    group
  3614.     ori    mdmgrp        ;Mask modem serial port
  3615.     out    grpsel
  3616. ENDIF;mdI  [Toad Hall]
  3617.  
  3618.     ret
  3619.  
  3620. selcon:
  3621. IF iobyt
  3622.     lda    coniob        ;Set up for output to go to the console port
  3623.     sta    iobyte        ;Switch directly
  3624. ENDIF;iobyt
  3625.  
  3626. IF mdI
  3627.     lda    group
  3628.     ori    congrp        ;Mask console serial port (1)
  3629.     out    grpsel
  3630. ENDIF;mdI  [Toad Hall]
  3631.  
  3632.     ret
  3633.  
  3634. ;    Get character from console, or return zero.
  3635. ;    result is returned in A.  destroys bc, de, hl.
  3636. ;
  3637. inpcon:
  3638. IF NOT iobyt
  3639.     mvi    c,dconio    ;Direct console I/O BDOS call.
  3640.     mvi    e,0FFH        ;Input.
  3641.     call    BDOS
  3642. ENDIF;NOT iobyt
  3643.  
  3644. IF iobyt
  3645.     call    bconst        ;Get the status
  3646.     ora    a        ;Anything there?
  3647.     rz            ;No, forget it
  3648.     call    bconin        ;Yes, get the character
  3649. ENDIF;iobyt
  3650.     ret
  3651.  
  3652. ;
  3653. ;    Output character in E to the console.
  3654. ;    destroys bc, de, hl
  3655. ;
  3656. outcon:
  3657.  
  3658. IF rm380z    ;[22]
  3659.     mov    a,e
  3660.     cpi    cr        ;cr produces cr + lf
  3661.     jnz    outcn1
  3662.     mvi    e,'N'-100O    ;Control-N produces cr only
  3663. outcn1:                ;continue
  3664. ENDIF;[22] rm380z
  3665.  
  3666. IF NOT iobyt
  3667.     mvi    c,dconio    ;Console output bdos call.
  3668.     call    bdos        ;Output the char to the console.
  3669. ENDIF;NOT iobyt
  3670.  
  3671. IF iobyt
  3672.     mov    c,e        ;Character
  3673.     call    bcnout        ;to Console
  3674. ENDIF;iobyt
  3675.     ret
  3676.  
  3677. ;
  3678. ;    outmdm - output a char from E to the modem.
  3679. ;        the parity bit has been set as necessary.
  3680. ;    returns nonskip; bc, de, hl preserved.
  3681. outmdm:
  3682. IF osi OR apple OR lobo        ;[hh]
  3683.     push    h
  3684. outmd1:    lxi    h,mnprts    ;address of the port status register
  3685. outmd2:    mov    a,m        ; get port status in A
  3686.     ani    output        ;Loop till ready.
  3687.     jz    outmd2
  3688. outmd3:    lxi    h,mnport    ;address of port data register
  3689.     mov    m,e        ; write the character
  3690.     pop    h
  3691.     ret
  3692. ENDIF;osi OR apple OR lobo
  3693.  
  3694. IF osbrn1
  3695.     call    osldst        ;Read the status port
  3696.     ani    output        ;Loop till ready.
  3697.     jz    outmdm
  3698.     mov    a,e
  3699.     jmp    osstda        ;Write to the data port
  3700. ENDIF;osbrn1
  3701.  
  3702. IF px8 ; [29]
  3703.         push    h
  3704.         push    b
  3705.         push    d
  3706. outmd1: call    rsoutst         ; get the output status
  3707.         ora     a
  3708.         jz      outmd1          ; check if output enabled
  3709.         pop     d
  3710.         mov     c, e            ; char in C
  3711.         push    d
  3712.         call    rsput
  3713.         pop     d
  3714.         pop     b
  3715.         pop     h
  3716.         ret
  3717. ENDIF; px8 [29]
  3718.  
  3719. IF inout
  3720.     in    mnprts        ;Get the output done flag.
  3721.     ani    output        ;Is it set?
  3722.     jz    outmdm        ;If not, loop until it is.
  3723.     mov    a,e
  3724.     out    mnport        ;Output it.
  3725.     ret
  3726. ENDIF;inout
  3727.  
  3728. IF iobyt
  3729. ;**** Note that we enter from outpkt with the I/O byte already set up for
  3730. ;  output to go to the comm port
  3731.     push    h
  3732.     push    b
  3733.     lda    prtfun        ;Get the output function
  3734.     mov    c,a        ;Into C
  3735.     call    bdos        ;And output the character
  3736.     pop    b
  3737.     pop    h
  3738.     ret
  3739. ENDIF;iobyt
  3740.  
  3741. IF cpm3
  3742.     push    h
  3743.     push    b
  3744.     mvi    c,auxout    ;Output to the aux output device
  3745.     call    bdos
  3746.     pop    b
  3747.     pop    h
  3748.     ret
  3749. ENDIF;cpm3
  3750.  
  3751.  
  3752. IF torch    ;[13] Torch stuff.  Requires some bit bashing
  3753.         ; via the BBC host computer (io computer)
  3754.         ; see also decription of osbyte later on
  3755. outdat:    lda    prinuse        ; get the printer in use flag
  3756.     ana    a        ; if set, then must use traditional osbyte,
  3757.     jnz    outda2        ; else...
  3758.     mov    a,e        ; get the byte to ssend [30]
  3759.     sta    outda1        ; little impure code [30]
  3760.     call    tx
  3761.     db    01        ; send to printer
  3762.     call    tx
  3763. outda1:    db    0        ; filled in by above [30]
  3764.     ret
  3765.  
  3766. outda2:    mov    a,e        ; get the byte to be sent s-l-o-w-l-y
  3767.     sta    txd        ; store for third parameter
  3768.            push    h
  3769.         lxi    h,txds        ; load for txdata via osbyte
  3770.         call    osbyte
  3771.            pop    h
  3772.     ret
  3773.  
  3774. instat:    push    h        ;get serial port status
  3775.         lxi    h,rxrs        ; load rxrdy string
  3776.         call    osbyte
  3777.            pop    h
  3778.         lda    xx
  3779.            ana    a        ; if zero, then nothing
  3780.         jz    notry
  3781.         jmp    rdy
  3782.  
  3783. outstat:push    h        ;get serial port status (tx)
  3784.         lxi    h,txrs        ; load string for tx ready string
  3785.         call    osbyte
  3786.            pop    h
  3787.         lda    xx        ; get reply byte from base proc.
  3788.           cpi    5        ; 5 spaces left?
  3789.         jm    notry
  3790.  
  3791.  
  3792. rdy:    mvi    a,0ffh        ; ready for data
  3793.            ana    a
  3794.            ret
  3795. notry:    xra    a
  3796.            ret
  3797.  
  3798.            ret
  3799. ENDIF    ;[13]
  3800.  
  3801.  
  3802.  
  3803. ;
  3804. ;    get character from modem; return zero if none available.
  3805. ;    for IOBYT systems, the modem port has already been selected.
  3806. ;    destroys bc, de, hl.
  3807. inpmdm:
  3808. IF iobyt
  3809.     call    bconst        ;Is Char at COMM-Port?
  3810.     ora    a        ;something there?
  3811.     rz            ; return if nothing there
  3812.     call    bconin        ; data present. read data.
  3813. ENDIF;iobyt
  3814.  
  3815. IF cpm3
  3816.     mvi    c,auxist
  3817.     call    bdos        ;is char at auxin?
  3818.     ora    a        ;something there?
  3819.     rz            ;no
  3820.     mvi    c,auxin
  3821.     call    bdos        ;read char from auxin
  3822. ENDIF;cpm3
  3823.  
  3824. IF osi OR apple OR lobo        ;[hh]
  3825. inpmd1:    lda    mnprts        ;Get the port status into A.
  3826.     ani    input        ;See if the input ready bit is on.
  3827.     rz            ;If not then return.
  3828. inpmd2:    lda    mnport        ;If so, get the char.
  3829. ENDIF;osi OR apple
  3830.  
  3831. IF osbrn1
  3832.     call    osldst        ;Read the status port
  3833.     ani    input        ;Something there?
  3834.     rz            ;Nope
  3835.     call    osldda        ;Read the data port
  3836. ENDIF;osbrn1
  3837.  
  3838. IF inout
  3839. ;Note: modem port should already be selected for mdI.  [Toad Hall]
  3840.     in    mnprts        ;Get the port status into A.
  3841.     ani    input        ;See if the input ready bit is on.
  3842.     rz            ;If not then return.
  3843.     in    mnport        ;If so, get the char.
  3844. ENDIF;inout
  3845.  
  3846. IF px8 ; [29]
  3847.         call    rserst          ; check error status
  3848.         ani     64h             ; this assumes 'not open' cannot occur
  3849.         jnz     inpmd1          ; error has occurred!
  3850.         call    rsinst          ; any chars outstanding?
  3851.         ora     a
  3852.         rz                      ; exit if none
  3853.         call    rsget           ; get char in A
  3854.         ret
  3855. ; return the 'no char outstanding' indication on error
  3856. inpmd1: mvi     a, 0
  3857. ENDIF; px8 [29]
  3858.  
  3859. IF torch        ;[13] torch input
  3860. indat:    push    h
  3861.         lxi    h,rxds
  3862.         call    osbyte
  3863.           pop    h
  3864.         lda    yy
  3865.           ani    7fh
  3866.     ret            ; rx data in a
  3867. ENDIF ;torch [13]
  3868.  
  3869. ret            ; return with character in A
  3870.  
  3871.  
  3872. ;
  3873. ;    flsmdm - flush comm line.
  3874. ;    Modem is selected.
  3875. ;    Currently, just gets characters until none are available.
  3876.  
  3877. flsmdm:    call    inpmdm        ; Try to get a character
  3878.     ora    a        ; Got one?
  3879.     jnz    flsmdm        ; If so, try for another
  3880.     ret            ; Receiver is drained.  Return.
  3881.  
  3882. ;
  3883. ;    outlpt - output character in E to printer
  3884. ;    console is selected.
  3885. ;    preserves de.
  3886. outlpt:
  3887.     push    d        ; save DE in either case
  3888.     call    prtflt        ; go through printer filter [30]
  3889.     ana    a        ; if A = 0 do nothing,
  3890.     jz    outlp1        ; [30] if a=0 do nothing
  3891.  
  3892. IF torch    ;[30] Must set printer routed to par port
  3893.     lxi    h,f51        ; fx 5,1 (parallel port selected for printer)
  3894.     call    osbyte
  3895. ;    lxi    h,f610        ; map out lf as these are usually added
  3896. ;    call    osbyte        ; by the printer,  alas.
  3897.     pop    d
  3898.     push    d        ; restore de regs
  3899. ENDIF    ;torch [30]
  3900.  
  3901. IF NOT iobyt
  3902.     mvi    c,lstout
  3903.     call    bdos        ;Char to printer
  3904. ENDIF;NOT iobyt
  3905. IF iobyt
  3906.     mov    c,e
  3907.     call    blsout
  3908. ENDIF;iobyt
  3909. IF torch    ; re-route printer to serial port => faster tx bytes to line [30]
  3910.     lxi    h,f52        ;fx 5,2
  3911.     call    osbyte
  3912.     lxi    h,f60        ;fx 6,0
  3913.     call    osbyte
  3914. ENDIF    ;torch [30]
  3915.  
  3916. outlp1:    pop    d        ; restore saved register pair
  3917.     ret
  3918.  
  3919. ;
  3920. ;    Screen manipulation routines
  3921. ;    csrpos - move to row B, column C
  3922. ;
  3923. ;    csrpos for terminals that use a leadin sequence followed
  3924. ;     by (row + 31.) and (column + 31.)
  3925. ;
  3926. IF NOT (robin OR dmII OR vt100 OR osi OR crt OR vector OR cifer OR torch )
  3927. csrpos:    push    b        ; save coordinates
  3928.     lxi    d,curldn    ; get cursor leadin sequence
  3929.     call    prtstr        ; print it
  3930.     pop    h        ; restore coordinates
  3931.     mov    a,h        ; get row
  3932.     adi    (' '-1)        ; space is row one
  3933.     mov    e,a
  3934.     push    h
  3935.     call    outcon        ; output row
  3936.     pop    h
  3937.     mov    a,l        ; get column
  3938.     adi    (' '-1)        ; space is column one
  3939.     mov    e,a
  3940.     jmp    outcon        ; output it and return
  3941. ENDIF;NOT (robin OR dmII OR vt100 OR osi OR crt OR vector OR cifer OR torch)
  3942. ;
  3943. ;
  3944. IF cifer        ; [14] cifer does it colums then rows.. swap b and c
  3945. csrpos:    push    b        ; save coordinates
  3946.     lxi    d,curldn    ; get cursor leadin sequence
  3947.     call    prtstr        ; print it
  3948.     pop    h        ; restore coordinates
  3949.     mov    a,l        ; [obs] get column
  3950.     adi    (' '-1)        ; space is column one
  3951.     mov    e,a
  3952.     push    h
  3953.     call    outcon        ; output row
  3954.     pop    h
  3955.     mov    a,h        ; [obs] get row
  3956.     adi    (' '-1)        ; space is row one
  3957.     mov    e,a
  3958.     jmp    outcon        ; output it and return
  3959. ENDIF; cifer [14]
  3960. ;
  3961. ;    csrpos for ANSI terminals
  3962. ;
  3963. IF robin OR dmII OR vt100
  3964. csrpos:    push    b        ; save coordinates
  3965.     lxi    d,curldn    ; get cursor leadin sequence
  3966.     call    prtstr        ; print it
  3967.     pop    h        ; peek at coordinates
  3968.     push    h        ;  then save away again
  3969.     mov    l,h        ; l = row
  3970.     mvi    h,0        ; hl = row
  3971.     call    nout        ; output in decimal
  3972.     mvi    e,';'        ; follow with semicolon
  3973.     call    outcon        ; print it
  3974.     pop    h        ; restore column
  3975.     mvi    h,0        ; hl = column
  3976.     call    nout
  3977.     mvi    e,'H'        ; terminate with 'move cursor' command
  3978.     jmp    outcon        ; output it and return
  3979. ENDIF;robin OR dmII OR vt100
  3980. ;
  3981. ;    csrpos for the Vector General.  It's weird.
  3982. ;
  3983. IF vector
  3984. csrpos: dcr    b        ; vector uses zero-based addressing?
  3985.     dcr    c
  3986.     push    b        ; save coordinates
  3987.     mvi    e,esc        ; print an escape
  3988.     call    outcon
  3989.     pop    d        ; peek at coordinates
  3990.     push    d
  3991.     call    outcon        ; output column
  3992.     pop    d
  3993.     mov    e,d        ; get row
  3994.     jmp    outcon        ; output and return
  3995. ENDIF;vector
  3996.  
  3997. ;[13] torch stuff follows
  3998. IF torch
  3999. ; This assumes no smartvdu functions..  and relies on BBC screen functions.
  4000. ; Has bias of -1 on column/row coords.  Column first.
  4001. ;  NOTE -- must use torch unique prtstr as cntl chars are trapped
  4002. ;          by the output routine.
  4003.  
  4004. csrpos:    push    b        ; save coordinates
  4005.     mvi    e,1fh        ; get cursor leadin sequence
  4006.     call    outcon        ; print it
  4007.     pop    h        ; restore coordinates
  4008.     mov    a,l        ; get column
  4009.     adi    0ffh        ; a zero is first (add minus 1)
  4010.     mov    e,a
  4011.     push    h
  4012.     call    outcon        ; output column
  4013.     pop    h
  4014.     mov    a,h        ; get row
  4015.     adi    0ffh        ; zero is first row
  4016.     mov    e,a
  4017.     jmp    outcon        ; output row
  4018. ENDIF ;torch [13]
  4019.  
  4020.  
  4021. IF osi OR crt            ; systems without cursor positioning
  4022. csrpos:    ret            ; dummy routine referenced by linkage section
  4023. ENDIF;osi OR crt
  4024.  
  4025. ;
  4026. ; position to various fields:
  4027. ; for the Kermits with cursor positioning, the display looks like this:
  4028. ;        5   10   15   20   25   30   35
  4029. ;      +----|----|----|----|----|----|----|...
  4030. ;    1 |
  4031. ;    2 |        Kermit-80 v4.0 [system]
  4032. ;    3 |
  4033. ;    4 |Number of packets: ____
  4034. ;    5 |Number of retries: ____
  4035. ;    6 |File name: ____________
  4036. ;    7 |<error>...
  4037. ;    8 |<status>...
  4038. ;    9 |RPack: ___(if debugging)...
  4039. ;   10 |
  4040. ;   11 |SPack: ___(if debugging)...
  4041. ;   12 |
  4042. ;   13 |Kermit-80  A:>    (when finished)
  4043. ;
  4044. ; For the PX-8, the display looks like:
  4045. ;           5    10   15   20   25   30   35   40   45   50   55
  4046. ;      +----|----|----|----|----|----|----|----|----|----|----|----|----
  4047. ;    1 |Kermit-80 v4.05 [Epson PX-8]            Number of retries: ____
  4048. ;    2 |Number of packets: ____                 File name: ________.___
  4049. ;    3 |<error>...
  4050. ;    4 |<status>...
  4051. ;    5 |RPack: ___ (if debugging)...
  4052. ;    6 |
  4053. ;    7 |SPack: ___ (if debugging)...
  4054. ;    8 |
  4055. ;    9 |Kermit-80 A:> (when finished)
  4056. ;
  4057.  
  4058. IF NOT px8 ; [29]
  4059. nppos   EQU     4*100h+20
  4060. rtpos   EQU     5*100h+20
  4061. fnpos   EQU     6*100h+12
  4062. errlin  EQU     7
  4063. stlin   EQU     8
  4064. rplin   EQU     9
  4065. splin   EQU     11
  4066. prplin  EQU     13
  4067. ENDIF ; NOT px8
  4068.  
  4069. IF px8
  4070. nppos   EQU     2*100h+20
  4071. rtpos   EQU     1*100h+59
  4072. fnpos   EQU     2*100h+51
  4073. errlin  EQU     3
  4074. stlin   EQU     4
  4075. rplin   EQU     5
  4076. splin   EQU     7
  4077. prplin  EQU     9
  4078. ENDIF ; px8 [29]
  4079.  
  4080. IF NOT (osi OR crt OR torch) ;[26] see also torch version below
  4081. scrnp:    lxi    b,nppos
  4082.     jmp    csrpos
  4083.  
  4084. scrnrt:    lxi    b,rtpos
  4085.     jmp    csrpos
  4086.  
  4087. scrfln:    lxi    b,fnpos
  4088.     call    csrpos
  4089. clreol:
  4090.     lxi    d,tk
  4091.     jmp    prtstr
  4092.  
  4093. screrr:    lxi    b,errlin*100H+1
  4094.     call    csrpos
  4095.     jmp    clreol
  4096.  
  4097. scrst:    lxi    b,stlin*100H+1
  4098.     call    csrpos
  4099.     jmp    clreol
  4100.  
  4101. rppos:    lxi    b,rplin*100H+8
  4102.     call    csrpos
  4103.     jmp    clreol
  4104.  
  4105. sppos:    lxi    b,splin*100H+8
  4106.     call    csrpos
  4107.     jmp    clreol
  4108.  
  4109. ; [29] Modify scrend to make the cursor line conditional on use of debugging
  4110. ; This means that in most cases the entire file transfer will fit on PX-8 lcd
  4111. scrend:    lda     dbgflg
  4112.         ora     a
  4113.         jz      scr1nd
  4114.         lxi    b,prplin*100H+1 ; debugging in use [29]
  4115.     jmp     scr2nd
  4116. scr1nd: lxi     b,rplin*100H+1  ; no debugging
  4117. scr2nd: call    csrpos
  4118. clreos:    lxi    d,tj
  4119.     jmp    prtstr
  4120. ; [29]  and nop out the rest for now...
  4121. ;
  4122. ;scrend:    lxi    b,prplin*100H+1
  4123. ;    call    csrpos
  4124. ;clreos:    lxi    d,tj
  4125. ;    jmp    prtstr
  4126. ENDIF;NOT (osi OR crt OR torch) [26]
  4127.  
  4128.  
  4129.  
  4130. IF torch    ;[26]  Torch version different, naturally, so duplicate 
  4131.         ;    the above code and add in querks.
  4132.  
  4133. scrnp:    lxi    b,nppos
  4134.     jmp    csrpos
  4135.  
  4136. scrnrt:    lxi    b,rtpos
  4137.     jmp    csrpos
  4138.  
  4139. scrfln:    lxi    b,fnpos
  4140.     call    csrpos
  4141. clreol:
  4142.     lxi    d,spac15    ; No clear to end of line, so fudge it...
  4143.     call    prtstr        ; by writing a load of spaces..
  4144.     lxi    b,fnpos        ; and re-position the cursor again
  4145.     jmp    prtstr
  4146.     lxi    d,tk
  4147.     jmp    prtstr
  4148.  
  4149. screrr:    lxi    b,errlin*100H+1
  4150.     call    csrpos
  4151.     jmp    clreol
  4152.  
  4153. scrst:    lxi    b,stlin*100H+1
  4154.     call    csrpos
  4155.     jmp    clreol
  4156.  
  4157. rppos:    lxi    b,rplin*100H+8
  4158.     call    csrpos
  4159.     jmp    clreol
  4160.  
  4161. sppos:    lxi    b,splin*100H+8
  4162.     call    csrpos
  4163.     jmp    clreol
  4164.  
  4165. scrend:    lxi    b,prplin*100H+1
  4166.     call    csrpos
  4167. clreos:    lxi    d,tj
  4168.     jmp    prtstr
  4169. ENDIF;torch [26]
  4170.  
  4171.  
  4172. IF osi OR crt    ; no cursor control
  4173. scrnp:    mvi    e,' '
  4174.     jmp    outcon
  4175.  
  4176. scrnrt:    mvi    e,' '
  4177.     call    outcon
  4178.     mvi    e,'%'
  4179.     jmp    outcon
  4180.  
  4181. scrfln:
  4182. screrr:
  4183. scrst:
  4184. scrend:    jmp    prcrlf        ;Print CR/LF    [Toad Hall]
  4185.  
  4186. rppos:    lxi    d,prpack
  4187.     jmp    prtstr
  4188.  
  4189. sppos:    lxi    d,pspack
  4190.     jmp    prtstr
  4191. ENDIF;osi OR crt
  4192.  
  4193. ;
  4194. ; delchr - make delete look like a backspace.  Unless delete is a printing
  4195. ;    character, we just need to print a backspace. (we'll output clrspc
  4196. ;    afterwards)
  4197. ;    For Kaypro and Vector General, delete puts a blotch on the screen.
  4198. ;    For Apple and Osborne 1, delete moves but doesn't print.
  4199. delchr:
  4200.  
  4201. IF bbI OR vector OR apple OR osbrn1 OR lobo
  4202.     lxi    d,delstr
  4203.     jmp    prtstr
  4204. ENDIF;bbI OR vector OR apple OR osbrn1 OR lobo
  4205.  
  4206. IF advant OR bbc OR rm380z    ;[22]
  4207.     ret
  4208. ENDIF;[22] advant OR bbc OR rm380z
  4209.  
  4210. IF NOT (bbI OR vector OR apple OR osbrn1 OR torch OR advant OR bbc OR rm380z);[22]
  4211.     mvi    e,bs        ;get a backspace
  4212.     jmp    outcon
  4213. ENDIF;NOT (bbI OR vector OR apple OR osbrn1 OR torch OR advant OR bbc OR rm380z [22]
  4214.  
  4215. ; erase the character at the current cursor position
  4216. clrspc:    mvi    e,' '
  4217.     call    outcon
  4218.     mvi    e,bs        ;get a backspace
  4219.     jmp    outcon
  4220.  
  4221. ; erase the current line
  4222. clrlin:    lxi    d,eralin
  4223.     jmp    prtstr
  4224.  
  4225. ; erase the whole screen, and go home. preserves b (but not c)
  4226. clrtop:    lxi    d,erascr
  4227.     jmp    prtstr
  4228.  
  4229. ; Some frequently-used routines (duplicates of those in CP4MIT):
  4230. ;    prcrlf - output a CR/LF
  4231. ;    prtstr - output string in DE
  4232. ;    rskp - return, skipping over error return
  4233. prcrlf:    lxi    d,crlf
  4234.  
  4235. ;[26] re-inserted prtstr for normal machines as some belly-ache at 
  4236. ; Torch code below (ie DOS function 9 emulation).  Save regs just in case
  4237. prtstr:
  4238. IF NOT (torch OR px8)    ;ie any machine that can send ctrl chrs via dos call 9
  4239.     push    b
  4240.     mvi    c,9    ; Dos call 9 (print a string)
  4241.     call    bdos
  4242.     pop    b
  4243.     ret        ; all done for good machines
  4244. ENDIF    ;NOT torch [26] OR px8 [31]
  4245.  
  4246. IF (torch OR px8)    ; Now for the not-so-good machine(s)
  4247. ;  [17] added this  to avoid prtstr.. emulate function 9 call.
  4248. ;
  4249. ;    Modified print string as the CP/N (for Nut) system traps control
  4250. ;    characters in a function 9 call.. rot its cotton socks.
  4251.     push    h
  4252.     push    d
  4253.     push    b
  4254. prtst1:
  4255.     ldax    d
  4256.     inx    d
  4257.     cpi    '$'        ; if a dollar then end of string
  4258.     jz    prtst2
  4259.     push    d
  4260.     mov    e,a
  4261.     call    outcon        ; send it to the screen
  4262.     pop    d
  4263.     jmp    prtst1
  4264.  
  4265. prtst2:    pop    b
  4266.     pop    d
  4267.     pop    h
  4268.     ret            ; regs restored.. just in case
  4269. ENDIF    ;torch  [17] [26] OR px8 [31]
  4270.  
  4271. rskp:    pop    h        ; Get the return address
  4272.     inx    h        ; Increment by three
  4273.     inx    h
  4274.     inx    h
  4275.     pchl
  4276.  
  4277. ;    Copy block of data
  4278. ;    source in HL, destination in DE, byte count in BC
  4279. ;    called by: cp4sys, mfname
  4280. ;
  4281. mover:
  4282. IF NOT z80        ; 8080's have to do it the hard way
  4283.     mov    a,m
  4284.     stax    d
  4285.     inx    h
  4286.     inx    d
  4287.     dcx    b
  4288.     mov    a,b
  4289.     ora    c
  4290.     jnz    mover
  4291. ENDIF;NOT z80
  4292. IF z80
  4293.     db    0EDh,0B0h    ; Z80 LDIR instruction
  4294. ENDIF;z80
  4295.     ret
  4296.  
  4297. IF torch    ;[13]
  4298. ; OSBYTE call from Torch to BBC Base Processor.
  4299. ;
  4300. ;  Two entries, one for call if (hl) points to three bytes which are
  4301. ;        Osbyte type
  4302. ;        X register byte (Parameter 2)
  4303. ;        Y register byte    (Parameter 3)
  4304. ;
  4305. ;        second entry where
  4306. ;        A register has osbyte type
  4307. ;        D register has equivalent X regiter of Beeb (Parameter 2)
  4308. ;        E register has equivalent Y register of 6502 (parametr 3)
  4309. ;
  4310. ;  Both have reply parameters equivaletnt to the Beeb 6502 processors X and Y
  4311. ;    registers as xx and yy address locations below.
  4312. ;
  4313. ;    A little impure code never hurt anyone...
  4314. ;
  4315.  
  4316. tx    equ    0ffc3h        ; tx routine to talk to base board proc.
  4317. rx    equ    0ffc6h        ; rx ditto
  4318.  
  4319. osbyt1:    sta    p1        ; accumulator to p1 (Type of osbyte)
  4320.     mov    a,d        ; get ls bits of input parameter
  4321.     sta    p2        ; second parameter from d
  4322.     mov    a,e        ;
  4323.     sta    p3        ; third parameter from e
  4324.     jmp    osbytx        ; now do funny torch call that calls an osbyte
  4325.  
  4326.  
  4327. osbyte:    mov    a,m
  4328.         sta    p1
  4329.            inx    h
  4330.            mov    a,m
  4331.         sta    p2
  4332.            inx    h
  4333.            mov    a,m
  4334.         sta    p3
  4335. osbytx:
  4336.         call    tx    ;set it for user function
  4337.            db    15
  4338.         call    tx    ; select function is osbyte
  4339.            db    15
  4340.         call    tx    ; now do call to osbyte proper
  4341. p1:    db    0
  4342.         call    tx
  4343. p2:    db    0
  4344.         call    tx    ; three params there,
  4345. p3:    db    0
  4346.         call    rx
  4347.         sta    xx    ; stor return value
  4348.         call    rx
  4349.         sta    yy    ; and second returned value
  4350.            ret
  4351.  
  4352. txrs:    db    128,253,0    ; string for txstatus
  4353. txds:    db    138,2
  4354. txd:    db    0        ; place data to be sent
  4355. rxrs:    db    128,254,0    ; get rx status string
  4356. rxds:    db    145,1,0
  4357. xx:    db    0
  4358. yy:    db    0        ; returned data from osbyte call
  4359. rs423m:    db    204,0,0
  4360. rs423n:    db    205,0,0
  4361. f31:    db    3,0,1        ; enable 423. uses xx=(xx AND Y) EOR X
  4362. f22:    db    2,2,0
  4363. f51:    db    5,1,0        ; fx 5,1 sets printer to parallel port [30]
  4364. f52:    db    5,2,0        ; 432 as printer => faster tx to line [30]
  4365. f60:    db    6,0,0        ; allow line feed chars [30]
  4366. f610:    db    6,10,0        ; add strip line feeds from prinetr stream [30]
  4367. prinuse:db    0        ; 0=> fast tx, <>0 => slow tx to serial pt. [30]
  4368. ENDIF    ;torch [13]
  4369.  
  4370. IF Torch    ;[27]
  4371. ;Peek and Poke routines for the Torch systems.. Needed to check if TX empty
  4372. ;
  4373. ; PEEK - On entry, has address to be snooped at in HL
  4374. ;      - On return, has the data at that address in tha A register
  4375. ;
  4376. ; POKE - On entry, has the address to be poked in HL, and the data in A
  4377. ;      - Nothing returned.
  4378. ;
  4379. ; Assume all other registers and flags corrupted
  4380. ;
  4381. ;
  4382. peek:    mvi    a,peekb        ; byte for tx routine to peek ram
  4383.     sta    ppbyte        ; save it in impure code
  4384.     call    peekpoke    ; do common code
  4385.     call    rx        ; and get peeked byte back in accumulator
  4386.     ret
  4387.  
  4388. poke:    sta    pbyte        ; save byte to be poked
  4389.     mvi    a,pokeb        ; byte for tx routne to poke to ram
  4390.     sta    ppbyte        ; save it in impure code
  4391.     call    peekpoke    ;call common routine
  4392.     call    tx        ; interprocessor tx routine
  4393. pbyte:    db    0        ; byte to be poked placed here
  4394.     ret            ; and return
  4395.  
  4396.  
  4397. peekpoke:            ; common routine for peek-ing and 
  4398.                 ; poke-ing to the base processor memory map.
  4399.     mov    a,l        ; get the taget address to this routine
  4400.     sta    lobyte
  4401.     mov    a,h        ; ditto high address byte
  4402.     sta    hibyte
  4403.     call    tx        ; call the interprocessor send routine
  4404. ppbyte:    db    0        ; this byte to be filled by the peek or poke routine
  4405.     call    tx        ; now send address
  4406. lobyte:    db    0        ; low address byte to be sent
  4407.     call    tx
  4408. hibyte:    db    0        ; high address byte
  4409.     ret            ; now do either a peek (rx) or poke (tx)
  4410. ;
  4411. peekb    equ    0dh        ; byte to initiate a peek
  4412. pokeb    equ    0eh        ; byte to initiate a poke
  4413. ENDIF ;torch [27]
  4414.  
  4415.  
  4416.  
  4417. ;
  4418. ;    Miscellaneous messages
  4419. ;
  4420. crlf:    db    cr,lf,'$'
  4421.  
  4422. cfgmsg:    db    'configured for $'
  4423.  
  4424. IF adm3a OR tvi912 OR tvi925 OR vt52 OR vt100 OR smrtvd    OR access; [7] [29]
  4425. witmsg:    db    ' with $'
  4426. ENDIF;adm3a OR tvi912 OR tvi925 OR vt52 OR vt100 OR smrtvd OR access [7] [29]
  4427.  
  4428. ;**************************Terminal tables****************************
  4429. IF NOT (osi OR crt) AND NOT px8    ; [29] got cursor control?
  4430. outln2:    db    ']',cr,lf,cr,lf,'Number of packets:'
  4431.     db    cr,lf,'Number of retries:'
  4432.     db    cr,lf,'File name:$'
  4433. ENDIF;NOT (osi OR crt) AND NOT px8 [29]
  4434.  
  4435. IF px8    ; [29]
  4436. outln2: db      ']           Number of retries:', cr, lf
  4437.         db      'Number of packets:                     File name:$'
  4438. ENDIF ; px8 [29]
  4439.  
  4440. IF NOT (osi OR crt) ; [29]
  4441. outln3:    db    cr,lf,cr,lf    ; debugging messages
  4442.     db    cr,lf,'Rpack:'
  4443.     db    cr,lf        ; Blank line in case of long packet
  4444.     db    cr,lf,'Spack:$'
  4445. ENDIF ; NOT (osi OR crt) [29]
  4446.  
  4447. IF lobo    ;[hh]
  4448. sysver:    db    'Lobo MAX-80$'
  4449. outlin:    db    esc,'*',cr,lf,tab,tab,'$'
  4450. erascr:    db    esc,'*$'        ;[hh] clear screen and home cursor
  4451. eralin:    db    cr,esc,'R$'        ;[hh] clear line
  4452. curldn:    db    esc,'=$'        ;[hh] cursor lead-in string
  4453. delstr:    db    bs,' ',bs,bs,'$'    ;[hh] ??adjust for echoing delete
  4454. ttab:                    ;[hh] table start location
  4455. ta:    db    0BH,'$',0,0        ;[hh] cursor up
  4456. tb:    db    0AH,'$',0,0        ;[hh] cursor down
  4457. tc:    db    0CH,'$',0,0        ;[hh] cursor right
  4458. td:    db    08H,'$',0,0        ;[hh] cursor left
  4459. te:    db    esc,'*$',0        ;[hh] clear display (homes cursor)
  4460. tf:    db    '$',0,0,0        ;[hh] (can't) enter graphics mode
  4461. tg:    db    '$',0,0,0        ;[hh] (can't) exit graphics mode
  4462. th:    db    01EH,'$',0,0        ;[hh] home cursor
  4463. ti:    db    esc,'E$',0        ;[hh] reverse linefeed (insert line)
  4464. tj:    db    esc,'Y$',0        ;[hh] clear to end of screen
  4465. tk:    db    esc,'T$',0        ;[hh] clear to end of line
  4466. ENDIF    ;lobo
  4467.  
  4468.  
  4469. IF brain
  4470. sysver:    db    'Intertec SuperBrain$'
  4471. outlin:    db    ('A'-100O),esc,'~k',cr,lf,tab,tab,'$'
  4472. erascr:    db    ('A'-100O),esc,'~k$'     ;Clear screen and go home.
  4473. eralin:    db    cr,esc,'~K$'        ;Clear line.
  4474. curldn:    db    esc,'Y$'        ; leadin for cursor positioning
  4475. ttab:                    ;Table start location.
  4476. ta:    db    ('K'-100O),'$',0,0    ;Cursor up.
  4477. tb:    db    12O,'$',0,0        ;Cursor down.
  4478. tc:    db    ('F'-100O),'$',0,0    ;Cursor right.
  4479. td:    db    '$',0,0,0        ;(can't) Cursor left
  4480. te:    db    '$',0,0,0        ;(can't) Clear display
  4481. tf:    db    '$',0,0,0        ;(can't) Enter graphics mode
  4482. tg:    db    '$',0,0,0        ;(can't) Exit graphics mode
  4483. th:    db    ('A'-100O),'$',0,0    ;Cursor home.
  4484. ti:    db    ('K'-100O),'$',0,0    ;Reverse linefeed.
  4485. tj:    db    esc,'~k$',0        ;Clear to end of screen.
  4486. tk:    db    esc,'~K$',0        ;Clear to end of line.
  4487. ENDIF;brain
  4488.  
  4489. IF px8 ; [29]
  4490. sysver: db      'Epson PX-8$'
  4491. outlin: db      esc,'*$'
  4492. erascr: db      esc,'*$'    ; clear screen and home
  4493. eralin: db      cr,esc,'T$' ; clear line
  4494. curldn: db      esc,'=$'    ; cursor lead in
  4495. ttab:                       ; table start location
  4496. ta:     db      30,'$',0,0  ; cursor up
  4497. tb:     db      31,'$',0,0  ; cursor down
  4498. tc:     db      28,'$',0,0  ; cursor right
  4499. td:     db      29,'$',0,0  ; cursor left
  4500. te:     db      esc,'*$',0  ; clear display
  4501. tf:     db      '$',0,0,0   ; can't enter graphics graphics mode
  4502. tg:     db      '$',0,0,0   ; can't exit graphics mode
  4503. th:     db      11,'$',0,0  ; home cursor
  4504. ti:     db      30,'$',0,0  ; reverse linefeed
  4505. tj:     db      esc,'Y$',0  ; erase to end of screen
  4506. tk:     db      esc,'T$',0  ; erase to end of line
  4507. ENDIF ; px8 [29]
  4508.  
  4509.  
  4510. IF osbrn1
  4511. sysver:    db    'Osborne 1$'
  4512. outlin:    db    1AH,cr,lf,tab,'$'    ;(Clear screen, home cursor)
  4513. erascr:    db    1AH,'$'            ;Clear screen and go home.
  4514. eralin:    db    cr,esc,'T$'        ;Clear line.
  4515. delstr:    db    bs,bs,'$'        ; Adjust for delete
  4516. curldn:    db    esc,'=$'        ;Cursor lead-in
  4517. ttab:                    ;Table start location.
  4518. ta:    db    ('K'-100O),'$',0,0    ;Cursor up.
  4519. tb:    db    12O,'$',0,0        ;Cursor down.
  4520. tc:    db    ('L'-100O),'$',0,0    ;Cursor right.
  4521. td:    db    bs,'$',0,0        ;Cursor left.
  4522. te:    db    subt,'$',0,0        ;Clear screen.
  4523. tf:    db    '$',0,0,0        ;(can't) Enter graphics mode
  4524. tg:    db    '$',0,0,0        ;(can't) Exit graphics mode
  4525. th:    db    ('^'-100O),'$',0,0    ;Cursor home.
  4526. ti:    db    ('K'-100O),'$',0,0    ;Reverse linefeed.
  4527. tj:    db    esc,'T$',0        ;(can't) Clear to end of screen.
  4528. tk:    db    esc,'T$',0        ;Clear to end of line.
  4529. ENDIF;osbrn1
  4530.  
  4531. IF apple
  4532. sysver:    db    'Apple II CP/M$'
  4533. outlin:    db    ('^'-100O),esc,'Y',cr,lf,'  $'
  4534. erascr:    db    ('^'-100O),esc,'Y$'    ;Clear screen and go home.
  4535. eralin:    db    cr,esc,'T$'        ;Clear line.
  4536. delstr:    db    bs,bs,'$'        ; Adjust for delete
  4537. curldn:    db    esc,'=$'        ;Cursor lead-in
  4538. ttab:                    ;Table start location.
  4539. ta:    db    ('K'-100O),'$',0,0    ;Cursor up.
  4540. tb:    db    12O,'$',0,0        ;Cursor down.
  4541. tc:    db    ('F'-100O),'$',0,0    ;Cursor right.
  4542. td:    db    '$',0,0,0        ;(can't) Cursor left
  4543. te:    db    '$',0,0,0        ;(can't) Clear display
  4544. tf:    db    '$',0,0,0        ;(can't) Enter graphics mode
  4545. tg:    db    '$',0,0,0        ;(can't) Exit graphics mode
  4546. th:    db    ('^'-100O),'$',0,0    ;Cursor home.
  4547. ti:    db    ('K'-100O),'$',0,0    ;Reverse linefeed.
  4548. tj:    db    esc,'Y$',0        ;Clear to end of screen.
  4549. tk:    db    esc,'T$',0        ;Clear to end of line.
  4550. ENDIF;apple
  4551.  
  4552. IF vector
  4553. sysver:    db    'Vector Graphics$'
  4554. outlin:    db    ('D'-100O),cr,lf,tab,tab,'$'
  4555. erascr:    db    ('D'-100O),'$'         ;Clear screen and go home.
  4556. eralin:    db    cr,('Q'-100O),'$'    ;Clear line.
  4557. delstr:    db    bs,' ',bs,bs,'$'    ; adjust for echoing delete character
  4558. ttab:                    ;Table start location.
  4559. ta:    db    ('U'-100O),'$',0,0    ;Cursor up.
  4560. tb:    db    12O,'$',0,0        ;Cursor down.
  4561. tc:    db    ('Z'-100O),'$',0,0    ;Cursor right.
  4562. td:    db    '$',0,0,0        ;(can't) Cursor left
  4563. te:    db    '$',0,0,0        ;(can't) Clear display
  4564. tf:    db    '$',0,0,0        ;(can't) Enter graphics mode
  4565. tg:    db    '$',0,0,0        ;(can't) Exit graphics mode
  4566. th:    db    ('B'-100O),'$',0,0    ;Cursor home.
  4567. ti:    db    ('U'-100O),'$',0,0    ;Reverse linefeed.
  4568. tj:    db    ('P'-100O),'$',0,0    ;Clear to end of screen.
  4569. tk:    db    ('Q'-100O),'$',0,0    ;Clear to end of line.
  4570. ENDIF;vector
  4571.  
  4572. IF telcon
  4573. sysver:    db    'Telcon Zorba$'
  4574. ENDIF;telcon
  4575.  
  4576. IF heath
  4577. sysver:    db    'Heath/Zenith 89$'
  4578. ENDIF;heath
  4579.  
  4580. IF z100
  4581. sysver:    db    'Heath/Zenith Z-100 CP/M$'
  4582. ENDIF;z100
  4583.  
  4584. IF vt52        ; DEC VT52
  4585. ttytyp:    db    'VT52$'
  4586. ENDIF;vt52
  4587.  
  4588. IF heath OR z100 OR telcon OR vt52
  4589. outlin:    db    esc,'H',esc,'J',cr,lf,tab,tab,'$'
  4590. erascr:    db    esc,'H',esc,'J$'     ;Clear screen and go home.
  4591. eralin:    db    cr,esc,'K$'        ;Clear line.
  4592. curldn:    db    esc,'Y$'        ;cursor leadin
  4593. ttab:                    ;Table start location.
  4594. ta:    db    esc,'A$',0        ;Cursor up.
  4595. tb:    db    esc,'B$',0        ;Cursor down.
  4596. tc:    db    esc,'C$',0        ;Cursor right.
  4597. td:    db    esc,'D$',0        ;Cursor left
  4598. te:    db    esc,'E$',0        ;Clear display
  4599. tf:    db    esc,'F$',0        ;Enter Graphics Mode
  4600. tg:    db    esc,'G$',0        ;Exit Graphics mode
  4601. th:    db    esc,'H$',0        ;Cursor home.
  4602. ti:    db    esc,'I$',0        ;Reverse linefeed.
  4603. tj:    db    esc,'J$',0        ;Clear to end of screen.
  4604. tk:    db    esc,'K$',0        ;Clear to end of line.
  4605. ENDIF;heath OR z100 OR telcon OR vt52
  4606.  
  4607. IF trs80lb
  4608. sysver:    db    'TRS-80 II Lifeboat CP/M$'
  4609. outlin:    db    esc,':',cr,lf,tab,tab,'$'
  4610. erascr:    db    esc,':$'        ;Clear screen and go home.
  4611. eralin:    db    cr,esc,'T$'        ;Clear line.
  4612. curldn:    db    esc,'=$'        ;Cursor lead-in
  4613. ttab:                    ;Table start location.
  4614. ta:    db    0BH,'$',0,0        ;Cursor up.
  4615. tb:    db    0AH,'$',0,0        ;Cursor down.
  4616. tc:    db    0CH,'$',0,0        ;Cursor right.
  4617. td:    db    bs,'$',0,0        ;Cursor left
  4618. te:    db    esc,':$',0        ;Clear display
  4619. tf:    db    '$',0,0,0        ;(can't) Enter Graphics Mode
  4620. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4621. th:    db    1EH,'$',0,0        ;Cursor home.
  4622. ti:    db    0BH,'$',0,0        ;Reverse linefeed.
  4623. tj:    db    esc,'Y$',0        ;Clear to end of screen.
  4624. tk:    db    esc,'T$',0        ;Clear to end of line.
  4625. ENDIF;trs80lb
  4626.  
  4627. IF trs80pt
  4628. sysver:    db    'TRS-80 II P+T CP/M$'
  4629. outlin:    db    0CH,cr,lf,tab,tab,'$'
  4630. erascr:    db    0CH,'$'            ;Clear screen and go home.
  4631. eralin:    db    cr,01H,'$'        ;Clear line.
  4632. curldn:    db    esc,'Y$'        ;Cursor lead-in
  4633. ttab:    ;Table start location        ;Must be 4 bytes each
  4634. ta:    db    1EH,'$',0,0        ;Cursor up.
  4635. tb:    db    1FH,'$',0,0        ;Cursor down.
  4636. tc:    db    1DH,'$',0,0        ;Cursor right.
  4637. td:    db    1CH,'$',0,0        ;Cursor left
  4638. te:    db    0CH,'$',0,0        ;Clear display
  4639. tf:    db    11H,'$',0,0        ;Enter Graphics Mode
  4640. tg:    db    14H,'$',0,0        ;Exit Graphics mode
  4641. th:    db    06H,'$',0,0        ;Cursor home.
  4642. ti:    db    1EH,'$',0,0        ;Reverse linefeed.
  4643. tj:    db    02H,'$',0,0        ;Clear to end of screen.
  4644. tk:    db    01H,'$',0,0        ;Clear to end of line.
  4645. ENDIF;trs80pt
  4646.  
  4647. IF robin
  4648. sysver:    db    'VT180 "Robin"$'
  4649. ENDIF;robin
  4650.  
  4651. IF dmII
  4652. sysver:    db    'DECmate II CP/M-80$'
  4653. ENDIF;dmII
  4654.  
  4655. IF vt100
  4656. ttytyp:    db    'VT100$'
  4657. ENDIF;vt100
  4658.  
  4659. IF norths
  4660. sysver:    db    'Northstar Horizon$'
  4661. ENDIF;norths
  4662.  
  4663. IF basicns    ;[29]
  4664. sysver:    db    'Northstar using printer port$'
  4665. ttytyp:    db    0
  4666. ENDIF    ;basicns [29]
  4667.  
  4668. IF comart    ;[25]
  4669. sysver:    db    'Comart Communicator$'
  4670. ENDIF;comart
  4671.  
  4672. IF horizon    ;[25]
  4673. sysver:    db    'Northstar Horizon$'
  4674. ENDIF;horizon
  4675.  
  4676. IF cmemco    ;[25]
  4677. sysver:    db    'Cromemco (TU-ART)$'
  4678. ENDIF;cmemco
  4679.  
  4680. IF robin OR dmII or vt100
  4681. ; Note that we cannot support Graphics Mode or the H19 erase-screen command
  4682. ; (<esc>E), because the sequences are more than three bytes.
  4683. outlin:    db    esc,3CH,esc,'[H',esc,'[J',cr,lf,tab,tab,'$'
  4684. erascr:    db    esc,'[H',esc,'[J$'     ;Clear screen and go home.
  4685. eralin:    db    cr,esc,'[K$'        ;Clear line.
  4686. curldn:    db    esc,'[$'        ; Cursor leadin
  4687. ttab:
  4688. ta:    db    esc,'[A$'        ; Cursor up.
  4689. tb:    db    esc,'[B$'        ; Cursor down.
  4690. tc:    db    esc,'[C$'        ; Cursor right.
  4691. td:    db    esc,'[D$'        ; Cursor left
  4692. te:    db    '$',0,0,0        ; (can't) Clear display
  4693. tf:    db    '$',0,0,0        ; (don't) Enter Graphics Mode
  4694. tg:    db    '$',0,0,0        ; (don't) Exit Graphics mode
  4695. th:    db    esc,'[H$'        ; Cursor home.
  4696. ti:    db    esc,'M$',0        ; Reverse linefeed.
  4697. tj:    db    esc,'[J$'        ; Clear to end of screen.
  4698. tk:    db    esc,'[K$'        ; Clear to end of line.
  4699. ENDIF;robin OR dmII or vt100
  4700.  
  4701. IF kpii
  4702. sysver:    db    'Kaypro II$'
  4703. outlin:    db    subt,cr,lf,tab,tab,'$'
  4704. erascr:    db    subt,'$'        ;Clear screen and home.
  4705. eralin:    db    cr,18H,'$'        ;Clear line.
  4706. curldn:    db    esc,'=$'        ;Cursor lead-in
  4707. delstr:    db    bs,' ',bs,bs,'$'    ; adjust for echoing delete character
  4708. ttab:                    ;Table start location.
  4709. ta:    db    0BH,'$',0,0        ;Cursor up.
  4710. tb:    db    0AH,'$',0,0        ;Cursor down.
  4711. tc:    db    0CH,'$',0,0        ;Cursor right.
  4712. td:    db    bs,'$',0,0        ;Cursor left
  4713. te:    db    subt,'$',0,0        ;Clear display
  4714. tf:    db    esc,'G$',0        ; Enter Graphics Mode (select Greek)
  4715. tg:    db    esc,'A$',0        ; Exit Graphics mode (select ASCII)
  4716. th:    db    1EH,'$',0,0        ; Cursor home.        [UTK016]
  4717. ti:    db    esc,'E','$',0        ; Reverse linefeed. (insert line)
  4718. tj:    db    'W'-100O,'$',0,0    ; Clear to end of screen.
  4719. tk:    db    'X'-100O,'$',0,0    ; Clear to end of line.
  4720. ENDIF ; kpii
  4721.  
  4722. IF xer820
  4723. sysver:    db    'Xerox 820$'
  4724. outlin:    db    subt,cr,lf,tab,tab,'$'
  4725. erascr:    db    subt,'$'        ;Clear screen and home.
  4726. eralin:    db    cr,18H,'$'        ;Clear line.
  4727. curldn:    db    esc,'=$'        ;Cursor lead-in
  4728. delstr:    db    bs,' ',bs,bs,'$'    ; adjust for echoing delete character
  4729. ttab:                    ;Table start location.
  4730. ta:    db    0BH,'$',0,0        ;Cursor up.
  4731. tb:    db    0AH,'$',0,0        ;Cursor down.
  4732. tc:    db    0CH,'$',0,0        ;Cursor right.
  4733. td:    db    bs,'$',0,0        ;Cursor left
  4734. te:    db    subt,'$',0,0        ;Clear display
  4735. tf:    db    '$',0,0,0        ; Enter Graphics Mode (can't)
  4736. tg:    db    '$',0,0,0        ; Exit Graphics mode (can't)
  4737. th:    db    1EH,'$',0,0        ; Cursor home.        [UTK016]
  4738. ti:    db    0BH,'$',0,0        ; Reverse linefeed. (cursor up)
  4739. tj:    db    11H,'$',0,0        ; Clear to end of screen.
  4740. tk:    db    18H,'$',0,0        ; Clear to end of line.
  4741. ENDIF ; xer820
  4742.  
  4743. IF mikko
  4744. sysver:    db    'MikroMikko$'
  4745. outlin:    db    subt,cr,lf,tab,'$'
  4746. erascr:    db    subt,'$'        ;Clear screen and go home.
  4747. eralin:    db    cr,1CH,'$'        ;Clear line.
  4748. curldn:    db    esc,'=$'        ;cursor leadin
  4749. ttab:                    ;Table start location.
  4750. ta:    db    0BH,'$',0,0        ;Cursor up.
  4751. tb:    db    0AH,'$',0,0        ;Cursor down.
  4752. tc:    db    0CH,'$',0,0        ;Cursor right.
  4753. td:    db    bs,'$',0,0        ;Cursor left
  4754. te:    db    subt,'$',0,0        ;Clear display
  4755. tf:    db    '$',0,0,0        ;(can't) Enter Graphics Mode
  4756. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4757. th:    db    1EH,'$',0,0        ;Cursor home.
  4758. ti:    db    '$',0,0,0        ;(can't) Reverse linefeed.
  4759. tj:    db    1cH,'$',0,0        ;Clear to end of screen.
  4760. tk:    db    1cH,'$',0,0        ;Clear to end of line.
  4761. ENDIF;mikko
  4762.  
  4763. IF cifer    ;[13]
  4764. ttytyp:    db    'Cifer 1886$'
  4765. sysver:    db    ' Cifer 1886 $'        ;
  4766. outlin:    db    esc,'J',cr,lf,tab,tab,'$'
  4767. eralin:    db    esc,'^K$'        ;Clear to end of line.
  4768. erascr:    db    esc,'J$'         ;Clear screen and go home.
  4769. curldn:    db    esc,'P$'        ;Cursor lead-in
  4770. ttab:                    ;Table start location.
  4771. ta:    db    esc,'A$',0        ;Cursor up.
  4772. tb:    db    esc,'@$',0        ;Cursor down.
  4773. tc:    db    esc,'C$',0        ;Cursor right.
  4774. td:    db    esc,'D$',0        ;Cursor left.
  4775. te:    db    esc,'J',0,0        ;Clear screen and home cursor
  4776. tf:    db    '$',0,0,0        ;(can't) Enter Graphics mode
  4777. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4778. th:    db    esc,'H$',0        ;Cursor home.
  4779. ti:    db    esc,'@$',0        ;reverse linfeed
  4780. tj:    db    esc,'B$',0        ;Clear to end of screen
  4781. tk:    db    esc,'K$',0        ;Clear to end of line.
  4782. ;
  4783. ; Setup string for the Cifer.. called as a prtstr param. from sysinit
  4784. ciferi:    db    esc,'/'            ;Setup cifer for on line
  4785.     db    esc,'*['        ; direct mode on
  4786.     db    esc,'%'            ; protocol on host line on
  4787.     db    esc,'*~x'        ; protocol is xon/xoff
  4788.     db    esc,'*('        ; protocol out on host is xon/xoff
  4789.     db    '$'            ; all done
  4790. ENDIF;cifer    [13]
  4791.  
  4792. IF torch AND NOT crt    ;[13]
  4793. ttytyp:    db    'Torch Unicorn 5$'
  4794. sysver:    db    'Torch Unicorn 5$'
  4795. outlin:    db    0ch,cr,lf,tab,tab,'$'
  4796. eralin:    db    '$'            ;Clear to end of line.
  4797. erascr:    db    0ch,'$'             ;Clear screen and go home.
  4798. curldn:    db    1fh,'$'            ;Cursor lead-in
  4799. ttab:                    ;Table start location.
  4800. ta:    db    0bh,'$',0,0        ;Cursor up.
  4801. tb:    db    0ah,'$',0,0        ;Cursor down.
  4802. tc:    db    09h,'$',0,0        ;Cursor right.
  4803. td:    db    08h,'$',0,0        ;Cursor left.
  4804. te:    db    0ch,'$',0,0        ;Clear screen and home cursor
  4805. tf:    db    '$',0,0,0        ;(can't) Enter Graphics mode
  4806. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4807. th:    db    1eh,'$',0,0        ;Cursor home.
  4808. ti:    db    0bh,'$',0,0        ;reverse linfeed
  4809. tj:    db    '$',0,0,0        ;(Can't) Clear to end of screen
  4810. tk:    db    '$',0,0,0        ;(Can't) Clear to end of line.
  4811.  
  4812. ;Specials
  4813. spac15:    db    '               '
  4814.     db    bs,bs,bs,bs,bs,bs,bs,bs,bs,bs,bs,bs,bs,bs,bs,'$';
  4815. spac80:    db    cr
  4816.     db    '                                        '
  4817.     db    '                                        '
  4818.     db    bs,cr,'$'    ;80 spaces, bs and then back to line start
  4819.  
  4820. ENDIF;torch    [13]
  4821.  
  4822. IF advant    ;[22]
  4823. sysver:    db    'North Star Advantage$'
  4824. outlin:    db    04H,cr,lf,tab,'$'
  4825. erascr:    db    04H,'$'            ;Clear screen and go home.
  4826. eralin:    db    cr,0EH,'$'        ;Clear line.
  4827. curldn:    db    esc,'=$'        ;cursor leadin
  4828. ttab:                    ;Table start location.
  4829. ta:    db    0BH,'$',0,0        ;Cursor up.
  4830. tb:    db    0AH,'$',0,0        ;Cursor down.
  4831. tc:    db    0CH,'$',0,0        ;Cursor right.
  4832. td:    db    bs,'$',0,0        ;Cursor left
  4833. te:    db    04H,'$',0,0        ;Clear display
  4834. tf:    db    12H,'$',0,0        ;Enter Graphics Mode
  4835. tg:    db    13H,'$',0,0        ;Exit Graphics mode
  4836. th:    db    1EH,'$',0,0        ;Cursor home.
  4837. ti:    db    0BH,'$',0,0        ;Reverse linefeed.
  4838. tj:    db    0FH,'$',0,0        ;Clear to end of screen.
  4839. tk:    db    0EH,'$',0,0        ;Clear to end of line.
  4840. ENDIF;[22] advant
  4841.  
  4842. IF bbc        ;[22]
  4843. sysver:    db    'BBC (Z80)$'
  4844. outlin:    db    0CH,esc,'=',21H,30H,'$'
  4845. erascr:    db    0CH,'$'            ;Clear screen and go home.
  4846. eralin:    db    cr,esc,'@$'        ;Clear line.
  4847. curldn:    db    esc,'=$'        ;cursor leadin
  4848. ttab:                    ;Table start location.
  4849. ta:    db    0BH,'$',0,0        ;Cursor up.
  4850. tb:    db    0AH,'$',0,0        ;Cursor down.
  4851. tc:    db    tab,'$',0,0        ;Cursor right.
  4852. td:    db    bs,'$',0,0        ;Cursor left
  4853. te:    db    0CH,'$',0,0        ;Clear display
  4854. tf:    db    '$',0,0,0        ;(can't) Enter Graphics Mode
  4855. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4856. th:    db    1EH,'$',0,0        ;Cursor home.
  4857. ti:    db    '$',0,0,0        ;(can't) Reverse linefeed.
  4858. tj:    db    esc,'?$',0,0        ;Clear to end of screen.
  4859. tk:    db    esc,'@$',0,0        ;Clear to end of line.
  4860. ENDIF;[22] bbc
  4861.  
  4862. IF rm380z    ;[22]
  4863. sysver:    db    'Research Machines 380Z$'
  4864. outlin:    db    1FH,cr,tab,'$'
  4865. erascr:    db    1FH,'$'            ;Clear screen and go home.
  4866. eralin:    db    0EH,19H,'$'        ;Clear line.
  4867. curldn:    db    16H,'$'            ;cursor leadin
  4868. ttab:                    ;Table start location.
  4869. ta:    db    0BH,'$',0,0        ;Cursor up.
  4870. tb:    db    0AH,'$',0,0        ;Cursor down.
  4871. tc:    db    18H,'$',0,0        ;Cursor right.
  4872. td:    db    bs,'$',0,0        ;Cursor left
  4873. te:    db    1FH,'$',0,0        ;Clear display
  4874. tf:    db    '$',0,0,0        ;(can't) Enter Graphics Mode
  4875. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4876. th:    db    1DH,'$',0,0        ;Cursor home.
  4877. ti:    db    '$',0,0,0        ;(can't) Reverse linefeed.
  4878. tj:    db    1EH,'$',0,0        ;Clear to end of screen.
  4879. tk:    db    19H,'$',0,0        ;Clear to end of line.
  4880. ENDIF;[22] rm380z
  4881.  
  4882.  
  4883. IF gener or cpm3
  4884. sysver:    db    'Generic CP/M-80$'
  4885. ENDIF;gener or cpm3
  4886.  
  4887. IF bbII
  4888. sysver:    db    'Big Board II$'
  4889. ENDIF;bbII
  4890.  
  4891. IF cpt85xx
  4892. sysver:    db    'CPT-85xx under CompuPak CP/M$'
  4893. ENDIF;cpt85xx
  4894.  
  4895. IF mdI
  4896. sysver:    db    'Morrow Decision I$'
  4897. ENDIF;mdI  [Toad Hall]
  4898.  
  4899. IF mmdI
  4900. sysver:    db    'MicroDecision I$'
  4901. ENDIF;mmdI
  4902.  
  4903. IF osi
  4904. sysver:    db    'Ohio Scientific$'
  4905. ENDIF;osi
  4906.  
  4907. IF pci2651    ;[28]
  4908. sysver:    db    'LUT M/C 3 Standard 8 inch system$'
  4909. ENDIF    ;pci2651 [28]
  4910.  
  4911. IF mmate    ;[29]
  4912. sysver:    db    'PMC Micromate using port I/O$'
  4913. ENDIF;mmate [29]
  4914.  
  4915. IF disc        ;[29]
  4916. sysver:    db    'Discovery using 83U board port B$'
  4917. ENDIF  ;disc [29]
  4918.  
  4919. IF access    ;[29]
  4920. sysver:    db    'Actrix CP/M$'
  4921. ENDIF ; access [29]
  4922.  
  4923. IF s1008    ;[29]
  4924. sysver: db 'U. S. MicroSales using printer port'
  4925. ENDIF ;s1008 [29]
  4926.  
  4927. IF (access OR s1008)    ;[29]  Should this not be with terminals.....
  4928. ttytyp:    db    'Soroc IQ-120$'
  4929. outlin:    db    1EH,esc,'Y',cr,lf,tab,tab,'$'
  4930. erascr:    db    1EH,esc,'Y$'  ;clear screen and home cursor
  4931. eralin:    db    cr,esc,'T$'  ;clear line
  4932. curldn:    db    esc,'=$'  ;cursor lead-in string
  4933. delstr:    db    bs,' ',bs,bs,'$' ;??adjust for echoing delete
  4934. ttab:                    ;table start location
  4935. ta:    db    0BH,'$',0        ;cursor up
  4936. tb:    db    0AH,'$',0        ;cursor down
  4937. tc:    db    0CH,'$',0         ;cursor right
  4938. td:    db    08H,'$',0        ;cursor left
  4939. te:    db    esc,'*$',0        ;clear display (homes cursor)
  4940. tf:    db    esc,')$',0         ;enter inverse video mode
  4941. tg:    db    esc,'($',0        ;exit inverse video mode
  4942. th:    db    01EH,'$',0        ;home cursor
  4943. ti:    db    0BH,'$',0        ;reverse linefeed (insert line)
  4944. tj:    db    esc,'Y$',0        ;clear to end of screen
  4945. tk:    db    esc,'T$',0        ;clear to end of line
  4946. ENDIF;access [29]
  4947.  
  4948. IF osi OR crt
  4949. outlin:    db    cr,lf,'Starting ...$'
  4950. erascr    equ    crlf            ;"Home & clear" (best we can do).
  4951. eralin:    db    '^U',cr,lf,'$'        ;Clear line.
  4952. prpack:    db    cr,lf,'RPack: $'
  4953. pspack:    db    cr,lf,'SPack: $'
  4954. ttab    equ    0            ; no VT52 table
  4955. ENDIF;osi OR crt
  4956.  
  4957. IF tvi912
  4958. ttytyp:    db    'TVI912/920$'
  4959. outlin:    db    'Z'-64,0,0,cr,lf,'$'
  4960. erascr:    db    'Z'-64,0,0,'$'        ;Clear screen and home
  4961. eralin:    db    esc,'Y$',0        ;Clear to end of sreen
  4962. curldn:    db    cr,esc,'=$'        ;Cursor lead-in
  4963. ttab:    ;Table start location        ;(MUST be 4 bytes each)
  4964. ta:    db    'K'-64,'$',0,0        ;Cursor up, stop at top
  4965. tb:    db    'J'-64,'$',0,0        ;Cursor down, stop at bottom
  4966. tc:    db    'L'-64,'$',0,0        ;Cursor right, stop at right
  4967. td:    db    'H'-64,'$',0,0        ;Cursor left, stop at left
  4968. te:    db    'Z'-64,0,0,'$'        ;Clear display (2 pad nulls)
  4969. tf:    db    '$',0,0,0        ;(can't) Enter Graphics mode
  4970. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4971. th:    db    1EH,'$',0,0        ;Cursor home
  4972. ti:    db    esc,'j$',0        ;Reverse linefeed, scroll
  4973. tj:    db    esc,'Y$',0        ;Clear to end of sreen
  4974. tk:    db    esc,'T$',0        ;Clear to end of line
  4975. ENDIF;tvi912
  4976. ;
  4977.  
  4978. IF tvi925
  4979. ;(incidentally, works fine for Freedom 100 also  [Toad Hall])
  4980. ;adm3a entry and tvi925 entry separated to remove warning message.
  4981. ttytyp:    db    'TVI925$'
  4982. outlin:    db    'Z'-64,0,0,cr,lf,'$'
  4983. erascr:    db    'Z'-64,0,0,'$'        ;Clear screen and home
  4984. eralin:    db    esc,'Y$',0        ;Clear to end of sreen
  4985. curldn:    db    cr,esc,'=$'        ;Cursor lead-in
  4986. ttab:    ;Table start location        ;(MUST be 4 bytes each)
  4987. ta:    db    'K'-64,'$',0,0        ;Cursor up, stop at top
  4988. tb:    db    'V'-64,'$',0,0        ;Cursor down, stop at bottom
  4989. tc:    db    'L'-64,'$',0,0        ;Cursor right, stop at right
  4990. td:    db    'H'-64,'$',0,0        ;Cursor left, stop at left
  4991. te:    db    'Z'-64,0,0,'$'        ;Clear display (2 pad nulls)
  4992. tf:    db    '$',0,0,0        ;(can't) Enter Graphics mode
  4993. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  4994. th:    db    1EH,'$',0,0        ;Cursor home
  4995. ti:    db    esc,'j$',0        ;Reverse linefeed, scroll
  4996. tj:    db    esc,'Y$',0        ;Clear to end of sreen
  4997. tk:    db    esc,'T$',0        ;Clear to end of line
  4998. ENDIF;tvi925
  4999. ;
  5000.  
  5001. IF adm3a
  5002. ttytyp:    db    'ADM3A$'
  5003. outlin:    db    'Z'-64,0,0,cr,lf,'$'
  5004. erascr:    db    'Z'-64,0,0,'$'        ;Clear screen and home
  5005. eralin:    db    esc,'Y$',0        ;Clear to end of sreen
  5006. curldn:    db    cr,esc,'=$'        ;Cursor lead-in
  5007. ttab:    ;Table start location        ;(MUST be 4 bytes each)
  5008. ta:    db    'K'-64,'$',0,0        ;Cursor up, stop at top
  5009. tb:    db    'J'-64,'$',0,0        ;Cursor down CTRL-J
  5010. tc:    db    'L'-64,'$',0,0        ;Cursor right, stop at right
  5011. td:    db    'H'-64,'$',0,0        ;Cursor left, stop at left
  5012. te:    db    'Z'-64,0,0,'$'        ;Clear display (2 pad nulls)
  5013. tf:    db    '$',0,0,0        ;(can't) Enter Graphics mode
  5014. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  5015. th:    db    1EH,'$',0,0        ;Cursor home
  5016. ti:    db    'K'-64,'$',0,0        ;Reverse linefeed
  5017. tj:    db    '$',0,0,0        ;(can't) Clear to end of screen
  5018. tk:    db    '$',0,0,0        ;(can't) Clear to end of line
  5019. ENDIF;adm3a
  5020.  
  5021. IF delphi    ; [7] new system
  5022. sysver:    db    'Digicomp Delphi 100$'
  5023. endif;delphi
  5024.  
  5025. IF smrtvd    ; [7] new terminal
  5026. ttytyp:    db    'Smartvid-80$'
  5027. outlin:    db    esc,'+',cr,lf,tab,tab,'$'
  5028. eralin:    db    cr,esc,'T$'            ;Clear to end of line.
  5029. erascr:    db    esc,'+$'             ;Clear screen and go home.
  5030. curldn:    db    esc,'=$'            ;Cursor lead-in
  5031. ttab:                    ;Table start location.
  5032. ta:    db    ('K'-100O),'$',0,0    ;Cursor up.
  5033. tb:    db    12O,'$',0,0        ;Cursor down.
  5034. tc:    db    ('A'-100O),'$',0,0    ;Cursor right.
  5035. td:    db    ('H'-100O),'$',0,0    ;Cursor left.
  5036. te:    db    ('L'-100O),'$',0,0    ;Clear screen and home cursor
  5037. tf:    db    '$',0,0,0        ;(can't) Enter Graphics mode
  5038. tg:    db    '$',0,0,0        ;(can't) Exit Graphics mode
  5039. th:    db    ('Z'-100O),'$',0,0    ;Cursor home.
  5040. ti:    db    ('K'-100O),'$',0,0    ;Reverse linefeed.
  5041. tj:    db    esc,'Y$',0        ;Clear to end of screen.
  5042. tk:    db    esc,'T$',0        ;Clear to end of line.
  5043. ENDIF;smrtvd
  5044.  
  5045. IF (torch AND crt)
  5046. sysver:    db    'Torch Unicorn 5 without crt addressing$'
  5047. ENDIF
  5048.  
  5049. ovlend    equ    $    ; End of overlay
  5050.  
  5051.     END
  5052.