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 / NUNH2-1.IQS / nunh2-1.ins
Text File  |  1986-04-25  |  3KB  |  136 lines

  1. ; NUNH2-1.INS - NUBYE insert for Northstar Horizon Computers - 04/21/86
  2. ;
  3. ; 8251A I/O on 2nd Serial Port of Northstar Horizon
  4. ; Supports 300 and 1200 baud automatic switching
  5. ;
  6. ; Note:  This is an insert, not an overlay.
  7. ;
  8. ; ========
  9. ;
  10. ; 04/21/86  Modified for NUBYE
  11. ; 08/30/85  Written to work with Northstar Horizon      - Adam Grow
  12. ; 07/17/85  Written to work with BYE5            - Irv Hoff
  13. ; 03/30/85  Written for Morrow Micro Decision Computers - Jim Sinning
  14. ;
  15. ; ========
  16. ;
  17. ;The following define the port address to use
  18. ;
  19. PORT    EQU    4        ; Data port
  20. MDCTL1    EQU    PORT+1        ; Status/control port
  21. STPORT    EQU    6        ; Motherboard status port supports
  22.                 ;   carrier detect
  23. ;
  24. ; NOTE: The baud rate header for the 2nd Serial Port must be wired for  
  25. ; 1200 baud and the configuration header for the 2nd Serial Port must
  26. ; be wired as a terminal (not modem) for this to work.
  27. ;
  28. BPORT    EQU    MDCTL1        ; Baud rate port=8251 control
  29. CPORT    EQU    MDCTL1        ; Control port=8251 control
  30. MODINS1    EQU    4EH        ; 8 bits, 1 stop, 64x, no parity
  31. ;
  32. ; See if we still have a carrier - if not, return with the zero flag set
  33. ;
  34. MDCARCK:IN    STPORT        ; Get status from motherboard status port
  35.     ANI    10H        ; Check CD bit for a carrier
  36.     CPI    10H        ; Set zero flag if no carrier
  37.     RET
  38. ;
  39. ; Disconnect and wait for an incoming call
  40. ;
  41. MDINIT:    MVI    A,10H        ; Clear DTR
  42.     OUT    MDCTL1        ; Causing hangup
  43.     PUSH    B        ; Preserve in case we need it
  44.     MVI    B,20        ; 2 second delay
  45. ;
  46. OFFTI:    CALL    DELAY        ; 0.1 second delay
  47.     DCR    B
  48.     JNZ    OFFTI        ; Keep looping until finnished
  49.     POP    B        ; Restore BC
  50.     MVI    A,17H        ; Assert DTR so that modem
  51.     OUT    MDCTL1        ; Can answer phone
  52.     CALL    UDELAY        ; Added to be safe
  53. ;
  54.      IF    IMODEM
  55.     CALL    IMINIT
  56.      ENDIF            ; IMODEM
  57. ;
  58.     RET
  59. ;
  60. ; Input a character from the modem port
  61. ;
  62. MDINP:    IN    PORT        ; Get character
  63.     RET
  64. ;
  65. ; Check the status to see if a character is available.    If not, return
  66. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  67. ;
  68. MDINST:    IN    MDCTL1        ; Get status
  69.     ANI    2        ; Check the receive ready bit
  70.     RZ            ; Return if none
  71.     ORI    0FFH        ; We have a character
  72.     RET
  73. ;
  74. ; Send a character to the modem
  75. ;
  76. MDOUTP:    OUT    PORT        ; Send it
  77.     RET
  78. ;
  79. ; See if the output is ready for another character
  80. ;
  81. MDOUTST:IN    MDCTL1
  82.     ANI    1        ; Check the transmit ready bit
  83.     RET
  84. ;
  85. ; Reinitialize the modem and hang up the phone by dropping DTR and
  86. ; leaving it inactive.
  87. ;
  88. MDQUIT:     IF    IMODEM
  89.     CALL    IMQUIT        ; Tell smartmodem to quit
  90.      ENDIF            ; IMODEM
  91. ;
  92. ; Called by the main program after caller types BYE
  93. ;
  94. MDSTOP:    MVI    A,10H        ; Turn off DTR
  95.     OUT    MDCTL1
  96.     RET
  97. ;
  98. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  99. ; speed you have available.
  100. ;
  101. SET2400    EQU    $        ; Only supports 300/1200
  102. ;
  103. SETINV:    ORI    0FFH        ; Make sure zero flag not set
  104.     RET
  105. ;
  106. SET300:    MVI    B,BD300
  107.     JMP    SETBAUD
  108. ;
  109. SET1200:MVI    B,BD1200
  110. ;
  111. SETBAUD:MVI    A,47H        ; Reset, enable Rx, DTR, Tx
  112.     OUT    MDCTL1        ; Rx,Tx enabled
  113.     CALL    UDELAY
  114.     MOV    A,B        ; Recover Baud Rate Word
  115.     OUT    BPORT
  116.     CALL    UDELAY        ; Wait for USART
  117.     MVI    A,17H        ; ERR reset, DTR, Rx, Tx all on
  118.     OUT    MDCTL1
  119.     CALL    UDELAY
  120.     XRA    A        ; Say rate OK
  121.     RET
  122. ;
  123. ; Values to switch the 8251 between x16 and x64
  124. ;
  125. BD300    EQU    4FH        ; 300 baud
  126. BD1200    EQU    4EH        ; 1200 bps
  127. ;
  128. ; IN8251 specific USART delay
  129. ;
  130. UDELAY:    NOP
  131.     NOP
  132.     NOP
  133.     RET
  134. ;
  135. ; end of insert
  136. ; -------------