home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bye5 / b5-clock.lbr / B5C-DCH2.IQS / B5C-DCH2.INS
Encoding:
Text File  |  1986-03-09  |  7.5 KB  |  228 lines

  1. ;**************************************************************
  2. ;
  3. ; B5C-DCH2.INS A TIME insert for BYE501 and up
  4. ;  10/19/85    Modified for BYE501 (clock read on c/r) F.E. Clayton
  5. ;  10/08/85    Modified for Zorba   F.E. Clayton
  6. ;  08/08/85    Note:  This is an insert -- not an overlay
  7. ;            Bucky Carr
  8. ;            World Peace RCP/M, 303-320-4822
  9. ;
  10. ; Adapted from:
  11. ; MBC-DCH1.ASM -- Version 1.1 -- 17 Apr 85 -- by Barron F. McIntire III
  12. ;
  13. ;   TIME routine for BYE5 running on machine with Hayes Chronograph
  14. ;   Clock connected to second serial port. This overlay should be
  15. ;   easily configurable to any system which has an extra RS-232 port to
  16. ;   which the clock may be connected.  
  17. ;
  18. ;   Insure that your clock set program does NOT set the time and
  19. ;   date separators on the Hayes.
  20. ;
  21. ;   With BYE502 the clock is read only after a c/r is sent. The code below
  22. ;   will read both the DATE and TIME when BYE answers the phone and
  23. ;   detects a carrier.
  24. ;   After the first read the DATE is read every 48 c/r's. This makes
  25. ;   the TIME read undetectable at 300 bps, just detectable at 1200 bps,
  26. ;   and noticable (but not TOO bad) at 2400.
  27. ;   Higher speeds (than 2400) are going to require a different approach.
  28. ;
  29. ;   NOTE: Your second serial will need to be initialized and set
  30. ;   to 1200 bps. 
  31. ;
  32. ;   Code must be placed in the BYE5 ANSW: area to set the
  33. ;   start value into the counter, when the caller's carrier is
  34. ;   recognized:
  35. ;         IF HAYCLK
  36. ;        LXI    H,0        ;when CLKCTR=0 then read clock
  37. ;        SHLD    CLKCTR        ;location where the count resides
  38. ;         ENDIF            ; hayclk
  39. ;
  40. ;   is all that is necessary.  This makes sure that the clock is read
  41. ;   as soon as the carrier is detected.
  42. ;
  43. ;   When called this routine will check the RTCBUF.  If a '99H' is in
  44. ;   the first byte, then clock is initialized.    Next, the seconds are
  45. ;   checked, and if changed since last update of RTC buffer, the clock
  46. ;   is read and new data copied to the RTCBUF.    The BCD hours and
  47. ;   minutes are converted to binary and stored in CCMIN and CCHOUR.
  48. ;
  49. ;   Notes by - Bucky Carr, World Peace RCP/M
  50. ;           303-320-4822
  51. ;   Addional notes and changes by - F.E. Clayton
  52. ;              FIDO 12/4 808-245-2080
  53. ;              Zorba Net #2 (RCP/M) 808-337-9280
  54. ;**********************************************************************
  55. HAYCLK     EQU    YES        ;For code above inserted at ANSW:
  56. ;
  57. ;        ;Next two address points for Zorba 25th line so
  58. ;        ;My BBS system can find date and time, as well as
  59. ;        ;for sysop use. (When did last user log off??)
  60. ;
  61. TME    EQU    0FEA6H        ;Zorba 25th line
  62. DTE    EQU    0FEADH        ;Zorba 25th line 
  63. ;
  64. CDAT    EQU    22H        ; Put your clock data port here
  65. CSTAT    EQU    23H        ; Put your clock status port here
  66. ;
  67. ; The Line Status Register is evaluated for whether a character is waiting
  68. ; in the receive buffer (from the clock) or whether the transmit buffer
  69. ; is empty and ready for another character (to the clock.)  The actual
  70. ; data is sent and fetched, as the case may be, from the data port.  
  71. ;
  72. TBE    EQU    01H        ; Mask for transmit buffer empty (ready)
  73. RBF    EQU    02H        ; Mask for receive buffer full (ready)
  74. ;
  75. CENTURY EQU    019H        ; BCD for 20th Century
  76. ;
  77. TIME:
  78.     PUSH    PSW        ; This register pair isn't saved by BYE500
  79.     LHLD    CLKCTR        ; Get counter value
  80.     MOV    A,L        ; Get lo bite
  81.     CPI    00H        ; Is it 0?
  82.     JNZ    DECRMT        ; No?  Then decrement and exit
  83.     MOV    A,H        ; Get hi bite
  84.     CPI    00H        ; Is it 0?
  85.     JZ    CLOCK1        ; If 0 read DATE and update RTCBUF
  86. DECRMT:
  87.     DCX    H        ; Otherwise decrement counter...
  88.     SHLD    CLKCTR        ; save...
  89.     JMP    CLOCK2        ; Read TIME but NOT DATE and update RTCBUF
  90. ;
  91. CLOCK1:    LHLD    CLKWT
  92.     SHLD    CLKCTR
  93.     LXI    H,RDDATE    ; Set pointer to 'ATRD' message
  94.     CALL    CLKRD        ; Read date
  95.     LXI    H,CLKASC    ; Set pointer to ASCII storage
  96.     CALL    GETASC        ; Get ASCII character
  97.     STA    DTE+0        ; Put it on 25th line
  98.     CALL    GETCHR        ; Get hi year char
  99.     RLC ! RLC ! RLC ! RLC    ; Mov to hi nibble for BCD
  100.     MOV    B,A        ; Save nibble
  101.     INX    H
  102.     CALL    GETASC        ; Get ASCII Char.
  103.     STA    DTE+1        ; Add it to 25th line
  104.     CALL    GETCHR        ; Get lo year char
  105.     ORA    B        ; Put nibbles together
  106.     STA    RTCBUF+4    ; Put year in RTCBUF
  107.     INX    H
  108.     CALL    GETASC        ; Get ASCII char.
  109.     STA    DTE+2        ; add to 25th line
  110.     CALL    GETCHR        ; Get hi month char
  111.     RLC ! RLC ! RLC ! RLC    ; Mov to hi nibble for BCD
  112.     MOV    B,A        ; Save nibble
  113.     INX    H
  114.     CALL    GETASC        ; Get ASCII Character
  115.     STA    DTE+3        ; Add to 25th line
  116.     CALL    GETCHR        ; Get lo month char
  117.     ORA    B        ; Put nibbles together
  118.     STA    RTCBUF+5    ; Put month in RTCBUF
  119.     INX    H
  120.     CALL    GETASC        ; Get ASCII Character
  121.     STA    DTE+4        ; Add to 25th line
  122.     CALL    GETCHR        ; Get hi day char
  123.     RLC ! RLC ! RLC ! RLC    ; Mov to hi nibble for BCD
  124.     MOV    B,A        ; Save nibble
  125.     INX    H
  126.     CALL    GETASC        ; Get ASCII Character
  127.     STA    DTE+5        ; Add to 25th line
  128.     CALL    GETCHR        ; Get lo day char    
  129.     ORA    B        ; Put nibbles together
  130.     STA    RTCBUF+6    ; Put day in RCTBUF
  131.     MVI    A,CENTURY    ; Set century value for RTCBUF+3
  132.     STA    RTCBUF+3    ; and store it
  133. ;
  134. CLOCK2:    LXI    H,RDTIME    ; Set pointer to 'ATRT' message
  135.     CALL    CLKRD        ; Read time
  136.     LXI    H,CLKASC    ; Point to stored ASCII data
  137.     CALL    GETASC        ; Get ASCII Character
  138.     STA    TME+0        ; Add to 25th line
  139.     CALL    GETCHR        ; Get hi hours char
  140.     RLC ! RLC ! RLC ! RLC    ; Mov to hi nibble for BCD
  141.     MOV    B,A        ; Save nibble
  142.     INX    H    
  143.     CALL    GETASC        ; Get ASCII Character
  144.     STA    TME+1        ; Add to 25th line
  145.     CALL    GETCHR        ; Get lo hours char
  146.     ORA    B        ; Put nibbles together    
  147.     STA    RTCBUF+0    ; Put hours in RTCBUF
  148.     INX    H
  149.     CALL    GETASC        ; Get ASCII Character
  150.     STA    TME+2        ; Add to 25th line
  151.     CALL    GETCHR        ; Get hi minutes char
  152.     RLC ! RLC ! RLC ! RLC    ; Mov to hi nibble for BCD
  153.     MOV    B,A        ; Save nibble
  154.     INX    H    
  155.     CALL    GETASC        ; Get ASCII Character
  156.     STA    TME+3        ; Add to 25th line
  157.     CALL    GETCHR        ; Get lo minutes char
  158.     ORA    B        ; Put nibbles together
  159.     STA    RTCBUF+1    ; Put minutes in RTCBUF
  160.     INX    H
  161.     CALL    GETASC        ; Get ASCII Character
  162.     STA    TME+4        ; Add to 25th line
  163.     CALL    GETCHR        ; Get hi seconds char
  164.     RLC ! RLC ! RLC ! RLC    ; Mov to hi nibble for BCD
  165.     MOV    B,A        ; Save nibble
  166.     INX    H
  167.     CALL    GETASC        ; Get ASCII Character
  168.     STA    TME+5        ; Add to 25th line
  169.     CALL    GETCHR        ; Get lo seconds char
  170.     ORA    B        ; Put nibbles together
  171.     STA    RTCBUF+2    ; Put minutes in RTCBUF
  172. ;
  173. ;
  174. CLOCK3:    LDA    RTCBUF        ; get the BCD hours
  175.     CALL    BCDBIN        ; convert to binary
  176.     STA    CCHOUR        ; store it
  177.     LDA    RTCBUF+1    ; now get the BCD minutes
  178.     CALL    BCDBIN        ; convert to binary
  179.     STA    CCMIN        ; store it
  180. CLKEXIT:
  181.     POP    PSW
  182.     RET            ; Return to BYE500
  183. ;
  184. CLKRD:
  185.     IN    CSTAT        ; Get status of the transmit buffer
  186.     ANI    TBE        ; Is it empty
  187.     JZ    CLKRD        ; No, loop until it is
  188.     MOV    A,M        ; Get char from ATxx string in memory
  189.     CPI    80H        ; Are we done with the string?
  190.     JZ    CLKIN        ; Yes, get ASCII from clock
  191.     OUT    CDAT        ; Otherwise send char to clock
  192.     INX    H        ; Point to next char
  193.     JMP    CLKRD        ; And do it again
  194. CLKIN:
  195.     LXI    H,CLKASC    ; Set pointer to next ASCII storage location
  196. CLKIN2:
  197.     IN    CSTAT        ; Get status of the receive buffer
  198.     ANI    RBF        ; Is there a character waiting for us?
  199.     JZ    CLKIN2        ; No, loop until there is
  200.     IN    CDAT        ; Yes, get char
  201.     MOV    M,A        ; Store it
  202.     CPI    0DH        ; Carriage return?
  203.     RZ            ; Return if so
  204.     INX    H        ; Else point to next storage location
  205.     JMP    CLKIN2        ; Get next char
  206. ;
  207. GETCHR:
  208.     MOV    A,M        ; Get character
  209.     SUI    30H        ; Convert from ASCII to binary
  210.     ANI    0FH        ; Clear hi nibble
  211.     RET
  212. ;
  213. GETASC:    MOV    A,M        ; Get character w/o change
  214.     RET
  215. ;
  216. RDTIME: DB    'ATRT',CR,80H
  217. RDDATE: DB    'ATRD',CR,80H
  218. CLKASC: DS    7
  219. CLKCTR: DS    2
  220. SECS:    DS    1
  221. CLKWT:    DW    0030H        ; # c/r's sent out between DATE reads
  222. ;
  223. ;......
  224. ;
  225. ; End of the CLOCK routine
  226. ;
  227. ;******************************************************************
  228.