home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / mxo13px8.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  34.0 KB  |  1,341 lines

  1. ; MXO13PX8  MEX overlay for Epson PX-8                Oct 18. 1985
  2. ;
  3. ; (delete the ";" in the above title line if assembling with MAC)
  4. ;
  5. ;
  6. REV    EQU    12        ; Overlay revision level
  7. ;
  8. ; MEX overlay for Epson PX-8 with MFU, Direct Connect modem, or external
  9. ; modem.  Support is provided for an external dialing overlay such as
  10. ; MXO-SM13.ASM. For details see MXO-PX8.DOC.
  11. ;
  12. ; Written 3/10/85 by David B. Kozinn
  13. ;
  14. ;    Copyright (C) 1985 by David B. Kozinn
  15. ;
  16. ; This program (in source or object code form) may be copied and distri-
  17. ; buted for non-commercial purposes.  Sale of this program is forbidden
  18. ; without written consent of the author.
  19. ;
  20. ; The author can be contacted on CompuServe [76703,565] via Easyplex, or
  21. ; (preferably) in CP-MIG (PCS-47) or EpsOnline (PCS-19).
  22. ;
  23. ;     PLEASE READ THE FOLLOWING IF YOU INTEND TO MODIFY THIS OVERLAY:
  24. ;     ---------------------------------------------------------------
  25. ; Much of the commentary has been removed in order to save space.  For
  26. ; complete documentation of how an overlay is structured, see the origi-
  27. ; nal overlay, MXO-PM.ASM, written by Ron Fowler.  Please be sure to
  28. ; read the comments in that overlay if you intend to change this one.
  29. ;
  30. ;    Version Date    Changes
  31. ;    ------- ------- -------
  32. ;      1.2    870502    Fixed another bug in the SET COMM command that
  33. ;            kept the uart from being properly set when using
  34. ;            the internal modem.  Also added pulse dial capa-
  35. ;            bility.  Removed all references to the letters
  36. ;            A-D in the tone dialing area to make room.
  37. ;                    - Bob Kitchen
  38. ;
  39. ;      1.1    870301    Fixed bugs in the SET COMM command so that the
  40. ;            correct values for "even" parity and "2" stop
  41. ;            bits were sent to the RS-232 device.  Also fixed
  42. ;            the problem with the screen not keeping up when
  43. ;            running at 1200 baud.
  44. ;                    - Bob Kitchen
  45. ;
  46. ;      1.0    850310    First general release version
  47. ;
  48. ;-----------------------------------------------------------------------
  49. ;
  50. ; Misc equates
  51. ;
  52. NO    EQU    0
  53. YES    EQU    0FFH
  54. ;
  55. ;
  56. TPA    EQU    100H
  57. CR    EQU    13
  58. LF    EQU    10
  59. TAB    EQU    9
  60. BELL    EQU    7
  61. ESC    EQU    01BH
  62. CUROFF    EQU    032H
  63. CURON    EQU    033H
  64. XON    EQU    011H
  65. XOFF    EQU    013H
  66. ;
  67. ; PX-8 port definitions
  68. ;
  69. MCTLR2    EQU    002H        ; Misc control signals (output)
  70. CCR    EQU    00DH        ; 8251 command port
  71. DCRREG    EQU    084H        ; Modem tone dialer control port (output)
  72. OCR    EQU    085H        ; Modem control register (output)
  73. STR    EQU    086H        ; Modem status register (input)
  74. OMR    EQU    087H        ; Modem port setup (output)
  75. ;
  76. ; PX-8 Special locations (see code for use)
  77. ;
  78. WBLOC    EQU    0EC03H        ; BIOS call Warm Boot location
  79. WRSDAT    EQU    0F6A9H        ; Working RS-232 data
  80. CTLR1    EQU    0F0B0H        ; CTLR1 register value
  81. CTLR2    EQU    0F0B2H        ; CTLR2 register value
  82. RSMODE    EQU    0F6D0H        ; 8251 Mode byte location
  83. RSCMD    EQU    0F6D1H        ; 8251 Command byte location
  84. RSOPN    EQU    0F2C8H        ; RS-232 open flag (00=Open)
  85. SLVFLG    EQU    0F358H        ; Slave cpu (6301) flag
  86. INTBUF    EQU    0FB90H        ; Internal rs232 buffer
  87. INTBUFL    EQU    0160H        ; Internal buffer length
  88. ;
  89. ; Bit definitions
  90. ;
  91. MDMINIT    EQU    089H        ; 8251 initialization string
  92. BRKBIT    EQU    008H        ; 8251 bit to turn break on
  93. MDRCVB    EQU    001H        ; Modem receive bits
  94. MDRCVR    EQU    001H        ; Modem recieve ready
  95. MDSNDB    EQU    002H        ; Modem send bits
  96. MDSNDR    EQU    002H        ; Modem recieve ready
  97. USEINT    EQU    020H        ; Set to 0, send this to CTLR2 to use int.
  98. DCD    EQU    008H        ; Use with RSIOX CTLIN
  99. ;
  100. ; Bit definitions for OCR
  101. ;
  102. OHC    EQU    001H        ; Off hook
  103. HSC    EQU    002H        ; Handset control
  104. MON    EQU    004H        ; Enable speaker
  105. TXC    EQU    008H        ; Transmit carrier
  106. ANS    EQU    010H        ; Answer mode
  107. TEST    EQU    020H        ; Test function
  108. PWR    EQU    040H        ; Modem Power
  109. CCT    EQU    080H        ; Connect to phone lne
  110. ;
  111. ; Bit definitions for STR
  112. ;
  113. BDS    EQU    001H        ; Bell Detect Signal. 0 if ringing
  114. CTSMSK    EQU    004H        ; Clear to send. (carrier det) =0 if clear
  115. MII    EQU    080H        ; Modem Installation Indicator 0=installed
  116. ;
  117. ; Special BIOS call locations
  118. ;
  119. CONIN    EQU    WBLOC+006H    ; Direct console input
  120. CONOUT    EQU    WBLOC+009H    ; Direct console output
  121. RSOPEN    EQU    WBLOC+039H    ; Open RS-232 port
  122. RSCLOSE    EQU    WBLOC+03CH    ; Close RS-232    port
  123. RSINST    EQU    WBLOC+03FH    ; Check for input
  124. RSOUTST    EQU    WBLOC+042H    ; Check for output
  125. RSIN    EQU    WBLOC+045H    ; Get a character
  126. RSOUT    EQU    WBLOC+048H    ; Send a character
  127. RSIOX    EQU    WBLOC+051H    ; Special RS-232 calls
  128. SLAVE    EQU    WBLOC+072H    ; Use slave CPU
  129. ;
  130. ; Equates for use with RSIOX
  131. ;
  132. OPNIOX    EQU    010H        ; Open using RSIOX
  133. CLSIOX    EQU    020H        ; Close using RSIOX
  134. INSTS    EQU    030H        ; Check for data in recieve buffer
  135. CTLIN    EQU    070H        ; Check carrier & DSR
  136. ;
  137. ; MEX locations
  138. ;
  139. QUEUE    EQU    00D51H        ; Queued I/O variable
  140. MODE    EQU    00D54H        ; Terminal mode byte (01 = in terminal mode)
  141. SMART    EQU    00B00H        ; Entry point for smart modem overlay
  142. ;
  143. ; Other equates
  144. ;
  145. WTCTS    EQU    125        ; How long to wait for carrier. 125=25 seconds
  146. ;
  147. ; MEX service processor stuff
  148. ;
  149. MEX    EQU    0D00H        ; Address of the service processor
  150. INMDM    EQU    255        ; Get char from port to A, CY=no more in 100 ms
  151. TIMER    EQU    254        ; Delay 100ms * reg B
  152. TMDINP    EQU    253        ; B=# secs to wait for char, cy=no char
  153. CHEKCC    EQU    252        ; Check for ^C from KBD, Z=present
  154. SNDRDY    EQU    251        ; Test for modem-send ready
  155. RCVRDY    EQU    250        ; Test for modem-receive ready
  156. SNDCHR    EQU    249        ; Send a character to the modem (after sndrdy)
  157. RCVCHR    EQU    248        ; Recv a char from modem (after rcvrdy)
  158. LOOKUP    EQU    247        ; Table search: see CMDTBL comments for info
  159. PARSFN    EQU    246        ; Parse filename from input stream
  160. BDPARS    EQU    245        ; Parse baud-rate from input stream
  161. SBLANK    EQU    244        ; Scan input stream to next non-blank
  162. EVALA    EQU    243        ; Evaluate numeric from input stream
  163. LKAHED    EQU    242        ; Get nxt char w/o removing from input
  164. GNC    EQU    241        ; Get char from input, cy=1 if none
  165. ILP    EQU    240        ; Inline print
  166. DECOUT    EQU    239        ; Decimal output
  167. PRBAUD    EQU    238        ; Print baud rate
  168. ;
  169. NOSMART    EQU    NO        ; Yes=no Smartmodem dialing overlay
  170. ;
  171. PRINT    EQU    9        ; Simulated BDOS function 9: print string
  172. INBUF    EQU    10        ; Input buffer, same structure as BDOS 10
  173. ;
  174.      IF    NOSMART
  175.     ORG    SMART        ; Put code in in case he calls Smartmodem
  176.     CPI    255        ;   without installing the overlay first
  177.     RNZ            ; Only do it once, at the end
  178.     CALL    ILPRT
  179.     DB    '** You have not installed a dialing overlay **'
  180.     DB    BELL,CR,LF,0
  181.     XRA    A        ; Set zero flag
  182.     MVI    A,3        ; Tell him dialing has been aborted
  183.     RET
  184.      ENDIF
  185. ;
  186. ;
  187.     ORG    TPA        ; We begin
  188. ;
  189. ;
  190.     DS    3        ; MEX has a JMP START here
  191. ;
  192. ; The following variables are located at the beginning of the program to
  193. ; facilitate modification without the need of re-assembly.
  194. ;
  195. PMODEM:    DB    NO        ; Yes=PMMI modem \ / These 2 locations are not
  196. SMODEM:    DB    NO        ; Yes=Smartmodem / \ referenced by MEX
  197. TPULSE:    DB    'T'        ; T=tone, P=pulse (tone or pulse dial flag)
  198. CLOCK:    DB    28        ; Clock speed x .1, up to 25.5 mhz.
  199. MSPEED:    DB    1        ; Sets display time for sending a file
  200.                 ; 0=110  1=300    2=450  3=600  4=710
  201.                 ; 5=1200 6=2400 7=4800 8=9600 9=19200
  202. BYTDLY:    DB    1        ; Default time to send character in
  203.                 ; Terminal mode file transfer (0-9)
  204.                 ; 0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  205. CRDLY:    DB    1        ; End-of-line delay after CRLF in terminal
  206.                 ; Mode file transfer for slow BBS systems
  207.                 ; 0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  208. COLUMS:    DB    5        ; Number of directory columns
  209. SETFL:    DB    YES        ; Yes=user-defined SET command
  210. SCRTST:    DB    YES        ; Yes=if home cursor and clear screen
  211.                 ; Routine at CLRSCRN
  212.     DB    0        ; Was once ACKNAK, now spare
  213. BAKFLG:    DB    YES        ; Yes=make .BAK file
  214. CRCDFL:    DB    YES        ; Yes=default to CRC checking
  215.                 ; No=default to Checksum checking
  216. TOGCRC:    DB    YES        ; Yes=allow toggling of Checksum to CRC
  217. CVTBS:    DB    NO        ; Yes=convert backspace to rub
  218. TOGLBK:    DB    YES        ; Yes=allow toggling of bksp to rub
  219. ADDLF:    DB    NO        ; No=no LF after CR to send file in
  220.                 ; Terminal mode (added by remote echo)
  221. TOGLF:    DB    YES        ; Yes=allow toggling of LF after CR
  222. TRNLOG:    DB    NO        ; Yes=allow transmission of logon
  223.                 ; Write logon sequence at location LOGON
  224. SAVCCP:    DB    YES        ; Yes=do not overwrite CCP
  225. LOCNXT:    DB    NO        ; Yes=local cmd if EXTCHR precedes
  226.                 ; No=not local cmd if EXTCHR precedes
  227. TOGLOC:    DB    YES        ; Yes=allow toggling of LOCNXTCHR
  228. LSTTST:    DB    YES        ; Yes=allow toggling of printer on/off
  229.                 ; In terminal mode. Set to no if using
  230.                 ; The printer port for the modem
  231. XOFTST:    DB    YES        ; Yes=allow testing of XOFF from remote
  232.                 ; While sending a file in terminal mode
  233. XONWT:    DB    NO        ; Yes=wait for XON after sending CR while
  234.                 ; Transmitting a file in terminal mode
  235. TOGXOF:    DB    YES        ; Yes=allow toggling of XOFF testing
  236. IGNCTL:    DB    NO        ; Yes=do not send control characters
  237.                 ; Above CTL-M to CRT in terminal mode
  238.                 ; No=send any incoming CTL-char to CRT
  239. EXTRA1:    DB    0        ; For future expansion
  240. EXTRA2:    DB    0        ; For future expansion
  241. BRKCHR:    DB    '@'-40H        ; ^@ = Send a 300 ms. break tone
  242. NOCONN:    DB    'N'-40H        ; ^N = Disconnect from phone line
  243. LOGCHR:    DB    'L'-40H        ; ^L = Send logon
  244. LSTCHR:    DB    'P'-40H        ; ^P = Toggle printer
  245. UNSVCH:    DB    'R'-40H        ; ^R = Close input text buffer
  246. TRNCHR:    DB    'T'-40H        ; ^T = Transmit file to remote
  247. SAVCHR:    DB    'Y'-40H        ; ^Y = Open input text buffer
  248. EXTCHR:    DB    '^'-40H        ; ^^ = Send next character
  249. ;
  250. ; The next two are for PMMI, we don't use them, but they have to hang
  251. ; around anyway.
  252. ;
  253.     DB    250
  254.     DB    0
  255. ;
  256. ; Low-level modem I/O routines
  257. ;
  258. INCTL1:    JMP    MODSTAT        ; In modem control port
  259.     DB    0,0,0,0,0,0,0    ; Spares
  260. ;
  261. OTDATA:    JMP    MODOUT        ; Out modem data port
  262.     DB    0,0,0,0,0,0,0    ; Spares
  263. ;
  264. INPORT:    JMP    MODIN        ; In modem data port
  265.     DB    0,0,0,0,0,0,0    ; Spares
  266. ;
  267. ; Bit-test routines
  268. ;
  269. MASKR:    ANI    MDRCVB ! RET    ; Bit to test for receive ready
  270. TESTR:    CPI    MDRCVR ! RET    ; Value of receive bit when ready
  271. MASKS:    ANI    MDSNDB ! RET    ; Bit to test for send ready
  272. TESTS:    CPI    MDSNDR ! RET    ; Value of send bit when ready
  273. ;
  274. ;
  275. ; Unused area: was once used for special PMMI functions, now used only
  276. ; to retain compatibility with MDM overlays.  You may use this area for
  277. ; any miscellaneous storage you'd like but the length of the area *must*
  278. ; be 12 bytes.
  279. ;
  280.     DS    12
  281. ;
  282. ; Special modem function table
  283. ;
  284. LOGON:    DS    2        ; Needed for MDM compat, not ref'd by MEX
  285. DIALV:    JMP    PDIAL        ; Dial digit in A (see info at PDIAL)
  286. DISCV:    JMP    PDISC        ; Disconnect the modem
  287. GOODBV:    DS    3        ; Called before exit to CP/M
  288. INMODV:    JMP    NITMOD        ; Initialization. Called at cold-start
  289. NEWBDV:    JMP    PBAUD        ; Set baud rate
  290. NOPARV:    DS    3        ; Set modem for no-parity
  291. PARITV:    DS    3        ; Set modem parity
  292. SETUPV:    JMP    SETCMD        ; SET cmd: jump to a RET if you don't write SET
  293. SPMENV:    DS    3        ; Not used with MEX
  294. VERSNV:    JMP    SYSVER        ; Overlay's voice in the sign-on message
  295. BREAKV:    JMP    PBREAK        ; Send a break
  296. ;
  297. ; Entry points here are for compatibility with MDM7
  298. ;
  299. ILPRTV:    DS    3        ; Replace with MEX function 9
  300. INBUFV:    DS    3        ; Replace with MEX function 10
  301. ILCMPV:    DS    3        ; Replace with table lookup funct. 247
  302. INMDMV:    DS    3        ; Replace with MEX function 255
  303. NXSCRV:    DS    3        ; Not supported by MEX (returns w/no action)
  304. TIMERV:    DS    3        ; Replace with MEX function 254
  305. ;
  306. ; Clear/screen and clear/end-of-screen.  Each routine must use the full
  307. ; 9 bytes alloted (may be padded with nulls).
  308. ;
  309. CLREOS:    LXI    D,EOSMSG
  310.     MVI    C,PRINT
  311.     CALL    MEX
  312.     RET
  313. ;
  314. CLS:    LXI    D,CLSMSG    ; Null unless patched
  315.     MVI    C,PRINT
  316.     CALL    MEX
  317.     RET
  318. ;
  319.     XRA    A        ; Don't allow queued I/O (it interferes
  320.                 ; With the stuff we're doing)
  321.     STA    QUEUE        ; Set to Queued I/O flag location
  322. ;
  323. ;-----------------------------------------------------------------------
  324. ;
  325. ;        *** END OF FIXED FORMAT AREA ***
  326. ;
  327. ;-----------------------------------------------------------------------
  328. ;
  329. ; Modem initialization.  First make sure that the dialing overlay ad-
  330. ; dress is correct (some overlays ORG the dial vector and stick a JMP
  331. ; B00 there.)  We have to make sure that we get control first.    Also,
  332. ; store away the current value in the DISCV address, because it might be
  333. ; the address of the dialing overlay disconnect vector.  We'll use this
  334. ; to disconnect along with the regular disconnect code if an external
  335. ; modem is being used.    Then, set up the default communications parame-
  336. ; ters.  Then, if the port is already open, just return, else set up to
  337. ; use the built-in modem.
  338. ;
  339. NITMOD:    LXI    H,PDIAL        ; Get address of our dialing routine
  340.     SHLD    DIALV+1        ; Store it as the address to jump to
  341.     LHLD    DISCV+1        ; Get address of disconnect vector
  342.     SHLD    SMDISCV+1    ; Save it in case it's needed
  343.     LXI    B,PDISC        ; Get our disconnect routine address
  344.     XRA    A        ; Clear carry flag
  345.     DB    0EDH,042H    ; SBC HL,BC If zero, then the same
  346.     JZ    NIT0        ; Don't do anything special
  347.     DCR    A        ; Get 0FFH to store
  348.     STA    GOTDISC        ; Indicate that we've got external disc
  349.     LXI    H,PDISC        ; Get the address of our disconnect routine
  350.     SHLD    DISCV+1        ; Store it in the proper place
  351. ;
  352. NIT0:    LXI    H,WRSDAT    ; Get working rs232 data
  353.     LXI    D,BAUDRATE
  354.     LXI    B,4
  355.     DB    0EDH,0B0H    ; LDIR
  356.     LDA    BAUDRATE    ; Find out what baud we're set to
  357.     LXI    H,BAUDTBL
  358.     MVI    B,0
  359. ;
  360. NIT1:    CMP    M        ; Do we match this table entry?
  361.     JZ    NIT2        ; Yes
  362.     INX    H
  363.     INR    B
  364.     JMP    NIT1
  365. ;
  366. NIT2:    MOV    A,B        ; Store the table entry locally
  367.     STA    MDMSPD
  368.     CALL    SMSPEED        ; Set modem speed for time for xfer
  369.     LDA    RSOPN        ; See if the port is already open
  370.     ORA    A
  371.     RZ            ; Don't do anything if so
  372.     CALL    RSOPEN        ; Turn the port on
  373.     CALL    PWRON        ; Try to turn the modem on
  374.     IN    STR        ; Read status register
  375.     ANI    MII        ; Is modem installed?
  376.     JNZ    OPENIT        ; No, open the RS-232 port normally
  377.     CALL    STPORT        ; Set up to use the direct connect
  378.     LDA    OCRVAL        ; Turn off modem power to conserve
  379.     ANI    (NOT PWR) AND 0FFH
  380.     STA    OCRVAL
  381.     OUT    OCR
  382.     MVI    A,0FFH        ; Indicate we're using the internal modem
  383.     STA    MDMTYPE
  384.     RET
  385. ;
  386. OPENIT:    CALL    RSCLOSE        ; Close the port to clean things up
  387.     CALL    RSOPEN        ; Open it up for the regular port
  388.     RET
  389. ;
  390. ; Send-break routine
  391. ;
  392. PBREAK:    LDA    RSCMD        ; Get the current command for the 8251
  393.     ORI    BRKBIT        ; Turn break on
  394.     OUT    CCR        ; Send it to the 8251
  395.     MVI    B,3        ; Wait 300 ms
  396.     MVI    C,TIMER
  397.     CALL    MEX
  398.     LDA    RSCMD        ; Restore the 8251 to normal
  399.     OUT    CCR
  400.     RET
  401. ;
  402. ; Disconnect the modem
  403. ;
  404. PDISC:    LDA    MDMTYPE        ; See if we're using an external modem
  405.     ORA    A        ; This will be zero if so
  406.     JNZ    PDISC0        ; If not, don't worry about it
  407.     LDA    GOTDISC        ; See if we had an external routine
  408.     ORA    A        ; This will be non-zero if so
  409.     JNZ    SMDISCV        ; Call it if it's there
  410. ;
  411. PDISC0:    CALL    RSCLOSE
  412.     LDA    OCRVAL        ; Get current modem control values
  413.     ANI    0FFH-(CCT+TXC+OHC) ; On-hook, carrier off,disconnect
  414.     OUT    OCR        ; Send it
  415.     ANI    (NOT PWR) AND 0FFH ; Now turn power off too
  416.     OUT    OCR
  417.     STA    OCRVAL        ; Save this as current mod. ctl. value
  418.     CALL    RESPORT        ; Reset to use internal
  419.     CALL    SPKROFF        ; Turn the speaker off
  420.     CALL    RSOPEN
  421.     RET
  422. ;
  423. ; External dialing routine disconnect code is called through here.
  424. ;
  425. SMDISCV:JMP    PDISC        ; <-----This may be modified
  426. ;
  427. ;-----------------------------------------------------------------------
  428. ;
  429. ;            DIALING ROUTINES
  430. ;
  431. ; The DIGITS table is a translation for digit to register value for all
  432. ; of the supported tone digits.  The modem also understands that a com-
  433. ; ma (,) means to wait for n seconds before continuing (for compatabil-
  434. ; ity with various intelligent modems).  Any other values (such as -,
  435. ; (, or ) ) are ignored.  For pulse dialing, only the digits 0-9 are
  436. ; used, all else, except a comma, is ignored.
  437. ;
  438. DIGITS:    DB    1DH,10H,11H,12H    ; 0, 1, 2, 3
  439.     DB    14H,15H,16H,18H    ; 4, 5, 6, 7
  440.     DB    19H,1AH        ; 8, 9
  441. ;
  442. SPLAT:    DB    1CH        ; *
  443. ;
  444. CRUNCH:    DB    1EH        ; #
  445. ;
  446. PDIAL:    MOV    B,A        ; Save the digit
  447.     LDA    MDMTYPE        ; See if we're using an external modem
  448.     ORA    A
  449.     MOV    A,B        ; Restore the digit
  450.     JZ    SMART        ; If so, jump to the Hayes routines
  451.     CPI    254        ; Start-dial?
  452.     JZ    STDIAL
  453.     CPI    255        ; End-dial
  454.     JZ    ENDIAL
  455.     CPI    ','        ; Smartmodem pause command
  456.     JNZ    CKDIG        ; If not pause, continue
  457.     LDA    COMDLY        ; Delay n seconds
  458.     MOV    B,A
  459.     ADD    A        ; X 2
  460.     ADD    A        ; X 4
  461.     ADD    A        ; X 8
  462.     ADD    B        ; X 9
  463.     ADD    B        ; X 10
  464.     MOV    B,A
  465.     MVI    C,TIMER
  466.     CALL    MEX
  467.     RET
  468. ;
  469. CKDIG:    CPI    '9'+1        ; Digits are 0-9
  470.     RNC            ; Too big...return
  471.     SUI    '0'
  472.     JC    CKSPEC        ; Too small....check if it's * or #
  473.     PUSH    A
  474.     LDA    TPULSE        ; Check to see if tone or pulse
  475.     CPI    'P'
  476.     JZ    PUDIAL        ; Go to pulse dial routines
  477.     POP    A
  478.     LXI    H,DIGITS    ; Get start of digits table
  479.     JMP    DIALIT
  480. ;
  481. CKSPEC:    LXI    H,SPLAT        ; Check for specials
  482.     CPI    ('*'-'0') AND 0FFH ; Is it *?
  483.     JZ    DIALIT1        ; Yup, go dial
  484.     INX    H        ; Point to CRUNCH
  485.     CPI    ('#'-'0') AND 0FFH ; Is it #?
  486.     RNZ            ; No, forget it
  487.     JMP    DIALIT1        ; Yup, go dial
  488. ;
  489. ; First get the value to send to the tone control register.  At DIALIT,
  490. ; HL contains the proper table, and A contains the offset into that table.
  491. ;
  492. DIALIT:    MVI    B,0
  493.     MOV    C,A        ; Get offset into BC
  494.     DAD    B        ; Get real byte location into HL
  495. ;
  496. DIALIT1:LDA    TPULSE        ; Check for tone or pulse
  497.     CPI    'P'
  498.     RZ            ; Return if pulse
  499.     MOV    A,M        ; Get value to dial into A
  500.     OUT    DCRREG        ; Start sending the tone
  501.     MVI    B,1        ; Send it for 100ms (which is kinda long
  502.     MVI    C,TIMER        ; But it's easier than coding my own timing
  503.     CALL    MEX        ; Routine.)
  504.     XRA    A
  505.     OUT    DCRREG        ; Turn tone off
  506.     MVI    B,1        ; Wait for 100ms for the inter-digit delay
  507.     MVI    C,TIMER
  508.     CALL    MEX
  509.     RET
  510. ;
  511. ; Pulse dialing routines (one pulse is 60ms onhook followed by 40ms off-
  512. ; hook).
  513. ;
  514. PUDIAL:    POP    A
  515.     CPI    0
  516.     JNZ    PUDIAL1        ; Jump if not equal to zero
  517.     MVI    A,0AH        ; 0 is 10 for pulse dialing
  518. ;
  519. PUDIAL1:CALL    ST60        ; Onhook for 60ms
  520.     CALL    ST40        ; Offhook for 40ms
  521.     DCR    A
  522.     CPI    0
  523.     JNZ    PUDIAL1        ; Repeat per value of each digit
  524.     MVI    B,7        ; 700ms between digits
  525.     MVI    C,TIMER
  526.     CALL    MEX
  527.     RET
  528. ;
  529. STDEL:    DCX    B        ; Time delay subroutine for
  530.     MOV    A,B        ; Producing the correct pulse
  531.     ORA    C        ; Lengths
  532.     JNZ    STDEL
  533.     RET
  534. ;
  535. ST60:    PUSH    A
  536.     LDA    OCRVAL        ; Connect to phone, offhook, speaker on
  537.     ANI    (NOT OHC) AND 0FFH ; Onhook
  538.     OUT    OCR
  539.     LXI    B,6000        ; 60ms onhook
  540.     CALL    STDEL
  541.     POP    A
  542.     RET
  543. ;
  544. ST40:    PUSH    A
  545.     LDA    OCRVAL        ; Connect to phone, offhook, speaker on
  546.     OUT    OCR
  547.     LXI    B,4000        ; 40ms offhook
  548.     CALL    STDEL
  549.     POP    A
  550.     RET
  551. ;
  552. ; Start-dial sequence:    Go thru normal init sequence, assuming that the
  553. ; guy is not trying to dial while connected.  (This should disconnect
  554. ; him anyway).
  555. ;
  556. STDIAL:    CALL    PDISC        ; Disconnect
  557.     LDA    OCRVAL        ; Turn on monitor soon
  558.     ORI    MON
  559.     STA    OCRVAL
  560.     CALL    RESPORT        ; I don't know why, but I gotta do this
  561.     CALL    PWRON        ; Init modem and ports
  562.     CALL    SPKRON        ; Turn power to speaker on
  563.     LDA    OCRVAL        ; Get current value for OCR
  564.     ANI    (NOT ANS) AND 0FFH ; Set originate mode
  565.     STA    OCRVAL
  566.     OUT    OCR
  567. OFFHK:    LDA    OCRVAL        ; Have to reload 'cause we're called directly
  568.     ORI    CCT        ; Connect to phone
  569.     OUT    OCR
  570.     ORI    OHC        ; Go off hook
  571.     OUT    OCR
  572.     STA    OCRVAL
  573.     MVI    B,20        ; Wait 2 seconds for dial tone
  574.     MVI    C,TIMER
  575.     CALL    MEX
  576.     RET            ; Dialing init done
  577. ;
  578. ; End-dial sequence: Watch to see if CTS goes on within 50 seconds.   If
  579. ; so, turn on carrier, turn speaker off, and connect to the line.
  580. ;
  581. ENDIAL:    LDA    OCRVAL        ; Turn on carrier
  582.     ORI    TXC
  583.     OUT    OCR
  584.     STA    OCRVAL
  585.     CALL    STPORT
  586.     MVI    E,WTCTS        ; # of ms * 5 to wait
  587. ;
  588. LP1:    MVI    B,2        ; 200 ms.
  589.     MVI    C,TIMER
  590.     CALL    MEX
  591.     IN    STR        ; Check modem status register
  592.     ANI    CTSMSK        ; See if we've got carrier yet
  593.     JZ    GOTCAR        ; If it's zero, then we've got carrier
  594.     MVI    C,CHEKCC    ; Not yet, see if he hit ctl-c
  595.     CALL    MEX
  596.     MVI    A,3        ; Get ready to return code
  597.     JZ    NOCAR        ; Yup, return
  598.     DCR    E        ; Nope, count down
  599.     JNZ    LP1        ; Keep going if more time
  600.     MVI    A,2        ; Set code in A to 2 (no answer)
  601. ;
  602. NOCAR:    PUSH    PSW        ; Save the return code
  603.     CALL    PDISC        ; Hang up
  604.     POP    PSW        ; Get the return code back
  605.     RET
  606. ;
  607. ; GOTCAR - Come here to go on-line, we've got a carrier from remote
  608. ;
  609. GOTCAR:    CALL    SPKROFF        ; Turn the speaker off
  610.     XRA    A        ; Report that we got carrier
  611.     RET
  612. ;
  613. ;          <end of PX-8 dialing routines>
  614. ;-----------------------------------------------------------------------
  615. ;
  616. PBAUD:    RET            ; Use SET COMM for this
  617. ;
  618. ; Sign-on message
  619. ;
  620. SYSVER:    LXI    D,SOMESG
  621.     MVI    C,PRINT
  622.     CALL    MEX
  623.     RET
  624. ;
  625. SOMESG:    DB    'Epson PX-8 overlay V'
  626.     DB    REV/10+'0'
  627.     DB    '.'
  628.     DB    REV MOD    10+'0'
  629.     DB    CR,LF,'$'
  630. ;
  631. ; Input from the status port.  Since the PX-8 has 2 status ports, and
  632. ; we can't tell why we're being call (for input or output), we have to
  633. ; kludge here.    We'll call both in & out status, and fake a 1 byte sta-
  634. ; tus word.  See the MOD??? bytes for the values. Also, we check here
  635. ; to see if carrier has been lost (only if we were using the modem.)  If
  636. ; so, then we'll disconnect from the phone line, reset the port and tell
  637. ; the user.
  638. ;
  639. ;     NOTE:    There is really no need for output status, so
  640. ;        these routines always return "ready to output".
  641. ;        However, the basic code structure to support
  642. ;        both input and output status has been left in
  643. ;        should it ever be necessary.
  644. ;
  645. ; Automatic X-ON/X-OFF flow control is also done from this point.
  646. ;
  647. ;     NOTE:    For the automatic X-ON/X-OFF flow control to
  648. ;        work properly, ASIZE: must be set to 255h at
  649. ;        memory location 0D22h.    If not, use MEXPAT.ASM
  650. ;        to reset the buffers.
  651. ;
  652. MODSTAT:PUSH    B        ; Push all registers (except A)
  653.     PUSH    D
  654.     PUSH    H
  655.     LDA    CTLR2        ; See if we're using an MFU
  656.     ANI    USEINT
  657.     JNZ    MDSTAT1        ; If not, forget about it
  658.     IN    STR        ; Else check modem status register
  659.     ANI    CTSMSK
  660.     JZ    MDSTAT1        ; Everything Ok if it's there
  661.     CALL    PDISC        ; Otherwise hang up
  662.     CALL    ILPRT        ; And say something about it
  663.     DB    CR,LF,'** Carrier Lost **',BELL,CR,LF,0
  664. ;
  665. MDSTAT1:LDA    MODE        ; Get terminal mode
  666.     CPI    1        ; 01 means in terminal mode
  667.     JNZ    MDSTAT4        ; If not, then don't worry about it
  668. ;
  669. MDSTAT2:MVI    B,INSTS        ; Check for characters in input buffer
  670.     LXI    H,WIPEOUT    ; Here's where to put the returned info
  671.     CALL    RSIOX
  672.     JNZ    MDSTAT2        ; Wait until we get good status
  673.     XRA    A        ; Clear carry
  674.     LXI    H,200        ; 3/4 full buffer
  675.     DB    0EDH,042H    ; SBC HL,BC
  676.     JNC    MDSTAT3        ; Continue if < 200 chars in buffer
  677.     LDA    PENDXOFF    ; Is there an XOFF outstanding already?
  678.     ORA    A        ; It'll be 0 if not
  679.     JNZ    MDSTAT4        ; If so, then just go ahead
  680.     MVI    C,XOFF        ; Send out an XOFF
  681.     CALL    RSOUT
  682.     XRA    A
  683.     DCR    A
  684.     STA    PENDXOFF    ; Indicate a pending XOFF
  685.     JMP    MDSTAT4        ; Continue
  686. ;
  687. MDSTAT3:MVI    B,INSTS        ; Check input again, this time we're
  688.     LXI    H,WIPEOUT    ; Seeing if it's time to send an XON
  689.     CALL    RSIOX
  690.     JNZ    MDSTAT3
  691.     XRA    A
  692.     LXI    H,50
  693.     DB    0EDH,042H    ; SBC HL,BC
  694.     JC    MDSTAT4        ; Don't send XON until < 50 chars in buffer
  695.     LDA    PENDXOFF    ; Ok, we've got < 50, did we send an XOFF?
  696.     ORA    A
  697.     JZ    MDSTAT4        ; No, so don't do anything
  698.     MVI    C,XON
  699.     CALL    RSOUT        ; Send the XON
  700.     XRA    A
  701.     STA    PENDXOFF
  702. ;
  703. MDSTAT4:CALL    RSINST        ; Now get status
  704.     ANI    MDRCVB        ; Mask off what we don't care about
  705.     ORI    MDSNDB        ; Always say that output is ready
  706. ;
  707. POPEM:    POP    H
  708.     POP    D
  709.     POP    B
  710.     RET
  711. ;
  712. ; Get a character
  713. ;
  714. MODIN:    PUSH    B
  715.     PUSH    D
  716.     PUSH    H
  717.     MVI    B,INSTS
  718.     LXI    H,STATBLK
  719.     CALL    RSIOX        ; Make sure there is really data so we
  720.     ORA    A        ; Don't ever hang waiting
  721.     JZ    MODIN1
  722.     CALL    RSIN
  723. ;
  724. MODIN1:    POP    H
  725.     POP    D
  726.     POP    B
  727.     RET
  728. ;
  729. ; Send a character
  730. ;
  731. MODOUT:    PUSH    B
  732.     PUSH    D
  733.     PUSH    H
  734.     MOV    C,A
  735.     CALL    RSOUT
  736.     POP    H
  737.     POP    D
  738.     POP    B
  739.     RET
  740. ;
  741. ; Type character in A on console
  742. ;
  743. TYPE:    PUSH    H        ; Save 'em
  744.     PUSH    D
  745.     PUSH    B
  746.     MOV    C,A        ; Align output character
  747.     CALL    CONOUT
  748.     POP    B
  749.     POP    D
  750.     POP    H
  751.     RET
  752. ;
  753. ; SETPORT - set up to use internal modem
  754. ;
  755. STPORT:    LDA    CTLR2        ; Get current port info
  756.     ANI    (NOT USEINT) AND 0FFH ; Use internal modem
  757. ;
  758. SPORT:    STA    CTLR2
  759.     OUT    MCTLR2
  760.     RET
  761. ;
  762. ; RESPORT - set up to use external modem
  763. ;
  764. RESPORT:LDA    CTLR2        ; Get current port info
  765.     ORI    USEINT        ; Use external modem
  766.     JMP    SPORT        ; Store & send to modem
  767. ;
  768. ; PWRON - Turn power on to the modem (& some other initialization stuff)
  769. ;
  770. PWRON:    MVI    A,MDMINIT    ; Initialize the 7508
  771.     OUT    OMR
  772.     LDA    OCRVAL        ; Get current parameters
  773.     ORI    PWR        ; Turn the power on
  774.     OUT    OCR
  775.     STA    OCRVAL        ; Save the parameters
  776.     MVI    B,1        ; Wait a while to let things settle
  777.     MVI    C,TIMER
  778.     CALL    MEX
  779.     RET
  780. ;
  781. ; SPKRON - Turn the speaker on
  782. ;
  783. SPKRON:    MVI    A,0FFH
  784.     STA    SLVFLG
  785.     LXI    D,SLVPRAM1
  786.     CALL    SLAVE
  787.     RET
  788. ;
  789. ; SPKROFF - Turn speaker off
  790. ;
  791. SPKROFF:LDA    OCRVAL        ; Get current params
  792.     ANI    (NOT MON) AND 0FFH ; We're not monitoring anymore
  793.     OUT    OCR
  794.     STA    OCRVAL
  795.     MVI    A,0FFH
  796.     STA    SLVFLG
  797.     LXI    D,SLVPRAM2
  798.     CALL    SLAVE
  799.     RET
  800. ;
  801. ; Print in-line message ... blows away C register
  802. ;
  803. ILPRT:    MVI    C,ILP        ; Get function code
  804.     JMP    MEX        ; Go do it
  805. ;
  806. ; PLACECUR - Place cursor at row/col specified by BC.
  807. ;
  808. PLACECUR:
  809.     PUSH    PSW
  810.     MOV    A,B
  811.     ADI    01FH        ; Add in offset
  812.     STA    ROW
  813.     MOV    A,C
  814.     ADI    01FH        ; Add in offset
  815.     STA    COL
  816.     CALL    ILPRT
  817.     DB    ESC,'='
  818. ;
  819. ROW:    DS    1
  820. ;
  821. COL:    DS    1
  822.     DB    0
  823.     POP    PSW
  824.     RET
  825. ;
  826. ; Keyin - get a character into A
  827. ;
  828. KEYIN:    PUSH    B
  829.     PUSH    D
  830.     PUSH    H
  831.     CALL    CONIN        ; Direct console input
  832.     POP    H
  833.     POP    D
  834.     POP    B
  835.     RET
  836. ;
  837. ; UCASE - Convert character in A to uppercase
  838. ;
  839. UCASE:    CPI    'a'
  840.     RC            ; Return if not lower case
  841.     CPI    'z'+1
  842.     RNC            ; Return if > lower case z
  843.     ANI    05FH        ; Else change to upper case
  844.     RET
  845. ;
  846. ; SMSPEED - Set time to transfer speed
  847. ;
  848. SMSPEED:LDA    MDMSPD        ; Get locally stored speed value
  849.     MOV    C,A        ; Put in lower half of BC
  850.     MVI    B,0        ; Zap upper half of BC
  851.     LXI    H,XSPDTBL    ; Get address of xfer speed table
  852.     DAD    B        ; Get address of time for xfer byte
  853.     MOV    A,M        ; Get the value
  854.     STA    MSPEED        ; Store it
  855.     RET
  856. ;
  857. ; Data area
  858. ;
  859. ;
  860. ; XSPDTBL - transfer speed table. The number in parenthesis is the value
  861. ;        given to MEX.  This differs from the actual baud rate in
  862. ;        some cases due to the baud rates available on the PX-8.
  863. ;
  864. XSPDTBL:  DB    0        ; Unused
  865.       DB    0        ; 110 Baud     (110)
  866.       DB    0        ; 150 Baud     (110)
  867.       DB    1        ; 300 Baud     (300)
  868.       DB    3        ; 800 Baud     (600)
  869.       DB    5        ; 1200 Baud     (1200)
  870.       DB    6        ; 2400 Baud     (2400)
  871.       DB    7        ; 4800 Baud     (4800)
  872.       DB    8        ; 9600 Baud     (9600)
  873.       DB    9        ; 19200 Baud     (19200)
  874. ;
  875. EOSMSG:      DB    ESC,'Y','$'    ; Clear to end-of-screen
  876. CLSMSG:      DB    ESC,'*','$'    ; Clear whole screen
  877. OCRVAL:      DB    0        ; OCR register value
  878. MDMTYPE:  DB    0        ; Modem type, 0FFH=external, 0=internal
  879. GOTDISC:  DB    0        ; Got external disconnect routine, FF=Yes
  880. MDMSPD:      DS    1        ; Current port speed
  881. COMDLY:      DB    2        ; #secs to wait for , in dial string
  882. PENDXOFF: DB    0        ; 0FFH if XOFF pending, 0 otherwise
  883. STATBLK:  DS    9        ; Returned info from RSIOX INSTS call
  884. ;
  885. ;--------------------Start of slave CPU data----------------------------
  886. ;
  887. ; The following group of data items are for using the slave CPU.
  888. ;
  889. ;    DO NOT ADD OR REMOVE ANYTHING IN THIS AREA!!!
  890. ;
  891. SLVPRAM1: DW    ONSNDCMD
  892.       DW    ONSNDLEN
  893.       DW    ONRETVAL
  894.       DW    ONRETLEN
  895. ;
  896. ONSNDCMD: DB    072H,080H
  897. ONSNDLEN: DB    2
  898. ONRETVAL: DB    1
  899. ONRETLEN: DB    1
  900. SLVPRAM2: DW    OFFSDCMD
  901.       DW    OFFSDLEN
  902.       DW    OFFRTVAL
  903.       DW    OFFRTLEN
  904. OFFSDCMD: DB    072H,0
  905. OFFSDLEN: DB    2
  906. OFFRTVAL: DB    1
  907. OFFRTLEN: DB    1
  908. ;
  909. ;--------------------End of Slave CPU data------------------------------
  910. ;
  911. ; Control is passed here after MEX parses a SET command.
  912. ;
  913. SETCMD:    MVI    C,SBLANK    ; Any arguments?
  914.     CALL    MEX
  915.     JC    SETSHO        ; If not, go print out values
  916.     LXI    D,CMDTBL    ; Parse command
  917.     CALL    TSRCH        ; From table
  918.     PUSH    H        ; Any address on stack
  919.     RNC            ; If we have one, execute it
  920.     POP    H        ; Nope, fix stack
  921. ;
  922. SETERR:    LXI    D,SETEMS    ; Print error
  923.     MVI    C,PRINT
  924.     CALL    MEX
  925.     RET
  926. ;
  927. SETEMS:    DB    CR,LF,'SET command error',CR,LF,'$'
  928. ;
  929. CMDTBL:    DB    '?'+80H        ; "set ?"
  930.     DW    STHELP
  931.     DB    'OFFHOO','K'+80H ; "set offhook"
  932.     DW    SETOFF
  933.     DB    'COM','M'+80H    ; "set comm"
  934.     DW    SETCOMM
  935.     DB    'DELA','Y'+80H    ; "set delay"
  936.     DW    SETDLY
  937.     DB    'PULS','E'+80H    ; "set pulse"
  938.     DW    SETPUL
  939.     DB    0        ; <<=== table terminator
  940. ;
  941. ; SET <no-args>: print current statistics
  942. ;
  943. SETSHO:    CALL    CARRSH        ; Show carrier present/not present
  944.     LXI    H,SHOTBL    ; Get table of SHOW subroutines
  945. ;
  946. SETSLP:    MOV    E,M        ; Get table address
  947.     INX    H
  948.     MOV    D,M
  949.     INX    H
  950.     MOV    A,D        ; End of table?
  951.     ORA    E
  952.     RZ            ; Exit if so
  953.     PUSH    H        ; Save table pointer
  954.     XCHG            ; Adrs to HL
  955.     CALL    GOHL        ; Do it
  956.     MVI    C,CHEKCC    ; Check for console abort
  957.     CALL    MEX
  958.     POP    H        ; It's done
  959.     JNZ    SETSLP        ; Continue if no abort
  960.     RET
  961. ;
  962. GOHL:    PCHL
  963. ;
  964. ; table of SHOW subroutines
  965. ;
  966. SHOTBL:    DW    SHSEP
  967.     DW    SHHOOK
  968.     DW    SHDLY
  969.     DW    SHPUL
  970.     DW    SHSEP
  971.     DW    0        ; <<== table terminator
  972. ;
  973. ; LF seperator
  974. ;
  975. SHSEP:    CALL    ILPRT
  976.     DB    CR,LF,0
  977.     RET
  978. ;
  979. ; SET ?  processor
  980. ;
  981. STHELP:    LXI    D,HLPMSG
  982.     MVI    C,PRINT
  983.     CALL    MEX
  984.     RET
  985. ;
  986. ; The help message
  987. ;
  988. HLPMSG:    DB    0CH,'SET command, PX-8 version:',CR,LF
  989.     DB    CR,LF,'SET COMM     set/display comm parameters'
  990.     DB    CR,LF,'SET DELAY n  set delay for comma in dial string'
  991.     DB    CR,LF,'SET PULSE    set pulse dialing'
  992.     DB    CR,LF,'SET OFFHOOK  go offhook'
  993.     DB    CR,LF,LF,'$'
  994. ;
  995. ; Show carrier status
  996. ;
  997. CARRSH:    CALL    CARRCK        ; Check for it
  998.     LXI    D,NOMESG    ; Tell about carrier
  999.     MVI    C,PRINT
  1000.     CZ    MEX        ; Print the "NO" if no carrier
  1001.     LXI    D,CARMSG    ; Print "carrier present"
  1002.     MVI    C,PRINT
  1003.     CALL    MEX
  1004.     RET
  1005. ;
  1006. NOMESG:    DB    'no $'
  1007. CARMSG:    DB    'carrier present',CR,LF,'$'
  1008. ;
  1009. ; Check the PX-8 for carrier-present (Z=no)
  1010. ;
  1011. CARRCK:    MVI    B,CTLIN        ; Get status byte
  1012.     CALL    RSIOX
  1013.     ANI    DCD        ; Check for carrier detect
  1014.     RET
  1015. ;
  1016. ; Set OFFHOOK processor
  1017. ;
  1018. SETOFF:    CALL    PDISC        ; Disconnect if anything was there
  1019.     CALL    PWRON        ; Fire up the modem
  1020.     CALL    OFFHK
  1021. ;
  1022. SHHOOK:    CALL    ILPRT
  1023.     DB    'modem is ',0
  1024.     LDA    OCRVAL
  1025.     ANI    OHC
  1026.     JZ    SHONHK
  1027.     CALL    ILPRT
  1028.     DB    'off-hook',CR,LF,0
  1029.     RET
  1030. ;
  1031. SHONHK:    CALL    ILPRT
  1032.     DB    'on-hook',CR,LF,0
  1033.     RET
  1034. ;
  1035. ; Set delay for comma
  1036. ;
  1037. SETDLY:    MVI    C,EVALA        ; Get the number
  1038.     CALL    MEX
  1039.     MOV    A,H        ; Validate
  1040.     ORA    A
  1041.     JNZ    SETERR
  1042.     MOV    A,L
  1043.     STA    COMDLY        ; Store new rate
  1044. ;
  1045. ; Show dialing delay
  1046. ;
  1047. SHDLY:    CALL    ILPRT
  1048.     DB    'delay time for dialing: ',0
  1049.     LDA    COMDLY
  1050.     MOV    L,A
  1051.     MVI    H,0
  1052.     MVI    C,DECOUT
  1053.     CALL    MEX
  1054.     CALL    ILPRT
  1055.     DB    ' sec',CR,LF,0
  1056.     RET
  1057. ;
  1058. ; Set for tone or pulse dialing
  1059. ;
  1060. SETPUL:    MVI    C,SBLANK    ; Any arguments?
  1061.     CALL    MEX
  1062.     JC    PULSON        ; If not, pulse on
  1063.     MVI    A,'T'        ; Tone dial flag
  1064.     STA    TPULSE
  1065.     JMP    SHPUL
  1066. PULSON:    MVI    A,'P'        ; Pulse dial flag
  1067.     STA    TPULSE
  1068. ;
  1069. ; Show tone or pulse status
  1070. ;
  1071. SHPUL:    CALL    ILPRT
  1072.     DB    'dialing mode: ',0
  1073.     LDA    TPULSE
  1074.     CPI    'T'
  1075.     JZ    SHPUL1
  1076.     CALL    ILPRT
  1077.     DB    'pulse',CR,LF,0
  1078.     RET
  1079. ;
  1080. SHPUL1:    CALL    ILPRT
  1081.     DB    'tone',CR,LF,0
  1082.     RET
  1083. ;
  1084. ; Compare next input-stream item in table @DE; CY=1
  1085. ; if not found, else HL=matched data item
  1086. ;
  1087. TSRCH:    MVI    C,LOOKUP    ; Get function code
  1088.     JMP    MEX        ; Pass to MEX processor
  1089. ;
  1090. SETCOMM:CALL    CLS        ; Clear the screen
  1091.     LXI    D,MENU
  1092.     MVI    C,PRINT
  1093.     CALL    MEX        ; Display the setup menu
  1094. ;
  1095. ; Display current values on setup screen
  1096. ;
  1097.     CALL    DBAUD
  1098.     CALL    DDBITS
  1099.     CALL    DPARITY
  1100.     CALL    DSTP
  1101.     CALL    DMODEM
  1102. ;
  1103. ; Get user's response and set paramiters
  1104. ;
  1105. SETUP0:    CALL    KEYIN
  1106.     CALL    UCASE
  1107.     CPI    ESC
  1108.     JZ    SETUP
  1109.     CPI    '9'+1        ; Greater than baud selection
  1110.     JNC    SDBITS        ; Check for data bits
  1111.     CPI    '1'        ; Less than 1?
  1112.     JC    SETUP0        ; Get another response
  1113.     ANI    0FH
  1114.     MOV    E,A
  1115.     MVI    A,10
  1116.     SUB    E
  1117.     STA    MDMSPD
  1118.     MOV    C,A
  1119.     MVI    B,0
  1120.     LXI    H,BAUDTBL
  1121.     DAD    B
  1122.     MOV    A,M
  1123.     STA    BAUDRATE
  1124.     CALL    DBAUD
  1125.     JMP    SETUP0
  1126. ;
  1127. SDBITS:    CPI    'B'+1        ; Greater than data bits
  1128.     JNC    SPARITY        ; Check for parity
  1129.     CPI    'A'        ; Less than 'a'
  1130.     JC    SETUP0        ; Get another response
  1131.     SUI    3FH        ; Make 2 or 3
  1132.     STA    DBITS
  1133.     CALL    DDBITS
  1134.     JMP    SETUP0
  1135. ;
  1136. SPARITY:CPI    'E'+1        ; Greater than parity
  1137.     JNC    SSTOP        ; Check for stop bits
  1138.     CPI    'E'        ; Check for "even" parity
  1139.     JNZ    SPAR0
  1140.     SUI    'B'        ; Even parity = 3
  1141.     JMP    SPAR1
  1142. ;
  1143. SPAR0:    SUI    'C'        ; Make 0 or 1
  1144. ;
  1145. SPAR1:    STA    PARBITS
  1146.     CALL    DPARITY
  1147.     JMP    SETUP0
  1148. ;
  1149. SSTOP:    CPI    'G'+1        ; Greater than stop bits
  1150.     JNC    SMOD        ; Check for modem
  1151.     SUI    'F'-1
  1152.     CPI    1
  1153.     JZ    SSTOP1
  1154.     ADI    1        ; Two stop bits = 3
  1155. ;
  1156. SSTOP1:    STA    STP
  1157.     CALL    DSTP
  1158.     JMP    SETUP0
  1159. ;
  1160. SMOD:    CPI    'I'+1        ; Greater than baud
  1161.     JNC    SETUP0        ; Bad selection get another response
  1162.     SUI    'H'
  1163.     JZ    SMOD1
  1164.     CALL    PWRON        ; Try to turn the modem on
  1165.     IN    STR        ; Read status register
  1166.     ANI    MII        ; Is modem installed?
  1167.     JNZ    SMOD2
  1168.     MVI    A,0FFH
  1169. ;
  1170. SMOD1:    STA    MDMTYPE
  1171.     CALL    DMODEM
  1172.     JMP    SETUP0
  1173. ;
  1174. SMOD2:    MVI    A,BELL
  1175.     CALL    TYPE
  1176. ;
  1177. SMOD3:    LXI    B,0201H
  1178.     CALL    PLACECUR
  1179.     CALL    ILPRT
  1180.     DB    TAB,'** NO MODEM **',0
  1181.     XRA    A
  1182.     STA    MDMTYPE
  1183.     CALL    DMODEM
  1184.     JMP    SETUP0
  1185. ;
  1186. ; Display baud rate
  1187. ;
  1188. DBAUD:    LXI    B,30DH
  1189.     CALL    PLACECUR
  1190.     LXI    H,BAUDSPD
  1191.     MVI    D,0
  1192.     LDA    MDMSPD        ; Get baud rate code
  1193.     CPI    0FFH
  1194.     RZ            ; Unknown baud rate
  1195.     MOV    E,A        ; X1
  1196.     ADD    A        ; X2
  1197.     ADD    A        ; X4
  1198.     ADD    E        ; X5
  1199.     ADD    E
  1200.     MOV    E,A
  1201.     DAD    D        ; Point to correct rate
  1202.     XCHG
  1203.     MVI    C,PRINT
  1204.     CALL    MEX
  1205.     CALL    ILPRT
  1206.     DB    ' bps ',CR,LF,0
  1207.     RET
  1208. ;
  1209. ; Display data bits
  1210. ;
  1211. DDBITS:    LXI    B,50DH
  1212.     CALL    PLACECUR
  1213.     LDA    DBITS
  1214.     CPI    2
  1215.     MVI    A,'7'
  1216.     JZ    DDBITS1
  1217.     MVI    A,'8'
  1218. ;
  1219. DDBITS1:CALL    TYPE
  1220.     RET
  1221. ;
  1222. ; Display parity
  1223. ;
  1224. DPARITY:LXI    B,60DH
  1225.     CALL    PLACECUR
  1226.     LDA    PARBITS
  1227.     ORA    A
  1228.     JNZ    DPAR1
  1229.     CALL    ILPRT
  1230.     DB    'none',0
  1231.     RET
  1232. DPAR1:    CPI    1
  1233.     JNZ    DPAR2
  1234.     CALL    ILPRT
  1235.     DB    'odd ',0
  1236.     RET
  1237. DPAR2:    CALL    ILPRT
  1238.     DB    'even',0
  1239.     RET
  1240. ;
  1241. ; Display stop bits
  1242. ;
  1243. DSTP:    LXI    B,70DH
  1244.     CALL    PLACECUR
  1245.     LDA    STP
  1246.     CPI    1
  1247.     MVI    A,'1'
  1248.     JZ    DSTP1
  1249.     MVI    A,'2'
  1250. ;
  1251. DSTP1:    CALL    TYPE
  1252.     RET
  1253. ;
  1254. ; Display modem type
  1255. ;
  1256. DMODEM:    LXI    B,80DH
  1257.     CALL    PLACECUR
  1258.     LDA    MDMTYPE
  1259.     ORA    A
  1260.     JNZ    DMODEM1
  1261.     CALL    ILPRT
  1262.     DB    'external',0
  1263.     RET
  1264. ;
  1265. DMODEM1:CALL    ILPRT
  1266.     DB    'internal',0
  1267.     RET
  1268. ;
  1269. SETUP:    CALL    STPORT        ; Set up for internal modem just in case
  1270.     CALL    SMSPEED        ; Set time to xfer speed
  1271.     LDA    MDMTYPE        ; See what kind of modem we're using
  1272.     INR    A        ; If FF, then it's internal
  1273.     JZ    SETUP1        ; Yep, it's internal
  1274.     CALL    RESPORT        ; Using external, do setup
  1275. ;
  1276. SETUP1:    LXI    H,PARAMS    ; Copy all settings to RSIOX string
  1277.     LXI    D,WIPEOUT
  1278.     LXI    B,9
  1279.     DB    0EDH,0B0H    ; LDIR
  1280.     LXI    H,BAUDRATE    ; Copy uart settings to working area
  1281.     LXI    D,WRSDAT
  1282.     LXI    B,4
  1283.     DB    0EDH,0B0H    ; LDIR
  1284.     MVI    B,CLSIOX
  1285.     CALL    RSIOX        ; Close port first
  1286.     MVI    B,OPNIOX
  1287.     LXI    H,WIPEOUT
  1288.     CALL    RSIOX        ; Open with new parameters
  1289.     CALL    CLS
  1290.     CALL    ILPRT
  1291.     DB    ESC,CURON
  1292.     DB    CR,LF,LF,LF
  1293.     DB    TAB,TAB,'Communication initialization completed',CR,LF
  1294.     DB    LF,LF,0
  1295.     RET
  1296. ;
  1297. BAUDSPD:DB    '50   $110  $150  $300  $600  $'
  1298.     DB    '1200 $2400 $4800 $9600 $19200$'
  1299. ;
  1300. BAUDTBL:DB    0FFH        ; 50   baud not supported
  1301.     DB    2        ; 110  baud
  1302.     DB    4        ; 150  baud
  1303.     DB    6        ; 300  baud
  1304.     DB    8        ; 600  baud
  1305.     DB    0AH        ; 1200 baud
  1306.     DB    0CH        ; 2400 baud
  1307.     DB    0DH        ; 4800 baud
  1308.     DB    0EH        ; 9600 baud
  1309.     DB    0FH        ; 19.2k baud
  1310. ;
  1311. MENU:    DB    ESC,CUROFF
  1312.     DB    TAB,'Select alphanumeric or ESC to return',CR,LF,LF
  1313.     DB    'bit rate  :           1=19200    2=9600     3=4800'
  1314.     DB    '     4=2400'
  1315.     DB    '     5=1200',CR,LF
  1316.     DB    '                      6=600      7=300      8=150'
  1317.     DB    '      9=110',CR,LF
  1318.     DB    'data bits :           A=7        B=8',CR,LF
  1319.     DB    'parity    :           C=none     D=odd      E=even'
  1320.     DB    CR,LF
  1321.     DB    'stop bits :           F=1        G=2',CR,LF
  1322.     DB    'modem type:           H=external I=internal$'
  1323. ;
  1324. PARAMS:      DW    INTBUF
  1325.       DW    INTBUFL
  1326. BAUDRATE: DS    1
  1327. DBITS:      DS    1
  1328. PARBITS:  DS    1
  1329. STP:      DS    1
  1330. SPECIAL:  DB    0FFH        ; Not XON/XOFF, not SI/SO, DTR on, RTS on
  1331. ;
  1332. WIPEOUT:  DS    9        ; This area gets overwritten by BIOS call
  1333. ;
  1334. ;-----------------------------------------------------------------------
  1335. ;
  1336. ;           End of PX-8 MEX modem overlay
  1337. ;
  1338. ;-----------------------------------------------------------------------
  1339. ;
  1340.     END
  1341.