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 / IMP / I2MDA-3.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  20KB  |  808 lines

  1.  
  2. ; I2MDA-3.ASM - Morrow Micro-Decision overlay file for IMP - 06/01/87
  3. ;
  4. ;        MD-3 8281, MD-5 or MD-121 Z80 SIO
  5. ;
  6. ; Version for ALL Micro-Decisions, including hard disk models, ROM v1.x
  7. ; machines (no parallel port), and ROM revision 2.x and 3.x machines
  8. ; with (with parallel port).
  9. ;
  10. ; If you are using this overlay for the MD-HD computer (MD-5, -11, etc.)
  11. ; you have two additional options in the SET command: AUX and P/M.  When
  12. ; using SET AUX, it selects the Auxilliary port as your modem port.  The
  13. ; SET P/M selects the Printer/Modem port.  Select either the MDHDA or
  14. ; the MDHDP equate below as the DEFAULT modem port.  You can always use
  15. ; the SET command later to swap ports.
  16. ;                          - Paul Bartholomew
  17. ;-----------------------------------------------------------------------
  18. ;
  19. ; You will want to look this file over carefully. There are a number of
  20. ; options that you can use to configure the program to suit your taste.
  21. ; This file adapts all of the MD series computers. Be sure and select
  22. ; which model you have below.
  23. ;
  24. ; Edit this file for your preferences then follow the "TO USE:" example
  25. ; shown below.
  26. ;
  27. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  28. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  29. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  30. ; (The ESC will automatically be typed with no CTL-character present.)
  31. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  32. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  33. ; looking at the function key table, typing CTL-Z in command mode, etc.
  34. ;
  35. ; Use the "SET" command to change the baudrate when desired.  The value
  36. ; at MSPEED controls the baudrate when the program is first called up.
  37. ;
  38. ;    TO USE: First edit this file filling in answers for your own
  39. ;        equipment.  Then assemble with ASM.COM or equivalent
  40. ;        assembler.  Then use MLOAD to merge into the main file:
  41. ;
  42. ;        MLOAD IMP.COM=IMP.COM,I2MDA-x.HEX
  43. ;
  44. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  45. ;
  46. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  47. ;    v3        IMP245 to use it.            - Irv Hoff
  48. ;
  49. ; 09/24/85  Fixed bug with MD-HD overlay trashing the BC registers in
  50. ;    v2     the I/O routines.    There are now only 3 or 4 bytes left
  51. ;        in the MD-HD overlay before it goes past the 0400h limit.
  52. ;                        - Paul Bartholomew
  53. ; 09/23/85 - Written to work with IMP        - Paul Bartholomew
  54. ;    v1
  55. ;
  56. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  57. ;
  58. ;
  59. YES    EQU    0FFH
  60. NO    EQU    0
  61. ;
  62. ;
  63. ; Set ONE AND ONLY ONE of the following to YES, all the rest to NO:
  64. ;
  65. MD3R1    EQU    NO    ; Set to YES for MD-2/3 with Revision 1.x ROM
  66. MD3R2    EQU    NO    ; Set to YES for MD-2/3 with Revision 2.x or 3.x ROM
  67. MDHDA    EQU    NO    ; Set to YES for MD-HD using Auxilliary port
  68. MDHDP    EQU    YES    ; Set to YES for MD-HD using Printer/Modem port
  69. ;
  70. ;
  71. ; EQUates for MD-2/3 all ROM's
  72. ;
  73.      IF    (MD3R1 OR MD3R2)
  74. MDDATP    EQU    0FEH    ; Printer/Modem DATA port
  75. MDCTL1    EQU    0FFH    ; Printer/Modem STATUS port
  76. MDRCV    EQU    02H    ; Modem receive ready
  77. MDSND    EQU    01H    ; Modem send ready bit
  78. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  79.      ENDIF
  80. ;
  81. ;
  82. ; CTC EQUates for MD-2/3 ROM 2.x and 3.x
  83. ;
  84.      IF    MD3R2
  85. BPORT    EQU    0F2H
  86. CPORT    EQU    0F3H
  87. CTCSEL    EQU    0BEH
  88.      ENDIF
  89. ;
  90. ;
  91. ; EQUates for MD-HD using Auxilliary port
  92. ;
  93.      IF    MDHDA
  94. PORT    EQU    70H    ; Auxilliary BASE port
  95. BRPORT    EQU    50H    ; Baud rate port
  96. BMODE    EQU    3EH    ; Mode
  97.      ENDIF
  98. ;
  99. ;
  100. ; EQUates for MD-HD using Printer/Modem port
  101. ;
  102.      IF    MDHDP
  103. PORT    EQU    62H    ; Printer/Modem BASE port
  104. BRPORT    EQU    51H    ; Baud rate port
  105. BMODE    EQU    7EH    ; Mode
  106.      ENDIF
  107. ;
  108. ;
  109. ;EQUates for MD-HD
  110. ;
  111.      IF    (MDHDA OR MDHDP)
  112. MDCTL1    EQU    PORT+1    ; Modem control port
  113. MDDATP    EQU    PORT    ; Modem data port
  114. MOPORT    EQU    53H    ; Mode port
  115. MDRCV    EQU    01H    ; Modem receive ready
  116. MDSND    EQU    04H    ; Modem send ready bit
  117. MDTXE    EQU    01H    ; Modem send buffer empty, holding buffer empty
  118.      ENDIF
  119. ;
  120. ;-----------------------------------------------------------------------
  121. ;
  122. ESC    EQU    '['-40H    ; ^[ = Escape
  123. BELL    EQU    'G'-40H    ; ^G = Bell character
  124. LF    EQU    'J'-40H    ; ^J = Linefeed
  125. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  126. CR    EQU    'M'-40H    ; ^M = Carriage return
  127. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  128. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  129. ;
  130. ;
  131. ;-----------------------------------------------------------------------
  132. ;
  133. ;
  134.     ORG    0100H
  135. ;
  136. ;
  137.     DS    3    ; Skip the data area below
  138. ;
  139. ;
  140. ; These routines and equates are at the beginning of the program so
  141. ; they can be patched by a monitor or overlay file without re-assembling
  142. ; the program.
  143. ;
  144. MSPEED:     DB    5    ; 1=300 5=1200 6=2400 7=4800 8=9600 9=19200    103H
  145. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  146. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  147. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  148. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  149. RESVD1:     DB    NO    ; Reserved for special modems            108H
  150. RESVD2:     DB    NO    ; Reserved for special modems            109H
  151. ;
  152. ;
  153. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  154. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  155.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  156. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  157.             ;   default time to send character in ter-
  158.             ;   minal mode file transfer for slow BBS
  159. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  160.             ;   default time for extra wait after CRLF
  161.             ;   in terminal mode file transfer
  162. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  163. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  164. ;.....
  165. ;
  166. ;
  167. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  168.             ;   mode (normally added by remote echo)
  169. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  170. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  171. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  172. ;.....
  173. ;
  174. ;
  175. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  176. EXITCHR: DB    'E'    ; Exit character                115H
  177. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  178. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  179. LOGCHR:     DB    'L'    ; Send logon                    118H
  180. LSTCHR:     DB    'P'    ; Toggle printer                119H
  181. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  182. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  183. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  184. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  185. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  186. ;.....
  187. ;
  188. ;
  189. ; Handles in/out ports for data and status
  190. ;
  191. I$MDCTL1:
  192.       JMP    IMDC        ;                    11FH
  193.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  194. ;
  195. I$MDTXE:
  196.       JMP    IMDT        ;                    129H
  197.       DB    0,0,0,0,0,0,0    ;                    12CH
  198. ;
  199. I$MDDATP:
  200.       JMP    IMDD        ;                    133H
  201.       DB    0,0,0,0,0,0,0    ;                    136H
  202. ;
  203. O$MDDATP:
  204.       JMP    OMDD        ;                    13DH
  205.       DB    0,0,0,0,0,0,0    ;                    140H
  206. ;.....
  207. ;
  208. ;
  209. A$MDRCV:  ANI    MDRCV        ;                    147H
  210.       RET            ;                    149H
  211. ;
  212. C$MDRCV:  CPI    MDRCV        ;                    14AH
  213.       RET            ;                    14CH
  214. ;
  215. A$MDSND:  ANI    MDSND        ;                    14DH
  216.       RET            ;                    14FH
  217. ;
  218. C$MDSND:  CPI    MDSND        ;                    150H
  219.       RET            ;                    152H
  220. ;
  221. A$MDTXE:  ANI    MDTXE        ;                    153H
  222.       RET            ;                    155H
  223. ;
  224. C$MDTXE:  CPI    MDTXE        ;                    156H
  225.       RET            ;                    158H
  226. ;.....
  227. ;
  228. ;
  229. ; Special exit vector, used by some computers to reset interrupt vectors
  230. ;
  231. J$EXITVEC:RET            ;                    159H
  232.       DB    0,0        ;                    15AH
  233. ;.....
  234. ;
  235. ;
  236. ; Jump vectors needed by each overlay
  237. ;
  238. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  239. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  240. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  241. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  242. ;.....
  243. ;
  244. ;
  245. ; "AT" command strings, can be replaced in individual overlay if needed
  246. ;
  247. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  248. J$STRNG1: DS    3        ; 2400 bps "AT" string            16B:IMP
  249. ;
  250. ;
  251. ; Next fourteen lines should not be changed by user overlay as these go
  252. ; to specific locations in the main program, not in the overlay.
  253. ;
  254. ;
  255. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  256. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  257. J$DIAL:      DS    3        ; Start of dialing routine        174H
  258. J$DSCONT: DS    3        ; Terminates modem use            177H
  259. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  260. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  261. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  262. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  263. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  264. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  265. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  266. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  267. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  268. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  269. J$NEW2:      DB    0,0,0        ; For future needs            198H
  270. ;.....
  271. ;
  272. ;
  273. ; For 2400 bps auto-stepdown units
  274. ;
  275. MANUAL:      DB    0        ; For manual selection flag        19BH
  276. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  277. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  278. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  279. ;.....
  280. ;
  281. ;
  282. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  283. ;
  284. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  285.       DB    'Version for '    ;                    1AAH
  286.  
  287.        IF    MD3R1
  288.       DB    'Morrow MD-2/3 with Revision 1.x ROM'
  289.        ENDIF
  290.  
  291.        IF    MD3R2
  292.       DB    'Morrow MD-2/3 with Revision 2.x or 3.x ROM'
  293.        ENDIF
  294.  
  295.        IF    MDHDA
  296.       DB    'Morrow MD-HD using Auxilliary Port'
  297.        ENDIF
  298.  
  299.        IF    MDHDP
  300.       DB    'Morrow MD-HD using Printer/Modem Port'
  301.        ENDIF
  302.  
  303.       DB    CR,LF,0
  304.       RET
  305. ;.....
  306. ;
  307. ;
  308. ;-----------------------------------------------------------------------
  309. ;
  310. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  311. ;     end of your last routine should terminate by 0400H (601 bytes
  312. ;     available after start of SYSVER).
  313. ;
  314. ;-----------------------------------------------------------------------
  315. ;
  316. ; You can put in a message at this location which can be called up with
  317. ; (special character-L).  You can put in several lines.  End with a 0.
  318. ;
  319. LOGON:    DB    'This is a Morrow Micro Decision computer',CR,LF,0
  320. ;
  321. ;-----------------------------------------------------------------------
  322. ;
  323. ; Modem I/O for MD-2/3 all ROM's:
  324. ;
  325. ; Input STATUS to A
  326. ;
  327.      IF    MD3R1 OR MD3R2
  328. IMDC:    IN    MDCTL1
  329.     RET
  330. ;.....
  331. ;
  332. ;
  333. ; Check for transmit ready
  334. ;
  335. IMDT:
  336.     IN    MDCTL1
  337.     RET
  338. ;.....
  339. ;
  340. ;
  341. ; Input byte from DATA port to A
  342. ;
  343. IMDD:
  344.     MVI    A,37H
  345.     OUT    MDCTL1
  346.     IN    MDDATP
  347.     RET
  348. ;.....
  349. ;
  350. ;
  351. ; Output byte in A to DATA port
  352. ;
  353. OMDD:
  354.     OUT    MDDATP
  355.     RET
  356.      ENDIF            ; MD3R1 OR MD3R2
  357. ;
  358. ;-----------------------------------------------------------------------
  359. ;
  360. ; Modem I/O for MD-HD using either port:
  361. ;
  362. ; BASE PORT - Changed by SET
  363. ;
  364. ; DON'T CHANGE THE ORDER OF THE FOLLOWING 3 BYTES!
  365. ; ------------------------------------------------
  366. ;
  367.      IF    MDHDA OR MDHDP
  368. BSPRT:    DB    PORT
  369. BRPRT:    DB    BRPORT
  370. BMD:    DB    BMODE
  371. ;.....
  372. ;
  373. ;
  374. ; Input STATUS to 'A' register
  375. ;
  376. IMDC:    PUSH    B
  377.     LDA    BSPRT
  378.     MOV    C,A
  379.     INR    C
  380.     MVI    A,10H        ; Register 0, reset interrupts
  381.     DW    79EDH        ; Z80 opcodes for  OUT    (C),A
  382.     DW    78EDH        ; Z80 opcodes for  IN    A,(C)
  383.     POP    B
  384.     RET            ; IN modem control port
  385. ;.....
  386. ;
  387. ;
  388. ; Check for transmit ready
  389. ;
  390. IMDT:    PUSH    B
  391.     LDA    BSPRT
  392.     MOV    C,A
  393.     INR    C
  394.     MVI    A,11H        ; Read register 1, for "all sent"
  395.     DW    79EDH        ; Z80 opcodes for  OUT    (C),A
  396.     DW    78EDH        ; Z80 opcodes for  IN    A,(C)
  397.     POP    B
  398.     RET
  399. ;.....
  400. ;
  401. ;
  402. ; Input byte from DATA port to A
  403. ;
  404. IMDD:    PUSH    B
  405.     LDA    BSPRT
  406.     MOV    C,A
  407.     DW    78EDH        ; Z80 opcodes for  IN    A,(C)
  408.     POP    B
  409.     RET
  410. ;....
  411. ;
  412. ;
  413. ; Output byte in A to DATA port
  414. ;
  415. OMDD:
  416.     PUSH    B
  417.     PUSH    PSW
  418.     LDA    BSPRT
  419.     MOV    C,A
  420.     POP    PSW
  421.     DW    79EDH        ; Z80 opcodes for  OUT    (C),A
  422.     POP    B
  423.     RET
  424.      ENDIF            ; MDHDA OR MDHDP
  425. ;
  426. ;-----------------------------------------------------------------------
  427. ;
  428. ;
  429. ; This routine sets a 300 ms break tone for the 8251 I/O
  430. ;
  431.      IF    MD3R1 OR MD3R2    ; 8251A
  432. SENDBRK:
  433.     MVI    A,3FH        ; DTR normal, send break tone
  434.     JMP    GOODBYE+2    ; Send the break tone
  435.      ENDIF            ; MD3R1 OR MD3R2
  436. ;
  437. ;
  438. ; This routine sets a 300 ms break tone for the Z80 SIO
  439. ;
  440.      IF    MDHDA OR MDHDP    ; Z80 SIO
  441. SENDBRK:
  442.     MVI    A,0F8H        ; DTR normal, send break tone
  443.     STA    GOODBYE1+1    ; Reset value temporarily
  444.     CALL    GOODBYE        ; Send the break tone
  445.     MVI    A,78H        ; Restore original value
  446.     STA    GOODBYE1+1
  447.     RET
  448.      ENDIF            ; MDHDA OR MDHDP
  449. ;.....
  450. ;
  451. ;
  452. ; This routine sets DTR low for 300 ms to disonnect the phone
  453. ;
  454.      IF    MD3R1 OR MD3R2    ; 8251A
  455. GOODBYE:
  456.     MVI    A,3DH        ; Send break, turn off DTR
  457.     OUT    MDCTL1        ; Send to status port
  458.     MVI    B,3        ; Delay 300 ms to hang up phone
  459.     CALL    J$TIMER
  460.     MVI    A,37H        ; Normal send/receive with DTR
  461.     OUT    MDCTL1        ; Send to status port
  462.     RET
  463.      ENDIF            ; MD3R1 OR MD3R2
  464. ;
  465.      IF    MDHDA OR MDHDP    ; Z80 SIO
  466. GOODBYE:
  467.     LDA    BSPRT
  468.     MOV    C,A
  469.     INR    C
  470.     MVI    A,5
  471.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  472. ;
  473. GOODBYE1:
  474.     MVI    A,78H        ; Turn off DTR
  475.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  476.     MVI    B,3        ; Wait for 300 ms
  477.     PUSH    B
  478.     CALL    J$TIMER
  479.     POP    B
  480.     MVI    A,5
  481.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  482.     MVI    A,0E8H        ; Restore normal, 8 bits, DTR on, etc.
  483.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  484.     POP    B        ; Restore the stack
  485.     RET
  486.      ENDIF            ; MDHDA OR MDHDP
  487. ;
  488. ;-----------------------------------------------------------------------
  489. ;
  490. ; MD-2/3 ROM 1.x initialization
  491. ;
  492.      IF    MD3R1        ; 8251A
  493. INITMOD:
  494.     MVI    A,087H        ; Insure out of mode
  495.     OUT    MDCTL1        ; Modem status port
  496.     OUT    MDCTL1        ; Slight extra delay
  497.     MVI    A,40H        ; Initialize USART
  498.     OUT    MDCTL1        ; Modem status port
  499. ;
  500. INITMOD1:
  501.     MVI    A,17H        ; DTR, RCV, XMT, error reset
  502.     OUT    MDCTL1        ; Modem status port
  503.     IN    MDDATP        ; Clear data port
  504.     LDA    MSPEED        ; Get the selected value
  505.     CPI    9+1
  506.     JNC    STUPR1        ; If invalid, ask for baud, else default
  507.     JMP    GETBAUD
  508.      ENDIF            ; MD3R1
  509. ;
  510. ;-----------------------------------------------------------------------
  511. ;
  512. ; MD-2/3 ROM 2.x and 3.x initialization
  513. ;
  514. ; Makes sure we are ok on the 2nd serial port
  515. ;
  516.      IF    MD3R2
  517. INITMOD:
  518.     MVI    A,087H
  519.     OUT    MDCTL1
  520.     MVI    A,40H
  521.     OUT    MDCTL1
  522.     MVI    A,4EH
  523.     OUT    MDCTL1
  524.     MVI    A,17H
  525.     OUT    MDCTL1
  526. ;
  527. ;
  528. ; Sets default baudrate to MSPEED selection on CTC
  529. ;
  530. INITMOD1:
  531.     LDA    MSPEED        ; Get the selected value
  532.     CPI    9+1
  533.     JNC    STUPR1        ; If invalid, ask for baud, else
  534.     JMP    GETBAUD        ; set to default
  535.      ENDIF            ; MD3R2
  536. ;
  537. ;-----------------------------------------------------------------------
  538. ;
  539. ; Morrow MD-HD initialization
  540. ;
  541.      IF    MDHDA OR MDHDP    ; Z80 SIO
  542. INITMOD:
  543.     PUSH    B
  544.     LDA    BSPRT
  545.     MOV    C,A
  546.     INR    C
  547.     MVI    A,0        ; Select register 0
  548.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  549.     MVI    A,18H        ; Throw out of mode
  550.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  551.     MVI    A,4        ; Select register 4
  552.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  553.     MVI    A,44H        ; 16x, 1 stop, parity off (44=1, 4C=2)
  554.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  555.     MVI    A,3        ; Select register 3
  556.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  557.     MVI    A,0C1H        ; Enable receive
  558.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  559.     MVI    A,5        ; Select register 5
  560.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  561.     MVI    A,0E8H        ; Enable send, 'DTR', 'RTS'
  562.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  563. ;
  564.     POP    B
  565.     LDA    MSPEED        ; Get the selected value
  566.     CPI    9+1
  567.     JNC    STUPR1        ; If invalid, ask for baud, else
  568.     JMP    GETBAUD        ; set to default
  569.      ENDIF            ; MDHDA OR MDHDP
  570. ;.....
  571. ;
  572. ;
  573. ; Setup routine to allow changing modem speed with the SET command.
  574. ;
  575. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  576.     JNC    STUPR2
  577. ;
  578. STUPR1:    CALL    J$ILPRT
  579.     DB    'Input Baud Rate '
  580. ;
  581.      IF    MD3R1
  582.     DB    '(300,1200): ',0
  583.      ENDIF            ; MD3R1
  584. ;
  585.      IF    MD3R2
  586.     DB    '(300,1200,2400,4800,9600): ',0
  587.      ENDIF            ; MD3R2
  588. ;
  589.      IF    MDHDA OR MDHDP
  590.     DB    '(300,1200,2400,4800,9600,19200,P/M,AUX): ',0
  591.      ENDIF            ; MDHDA OR MDHDP
  592. ;
  593.     LXI    D,BAUDBUF    ; Point to new input buffer
  594.     CALL    J$INBUF
  595.     CALL    J$CRLF
  596.     LXI    D,BAUDBUF+2
  597. ;...
  598. ;
  599. ;
  600. STUPR2:    CALL    J$INLNCP
  601.     DB    '300',0
  602.     JNC    OK300
  603. ;
  604.     CALL    J$INLNCP
  605.     DB    '1200',0
  606.     JNC    OK1200
  607. ;
  608.      IF    NOT MD3R1
  609.     CALL    J$INLNCP
  610.     DB    '2400',0
  611.     JNC    OK2400
  612. ;
  613.     CALL    J$INLNCP
  614.     DB    '4800',0
  615.     JNC    OK4800
  616. ;
  617.     CALL    J$INLNCP
  618.     DB    '9600',0
  619.     JNC    OK9600
  620.      ENDIF            ; NOT MD3R1
  621. ;
  622.      IF    MDHDA OR MDHDP
  623.     CALL    J$INLNCP
  624.     DB    '19200',0
  625.     JNC    OK19200
  626. ;
  627.     CALL    J$INLNCP
  628.     DB    'P/M',0
  629.     JNC    OKPM
  630. ;
  631.     CALL    J$INLNCP
  632.     DB    'AUX',0
  633.     JNC    OKAUX
  634.      ENDIF            ; MDHDA OR MDHDP
  635. ;
  636.     CALL    J$ILPRT        ; All matches failed, tell operator
  637.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  638.     JMP    STUPR1        ; Try again
  639. ;
  640. ;-----------------------------------------------------------------------
  641. ;
  642. ;Baud rate code for MD-2/3 ROM 1.x
  643. ;
  644.      IF    MD3R1
  645. OK300:    MVI    A,1        ; MSPEED 300 baud value
  646.     JMP    GETBAUD        ; Go load them
  647. ;
  648. OK1200:    MVI    A,5        ; MSPEED 1200 bps value
  649.     JMP    GETBAUD        ; Go load th;em
  650. ;
  651. OK2400:    JMP    OK1200        ; Doesn't support 2400 bps
  652. ;...
  653. ;
  654. ;
  655. GETBAUD:STA    MSPEED
  656.     MVI    B,4FH        ; Divide by 64 for 300 baud
  657.     CPI    1
  658.     JZ    LOADBD
  659.     MVI    B,04EH        ; Divide by 16 for 1200 bps (default)
  660. ;
  661. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  662.     MOV    A,B        ; Get baudrate byte
  663.     OUT    MDCTL1        ; Modem status port
  664.     IN    MDDATP        ; Read in any garbage
  665.     RET
  666.      ENDIF            ; MD3R1
  667. ;
  668. ;-----------------------------------------------------------------------
  669. ;
  670. ; Common baud rate code for MD-2/3 ROM's 2.x and 3.x and MD-HD
  671. ;
  672.      IF    NOT MD3R1
  673. OK300:    MVI    A,1
  674.     JMP    GETBAUD
  675. ;
  676. OK1200:    MVI    A,5
  677.     JMP    GETBAUD
  678. ;
  679. OK2400:    XRA    A
  680.     STA    MANUAL        ; Reset to maximum auto-speed
  681.     MVI    A,6
  682.     JMP    GETBAUD
  683. ;
  684. OK4800:    MVI    A,7
  685.     JMP    GETBAUD
  686. ;
  687. OK9600:    MVI    A,8
  688.     JMP    GETBAUD
  689. ;
  690. OK19200:MVI    A,9
  691.      ENDIF
  692. ;
  693. ;-----------------------------------------------------------------------
  694. ;
  695. ; Code to swap ports on the MD-HD
  696. ;
  697.      IF    MDHDA OR MDHDP
  698. OKPM:    MVI    A,062H
  699.     STA    BSPRT
  700.     LXI    H,7E51H
  701.     SHLD    BRPRT
  702.     JMP    INITMOD
  703. ;
  704. OKAUX:
  705.     MVI    A,070H
  706.     STA    BSPRT
  707.     LXI    H,3E50H
  708.     SHLD    BRPRT
  709.     JMP    INITMOD
  710.      ENDIF
  711. ;
  712. ;-----------------------------------------------------------------------
  713. ;
  714. ; Common baud rate code for MD-2/3 ROM's 2.x and 3.x and MD-HD
  715. ;
  716.      IF    NOT MD3R1
  717. GETBAUD:PUSH    PSW
  718.     LXI    H,BDTAB
  719.     ADD    A        ; *2
  720.     MOV    E,A
  721.     MVI    D,0
  722.     DAD    D
  723.     MOV    A,M
  724.     INX    H
  725.     MOV    H,M
  726.     MOV    L,A        ; HL = baud rate divisor
  727.     POP    PSW
  728.     JMP    LOADBD
  729.      ENDIF            ; NOT MD3R1
  730. ;
  731. ;-----------------------------------------------------------------------
  732. ;
  733. ; Baud rate code for MD-2/3 ROM's 2.x and 3.x
  734. ;
  735.      IF    MD3R2
  736. LOADBD:    STA    MSPEED
  737.     MVI    A,CTCSEL
  738.     OUT    CPORT
  739.     MOV    A,L
  740.     OUT    BPORT
  741.     MOV    A,H
  742.     OUT    BPORT
  743.     RET
  744.      ENDIF
  745. ;
  746. ;-----------------------------------------------------------------------
  747. ;
  748. ; Baud rate code for MD-HD
  749. ;
  750.      IF    (MDHDA OR MDHDP)
  751. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  752.     LDA    BMD
  753.     OUT    MOPORT
  754.     PUSH    B
  755.     LDA    BRPRT
  756.     MOV    C,A
  757.     MOV    A,L
  758.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  759.     MOV    A,H
  760.     DW    79EDH        ; Z80 opcode for  OUT  (C),A
  761.     POP    B
  762.     RET
  763.      ENDIF            ;(MDHDA OR MDHDP)
  764. ;
  765. ;-----------------------------------------------------------------------
  766. ;
  767. ; Table of baud rate values for MD-2/3 ROM's 2.x and 3.x
  768. ;
  769.      IF    MD3R2
  770. BDTAB:    DW    0        ; 110 baud (not supported)
  771.     DW    417        ; 300 baud
  772.     DW    0        ; 450 baud (not supported)
  773.     DW    0        ; 600 baud (not supported)
  774.     DW    0        ; 710 baud (not supported)
  775.     DW    104        ; 1200 bps
  776.     DW    52        ; 2400 bps
  777.     DW    26        ; 4800 bps
  778.     DW    13        ; 9600 bps
  779.     DW    0        ; 19200 bps (not supported)
  780.      ENDIF            ; MD3R2
  781. ;
  782. ;-----------------------------------------------------------------------
  783. ;
  784. ; Table of baud rate values for MD-HD
  785. ;
  786.      IF    MDHDA OR MDHDP
  787. BDTAB:    DW    0        ; 110 baud (not supported)
  788.     DW    417*2        ; 300 baud
  789.     DW    0        ; 450 baud (Not supported)
  790.     DW    0        ; 600 baud (not supported)
  791.     DW    0        ; 710 baud (Not supported)
  792.     DW    104*2        ; 1200 bps
  793.     DW    52*2        ; 2400 bps
  794.     DW    26*2        ; 4800 bps
  795.     DW    13*2        ; 9600 bps
  796.     DW    13        ; 19200 bps
  797.      ENDIF            ; MDHDA OR MDHDP
  798. ;
  799. BAUDBUF:DB    10,0,0,0,0,0
  800.     DB    0,0,0,0,0
  801. ;
  802. ;                   end
  803. ;-----------------------------------------------------------------------
  804. ;
  805. ; NOTE: Must terminate prior to 0400H
  806. ;
  807.     END
  808.