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 / BEEHIVE / COMMS / IMP-OV5B.LBR / I2MDA-5.AZM / I2MDA-5.ASM
Assembly Source File  |  2000-06-30  |  22KB  |  822 lines

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