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 / BYE5 / B5TV-3.IQS / B5TV-3.INS
Text File  |  2000-06-30  |  6KB  |  258 lines

  1. ; B5TV-3.INS - BYE5 insert for TeleVideo TS-803 - 01/02/86
  2. ;
  3. ;       TV802 uses the Z80 SIO & CTC timer (3.6864 MHz)
  4. ;       TV803 uses Mostek 8301 & CTC timer (3.6864 MHz)
  5. ;       TV804 uses the Z80 SIO & CTC timer (3.9936 MHz)
  6. ;
  7. ;
  8. ;        Note:  This is an insert, not an overlay.
  9. ;
  10. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  11. ;
  12. ; 01/05/86  Added TV804 capability    - Irv Hoff
  13. ; 01/02/86  Added TV803 capability    - Tanny O'Haley
  14. ; 07/17/85  Written for TV802 and BYE5    - Irv Hoff
  15. ;
  16. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  17. ;
  18. ;
  19. ; Select one of the following choices for your computer.  (Gets the
  20. ; YES/NO values from the main BYE5 program.)
  21. ;
  22. TV802    EQU    NO
  23. TV803    EQU    NO
  24. TV804    EQU    YES
  25. ;
  26. ;
  27. ; Modem port equates
  28. ;
  29.      IF    TV802
  30. PORT    EQU    20H        ; Modem data port
  31. MDCTL1    EQU    PORT+2        ; Modem status port
  32. BDPORT    EQU    08H        ; CTC port for baud rate
  33.      ENDIF            ; TV802
  34. ;
  35.      IF    TV803
  36. PORT    EQU    2FH        ; Modem data port
  37. MDCTL1    EQU    PORT-1        ; Modem send status port
  38. MDCTL2    EQU    PORT-2        ; Modem receive status port
  39. REGINT    EQU    27H        ; Interrupt register port
  40. SPSTAT    EQU    21H        ; Parameter status register
  41. BDPORT    EQU    2BH        ; CTC port for baud rate
  42.      ENDIF            ; TV803
  43. ;
  44.      IF    TV804
  45. PORT    EQU    1EH        ; Modem data ort
  46. MDCTL1    EQU    PORT+1        ; Modem status port
  47. BDPORT    EQU    0EH        ; CTC port for baud rate
  48.      ENDIF            ; TV804
  49. ;
  50. ;
  51. ; Baudrate table
  52. ;
  53.      IF    TV802
  54. BD300    EQU    4780H        ; 38400/300  converted to hex value
  55. BD1200    EQU    4720H        ; 38400/1200 converted to hex value
  56. BD2400    EQU    4710H        ; 38400/2400 converted to hex value
  57. BD9600    EQU    4704H        ; 38400/9600 converted to hex value
  58.      ENDIF            ; TV802
  59. ;
  60.      IF    TV803
  61. BD300    EQU    4720H        ; 9600/300  converted to hex value
  62. BD1200    EQU    4708H        ; 9600/1200 converted to hex value
  63. BD2400    EQU    4704H        ; 9600/2400 converted to hex value
  64. BD9600    EQU    4701H        ; 9600/9600 converted to hex value
  65.      ENDIF            ; TV803
  66. ;
  67.      IF    TV804
  68. BD300    EQU    0734H        ; 7800/300 converted to hex value
  69. BD1200    EQU    4768H        ; 124800/1200 converted to hex value
  70. BD2400    EQU    4734H        ; 124800/2400 converted to hex value
  71. BD9600    EQU    470DH        ; 124800/9600 converted to hex value
  72.      ENDIF            ; TV804
  73. ;
  74. ;
  75. ;-----------------------------------------------------------------------
  76. ;
  77. ; See if we still have a carrier - if not, return with the zero flag set
  78. ; Reg A is zero if no carrier, non-zero if carrier
  79. ;
  80. MDCARCK: IF    TV802 OR TV804
  81.     MVI    A,10H        ; Reset status
  82.     OUT    MDCTL1
  83.     IN    MDCTL1        ; Get status
  84.     ANI    08H        ; Check for carrier detect
  85.      ENDIF            ; TV802 OR TV804
  86. ;
  87.      IF    TV803
  88.     IN    SPSTAT        ; Read status register
  89.     ANI    01H        ; Check for carrier detect
  90.     XRI    01H        ; Ready if bit 0 = 0
  91.      ENDIF            ; TV803
  92. ;
  93.     RET
  94. ;.....
  95. ;
  96. ;
  97. ; Disconnect and wait for an incoming call
  98. ;
  99. MDINIT:     IF    TV802 OR TV804
  100.     MVI    A,18H        ; Reset channel
  101.     OUT    MDCTL1
  102.     MVI    A,4        ; Setup to write register 4
  103.     OUT    MDCTL1
  104.     MVI    A,44H        ; 1 stop, 8 bits, no parity
  105.     OUT    MDCTL1
  106.     MVI    A,1        ; Setup to write register 1
  107.     OUT    MDCTL1
  108.     MVI    A,00H
  109.     OUT    MDCTL1
  110.     MVI    A,5        ; Setup to write register 5
  111.     OUT    MDCTL1
  112.     MVI    A,68H        ; Clear DTR causing hangup
  113.     OUT    MDCTL1
  114.     PUSH    B        ; In case it is being used elsewhere
  115. ;
  116. OFFTI:    CALL    DELAY        ; 0.1 second delay
  117.     DCR    B
  118.     JNZ    OFFTI        ; Keep looping until finished
  119.     POP    B        ; Restore BC
  120.     MVI    A,3        ; Setup to write register 3
  121.     OUT    MDCTL1
  122.     MVI    A,0C1H        ; Initialize receive register
  123.     OUT    MDCTL1
  124.     MVI    A,5        ; Setup to write register 5
  125.     OUT    MDCTL1
  126.     MVI    A,0EAH        ; Turn on DTR so modem can answer phone
  127.     OUT    MDCTL1
  128.      ENDIF            ; TV802 OR TV804
  129. ;
  130.      IF    TV803
  131.     XRA    A
  132.     OUT    REGINT        ; Stop interrupts
  133.     MVI    A,20H        ; Drop DTR
  134.     OUT    SPSTAT
  135.     MVI    B,20        ; 2 seconds delay to drop any carrier
  136.     PUSH    B        ; In case it is being used elsewhere
  137. ;
  138. OFFTI:    CALL    DELAY        ; 0.1 second delay
  139.     DCR    B
  140.     JNZ    OFFTI        ; Keep looping till finished
  141.     POP    B        ; Restore BC
  142.     XRA    A        ; Turn on DTR so modem can answer phone
  143.     OUT    SPSTAT
  144.      ENDIF            ; TV803
  145. ;
  146.      IF    IMODEM
  147.     CALL    IMINIT        ; Initialize smartmodem
  148.      ENDIF            ; IMODEM
  149. ;
  150.     RET
  151. ;.....
  152.  
  153. ;
  154. ; Input a character from the modem port
  155. ;
  156. MDINP:    IN    PORT        ; Get character
  157.     RET
  158. ;.....
  159. ;
  160. ;
  161. ; Check the status to see if a character is available.    If not, return
  162. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  163. ;
  164. MDINST:     IF    TV802 OR TV804
  165.     IN    MDCTL1        ; Get status
  166.     ANI    01H        ; Check receive ready bit
  167.     RZ            ; Return if none
  168.     ORI    0FFH        ; Otherwise, set the flags
  169.      ENDIF            ; TV802 OR TV804
  170. ;
  171.      IF    TV803
  172.     IN    MDCTL2        ; Get input status
  173.     ANI    80H        ; Check receive ready bit
  174.      ENDIF            ; TV803
  175. ;
  176.     RET
  177. ;.....
  178. ;
  179. ;
  180. ; Send a character to the modem
  181. ;
  182. MDOUTP:    OUT    PORT        ; Send it
  183.     RET
  184. ;.....
  185. ;
  186. ;
  187. ; See if the output is ready for another character
  188. ;
  189. MDOUTST:IN    MDCTL1        ; Read port
  190. ;
  191.      IF    TV802 OR TV804
  192.     ANI    04H        ; Check transmit ready bit
  193.      ENDIF            ; TV802 OR TV804
  194. ;
  195.      IF    TV803
  196.     ANI    80H        ; Check transmit ready bit
  197.      ENDIF            ; TV803
  198. ;
  199.     RET
  200. ;.....
  201. ;
  202. ;
  203. ; Reinitialize the modem and hang up the phone by dropping DTR and
  204. ; leaving it inactive
  205. ;
  206. MDQUIT:     IF    IMODEM
  207.     CALL    IMQUIT        ; If a smartmodem, tell it to shut down
  208.      ENDIF            ; IMODEM
  209. ;
  210. ;
  211. ; Called by the main program after caller types BYE
  212. ;
  213. MDSTOP:     IF    TV802 OR TV804
  214.     MVI    A,5        ; Setup to write register 5
  215.     OUT    MDCTL1
  216.     MVI    A,68H        ; Clear DTR causing shutdown
  217.     OUT    MDCTL1
  218.      ENDIF            ; TV802 OR TV804
  219. ;
  220.      IF    TV803
  221.     MVI    A,20H
  222.     OUT    SPSTAT        ; Turn DTR off to disconnect
  223.      ENDIF            ; TV803
  224. ;
  225.     RET
  226. ;.....
  227. ;
  228. ;
  229. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  230. ; speed you have available.
  231. ;
  232. SETINV:    ORI    0FFH        ; Make sure the Zero flag is not set
  233.     RET
  234. ;.....
  235. ;
  236. ;
  237. SET300:    LXI    H,BD300
  238.     JMP    STBAUD
  239. ;
  240. SET1200:LXI    H,BD1200
  241.     JMP    STBAUD
  242. ;
  243. SET2400:LXI    H,BD2400
  244.     JMP    STBAUD
  245. ;
  246. SET9600:LXI    H,BD2400
  247.     JMP    STBAUD
  248. ;
  249. STBAUD:    MOV    A,H        ; CTC timer control word
  250.     OUT    BDPORT        ; Controls CTC timer/counter
  251.     MOV    A,L        ; Baudrate
  252.     OUT    BDPORT
  253.     RET
  254. ;.....
  255. ;
  256. ;                   end
  257. ;-----------------------------------------------------------------------
  258.