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 / NUPH-1.IQS / nuph-1.ins
Text File  |  1986-04-26  |  3KB  |  139 lines

  1. ; NUPH-1.INS - NUBYE insert for Philips "Happy Man" P2000C - 04/21/86
  2. ;
  3. ; Zilog Z80-SIO and 8430 CTC timer
  4. ;
  5. ; Note:  This is an insert, not an overlay.
  6. ;
  7. ;
  8. ; ========
  9. ;
  10. ; 04/21/86  Modified for NUBYE
  11. ; 07/17/85  Written for use with BYE5        - Irv Hoff
  12. ;
  13. ; ========
  14. ;
  15. PORT    EQU    28H        ; Data port
  16. MDCTL1    EQU    PORT+1        ; Modem control port
  17. BRPORT    EQU    21H        ; Baud rate generator port (CTC)
  18. ;
  19. MDRCV    EQU    1        ; Modem receive ready bit
  20. MDSND    EQU    4        ; Modem send ready bit
  21. MDDCD    EQU    8        ; Data carrier detect
  22. ;
  23. ; First byte of CTC Command:
  24. ;
  25. BDCMD1    EQU    47H        ; Counter mode
  26. ;
  27. BD300    EQU    128        ; 300 baud
  28. BD1200    EQU    32        ; 1200 bps
  29. BD2400    EQU    16        ; 2400 bps
  30. ;
  31. ; See if we still have a carrier - if not, return with the zero flag set
  32. ;
  33. MDCARCK:MVI    A,10H        ; Reset status
  34.     OUT    MDCTL1
  35.     IN    MDCTL1        ; Get status
  36.     ANI    MDDCD        ; Check for carrier
  37.     RET
  38. ;
  39. ; Disconnect and wait for an incoming call
  40. ;
  41. MDINIT:    MVI    A,0        ; Setup to write register 0
  42.     OUT    MDCTL1
  43.     MVI    A,18H        ; Reset channel
  44.     OUT    MDCTL1
  45.     MVI    A,4        ; Setup to write register 4
  46.     OUT    MDCTL1
  47.     MVI    A,44H        ; Set 16x, 1 stop bit, no parity
  48.     OUT    MDCTL1
  49.     MVI    A,3        ; Setup to write register 3
  50.     OUT    MDCTL1
  51.     MVI    A,0C1H        ; 8 bits, Rx enable
  52.     OUT    MDCTL1
  53.     MVI    A,5        ; Setup to write register 5
  54.     OUT    MDCTL1
  55.     MVI    A,68H        ; DTR off
  56.     OUT    MDCTL1
  57.     PUSH    B        ; Save in case it's being used elsewhere
  58.     MVI    B,20        ; 2 second delay to drop any carrier
  59. ;
  60. OFFTI:    CALL    DELAY        ; 1 second delay
  61.     DCR    B
  62.     JNZ    OFFTI        ; Keep looping until finished
  63.     POP    B        ; Restore 'BC'
  64.     MVI    A,5        ; Setup to write register 5
  65.     OUT    MDCTL1
  66.     MVI    A,0E8H        ; Turn DTR back on
  67.     OUT    MDCTL1
  68. ;
  69.      IF    IMODEM        ; If using an intellegent modem
  70.     CALL    IMINIT        ; Go initialize it now
  71.      ENDIF            ; IMODEM
  72. ;
  73.     RET
  74. ;
  75. ; Input a character from the modem port
  76. ;
  77. MDINP:    IN    PORT        ; Get character
  78.     RET
  79. ;
  80. ; Check the status to see if a character is available.  If yes, return
  81. ; with the zero flag set and use 0FFH to clear the flag.
  82. ;
  83. MDINST:    IN    MDCTL1        ; Get status
  84.     ANI    MDRCV        ; Got a character
  85.     RZ            ; Return if none
  86.     ORI    0FFH        ; Otherwise set the proper flag
  87.     RET
  88. ;
  89. ; Send a character to the modem
  90. ;
  91. MDOUTP:    OUT    PORT        ; Send it
  92.     RET
  93. ;
  94. ; See if the output is ready for another character
  95. ;
  96. MDOUTST:IN    MDCTL1        ; Get status
  97.     ANI    MDSND        ; Ready for a character?
  98.     RET
  99. ;
  100. ; Reinitialize the modem and hang up the phone by dropping DTR and
  101. ; leaving it inactive.
  102. ;
  103. MDQUIT:     IF    IMODEM
  104.     CALL    IMQUIT
  105.      ENDIF            ; IMODEM
  106. ;
  107. ; Called by the main program after caller types BYE
  108. ;
  109. MDSTOP:    MVI    A,5        ; Setup to write register 5
  110.     OUT    MDCTL1
  111.     MVI    A,68H        ; Turn off DTR until next time
  112.     OUT    MDCTL1
  113.     RET
  114. ;
  115. ; The following routine sets the baudrate.  NUBYE asks for the maximum
  116. ; speed you have available.
  117. ;
  118. SETINV:    ORI    0FFH        ; Make sure zero flag is not set
  119.     RET
  120. ;
  121. SET300:    MVI    B,BD300        ; Set for 300 baud
  122.     JMP    SETBAUD
  123. ;
  124. SET1200:MVI    B,BD1200    ; Set for 1200 bps
  125.     JMP    SETBAUD
  126. ;
  127. SET2400:MVI    B,BD2400    ; Set for 2400 bps
  128.     PUSH    PSW
  129. ;
  130. SETBAUD:MVI    A,BDCMD1    ; Get CTC command word
  131.     OUT    BRPORT        ; Send first byte of command
  132.     MOV    A,B        ; Restore the baudrate
  133.     OUT    BRPORT        ; Send rate
  134.     XRA    A        ; Say rate is ok
  135.     RET
  136. ;
  137. ; end of insert
  138. ; -------------
  139.