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 / NUBYE / NUBY-INS.LBR / NUR2-1.IQS / nur2-1.ins
Text File  |  1986-04-26  |  4KB  |  154 lines

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