home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MODEMS / MODEM7 / M7QX-3.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  28KB  |  863 lines

  1. ; M7QX-3.ASM -- Epson QX-10 overlay file for VALDOCS 1.1X  06/06/84
  2. ;
  3. ;        Overlay file for MDM730 (and later), Epson QX-10, and the
  4. ;        D.C. Hayes Smartmodem 300 or 1200, US Robotics modems, the
  5. ;        Anchor Automation Signalman Mark XII, Prometheus, or similiar
  6. ;        modems which use the DC Hayes Smartmodem protocols.  It is
  7. ;         designed to be used with a .SYS extent as a VALDOCS applica-
  8. ;        tion from the <M>enu of Applications, <R>un specific program,
  9. ;        or <E>xit to TPM options.  It will also run under TPM-II
  10. ;        without VALDOCS (using a .SYS or .COM extent) or under
  11. ;        CP/M A2.21 or B2.20 if given a .COM file extent.  It
  12. ;         incorporates the special SET menu advantages of Bruce
  13. ;        Ratoff's ATXMODEM, plus it offers the ability to toggle
  14. ;        on or off the 7th bit mask. This permits the use of QX-10
  15. ;        graphics when desired, but retains the ability to use this
  16. ;        same program on mainframes such as Compuserve.  This overlay
  17. ;        is specifically tailored to MDM730 and makes direct calls to
  18. ;        addresses in the main program.  You must change these addresses
  19. ;        to use this overlay with a later MDM7XX series program.
  20. ;        For standardization among the four operating systems used on
  21. ;        the QX-10, I have chosen ^B for the sendbreak character,
  22. ;        and ^Z to transmit control characters above ^M to the remote.
  23. ;
  24. ;******************************************************************************
  25. ;
  26. ; NOTE:  All improvements to this overlay intended for distribution must be
  27. ; compatible with VALDOCS.  Send all updates to either the Technical RCPM/RBBS
  28. ; (313)846-6127, or CompuServe CP/MIG (PCS-47), Area XA0 along with a message
  29. ; addressed to the SYSOP.  They, in turn, will make official release.  If you
  30. ; wish to discuss the overlay, leave a message for Chris Hopkins, 71026,1407 on
  31. ; CompuServe's EpsOnLine SIG (PCS-19), or EMAIL.
  32. ;
  33. ;******************************************************************************
  34. ;
  35. ; Switch settings for the D.C. Hayes Smartmodem and Smartmodem 1200 are:
  36. ;
  37. ;    SW1    SW2    SW3    SW4    SW5    SW6    SW7    SW8
  38. ;    UP    ANY    ANY    ANY    ANY    UP    ANY*    DN
  39. ;
  40. ;   These settings are compatible with those used in VALDOCS MAIL to prevent
  41. ;   unnecessary changing of settings.  This program resets switches 2 thru 5
  42. ;   by software, so their physical settings have no effect.
  43. ;
  44. ;   *Depends on type of telephone jack used.
  45. ;.....
  46. ; You will want to look this file over carefully. There are a number of
  47. ; options that you can use to configure the program to suit your taste.
  48. ;
  49. ; Edit this file for your preferences then follow the "TO USE:" example
  50. ; shown below.
  51. ;
  52. ;    TO USE: First edit this file, filling in answers for your own
  53. ;        preferences.  Assemble with ASM.COM or equivalent
  54. ;        assembler to obtain a file named M7QX-3.HEX.  Then
  55. ;               use DDT to overlay the HEX file on the original .COM file:
  56. ;
  57. ;        A>DDT MDM730.COM
  58. ;        DDT VERS 2.2
  59. ;        NEXT  PC
  60. ;        4A00 0100
  61. ;        -IM7QX-3.HEX        (note the "I" command)
  62. ;        -R            ("R" loads in the .HEX file)
  63. ;        NEXT  PC
  64. ;        4A00 0000
  65. ;        -G0            (return to CP/M)
  66. ;               A>SAVE 73 QXMDM3.SYS   (now have a modified .SYS file)
  67. ;                    (can also make a .COM file now)
  68. ;    =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  69. ; 06/06/84 - Renamed to M7QX-3.ASM and added addresses for MDM740.ASM. 
  70. ;        - Added BYEBYE messages for CP/M, TPM and VALDOCS. 
  71. ;        - Corrected error in hardware initiation that forgot to tell the
  72. ;         QX-10 baudrate timer the speed in use according to the CMOS. 
  73. ;       - Corrected timing problem in VALDOCS during ^T text transfer. 
  74. ;        - Corrected GOODBYE and SENDBRK to reset to parameters that were in
  75. ;         use before the break.  Previously, it always reset to 8 bit words,
  76. ;         1 stop bit and no parity. 
  77. ;        - Corrected timing problems for VALDOCS by placing CLOCKSET routine
  78. ;         at START.  Previously, timing set did not occur until INITMOD.
  79. ;                            -Chris Hopkins 
  80. ; 04/15/84 - Removed macros to allow assembly using ASM.COM, and revised to
  81. ;         work with MDM730. 
  82. ;        - Added cursor control routines for signon. 
  83. ;        - Added toggle in SET command to allow selection of QX-10 graphics
  84. ;         for use in the terminal mode.  Subsequent selection of 7-bit
  85. ;         words or 8-bit words with the 7th bit masked cancels the
  86. ;         graphics selection. - Chris Hopkins
  87. ; 03/11/84 - Renamed to M7QX-2.ASM and revised to work with MDM727.  
  88. ;        - Added subroutines to provide [ Using TPM ], [ Using CP/M ] and
  89. ;         [ Using VALDOCS ] statements following signon message. - CH 
  90. ; 01/22/84 - Revised M712QS.ASM to fit MDM718-720, renamed overlay to
  91. ;            M7QX-1.ASM to conform to new format. 
  92. ;        - Added sendbreak routine and revised signon - Chris Hopkins
  93. ; 10/13/83 - Checks for CP/M or TPM to prevent crashing CP/M
  94. ;         with TPM backdoor calls. - BRR
  95. ; 10/11/83 - Detects presence of SYSINIT and uses its interrupt-driven
  96. ;            serial routines if present. - BRR
  97. ; 10/10/83 - Stop bits, parity, word size in SETUPR - BRR
  98. ; 08/14/83 - Cosmetic changes only for MDM712    - Bruce Ratoff
  99. ; 07/26/83 - QX-10 version created from GP file - Bruce Ratoff
  100. ; 07/01/83 - Revised to work with MDM711    - Irv Hoff
  101. ; 07/01/83 - Revised to work with MDM710    - Irv Hoff
  102. ; 05/27/83 - Updated to work with MDM709    - Irv Hoff
  103. ; 05/15/83 - Revised to work with MDM708    - Irv Hoff
  104. ; 04/11/83 - Updated to work with MDM707    - Irv Hoff
  105. ; 04/04/83 - First version of this file        - Irv Hoff
  106. ;
  107. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  108. ;
  109. BELL:        EQU    07H        ;bell
  110. CR:        EQU    0DH        ;carriage return
  111. ESC:        EQU    1BH        ;escape
  112. LF:        EQU    0AH        ;linefeed
  113. ;
  114. YES:        EQU    0FFH
  115. NO:        EQU    0
  116. ;
  117. ;------------------------------------------------------------------------------
  118. ; The following equates are addresses in the main program of MDM730.COM.  If
  119. ; this overlay is adapted to a later version, these may have to be changed.
  120. ;
  121. PMMIMENU:    EQU    09EDH        ;addr of SPCLMENU in basic program 
  122.                     ;available as extra patch area.
  123.                     ;For MDM730 use 09EDH
  124.                     ;For MDM740 use 0A78H
  125.                     ;Must match byte of basic program.
  126. ;
  127. START:        EQU    13CAH        ;addr of START in basic program.
  128.                      ;For MDM730-740 use 13CAH
  129. ;
  130. SPEED4:        EQU    1A7EH        ;addr of SPEED4 in basic program.
  131.                     ;For MDM730-740 use 1A7EH
  132. ;
  133. TERML:        EQU    1F01H        ;addr of TERML in basic program.
  134.                     ;Use 1F01 for MDM730-740
  135. ;
  136. GRAFMASK:    EQU    TERML+10    ;addr of 7th bit mask in TERML
  137. ;
  138. BYEBYE:        EQU    404DH        ;addr of BYEBYE in basic program.
  139.                     ;For MDM730-740 use 404DH
  140. ;
  141. ;------------------------------------------------------------------------------
  142. ; The following information is specific to the Epson QX-10.
  143. ;
  144. PORT:        EQU    011H        ;QX-10 base port
  145. MODCTL1:    EQU    PORT+2        ;Modem control port
  146. MODDATP:    EQU    PORT        ;Modem data in port
  147. MODDATO:    EQU    PORT        ;Modem data out port
  148. TPORTS:        EQU    007H        ;Baud rate setup port
  149. TPORTC:        EQU    006H        ;Baud rate counter port
  150. MODRCVB:    EQU    1        ;Bit to test for receive
  151. MODRCVR:    EQU    1        ;Value when ready
  152. MODSNDB:    EQU    4        ;Bit to test for send
  153. MODSNDR:    EQU    4        ;Value when ready
  154. CRAM:        EQU    35        ;CMOS RAM baud rate storage
  155. MOSADR:        EQU    3DH        ;CMOS RAM address port
  156. MOSDAT:        EQU    3CH        ;CMOS RAM data port
  157. ;
  158.         ORG    100H
  159. ;.....
  160. ; Change the clock speed to suit your system
  161. ;
  162.         DS    3    ;(for  "JMP   START" instruction)
  163. PMMIMODEM:    DB    NO    ;yes=PMMI S-100 Modem, no=non-PMMI    103H
  164. AUTODIAL:    DB    YES    ;yes=HAYES Smartmodem or lookalike    104H
  165. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  166. CLOCK:        DB    40    ;clock speed in MHz x10, 25.5 MHz max.    106H
  167.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  168. MSPEED:        DB    1    ;When booting up, the program will set  107H
  169.                 ;this flag to match the QX-10's current
  170.                 ;CMOS baud rate.
  171. BYTDLY:        DB    5    ;0=0 delay, 1=10ms, 5=50ms - 9=90ms     108H
  172.                 ;default time to send character in ter-
  173.                 ;minal mode file transfer for slow BBS.
  174. CRDLY:        DB    5    ;0=0 delay, 1=100ms, 5=500ms - 9=900ms  109H
  175.                 ;default time for extra wait after CRLF
  176.                 ;in terminal mode file transfer
  177. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  178. SETUPTST:    DB    YES    ;yes=user-added SETUP routine        10BH
  179. SCRNTEST:    DB    YES    ;Cursor control routine         10CH
  180. RETRY:        DB    YES    ;yes=reset the error limit to try again 10DH
  181.                 ;no=abort after 10 consecutive errors
  182.                 ;(ARPANET users should select yes)
  183. BAKUPBYTE:    DB    YES    ;yes=change any file same name to .BAK    10EH
  184. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  185. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  186. CONVRUB:    DB    NO    ;yes=convert rub to backspace        111H
  187. TOGGLERUB:    DB    YES    ;yes=allow toggling of rub to backspace    112H
  188. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  189.                 ;terminal mode (added by remote echo)
  190. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  191. TRANLOGON:    DB    YES     ;yes=allow transmission of logon    115H
  192.                 ;write logon sequence at location LOGON
  193. SAVCCP:        DB    NO     ;yes=do not overwrite CCP        116H
  194. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  195.                 ;no=external command if EXTCHR precedes
  196. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  197. LSTTST:        DB    YES    ;yes=printer available on printer port    119H
  198. XOFFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  199.                 ;sending a file in terminal mode
  200. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  201.                 ;sending a file in terminal mode
  202. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  203. IGNORCTL:    DB    NO     ;yes=CTL-chars above ^M not displayed    11DH
  204. TPMFLG:        DB    NO    ;set by the program, always no here    11EH
  205. VALFLG:        DB    NO    ;set by the program, always no here    11FH
  206. BRKCHR:        DB    'B'-40H    ;^B = Send 300 ms. break tone        120H
  207.                 ;(CP/M A & B don't permit CONTROL-@)
  208. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  209. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  210. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  211. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  212. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  213. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  214. EXTCHR:        DB    'Z'-40H    ;^Z = Send next character        127H
  215.                 ;(CP/M A doesn't permit CONTROL-^ while
  216.                 ;..CP/M B requires SHIFT CONTROL-^ to get
  217.                 ;..the character, so we standardized with this)
  218.         DS    2    ;                    128H
  219. ;.....
  220. ; Handles in/out ports for data and status:
  221. ;
  222. IN$MODCTL1:    IN    MODCTL1 ! RET    ;in modem control port             12AH
  223.                     ;INITMOD makes this a jump to SYSI$STAT
  224.                     ;when run under VALDOCS
  225.         DS    7        ;spares
  226. OUT$MODDATP:    OUT    MODDATP ! RET    ;out modem data port        134H
  227.                     ;INITMOD makes this a jump to SYSI$OUT
  228.                     ;when run under VALDOCS
  229.         DS    7        ;spares
  230. IN$MODDATP:    IN    MODDATP ! RET    ;in modem data port        13EH
  231.                     ;INITMOD makes this a jump to SYSI$IN
  232.                     ;when run under VALDOCS
  233.         DS    7        ;spares
  234. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to test for receive ready    148H
  235. CPI$MODRCVR:    CPI    MODRCVR    ! RET    ;value of rcv. bit when ready    14BH
  236. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to test for send ready    14EH
  237. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when ready    151H
  238.         DS    6        ;bypasses PMMI routines        156H
  239. ;
  240. OUT$MODCTL1:    RET    ! NOP     ! NOP    ;out modem control port #1    15AH
  241. OUT$MODCTL2:    RET     ! NOP     ! NOP    ;out modem control port #2    15DH
  242. ;
  243. LOGONPTR:    DW    LOGON        ;for user message.        160H
  244.         DS    3        ;do not change            162H
  245. JMP$DISCONNT:    RET    ! NOP    ! NOP    ;not needed with QX-10/Smartmdm 165H
  246. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  247. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  248.         RET     ! NOP     ! NOP    ;(by-passes PMMI routine)    16EH
  249.         RET     ! NOP     ! NOP    ;(by-passes PMMI routine)    171H
  250.         RET     ! NOP     ! NOP    ;(by-passes PMMI routine)    174H
  251. JMP$SETUPR:    JMP    SETUPR        ;                177H
  252. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  253. JMP$SYSVER:    JMP    SYSVER        ;                17DH
  254. JMP$BREAK:    JMP    SENDBRK        ;INITMOD makes this a        180H
  255.                     ;jump to SYSI$BREAK when run 
  256.                     ;under VALDOCS
  257. ; Do not change the following six lines.  They go to specific locations in the 
  258. ; main program, not the overlay.
  259. ;
  260. JMP$ILPRT:    DS    3        ;                183H
  261. JMP$INBUF:    DS    3        ;                186H
  262. JMP$INLNCOMP:    DS    3        ;                189H
  263. JMP$INMODEM:    DS    3        ;                18CH
  264. JMP$NXTSCRN:    DS    3        ;                18FH
  265. JMP$TIMER:    DS    3        ;                192H
  266. ;.....
  267. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  268. ; SCRNTEST to YES at 010CH (above).  Room allowed for four bytes.  Last zero
  269. ; needed for stopping the string display.  Any extra zeros just act as NOPs.
  270. ;
  271. CLREOS:        CALL    JMP$ILPRT    ;                195H
  272.         DB    ESC,059H,0,0,0    ;Hex code for ESC Y        198H
  273.         RET            ;                19DH
  274. ;
  275. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  276.         DB    01AH,0,0,0,0    ;Hex for Control Z        1A1H
  277.         RET            ;                1A6H
  278. ;.....
  279. ; NOTE:  You can change the SYSVER and LOGON messages to be longer or
  280. ;        shorter.  The following overlay routines must terminate before 0400H.
  281. ;
  282. SYSVER:        CALL    CPMMODE        ;Set CP/M emulation mode    1A7H   
  283.         CALL    CLRSCRN        ;
  284.         CALL    JMP$ILPRT    ;
  285.         DB    ESC,3DH,2AH,3DH,'WELCOME TO QX-MODEM'
  286.         DB    ESC,3DH,2CH,3DH,'For the Epson QX-10'
  287.         DB    ESC,3DH,2EH,3FH,0
  288.         RET
  289. ;.....
  290. ; You can put a message at this location which will be called up with
  291. ; CTL-L if TRANLOGON has been set TRUE.  In this overlay version, approximately
  292. ; 8 bytes are available for LOGON message.  A common usage of this feature is
  293. ; 'FIRSTNAME;LASTNAME;PASSWORD' separated by semi-colons for use in signing
  294. ; on to remote bulletin boards with only one keystroke.  The logon capability
  295. ; has lost much of its importance with the addition of function keys to the 
  296. ; program.  The length of this overlay has left little room for the logon
  297. ; sequence.  End with a 0.
  298. ;
  299. LOGON:        DB    'Hello',CR,LF,0
  300. ;.....
  301. ; Sets DTR low for 300ms
  302. ;
  303. GOODBYE:    MVI    A,5        ;point to register 5
  304.         OUT    MODCTL1        
  305.         LDA    TXBYT        ;fetch the most recent TXBYT sent
  306.         ANI    7FH        ;set the DTR bit low
  307. ;
  308. GOODBYE1:    OUT    MODCTL1        ;send it
  309.         MVI    B,3        ;delay 300ms
  310.         CALL    JMP$TIMER
  311.         MVI    A,5        ;point to register 5
  312.         OUT    MODCTL1
  313.         LDA    TXBYT        ;restore previous condition by sending
  314.         OUT    MODCTL1        ;..the original TXBYT
  315.         RET
  316. ;.....
  317. ; This is a continuation of BYEBYE from end of overlay.
  318. ;
  319. BYEBYE1:    RZ            ;if CP/M, back to main program
  320.         LDA    VALFLG        ;if not CP/M, is it VALDOCS?
  321.         ORA    A
  322.         CZ    TPMMSG        ;no? then print TPM
  323.         CNZ    VALMSG        ;if yes, then VALDOCS
  324.         RET            ;back to main program
  325. ;.....
  326. ; The following SENDBRK routine sends a break tone to reset some time-share
  327. ; computers, such as BRS After Dark and Dialog's Knowledge Index.  However, it
  328. ; will usually cause an immediate disconnect when on line with an RBBS/RCPM
  329. ; system.  This routine is automatically replaced by SYSI$BREAK if run under
  330. ; VALDOCS.
  331. ;
  332. SENDBRK:        MVI        A,5        ;point to register 5
  333.                 OUT        MODCTL1
  334.                 LDA        TXBYT          ;get TXBYT currently in use      
  335.         ORI    10H        ;turn sendbreak bit on
  336.             JMP     GOODBYE1
  337. ;.....
  338. ; This routine shuttles from TPM to CP/M 
  339. ;
  340. CPMMODE:    LXI    D,0CCCCH    ;Put request for CP/M in D reg
  341. BDOSMODE:    MVI    C,12
  342.         JMP    5
  343. ;......
  344. ; This routine sets the CLOCK equate for computations at the very beginning of
  345. ; the main program.
  346. ;
  347. CLOCKSET:    LXI    H,0        ;Set HL to 0 since these three bytes
  348.                     ;were stolen from main program START
  349.                     ;subroutine
  350.         CALL    CPMMODE        ;get system version
  351.         MOV    A,E
  352.         CPI    'T'        ;is this CP/M?
  353.         RNZ            ;if CP/M, quit here
  354.         MVI    A,YES        ;store flag saying TPM in use
  355.         STA    TPMFLG
  356.         LXI    D,0        
  357.         CALL    BACKDOOR    ;if VALDOCS SYSINIT module is not
  358.                     ;loaded, returns 0FFH in A register
  359.         INR    A
  360.         RZ            ;If no SYSINIT, quit here
  361.         MVI    A,YES        ;tell flag that VALDOCS is loaded
  362.         STA    VALFLG
  363.         MVI    A,2        ;Replace clock value with this to
  364.         STA    CLOCK        ;..reduce apparent speed for overhead
  365.                     ;..calls if using VALDOCS
  366.         RET
  367. ;.....
  368. ; This routine checks to see what system the program is running under.  It
  369. ; announces it at signon and, if VALDOCS SYSINIT module is loaded, it rewrites
  370. ; code to direct the use of backdoor subroutines needed by VALDOCS.  
  371. ;
  372. INITMOD:    CALL     JMP$ILPRT
  373.         DB    '[ Using ',0
  374.         LDA     TPMFLG        ;is this CP/M or TPM?
  375.         ORA    A
  376.         PUSH    PSW
  377.         CZ    CPMMSG        ;if CP/M, go get message
  378.         POP    PSW
  379.         JZ    NOSYSINIT    ;..and go back to work
  380.         LDA    VALFLG        ;we're this far, must be TPM or VALDOCS
  381.         ORA    A        ;which is it?
  382.         PUSH    PSW
  383.         CZ    TPMMSG        ;if TPM, go get message
  384.         POP    PSW
  385.         JZ    NOSYSINIT    ;..and then skip ahead
  386.         CALL    VALMSG        ;now this far, must be VALDOCS
  387.         MVI    A,0C3H        ;Mod modem I/O to use BACKDOOR routines
  388.         STA    IN$MODCTL1
  389.         STA    OUT$MODDATP
  390.         STA    IN$MODDATP
  391.         LXI    H,SYSI$STAT
  392.         SHLD    IN$MODCTL1+1
  393.         LXI    H,SYSI$OUT
  394.         SHLD    OUT$MODDATP+1
  395.         LXI    H,SYSI$IN
  396.         SHLD    IN$MODDATP+1
  397.         LXI    H,SYSI$BREAK
  398.         SHLD    JMP$BREAK+1
  399.         MVI    A,2
  400.         STA    ANI$MODSNDB+1
  401.         STA    CPI$MODSNDR+1
  402.         MVI    A,11H        ;load op code for LXI D and then store
  403.         STA    SPEED4        ;..speed to insure correct...
  404.         LXI    H,1275        ;..timing is used under VALDOCS...
  405.         SHLD    SPEED4+1    ;..for ^T text transfers
  406.         MVI    A,0        ;put NOP to fill
  407.         STA    SPEED4+3
  408.         LXI    D,4FFH        ;Re-enable BACKDOOR interrupt stuff
  409.         CALL    BACKDOOR
  410. ;.....
  411. ; If SYSINIT was not loaded, program comes here to see if carrier is present
  412. ; (DCD active), and then reset the modem if not. 
  413. ;    
  414. NOSYSINIT:    CALL    JMP$ILPRT    ;send cursor to bottom of page
  415.         DB    ESC,3DH,36H,20H,0
  416.         MVI     A,CRAM        ;point to QX-10 CMOS baud rate address
  417.         DI            ;disable interrupts
  418.         OUT    MOSADR        ;
  419.         IN    MOSDAT        ;get CMOS status byte
  420.         EI            ;enable interrupts
  421.         ANI    0FH        ;set flags & strip off all but baudrate
  422.         CPI    3        ;operating at 300 baud?
  423.         JNZ     TEST1200    ;if not, see if 1200
  424.         LXI    H,CSPDTBL+12    ;if 300, point to that speed in table
  425. NOSYSINIT1:    MOV    E,M        ;load baudrate into D-E
  426.         INX    H        
  427.         MOV    D,M
  428.         XCHG            ;now put it in H-L
  429.         CALL    FINDRATE    ;tell the timer and set MSPEED flag
  430. NOSYSINIT2:    CALL    SIOINIT        ;send out default SIO initialization
  431.         CALL     IN$MODCTL1    ;look at status of DCD
  432.         ANI    8        ;is connection active?
  433.         RNZ            ;if yes, initialization already done
  434.         LXI    H,MDMRESET
  435.         CALL    SEND        ;Reset the modem
  436.         RET
  437. ;.....
  438. ; If baudrate set on CMOS was not 300, program comes here to see if it is 1200
  439. ; baud.  If not, a prompt is called to allow user to set either 300 or 1200.
  440. ; The Smartmodem can only be addressed at those two speeds.
  441. ;
  442. TEST1200:    CPI    5        ;is it 1200 baud?
  443.         PUSH    PSW        ;save the flags
  444.         CNZ    AGAIN        ;if not, means we weren't at 300 or
  445.                     ;1200, so get a SET prompt to fix.
  446.         POP    PSW        ;bring flags back
  447.         JNZ    NOSYSINIT2    ;continue with new speed from prompt
  448.         LXI    H,CSPDTBL+20    ;was 1200, so point to 1200 in table
  449.         JMP     NOSYSINIT1    ;back to work
  450. ;.....
  451. ; This series of bytes initialize the Smartmodem, and are taken from the
  452. ; owner's manual.
  453. ;
  454. MDMRESET:    DB    'ATE1M1Q0V1S0=0S11=55',CR,0
  455.                     ;E1=set switch 4, echo on in local cmd
  456.                     ;M1=speaker on til carrier detect
  457.                     ;Q0=set switch 3, result codes sent
  458.                     ;V1=set switch 2, word result codes
  459.                     ;S0=0=set switch 5, mdm will not answer
  460.                     ;S11=55=touchtone dial speed
  461.                     ;CR,0=send it. Must end with a zero
  462. ;
  463. CPMMSG:        CALL    JMP$ILPRT
  464.         DB    'CP/M ]',0
  465.         RET
  466. ;
  467. TPMMSG:        CALL    JMP$ILPRT
  468.         DB    'TPM ]',0
  469.         RET
  470. ;
  471. VALMSG:        CALL     JMP$ILPRT
  472.         DB    'VALDOCS ]',0
  473.         RET
  474. ;.....
  475. ; This subroutine is used in place of SENDBRK when running under VALDOCS
  476. ;
  477. SYSI$BREAK:    PUSH    D
  478.         LXI    D,07FFH        ;send break  
  479.         CALL    BACKDOOR
  480.         MVI    B,3        ;wait 300ms
  481.         CALL     JMP$TIMER
  482.         LXI    D,0700H     ;turn sendbreak off
  483.         CALL    BACKDOOR
  484.         POP     D
  485.         RET
  486. ;.....
  487. ; This subroutine is called in place of IN MODCTL1 when running under VALDOCS
  488. ;
  489. SYSI$STAT:    PUSH    D
  490.         MVI    D,3        ;Get SYSINIT serial port status byte
  491.                     ;and return it in the A register
  492.         CALL    BACKDOOR
  493.         POP    D
  494.         RET
  495. ;
  496. ;.....
  497. ; This subroutine is called in place of OUT MODDATP when running under VALDOCS
  498. ;
  499. SYSI$OUT:    PUSH    D
  500.         PUSH    PSW
  501.         MOV    E,A        ;get char to send from A and move to E
  502.         MVI    D,2        ;send it
  503.         CALL    BACKDOOR
  504.         POP    PSW
  505.         POP    D
  506.         RET
  507. ;
  508. ;......
  509. ; This subroutine is called in place of IN MODDATP when running under VALDOCS
  510. ;
  511. SYSI$IN:    PUSH    D
  512.         MVI    D,1        ;receive a character, put it in A
  513.         CALL    BACKDOOR
  514.         POP    D
  515.         RET
  516. ;.....
  517. ; This back door subroutine (BDS03) provides support for the B side of
  518. ; the 7201 MPSCC, otherwise known as the "serial port", when using VALDOCS.  
  519. ;
  520. BACKDOOR:    PUSH    H        ;Save unused registers
  521.         PUSH    B
  522.         PUSH    D        ;Save BACKDOOR call arguments
  523.         LXI    D,0AAAAH    ;Set TPM mode
  524.         CALL    BDOSMODE
  525.         POP    D        ;Get back BACKDOOR arguments
  526.         LXI    B,(3 SHL 8)+40    ;Function codes for BACKDOOR serial
  527.                     ;routines, 3 (BDS03) in the B reg
  528.                     ;and 40 in the C reg.
  529.         CALL    5        ;Call TPM
  530.         PUSH    PSW        ;Save result of BACKDOOR call
  531.         CALL    CPMMODE        ;Go back into CP/M mode
  532.         POP    PSW        ;Restore BACKDOOR result
  533.         POP    B        ;Restore registers
  534.         POP    H
  535.         RET
  536. ;.....
  537. ; Sends out the serial I/O initialization
  538. ;
  539. SIOINIT:    PUSH    H
  540.         MVI    C,MODCTL1    ;modem control port
  541.         MVI    B,MINLEN    ;length of modem init table
  542.         LXI    H,MINTBL    ;point to init table
  543.         DB    0EDH,0B3H    ;sneak in Z80 op code to OTIR the init
  544.                     ;table
  545.         POP    H
  546.         RET
  547. ;.....
  548. ; Modem initialization table.  Default settings: 8 bit words, no parity, 1 stop
  549. ; bit, transmit and receive enabled.
  550. ;
  551. MINTBL:        DB    4        ;point to register 4
  552. PARBYT:        DB    44H        ;the parity byte
  553.         DB    3        ;point to register 3
  554. RXBYT:        DB    0C1H        ;the receive byte 
  555.         DB    5        ;point to register 5
  556. TXBYT:        DB    0EAH        ;the transmit byte
  557. MINLEN:        EQU    $-MINTBL
  558. ;
  559. EVNPAR:        LXI    B,0FC03H
  560. SETPAR:        LDA    PARBYT
  561.         ANA    B
  562.         ORA    C
  563.         STA    PARBYT
  564. SETPXX:        CALL    SIOINIT    
  565.         JMP    GDLUP        ;go back for another parameter
  566. ;
  567. ODDPAR:        LXI    B,0FC01H
  568.         JMP    SETPAR
  569. ;
  570. NOPAR:        LXI    B,0FC00H
  571.         JMP    SETPAR
  572. ;
  573. ONESTOP:    LXI    B,0F304H
  574.         JMP    SETPAR
  575. ;
  576. TWOSTOP:    LXI    B,0F30CH
  577.         JMP    SETPAR
  578. ;
  579. BIT7:        MVI    A,7FH        ;load mask in A
  580.         STA    GRAFMASK    ;store it in main program TERML routine
  581.         MVI    A,41H
  582.         STA    RXBYT
  583.         MVI    A,0AAH
  584. BIT7XX:        STA    TXBYT
  585.         JMP    SETPXX
  586. ;
  587. GRAFON:        MVI    A,0FFH        ;load mask in A
  588.         STA    GRAFMASK    ;store it at TERML, lets 7th bit pass
  589.         JMP    BIT8
  590. ;
  591. GRAFOFF:    MVI    A,7FH        ;load mask in A
  592.         STA    GRAFMASK    ;store it at TERML, stops 7th bit
  593. BIT8:        MVI    A,0C1H        
  594.         STA    RXBYT
  595.         MVI    A,0EAH
  596.         JMP    BIT7XX
  597. ;.....
  598. ; Make modem's speed flag match QX-10's
  599. ;
  600. SETMSPEED:    MVI    A,CRAM        ;point to baudrate address
  601.         DI            ;stop interrupts
  602.         OUT    MOSADR        
  603.         IN    MOSDAT        ;get status byte
  604.         EI            ;ok to interrupt now
  605.         ANI    0FH        ;strip all but baudrate, set flags
  606.         LXI    H,MSPDTBL    ;load HL with table address
  607.         ADD    L        ;make the conversion
  608.         MOV    L,A        ;
  609.         JNC    SETMSPD2    ;carry? if not, jump
  610.         INR    H        ;if yes, increment MSB of pointer
  611. ;
  612. SETMSPD2:    MOV    A,M        ;move table value to register A
  613.         STA    MSPEED        ;store it at MSPEED
  614.         RET
  615. ;
  616. ;.....
  617. ; This table gives MSPEED values for QX-10 CMOS baud rate values.
  618. ; Note that lower rates do not match and approximations are used.
  619. ;
  620. MSPDTBL:    DB    0,0,0,1,3,5,6,7,8,2
  621. ;
  622. TBLADR:        DW    0
  623. ;
  624. ;******************************************************************************
  625. ;          NOTE: All above overlay routines must end before 0400H
  626. ;******************************************************************************
  627. ;
  628.         ORG    PMMIMENU    ;pop over to second patch area
  629.                     ;(overlays PMMI special menu)
  630. ;.....
  631. ; Clock speed table.  This gives the timer chip divisors for each baud rate.
  632. ; Must be in same order as MSPDTBL.
  633. ;
  634. CSPDTBL:    DW    110,1135     ; 0
  635.         DW    135,924         ; 1
  636.         DW    150,832         ; 2
  637.         DW    300,416         ; 3
  638.         DW    600,208         ; 4
  639.         DW    1200,104     ; 5
  640.         DW    2400,52         ; 6
  641.         DW    4800,26         ; 7
  642.         DW    9600,13         ; 8
  643.         DW    450,277         ; 9
  644. ;
  645. NXTARG:        CALL    SCNTOB
  646.         RC
  647. ;
  648. SCNNB:        LDAX    D
  649.         CPI    ' '
  650.         RNZ
  651.         INX    D
  652.         DCR    B
  653.         JNZ    SCNNB
  654.         STC
  655.         RET
  656. ;
  657. SCNTOB:        LDAX    D
  658.         CPI    ' '
  659.         RZ
  660.         RC
  661.         INX    D
  662.         DCR    B
  663.         JNZ    SCNTOB
  664.         STC
  665.         RET
  666.  
  667. ;
  668. KEYBUF:        DB    10
  669.         DB    0,0,0,0,0,0
  670.         DB    0,0,0,0,0,0
  671. ;..... 
  672. ; Send a string to the Smartmodem
  673. ;
  674. SEND:        MOV    A,M        ;Get a character
  675.         INX    H
  676.         ORA    A        ;End of the string?
  677.         RZ
  678.         MOV    C,A        ;No, send it
  679.         CALL    PUT
  680.         CALL    JMP$INMODEM    ;Eat echo
  681.         JMP    SEND
  682. ;
  683. PUT:        CALL    IN$MODCTL1    ;Get modem status
  684.         CALL    ANI$MODSNDB    ;Test send bits
  685.         CALL    CPI$MODSNDR
  686.         JNZ    PUT
  687.         MOV    A,C
  688.         JMP    OUT$MODDATP
  689. ;.....
  690. ; The following routine changes the baud rate, parity and word length for
  691. ; the QX-10 from the SET menu.
  692. ;
  693. SETUPR:        LDAX    D        ;Look at passed-in byte count
  694.         CPI    5        ;Enuf for possible baud rate?
  695.         JC    AGAIN        ;No, prompt for one
  696.         MOV    B,A        ;Save byte count
  697.         INX    D        ;Point to first byte
  698.         CALL    NXTARG        ;Skip to next argument
  699.         MOV    A,B
  700.         JNC    SETUP1
  701. ;
  702. AGAIN:        CALL    JMP$ILPRT
  703.         DB    'Enter Baud Rate and/or Options: ',0
  704.         LXI    D,KEYBUF
  705.         CALL    JMP$INBUF    ;read baud rate from console
  706.         LXI    D,KEYBUF+1
  707.         LDAX    D
  708.         INX    D
  709. ;
  710. SETUP1:        MOV    L,A        ;Force null at end of buffer
  711.         MVI    H,0        
  712.         DAD    D
  713.         MVI    M,0
  714.         LXI    H,0
  715. ;
  716. GDLUP:        LDAX    D
  717.         INX    D
  718.         ORA    A
  719.         JZ    GDONE
  720.         CPI    ' '        ;Ignore spaces
  721.         JZ    GDLUP
  722.         SUI    '0'        ;Try for digit
  723.         JC    BADRATE
  724.         CPI    10
  725.         JNC    BADRATE
  726.         MOV    B,H
  727.         MOV    C,L
  728.         DAD    H
  729.         DAD    H
  730.         DAD    B
  731.         DAD    H
  732.         MVI    B,0
  733.         MOV    C,A
  734.         DAD    B
  735.         JMP    GDLUP
  736. ;
  737. BADRATE:    ADI    '0'        ;Fix bias from conversion routine
  738.         CPI    'E'        ;Check option letters for
  739.         JZ    EVNPAR        ;Even parity
  740.         CPI    'O'
  741.         JZ    ODDPAR        ;Odd parity
  742.         CPI    'N'
  743.         JZ    NOPAR        ;No parity
  744.         CPI    'S'
  745.         JZ    ONESTOP        ;One stop bit
  746.         CPI    'T'
  747.         JZ    TWOSTOP        ;Two stop bits
  748.         CPI    'A'
  749.         JZ    BIT7        ;ASCII mode (7 data bits)
  750.         CPI    'B'
  751.         JZ    GRAFOFF        ;Binary mode (8 data bits) with 7th bit
  752.                     ;masked
  753.         CPI    'G'
  754.         JZ    GRAFON        ;8 data bits, but with no masking to
  755.                     ;permit use of QX-10 graphics in
  756.                     ;terminal mode
  757.         CALL    JMP$ILPRT    ;Anything else gets error
  758.         DB    CR,LF,'[ Invalid rate ]',CR,LF,0
  759.         JMP    AGAIN
  760. ;
  761. GDONE:        MOV    A,H
  762.         ORA    L
  763.         JZ    QUIT
  764. ;.....
  765. ; Enter here with baud rate in HL to set baud rate of timer.
  766. ;
  767. FINDRATE:    PUSH    H        ;save baud rate
  768.         LXI    H,CSPDTBL    ;load table address
  769.         SHLD    TBLADR        ;store it there
  770.         POP    H        ;get baud back
  771.         LXI    B,0A00H        
  772. ;
  773. CLP:        PUSH    H
  774.         LHLD    TBLADR        ;get address back
  775.         MOV    E,M        ;move value to E
  776.         INX    H        ;advance pointer
  777.         MOV    D,M        ;other half in D
  778.         INX    H
  779.         XTHL            
  780.         XCHG            ;switch
  781.         ORA    A        ;prepare for true subtract by clearing
  782.         DB    0EDH,52H    ;sneak in Z80 op code to SBC HL,DE
  783.         XCHG            ;switch again
  784.         XTHL
  785.         JZ    DOIT
  786.         INX    H
  787.         INX    H
  788.         SHLD    TBLADR
  789.         POP    H
  790.         INR    C
  791.         DCR    B
  792.         JNZ    CLP
  793.         JMP    BADRATE
  794. ;
  795. DOIT:        POP    D        
  796.         MVI    A,0B6H
  797.         OUT    TPORTS
  798.         MOV    A,M
  799.         INX    H
  800.         OUT    TPORTC
  801.         MOV    A,M
  802.         OUT    TPORTC
  803.         CALL    IN$MODDATP
  804.         CALL    IN$MODDATP
  805.         MVI    A,CRAM
  806.         DI            ;Disable interrupts
  807.         OUT    MOSADR
  808.         MOV    A,C
  809.         OUT    MOSDAT
  810.         EI            ;Enable interrupts
  811. ;
  812. QUIT:        JMP    SETMSPEED
  813. ;.....
  814. ; This special menu is unavailable without putting the actual address of
  815. ; SPCLMENU (in the basic program) in the overlay above at the PMMIMENU equate.
  816. ;
  817. SPCLMENU:    CALL    JMP$NXTSCRN
  818.         CALL    JMP$ILPRT
  819.         DB    '        Additional SET options for QX-10',cr,lf,lf
  820.         DB    '  Parity:',cr,lf
  821.         DB    '    E - Even',cr,lf
  822.         DB    '    O - Odd',cr,lf
  823.         DB    '    N - None',cr,lf,lf
  824.         DB    '  Stop bits:',cr,lf
  825.         DB    '    S - Single (1)',cr,lf
  826.         DB    '    T - Two    (2)',cr,lf,lf
  827.         DB    '  Data bits (word length):',cr,lf
  828.         DB    '    A - ASCII mode (7 data bits)',cr,lf
  829.         DB    '    B - Binary mode (8 data bits)',cr,lf
  830.         DB    '    G - Graphics mode (8 data bits, no masking)'
  831.         DB    CR,LF,LF
  832.         DB    '  Examples:',cr,lf
  833.         DB    '    SET 300ETA',cr,lf
  834.         DB    '    SET B',cr,lf
  835.         DB    '    SET NSG 1200',cr,lf
  836.         DB    0
  837.         RET
  838. ;
  839. ;******************************************************************************
  840. ;    NOTE:  THE ABOVE MUST TERMINATE PRIOR TO 0CBB FOR MDM730 THRU MDM740.
  841. ;******************************************************************************
  842. ;
  843. ;.....
  844. ; This routine modifies the basic program to call CLOCKSET before timing rates
  845. ; are computed.  The overlayed bytes (LXI H,0) are placed at the beginning
  846. ; of CLOCKSET.
  847. ;    
  848.         ORG    START
  849.         CALL    CLOCKSET
  850. ;.....
  851. ; This subroutine overlays BYEBYE of basic program to add capability of send-
  852. ; ing correct signoff messages as program exits through BYE command.
  853. ;     
  854.             ORG    BYEBYE+20
  855.         DB    CR,LF,'[ Exit to ',0
  856.         LDA    TPMFLG        ;is this CP/M or TPM?
  857.         ORA    A
  858.         CZ    CPMMSG        ;if CP/M, go get message
  859.         CALL    BYEBYE1        ;go continue this
  860. ;
  861.         END    
  862. ;