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 / B5R2-1.INS < prev    next >
Text File  |  2000-06-30  |  4KB  |  180 lines

  1. ; B5R2-1.INS - BYE5 Insert for TRS-80 2/12/16/16B - 07/17/85
  2. ;
  3. ;         SIO I/O and CTC 8430 timer
  4. ;
  5. ; This version adapted for use with TRS-80 Models 2/12/16 & 16B.
  6. ;
  7. ; This works with the TRS-80 Model II & 12 with versions of CP/M 2.2
  8. ; except Pickles and Trout 2.2m.  Will work on P&T 2.2m ONLY if running
  9. ; ZCPR3.
  10. ;
  11. ; NOTE:  This is an insert, not an overlay.
  12. ;
  13. ;
  14. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  15. ;
  16. ; 07/17/85  Written to work with BYE5            - Irv Hoff
  17. ; 12/23/84  Written for TRS-80 Models II//16/ and 16B    - Ken Brown
  18. ;
  19. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  20. ;
  21. ;
  22. ; Set ports for SIO & CTC chips for TRS-80 Models 2/12/16/16B
  23. ;
  24. ; The following define the port addresses to use.
  25. ;
  26. PORT    EQU    0F4H        ; Data port
  27. STPORT    EQU    PORT+2        ; Status/control port
  28. BPORT    EQU    0F0H        ; Baud rate port
  29. BPORT1    EQU    BPORT+1        ; Port for TRS-80 Models 2/12/16/16B
  30. ;
  31. ;
  32. ; Changed BDCMD1 & BDCMD2 EQU'S for TRS-80 Models 2/12/16/16B
  33. ;
  34. BDCMD1    EQU    07H        ; 110,300,600 & 1200 baud
  35. BDCMD2    EQU    47H        ; 2400 4800 9600 baud
  36. ;
  37. ;
  38. ; CTC baud rate divisors
  39. ;
  40. BD300    EQU    52        ; 300 baud
  41. BD1200    EQU    104        ; 1200 bps
  42. BD2400    EQU    52        ; 2400 bps
  43. ;
  44. ;
  45. ;-----------------------------------------------------------------------
  46. ;
  47. ; See if we still have a carrier - if not, return with the zero flag set
  48. ;
  49. MDCARCK:MVI    A,10H        ; Reset status
  50.     OUT    STPORT
  51.     IN    STPORT        ; Get status
  52.     ANI    08H        ; Check for data carrier
  53.     RET
  54. ;.....
  55. ;
  56. ;
  57. ; Disconnect and wait for an incoming call
  58. ;
  59. MDINIT:    MVI    A,18H        ; Reset channel
  60.     OUT    STPORT
  61.     MVI    A,4        ; Setup to write register 4
  62.     OUT    STPORT
  63.     MVI    A,44H        ; 1 stop, 8 bits, no parity
  64.     OUT    STPORT
  65.     MVI    A,1        ; Setup to write register 1
  66.     OUT    STPORT
  67.     MVI    A,00H
  68.     OUT    STPORT
  69.     MVI    A,5        ; Setup to write register 5
  70.     OUT    STPORT
  71.     MVI    A,68H        ; Clear DTR causing hangup
  72.     OUT    STPORT
  73.     PUSH    B
  74.     MVI    B,20        ; 2 second delay
  75. ;
  76. OFFTI:    CALL    DELAY        ; 0.1 second delay
  77.     DCR    B
  78.     JNZ    OFFTI        ; Keep looping until finished
  79.     POP    B        ; Restore BC
  80.     MVI    A,3        ; Setup to write register 3
  81.     OUT    STPORT
  82.     MVI    A,0C1H        ; Initialize receive register
  83.     OUT    STPORT
  84.     MVI    A,5        ; Setup to write register 5
  85.     OUT    STPORT
  86.     MVI    A,0EAH        ; Turn on DTR so modem can answer phone
  87.     OUT    STPORT
  88. ;
  89.      IF    IMODEM        ; If using hayes 300/1200 smartmodem
  90.     CALL    IMINIT        ; Go initialize smartmodem now
  91.      ENDIF            ; Smodem
  92. ;
  93.     RET            ; Return
  94. ;.....
  95. ;
  96. ;
  97. ; Input a character from the modem port
  98. ;
  99. MDINP:    IN    PORT        ; Get character
  100.     RET            ; Return
  101. ;.....
  102. ;
  103. ;
  104. ; Check the status to see if a character is available.    If not, return
  105. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  106. ;
  107. MDINST:    IN    STPORT        ; Get status
  108.     ANI    01H        ; Check the receive ready bit
  109.     RZ            ; Return if none
  110.     ORI    0FFH        ; Otherwise, set the proper flag
  111.     RET            ; And return
  112. ;.....
  113. ;
  114. ;
  115. ; Send a character to the modem
  116. ;
  117. MDOUTP:    OUT    PORT        ; Send it
  118.     RET
  119. ;.....
  120. ;
  121. ;
  122. ; See if the output is ready for another character
  123. ;
  124. MDOUTST:IN    STPORT
  125.     ANI    04H        ; Check the transmit ready bit
  126.     RET
  127. ;.....
  128. ;
  129. ;
  130. ; Reinitialize the modem and hang up the phone by dropping DTR and
  131. ; leaving it inactive.
  132. ;
  133. MDQUIT:     IF    IMODEM        ; If using a smartmodem
  134.     CALL    IMQUIT        ; Tell it to shut down
  135.      ENDIF            ; IMODEM
  136. ;
  137. ;
  138. ; Called by the main program after caller types BYE
  139. ;
  140. MDSTOP:    MVI    A,5        ; Setup to write register 5
  141.     OUT    STPORT
  142.     MVI    A,68H        ; Clear DTR causing shutdown
  143.     OUT    STPORT
  144.     XCHG            ; Give it time to react
  145.     XCHG
  146.     RET
  147. ;.....
  148. ;
  149. ;
  150. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  151. ; speed you have available.
  152. ;
  153. SETINV:    ORI    0FFH        ; Make sure zero flag is not set
  154.     RET
  155. ;.....
  156. ;
  157. ;
  158. SET300:    MVI    B,BD300        ; Load rate
  159.     MVI    A,BDCMD1    ; Get first byte of command
  160.     JMP    SETBAUD
  161. ;
  162. SET1200:MVI    B,BD1200
  163.     MVI    A,BDCMD2
  164.     JMP    SETBAUD
  165. ;
  166. SET2400:MVI    B,BD2400
  167.     MVI    A,BDCMD2
  168. ;
  169. SETBAUD:OUT    BPORT        ; Send CTC command word
  170.     OUT    BPORT1
  171.     MOV    A,B        ; Get the baudrate value
  172.     OUT    BPORT        ; Send rate
  173.     OUT    BPORT1
  174.     XRA    A        ; Say rate is ok
  175.     RET
  176. ;.....
  177. ;
  178. ;                   end
  179. ------------------------------------------------------------------------:
  180.