home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol220 / mxo-oc10.aqm / MXO-OC10.ASM
Encoding:
Assembly Source File  |  1986-02-11  |  16.8 KB  |  689 lines

  1. ; MXO-CP10.ASM - Overlay for Osborne01 with the COMM-PAC Modem 06/23/84
  2. ;           Auto-dialing supported.
  3. ;
  4. REV:    EQU    10
  5. ;
  6. ;    This overlay will work with MEX
  7. ;
  8. ;
  9. ; You will want to look this file over carefully.  There are a number of
  10. ; options that can be used to configure the program to suit your taste.
  11. ;
  12. ; Use the "SET" command to change the baudrate when desired.  It starts
  13. ; out at 300 baud when the program is first called up, but remember, the
  14. ; COMM-PAC only works at 300 baud.  
  15. ;
  16. ; Please report any problems by leaving a message on the Houston Bay Area
  17. ; RCP/M  1-713-488-5619 --- John Riehl
  18. ;
  19. ;    TO USE: First edit this file filling in answers for your own
  20. ;        equipment.  Then assemble with ASM.COM or equivalent
  21. ;        assembler.  Then use MLOAD to overlay the the results
  22. ;        of this program to the original .COM file:
  23. ;
  24. ;        A>MLOAD NEWMEX.COM=MEX10.COM,MXO-OC10.HEX
  25. ;
  26. ;         You now have modified .COM file.
  27. ;
  28. ;=========================================================================
  29. ;
  30. ; 06/23/84   Original derived from M7OSCP-4.ASM & MXO-PM11.ASM
  31. ; Vers. 1.0
  32. ;                            - John Riehl    
  33. ;=========================================================================
  34. ;
  35. YES:    EQU    0FFH
  36. NO:    EQU    0
  37. TPA:    EQU    100H
  38. CR:    EQU    0DH
  39. LF:    EQU    0AH
  40. TAB:    EQU    9
  41. ESC:    EQU    1BH    
  42. ;
  43. ;  Osborne01 port definitions
  44. ;
  45. PORT:    EQU    2A00H
  46. MODCT1:    EQU    PORT    ;status register for RS232
  47. MODDAT:    EQU    PORT+1  ;data resister for RS232
  48. MDRCVB:    EQU    1    ;bit to test for received data
  49. MDRCVR:    EQU    1    ;modem receive ready when high
  50. MDSNDB:    EQU    2    ;bit to test for ready to send
  51. MDSNDR:    EQU    2    ;modem send ready when high
  52. DCDMSK:    EQU    4    ;modem carrier on when low
  53. ;
  54. MCBON:    EQU    40H    ;mask to turn on MCB 
  55. MCBOFF:    EQU    0BFH    ;mask to turn off MCB
  56. ;
  57. ORIGMD:    EQU    56H
  58. WTCTS:    EQU    150    ;number of seconds (x5) to wait for the
  59.             ;computer to answer after COMM-PAC auto-dial
  60.             ;100=20 sec, 150=30 sec, 255=51 sec.
  61.             ;any number 0-255 acceptable
  62. RBWAIT:    EQU    50    ;5 second delay before redialing COMM-PAC
  63. ;
  64. ;
  65. ; MEX service processor stuff
  66. ;
  67. MEX:    EQU    0D00H    ;address of the service processor
  68. INMDM:    EQU    255    ;get char from port to A, CY=no more in 100 ms
  69. TIMER:    EQU    254    ;delay 100ms * reg B
  70. TMDINP:    EQU    253    ;B=# secs to wait for char, cy=no char
  71. CHEKCC:    EQU    252    ;check for ^C from KBD, Z=present
  72. SNDRDY:    EQU    251    ;test for modem-send ready
  73. RCVRDY:    EQU    250    ;test for modem-receive ready
  74. SNDCHR:    EQU    249    ;send a character to the modem (after sndrdy)
  75. RCVCHR:    EQU    248    ;recv a char from modem (after rcvrdy)
  76. LOOKUP:    EQU    247    ;table search: see CMDTBL comments for info
  77. PARSFN:    EQU    246    ;parse filename from input stream
  78. BDPARS:    EQU    245    ;parse baud-rate from input stream
  79. SBLANK:    EQU    244    ;scan input stream to next non-blank
  80. EVALA:    EQU    243    ;evaluate numeric from input stream
  81. LKAHED:    EQU    242    ;get nxt char w/o removing from input
  82. GNC:    EQU    241    ;get char from input, cy=1 if none
  83. ILP:    EQU    240    ;inline print
  84. DECOUT:    EQU    239    ;decimal output
  85. PRBAUD:    EQU    238    ;print baud rate
  86. ;
  87. BDOS:    EQU    5
  88. ;
  89. CONOUT:    EQU    2    ;simulated BDOS function 2: console char out
  90. PRINT:    EQU    9    ;simulated BDOS function 9: print string
  91. INBUF:    EQU    10    ;input buffer, same structure as BDOS 10
  92. ;
  93. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++è;
  94.     ORG    TPA
  95. ;
  96.     DS    6    ;(for  "JMP   START" instruction)
  97. CLOCK:    DB    40    ;clock speed (must 40 for Osborne01    106H
  98. MSPEED:    DB    1    ; 1=300 5=1200                107H
  99. BYTDLY:    DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms   108H
  100.             ;default time to send character in ter-
  101.             ;minal mode file transfer for slow BBS.
  102. CRDLY:    DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  103.             ;default time for extra wait after CRLF
  104.             ;in terminal mode file transfer
  105. COLUMS:    DB    3    ;number of DIR columns shown        10AH
  106. SETFL:    DB    YES    ;yes=user-added Setup routine        10BH
  107. SCRTST:    DB    YES    ;cursor control routine         10CH
  108.     DB    0    ;spare                    10DH
  109. BAKFLG:    DB    NO    ;yes=change any file same name to .BAK    10EH
  110. CRCDFL:    DB    YES    ;yes=default to CRC checking        10FH
  111. TOGCRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  112. CVTBS:    DB    NO    ;yes=convert backspace to rub        111H
  113. TOGLBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  114. ADDLF:    DB    NO    ;no=no LF after CR to send file in    113H
  115.             ;terminal mode (added by remote echo)
  116. TOGLF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  117. TRNLOG:    DB    NO    ;yes=allow transmission of logon    115H
  118.             ;write logon sequence at location LOGON
  119. NOSAVE:    DB    NO    ;DO NOT CHANGE, MUST BE 'NO' FOR OS-1    116H
  120. LOCNXT:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  121.             ;no=external command if EXTCHR precedes
  122. TOGLOC:    DB    YES    ;yes=allow toggling of LOCNXT    118H
  123. LSTTST:    DB    YES    ;yes=printer available on printer port    119H
  124. XOFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  125.             ;sending a file in terminal mode
  126. XONWT:    DB    NO    ;yes=wait for XON after CR while    11BH
  127.             ;sending a file in terminal mode
  128. TOGXOF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  129. IGNCTL:    DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  130. EXTRA1:    DB    0    ;For future expansion            11EH
  131. EXTRA2:    DB    0    ;for future expansion            11FH
  132. CARRIER:DB    'V'-40H    ;^V = Turn on carrier            120H
  133. NOCONN:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  134. LOGCHR:    DB    'L'-40H    ;^L = Send logon            122H
  135. LSTCHR:    DB    'P'-40H    ;^P = Toggle printer            123H
  136. UNSVCH:    DB    'R'-40H    ;^R = Close input text buffer        124H
  137. TRNCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  138. SAVCHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  139. EXTCHR:    DB    ESC    ;ESC= Send next character        127H
  140. ;
  141.     DS    2    ;NOT USED
  142. ;
  143. INCTL1:    CALL    OSTAT    ! RET    ;get the I/O status        12AH
  144. OTCTL1:    CALL    OSET    ! RET    ;setup I/O            12EH
  145.         DS    2è;
  146. OTDATA:    CALL    OSOUT    ! RET    ;send a character to the I/O    134H
  147.         DS    6
  148. ;
  149. INPORT:    CALL    OSIN    ! RET    ;get a character from the I/O    13EH
  150.         DS    6
  151. ;
  152. MASKR:    ANI    MDRCVB ! RET    ;bit to test for receive ready    148H
  153. TESTR:    CPI    MDRCVR ! RET    ;value of rcv. bit when ready    14BH
  154. MASKS:    ANI    MDSNDB ! RET    ;bit to test for send ready    14EH
  155. TESTS:    CPI    MDSNDR ! RET    ;value of send bit when ready    151H
  156. ;
  157.     DS    14    ;UNUSED AREA                154H
  158. ;
  159. DIALV:    JMP    PDIAL    ;dial digit in A            162H
  160. DISCV:    JMP    PDISC    ;disconnect the modem            165H
  161. GOODBV:    RET ! NOP ! NOP    ;called before exit to CP/M        168H
  162. INMODV:    JMP    NITMOD    ;initialization called by cold start    16BH
  163.     RET ! NOP ! NOP    ;(by-passes PMMI routine)        16EH
  164.     RET ! NOP ! NOP    ;(by-passes PMMI routine)        171H
  165.     RET ! NOP ! NOP    ;(by-passes PMMI routine)        174H
  166. SETUPV:    JMP    SETCMD    ;                    177H
  167.     DS    3    ;not used by mex            17AH
  168. VERSNV:    JMP    SYSVER    ;overlays voice in sign-on msg        17DH
  169. BREAKV:    JMP    PCNCT    ;Turn on carrier            180H
  170. ;
  171. ;
  172. ; Do not change the following six lines.
  173. ;
  174. ILPRTV:    DS    3        ;                183H
  175. INBUFV:    DS    3        ;                186H
  176. ILCMPV:    DS    3        ;                189H
  177. INMDMV:    DS    3        ;                18CH
  178. NXSCRV:    DS    3        ;                18FH
  179. TIMERV:    DS    3        ;                192H
  180. ;
  181. ;
  182. ; Clear/screen and clear/end-of-screen.
  183. ;
  184. CLREOS:    LXI    D,EOSMSG
  185.     MVI    C,PRINT
  186.     CALL    MEX
  187.     RET
  188. ;
  189. ;
  190. CLS:    LXI    D,CLSMSG        ;null unless patched
  191.     MVI    C,PRINT
  192.     CALL    MEX
  193.     RET
  194. ;
  195. ;------------------------------------------------------------
  196. ;
  197. ;    *** END OF FIXED FORMAT AREA ***è;
  198. ;------------------------------------------------------------
  199. ;
  200. ; Osborne & Modem initialization.
  201. ;
  202. NITMOD:    LHLD    BDOS+1        ;FIND START OF BDOS
  203.     LXI    D,-0100H    ;GO TO FIRST PAGE AHEAD OF BDOS
  204.     DAD    D        ;HL NOW POSITIONED ONE PAGE BELOW BDOS
  205.     PUSH    H        ;SAVE THE ADDRESS
  206.     LXI    D,BDJ        ;POINT TO OUR ROUTINE TO PUT THERE
  207.     LXI    B,CDLEN+2    ;SET LENGTH OF CODE
  208.     XCHG
  209.     DB    0EDH,0B0H    ;Z80 LDIR
  210. ;
  211.     LHLD    BDOS+1        ;GET BDOS ADDRESS BACK ONCE MORE
  212.     POP    D        ;GET THE STARTING ADDRESS OFF STACK
  213.     PUSH    D        ;PUT IT BACK ON THE STACK
  214.     INX    D        ;POINT TO ADDRESS POSITION
  215.     XCHG            ;PUT INTO 'HL'
  216.     MOV    M,E        ;STORE 'LSP' ADDRESS
  217.     INX    H        ;GET 'LSP' LOCATION
  218.     MOV    M,D        ;STORE 'MSP' ADDRESS
  219.     POP    H        ;GET THE ADDRESS BACK ONCE MORE
  220.     SHLD    BDOS+1        ;NEW ADDRESS TO PROTECT FOR OVERWRITE
  221. ;
  222.     LXI    D,OSIN-BDJ    ;GET THE LENGTH OF ROUTINE TO MOVE
  223.     DAD    D        ;COMUTE ADDRESS OF THE 'OSIN' ROUTINE
  224.     SHLD    INPORT+1    ;PATCH CALL FOR "GET CHAR." ROUTINE
  225.     LXI    D,OSOUT-OSIN
  226.     DAD    D
  227.     SHLD    OTDATA+1    ;PATCH CALL FOR "SEND CHAR." ROUTINE
  228.     LXI    D,OSTAT-OSOUT
  229.     DAD    D
  230.     SHLD    INCTL1+1    ;PATCH CALL FOR "GET STATUS" ROUTINE
  231.     LXI    D,OSET-OSTAT
  232.     DAD    D
  233.     SHLD    OTCTL1+1    ;PATCH JMP FOR "SEND ACIA CTL" ROUTINE
  234. ;
  235.     MVI    A,1        ;MSPEED 300 baud value
  236.     STA    MSPEED
  237. ;
  238. ;
  239. ; SET THE INITIAL BAUD RATE TO 300
  240. ;
  241.     MVI    A,56H        ;FOR 300 BAUD
  242. SETUPR1:STA    UCTLB
  243. ;
  244. MODCTL2:PUSH    B
  245.     MVI    C,3
  246. CNT:    MVI    B,6BHè    LDA    UCTLB
  247.     ORI    MCBON
  248.     CALL    OTCTL
  249.     CALL    DELAY
  250.     MVI    B,6BH
  251.     LDA    UCTLB
  252.     ANI    MCBOFF
  253.     CALL    OTCTL
  254.     CALL    DELAY
  255.     DCR    C
  256.     JNZ    CNT
  257.     MVI    B,6BH
  258.     LDA    UCTLB
  259.     ORI    MCBON
  260.     CALL    OTCTL
  261.     CALL    DELAY
  262.     MVI    B,6BH
  263.     MVI    A,3
  264.     CALL    OTCTL
  265.     CALL    DELAY
  266.     LDA    UCTLB
  267.     ORI    MCBON
  268.     CALL    OTCTL
  269.     POP    B
  270.     RET
  271. ;
  272. OTCTL:    PUSH    H
  273.     CALL    OTCTL1
  274.     POP    H
  275.     XRA    A    ;CLEAR CARRY
  276.     RET
  277. ;.....
  278. ;
  279. DELAY:    DCR    B
  280.     JNZ    DELAY
  281.     RET
  282. ;
  283. ; disconnect the modem
  284. ;
  285. PDISC:    LDA    UCTLB
  286.     ORI    MCBON
  287.     CALL    OTCTL
  288.     PUSH    B
  289.     MVI    B,20        ;wait for COMM-PAC to disconnect (1 sec)
  290.     MVI    C,TIMER        ;0.1 second per timer interval
  291.     CALL    MEX
  292.     POP    B
  293.     RET
  294. ;
  295. ;------------------------------------------------------------
  296. ;
  297. ; --- ROUTINES THAT GET PLACED JUST UNDER 'BDOS' OVERLAYING 'CCP'
  298. ;
  299. BDJ:    JMP    $-$        ;THIS GETS PATCHED TO JUMP TO BDOS ENTRY
  300. ;
  301. OSIN:    DI            ;DISABLE INTERRUPTS
  302.     OUT    0        ;SWITCH TO ALTERNATE PAGE
  303.     LDA    MODDAT        ;GET DATA BYTE
  304.     OUT    1        ;SWITCH PAGES BACK
  305.     EI            ;RE-ENABLE INTERRUPTS
  306.     RET
  307. ;.....
  308. ;
  309. ;
  310. OSOUT:    DI            ;DISABLE INTERRUPTS
  311.     OUT    0        ;SWITDH TO ALTERNATE PAGE
  312.     STA    MODDAT        ;SEND DATA BYTE
  313.     OUT    1        ;SWITCH PAGES BACK
  314.     EI            ;RE-ENABLE INTERRUPTS
  315.     RET
  316. ;.....
  317. ;
  318. ;
  319. OSTAT:    DI            ;DISABLE INTERRUPTS
  320.     OUT    0        ;SWITCH TO ALTERNATE PAGE
  321.     LDA    MODCT1        ;GET STATUS BYTE
  322.     OUT    1        ;SWITCH PAGES BACK
  323.     EI            ;RE-ENABLE INTERRUPTS
  324.     RET
  325. ;.....
  326. ;
  327. ;
  328. OSET:    DI
  329.     OUT    0
  330.     STA    MODCT1
  331.     OUT    1
  332.     EI
  333.     RET
  334. ;.....
  335. ;
  336. CDLEN:    EQU    $-BDJ        ;LENGTH OF CODE TO COPY
  337. ;
  338. ;
  339. ;=======================================================================
  340. ;
  341. ;               COMM-PAC DIALIN╟ ROUTINES
  342. ;
  343. ;=======================================================================
  344. ;
  345. PDIAL:    CPI    254        ;start-dial?è    JZ    STDIAL
  346.     CPI    255        ;end-dial
  347.     JZ    ENDIAL
  348.     CPI    ','        ;smartmodem pause command
  349.     JNZ    CKDIG        ;if not pause, continue
  350.     MVI    B,10        ;delay 1 second
  351.     MVI    C,TIMER
  352.     CALL    MEX
  353.     RET
  354. ;
  355. CKDIG:    CPI    '9'+1        ;digits are 0-9
  356.     RNC            ;too big...
  357.     SUI    '0'
  358.     RC            ;too small....
  359.     JNZ    NOTZERO        ;just right...
  360.     MVI    A,10        ;convert zero to 10 pulses
  361. NOTZERO:MOV    C,A
  362. ;
  363. ; Send the digit to the modem.   Wait 200 ms. inter-digit.
  364. ;
  365. DIALIT:    PUSH    B
  366.     CALL    PULSE
  367.     CALL    BDELAY
  368.     POP    B
  369.     DCR    C
  370.     JNZ    DIALIT
  371.     LDA    INTERD
  372.     MOV    B,A        ;get inter-digit delay
  373.     MVI    C,TIMER
  374.     CALL    MEX
  375.     RET
  376. ;
  377. BDELAY: PUSH    PSW
  378.     PUSH    B
  379.     MVI    B,40
  380.     MVI    C,0
  381.     MOV    A,B
  382. BIGAGN:    CALL    BDELAY1
  383.     POP    B
  384.     POP    PSW
  385.     RET
  386. ;
  387. BDELAY1:MOV    B,A
  388.     CALL    DELAY
  389.     DCR    C
  390.     JNZ    BDELAY1
  391.     RET
  392. ;
  393. ; Disconnect from the line, reconnect and wait for the dialtone.
  394. ;
  395. STDIAL:    CALL    PDISC
  396.     CALL    PCNCT
  397.     MVI    D,DCDMSK
  398.     MVI    E,5
  399.     CALL    WAITè    RET
  400. ;.....
  401. ;
  402. ; End-dial sequence
  403. ;
  404. ENDIAL:    CALL    ENDIT        ;close out dialing
  405.     ORA    A        ;successfully connected?
  406.     RZ            ;exit now if so
  407.     PUSH    PSW        ;nope, save the error code
  408.     CALL    PDISC        ;shut down the modem
  409.     POP    PSW
  410.     RET
  411. ;
  412. ENDIT:    CALL    OFF        ;go off-hook
  413.     MVI    D,DCDMSK
  414.     MVI    E,WTCTS        ;wait up to 30 seconds
  415.     CALL    WAIT
  416.     RNC            ;return A=0 if good
  417.     CPI    3        ;keyboard abort?
  418.     RZ            ;if so return it
  419.     MVI    A,2        ;nope, convert error to "no answer"
  420.     RET
  421. ;
  422. ;    <end of COMM-PAC dialing routines>
  423. ;------------------------------------------------------------
  424. ;
  425. ; go off-hook
  426. ;
  427. OFF:    CALL    PCNCT        ;turn on DTR
  428.     MVI    B,1        ;wait 100 ms
  429.     MVI    C,TIMER
  430.     CALL    MEX
  431.     RET
  432. ;
  433. ; Time-out routine.
  434. ;
  435. WAIT:    MVI    B,2        ;200 ms
  436.     MVI    C,TIMER        ;wait for timer to go high then low
  437.     CALL    MEX
  438.     CALL    CARRCK        ;do we have a carrier
  439.     ANA    D
  440.     RZ            ;active low, so return on 0
  441.     MVI    C,CHEKCC    ;not yet, check for console-abort
  442.     CALL    MEX        ;abort?
  443.     MVI    A,3        ;set error code 3 if abort active
  444.     STC
  445.     RZ            ;return if aborted
  446.     DCR    E        ;nope, downcount
  447.     JNZ    WAIT
  448.     INR    A        ;set error=4 (modem error); cy already set
  449.     RET
  450. ;
  451. ;
  452. ; Set baud-rate code in A
  453. ;
  454. PBAUD:    PUSH    H        ;don't alter anybody
  455.     PUSH    Dè    PUSH    B
  456.     MOV    E,A        ;code to DE
  457.     MVI    D,0
  458.     LXI    H,BAUDTB    ;offset into table
  459.     DAD    D
  460.     MOV    A,M        ;fetch code
  461.     ORA    A        ;0? (means unsupported code)
  462.     STC            ;return error for STBAUD caller
  463.     JZ    PBEXIT        ;exit if so
  464.     CALL    SETUPR1        ;good rate, set it
  465.     STA    BAUDSV        ;save it
  466.     MOV    A,E        ;get speed code back
  467.     STA    MSPEED        ;make it current
  468. PBEXIT:    POP    B        ;all done
  469.     POP    D
  470.     POP    H
  471.     RET
  472. ;
  473. ; table of baud rate divisors for supported rates
  474. ;
  475. BAUDTB:    DB    0,56H,0,0,0    ;110,300,450,610,710
  476.     DB    55H,0,0,0,0    ;1200,2400,4800,9600,19200
  477. ;
  478. ;======================= SIGN-ON MESSAGE ==============================    
  479. ;
  480. SYSVER:    CALL    NITMOD            ;relocate i/o
  481.     LXI    D,SOMESG
  482.     MVI    C,PRINT
  483.     CALL    MEX
  484. CARRSH:    LXI    D,NOMESG        ;tell about carrier
  485.     CALL    CARRCK            ;check for it
  486.     ANI    DCDMSK
  487.     MVI    C,PRINT
  488.     CNZ    MEX            ;print the "NO" if no carrier
  489.     LXI    D,CARMSG        ;print "carrier present"
  490.     MVI    C,PRINT
  491.     CALL    MEX
  492.     RET
  493. ;
  494. SOMESG:    DB    ' Osborne COMM-PAC modem V. '
  495.     DB    REV/10+'0'
  496.     DB    '.'
  497.     DB    REV MOD 10+'0'
  498.     DB    ': $'
  499. ;
  500. NOMESG:    DB    'no $'
  501. CARMSG:    DB    'carrier present',CR,LF,'$'
  502. ;
  503. ;.....
  504. ;
  505. PULSE:  LDA    UCTLB
  506.     ORI    MCBON
  507.     CALL    OTCTL
  508.     CALL    BDELAY
  509. ;
  510. PCNCT:  LDA    UCTLB
  511.     ANI    MCBOFF
  512.     CALL    OTCTL
  513.     RET
  514. ;
  515. ;.....
  516. ;è; check the COMM-PAC for carrier-present (NZ=no)
  517. ;
  518. CARRCK:    CALL    INCTL1        ;get status byte
  519.     PUSH    PSW
  520.     ANI    DCDMSK
  521.     CNZ    INPORT
  522.     POP    PSW
  523.     RET
  524. ;
  525. ; Newline on console
  526. ;
  527. CRLF:    MVI    A,CR
  528.     CALL    TYPE
  529.     MVI    A,LF        ;fall into TYPE
  530. ;
  531. ; type char in A on console
  532. ;
  533. TYPE:    PUSH    H        ;save 'em
  534.     PUSH    D
  535.     PUSH    B
  536.     MOV    E,A        ;align output character
  537.     MVI    C,CONOUT    ;print via MEX
  538.     CALL    MEX
  539.     POP    B
  540.     POP    D
  541.     POP    H
  542.     RET
  543. ;
  544. ; strings to clear-to-end-of-screen, and clear-screen
  545. ;
  546. EOSMSG:    DB    CR,LF,'$'    ;clear to end-of-screen
  547. CLSMSG:    DB    1AH,CR,LF,'$'    ;clear whole screen
  548. ;
  549. ; Data area
  550. ;
  551. ERRFLG:    DB    0        ;connection error code
  552. UCTLB:    DB    ORIGMD        ;uart-control byte image
  553. BAUDSV:    DB    ORIGMD        ;current baud rate (dflt 300)
  554. MODCTB:    DB    07FH        ;modem control byte
  555. INTERD:    DB    10        ;inter-digit delay in 100's of ms
  556. ;
  557. ;------------------------------------------------------------
  558. ;
  559. ; The remainder of this overlay implements a very versatile
  560. ; SET command -- if you prefer not to write a SET for your
  561. ; modem, you may delete the code from here to the END statement.
  562. ;
  563. ;
  564. ; Control is passed here after MEX parses a SET command.
  565. ;
  566. SETCMD:    MVI    C,SBLANK    ;any arguments?
  567.     CALL    MEX
  568.     JC    SETSHO        ;if not, go print out values
  569.     LXI    D,CMDTBL    ;parse commandè    CALL    TSRCH        ;from table
  570.     PUSH    H        ;any address on stack
  571.     RNC            ;if we have one, execute it
  572.     POP    H        ;nope, fix stack
  573. SETERR:    LXI    D,SETEMS    ;print error
  574.     MVI    C,PRINT
  575.     CALL    MEX
  576.     RET
  577. ;
  578. SETEMS:    DB    CR,LF,'SET command error',CR,LF,'$'
  579. ;......
  580. ;
  581. ; SET command table 
  582. ;
  583. CMDTBL:    DB    '?'+80H            ;"set ?"
  584.     DW    STHELP
  585.     DB    'BAU','D'+80H        ;"set baud"
  586.     DW    STBAUD
  587.     DB    'ID','G'+80H        ;"set id"
  588.     DW    SETIDG
  589.     DB    'OFFHOO','K'+80H    ;"set offhook"
  590.     DW    OFF
  591. ;
  592.     DB    0        ;<<=== table terminator
  593. ;
  594. ; SET <no-args>: print current statistics
  595. ;
  596. SETSHO:    CALL    CARRSH        ;show carrier present/not present
  597.     LXI    H,SHOTBL    ;get table of SHOW subroutines
  598. SETSLP:    MOV    E,M        ;get table address
  599.     INX    H
  600.     MOV    D,M
  601.     INX    H
  602.     MOV    A,D        ;end of table?
  603.     ORA    E
  604.     RZ            ;exit if so
  605.     PUSH    H        ;save table pointer
  606.     XCHG            ;adrs to HL
  607.     CALL    GOHL        ;do it
  608.     CALL    CRLF        ;print newline
  609.     MVI    C,CHEKCC    ;check for console abort
  610.     CALL    MEX
  611.     POP    H        ;it's done
  612.     JNZ    SETSLP        ;continue if no abort
  613.     RET
  614. ;
  615. GOHL:    PCHL
  616. ;
  617. ; table of SHOW subroutines
  618. ;
  619. SHOTBL:    DW    BDSHOW
  620.     DW    SHOIDG
  621.     DW    0        ;<<== table terminator
  622. ;è; SET ?  processor
  623. ;
  624. STHELP:    LXI    D,HLPMSG
  625.     MVI    C,PRINT
  626.     CALL    MEX
  627.     RET
  628. ;
  629. ; The help message
  630. ;
  631. HLPMSG:    DB    CR,LF,'SET command, COMM-PAC version:',CR,LF,LF
  632.     DB    CR,LF,'SET BAUD 300 <or> 1200'
  633.     DB    CR,LF,'SET OFFHOOK       ... go offhook'
  634.     DB    CR,LF,'SET IDG <value>     ... interdig. delay in 100''s msec'
  635.     DB    CR,LF,'$'
  636. ;
  637. ; SET BAUD processor
  638. ;
  639. STBAUD:    MVI    C,BDPARS    ;function code
  640.     CALL    MEX        ;let MEX look up code
  641.     JC    SETERR        ;invalid code
  642.     CALL    PBAUD        ;no, try to set it
  643.     JC    SETERR        ;not-supported code
  644. BDSHOW:    CALL    ILPRT        ;display baud
  645.     DB    'Baud rate:',TAB,' ',0
  646.     LDA    MSPEED
  647.     MVI    C,PRBAUD    ;use MEX routine
  648.     CALL    MEX
  649.     RET
  650. ;.......
  651. ;
  652. ; SET IDIG command processor
  653. ;
  654. SETIDG:    MVI    C,EVALA
  655.     CALL    MEX        ;get numeric
  656.     MOV    A,H        ;validate
  657.     ORA    A
  658.     JNZ    SETERR
  659.     MOV    A,L
  660.     STA    INTERD        ;set new rate
  661. SHOIDG:    CALL    ILPRT
  662.     DB    'Inter-digit time:',0
  663.     LDA    INTERD        ;get value
  664.     MOV    L,A        ;move delay to HL
  665.     MVI    H,0
  666.     MVI    C,DECOUT    ;print it
  667.     CALL    MEX
  668.     CALL    ILPRT
  669.     DB    '00 ms',0
  670.     RET
  671. ;
  672. ; Compare next input-stream item in table @DE; CY=1
  673. ; if not found, else HL=matched data item
  674. ;
  675. TSRCH:    MVI    C,LOOKUP    ;get function code
  676.     JMP    MEX        ;pass to MEX processorè;
  677. ; Print in-line message ... blows away C register
  678. ;
  679. ILPRT:    MVI    C,ILP        ;get function code
  680.     JMP    MEX        ;go do it
  681. ;
  682. ;------------------------------------------------------------
  683. ;
  684. ; End of MEX COMM-PAC modem overlay
  685. ;
  686. ;------------------------------------------------------------
  687. ;
  688.     END
  689.