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 / I2AM-4.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  13KB  |  464 lines

  1.  
  2. ; I2AM-4.ASM - AMPRO "Little Board" overlay file for IMP - 06/01/87
  3. ;
  4. ;     Z80 DART and 8430 CTC timer and 4.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. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  58. ;        IMP245 to use it.            - Irv Hoff
  59. ;
  60. ; 08/22/86  Added 'A' channel, up to 38400 bps    - Irv Hoff
  61. ; 11/05/85  Added 9600 pbs, etc.        - Irv Hoff
  62. ; 10/27/85  Written to work with IMP        - Irv Hoff
  63. ;
  64. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  65. ;
  66. ;
  67. YES    EQU    0FFH
  68. NO    EQU    0
  69. ;
  70. ;
  71. ACHNL    EQU    NO        ; 'A' channel, normally used for CRT
  72. BCHNL    EQU    YES        ; 'B' channel, normally used for modem
  73. ;
  74. ;
  75. ; Values shown are for a Z80 DART
  76. ;
  77. ;     Channel          A     B
  78. ;     Data port         80h    88h
  79. ;     Control port         84h    8Ch
  80. ;     CTC port         40h    50h
  81. ;     Maximum speed        77600    9600
  82. ;
  83. ;
  84.      IF    ACHNL
  85. CHNL    EQU    80H
  86. CTC    EQU    40H
  87.      ENDIF            ; ACHNL
  88. ;
  89.      IF    BCHNL
  90. CHNL    EQU    88H
  91. CTC    EQU    50H
  92.      ENDIF            ; BCHNL
  93. ;
  94. ;
  95. PORT    EQU    CHNL    ; Your base data port
  96. MDCTL1    EQU    PORT+4    ; Modem control port
  97. MDDATP    EQU    PORT    ; Modem data port
  98. MDRCV    EQU    01H    ; Modem receive ready
  99. MDSND    EQU    04H    ; Modem send ready bit
  100. MDTXE    EQU    01H    ; Modem send buffer empty, holding buffer empty
  101. ;
  102. BRPORT    EQU    CTC    ; Baud rate generator port (CTC)
  103. ;
  104. ;
  105. ;-----------------------------------------------------------------------
  106. ;
  107. ESC    EQU    '['-40H    ; ^[ = Escape
  108. BELL    EQU    'G'-40H    ; ^G = Bell character
  109. LF    EQU    'J'-40H    ; ^J = Linefeed
  110. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  111. CR    EQU    'M'-40H    ; ^M = Carriage return
  112. CLEARSC    EQU    'Z'-40H    ; ^Z = Clear screen, command mode only
  113. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  114. ;
  115. ;
  116. ;-----------------------------------------------------------------------
  117. ;
  118. ;
  119.     ORG    0100H
  120. ;
  121. ;
  122.     DS    3    ; Skip the data area below
  123. ;
  124. ;
  125. ; These routines and equates are at the beginning of the program so
  126. ; they can be patched by a monitor or overlay file without re-assembling
  127. ; the program.
  128. ;
  129. MSPEED:     DB    6    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  130.             ; 6=2400 7=4800 8=9600 9=19200 default
  131. HS2400:     DB    YES    ; Yes=2400 bps highest speed            104H
  132. HS1200:     DB    NO    ; Yes=1200 bps highest speed            105H
  133. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  134. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  135. RESVD1:     DB    NO    ; Reserved for special modems            108H
  136. RESVD2:     DB    NO    ; Reserved for special modems            109H
  137. ;
  138. ;
  139. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  140. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  141.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  142. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  143.             ;   default time to send character in ter-
  144.             ;   minal mode file transfer for slow BBS
  145. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  146.             ;   default time for extra wait after CRLF
  147.             ;   in terminal mode file transfer
  148. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  149. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  150. ;.....
  151. ;
  152. ;
  153. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  154.             ;   mode (normally added by remote echo)
  155. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  156. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  157. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  158. ;.....
  159. ;
  160. ;
  161. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  162. EXITCHR: DB    'E'    ; Exit character                115H
  163. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  164. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  165. LOGCHR:     DB    'L'    ; Send logon                    118H
  166. LSTCHR:     DB    'P'    ; Toggle printer                119H
  167. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  168. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  169. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  170. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  171. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  172. ;.....
  173. ;
  174. ;
  175. ; Handles in/out ports for data and status
  176. ;
  177. I$MDCTL1: MVI    A,10H        ; Register 0, reset interrupts        11FH
  178.       OUT    MDCTL1        ;                    121H
  179.       IN    MDCTL1        ;                    123H
  180.       RET            ; IN modem control port         125H
  181.       DB    0,0,0        ; Spares if needed            126H
  182. ;
  183. I$MDTXE:  MVI    A,11H        ; Select read register 1        129H
  184.       OUT    MDCTL1        ;                    12BH
  185.       IN    MDCTL1        ;                    12DH
  186.       RET            ;                    12FH
  187.       DB    0,0,0        ;                    130H
  188. ;
  189. I$MDDATP: IN    MDDATP        ;                    137H
  190.       RET            ;                    139H
  191.       DB    0,0,0,0,0,0,0    ; Spares if needed            13AH
  192.  
  193. O$MDDATP: OUT    MDDATP        ;                    13DH
  194.       RET            ; OUT modem data port            13FH
  195.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  196. ;.....
  197. ;
  198. ;
  199. A$MDRCV:  ANI    MDRCV        ;                    147H
  200.       RET            ;                    149H
  201. ;
  202. C$MDRCV:  CPI    MDRCV        ;                    14AH
  203.       RET            ;                    14CH
  204. ;
  205. A$MDSND:  ANI    MDSND        ;                    14DH
  206.       RET            ;                    14FH
  207. ;
  208. C$MDSND:  CPI    MDSND        ;                    150H
  209.       RET            ;                    152H
  210. ;
  211. A$MDTXE:  ANI    MDTXE        ;                    153H
  212.       RET            ;                    155H
  213. ;
  214. C$MDTXE:  CPI    MDTXE        ;                    156H
  215.       RET            ;                    158H
  216. ;.....
  217. ;
  218. ;
  219. ; Special exit vector, used by some computers to reset interrupt vectors
  220. ;
  221. J$EXITVEC:RET            ;                    159H
  222.       DB    0,0        ;                    15AH
  223. ;.....
  224. ;
  225. ;
  226. ; Jump vectors needed by each overlay
  227. ;
  228. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  229. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  230. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  231. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  232. ;.....
  233. ;
  234. ;
  235. ; "AT" command strings, can be replaced in individual overlay if needed
  236. ;
  237. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  238. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  239. ;
  240. ;
  241. ; Next fourteen lines should not be changed by user overlay as these go
  242. ; to specific locations in the main program, not in the overlay.
  243. ;
  244. ;
  245. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  246. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  247. J$DIAL:      DS    3        ; Start of dialing routine        174H
  248. J$DSCONT: DS    3        ; Terminates modem use            177H
  249. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  250. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  251. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  252. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  253. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  254. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  255. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  256. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  257. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  258. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  259. J$NEW2:      DB    0,0,0        ; For future needs            198H
  260. ;.....
  261. ;
  262. ;
  263. ; For 2400 bps auto-stepdown units
  264. ;
  265. MANUAL:      DB    0        ; For manual selection flag        19BH
  266. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  267. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  268. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  269. ;.....
  270. ;
  271. ;
  272. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  273. ;
  274. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  275.       DB    'Version for the Ampro Little Board ' ;         1AAH
  276.       DB    'using Port 88H',CR,LF,0
  277.       RET
  278. ;.....
  279. ;
  280. ;
  281. ;-----------------------------------------------------------------------
  282. ;
  283. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  284. ;     end of your last routine should terminate by 0400H (601 bytes
  285. ;     available after start of SYSVER).
  286. ;
  287. ;-----------------------------------------------------------------------
  288. ;
  289. ; You can put in a message at this location which can be called up with
  290. ; (special character-L).  You can put in several lines.  End with a 0.
  291. ;
  292. LOGON:    DB    'This is an Ampro Little Board computer. ',CR,LF,0
  293. ;
  294. ;-----------------------------------------------------------------------
  295. ;
  296. ; This routine sets a 300 ms break tone
  297. ;
  298. SENDBRK:
  299.     MVI    A,5
  300.     OUT    MDCTL1        ; Send to the status port
  301.     MVI    A,0F8H        ; DTR normal, send break tone
  302.     JMP    GOODBYE1    ; Go send the break tone
  303. ;.....
  304. ;
  305. ;
  306. ; This routine sets DTR low for 300 ms to disconnect the modem.
  307. ;
  308. GOODBYE:
  309.     MVI    A,5
  310.     OUT    MDCTL1        ; Send to the status port
  311.     MVI    A,78H        ; Turn off DTR and send break tone
  312. ;
  313. GOODBYE1:
  314.     OUT    MDCTL1
  315.     MVI    B,3        ; Delay 300 ms
  316.     CALL    J$TIMER
  317.     MVI    A,5
  318.     OUT    MDCTL1
  319.     MVI    A,0E8H        ; Restore normal, 8 bits, DTR on, etc.
  320.     OUT    MDCTL1
  321.     RET
  322. ;.....
  323. ;
  324. ;
  325. ; Sets CTC for baud rate.
  326. ;
  327. INITMOD:
  328.     MVI    A,0        ; Select register
  329.     OUT    MDCTL1        ; Send to the status port
  330.     MVI    A,18H        ; Reset the Z8SIO chip
  331.     OUT    MDCTL1        ; Send to the status port
  332.     MVI    A,4        ; Select register
  333.     OUT    MDCTL1        ; Send to the status port
  334.     MVI    A,44H        ; 16x, 2-stop, no parity  (44=1,4C=2)
  335.     OUT    MDCTL1        ; Send to the status port
  336.     MVI    A,3        ; Select register
  337.     OUT    MDCTL1        ; Send to the status port
  338.     MVI    A,0C1H        ; Enable receive section
  339.     OUT    MDCTL1        ; Send to the status port
  340.     MVI    A,5        ; Select register
  341.     OUT    MDCTL1        ; Send to the status port
  342.     MVI    A,0EAH        ; DTR, RTS, 8-bits, enable send section
  343.     OUT    MDCTL1        ; Send to the status port
  344. ;
  345.     LDA    MSPEED        ; Get the selected value
  346.     CPI    1        ; 300 bps
  347.     JZ    OK300
  348.     CPI    5        ; 1200 bps
  349.     JZ    OK1200
  350.     CPI    6        ; 2400 bps
  351.     JZ    OK2400
  352.     CPI    8        ; 9600 bps
  353.     JZ    OK9600
  354.     JMP    STUPR1        ; Else ask what is wanted
  355. ;.....
  356. ;
  357. ;
  358. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  359.     JNC    STUPR2
  360. ;
  361. STUPR1:    CALL    J$ILPRT
  362.     DB    'Input Baud Rate (300, 1200, 2400, 9600'
  363. ;
  364.      IF    ACHNL
  365.     DB    ', 19200, 38400'
  366.      ENDIF            ; ACHNL
  367. ;
  368.     DB    '): ',0
  369.     LXI    D,BAUDBUF    ; Point to new input buffer
  370.     CALL    J$INBUF
  371.     CALL    J$CRLF
  372.     LXI    D,BAUDBUF+2
  373. ;
  374. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  375.     DB    '300',0
  376.     JNC    OK300        ; Go if got match
  377.     CALL    J$INLNCP
  378.     DB    '1200',0
  379.     JNC    OK1200
  380.     CALL    J$INLNCP
  381.     DB    '2400',0
  382.     JNC    OK2400
  383.     CALL    J$INLNCP
  384.     DB    '9600',0
  385.     JNC    OK9600
  386. ;
  387.      IF    ACHNL
  388.     CALL    J$INLNCP
  389.     DB    '19200',0
  390.     JNC    OK19200
  391.     CALL    J$INLNCP
  392.     DB    '38400',0
  393.     JNC    OK38400
  394.      ENDIF            ; ACHNL
  395. ;
  396.     CALL    J$ILPRT        ; All matches failed, tell operator
  397.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  398.     JMP    STUPR1        ; Try again
  399. ;
  400. OK300:    MVI    A,1        ; MSPEED 300 baud value
  401.     LXI    H,BD300        ; Get 300 bps parameters in 'HL'
  402.     JMP    LOADBD        ; Go load them
  403. ;
  404. OK1200:    MVI    A,5
  405.     LXI    H,BD1200
  406.     JMP    LOADBD
  407. ;
  408. OK2400:    XRA    A
  409.     STA    MANUAL        ; Reset to maximum auto-speed
  410.     MVI    A,6
  411.     LXI    H,BD2400
  412.     JMP    LOADBD
  413. ;
  414. OK9600:    MVI    A,8
  415.     LXI    H,BD9600
  416.     JMP    LOADBD
  417. ;
  418.      IF    ACHNL
  419. OK19200:MVI    A,9
  420.     LXI    H,BD19200
  421.     JMP    LOADBD
  422. ;
  423. OK38400:MVI    A,9
  424.     LXI    H,BD38400
  425.      ENDIF            ; ACHNL
  426. ;
  427. LOADBD:    STA    MSPEED        ; Change time-to-send to match baud rate
  428.     MOV    A,H        ; Command word
  429.     OUT    BRPORT
  430.     MOV    A,L        ; Baudrate
  431.     OUT    BRPORT
  432.     RET
  433. ;.....
  434. ;
  435. ;
  436. ; Table of baud rate parameters
  437. ;
  438.      IF    ACHNL
  439. BD300    EQU    0700H        ; 76800/300 (first half is CTC command)
  440. BD1200    EQU    0740H        ; 76800/1200
  441. BD2400    EQU    0720H        ; 76800/2400
  442. BD9600    EQU    4740H        ; 614,400/9600
  443. BD19200    EQU    4720H        ; 614,400/19200
  444. BD38400    EQU    4710H        ; 614,400/38400
  445.      ENDIF            ; ACHNL
  446. ;
  447.      IF    BCHNL
  448. BD300    EQU    0734H        ; 15600/300 (first half is CTC command)
  449. BD1200    EQU    4768H        ; 124800/1200
  450. BD2400    EQU    4734H        ; 124800/2400
  451. BD9600    EQU    470DH        ; 124800/9600
  452.      ENDIF            ; BCHNL
  453. ;
  454. ;
  455. BAUDBUF:DB    10,0,0,0,0,0
  456.     DB    0,0,0,0,0,0
  457. ;
  458. ;                   end
  459. ;-----------------------------------------------------------------------
  460. ;
  461. ; NOTE: Must terminate prior to 0400H
  462. ;
  463.     END
  464.