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 / I2OX-2.AZM / I2OX-2.ASM
Assembly Source File  |  2000-06-30  |  11KB  |  380 lines

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