home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 300 / 257 / msxtipro.asm < prev    next >
Assembly Source File  |  1984-12-07  |  63KB  |  1,572 lines

  1. PAGE    60,132  ;60 lines, 132 columns
  2. TITLE   MSXTIPRO - Texas Instruments "Professional" code for KERMIT
  3. REVLVL  EQU 3   ;Revision level for this module, 29-Nov-84
  4.  
  5. ;************  REVISION HISTORY for MSXTIPRO.ASM  **********************
  6. ;
  7. ; REVLVL=1  29-Oct-84  First version to be able to transfer files
  8. ; REVLVL=2  14-Nov-84  Fixed bugs in version 1
  9. ; REVLVL=3  27-Nov-84  Added Tektronix-4010 emulation in CONNECT mode
  10. ;
  11. ;       -- CHANGES --
  12. ;
  13. ; MSXTIPRO has been tested with the Sync/Async Comm Card at all speeds from
  14. ; 110 to 9600 baud using SET PORT 1 thru SET PORT 4, and a 300-baud
  15. ; internal modem in port 3.
  16. ;
  17. ; To use the internal modem, SET PORT 3, SET BAUD 300, CONNECT.
  18. ; With external phone, type "O" to go into manual original mode.
  19. ; Or type "T1(617)467-7437X" to use the built-in dialer.  Capital T
  20. ; means to use touch-tones, capital X marks the end of the number.
  21. ;
  22. ; Terminal emulation works fine at 1200 baud, reasonably OK at 2400 baud
  23. ; if you use ".SET TERMINAL TYPE VT100 FILL 3" on TOPS-10.
  24. ;
  25. ; Can transfer file-packets at 9600 baud (but not 19.2 kbaud).
  26. ;
  27. ; The VT52 "identify yourself" sequence of ESC,'Z' triggers a response of
  28. ; ESC,'[?1;4c' which is a VT100 with graphics (but no STP, no printer).
  29. ;
  30. ;        -- BUGS --
  31. ;
  32. ; No known bugs at this time (28-Nov-84).
  33. ;
  34. ;        -- DEFICIENCIES --
  35. ;
  36. ; The STATUS command is wrong if you select port 2, 3, or 4.
  37. ;**** According to the MSXSYS.DOC, flags.comflg is supposed to be 0
  38. ;**** when using port 2.  This makes it difficult to use ports 3 and 4.
  39.         extrn port3:byte, port4:byte            ;********
  40. ;**** MSCOMM.ASM must be edited to define PORT3 and PORT4 like PORT1 and 2.
  41. ;**** You MUST edit MSCOMM.ASM, and add the following at line 17:
  42. ;        port3   prtinfo <0FFFH,0,defpar,1,0,defhand,floxon>
  43. ;        port4   prtinfo <0FFFH,0,defpar,1,0,defhand,floxon>
  44. ;
  45. ; The SET HEATH-19 ON/OFF command needs to be replaced by a new command,
  46. ; SET TERMINAL-EMULATION ON/OFF/HEATH-19/VT52/VT100/VT102/ADM3A/TVI910/etc.
  47. ; In REVLVL=3, this command changes only the ID sequence for ESC-Z.
  48. ;
  49. ; ANSI.SYS is a part of the TI-BIOS, but it does not fully emulate a VT100.
  50. ;   FIX: Add more features to MSTEKTRM.ASM, rename it to MSVT241.ASM.
  51. ;   [I am working on this for version 4.  /Joe]
  52. ;
  53. ; Looses the 4th character after LF at 2400 baud when scrolling because DOS
  54. ; is so slow at outputing characters to the screen.  Looses even more at 9600
  55. ; baud.  (Although you can type "KERMIT SERVER" at transfer files at 9600.)
  56. ;   FIX: Use interrupt handling instead of polling USART, with XON/XOFF.
  57. ;        (Received a listing from Charlie Lindahl, not yet implemented)
  58. ;   [Feel free to add this, I will be working on MSVT241.  /Joe]
  59. ;
  60. ;*************************************************************************
  61.  
  62. ;Credits:
  63. ; Joe Smith, Systems Programmer for DECsystem-10, CSM Computing Center
  64. ; Dan Smith, Microcomputer Programmer, CSM Computing Center
  65. ;   Colorado School of Mines, Golden CO 80401 (303)273-3448,273-3396
  66. ; Charlie Lindahl, Rusty Haddock, Steve Krueger, Larry Kroeker of TI
  67. ;   Texas Instruments Computer Science Laboratory
  68. ;   P.O. Box 226015 - MS 238, Dallas, TX 75266 (214)995-0376
  69.  
  70.         public  serini, serrst, clrbuf, outchr, coms, vts, dodel,
  71.         public  ctlu, cmblnk, locate, lclini, prtchr, dobaud, clearl,
  72.         public  dodisk, getbaud, beep
  73.         public  count, xofsnt, puthlp, putmod, clrmod, poscur
  74.         public  sendbr, term, machnam, setktab, setkhlp, showkey
  75.  
  76.         include msdefs.h
  77. SUBTTL Constants used by Zilog Z-8530 Serial Communications Controller
  78.  
  79. ;Taken from page 3-12 of the TI-PRO Technical Reference Manual 2223216-0001
  80.  
  81. SCC1_INTA EQU   0E0h    ;Port 1 interrupt acknowledge
  82. SCC1_BCMD EQU   0E4h    ;Port 1 channel B command
  83. SCC1_BDAT EQU   0E5h    ;Port 1 channel B data (not used)
  84. SCC1_ACMD EQU   0E6h    ;Port 1 channel A command
  85. SCC1_ADAT EQU   0E7h    ;Port 1 channel A data
  86.  
  87. SCC2_INTA EQU   0E8h    ;Port 2 interrupt acknowledge
  88. SCC2_BCMD EQU   0ECh    ;Port 2 channel B command
  89. SCC2_BDAT EQU   0EDh    ;Port 2 channel B data (not used)
  90. SCC2_ACMD EQU   0EEh    ;Port 2 channel A command
  91. SCC2_ADAT EQU   0EFh    ;Port 2 channel A data
  92.  
  93. SCC3_INTA EQU   0F0h    ;Port 3 interrupt acknowledge
  94. SCC3_BCMD EQU   0F4h    ;Port 3 channel B command
  95. SCC3_BDAT EQU   0F5h    ;Port 3 channel B data (not used)
  96. SCC3_ACMD EQU   0F6h    ;Port 3 channel A command
  97. SCC3_ADAT EQU   0F7h    ;Port 3 channel A data
  98.  
  99. SCC4_INTA EQU   0F8h    ;Port 4 interrupt acknowledge
  100. SCC4_BCMD EQU   0FCh    ;Port 4 channel B command
  101. SCC4_BDAT EQU   0FDh    ;Port 4 channel B data (not used)
  102. SCC4_ACMD EQU   0FEh    ;Port 4 channel A command
  103. SCC4_ADAT EQU   0FFh    ;Port 4 channel A data
  104.  
  105. ;To send the INTACK signal to the Z8530, write anything to SCCx_INTA and then
  106. ;immdiately read from SCCx_INTA.  The 8-bit interrupt vector is returned.
  107.  
  108. ;-------------------------------------------------------------------------------
  109.  
  110. ;From ZILOG's Z8030/Z8050 SCC Serial Communications Controller Technical Manual
  111.  
  112.   ;Bits for WR0 - set by writing to SC1ACMD or SC1BCMD
  113. SW0_SREG  EQU   00001111b       ;Set register pointer (if hi 4 bits all zero)
  114. ;;;_CMD1        --XXX---b       ;Command bits 1
  115.   SW0_RESET EQU   010b*8          ;Reset EXT/STATUS (must be done twice)
  116.   SW0_ABORT EQU   011b*8          ;Send ABORT (SDLC mode only)
  117.   SW0_INTEN EQU   100b*8          ;Enable INT on next Rx character
  118.   SW0_TXINT EQU   101b*8          ;Reset TxINT pending
  119.   SW0_ERROR EQU   110b*8          ;Error reset (unlock FIFO)
  120.   SW0_RHIUS EQU   111b*8          ;Reset highest IUS (interrupt under service)
  121. ;;;_CMD2        XX------b       ;Command bits 2
  122.   SW0_RRCRC EQU 01b*64            ;Reset Rx CRC checker (SYNC)
  123.   SW0_RTCRC EQU 10b*64            ;Reset Tx CRC generator (SYNC)
  124.   SW0_RTEOM EQU 11b*64            ;Reset Tx underrun/EOM latch (SYNC)
  125.  
  126.   ;Bits for WR1 - Rx/Tx Interrupt and Data Transfer Mode
  127. SW1_NOINT EQU   00000000b       ;Disable interrupts
  128. SW1_EXINT EQU   00000001b       ;External/Status interrupt enable
  129. SW1_TXINT EQU   00000010b       ;Transmit interrupt enable
  130. SW1_PAREN EQU   00000100b       ;Parity error activates special condition
  131. ;;;_CMD         ---XX---b       ;Receive Interrupt Modes
  132.   SW1_NORI  EQU    00b*16         ;Receive Interrupts Disabled
  133.   SW1_I1ST  EQU    01b*16         ;Interrupt on 1st character or special condition
  134.   SW1_IALL  EQU    10b*16         ;Interrupt on all character or special condition
  135.   SW1_ISPC  EQU    11b*16         ;Interrupt on special condition only
  136. SW1_REC   EQU   00100000b       ;Activate receive request (1 for transmit)
  137. SW1_WAIT  EQU   01000000b       ;Activate the DMA request (0 for WAIT request)
  138. SW1_DMAEN EQU   10000000b       ;Enable WAIT/DMA as selected by bits 5 & 6
  139.  
  140.   ;Bits for WR2 - Interrupt vector
  141. SW2_VECT  EQU   11111111b       ;8-bits of interrupt vector
  142.  
  143.   ;Bits for WR3 - Receive Parameters and Control
  144. SW3_RXEN  EQU   00000001b       ;Rx Enable (set only after all other parameters)
  145. SW3_NSYNC EQU   00000010b       ;Sync character load inhibit (SYNC only)
  146. SW3_ADDR  EQU   00000100b       ;Address search mode (SDLC only)
  147. SW3_RXCRC EQU   00001000b       ;Enable Rx CRC (SDLC only)
  148. SW3_HUNT  EQU   00010000b       ;Enter hunt mode (SYNC)
  149. SW3_AUTOE EQU   00100000b       ;Autoenable, CTS for Tx, DCD for Rx enable
  150. ;;;_BITS        XX------b       ;Receive bits per character
  151.   SW3_5BITS EQU 00b*64            ;5 bits per character
  152.   SW3_6BITS EQU 01b*64            ;6 bits per character
  153.   SW3_7BITS EQU 10b*64            ;7 bits per character
  154.   SW3_8BITS EQU 11b*64            ;8 bits per character
  155.  
  156.   ;Bits for WR4 - Tx/Rx misc parameters and modes
  157. SW4_PAREN EQU   00000001b       ;Parity enable (transmit and receive both)
  158. SW4_EVENP EQU   00000010b       ;Even Parity (0 for Odd)
  159. ;;;_STOPB       ----XX--b         ;Number of stop bits
  160.   SW4_SYNC  EQU     00b*4         ;Synchronous mode enable
  161.   SW4_1STOP EQU     01b*4         ;1 stop bit
  162.   SW4_1HALF EQU     10b*4         ;1.5 stop bits
  163.   SW4_2STOP EQU     11b*4         ;2 stop bits
  164. ;;;_SYNCM       --XX----b       ;Sync modes
  165.   SW4_8BIT  EQU   00b*16          ;8-bit sync character
  166.   SW4_16BIT EQU   01b*16          ;16-bit sync character
  167.   SW4_SDLC  EQU   10b*16          ;SDLC mode (pattern 01111110)
  168.   SW4_EXTS  EQU   11b*16          ;External sync mode
  169. ;;;_CLOCK       XX------b       ;Clock rate
  170.   SW4_X1    EQU 00b*64            ;Clock rate = data rate
  171.   SW4_X16   EQU 01b*64            ;Clock rate = 16 times the data rate
  172.   SW4_X32   EQU 10b*64            ;Clock rate = 32 times the data rate
  173.   SW4_X64   EQU 11b*64            ;Clock rate = 64 times the data rate
  174.  
  175.   ;Bits for WR5 - Transmit parameters and control
  176. SW5_TCRC  EQU   00000001b       ;Calculate and transmit CRC (SYNC only)
  177. SW5_RTS   EQU   00000010b       ;Raise RTS (set RCNTL for B)
  178. SW5_CRC16 EQU   00000100b       ;CRC-16 polynomial (0 for SDLC) (SYNC only)
  179. SW5_TXEN  EQU   00001000b       ;Tx Enable (set only after all other parameters)
  180. SW5_BREAK EQU   00010000b       ;Send a BREAK condition
  181. ;;;_BITS        -XX-----b       ;Transmit bits per character
  182.   SW5_5BITS EQU  00b*32           ;5 or fewer bits per character
  183.   SW5_6BITS EQU  01b*32           ;6 bits per character
  184.   SW5_7BITS EQU  10b*32           ;7 bits per character
  185.   SW5_8BITS EQU  11b*32           ;8 bits per character
  186. SW5_DTR   EQU   10000000b       ;Raise DTR (set speed indicator for B)
  187.  
  188.   ;Bits for WR6 - SYNC character 0
  189. SW6_SYNC  EQU   11111111b       ;Sync character
  190.  
  191.   ;Bits for WR7 - SYNC character 1
  192. SW7_SYNC  EQU   11111111b       ;Sync character
  193.  
  194.   ;Bits for WR8 - Transmit data
  195. SW8_DATA  EQU   11111111b       ;Same as writing to SCCx_xDAT
  196.  
  197.   ;Bits for WR9 - Master interrupt control
  198. SW9_VSTAT EQU   00000001b       ;Int vector modified depending on status
  199. SW9_NOVEC EQU   00000010b       ;No vector during interrupt acknowledge
  200. SW9_IEOL  EQU   00000100b       ;Force Interrupt Enable Out low
  201. SW9_MIEN  EQU   00001000b       ;Master Interrupt Enable
  202. SW9_VEC16 EQU   00010000b       ;Int vector multiple of 16 (0 for mult of 2)
  203. ;;;_BIT5  EQU   00100000b       ;Unused, must be 0
  204. ;;;_RESET       XX------b       ;Reset channel commands
  205.   SW9_CBR   EQU 01b*64            ;Channel A reset
  206.   SW9_CAR   EQU 10b*64            ;Channel B reset
  207.   SW9_RESET EQU 11b*64            ;Force hardware reset
  208.  
  209.   ;Bits for WR10 - Miscellaneous Transmit/Receive control bits
  210. SWA_6BIT  EQU   00000001b       ;Use only 6 of 8 bits to detect sync character
  211. SWA_LOOP  EQU   00000010b       ;Synchronous loop-back mode
  212. SWA_ABORT EQU   00000100b       ;Sent abort on transmit underrun
  213. SWA_MARK  EQU   00001000b       ;Send mark when idle (0 to send flag)
  214. SWA_GAOP  EQU   00010000b       ;Go active on poll (SYNC only)
  215. ;;;_CODE        -XX-----b       ;Data encoding
  216.   SWA_NRZ   EQU  00b*32           ;NRZ (1=1, 0=0) (ASYNC)
  217.   SWA_NRZI  EQU  01b*32           ;NRZI (1=no change, 0=invert)
  218.   SWA_FM1   EQU  10b*32           ;FM1 (1=high frequency, 0=low frequency)
  219.   SWA_FM0   EQU  11b*32           ;FM0 (1=low frequency, 1=high frequency)
  220. SWA_PCRC  EQU   10000000b       ;Preset CRC to all ones (0 for all zeros)
  221.  
  222.   ;Bits for WR11 - Clock mode control
  223. ;;;_TRXC        ------XXb       ;TRxC output control
  224.   SWB_XTALO EQU       00b         ;TRxC output same as XTAL oscillator
  225.   SWB_TRANS EQU       01b         ;TRxC output same as transmitter clock
  226.   SWB_BRGO  EQU       10b         ;TRxC output same as baud rate generator
  227.   SWB_DPLLO EQU       11b         ;TRxC output same as digital phase-locked-loop
  228. SWB_TRXCO EQU   00000100b       ;TRxC pin is an output (0=TRxC is an input)
  229. ;;;_TXC         ---XX---b       ;Transmit clock
  230.   SWB_TRTXC EQU    00b*8          ;Transmit clock = RTxC pin
  231.   SWB_TTRXC EQU    01b*8          ;Transmit clock = TRxC pin
  232.   SWB_TBRG  EQU    10b*8          ;Transmit clock = baud rate generator output
  233.   SWB_TDPLL EQU    11b*8          ;Transmit clock = digital phase-locked-loop
  234. ;;;_RXC         -XX-----b       ;Receive clock
  235.   SWB_RRTXC EQU  00b*32           ;Receive clock = RTxC pin
  236.   SWB_RTRXC EQU  01b*32           ;Receive clock = TRxC pin
  237.   SWB_RBRG  EQU  10b*32           ;Receive clock = baud rate generator output
  238.   SWB_RDPLL EQU  11b*32           ;Receive clock = digital phase-locked-loop
  239. SWB_XTAL  EQU   10000000b       ;Crystal is connected between RTxC and SYNC pins
  240.  
  241.   ;Bits for WR12 (low byte of divisor) and WR13 (high byte) in decimal.
  242. SWC_BAUD  EQU   11111111b       ;Low byte
  243. SWD_BAUD  EQU   11111111b       ;High byte
  244.  
  245. ;Taken from page 3-10 of the TI-PRO Technical Reference Manual 2223216-0001
  246. SCC_0045  EQU   1686    ;  45.5 baud
  247. SCC_0050  EQU   1534    ;  50 baud
  248. SCC_0075  EQU   1022    ;  75 baud
  249. SCC_0100  EQU   0696    ; 110 baud (+0.03%)
  250. SCC_0134  EQU   0569    ; 134.5 baud (Selectric)
  251. SCC_0150  EQU   0510    ; 150 baud
  252. SCC_0200  EQU   0382    ; 200 baud
  253. SCC_0300  EQU   0254    ; 300 baud
  254. SCC_0600  EQU   0126    ; 600 baud
  255. SCC_1200  EQU   0062    ;1200 baud
  256. SCC_1800  EQU   0041    ;1800 baud (-0.78%)
  257. SCC_2000  EQU   0036    ;2000 baud (+1.05%)
  258. SCC_2400  EQU   0030    ;2400 baud
  259. SCC_3600  EQU   0019    ;3600 baud (+1.59%)
  260. SCC_4800  EQU   0014    ;4800 baud
  261. SCC_7200  EQU   0009    ;7200 baud (-3.03%)
  262. SCC_9600  EQU   0006    ;9600 baud
  263. SCC_19K2  EQU   0002    ;19.2 kbaud
  264.   ;Divisor = (256*300/BAUD)-2 for 16x async clock with 4.9152 MHz crystal
  265.  
  266.   ;Bits for WR14 - Miscellaneous control bits
  267. SWE_BRENA EQU   00000001b       ;Baud Rate Generator enable
  268. SWE_PCLK  EQU   00000010b       ;BRG source is PCLK pin (1 for RTxC/XTAL)
  269. SWE_DTREQ EQU   00000100b       ;DTR/REQ pin triggers DMA output cycle
  270. SWE_AECHO EQU   00001000b       ;Auto Echo, TxD connected to RxD
  271. SWE_LLOOP EQU   00010000b       ;Local Loopback on the digital side
  272. ;;;_DPLL        XXX-----b       ;Command field
  273.   SWE_NUL  EQU  000b*32           ;Null command
  274.   SWE_SEA  EQU  001b*32           ;DPLL enters search mode
  275.   SWE_RMC  EQU  010b*32           ;Reset Missing Clock in FM mode
  276.   SWE_DPL  EQU  011b*32           ;Disable DPLL
  277.   SWE_SBR  EQU  100b*32           ;Set DPLL source = BRG clock
  278.   SWE_STC  EQU  101b*32           ;Set DPLL source = RTxC clock
  279.   SWE_SFM  EQU  110b*32           ;Set DPLL to FM mode
  280.   SWE_SNR  EQU  111b*32           ;Set DPLL to NRZI mode
  281.  
  282.   ;Bits for WR15 - External/Status Interrupt Control
  283. SWF_NOINT EQU   00000000b       ;Disable interrupts
  284. ;;;_BIT0  EQU   00000001b       ;Not used, must be 0
  285. SWF_ZEROC EQU   00000010b       ;Interrupt when BRG count goes to zero
  286. ;;;_BIT2  EQU   00000100b       ;Not used, must be 0
  287. SWF_DCD   EQU   00001000b       ;Interrupt when DCD changes state
  288. SWF_SYNC  EQU   00010000b       ;Interrupt when SYNC changes state
  289. SWF_CTS   EQU   00100000b       ;Interrupt when CTS changes state
  290. SWF_EOM   EQU   01000000b       ;Interrupt when transmit underrun or EOM
  291. SWF_BREAK EQU   10000000b       ;Interrupt when BREAK or ABORT condition
  292.  
  293. ;-------------------------------------------------------------------------------
  294.  
  295.   ;Bits for RR0 - available by reading SC1ACMD or SC1BCMD
  296. SR0_RBUFA EQU   00000001b       ;Receive buffer has character(s) available
  297. SR0_ZEROC EQU   00000010b       ;Baud Rate Generator count is zero
  298. SR0_TBUFE EQU   00000100b       ;Transmitter buffer empty (double-buffered)
  299. SR0_DCD   EQU   00001000b       ;DCD is on (channel-B DCD connected to DSR)
  300. SR0_SYNC  EQU   00010000b       ;SYNC in on (ACNTL or modem detected hi speed)
  301. SR0_CTS   EQU   00100000b       ;CTS in on (channel-B CTS connected to RING)
  302. SR0_EOM   EQU   01000000b       ;Transmitter underrun or EOM (SYNC only)
  303. SR0_BREAK EQU   10000000b       ;BREAK (async) or ABORT (sync) condition
  304.  
  305.   ;Bits for RR1 - Special receive conditions
  306. SR1_SENT  EQU   00000001b       ;Last transmit bit has left TxD pin
  307. SR1_RES   EQU   00001110b       ;Residue from I-field (SDLC only)
  308. SR1_PAR   EQU   00010000b       ;Parity error
  309. SR1_OVER  EQU   00100000b       ;Receive overrun (FIFO overflowed)
  310. SR1_FRAME EQU   01000000b       ;CRC or framing error
  311. SR1_EOF   EQU   10000000b       ;End of Frame (SDLC only)
  312.  
  313.   ;Bits for RR3 - Interrupt Pending
  314. SR3_BEXT  EQU   00000001b       ;Channel B external/status
  315. SR3_BTX   EQU   00000010b       ;Channel B transmitter empty
  316. SR3_BRX   EQU   00000100b       ;Channel B receiver full
  317. SR3_AEXT  EQU   00001000b       ;Channel A external/status
  318. SR3_ATX   EQU   00010000b       ;Channel A transmitter empty
  319. SR3_ARX   EQU   00100000b       ;Channel A receiver full
  320. ;;;_BIT6  EQU   01000000b       ;Not used, always zero
  321. ;;;_BIT7  EQU   10000000b       ;Not used, always zero
  322.  
  323.   ;Bits for RR8 - Receive data
  324. SR8_DATA  EQU   SW8_DATA        ;Same as writing to SCCx_xDAT
  325.  
  326.   ;Bits for RR10 - Miscellaneous status bits
  327. ;;;_BIT0  EQU   00000001b       ;Not used, always zero
  328. SRA_LOOP  EQU   00000010b       ;On-loop condition (SDLC only)
  329. ;;;_BIT2  EQU   00000100b       ;Not used, always zero
  330. ;;;_BIT3  EQU   00001000b       ;Not used, always zero
  331. SRA_SEND  EQU   00010000b       ;SCC is actively on-loop and sending now
  332. ;;;_BIT5  EQU   00100000b       ;Not used, always zero
  333. SRA_2MISS EQU   01000000b       ;FM mode, 2 clocks missing
  334. SRA_1MISS EQU   10000000b       ;FM mode, 1 clock missing
  335.  
  336.   ;Bits for RR12 - Low divisor
  337. SRC_BAUD  EQU   SWC_BAUD        ;Returns current baud rate divisor
  338.  
  339.   ;Bits for RR13 - High divisor
  340. SRD_BAUD  EQU   SWD_BAUD        ;Returns current baud rate divisor
  341.  
  342.   ;Bits for RR15 - Interrupt enable bits
  343. ;RR15 returns the bits written to WR15
  344. SRF_NOINT EQU   SWF_NOINT       ;Interrupts are disabled
  345. SRF_ZEROC EQU   SWF_ZEROC       ;Interrupt when BRG count is zero
  346. SRF_DCD   EQU   SWF_DCD         ;Interrupt when DCD changes state
  347. SRF_SYNC  EQU   SWF_SYNC        ;Interrupt when SYNC changes state
  348. SRF_CTS   EQU   SWF_CTS         ;Interrupt when CTS changes state
  349. SRF_EOM   EQU   SWF_EOM         ;Interrupt when transmit underrun or EOM
  350.  
  351. ;-------------------------------------------------------------------------------
  352.  
  353.   ;Output to RS-232 connector  (pin 2 has channel A transmit data)
  354. SCC_RTS   EQU   SW5_RTS  ;Pin 4,  A-WR5 bit 1, Request To Send
  355. SCC_RCNTL EQU   SW5_RTS  ;(RTSB)  B-WR5 bit 1  (internal modem, request control)
  356. SCC_DTR   EQU   SW5_DTR  ;Pin 20, A-WR5 bit 7, Data Terminal Ready
  357. SCC_SPDO  EQU   SW5_DTR  ;Pin 11, B-WR5 bit 7, Speed select out (also Pin 23)
  358.   ;Input from RS-232 connector (pin 3 has channel A receive data)
  359. SCC_DCD   EQU   SR0_DCD  ;Pin 8,  A-RR0 bit 3, Data Carrier Detect
  360. SCC_DSR   EQU   SR0_DCD  ;Pin 6,  B-RR0 bit 3, Data Set Ready, pin 6
  361. SCC_ACNTL EQU   SR0_SYNC ;(SYNCA) A-RR0 bit 4  (internal modem, ack control)
  362. SCC_SPDI  EQU   SR0_SYNC ;Pin 12, B-RR0 bit 4, Speed select in, pin 12
  363. SCC_CTS   EQU   SR0_CTS  ;Pin 5,  A-RR0 bit 5, Clear To Send, pin 5
  364. SCC_RI    EQU   SR0_CTS  ;Pin 22, B-RR0 bit 5, Ring Indicator, pin 22
  365.   ;Taken from page E-1 of the TI-PRO Technical Reference Manual 2223216-0001
  366.  
  367. ;End if TI-Professional Sync/Async Comm Card definitions
  368. SUBTTL Configuration info
  369.  
  370. ;To get the system configuration, execute an INT 4Fh.  The number returned
  371. ;in BX is the size of contiguous RAM (in paragraphs).  The bits returned
  372. ;in AX are:
  373. SYS_INT   EQU   4Fh     ;INT number
  374. SYS_DSKA  EQU   0001h   ;Diskette A (internal) installed
  375. SYS_DSKB  EQU   0002h   ;Diskette B (internal) installed
  376. SYS_DSKC  EQU   0004h   ;Diskette C (external) installed
  377. SYS_DSKD  EQU   0008h   ;Diskette D (external) installed
  378. SYS_1SID  EQU   0010h   ;E1-E2 jumper (0 indicates drive A is double sided)
  379. SYS_40TK  EQU   0020h   ;E3-E4 jumper (0 indicates drive A has 80 tracks)
  380. SYS_60HZ  EQU   0040h   ;E5-E6 jumper (0 indicates 50 Hz system)
  381. SYS_HARD  EQU   0080h   ;Winchester disk controller installed
  382. SYS_PRT1  EQU   0100h   ;Serial port 1 installed
  383. SYS_PRT2  EQU   0200h   ;Serial port 2 installed
  384. SYS_PRT3  EQU   0400h   ;Serial port 3 installed
  385. SYS_PRT4  EQU   0800h   ;Serial port 4 installed
  386. SYS_GRFA  EQU   1000h   ;Graphics RAM bank A installed
  387. SYS_GRFB  EQU   2000h   ;Graphics RAM bank B installed
  388. SYS_GRFC  EQU   4000h   ;Graphics RAM bank C installed
  389. SYS_RSVD  EQU   8000h   ;Reserved
  390.  
  391. ;Speaker control - Put code in AH and execute INT 48h
  392.  
  393. SPK_INT   EQU   48h     ;INT number
  394. SPK_BEEP  EQU   0h      ;Sound speaker, AL has number of 25ms ticks (40=1 sec)
  395. SPK_STAT  EQU   1h      ;Get speaker status, Z-flag is set if enabled
  396. SPK_FREQ  EQU   2h      ;Set speaker frequency from CX (1563 = 800 Hz)
  397. SPK_ON    EQU   3h      ;Turn on speaker until SPK_OFF or SKP_BEEP
  398. SPK_OFF   EQU   4h      ;Turn off speaker
  399. SUBTTL  Data segment
  400.  
  401. ; external variables used:
  402. ; drives - # of disk drives on system
  403. ; flags - global flags as per flginfo structure defined in pcdefs
  404. ; trans - global transmission parameters, trinfo struct defined in pcdefs
  405. ; portval - pointer to current portinfo structure (currently either port1
  406. ;    or port2)
  407. ; port1, port2 - portinfo structures for the corresponding ports
  408.  
  409. ; global variables defined in this module:
  410. ; xofsnt, xofrcv - tell whether we saw or sent an xoff.
  411.  
  412. datas   segment public 'datas'
  413.         extrn   drives:byte,flags:byte, trans:byte
  414.         extrn   portval:word, port1:byte, port2:byte
  415.  
  416. false   equ     0
  417. true    equ     1
  418.  
  419. machnam db      'TI-PRO (rev ',REVLVL+'0',')$'
  420. badbd   db      cr,lf,'Unimplemented baud rate$'
  421. noimp   db      cr,lf,'Command not implemented.$'
  422. shkmsg  db      'Not implemented.'
  423. shklen  equ     $-shkmsg
  424. setktab db      0
  425. setkhlp db      0
  426. crlf    db      cr,lf,'$'
  427. delstr  db      BS,' ',BS,'$'   ; Delete string.
  428. clrlin  db      cr              ; Must be at clreol-1
  429. clreol  db      esc,'[K$'       ; Clear line.
  430. homeras db      esc,'[H',esc,'[J$' ;Home and erase
  431. posseq  db      esc,'[00;00H$'  ; Escape sequence to position cursor
  432.   rowhi equ posseq+2
  433.   rowlo equ posseq+3
  434.   colhi equ posseq+5            ; Modified by POSCUR routine
  435.   collo equ posseq+6
  436. invvid  db      esc,'[0;7m($'   ; Inverse video
  437. norvid  db      ')',esc,'[0;1m$'; Normal video (WHITE=BOLD, as opposed to GREEN)
  438.  
  439.   ;For IBM-PC, numbers are 12,20,5,20,199 for coordinates to 613,194
  440. xmult   dw      9               ; Scale TEK to TI by 9/13
  441. xdiv    dw      13              ;  so that 0-1023 converts to 0-708
  442. ymult   dw      5               ; Scale TEK to TI by 5/13
  443. ydiv    dw      13              ;  so that 0-779 converts to 299-0
  444. ybot    dw      299             ; Bottom of screen is Y=299
  445. oldx    dw      0               ; Previous scaled coordinates
  446. oldy    dw      0
  447.  
  448. palnorm db      0,1,2,3,4,5,6,7 ;Normal colors
  449. pal1pln db      0,7,2,3,4,5,6,1 ;For single-plane machines, 0=Black,1=White
  450. pal3pln db      0,4,2,3,1,5,6,7 ;For three-plane machines,  0=Black,1=Green
  451.  
  452. sysdata dw      0               ;AX from SYS_INT
  453. syssize dw      0               ;BX from SYS_INT
  454.  
  455. xofsnt  db      0               ; Say if we sent an XOFF.
  456. xofrcv  db      0               ; Say if we received an XOFF.
  457. count   dw      0               ; Number of chars in int buffer.
  458. portin  db      0               ; Non-zero if port is initialized
  459.  
  460. porttab db      04h             ; 4 entries
  461.         db      01h,'1$'
  462.         dw      01h
  463.         db      01h,'2$'
  464.         dw      02h             ;*** NOTE: This is 2, not 0 ****
  465.         db      01h,'3$'
  466.         dw      03h
  467.         db      01h,'4$'
  468.         dw      04h
  469.  
  470. termtab db      11              ;Number of entries
  471.         db      05h,'ADM3A$'
  472.         dw      tty_adm3a
  473.         db      04h,'GIGI$'
  474.         dw      tty_gigi
  475.         db      08h,'HEATH-19$'
  476.         dw      tty_heath
  477.         db      03h,'OFF$'
  478.         dw      tty_dos
  479.         db      02h,'ON$'
  480.         dw      tty_heath       ;Same as HEATH-19
  481.         db      06h,'TI-PRO$'
  482.         dw      tty_tipro
  483.         db      06h,'TVI910$'
  484.         dw      tty_tvi910
  485.         db      05h,'VT100$'
  486.         dw      tty_vt100
  487.         db      05h,'VT102$'
  488.         dw      tty_vt102
  489.         db      05h,'VT125$'
  490.         dw      tty_vt125
  491.         db      04h,'VT52$'
  492.         dw      tty_vt52
  493.  
  494. tty_heath  dw   ctl_vt52        ;Control table
  495.         db      01h,'HEATH19'   ;Type, name
  496.         db      esc,'/K',0      ;VT52 superset
  497.  
  498. tty_vt52   dw   ctl_vt52
  499.         db      02h,'VT52   '
  500.         db      esc,'/Z',0      ;ANSI terminal in VT52 mode
  501.  
  502. tty_tipro  label word
  503. tty_dos    dw   ctl_none        ;Use ANSI.SYS that is build into the BIOS
  504.         db      03h,'TIPRO  '
  505.         db      esc,'[?1;4c',0  ;Like a VT100 with graphics but no STP
  506.  
  507. tty_gigi   dw   ctl_ansi
  508.         db      04h,'GIGI   '
  509.         db      esc,'[?5c',0
  510.  
  511. tty_vt100  dw   ctl_ansi
  512.         db      05h,'VT100  '
  513.         db      esc,'[?1;0c',0
  514.  
  515. tty_vt102  dw   ctl_ansi
  516.         db      06h,'VT102  '
  517.         db      esc,'[?6c',0
  518.  
  519. tty_vt125  dw   ctl_ansi
  520.         db      07h,'VT125  '
  521.         db      esc,'[?12;7;0;102c',0
  522.  
  523. tty_adm3a  dw   ctl_adm
  524.         db      08h,'ADM3A  '
  525.         db      esc,']3',0      ; Something I made up
  526.  
  527. tty_tvi910 dw   ctl_adm
  528.         db      09h,'TVI910 '
  529.         db      esc,']0',0      ; Something I made up
  530.  
  531. IDSEQ   dw      tty_dos+10      ; Public pointer to string
  532. CTLTAB  dw      ctl_none        ; Public pointer to control table
  533.  
  534. ctl_vt52 dw     0
  535. ctl_ansi dw     0
  536. ctl_none dw     0
  537. ctl_adm  dw     0
  538.  
  539. modem   mdminfo <SCC1_ADAT,SCC1_ACMD,SCC1_BCMD>
  540.  
  541. tmp     db      ?,'$'
  542. temp    dw      0
  543. temp1   dw      ?               ; Temporary storage.
  544. temp2   dw      ?               ; Temporary storage.
  545. rdbuf   db      20 dup(?)       ; Buffer for input.
  546.  
  547. ourarg  termarg <>
  548. SUBTTL  Data to init Serial Controller
  549.  
  550. PARMTA  DB 09h                  ;Select WR9
  551.         DB SW9_RESET            ;Reset 8530
  552.         DB 0Bh                  ;Select WR11
  553.         DB SWB_RBRG+SWB_TBRG+0  ;No XTAL, RxC=BRG=TxC, TRxC pin is an input
  554.         DB 0Eh                  ;Select WR14
  555.         DB SWE_PCLK+SWE_BRENA   ;BRG source is PCLK pin, enable BRG
  556.         DB 0Fh                  ;Select WR15
  557.         DB SWF_NOINT            ;Disable external status interrupts
  558.         DB 01h                  ;Select WR1
  559.         DB SW1_NOINT            ;Disable all other interupts
  560.         DB 03h                  ;Select WR3
  561.         DB SW3_8BITS+SW3_RXEN   ;8 bits, enable receiver
  562.         DB 04h                  ;Select WR4
  563.         DB SW4_X16+SW4_1STOP+0  ;x16 clock, 1 stop bit, no parity
  564.         DB 05h                  ;Select WR5
  565.         DB SW5_DTR+SW5_8BITS+SW5_TXEN+SW5_RTS ;Raise DTR+RTS, 8 bits, Tx enable
  566. PARMAS  EQU $-PARMTA
  567.         ;The baud rate is set via GETBAUD and/or DOBAUD
  568.  
  569.   ;Channel B parameters
  570. PARMTB  DB 0Fh                  ;Select WR15
  571.         DB SWF_NOINT            ;Disable external status interrupts
  572.         DB 01h                  ;Select WR1
  573.         DB SW1_NOINT            ;Disable all other interrupts
  574.         DB 05H                  ;Select WR5
  575.         DB SW5_RTS              ;Raise RTSB (RCNTL) for internal modem
  576. PARMBS  EQU $-PARMTB
  577.  
  578. BAUDAT  LABEL   WORD    ;Divisors for Z-8530 with 4.9152-MHz oscillator
  579.         DW      0696h   ; 0   45.5 baud
  580.         DW      05FEh   ; 1   50 baud
  581.         DW      03FEh   ; 2   75 baud
  582.         DW      02B8h   ; 3  110 baud (+0.03%)
  583.         DW      0239h   ; 4  134.5 baud (Selectric)
  584.         DW      01FEh   ; 5  150 baud
  585.         DW      00FEh   ; 6  300 baud
  586.         DW      007Eh   ; 7  600 baud
  587.         DW      003Eh   ; 8 1200 baud
  588.         DW      0029h   ; 9 1800 baud (-0.78%)
  589.         DW      0024h   ;10 2000 baud (+1.05%)
  590.         DW      001Eh   ;11 2400 baud
  591.         DW      000Eh   ;12 4800 baud
  592.         DW      0006h   ;13 9600 baud
  593.         DW      0002h   ;14 19.2 kbaud
  594.         DW      0000h   ;15 38.4 kbaud - not supported
  595. BAUDLEN EQU     $-BAUDAT        ;Size of table in bytes
  596. ;End of init data
  597.  
  598. datas   ends
  599. SUBTTL  Serial port routines -- Initialize
  600.  
  601. code    segment public
  602.         extrn   comnd:near, dopar:near, prserr:near, atoi:near, prompt:near
  603.         extrn   nout:near
  604.         extrn   TERMEMU:near            ;Terminal emulator for TEK and VT100
  605.         public  CLS,TEKDRAW,CROSHAIR    ;Graphics routines
  606.         public  INMODEM,OUTMODEM        ;I/O to communications port
  607.         public  INKEYB,OUTSCRN          ;I/O to console
  608.         public  IDSEQ,CTLTAB            ;Used by TERMEMU routine
  609.         assume  cs:code,ds:datas
  610.  
  611. ;============================================================================
  612. ;  Serial-port routines - talks to the Async COMM card.
  613. ;============================================================================
  614.  
  615. ; Initialization for using serial port.  Returns normally.
  616. ; This is called for by SEND, RECEIVE, and CONNECT commands.
  617.  
  618. SERINI  PROC    NEAR
  619.         cld                     ; Do increments in string operations
  620.         cmp portin,0            ; Is it initialized already?
  621.         jne serinc              ; Yes, skip all this
  622.  
  623.         mov si,offset PARMTA    ; Addr of port A parameter table
  624.         mov dx,modem.mdstat     ; Port A command/status addr
  625.         in al,dx                ; Make sure it's pointing to WR0
  626.         mov cx,PARMAS           ; Table size
  627. serina: lods PARMTA             ; Get a byte
  628.         out dx,al               ; Send it to 8530
  629.         loop serina             ; Do all of port A
  630.  
  631.         mov si,offset PARMTB    ; Addr of port-B parameter table
  632.         mov dx,modem.mdcom      ; Port B command/status addr
  633.         in al,dx                ; Make sure it's pointing to WR0
  634.         mov cx,PARMBS
  635. serinb: lods PARMTB             ; Get a byte
  636.         out dx,al               ; Send it to 8530
  637.         loop serinb
  638.  
  639. serinc: mov portin,0FFh         ; Flag that port is set up
  640.         ret
  641. SERINI  ENDP
  642.  
  643.  
  644. ; Reset the serial port.  This is the opposite of SERINI.  Calling
  645. ; this twice without intervening calls to SERINI should be harmless.
  646. ; Returns normally.
  647.  
  648. SERRST  PROC    NEAR
  649.         mov portin,00h          ; Port is not set up
  650.         ret                     ; All done.
  651. SERRST  ENDP
  652.  
  653. ; Clear the input buffer. This throws away all the characters in the
  654. ; serial interrupt buffer.  This is particularly important when
  655. ; talking to servers, since NAKs can accumulate in the buffer.
  656. ; Do nothing since we are not interrupt driven.  Returns normally.
  657.  
  658. CLRBUF  PROC    NEAR
  659.         mov cx,8
  660.         mov dx,modem.mddat      ; Address channel-A data register
  661. clrbf1: in al,dx                ; Clear out anything in the receive FIFO
  662.         loop clrbf1
  663.         mov count,cx            ; Set count to zero
  664.         ret
  665. CLRBUF  ENDP
  666. SUBTTL  Serial port routines -- Output to the port
  667.  
  668. ; Put the char in AH to the serial port.  This assumes the
  669. ; port has been initialized.  Should honor xon/xoff.  Skip returns on
  670. ; success, returns normally if the character cannot be written.
  671.  
  672. OUTCHR  PROC    NEAR
  673.         push bx
  674.         push cx
  675.         push dx
  676.         mov bx,portval
  677.         cmp [bx].floflg,0       ; Are we doing flow control.
  678.         je outch2               ; No, just continue.
  679.         xor cx,cx               ; clear counter
  680. outch1: cmp xofrcv,true         ; Are we being held?
  681.         jne outch2              ; No - it's OK to go on.
  682.         loop outch1             ; held, try for a while
  683.         mov xofrcv,false        ; timed out, force it off and fall thru.
  684. outch2: mov al,ah               ; Parity routine works on AL.
  685.         call dopar              ; Set parity appropriately.
  686.  
  687.         mov ah,al               ; Preserve character for a bit
  688.         xor cx,cx               ; Set loop counter to max
  689.         mov dx,modem.mdstat     ; Port 1 channel A command/status address
  690. outch3: in al,dx                ; Get RR0 contents
  691.         and al,SR0_TBUFE        ; Transmit buffer empty?
  692.         jnz outch4              ; Yes, output char
  693.         loop outch3             ; No, try again
  694.          jmp outch5             ; Loop counter expired, give up
  695. outch4: mov dx,modem.mddat      ; Get port 1 channel A data address
  696.         mov al,ah               ; Get the character
  697.         out dx,al               ; Send it
  698.         pop dx
  699.         pop cx
  700.         pop bx
  701.         jmp RSKP                ; Skip return for OK
  702.  
  703. outch5: pop dx
  704.         pop cx
  705.         pop bx
  706.         ret                     ; Non-skip return due to timeout
  707. OUTCHR  ENDP
  708. SUBTTL  Serial port routines -- Input from port
  709.  
  710. ; Port read character.  Check the port status.  If no data, skip
  711. ; return.  Else, read in a char and return.
  712.  
  713. PRTCHR  PROC    NEAR
  714.         push bx
  715.         push dx
  716.         call chkxon
  717.  
  718.         mov dx,modem.mdstat     ; Port 1 channel A command address
  719. prtch1: in al,dx                ; Read RR0 contents
  720.         and al,SR0_RBUFA        ; Any characters in receive FIFO?
  721.         jz prtch4               ; No, exit without waiting
  722.         mov dx,modem.mddat      ; Yes, get port 1 channel A data address
  723.         in al,dx                ; Get the character
  724.  
  725.         mov bx,portval
  726.         cmp [bx].parflg,PARNON  ; no parity?
  727.         je prtch3               ; then don't strip
  728.         and al,7fh              ; else turn off parity
  729. prtch3: pop dx
  730.         pop bx
  731.         ret
  732.  
  733. prtch4: pop dx                  ; Here when no character is available
  734.         pop bx
  735.         jmp RSKP                ; no chars...
  736. PRTCHR  ENDP
  737.  
  738.  
  739. ; Local routine to see if we have to transmit an xon
  740. CHKXON  PROC    NEAR
  741.         push    bx
  742.         mov     bx,portval
  743.         cmp     [bx].floflg,0   ; doing flow control?
  744.         je      chkxo1          ; no, skip all this
  745.         cmp     xofsnt,false    ; have we sent an xoff?
  746.         je      chkxo1          ; no, forget it
  747.         mov     ax,[bx].flowc   ; ah gets xon
  748.         call    outchr          ; send it
  749.         nop
  750.         nop
  751.         nop                     ; in case it skips
  752.         mov     xofsnt,false    ; remember we've sent the xon.
  753. chkxo1: pop     bx              ; restore register
  754.         ret                     ; and return
  755. CHKXON  ENDP
  756. SUBTTL  Serial port routines -- Send a break
  757.  
  758. ; Send a break out the current serial port.  Returns normally.
  759. SENDBR  PROC    NEAR
  760.         push cx
  761.         push dx
  762.         push ax
  763.         xor cx,cx               ; Clear loop counter.
  764.         mov dx,modem.mdstat     ; Address channel-A command port
  765.         mov al,5                ; Point to register 5
  766.         out dx,al
  767.         jmp short $+2
  768.         in  al,dx               ; Get current setting.
  769.         mov ah,al               ; Copy the bits
  770.         mov al,5                ; Point back to register 5
  771.         out dx,al
  772.         mov al,ah               ; Get old bits
  773.         or  al,SW5_BREAK        ; Set send-break bit
  774.         out dx,al               ; Start the break
  775. pause:  loop pause              ; Wait a while.
  776.         mov al,5                ; Point to register 5
  777.         out dx,al
  778.         jmp short $+2
  779.         mov al,ah               ; Clear send-break bit
  780.         out dx,al               ; Stop the break
  781.         pop ax
  782.         pop dx
  783.         pop cx
  784.         ret                     ; And return.
  785.         ret
  786. SENDBR  ENDP
  787. SUBTTL  Serial port routines -- Change baud rate
  788.  
  789. ; Set the baud rate for the current port, based on the value
  790. ; in the portinfo structure.  Returns normally.
  791. ; Called from SET BAUD command with new index in PORT.BAUD, previous in AX
  792.  
  793. DOBAUD  PROC    NEAR
  794.         push bx
  795.         mov bx,portval          ;Get pointer
  796.         mov bx,[bx].baud        ;Get new baud-rate index
  797.         shl bx,1                ;Multiply by 2
  798.         cmp BAUDAT[bx],0        ;Test for zero
  799.         jne dobod1              ;Nonzero is OK
  800.         mov bx,portval          ;Error, get back to data structure
  801.         mov [bx].baud,ax        ;Restore previous baud rate number
  802.         mov ah,prstr
  803.         mov dx,offset badbd     ;Bad baud rate
  804.         int dos
  805.         pop bx
  806.         ret
  807.  
  808. dobod1: mov ax,BAUDAT[bx]       ;Get BRG divisor
  809.         call SETBAUD            ;Send AX to baud-rate-divisor
  810.         pop bx
  811.         ret
  812. DOBAUD  ENDP
  813.  
  814.  
  815. ;Routine to send AX to the Baud Rate Generator.  Preserves all regs
  816.  
  817. SETBAUD PROC NEAR
  818.         push dx
  819.         push ax                 ;Save rate
  820.         mov dx,modem.mdstat     ;Address the channel-A command port
  821.         mov al,13               ;Point to register 13
  822.         out dx,al
  823.         jmp short $+2           ;Slight delay to let hardware respond
  824.         mov al,ah               ;High-order part of divisor
  825.         out dx,al
  826.         jmp short $+2
  827.         mov al,12               ;Point to register 12
  828.         out dx,al
  829.         jmp short $+2
  830.         pop ax
  831.         out dx,al               ;Low-order part of divisor
  832.         pop dx
  833.         ret
  834. SETBAUD ENDP
  835.  
  836.  
  837. ; Get the current baud rate from the serial card and set it
  838. ; in the portinfo structure for the current port.  Returns normally.
  839. ; This is used during initialization.
  840.  
  841. GETBAUD PROC    NEAR
  842.         mov dx,modem.mdstat     ;Address channel-A command port
  843.         mov al,13               ;Point to register 13
  844.         out dx,al
  845.         jmp short $+2           ;Small delay
  846.         in  al,dx               ;Read RR13
  847.         mov ah,al               ;Save high-order part
  848.         mov al,12               ;Point to register 12
  849.         out dx,al
  850.         jmp short $+2
  851.         in  al,dx               ;Read RR12
  852. ;Baud rate = (300*256)/(AX+2)
  853.         mov bx,0                ;Index value
  854. getbd1: cmp ax,BAUDAT[bx]       ;See if known value
  855.         je  getbd2              ;Found it
  856.         add bx,2                ;Point to next word
  857.         cmp bl,BAUDLEN          ;End of table?
  858.         jl  getbd1              ;No, keep looking
  859.         mov bx,B1200*2          ;Yes, force it to 1200 baud
  860.         mov ax,BAUDAT[bx]
  861.         call SETBAUD
  862.  
  863. getbd2: mov ax,bx               ;Get the byte index
  864.         shr ax,1                ;Reduce to number from 0 to 15
  865.         mov bx,portval          ;Point to structure
  866.         mov [bx].baud,ax        ;Store where SHOW processor can see it
  867.         ret
  868. GETBAUD ENDP
  869. SUBTTL  Machine-dependent screen update routines
  870.  
  871. ;============================================================================
  872. ;  Screen handling routines
  873. ;============================================================================
  874.  
  875.  
  876. ; Delete a character from the terminal.  This works by printing
  877. ; backspaces and spaces.  Returns normally.
  878.  
  879. DODEL   PROC    NEAR
  880.         mov ah,prstr
  881.         mov dx,offset delstr    ; Backspace-space-backspace
  882.         int dos
  883.         ret
  884. DODEL   ENDP
  885.  
  886.  
  887. ; Move the cursor to the left margin, then clear to end of line.
  888. ; Returns normally.
  889.  
  890. CTLU    PROC    NEAR
  891.         mov ah,prstr
  892.         mov dx,offset clrlin    ;Output CR, then clear to end of line
  893.         int dos
  894.         ret
  895. CTLU    ENDP
  896.  
  897. ; Clear to the end of the current line.  Returns normally.
  898.  
  899. CLEARL  PROC    NEAR
  900.         mov ah,prstr
  901.         mov dx,offset clreol    ;Erase from cursor position to end of line
  902.         int dos
  903.         ret
  904. CLEARL  ENDP
  905.  
  906.  
  907. ; This routine blanks the screen.  Returns normally.
  908.  
  909. CMBLNK  PROC    NEAR
  910.         mov     ah,13h          ;Function 13h of INT 49h clears the screen
  911.         int     49h
  912.         ret
  913. CMBLNK  ENDP
  914.  
  915.  
  916. ; Produce a short beep.  The PC DOS bell is long enough to cause a loss
  917. ; of data at the port.  Returns normally.
  918.  
  919. BEEP1   PROC    NEAR
  920.         mov ah,SPK_FREQ         ; Set speaker frequency
  921.         mov cx,1000             ; Approx 1.5 kHz
  922.         int SPK_INT
  923.         ret
  924. BEEP1   ENDP
  925.  
  926. BEEP    PROC    NEAR
  927.         call BEEP1              ; Set the frequency
  928.         mov ah,SPK_BEEP         ; Timed beep function
  929.         mov al,5                ; 5/40 = 1/8 second
  930.         int SPK_INT
  931.         ret
  932. BEEP    ENDP
  933.  
  934.  
  935. ; Homes the cursor.  Returns normally.
  936.  
  937. LOCATE  PROC    NEAR
  938.         mov dx,0                ; Go to top left corner of screen.
  939.         jmp poscur
  940. LOCATE  ENDP
  941.  
  942.  
  943. ; Write a line at the bottom of the screen...
  944. ; the line is passed in dx, terminated by a $.  Returns normally.
  945.  
  946. PUTMOD  PROC    NEAR
  947.         push    dx              ; preserve message
  948.         mov     dx,24*100h      ; now address line 24
  949.         call    poscur
  950.         mov     dx,offset invvid
  951.         mov     ah,prstr
  952.         int     dos             ;Set inverse video
  953.         pop     dx              ; get message back
  954.         mov     ah,prstr
  955.         int     dos             ; write it out
  956.         mov     dx,offset norvid
  957.         mov     ah,prstr
  958.         int     dos             ;Normal video
  959.         ret                     ; and return
  960. PUTMOD  ENDP
  961.  
  962.  
  963. ; Clear the mode line written by PUTMOD.  Returns normally.
  964.  
  965. CLRMOD  PROC    NEAR
  966.         mov     dx,1800h
  967.         call    poscur          ; Go to bottom row.
  968.         call    clearl          ; Clear to end of line.
  969.         ret
  970. CLRMOD  ENDP
  971.  
  972.  
  973. ; Put a help message on the screen.
  974. ; Pass the message in ax, terminated by a null.  Returns normally.
  975.  
  976. PUTHLP  PROC    NEAR
  977.         push    ax              ; preserve this
  978.         mov     ah,prstr
  979.         mov     dx,offset crlf
  980.         int     dos
  981.         pop     si              ; point to string again
  982. puthl3: lodsb                   ; get a byte
  983.         cmp     al,0            ; end of string?
  984.         je      puthl4          ; yes, stop
  985.         mov     dl,al
  986.         mov     ah,dconio
  987.         int     dos             ; else write to screen
  988.         jmp     puthl3          ; and keep going
  989. puthl4: mov     ah,prstr
  990.         mov     dx,offset crlf
  991.         int     dos
  992.         ret
  993. PUTHLP  ENDP
  994.  
  995.  
  996. ; Position the cursor according to contents of DX:
  997. ; DH contains row, DL contains column.  Returns normally.
  998.  
  999. POSCUR  PROC    NEAR
  1000.         mov al,dh               ;Get row
  1001.         inc al                  ;Top row is row #1, not zero
  1002.         aam                     ;ah gets tens, al gets units
  1003.         add ax,'00'             ;Convert to ASCII
  1004.         mov rowhi,ah            ;Store in ESCape sequence
  1005.         mov rowlo,al
  1006.         mov al,dl               ;Get column
  1007.         inc al
  1008.         aam
  1009.         add ax,'00'
  1010.         mov colhi,ah
  1011.         mov collo,al
  1012.         mov ah,prstr
  1013.         mov dx,offset posseq    ;Output ESC,'[',row,';',col,'H'
  1014.         int     dos
  1015.         ret
  1016. POSCUR  ENDP
  1017. SUBTTL TEKTRONIX-4010 emulation
  1018.  
  1019.  
  1020. ;**** NOTE: This version of TERM really belongs in MSCOMM.ASM ****
  1021. TERM    PROC    NEAR
  1022.         mov si,ax               ; this is source
  1023.         mov di,offset ourarg    ; place to store arguments
  1024.         mov ax,ds
  1025.         mov es,ax               ; address destination segment
  1026.         mov cx,size termarg
  1027.         rep movsb               ; copy into our arg blk
  1028.         call TERMINI            ; Set 25th line, graphics bright
  1029.  
  1030. ; Get a character from the modem, send it to the screen
  1031.  
  1032. term1:  call INMODEM            ; Input from modem
  1033.           jmp short term2       ; No input available
  1034.           nop                   ; 3rd byte
  1035.         push ax
  1036.         call TERMEMU            ; Call terminal emulation routines
  1037.         pop ax
  1038.         test ourarg.flgs,capt   ; capturing output?
  1039.         jz term2                ; no, forget it
  1040.         call ourarg.captr       ; else call the routine
  1041.  
  1042. ; Get character from the keyboard, send it to the modem port
  1043.  
  1044. term2:  call INKEYB             ; Get char from keyboard (with translation)
  1045.           jmp short term1       ; No input available
  1046.           nop                   ; 3rd byte
  1047.         cmp al,ourarg.escc      ; Match our escape character?
  1048.         je term3                ; yes, exit
  1049.         call OUTMODEM           ; output the character
  1050.         test ourarg.flgs,lclecho ; echoing?
  1051.         jz term1                ; no, continue loop
  1052.         push ax
  1053.         call TERMEMU
  1054.         pop ax
  1055.         and al,7Fh              ; Ignore parity
  1056.         cmp al,CR               ; Was the RETURN key pressed?
  1057.         jne term1
  1058.         mov al,LF               ; Yes, echo a linefeed to the screen
  1059.         call TERMEMU
  1060.         jmp term1
  1061.  
  1062. term3:  call TERMEND            ; Undo line 25 or graphics
  1063.         ret
  1064. TERM    ENDP
  1065. ;**** NOTE: This version of TERM really belongs in MSCOMM.ASM ****
  1066.  
  1067.  
  1068. ;Routine to make graphics more visible.
  1069. ;For a 1-plane monochrome display, draw bright lines on a black background
  1070. ;For a 3-plane color display, draw green lines on a black background
  1071. ;(It is better to use only one color on a color monitor, so as to avoid
  1072. ;any problems if the convergence is not exact.)
  1073. ;Line 25 is not given any special treatment.
  1074.  
  1075. TERMINI PROC NEAR
  1076.         mov si,offset pal3pln   ;New palette if 3 planes
  1077.         test sysdata,SYS_GRFC   ;Graphics plane C installed ?
  1078.         jnz termin1             ;Yes
  1079.         mov si,offset pal1pln   ;No, only single plane graphics
  1080. termin1:call palette            ;Set up so that color 1 is more visible
  1081.         ret
  1082. TERMINI ENDP
  1083.  
  1084.  
  1085. ;Routine to make graphics dimmer.
  1086. ;For a 1-plane monochrome display, graphics will be very dim
  1087. ;For a 3-plane color display, graphics will be blue (text will be white)
  1088. ;Line 25 is not given any special treatment
  1089.  
  1090. TERMEND PROC NEAR
  1091.         mov si,offset palnorm   ;Reset to normal palette
  1092.         call palette
  1093.         ret
  1094. TERMEND ENDP
  1095.  
  1096.  
  1097. ;Routine to input a character from the keyboard with translation.
  1098. ;Skip return if input was available, character in AL.
  1099.  
  1100. INKEYB  PROC NEAR               ;Input from the keyboard
  1101.         mov ah,dconio
  1102.         mov dl,0ffh
  1103.         int dos
  1104.         jc  inkey1              ;Carry set if no character available
  1105.         and al,7Fh              ;No meta characters (yet)
  1106.         je  inkey1              ;*HACK* No char if null
  1107.         jmp RSKP                ;Skip return of char is available
  1108. inkey1: ret                     ;Error return if no input
  1109. INKEYB  ENDP
  1110.  
  1111.  
  1112. ;Routine to output character in AL to the screen.
  1113.  
  1114. OUTSCRN PROC NEAR               ;Output one character to the screen
  1115.         mov dl,al
  1116.         mov ah,conout
  1117.         int dos                 ; go print it
  1118.         ret
  1119. OUTSCRN ENDP
  1120.  
  1121.  
  1122. ;Routine to input a character from the modem port.
  1123. ;Skip return if input was available, character in AL.
  1124.  
  1125. INMODEM PROC NEAR               ;Input from the modem
  1126.         call PRTCHR
  1127.           jmp RSKP              ;Skip return if char is available
  1128.         ret
  1129. INMODEM ENDP
  1130.  
  1131.  
  1132. ;Routine to output character in AL to the modem port.
  1133.  
  1134. OUTMODEM PROC NEAR              ;Output one character to the modem
  1135.         push ax                 ;Preserve character in AL
  1136.         mov ah,al
  1137.         call OUTCHR             ;Output char in AH
  1138.         nop                     ;Ignore non-skip return
  1139.         nop
  1140.         nop
  1141.         pop ax
  1142.         ret
  1143. OUTMODEM ENDP
  1144.  
  1145.  
  1146. ;Routine to draw a line on the screen, using TEKTRONIX coordinates.
  1147. ;X coordinate in AX, 0=left edge of screen, 1023=right edge of screen.
  1148. ;Y coordinate in BX, 0=bottom of screen, 779=top of screen.
  1149. ;Visiblity flag in CL, 0=move invisible, 1=draw a line.
  1150.  
  1151. ;The TI-PRO has (719,299) as the coordinate of the lower-right corner.
  1152. ;Calculate endpoint X=(9/13)*(HIX*32+LOX), Y=299-(5/13)*(HIY*32+LOY)
  1153.  
  1154. ;The IBM-PC has (639,199) as the coordinate of the lower-right corner.
  1155. ;Calculate endpoint X=(12/20)*(HIX*32+LOX), Y=199-(5/20)*(HIY*32+LOY)
  1156.  
  1157. TEKDRAW PROC NEAR
  1158.         imul xmult              ; Multiply by 9
  1159.         idiv xdiv               ; Divide by 13
  1160.         push ax                 ; X is now between 0 and 708
  1161.         mov ax,bx
  1162.         imul ymult              ; Multiply by 5
  1163.         idiv ydiv               ; Divide by 13
  1164.         mov  bx,ybot            ; Y is now between 0 and 299
  1165.         sub  bx,ax              ; Put new Y in right reg
  1166.         pop  ax                 ; Put new X in right reg
  1167.         mov  si,oldx            ; Previous position
  1168.         mov  di,oldy
  1169.         mov  dl,cl              ; Draw a line in 1 plane if DL=1
  1170.         or   dl,80h             ; Use fast line drawing routine
  1171.         call LINE
  1172.         mov  oldx,si            ; Update position
  1173.         mov  oldy,di
  1174.         ret
  1175. TEKDRAW ENDP
  1176.  
  1177.  
  1178. ;Routine to trigger the crosshairs, wait for a key to be struck, and send
  1179. ;5 byte out the modem port.
  1180.  
  1181. CROSHAIR PROC NEAR
  1182.         ret
  1183. CROSHAIR ENDP
  1184. SUBTTL  Screen routines -- Graphics
  1185. ;Note: All arguments to these 3 routines are passed in the registers.
  1186.  
  1187.         public  CLS, PALETTE, LINE
  1188. ;==============================================================================
  1189. ; CLS   Subroutine to clear the screen.  Call with 0 in AL to clear both,
  1190. ;       1 to clear graphics only, 2 to clear text only.
  1191. ;==============================================================================
  1192.  
  1193. CLS     PROC    NEAR            ;0=both, 1=graphics, 2=text
  1194.         push    ax
  1195.         test    al,1            ;CLS 1 does not clear text
  1196.         jnz     cls1
  1197.         mov     ah,13h          ;CLS 0 or CLS 2 clears text screen
  1198.         int     49h
  1199. cls1:   pop     ax
  1200.         test    al,2            ;CLS 2 does not clear graphics
  1201.         jnz     cls2
  1202.         mov     ah,14h          ;CLS 0 or CLS 1 clears graphics screen
  1203.         int     49h
  1204. cls2:   ret
  1205. CLS     ENDP
  1206.  
  1207. ; Colors 0=Black, 1=Blue, 2=Red, 3=Magenta, 4=Green, 5=Cyan, 6=Yellow, 7=White
  1208. planea  equ     0C000h          ;1st graphics plane (blue)
  1209. planeb  equ     0C800h          ;2nd graphics plane (red)
  1210. planec  equ     0D000h          ;3rd graphics plane (green)
  1211.   ; The colors listed above are assuming that the PALETTE is not changed.
  1212. latchs  equ     0DF00h          ;Segment number of color latches
  1213. latchb  equ     00010h          ;Blue output latch
  1214. latchg  equ     00020h          ;Green output latch
  1215. latchr  equ     00030h          ;Red output latch
  1216. palblue equ     10101010b       ;Default blue latch
  1217. palgren equ     11001100b       ;Default green latch
  1218. palred  equ     11110000b       ;Default red latch
  1219.  
  1220. ;==============================================================================
  1221. ; PALETTE Subroutine to change the color palette (ala BASIC)
  1222. ;       Call with DS:SI pointing to 8 bytes defining the new colors
  1223. ;       Preserves all but AX,SI.
  1224. ;==============================================================================
  1225.  
  1226. PALETTE PROC    NEAR
  1227.         push bx
  1228.         push cx
  1229.         mov bx,0                ;Start at 1st byte
  1230.         mov ah,0                ;Code for blue latch
  1231.         mov cx,0                ;Code for red and green latches
  1232.  
  1233. palet1: mov al,CS:PALBITS[bx]   ;Bit to be set
  1234.         test byte ptr [bx+si],01h ;Check blue component of this color
  1235.         jz palet2
  1236.         or  ah,al               ;Set the bit
  1237. palet2: test byte ptr [bx+si],02h ;Check red component
  1238.         jz palet3
  1239.         or  ch,al               ;Set the bit
  1240. palet3: test byte ptr [bx+si],04h ;Check the green component
  1241.         jz palet4
  1242.         or  cl,al
  1243. palet4: shl al,1                ;Do next bit
  1244.         add bx,1                ;Point to next input data byte
  1245.         cmp bl,8                ;Done all 8?
  1246.         jl  palet1
  1247.  
  1248.         push ds
  1249.         mov bx,latchs           ;Address the latch segment
  1250.         mov ds,bx
  1251.         mov DS:[latchb],ah      ;Set the hardware latches
  1252.         mov DS:[latchg],cl
  1253.         mov DS:[latchr],ch
  1254.         pop ds
  1255.         pop cx
  1256.         pop bx
  1257.         ret
  1258. PALBITS db 01h,02h,10h,20h,04h,08h,40h,80h   ;Red & Green bits swapped
  1259. PALETTE ENDP
  1260.  
  1261. ;==============================================================================
  1262. ; LINE  Subroutine to plot a line with endpoints in BX,CX and SI,DI. The method
  1263. ;       used is an adaptation of the octantal dynamic differential analyzer(DDA).
  1264. ;
  1265. ; Registers at CALL             Registers on return
  1266. ; -----------------             -------------------
  1267. ; SI=Start X coord              SI=End X coord (start for next time)
  1268. ; DI=Start Y coord              DI=End Y coord
  1269. ; AX=End X coord                AX=garbage
  1270. ; BX=End Y coord                BX=garbage
  1271. ; CX=anything                   CX=unchanged (for loop counter)
  1272. ; DX=Color code, 0-7 or 80-87   DX=unchanged
  1273. ; BP,SP,CS,DS,ES,SS are all unchanged
  1274. ;
  1275. ; I considered returning meaningful data in AX and BX (such as the last bit
  1276. ; and word address drawn), but that is complicated by the fact that the lines
  1277. ; are always drawn left to right.
  1278. ;==============================================================================
  1279.  
  1280. LINE    proc    near
  1281.         push    ax                      ;End coords in (AX,BX) will be returned
  1282.         push    bx                      ; in (SI,DI)
  1283.         push    cx                      ;Preserve CX,BP,DS
  1284.         push    bp
  1285.         push    ds
  1286. ;       call    clip                    ;Clip line to fit in screen bounds
  1287. ;       jnz     done                    ;Jump if line is on screen
  1288.         cmp     ax,si                   ;Compare X1 to X2
  1289.         jl      plusx                   ;Jump if X1 is to left of X2
  1290.         xchg    ax,si                   ;Swap points so point 1 is to left
  1291.         xchg    bx,di                   ;  This mirrors quadrants 2,3 to 1,4
  1292. plusx:  sub     si,ax                   ;Get delta X into SI
  1293.         sub     di,bx                   ;Get delta Y into DI
  1294.  
  1295. ; Left-hand coordinate in (AX,BX), delta movement in (SI,DI)
  1296. ; Map X1,Y1 in AX,BX to an offset into the video buffer in BX and bit pos in AX
  1297.  
  1298.         shl     bx,1                    ;2*Y
  1299.         shl     bx,1                    ;4*Y
  1300.         mov     bp,bx                   ;Save 4*Y
  1301.         shl     bx,1                    ;8*Y
  1302.         shl     bx,1                    ;16*Y
  1303.         shl     bx,1                    ;32*Y
  1304.         add     bp,bx                   ;DX = 36*Y
  1305.         shl     bx,1                    ;64*Y
  1306.         shl     bx,1                    ;128*Y
  1307.         sub     bx,bp                   ;128Y - 36Y = 92*Y
  1308.         mov     cl,al                   ;Low 4 bits of X position
  1309.         and     cl,0Fh
  1310.         shr     ax,1                    ;Divide by 8 bits per byte
  1311.         shr     ax,1
  1312.         shr     ax,1
  1313.         and     ax,0fffeh               ;Truncate down to word boundary
  1314.         add     bx,ax
  1315.         mov     ax,8000h                ;Start with set bit on left edge
  1316.         shr     ax,cl                   ;Shift it over the correct amount
  1317.  
  1318. ;AX has bit in position, BX has word address, SI has delta-X, DI has delta-Y
  1319.  
  1320.         mov     bp,92                   ;Offset from 1 pixel to one below it
  1321.         or      di,di                   ;See if delta y is below zero
  1322.         jg      quad3                   ;Yes, already on quadrant 3
  1323.         neg     di                      ;Get absolute value of delta y
  1324.         neg     bp                      ;Move toward top of screen
  1325. quad3:  test    dl,1                    ;Want color 1?
  1326.         jz      try2                    ;No
  1327.         mov     cx,planea               ;Yes, do BLUE
  1328.         call    line1
  1329. try2:   test    dl,2                    ;Want color 2?
  1330.         jz      try3                    ;No
  1331.         mov     cx,planeb               ;Yes, do RED
  1332.         call    line1
  1333. try3:   test    dl,4                    ;Want color with this bit on?
  1334.         jz      lindone                 ;No
  1335.         mov     cx,planec               ;Yes, do GREEN
  1336.         call    line1
  1337.  
  1338. lindone:pop     ds
  1339.         pop     bp
  1340.         pop     cx
  1341.         pop     di                      ;Return end points (formerly in AX,BX)
  1342.         pop     si                      ; in (SI,DI)
  1343.         ret
  1344.  
  1345. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1346.  
  1347. line1:  mov     ds,cx                   ;Segment for video buffer
  1348.         push    ax                      ;Starting bit position
  1349.         push    bx                      ;Starting address
  1350.         push    dx                      ;Color bits (SI and DI not modified)
  1351.  
  1352.         cmp     di,si                   ;Compare delta-Y with delta-X
  1353.         jg      line1a                  ;Greater than +/- 45 degrees
  1354.         call    line2                   ;Flat line, count with delta-X
  1355.         jmp     short line1b
  1356. line1a: call    line3                   ;Steep line, count with delta-Y
  1357.  
  1358. line1b: pop     dx
  1359.         pop     bx
  1360.         pop     ax
  1361.         ret
  1362.  
  1363. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1364.  
  1365. ; Here when slop is less than +/- 45 degrees
  1366.  
  1367. line2:  mov     cx,si                   ;Number of pixels to plot = delta x
  1368.         inc     cx                      ;  + 1
  1369.         mov     dx,si                   ;Initialize line error to -(deltax)/2
  1370.         shr     dx,1                    ;
  1371.         neg     dx                      ;
  1372.  
  1373. line2a: or      [bx],ax                 ;Turn on pixel pointed to by BX and Al
  1374.         ror     ax,1                    ;Increment X direction
  1375.         jnc     line2b                  ;
  1376.         add     bx,2                    ;
  1377. line2b: add     dx,di                   ;Add delta y to line error
  1378.         jl      line2c                  ;Jump for next pixel if error < 0
  1379.         add     bx,bp                   ;Go up (or down) one pixel
  1380.         sub     dx,si                   ;Subtract delta x from line error
  1381. line2c: loop    line2a                  ;Set next pixel
  1382.         ret
  1383.  
  1384. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1385.  
  1386. ; Here when slope is greater than +/- 45 degrees
  1387.  
  1388. line3:  mov     cx,di                   ;Number of pixels to plot = delta y
  1389.         inc     cx                      ;  + 1 (Delta Y was negated above)
  1390.         mov     dx,di                   ;Initialize line error to -(deltay)/2
  1391.         shr     dx,1                    ;
  1392.         neg     dx                      ;
  1393.  
  1394. line3a: or      [bx],ax                 ;Turn on pixel pointed to by BX and Al
  1395.         add     bx,bp                   ;Move up (or down) 1 pixel
  1396.         add     dx,si                   ;Add delta x to line error
  1397.         jl      line3c                  ;Jump for next pixel if error < 0
  1398.         ror     ax,1                    ;Time to increment X direction
  1399.         jnc     line3b                  ;
  1400.         add     bx,2                    ;
  1401. line3b: sub     dx,di                   ;Subtract delta y from line error
  1402. line3c: loop    line3a                  ;Set next pixel
  1403.         ret
  1404.  
  1405. LINE    endp
  1406. SUBTTL  Interface to KERMIT's command parser
  1407.  
  1408. ;============================================================================
  1409. ;  General KERMIT or MS-DOS routines.
  1410. ;============================================================================
  1411.  
  1412. ; this is called by Kermit initialization.  It checks the
  1413. ; number of disks on the system, sets the drives variable
  1414. ; appropriately.  Returns normally.
  1415.  
  1416. DODISK  PROC    NEAR
  1417.         mov ah,gcurdsk                  ; Current disk value to AL.
  1418.         int dos
  1419.         mov dl,al                       ; Put current disk in DL.
  1420.         mov ah,seldsk                   ; Select current disk.
  1421.         int dos                         ; Get number of drives in AL.
  1422.         mov drives,al
  1423.         ret
  1424. DODISK  ENDP
  1425.  
  1426.  
  1427. ; Initialize variables to values used by the TI PROFESSIONAL version.
  1428.  
  1429. LCLINI  PROC    NEAR
  1430.         int     SYS_INT         ;Get system configuration info
  1431.         mov     sysdata,ax      ;Bit mask of installed devices
  1432.         mov     syssize,bx      ;Size of RAM
  1433.         call    BEEP1           ;In case BASIC left the speaker messed up
  1434.         mov     flags.vtflg,0   ;HEATH-19 emulation is off
  1435.         ret
  1436. LCLINI  ENDP
  1437.  
  1438.  
  1439. ; Get a file handle for the communications port.  Use DOS call to get the
  1440. ; next available handle.  If it fails, ask user what value to use (there
  1441. ; should be a predefined handle for the port, generally 3).  The open
  1442. ; will fail if the system uses names other than "COM1" or "COM2".
  1443.  
  1444. OPNPRT  PROC    NEAR
  1445.         ret
  1446. OPNPRT  ENDP
  1447.  
  1448.  
  1449.  
  1450. SHOWKEY PROC    NEAR
  1451.         mov ax,offset shkmsg
  1452.         mov cx,shklen
  1453.         ret
  1454. SHOWKEY ENDP
  1455.  
  1456.  
  1457. ; Set heath emulation on/off.  Called from SET TERMINAL-EMULATION command
  1458.  
  1459. VTS     PROC    NEAR
  1460.         mov dx,offset termtab
  1461.         mov bx,0
  1462.         mov ah,cmkey
  1463.         call comnd              ;Keyword, HEATH-19, VT102, ADM3A, or OFF
  1464.           jmp r
  1465.         push bx
  1466.         mov ah,cmcfm
  1467.         call comnd
  1468.           jmp short vt0
  1469.           nop
  1470.         pop bx
  1471.         mov ax,0[bx]            ; Get the control table address
  1472.         mov CTLTAB,ax
  1473.         mov al,2[bx]            ; Get terminal type
  1474.         mov flags.vtflg,al
  1475.         add bx,2+8              ; Get addr of ID sequence
  1476.         mov IDSEQ,bx
  1477.         ret
  1478.  
  1479. vt0:    pop bx
  1480.         ret
  1481. VTS     ENDP
  1482.  
  1483.  
  1484. notimp: mov ah,prstr
  1485.         mov dx,offset noimp
  1486.         int dos
  1487.         jmp prserr
  1488.  
  1489.  
  1490. ; Set the current port.  Called from SET PORT command
  1491.  
  1492. COMS    PROC    NEAR
  1493.         mov dx,offset porttab
  1494.         mov bx,0
  1495.         mov ah,cmkey
  1496.         call comnd
  1497.          jmp r
  1498.         push bx
  1499.         mov ah,cmcfm
  1500.         call comnd              ; Get a confirm.
  1501.          jmp comx               ;  Didn't get a confirm.
  1502.          nop
  1503.         call SERRST             ; Reset previous serial port
  1504.         pop bx
  1505.         mov flags.comflg,bl     ; Set the comm port flag.
  1506.  
  1507. ;**** According to the MSXSYS.DOC, flags.comflg is supposed to be 0
  1508. ;**** when using port 2.  This makes it difficult to use ports 3 and 4.
  1509.  
  1510.         cmp flags.comflg,1              ;Port 1?
  1511.         jne coms2
  1512.         mov ax,offset port1
  1513.         mov portval,ax
  1514.         mov modem.mddat,SCC1_ADAT       ;Data reg
  1515.         mov modem.mdstat,SCC1_ACMD      ;Channel A command/status
  1516.         mov modem.mdcom,SCC1_BCMD       ;Channel B command/status
  1517.         call SERINI
  1518.         ret
  1519.  
  1520. coms2:  cmp flags.comflg,2              ;Port 2?
  1521.         jne coms3
  1522.         mov ax,offset port2
  1523.         mov portval,ax
  1524.         mov modem.mddat,SCC2_ADAT       ;Data reg
  1525.         mov modem.mdstat,SCC2_ACMD      ;Channel A command/status
  1526.         mov modem.mdcom,SCC2_BCMD       ;Channel B command/status
  1527.         call SERINI
  1528.         ret
  1529.  
  1530. coms3:  cmp flags.comflg,3              ;Port 3?
  1531.         jne coms4
  1532.         mov ax,offset port3
  1533.         mov portval,ax
  1534.         mov modem.mddat,SCC3_ADAT       ;Data reg
  1535.         mov modem.mdstat,SCC3_ACMD      ;Channel A command/status
  1536.         mov modem.mdcom,SCC3_BCMD       ;Channel B command/status
  1537.         call SERINI
  1538.         ret
  1539.  
  1540. coms4:  mov ax,offset port4             ;Port 4
  1541.         mov portval,ax
  1542.         mov modem.mddat,SCC4_ADAT       ;Data reg
  1543.         mov modem.mdstat,SCC4_ACMD      ;Channel A command/status
  1544.         mov modem.mdcom,SCC4_BCMD       ;Channel B command/status
  1545.         call SERINI
  1546.         ret
  1547.  
  1548. comx:   pop bx
  1549.         ret
  1550. COMS    ENDP
  1551.  
  1552.  
  1553. ; Jumping to this location is like retskp.  It assumes the instruction
  1554. ;   after the call is a jmp addr.
  1555.  
  1556. RSKP    PROC    NEAR
  1557.         pop bp
  1558.         add bp,3
  1559.         push bp
  1560.         ret
  1561. RSKP    ENDP
  1562.  
  1563.  
  1564. ; Jumping here is the same as a ret.
  1565.  
  1566. R       PROC    NEAR
  1567.         ret
  1568. R       ENDP
  1569.  
  1570. code    ends
  1571.         end
  1572.