home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3c-qx10.ins < prev    next >
Text File  |  1994-07-13  |  4KB  |  99 lines

  1. ;****************************************************************************
  2. ;  B3C-QX10.INS    ( QX-10 RTC clock code for BYE335)
  3. ;
  4. ;  v1.2 June 1985   Norm Gregory   Seattle's 'downspout' 206-325-1325
  5. ;
  6. ; This is to be inserted in the BYE3 code right afte IF TIMEON label following
  7. ; the machine insert.
  8. ;
  9. ; NOTE: It is no longer required that the user define the starting address
  10. ;       of the BIOS area. Modifications allowing fuller compatibility
  11. ;       with most versions of CP/M have been incorporated (i.e. removing
  12. ;       the need for indirect access to clock via BIOS jump table.
  13. ;
  14. ;    Since we are accessing the CMOS chip directly this insert should
  15. ;    work under any QX-10 operating system.
  16. ;
  17. ; THANKS TO:  Roger Lanphere (Mt Vernon, WA) for invaluable help whenever
  18. ;    asked.  Mick Gaitor (Brooklyn, NY) for much of the code here.  I
  19. ;    borrowed heavily from his MXC-QX10.ASM.  If you are using MEX on
  20. ;       your QX-10 you should be using his overlays.  Super job Mick!
  21. ;
  22. ;****************************************************************************
  23. ;
  24. BUSY    EQU     80H             ;Mask to test for clock busy condition
  25. CLKADR  EQU     3DH             ;QX-10 clock command register port
  26. CLKDAT  EQU     3CH             ;QX-10 clock data register port
  27. STBYTE  EQU     0AH             ;Clock memory addr to check for clock busy
  28. CENTURY EQU    019H        ;Hey, it's the 1900's (for a while).
  29. ;
  30.      IF    RTC
  31. TIME:   CALL    CREAD           ; read data from clock chip
  32.         LDA     TBFR+3
  33.         STA     RTCBUF+0        ; Hour
  34.         LDA     TBFR+4
  35.         STA     RTCBUF+1        ; Minute
  36.     LDA    TBFR+5
  37.     STA    RTCBUF+2    ; Second
  38.         MVI     A,CENTURY
  39.         STA     RTCBUF+3        ; Century
  40.     LDA    TBFR+0
  41.     STA    RTCBUF+4    ; Year
  42.     LDA    TBFR+1
  43.     STA    RTCBUF+5    ; Month
  44.     LDA    TBFR+2
  45.     STA    RTCBUF+6    ; Day
  46.         LDA     RTCBUF          ; Pick up BCD HH
  47.         CALL    BCDBIN          ; And convert to binary
  48.         STA     CCHOUR          ; For BYE3
  49.         LDA     RTCBUF+1        ; BCD MM
  50.         CALL    BCDBIN
  51.         STA     CCMIN           ; To binary for BYE3
  52.         RET                     ; And return (for now..)
  53. ;
  54. ;=========
  55. ;
  56. ; CREAD: gets date/time directly from the LSI 46818 chip.
  57. ;        (doing it this way rather than through the QX-10 BIOS
  58. ;        call makes this overlay independent of the version
  59. ;        of Epson's CPM (A or B) being used.)
  60. ;
  61. ; Time/Date buffer consists of 6 bytes of packed BCD-encoded information
  62. ; located in buffer TBFR.   Time/Date buffer is of the following format:
  63. ;
  64. ;        TBFR  + 0      = year
  65. ;              + 1      = month
  66. ;              + 2      = day
  67. ;              + 3      = hour
  68. ;              + 4      = minute
  69. ;              + 5      = second
  70. ;
  71. CREAD:
  72.         CALL    CLKBSY          ;Wait till clock is idle
  73.         LXI     H,TBFR          ;Point to time/date buffer
  74.         LXI     D,ADRTBL        ;Point to clock memory data address table
  75.         MVI     B,6             ;Number of data items to read
  76. TDLOOP: LDAX    D               ;Get next clock memory data address
  77.         OUT     CLKADR          ;and send addr to clock port
  78.         IN      CLKDAT          ;Read clock data
  79.         MOV     M,A             ;and store in time/date buffer
  80.         INX     H               ;Set next time/date buffer position
  81.         INX     D               ;Set next clock memory data address
  82.         DCR     B               ;One less data item
  83.         JNZ     TDLOOP          ; - continue read till done
  84.         RET
  85. ;
  86. CLKBSY:                         ;Routine to wait till clock is idle
  87.         MVI     A,STBYTE        ;Check if clock is updating
  88.         OUT     CLKADR          ;Send address
  89.         IN      CLKDAT          ;Read clock
  90.         ANI     BUSY            ;Test bit 7
  91.         JNZ     CLKBSY          ;Jump if clock busy
  92.         RET
  93. ;
  94. TBFR:   DS      6               ;Real-time clock buffer - see above
  95. ADRTBL: DB      9,8,7,4,2,0     ;Clock memory addr's for yr,mo,da,hr,min,sec
  96.      ENDIF    ;RTC
  97. ;
  98. ;***************************************************************************
  99.