home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol273 / i2kp-1.aqm / I2KP-1.ASM
Encoding:
Assembly Source File  |  1986-06-11  |  10.5 KB  |  368 lines

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