home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / mex / mxm-usr2.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  28.1 KB  |  908 lines

  1.     Title    'MEX overlay for the U.S. Robotics 212A version 1.0'
  2. ;
  3. ;    06/17/85 by Gary MacKay Converted MXM-US13.ASM to MXM-USR2.ASM
  4. ;            for use with the U.S. Robotics 212A. Also cleaned up
  5. ;            the fancy video rtns to work better on my TVI925 term. 
  6. ;    08/30/84 added parity routines
  7. ;    08/29/84 added fancy video conditionals
  8. ;     08/27/84 by Don Wilke
  9. ;
  10. REV    EQU    10        ; Overlay revision level
  11. ;
  12. ; Misc equates
  13. ;
  14. NO    EQU    0
  15. YES    EQU    0FFH
  16. BELL    EQU    07H        ; Bell
  17. TAB    EQU    09H        ; Tab
  18. LF    EQU    0AH        ; Line feed
  19. CR    EQU    0DH        ; Carriage return
  20. ESC    EQU    1BH        ; Escape
  21. TPA    EQU    100H        ; Transient prog area
  22. MEX    EQU    0D00H        ; Address of the service processor
  23. ATTRIB    EQU    YES        ; Yes if fancy video supported
  24. ;
  25. ; USR port equates
  26. ;
  27. PORT    EQU    060H        ; Base I/O address for my 8251 DART card
  28. MODCT1  EQU    064H        ; 8251 control port
  29. MODDAT  EQU    063H        ; 8251 data port
  30. MDDCDB    EQU    10000000B    ; Carrier detect bit
  31. MDDCDA    EQU    10000000B    ; Value when active
  32. MDRCVB    EQU    00000010B    ; Bit to test for receive
  33. MDRCVR    EQU    00000010B    ; Value when ready
  34. MDSNDB    EQU    00000001B    ; Bit to test for send
  35. MDSNDR    EQU    00000001B    ; Value when ready
  36. MMODEA    EQU    01001110B    ; 8 bits, clock/16, 1 stop bit 
  37. MMODEB    EQU    11001111B    ; 8 bits, clock/64, 2 stop bits
  38. MMCMDA    EQU    00110111B    ; RTS hi, error reset, DTR hi, enable TX/RX
  39. MMCMDB    EQU    00010111B    ; Error reset, DTR hi, enable TX/RX
  40. MRESET    EQU    01000000B    ; 8251 reset
  41. ;
  42. ; Following are function codes for the MEX service call processor
  43. ;
  44. INMDM    EQU    255        ; Get char from port to A, CY=no more in 100 ms
  45. TIMER    EQU    254        ; Delay 100ms * reg B
  46. TMDINP    EQU    253        ; B=# secs to wait for char, cy=no char
  47. CHEKCC    EQU    252        ; Check for ^C from KBD, Z=present
  48. SNDRDY    EQU    251        ; Test for modem-send ready
  49. RCVRDY    EQU    250        ; Test for modem-receive ready
  50. SNDCHR    EQU    249        ; Send a character to the modem (after sndrdy)
  51. RCVCHR    EQU    248        ; Recv a char from modem (after rcvrdy)
  52. LOOKUP    EQU    247        ; Table search: see CMDTBL comments for info
  53. PARSFN    EQU    246        ; Parse filename from input stream
  54. BDPARS    EQU    245        ; Parse baud-rate from input stream
  55. SBLANK    EQU    244        ; Scan input stream to next non-blank
  56. EVALA    EQU    243        ; Evaluate numeric from input stream
  57. LKAHED    EQU    242        ; Get nxt char w/o removing from input
  58. GNC    EQU    241        ; Get char from input, cy=1 if none
  59. ILP    EQU    240        ; Inline print
  60. DECOUT    EQU    239        ; Decimal output
  61. PRBAUD    EQU    238        ; Print baud rate
  62. CONOUT    EQU    2        ; Simulated BDOS function 2: console char out
  63. PRINT    EQU    9        ; Simulated BDOS function 9: print string
  64. INBUF    EQU    10        ; Input buffer,same structure as BDOS 10
  65.  
  66.     ORG    TPA        ; We begin
  67.     DS    3        ; MEX has a JMP START here
  68. ; The following variables are located at the beginning of the program
  69. ; to facilitate modification without the need of re-assembly. They will
  70. ; be moved in MEX 2.0.
  71. PMODEM:    DB    NO        ; Yes=PMMI modem \ / These 2 locations are not
  72. SMODEM:    DB    YES        ; Yes=Smartmodem / \ referenced by MEX
  73. TPULSE:    DB    'T'        ; T=touch,P=pulse (not referenced by MEX)
  74. CLOCK:    DB    40        ; Clock speed x .1, up to 25.5 mhz.
  75. MSPEED:    DB    5        ; Sets display time for sending a file
  76.                 ; 0=110    1=300  2=450  3=600  4=710
  77.                 ; 5=1200 6=2400 7=4800 8=9600 9=19200
  78. BYTDLY:    DB    5        ; Default time to send character in
  79.                 ; terminal mode file transfer (0-9)
  80.                 ; 0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  81. CRDLY:    DB    5        ; End-of-line delay after CRLF in terminal
  82.                 ; mode file transfer for slow BBS systems
  83.                 ; 0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  84. COLUMS:    DB    5        ; Number of directory columns
  85. SETFL:    DB    YES        ; Yes=user-defined SET command
  86. SCRTST:    DB    YES        ; Yes=if home cursor and clear screen
  87.                 ; routine at CLRSCRN
  88.     DB    0        ; Was once ACKNAK,now spare
  89. BAKFLG:    DB    NO        ; Yes=make .BAK file
  90. CRCDFL:    DB    YES        ; Yes=default to CRC checking
  91.                 ; No=default to Checksum checking
  92. TOGCRC:    DB    YES        ; Yes=allow toggling of Checksum to CRC
  93. CVTBS:    DB    NO        ; Yes=convert backspace to rub
  94. TOGLBK:    DB    YES        ; Yes=allow toggling of bksp to rub
  95. ADDLF:    DB    NO        ; No=no LF after CR to send file in
  96.                 ; terminal mode (added by remote echo)
  97. TOGLF:    DB    YES        ; Yes=allow toggling of LF after CR
  98. TRNLOG:    DB    YES        ; Yes=allow transmission of logon
  99.                 ; write logon sequence at location LOGON
  100. SAVCCP:    DB    YES        ; Yes=do not overwrite CCP
  101. LOCNXT:    DB    NO        ; Yes=local cmd if EXTCHR precedes
  102.                 ; No=not local cmd if EXTCHR precedes
  103. TOGLOC:    DB    YES        ; Yes=allow toggling of LOCNXTCHR
  104. LSTTST:    DB    YES        ; Yes=allow toggling of printer on/off
  105.                 ; in terminal mode. Set to no if using
  106.                 ; the printer port for the modem
  107. XOFTST:    DB    NO        ; Yes=allow testing of XOFF from remote
  108.                 ; while sending a file in terminal mode
  109. XONWT:    DB    NO        ; Yes=wait for XON after sending CR while
  110.                 ; transmitting a file in terminal mode    
  111. TOGXOF:    DB    YES        ; Yes=allow toggling of XOFF testing
  112. IGNCTL:    DB    YES        ; Yes=do not send control characters
  113.                 ; above CTL-M to CRT in terminal mode
  114.                 ; no=send any incoming CTL-char to CRT
  115. EXTRA1:    DB    0        ; For future expansion
  116. EXTRA2:    DB    0        ; For future expansion
  117. BRKCHR:    DB    '@'-40H        ; ^@ = Send a 300 ms. break tone
  118. NOCONN:    DB    'N'-40H        ; ^N = Disconnect from phone line
  119. LOGCHR:    DB    'L'-40H        ; ^L = Send logon
  120. LSTCHR:    DB    'P'-40H        ; ^P = Toggle printer
  121. UNSVCH:    DB    'R'-40H        ; ^R = Close input text buffer
  122. TRNCHR:    DB    'T'-40H        ; ^T = Transmit file to remote
  123. SAVCHR:    DB    'Y'-40H        ; ^Y = Open input text buffer
  124. EXTCHR:    DB    '^'-40H        ; ^^ = Send next character
  125. ; Equates used only by PMMI routines grouped together here.
  126. PRATE:    DB    250        ; 125=20pps dialing, 250=10pps
  127.     DB    0        ; Not used
  128. ; Low-level modem I/O routines: this will be replaced with
  129. ; a jump table in MEX 2.0 (you can insert jumps here to longer
  130. ; routines if you'd like ... I'd recommend NOT putting part of
  131. ; a routine in this area,then jumping to the rest of the routine
  132. ; in the non-fixed area; that will complicate the 2.0 conversion)
  133. INCTL1:    IN    MODCT1        ; In modem control port
  134.     RET
  135.     DB    0,0,0,0,0,0,0    ; Spares if needed for non-PMMI
  136. OTDATA:    OUT    MODDAT        ; Out modem data port
  137.     RET
  138.     DB    0,0,0,0,0,0,0    ; Spares if needed for non=PMMI
  139. INPORT:    IN    MODDAT        ; In modem data port
  140.     RET
  141.     DB    0,0,0,0,0,0,0    ; Spares if needed for non-PMMI
  142. ; Bit-test routines.  These will be merged with the above
  143. ; routines in MEX 2.0 to provide a more reasonable format
  144. MASKR:    ANI MDRCVB ! RET    ; Bit to test for receive ready
  145. TESTR:    CPI MDRCVR ! RET    ; Value of receive bit when ready
  146. MASKS:    ANI MDSNDB ! RET    ; Bit to test for send ready
  147. TESTS:    CPI MDSNDR ! RET    ; Value of send bit when ready
  148. ; Unused area: was once used for special PMMI functions,
  149. ; Now used only to retain compatibility with MDM overlays.
  150. ; You may use this area for any miscellaneous storage you'd
  151. ; like but the length of the area *must* be 12 bytes.
  152.     DS    12
  153. ; Special modem function jump table: if your overlay cannot handle
  154. ; some of these, change the jump to "DS 3", so the code present in
  155. ; MEX will be retained.  Thus, if your modem can't dial, change the
  156. ; JMP PDIAL at DIALV to DS 3, and MEX will print a "not-implemented"
  157. ; diagnostic for any commands that require dialing.
  158. ; DIALV  dials the digit in A. See the comments at PDIAL for specs.
  159. ; DISCV  disconnects the modem
  160. ; GOODBV is called just before MEX exits to CP/M.  If your overlay
  161. ;        requires some exit cleanup, do it here.
  162. ; INMODV is called when MEX starts up; use INMODV to initialize the modem.
  163. ; NEWBDV is used for phone-number baud rates and is called with a baud-rate
  164. ;        code in the A register, value as follows:
  165. ;      A=0:   110 baud       A=1:   300 baud      A=2:   450 baud
  166. ;      A=3:   600 baud       A=4:   710 baud      A=5:  1200 baud
  167. ;      A=6:  2400 baud       A=7:  4800 baud      A=8: 19200 baud
  168. ;        If your overlay supports the passed baud rate,it should store the
  169. ;      value passed in A at MSPEED (107H), and set the requested rate. If
  170. ;      the value passed is not supported, you should simply return (with-
  171. ;      out modifying MSPEED) -or- optionally request a baud-rate from the
  172. ;      user interactively.
  173. ; NOPARV is called at the end of each file transfer; your overlay may simply
  174. ;      return here, or you may want to restore parity if you set no-parity
  175. ;      in the following vector (this is the case with the PMMI overlay).
  176. ;      
  177. ; PARITV is called at the start of each file transfer; your overlay may simply
  178. ;      return here, or you may want to enable parity detection (this is the
  179. ;      case with the PMMI overlay).
  180. ; SETUPV is the user-defined command ... to use this routine to build your own
  181. ;      MEX command, set the variable SETFL (117H) non-zero,and add your SET
  182. ;      code.  You can use the routine presented in the PMMI overlay as a 
  183. ;      guide for parsing, table lookup, etc.
  184. ; SPMENU is provided only for MDM compatibility, and is not used by MEX 1.0 
  185. ;      for any purpose (it will be gone in MEX 2).
  186. ; VERSNV is called immediately after MEX prints its sign-on message at cold
  187. ;      startup -- use this to identify your overlay in the sign-on message
  188. ;      (include overlay version number in the line).
  189. ; BREAKV is provided for sending a BREAK (<ESC>-B in terminal mode).  If your
  190. ;      modem doesn't support BREAK, or you don't care to code a BREAK rou-
  191. ;      tine, you may simply execute a RET instruction.
  192. LOGON:    DS    2        ; Needed for MDM compat, not ref'd by MEX
  193. DIALV:    DS    3        ; Dial digit in A 
  194. DISCV:    DS    3        ; Disconnect the modem
  195. GOODBV:    JMP    GOODBYE        ; Called before exit to CP/M
  196. INMODV:    JMP    NITMOD        ; Initialization. Called at cold-start
  197. NEWBDV:    JMP    PBAUD        ; Set baud rate
  198. NOPARV:    RET ! NOP ! NOP        ; Set modem for no-parity
  199. PARITV:    RET ! NOP ! NOP        ; Set modem parity
  200. SETUPV:    JMP    SETCMD        ; SET cmd
  201. SPMENV:    RET ! NOP ! NOP        ; Not used with MEX
  202. VERSNV:    JMP    SYSVER        ; Overlay's voice in the sign-on message
  203. BREAKV:    JMP    PBREAK        ; Send a break
  204. ; The following jump vector provides the overlay with access to special
  205. ; routines in the main program (retained and supported in the main pro-
  206. ; gram for MDM overlay compatibility). These should not be modified by
  207. ; the overlay.
  208. ; Note that for MEX 2.0 compatibility, you should not try to use these
  209. ; routines, since this table will go away with MEX 2.0 (use the MEX
  210. ; service call processor instead).
  211. ILPRTV:    DS    3        ; Replace with MEX function 9
  212. INBUFV:    DS    3        ; Replace with MEX function 10
  213. ILCMPV:    DS    3        ; Replace with table lookup funct. 247
  214. INMDMV:    DS    3        ; Replace with MEX function 255
  215. NXSCRV:    DS    3        ; Not supported by MEX (returns w/no action)
  216. TIMERV:    DS    3        ; Replace with MEX function 254
  217. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  218. ; SCRNTEST to YES at 010AH (above).  Each routine must use the
  219. ; full 9 bytes alloted (may be padded with nulls).
  220. ; These routines (and other screen routines that MEX 2.0 will sup-
  221. ; port) will be accessed through a jump table in 2.0, and will be
  222. ; located in an area that won't tie the screen functions to the
  223. ; modem overlay (as the MDM format does).
  224. CLREOS:    LXI    D,EOSMSG    ; Point to clear to EOS msg
  225.     MVI    C,PRINT        ; MEX print string funct #
  226.     CALL    MEX        ; Let MEX do it
  227.     RET
  228. CLS:    LXI    D,CLSMSG    ; Point to clear screen msg
  229.     MVI    C,PRINT        ; MEX print string funct #
  230.     CALL    MEX        ; Let MEX do it
  231.     RET
  232. ; The following routine sends a break "character" to the remote computer 
  233. ; for 300 ms.  The "MSPEED" value is needed to decide whether the modem 
  234. ; is at 300, 600, or 1200 baud.  The routine must know this because U.S.R. 
  235. ; sets up the RTS bit of the command register as a baud rate selection bit, 
  236. ; and this routine must be careful not to change it, or the user will end up 
  237. ; at a different baud rate after the break "character" is sent.  Note that 
  238. ; the "MVI A,01FH" does not change any flags.
  239. PBREAK:    LDA    MSPEED        ; Get speed byte
  240.     CPI    3        ; Are we at 600 baud?
  241.     MVI    A,01FH        ; Set up for 600 (no flag changes)
  242.     JZ    PBRK2        ; And if we are, go do that
  243.     MVI    A,03FH        ; Otherwise,set up for 300/1200
  244. PBRK2:    OUT    MODCT1        ; Send break
  245.     PUSH    PSW        ; Save value
  246.     MVI    B,3        ; 300 ms delay value
  247.     MVI    C,TIMER        ; MEX service function #254
  248.     CALL    MEX        ; Wait that long
  249.     POP    PSW        ; Restore command byte
  250.     ANI    0F7H        ; Turn off break bit
  251.     OUT    MODCT1        ; Send command byte to UART
  252.     RET
  253. ; The U.S.R. 212A does not have a "quick-disconnect" feature like
  254. ; the Hayes does (by lowering DTR).  Therefore, "GOODBYE" is not
  255. ; implemented.  Yet control-N still works to hang up (see note
  256. ; above in introduction)
  257. GOODBYE:
  258.     LXI    D,DISC1        ; Point to disconnect message
  259.     CALL    PMSG        ; Send it
  260.     MVI    B,15        ; Wait 1.5 sec
  261.     MVI    C,TIMER        ; MEX service function #254
  262.     CALL    MEX        ; Wait for USR212A to wake up
  263.     LXI    D,DISC2        ; Point to rest of disconnect message 
  264.     CALL    PMSG        ; Send it too
  265.     MVI    B,15        ; Wait 1.5 sec
  266.     MVI    C,TIMER        ; MEX service function #254
  267.     CALL    MEX        ; Wait for USR212A to wake up
  268.     LXI    H,INITBL    ; Point to beginning of 8251 chip init table
  269.     LXI    B,4        ; Only want first 4 commands this time
  270. GBOUT:    MOV    A,M        ; Get character
  271.     INX    H        ; Bump up pointer
  272.     OUT    MODCT1        ; Send command to port
  273.     DCX    B        ; Counter -1
  274.     MOV    A,C        ; Move C into accum.
  275.     ORA    B        ; Test for zero
  276.     JNZ    GBOUT        ; Nope, keep sending
  277.     RET
  278. ;
  279. DISC1:    DB    '+++','$'    ; To get modems attention
  280. DISC2:    DB    'ATH',CR,'$'    ; To hang up modem
  281. ; *    *    *    *    *    *    *    *    *
  282. ;
  283. ; You can use this area for any special initialization or setup you may
  284. ; wish to include.  Each must stop with a RET.    This initialization
  285. ; sets up 1200 baud, 8 data bits, 1 stop bit, no parity.  
  286. NITMOD: DB    3EH        ; "MVI,A" OP-CODE
  287. BDCODE:    DB    33H        ; Default to 1200 baud
  288.     OUT    PORT        ; Send to 8251 buad rate port
  289.     LXI    H,INITBL    ; Point to beginning of 8251 chip init table
  290.     LXI    B,INITBLL    ; Point to length of table
  291. UOUT:    MOV    A,M        ; Get character
  292.     INX    H        ; Bump up pointer
  293.     OUT    MODCT1        ; Send command to port
  294.     DCX    B        ; Counter -1
  295.     MOV    A,C        ; Move C into accum.
  296.     ORA    B        ; Test for zero
  297.     JNZ    UOUT        ; Nope, keep sending
  298.     LXI    H,INISTR    ; Yep, point to    modem init string 
  299.     LXI    B,MDMTBLL    ; Get length of table
  300. MDM:    MOV    A,M        ; Get character
  301.     INX    H        ; Bump up pointer
  302.     PUSH    PSW        ; Save command
  303. MDM1:    IN    MODCT1        ; Get modem status
  304.     ANI    085H        ; Ready?
  305.     CPI    085H        ; 
  306.     JNZ    MDM1        ; Nope, wait
  307.     POP    PSW        ; Recall command
  308.     OUT    MODDAT        ; Send command
  309.     DCX    B        ; Decrement counter
  310.     MOV    A,C        ; Move C to accum.
  311.     ORA    B        ; Test for zero
  312.     JNZ    MDM        ; Nope, keep sending
  313.     RET            ; Yep, return to caller
  314. ;
  315. INITBL:    DB    0,0,0        ; Three nulls to reset modem
  316.     DB    40H        ; 8251 UART reset command
  317. MODEBT:    DB    4EH        ; 8 bits, 1 stop bit, clock/16, no parity
  318. CMDBT:    DB    37H        ; RTS hi, Error reset, DTR hi, Enable TX/RX
  319. INITBLL    EQU    $-INITBL    ; Length of table
  320. ;
  321. ;
  322. ; Command string sent to modem after I/O initialization
  323. ;
  324. INISTR:    DB    'AT'        ; Get modem's attention
  325.     DB    'X1'        ; Send extended result codes
  326. SPBYTE:    DB    'M1'        ; Speaker on 'til connect
  327. WABYTE:    DB    'S7=30'        ; Wait for 30 seconds for carrier
  328.     DB    CR,'$'        ; End of command string
  329. MDMTBLL    EQU    $-INISTR    ; LENGTH OF STRING TO SEND
  330. ;
  331. ;....
  332. PBAUD:    CPI    8        ; 8=9600 baud
  333.     JZ    OK9600        ; Set to 9600 baud
  334.     CPI    7        ; 7=4800
  335.     JZ    OK4800        ; Set to 4800 baud
  336.     CPI    6        ; 6=2400
  337.     JZ    OK2400        ; Set to 2400 baud
  338.     CPI    5        ; 5=1200 baud
  339.     JZ    OK1200        ; Set to 1200 baud
  340.     CPI    1        ; 1=300 baud
  341.     JZ    OK300        ; Set to 300 baud
  342.                 ; Else set up for 110 baud  * sigh!
  343. OK110:    CALL    WAIT90        ; Set even longer wait for carrier
  344.     MVI    A,MMODEA    ; Get default mode byte
  345.     STA    MODEBT        ; Reinit for 8 bits, 1 stp bit, no parity
  346.     MVI    B,00H        ; Initializer for 110 baud
  347.     MVI    A,0        ; 110 baud
  348.     JMP    LOADBD        ; Go load it
  349.                 ;
  350. OK300:    CALL    WAIT60        ; Set longer wait for carrier
  351.     MVI    A,MMODEA    ; Get default mode byte
  352.     STA    MODEBT        ; Reinit for 8 bits, 1 stp bit, no parity
  353.     MVI    B,22H        ; Initializer for 300 baud
  354.     MVI    A,1        ; 300 baud value
  355.     JMP    LOADBD        ; Go load it
  356.                 ;
  357. OK1200:    CALL    WAIT30        ; Set short wait for carrier 
  358.     MVI    A,MMODEA    ; Get default mode byte
  359.     STA    MODEBT        ; Reinit for 8 bits, 1 stp bit, no parity
  360.     MVI    B,33H        ; Initializer for 1200 baud
  361.     MVI    A,5        ; 1200 baud value
  362.     JMP    LOADBD        ; Go load it
  363.                 ;
  364. OK2400:    CALL    WAIT10        ; Set short wait for carrier 
  365.     MVI    A,MMODEA    ; Get default mode byte
  366.     STA    MODEBT        ; Reinit for 8 bits, 1 stp bit, no parity
  367.     MVI    B,55H        ; Initializer for 2400 baud
  368.     MVI    A,6        ; 2400 baud value
  369.     JMP    LOADBD        ; Go load it
  370.                 ;
  371. OK4800:    CALL    WAIT10        ; Set short wait for carrier 
  372.     MVI    A,MMODEA    ; Get default mode byte
  373.     STA    MODEBT        ; Reinit for 8 bits, 1 stp bit, no parity
  374.     MVI    B,66H        ; Initializer for 4800 baud
  375.     MVI    A,7        ; 4800 baud value
  376.     JMP    LOADBD        ; Go load it
  377.                 ;
  378. OK9600:    CALL    WAIT10        ; Set short wait for carrier 
  379.     MVI    A,MMODEA    ; Get default mode byte
  380.     STA    MODEBT        ; Reinit for 8 bits, 1 stp bit, no parity
  381.     MVI    B,77H        ; Initializer for 9600 baud
  382.     MVI    A,8        ; 9600 baud value
  383.                 ;
  384. LOADBD:    STA    MSPEED        ; Change baud rate code value
  385.     MOV    A,B        ; Get mode byte value
  386.     STA    BDCODE        ; Change mode byte
  387.     CALL    NITMOD        ; (Re)initialize the modem 
  388.     LDA    SETFLG        ; Get setflg
  389.     CPI    0FFH        ; Is it a 'SET'
  390.     JNZ    PBPSA        ; No, print bps in dial prompt
  391.     RET            ; Yes, just return
  392. PBPSA:    
  393.      IF    ATTRIB
  394.     LXI    D,INDVID    ; Set video attribute
  395.     CALL    PMSG        ; Issue attribute to term
  396.      ENDIF    ;ATTRIB
  397.     JMP    PBPS        ; Print bps rate
  398. ;.....
  399. ;
  400. ;WAIT FOR CARRIER 30/60 SECONDS
  401. ;
  402. WAIT10:    MVI    A,'1'        ; SET UP FOR REAL SHORT WAIT
  403.     JMP    SWAIT        ; JUMP AROUND 
  404. WAIT30:    MVI    A,'3'        ; SET UP FOR SHORT WAIT
  405.     JMP    SWAIT        ; JUMP AROUND
  406. WAIT60:    MVI    A,'6'        ; SET UP FOR LONG WAIT
  407.     JMP    SWAIT        ; JUMP AROUND
  408. WAIT90:    MVI    A,'9'        ; SET UP FOR LONG LONG WAIT
  409. SWAIT:    STA    WABYTE+3    ; STORE THE WAIT MSB VALUE
  410.     MVI    A,'0'        ; FAKE LSBYTE
  411.     STA    WABYTE+4    ; STORE THE WAIT LSB VALUE
  412.     RET            ;
  413. ;....
  414. ;
  415. ; Sign-on message
  416. SYSVER:     IF    ATTRIB        ; IF ATTRIB
  417.     LXI    D,INVID        ; Set video attribute
  418.     CALL    PMSG        ; Issue attribute to term
  419.      ENDIF            ; ENDIF ATTRIB
  420.                 ;    
  421.     LXI    D,SOMESG    ; Point to signon message
  422.     CALL    PMSG        ; Print message on term
  423.                 ;
  424. CARRSH:     IF    ATTRIB        ; IF ATTRIB
  425.     LXI    D,NORVID    ; Reset video attribute
  426.     CALL    PMSG        ; Issue attribute to term
  427.      ENDIF            ; ENDIF ATTRIB
  428.                 ;
  429.     CALL    CRLF        ; Print crlf
  430.                 ;
  431.     LXI    D,NOMESG    ; Tell about carrier
  432.     CALL    CARRCK        ; Check for it
  433.     CZ    PMSG        ; Print the "No" if no carrier
  434.     LXI    D,CARMSG    ; Print "carrier present"
  435.     CALL    PMSG        ; Print message on term
  436.                 ;
  437.      IF    ATTRIB        ; IF ATTRIB 
  438.     LXI    D,NORVID    ; Reset video attribute
  439.      ENDIF            ; ENDIF ATTRIB
  440.                 ;
  441.      IF    NOT ATTRIB    ; IF NOT ATRIB
  442.     RET            ; Return
  443.       ENDIF            ; ENDIF NOT ATTRIB
  444.                 ;
  445. PMSG:    MVI    C,PRINT        ; Get print funct #
  446.     CALL    MEX        ; Let MEX do it
  447.     RET
  448. ;
  449. SOMESG:    DB    ' U. S. Robotics 212A  '
  450.     DB    ' Autodial Version '
  451.     DB    REV/10+'0','.'
  452.     DB    REV MOD 10+'0',' ','$'
  453. NOMESG:    DB    'No$'
  454. CARMSG:    DB    ' carrier present '
  455.     DB    CR,LF,'$'
  456. ; Strings to clear-to-end-of-screen, and clear-screen
  457. EOSMSG:    DB    ESC,79H,'$'    ; ANSI clear EOS
  458. CLSMSG:    DB    ESC,'+$'    ; ANSI clear screen
  459. ;
  460. ; Strings for setting video attributes
  461. ;
  462. UNVID:    DB    ESC,'G8$'    ; ANSI underscore
  463. INDVID:    DB    ESC,'G4$'    ; ANSI inverse
  464. INVID:    DB    ESC,'G4$'    ; ANSI bold, inverse
  465. BLVID:    DB    ESC,'G6$'    ; ANSI bold, inverse, blinking
  466. NORVID:    DB    ESC,'G0$'    ; ANSI return to normal video
  467. ; Check the USR for carrier-present (Z=no)
  468. CARRCK:    IN    MODCT1        ; Get status byte
  469.     ANI    MDDCDB
  470.     RET
  471. ; Newline on console
  472. CRLF:    MVI    A,CR
  473.     CALL    TYPE
  474.     MVI    A,LF        ; Fall into TYPE
  475. ; Type char in A on console
  476. TYPE:    PUSH    H        ; Save 'em
  477.     PUSH    D
  478.     PUSH    B
  479.     MOV    E,A        ; Align output character
  480.     MVI    C,CONOUT    ; Print via MEX
  481.     CALL    MEX
  482.     POP    B
  483.     POP    D
  484.     POP    H
  485.     RET
  486. ; The remainder of this overlay implements a very versatile
  487. ; SET command -- if you prefer not to write a SET for your
  488. ; modem, you may delete the code from here to the END statement.
  489. ; Control is passed here after MEX parses a SET command.
  490. SETCMD:    PUSH    PSW        ; Save modem speed code
  491.     MVI    A,0FFH        ; Get all ones
  492.     STA    SETFLG        ; Set setflg
  493.     POP    PSW        ; Get modem spd back
  494.     MVI    C,SBLANK    ; Any arguments?
  495.     CALL    MEX
  496.     JC    SETSHO        ; If not, go print out values
  497.     LXI    D,CMDTBL    ; Parse command
  498.     CALL    TSRCH        ; From table
  499.     PUSH    H        ; Any address on stack
  500.     RNC            ; If we have one, execute it
  501.     POP    H        ; Nope, fix stack
  502.                 ;    
  503. SETERR:    CALL    CRLF        ; Print crlf
  504.     LXI    D,SPCS2        ; Point to spaces
  505.     CALL    PMSG        ; Print them
  506.                 ;
  507.      IF    ATTRIB        ; IF ATTRIB
  508.     LXI    D,BLVID        ; Set video attribute
  509.     CALL    PMSG        ; Issue attribute to term
  510.      ENDIF            ; ENDIF ATTRIB
  511.                 ;
  512.     LXI    D,SETEMS    ; Point to error msg
  513.     CALL    PMSG        ; Print message on term
  514.                 ;
  515.      IF    ATTRIB        ; IF ATTRIB
  516.     LXI    D,NORVID    ; Reset video attribute
  517.     CALL    PMSG        ; Issue attribute to term
  518.      ENDIF            ; ENDIF ATTRIB
  519.                 ;
  520.     CALL    CRLF        ; Print crlf
  521.                 ;
  522.     CALL    STHELP        ; Print help on error
  523.                 ;
  524.     MVI    A,0        ; Clear acc
  525.     STA    SETFLG        ; Reset setflg
  526.     RET
  527. SETEMS:    DB    BELL,'  SET COMMAND ERROR  $'
  528. ; SET command table ... note that tables are constructed of command-
  529. ; name (terminated by high bit=1) followed by word-data-value returned
  530. ; in HL by MEX service processor LOOKUP.  Table must be terminated by
  531. ; a binary zero.
  532. ; Note that LOOKUP attempts to find the next item in the input stream
  533. ; in the table passed to it in HL ... if found, the table data item is
  534. ; returned in HL; if not found, LOOKUP returns carry set.
  535. CMDTBL:    DB    '?'+80H        ; "set ?"
  536.     DW    STHELP
  537.     DB    'BAU','D'+80H    ; "set baud"
  538.     DW    STBAUD
  539.     DB    'PARIT','Y'+80H    ; "set parity"
  540.     DW    STPAR
  541.     DB    'SPK','R'+80H    ; "set spkr"
  542.     DW    STSPKR
  543.     DB    'WAI','T'+80H    ; "set wait"
  544.     DW    STWAIT
  545.     DB    'DIA','L'+80H    ; "set dial"
  546.     DW    STDIAL
  547.     DB    0        ; <<=== table terminator
  548. ; SET <no-args>: print current statistics
  549. SETSHO:    CALL    CRLF        ; Print crlf
  550.     CALL    CARRSH        ; Show carrier present/not present
  551.     LXI    H,SHOTBL    ; Get table of SHOW subroutines
  552. SETSLP:    MOV    E,M        ; Get table address
  553.     INX    H
  554.     MOV    D,M
  555.     INX    H
  556.     MOV    A,D        ; End of table?
  557.     ORA    E
  558.     JZ    SETEXT        ; Exit if so
  559.     PUSH    H        ; Save table pointer
  560.     XCHG            ; Adrs to HL
  561.     CALL    GOHL        ; Do it
  562.     CALL    CRLF        ; Print newline
  563.     MVI    C,CHEKCC    ; Check for console abort
  564.     CALL    MEX
  565.     POP    H        ; It's done
  566.     JNZ    SETSLP        ; Continue if no abort
  567.     CALL    CRLF        ; Abort and send crlf
  568.     RET
  569. GOHL:    PCHL
  570. ;
  571. SETEXT:    CALL    CRLF        ; Print crlf
  572.     RET            ; Return to caller
  573. ; table of SHOW subroutines
  574. SHOTBL:    DW    BDSHOW
  575.     DW    PASHOW
  576.     DW    SPSHOW
  577.     DW    WASHOW
  578.     DW    DISHOW
  579.     DW    0        ; <<== table terminator
  580. ; SET ?  processor
  581. STHELP:    
  582.     CALL    CRLF        ; Print message on term
  583.     CALL    CRLF        ; Print message on term
  584.                 ;
  585.     LXI    D,SPCS1        ; Point to spaces
  586.     CALL    PMSG        ; Print them
  587.                 ;
  588.      IF    ATTRIB        ; IF ATTRIB
  589.     LXI    D,UNVID        ; Set video attribute
  590.     CALL    PMSG        ; Issue attribute to term
  591.      ENDIF            ; ENDIF ATTRIB
  592.                 ;
  593.     LXI    D,HLPHDR    ; Point to HELP header
  594.     CALL    PMSG        ; Print message on term
  595.                 ;
  596.      IF    ATTRIB        ; IF ATTRIB
  597.     LXI    D,NORVID    ; Reset video attribute
  598.     CALL    PMSG        ; Issue attribute to term
  599.      ENDIF            ; ENDIF ATTRIB
  600.                 ;
  601.     CALL    CRLF        ; Print message on term
  602.     CALL    CRLF        ; Print message on term
  603.                 ;
  604.     LXI    D,HLPMSG    ; Point to HELP msg
  605.     CALL    PMSG        ; Print message on term
  606.                 ;
  607.     CALL    CRLF        ; Print message on term
  608.                 ;
  609.     LXI    D,SPCS1        ; Point to spaces
  610.     CALL    PMSG        ; Print them
  611.                 ;
  612.      IF    ATTRIB        ; IF ATTRIB
  613.     LXI    D,INDVID    ; Set video attribute
  614.     CALL    PMSG        ; Issue attribute to term
  615.      ENDIF            ; ENDIF ATTRIB
  616.                 ;
  617.     LXI    D,HLPNOT    ; Point to HELP note
  618.     CALL    PMSG        ; Print message on term
  619.                 ;
  620.      IF    ATTRIB        ; IF ATTRIB
  621.     LXI    D,NORVID    ; Reset video attribute
  622.     CALL    PMSG        ; Issue attribute to term
  623.      ENDIF            ; ENDIF ATTRIB
  624.                 ;
  625.     CALL    CRLF        ; Print CR,LF on term
  626.     CALL    CRLF        ; Print another CR,LF on term
  627.     RET            ; Return to caller
  628. ; The help message
  629. HLPHDR:    DB    'THE FOLLOWING ARE VALID SET COMMANDS:$'
  630. ;
  631. HLPMSG:    DB    '     SET BAUD <110>  or <300>  or <1200>',CR,LF
  632.     DB    '              <2400> or <4800) or <9600>',CR,LF
  633.     DB    '     SET PARITY <NONE> or <ODD> or <EVEN>',CR,LF
  634.     DB    '     SET SPKR <OFF> or <ON> or <DEBUG>',CR,LF
  635.     DB    '     SET WAIT <10> or <30> or <60> or <90>',CR,LF
  636.     DB    '     SET DIAL <TOUCH> or <PULSE>',CR,LF,'$'
  637. ;
  638. HLPNOT:    DB    'NOTE: SET BAUD defaults to NO parity.$'
  639. ;
  640. SPCS1:    DB    '  $'
  641. SPCS2:    DB    '         $'
  642. ;
  643. SETFLG:    DB    0        ; SET command flag
  644. ;
  645. ;....
  646. ; SET BAUD processor
  647. STBAUD:    MVI    C,BDPARS    ; Function code
  648.     CALL    MEX        ; Let MEX look up code
  649.     JC    SETERR        ; Invalid code
  650.     CALL    PBAUD        ; No, try to set it
  651.     JC    SETERR        ; Not-supported code
  652.     JMP    SETSHO        ; review parameters
  653. ;
  654. BDSHOW:    LDA    SETFLG        ; Get setflg
  655.     CPI    0FFH        ; Is it a 'SET' operation?
  656.     JNZ    PBPS        ; No, must be dial - just display bps
  657.     CALL    ILPRT        ; Yes, display the 'Baud' prompt
  658.     DB    'Baud rate: ',0
  659. PBPS:    LDA    MSPEED        ; Load modem speed code
  660.     MVI    C,PRBAUD    ; Use MEX function #
  661.     CALL    MEX        ; To print bps
  662.     LXI    D,NORVID    ; Reset video attribute
  663.     CALL    PMSG        ; Issue attribute to term
  664.     MVI    E,' '        ; Followed by space
  665.     MVI    C,CONOUT    ; Use MEX function #
  666.     CALL    MEX        ; Let MEX do it
  667.     MVI    A,0        ; Clear acc
  668.     STA    SETFLG        ; Reset setflg
  669.     RET
  670. ;
  671. ;....
  672. ;
  673. ; SET PARITY PROCESSOR
  674. ;
  675. STPAR:    LXI    D,PARTBL    ; Point to parity table
  676.     CALL    TSRCH        ; Lookup next input item in table
  677.     JC    SETERR        ; If NOT found, error
  678.     PUSH    PSW        ; A=byte from table
  679.     LDA    MODEBT        ; Get old mode byte
  680.     ANI    0C3H        ; Strip off parity bits, word length
  681.     MOV    B,A        ; Old modebt into B
  682.     POP    PSW        ; Get table entry back
  683.     ANI    3CH        ; Mask parity bits, word length
  684.     ADD    B        ; Adjust new parity values
  685.     STA    MODEBT        ; Store the new mode byte
  686.     CALL    NITMOD        ; (Re)initialize the modem
  687.     JMP    SETSHO        ; Review parameters 
  688. ;
  689. PASHOW:    CALL    ILPRT        ; Show parity mode
  690.     DB    'Parity: ',0    
  691.     LDA    MODEBT        ; Get mode byte
  692.     ANI    30H        ; Mask off parity bits
  693.     CPI    10H        ; Bit 4 hi?
  694.     JZ    ODDPAR        ; Yes, ODD parity
  695.     CPI    30H        ; Bits 4,5 hi?
  696.     JZ    EVPAR        ; Yes, EVEN parity
  697.                 ; Else NO parity
  698. NOPAR:    CALL    ILPRT        ; In-line print
  699.     DB    'NONE',0    ; Message
  700.     RET            ; Return
  701. EVPAR:    CALL    ILPRT        ; In-line print
  702.     DB    'EVEN',0    ; Message
  703.     RET            ; Return
  704. ODDPAR:    CALL    ILPRT        ; In-line print
  705.     DB    'ODD',0        ; Message
  706.     RET            ; Return
  707. ;
  708. PARTBL:    DB    'NON','E'+80H    ; Set parity NONE
  709.     DB    0CH,0        ; 8 Bit word length
  710.     DB    'EVE','N'+80H    ; Set parity EVEN
  711.     DB    38H,0        ; Bits 5,4,3 hi (7 bit word length)
  712.     DB    'OD','D'+80H    ; Set parity ODD
  713.     DB    18H,0        ; Bits 4,3 hi (7 bit word length)
  714.     DB    0        ; <<==== TABLE TERMINATOR
  715. ;....
  716. ;
  717. ; SET SPKR processor
  718. ;
  719. STSPKR:    LXI    D,SPKTBL    ; lookup next input item in table
  720.     CALL    TSRCH
  721.     JC    SETERR        ; if not found, error
  722.     STA    SPBYTE+1    ; store the spkr command
  723.     CALL    NITMOD        ; (re)initialize modem
  724.     JMP    SETSHO        ; review parameters
  725. ;
  726. SPSHOW:    CALL    ILPRT        ; show spkr mode
  727.     DB    'Speaker: ',0
  728.     LDA    SPBYTE+1    ; get spkr byte
  729.     CPI    '1'
  730.     JZ    SPONPT        ; spkr on part-time
  731.     CPI    '2'
  732.     JZ    SPON        ; spkr on continuously
  733. ;
  734. SPOFF:    CALL    ILPRT
  735.     DB    'OFF',0
  736.     RET
  737. ;
  738. SPONPT:    CALL    ILPRT
  739.     DB    'ON until connect',0
  740.     RET
  741. ;
  742. SPON:    CALL    ILPRT
  743.     DB    'ON always',0
  744.     RET
  745. ;
  746. SPKTBL:    DB    'OF','F'+80H    ; set spkr off
  747.     DB    '0',0
  748.     DB    'O','N'+80H    ; set spkr on 'til connect    
  749.     DB    '1',0
  750.     DB    'DEBU','G'+80H    ; set spkr on continuously
  751.     DB    '2',0
  752.     DB    0        ; <<=== table terminator
  753. ; SET WAIT PROCESSOR
  754. ;
  755. STWAIT:    LXI    D,WAITBL    ; LOOKUP NEXT INPUT ITEM IN TABLE
  756.     CALL    TSRCH        ;
  757.     JC    SETERR        ; IF NOT FOUND, ERROR
  758.     STA    WABYTE+3    ; STORE THE WAIT MSB VALUE
  759.     MVI    A,'0'        ; FAKE LSB BYTE
  760.     STA    WABYTE+4    ; STORE THE WAIT LSB VALUE
  761.     CALL    NITMOD        ; (RE) INITIALIZE MODEM
  762.     JMP    SETSHO        ; REVIEW PARAMETERS
  763.                 ;
  764. WASHOW:    CALL    ILPRT
  765.     DB    'Wait: ',0
  766.     LDA    WABYTE+3
  767.     CALL    TYPE        ; SHOW MSB OF VALUE
  768.     LDA    WABYTE+4    ; 
  769.     CALL    TYPE        ; SHOW LSB OF VALUE
  770.     CALL    ILPRT
  771.     DB    ' seconds for carrier',0
  772.     RET            ;
  773. ;
  774. WAITBL:    DB    '1','0'+80H    ; "SET WAIT 10"
  775.     DB    '1',0
  776.     DB    '3','0'+80H    ; "SET WAIT 30"
  777.     DB    '3',0
  778.     DB    '6','0'+80H    ; "SET WAIT 60"
  779.     DB    '6',0
  780.     DB    '9','0'+80H    ; "SET WAIT 90"
  781.     DB    '9',0
  782.     DB    0
  783. ;
  784. ;.....
  785. ;
  786. ; SET DIAL PROCESSOR
  787. ;
  788. STDIAL:    LXI    D,DIATBL    ; LOOKUP NEXT INPUT ITEM IN TABLE
  789.     CALL    TSRCH
  790.     JC    SETERR        ; IF NOT FOUND, ERROR
  791.     STA    TPULSE        ; STORE THE DIAL COMMAND 
  792.     CALL    NITMOD        ; (RE) INITIALIZE MODEM
  793.     JMP    SETSHO        ; REVIEW PARAMETERS
  794.                 ;
  795. DISHOW:    CALL    ILPRT        ; SHOW DIAL MODE
  796.     DB    'Dial:  ',0
  797.     LDA    TPULSE        ; GET DIAL BYTE
  798.     CPI    'T'        ;
  799.     JZ    TTONE        ; TOUCH TONE
  800.                 ;
  801. PDIAL:    CALL    ILPRT        ; PRINT
  802.     DB    'Pulse',0    ; PULSE DIAL MESSAGE
  803.     RET            ; AND RETURN
  804.                 ;
  805. TTONE:    CALL    ILPRT        ; PRINT
  806.     DB    'Touch Tone',0    ; TONE DIAL MESSAGE
  807.     RET            ; AND RETURN
  808.                 ;
  809. ; DIAL ARGUMENT TABLE
  810. ;
  811. DIATBL:    DB    'TOUC','H'+80H    ; TOUCH TONE
  812.     DB    'T',0
  813.     DB    'PULS','E'+80H    ; PULSE DIAL
  814.     DB    'P',0
  815.     DB    0
  816. ;
  817. ;.....
  818. ;
  819. ; Compare next input-stream item in table @DE; CY=1
  820. ; if not found, else HL=matched data item
  821. TSRCH:    MVI    C,LOOKUP    ; Get function code
  822.     JMP    MEX        ; Pass to MEX processor
  823. ;....
  824. ; Print in-line message ... blows away C register
  825. ILPRT:    MVI    C,ILP        ; Get function code
  826.     JMP    MEX        ; Go do it
  827. ;
  828. ;.... 
  829. ;
  830. ; NOTE:  Must terminate prior to 0B00H 
  831.       END
  832.