home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3tv-2.ins < prev    next >
Text File  |  1994-07-13  |  4KB  |  149 lines

  1.  
  2. ; B3TV-2.INS - BYE3 insert for TeleVideo TS-802 - 08/01/85
  3. ;
  4. ;         SIO I/O and CTC baudrate generator
  5. ;
  6. ;        Note:  This is an insert, not an overlay.
  7. ;
  8. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  9. ;
  10. ; 04/16/83  TS802 code created from B3SIO    - Kevin Robesky
  11. ;
  12. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  13. ;
  14. ;
  15. ; Modem port equates
  16. ;
  17. DPORT    EQU    20H        ; Modem data port
  18. SPORT    EQU    DPORT+2        ; Modem status port
  19. BDPORT    EQU    08H        ; Modem baud rate port
  20. ;
  21. ; Status port masks
  22. ;
  23. DAV    EQU    00000001B    ; Data available
  24. TBMT    EQU    00000100B    ; Transmit buffer empty
  25. DCD    EQU    00001000B    ; Data carrier detect
  26. ;
  27. ; First Byte of CTC Command:
  28. ;
  29. BDCMD    EQU    47H
  30. ;
  31. ; Baudrate table
  32. ;
  33. BD300    EQU    80H        ; 300 baud
  34. BD1200    EQU    20H        ; 1200 bps
  35. BD2400    EQU    10H        ; 2400 bps
  36. ;
  37. ;-----------------------------------------------------------------------
  38. ;
  39. ; See if we still have a carrier - if not, return with the zero flag set
  40. ;
  41. MDCARCK:MVI    A,10H        ; Reset status
  42.     OUT    SPORT
  43.     IN    SPORT        ; Get status
  44.     ANI    DCD        ; Check for carrier detect
  45.     RZ
  46.     ORI    255
  47.     RET
  48. ;
  49. ; Disconnect and wait for an incoming call
  50. ;
  51. MDINIT:    MVI    A,18H        ; Reset channel
  52.     OUT    SPORT
  53.     MVI    A,4        ; Setup to write register 4
  54.     OUT    SPORT
  55.     MVI    A,44H        ; 1 stop, 8 bits, no parity
  56.     OUT    SPORT
  57.     MVI    A,1        ; Setup to write register 1
  58.     OUT    SPORT
  59.     MVI    A,00H
  60.     OUT    SPORT
  61.     MVI    A,5        ; Setup to write register 5
  62.     OUT    SPORT
  63.     MVI    A,68H        ; Clear DTR causing hangup
  64.     OUT    SPORT
  65. ;
  66.     PUSH    B        ; In case it is being used elsewhere
  67.     MVI    B,20        ; 2 seconds delay to drop any carrier
  68. OFFTI:    CALL    DELAY        ; 0.1 second delay
  69.     DCR    B
  70.     JNZ    OFFTI        ; Keep looping until finished
  71.     POP    B        ; Restore BC
  72. ;
  73.     MVI    A,3        ; Setup to write register 3
  74.     OUT    SPORT
  75.     MVI    A,0C1H        ; Initialize receive register
  76.     OUT    SPORT
  77.     MVI    A,5        ; Setup to write register 5
  78.     OUT    SPORT
  79.     MVI    A,0EAH        ; Turn on DTR so modem can answer phone
  80.     OUT    SPORT
  81. ;
  82.      IF    IMODEM
  83.     CALL    IMINIT        ; Initialize smartmodem
  84.      ENDIF            ; IMODEM
  85. ;
  86.     RET
  87. ;
  88. ; Input a character from the modem port
  89. ;
  90. MDINP:    IN    DPORT        ; Get character
  91.     RET
  92. ;
  93. ; Check the status to see if a character is available.    If not, return
  94. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  95. ;
  96. MDINST:    IN    SPORT        ; Get status
  97.     ANI    DAV        ; Check receive ready bit
  98.     RZ            ; Return if none
  99.     ORI    255        ; Otherwise, set the flags
  100.     RET
  101. ;
  102. ; Send a character to the modem
  103. ;
  104. MDOUTP:    OUT    DPORT        ; Send it
  105.     RET
  106. ;
  107. ; See if the output is ready for another character
  108. ;
  109. MDOUTST:IN    SPORT        ; Read port
  110.     ANI    TBMT        ; Check transmit ready bit
  111.     RZ
  112.     ORI    255
  113.     RET
  114. ;
  115. ; Reinitialize the modem and hang up the phone by dropping DTR and
  116. ; leaving it inactive
  117. ;
  118. MDQUIT:     IF    IMODEM
  119.     CALL    IMQUIT        ; If a smartmodem, tell it to shut down
  120.      ENDIF            ; IMODEM
  121. ;
  122. ; Called by the main program after caller types BYE
  123. ;
  124. MDSTOP:    MVI    A,5        ; Setup to write register 5
  125.     OUT    SPORT
  126.     MVI    A,68H        ; Clear DTR causing shutdown
  127.     OUT    SPORT
  128.     RET
  129. ;
  130. ; The following routine sets the baudrate.  BYE3 asks for the maximum
  131. ; speed you have available.
  132. ;
  133. SET300:    MVI    B,BD300        ; 2nd byte of command
  134.     JMP    STBAUD
  135. ;
  136. SET1200:MVI    B,BD1200    ; 2nd byte of command
  137.     JMP    STBAUD
  138. ;
  139. SET2400:MVI    B,BD2400
  140.  
  141. STBAUD:    MVI    A,BDCMD
  142.     OUT    BDPORT        ; Send 1st byte of command
  143.     MOV    A,B        ; Get the speed byte back again
  144.     OUT    BDPORT        ; Send it
  145.     XRA    A        ; Say rate is OK
  146.     RET
  147. ;                   end
  148. ;-----------------------------------------------------------------------
  149.