home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / dbaseii / dbclock.lbr / DBCLOCK.ZZ0 / DBCLOCK.Z80
Text File  |  1987-05-23  |  2KB  |  102 lines

  1.  
  2. ;    ******************************************
  3. ;    *                     *
  4. ;    *    READ DATESTAMPER FOR DBASE II     *
  5. ;    *    May 14, 1987, Bruce Morgen     *
  6. ;    *                     *
  7. ;    ******************************************
  8.  
  9. ; This code has been tested with dBaseII Version 2.41 ONLY!
  10. ; It is based on TM-DS10.Z80 by Jim Lill and KP4CLOCK.Z80
  11. ; by Ulrich Steinberg.  Note that no self-modifying code is
  12. ; employed to read the DateStamper "clock" - this is of no
  13. ; particular consequence on today's Z80-compatible CPUs but
  14. ; is a good habit to get into for pipelined chips like the
  15. ; upcoming Z280.
  16.  
  17. DBFREE    EQU    0A400H        ; First free memory above dBase
  18. BDOS    EQU    5        ; DOS call vector
  19. CPMVER    EQU    12        ; Get CP/M version function #
  20. DSCLUE    EQU    'D'        ; Returned by DateStamper
  21.  
  22.     ORG    DBFREE
  23.  
  24. ;    Entry "vector"
  25.  
  26.     JR    DATE
  27.     JR    WDAY        ; Dummy for day-of-week
  28.     JR    TIME
  29.  
  30. DATE:
  31.     CALL    READRTC        ; Read real time clock
  32.     RET    NZ
  33.     LD    A,(MONTH)
  34.     CALL    STORE        ; Store month in memory variable
  35.     INC    HL
  36.     LD    (HL),'/'
  37.     LD    A,(DAY)
  38.     CALL    STORE        ; Store day in memory variable
  39.     INC    HL
  40.     LD    (HL),'/'
  41.     LD    A,(YEAR)
  42.     JR    STORE        ; Return to dBase via STORE
  43.  
  44. TIME:    CALL    READRTC
  45.     RET    NZ
  46.     LD    A,(HOUR)
  47.     CALL    STORE
  48.     INC    HL
  49.     LD    (HL),':'
  50.     LD    A,(MINUTE)
  51.     JR    STORE        ; Return to dBase via STORE
  52.  
  53. ;    Read The DateStamper's "real time clock"
  54.  
  55. READRTC:
  56.     PUSH    HL        ; Save pointer
  57.     LD    E,DSCLUE
  58.     LD    C,CPMVER
  59.     CALL    BDOS
  60.     CP    22H        ; MUST be Version 2.2
  61.     RET    NZ
  62.     LD    A,H
  63.     CP    DSCLUE
  64.     RET    NZ
  65.     LD    HL,RETURN    ; Avoids self-modifying code:
  66.     PUSH    HL        ; DS's RET will get back there
  67.     PUSH    DE        ; Our 1st RET will get to DS
  68.     LD    HL,COUNTERS    ; Point to our data space
  69.     RET            ; "CALL"ing The DateStamper
  70. RETURN:    POP    HL        ; Recover pointer to dBaseII
  71. WDAY:    RET            ; Doubles as dummy routine
  72.  
  73. ;    Store ASCII in dBaseII's memory variables
  74.  
  75. STORE:    LD    B,A        ; Stash BCD in B
  76.     RRCA            ; Exchange nybbles
  77.     RRCA
  78.     RRCA
  79.     RRCA
  80.     AND    0FH        ; Mask
  81.     ADD    A,'0'        ; ASCII
  82.     INC    HL        ; Bump pointer
  83.     LD    (HL),A        ; Store
  84.     LD    A,B        ; Get other nybble
  85.     AND    0FH        ; Mask
  86.     ADD    A,'0'        ; ASCII
  87.     INC    HL        ; Bump pointer
  88.     LD    (HL),A        ; Store
  89.     RET
  90.  
  91. ;    BCD counter storage
  92.  
  93. COUNTERS:
  94. YEAR:    DS    1
  95. MONTH:    DS    1
  96. DAY:    DS    1
  97. HOUR:    DS    1
  98. MINUTE:    DS    1
  99. SECOND:    DS    1
  100.  
  101.     END    DBFREE
  102.