home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol272 / i2am-2.aqm / I2AM-2.ASM
Encoding:
Assembly Source File  |  1986-06-11  |  11.6 KB  |  393 lines

  1.  
  2. ; I2AM-1.ASM - AMPRO "Little Board" overlay file for IMP - 10/27/85
  3. ;
  4. ;     Z80 DART and 8430 CTC timer and 2.000 MHz clock
  5. ;
  6. ; This overlay adapts the IMP modem program to the AMPRO Series 100
  7. ; computer with the Z80 DART serial port "B" and the Z80 CTC baud rate
  8. ; generator.
  9. ;
  10. ; Important:  This computer does not use a clock that divides
  11. ;          to the exact baud rate desired.  For instance,
  12. ;          2400 bps comes out 2403.846 Hz.  A 1.9968 xtal
  13. ;          would be needed.    9600 bps is actually 9615.385 Hz.
  14. ;
  15. ;
  16. ;          CTS and RTS are used with the AMPRO computer as
  17. ;          it does not support DTR or DCD - however it puts
  18. ;          CTS on pin 20 which historically holds the DTR.
  19. ;          Just be sure to drop CTS to hang up the phone.
  20. ;
  21. ;          You will need to use the following wiring circuit:
  22. ;
  23. ;            Modem       Ampro
  24. ;            -----       -----
  25. ;            pin 2       pin 3
  26. ;            pin 3       pin 2
  27. ;            pin 7       pin 7
  28. ;            pin 8       pin 20
  29. ;            pin 20       pin 5
  30. ;
  31. ; The Ampro DB-25 connector is shown wired per factory standards.
  32. ;
  33. ;-----------------------------------------------------------------------
  34. ;
  35. ; Edit this file for your preferences then follow the "TO USE:" example
  36. ; shown below.
  37. ;
  38. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  39. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  40. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  41. ; (The ESC will automatically be typed with no CTL-character present.)
  42. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  43. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  44. ; looking at the function key table, typing CTL-Z in command mode, etc.
  45. ;
  46. ; Use the "SET" command to change the baudrate when desired.  The value
  47. ; at MSPEED controls the baudrate when the program is first called up.
  48. ;
  49. ;    TO USE: First edit this file filling in answers for your own
  50. ;        equipment.  Then assemble with ASM.COM or equivalent
  51. ;        assembler.  Then use MLOAD to merge into the main file:
  52. ;
  53. ;        MLOAD IMP.COM=IMP.COM,I2AM-x.HEX
  54. ;
  55. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  56. ;
  57. ; 11/05/85 - Added 9600 baud, etc.        - Irv Hoff
  58. ; 10/27/85 - Written to work with IMP        - Irv Hoff
  59. ;
  60. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  61. ;
  62. ;
  63. YES    EQU    0FFH
  64. NO    EQU    0
  65. ;
  66. ;
  67. ; Values shown are for a Z80 DART
  68. ;
  69. PORT    EQU    88H    ; Your base data port
  70. MDCTL1    EQU    PORT+4    ; Modem control port
  71. MDDATP    EQU    PORT    ; Modem data port
  72. MDRCV    EQU    01H    ; Modem receive ready
  73. MDSND    EQU    04H    ; Modem send ready bit
  74. MDTXE    EQU    01H    ; Modem send buffer empty, holding buffer empty
  75. ;
  76. BRPORT    EQU    50H    ; Baud rate generator port (CTC)
  77. ;
  78. ;
  79. ;-----------------------------------------------------------------------
  80. ;
  81. ESC    EQU    '['-40H    ; ^[ = Escape
  82. BELL    EQU    'G'-40H    ; ^G = Bell character
  83. LF    EQU    'J'-40H    ; ^J = Linefeed
  84. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  85. CR    EQU    'M'-40H    ; ^M = Carriage return
  86. CLEARSC    EQU    'Z'-40H    ; ^Z = Clear screen, command mode only
  87. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  88. ;
  89. ;
  90. ;-----------------------------------------------------------------------
  91. ;
  92. ;
  93.     ORG    0100H
  94. ;
  95. ;
  96.     DS    3    ; Skip the data area below
  97. ;
  98. ;
  99. ; These routines and equates are at the beginning of the program so
  100. ; they can be patched by a monitor or overlay file without re-assembling
  101. ; the program.
  102. ;
  103. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  104.             ; 6=2400 7=4800 8=9600 9=19200 default
  105. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  106. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  107. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  108. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  109. RESVD1:     DB    NO    ; Reserved for special modems            108H
  110. RESVD2:     DB    NO    ; Reserved for special modems            109H
  111. ;
  112. ;
  113. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  114. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  115.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  116. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  117.             ;   default time to send character in ter-
  118.             ;   minal mode file transfer for slow BBS
  119. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  120.             ;   default time for extra wait after CRLF
  121.             ;   in terminal mode file transfer
  122. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  123. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  124. ;.....
  125. ;
  126. ;
  127. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  128.             ;   mode (normally added by remote echo)
  129. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  130. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  131. IGNRCTL: DB    NO    ; Yes=CTL-chars above ^M not displayed        113H
  132. ;.....
  133. ;
  134. ;
  135. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  136. EXITCHR: DB    'E'    ; Exit character                115H
  137. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  138. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  139. LOGCHR:     DB    'L'    ; Send logon                    118H
  140. LSTCHR:     DB    'P'    ; Toggle printer                119H
  141. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  142. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  143. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  144. SPARE1:     DB    0    ; For future development            11DH
  145. NODTR:     DB    NO    ; Yes if no DTR and need +++ to disconnect    11EH
  146. ;.....
  147. ;
  148. ;
  149. ; Handles in/out ports for data and status
  150. ;
  151. I$MDCTL1: MVI    A,10H        ; Register 0, reset interrupts        11FH
  152.       OUT    MDCTL1        ;                    121H
  153.       IN    MDCTL1        ;                    123H
  154.       RET            ; IN modem control port         125H
  155.       DB    0,0,0        ; Spares if needed            126H
  156. ;
  157. I$MDTXE:  MVI    A,11H        ; Select read register 1        129H
  158.       OUT    MDCTL1        ;                    12BH
  159.       IN    MDCTL1        ;                    12DH
  160.       RET            ;                    12FH
  161.       DB    0,0,0        ;                    130H
  162. ;
  163. I$MDDATP: IN    MDDATP        ;                    137H
  164.       RET            ;                    139H
  165.       DB    0,0,0,0,0,0,0    ; Spares if needed            13AH
  166.  
  167. O$MDDATP: OUT    MDDATP        ;                    13DH
  168.       RET            ; OUT modem data port            13FH
  169.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  170. ;.....
  171. ;
  172. ;
  173. A$MDRCV:  ANI    MDRCV        ;                    147H
  174.       RET            ;                    149H
  175. ;
  176. C$MDRCV:  CPI    MDRCV        ;                    14AH
  177.       RET            ;                    14CH
  178. ;
  179. A$MDSND:  ANI    MDSND        ;                    14DH
  180.       RET            ;                    14FH
  181. ;
  182. C$MDSND:  CPI    MDSND        ;                    150H
  183.       RET            ;                    152H
  184. ;
  185. A$MDTXE:  ANI    MDTXE        ;                    153H
  186.       RET            ;                    155H
  187. ;
  188. C$MDTXE:  CPI    MDTXE        ;                    156H
  189.       RET            ;                    158H
  190. ;.....
  191. ;
  192. ;
  193. ; Special exit vector, used by some computers to reset interrupt vectors
  194. ;
  195. J$EXITVEC:RET            ;                    159H
  196.       DB    0,0        ;                    15AH
  197. ;.....
  198. ;
  199. ;
  200. ; Jump vectors needed by each overlay
  201. ;
  202. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  203. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  204. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  205. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  206. ;.....
  207. ;
  208. ;
  209. ; "AT" command strings, can be replaced in individual overlay if needed
  210. ;
  211. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  212. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  213. ;
  214. ;
  215. ; Next fourteen lines should not be changed by user overlay as these go
  216. ; to specific locations in the main program, not in the overlay.
  217. ;
  218. ;
  219. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  220. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  221. J$DIAL:      DS    3        ; Start of dialing routine        174H
  222. J$DSCONT: DS    3        ; Terminates modem use            177H
  223. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  224. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  225. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  226. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  227. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  228. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  229. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  230. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  231. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  232. J$NEW1:      DB    0,0,0        ; For future needs            195H
  233. J$NEW2:      DB    0,0,0        ; For future needs            198H
  234. ;.....
  235. ;
  236. ;
  237. ; For 2400 bps auto-stepdown units
  238. ;
  239. MANUAL:      DB    0        ; For manual selection flag        19BH
  240. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  241. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  242. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  243. ;.....
  244. ;
  245. ;
  246. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  247. ;
  248. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  249.       DB    'Version for the Ampro Little Board ' ;         1AAH
  250.       DB    'using Port 88H',CR,LF,0
  251.       RET
  252. ;.....
  253. ;
  254. ;
  255. ;-----------------------------------------------------------------------
  256. ;
  257. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  258. ;     end of your last routine should terminate by 0400H (601 bytes
  259. ;     available after start of SYSVER).
  260. ;
  261. ;-----------------------------------------------------------------------
  262. ;
  263. ; You can put in a message at this location which can be called up with
  264. ; (special character-L).  You can put in several lines.  End with a 0.
  265. ;
  266. LOGON:    DB    'This is an Ampro Little Board computer. ',CR,LF,0
  267. ;
  268. ;-----------------------------------------------------------------------
  269. ;
  270. ;
  271. ; This routine sets DTR and RTS low for 300 ms to disconnect the phone.
  272. ;
  273. GOODBYE:
  274.     MVI    B,'S'-40H    ; X-off to stop host if needed
  275.     CALL    J$SNDCHR
  276.     MVI    B,1        ; Wait a moment to let it react
  277.     CALL    J$TIMER
  278.     MVI    A,5
  279.     OUT    MDCTL1        ; Sned to the status port
  280.     MVI    A,068H        ; Turn off DTR, RTS, send break
  281.     OUT    MDCTL1
  282.     MVI    B,3        ; Wait 300 ms
  283.     CALL    J$TIMER
  284.     MVI    A,5
  285.     OUT    MDCTL1
  286.     MVI    A,0EAH        ; Restore normal, 8 bits, RTS on, etc.
  287.     OUT    MDCTL1
  288.     RET
  289. ;.....
  290. ;
  291. ;
  292. ; IMS baud rate change.  Sets CTC for baud rate.
  293. ;
  294. INITMOD:
  295.     MVI    A,0        ; Select register
  296.     OUT    MDCTL1        ; Send to the status port
  297.     MVI    A,18H        ; Reset the Z8SIO chip
  298.     OUT    MDCTL1        ; Send to the status port
  299.     MVI    A,4        ; Select register
  300.     OUT    MDCTL1        ; Send to the status port
  301.     MVI    A,44H        ;*32x, 2-stop, no parity  (84=1, 8C=2)
  302.     OUT    MDCTL1        ; Send to the status port
  303.     MVI    A,3        ; Select register
  304.     OUT    MDCTL1        ; Send to the status port
  305.     MVI    A,0C1H        ; Enable receive section
  306.     OUT    MDCTL1        ; Send to the status port
  307.     MVI    A,5        ; Select register
  308.     OUT    MDCTL1        ; Send to the status port
  309.     MVI    A,0EAH        ; DTR, RTS, 8-bits, enable send section
  310.     OUT    MDCTL1        ; Send to the status port
  311. ;
  312.     LDA    MSPEED        ; Get the selected value
  313.     CPI    1        ; 300 bps
  314.     JZ    OK300
  315.     CPI    5        ; 1200 bps
  316.     JZ    OK1200
  317.     CPI    6        ; 2400 bps
  318.     JZ    OK2400
  319.     CPI    8        ; 9600 bps
  320.     JZ    OK9600
  321.     JMP    STUPR1        ; Else ask what is wanted
  322. ;.....
  323. ;
  324. ;
  325. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  326.     JNC    STUPR2
  327. ;
  328. STUPR1:    CALL    J$ILPRT
  329.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  330.     LXI    D,BAUDBUF    ; Point to new input buffer
  331.     CALL    J$INBUF
  332.     CALL    J$CRLF
  333.     LXI    D,BAUDBUF+2
  334. ;
  335. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  336.     DB    '300',0
  337.     JNC    OK300        ; Go if got match
  338.     CALL    J$INLNCP
  339.     DB    '1200',0
  340.     JNC    OK1200
  341.     CALL    J$INLNCP
  342.     DB    '2400',0
  343.     JNC    OK2400
  344.     CALL    J$INLNCP
  345.     DB    '9600',0
  346.     JNC    OK9600
  347.     CALL    J$ILPRT        ; All matches failed, tell operator
  348.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  349.     JMP    STUPR1        ; Try again
  350. ;
  351. OK300:    MVI    A,1        ; MSPEED 300 baud value
  352.     LXI    H,BD300        ; Get 300 bps parameters in 'HL'
  353.     JMP    LOADBD        ; Go load them
  354. ;
  355. OK1200:    MVI    A,5
  356.     LXI    H,BD1200
  357.     JMP    LOADBD
  358. ;
  359. OK2400:    XRA    A
  360.     STA    MANUAL        ; Reset to maximum auto-speed
  361.     MVI    A,6
  362.     LXI    H,BD2400
  363.     JMP    LOADBD
  364. ;
  365. OK0600:    MVI    A,8
  366.     LXI    H,BD9600
  367. ;
  368. LOADBD:    STA    MSPEED        ; Change time-to-send to match baud rate
  369.     MOV    A,H        ; Command word
  370.     OUT    BRPORT
  371.     MOV    A,L        ; Baudrate
  372.     OUT    BRPORT
  373.     RET
  374. ;.....
  375. ;
  376. ;
  377. ; Table of baud rate parameters
  378. ;
  379. BD300    EQU    0734H        ; 15600/300 (first half is CTC command)
  380. BD1200    EQU    4768H        ; 124800/1200
  381. BD2400    EQU    4734H        ; 124800/2400
  382. BD9600    EQU    470DH        ; 124800/9600
  383. ;
  384. BAUDBUF:DB    10,0,0,0,0,0
  385.     DB    0,0,0,0,0,0
  386. ;
  387. ;                   end
  388. ;-----------------------------------------------------------------------
  389. ;
  390. ; NOTE: Must terminate prior to 0400H
  391. ;
  392.     END
  393.