home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zdbdat11.lbr / ZDBDAT11.ZZ0 / ZDBDAT11.Z80
Encoding:
Text File  |  1991-06-22  |  4.6 KB  |  146 lines

  1. ;
  2. ;       TITLE   'ZDBDATE.Z80 DBase II DATE SET FUNCTION '
  3. ;
  4. ;       This program is used to create an overlay for DBase II which
  5. ;       will set the clock using the ZSDOS Function 98 (Get Time).
  6. ;       
  7. ;       The program is compatible with both plain vanilla DBASE.COM
  8. ;       files and with files that have been modified by NEWBASE.COM.
  9. ;       
  10. ;    The program will set the date when entering DBase if ZSDOS
  11. ;    and an appropriate clock driver are present.  If there is an
  12. ;    error reading the clock the program will print the message
  13. ;    'CLOCK NOT WORKING' and will return to DBase.  If the version
  14. ;    of DBase does not have the Newbase 'SKIPDATE' on, you will be
  15. ;    prompted for the date.
  16. ;
  17. ;    Information on the size and location of the free area in the
  18. ;    various versions of DBase was obtained from the program
  19. ;    NEWBASE.ASM.  Only versions 2.41 & 2.43* have a sufficient
  20. ;    free area to use this program.
  21. ;
  22. ;    Many thanks to Gene Head, the author of NEWBASE.ASM (TM), whose
  23. ;    work in dissecting the various versions of DBase II provided
  24. ;     starting points and valuable aid in preparing this routine and
  25. ;    to the developers of ZSDOS and the ZSYStem libraries.
  26. ;
  27. ;    If anyone wishes to incorporate this program into other versions
  28. ;    of DBase - the writer will be willing to provide help as required.
  29. ;    Please leave a message on Jay Sage's Znode (617) 965-7259 or call
  30. ;    me at (516) 224-5935 voice-evenings.
  31. ;                        Ed McGovern
  32. ;
  33. ;       REVISION HISTORY
  34. ;       ================
  35. ;
  36. ;    22-Jun-91 Gene Pizzetta
  37. ;        ZDBDATE did not work (in fact, crashed the system, if
  38. ;        NEWBASE had the ALTDRIVE (ZCPR) equate set TRUE for DBASE
  39. ;        version 2.43*.  It now overwrites part of the "Thirty days
  40. ;        hath September" message instead.  I don't own DBASE 2.41,
  41. ;        so somebody else will have to deal with that one.
  42. ;    14-Jun-91 Ed McGovern
  43. ;        Original Release
  44. ;
  45. false    equ    0
  46. true    equ    false-1
  47. bdos    equ    0005h
  48. gt_time    equ    62h
  49. CR    equ    0Dh
  50. LF    equ    0Ah
  51. ;
  52. ;
  53. ;set the equate for your version of dbII to true
  54.  
  55. db241    equ    false
  56. db243    equ    true
  57.  
  58.   if    db241
  59. date    equ    44ffh        ; month location in version 2.41 (mdy)
  60. hdate    equ    4b45h        ; high date day location (dmy)
  61. db_ret    equ    49ffh        ; address for normal return to dbase
  62. free    equ    45a7h        ; free area in version 2.41 (344 bytes)
  63. jp_date    equ    48e2h        ; address to patch to jump to date routine
  64. nc_ret    equ    491bh        ; address to return to if clock error
  65. pr_msg    equ    36c5h        ; dbase print message routine
  66.   endif
  67.  
  68.   if    db243
  69. date    equ    4941h        ; month location in version 2.43*
  70. hdate    equ    501eh        ; high date day location (dmy)
  71. db_ret    equ    4eaeh        ; address for normal return to dbase
  72. free    equ    4a2bh        ; free area in version 2.43* (112 bytes)
  73. morfre    equ    4f74h        ; more free area if NEWBASE is used
  74. jp_date    equ    4d91h        ; address to patch for jump to date routine
  75. nc_ret    equ    4dcah        ; address to return to if clock error
  76. pr_msg    equ    3a90h        ; dbase print message routine
  77.   endif
  78.  
  79.     page
  80. ;
  81. ; main line
  82. ;
  83.     org    free        ;org at start of free area
  84.     exx            ;save the registers
  85.     ld    de,buffer    ;location to store datespec
  86.     ld    c,gt_time    ;Call the ZSDOS get-time
  87.     call    bdos        ; function
  88.     inc    a        ;check for error and
  89.     jr    z,noclock    ; branch if we have one
  90.     ld    hl,buffer    ;location to store datespec
  91.     ld    de,date+2    ;destination (Year location in date)
  92.     ld    ix,hdate    ;high date location
  93.     ld    a,(hl)        ;get the year,
  94.     call    bcd2bin        ; convert it to binary,
  95.     ld    (de),a        ; and store it in date
  96.     ld    (ix+2),a    ; and hdate
  97.     dec    de        ;point to the month 
  98.     dec    de        ; in dbase and
  99.     inc    hl        ; the datespec
  100.     ld    a,(hl)        ;get the month,
  101.     call    bcd2bin        ; convert it to binary,
  102.     ld    (de),a        ; store it in date
  103.     ld    (ix+1),a    ; and hdate
  104.     inc    hl        ;point to the day in the
  105.     inc    de        ; datespec and dbase
  106.     ld    a,(hl)        ;get the day,
  107.     call    bcd2bin        ; convert it to binary,
  108.     ld    (de),a        ; and store it
  109.     ld    (ix+0),a
  110.     exx            ;restore the registers
  111.     jp    db_ret        ;normal return
  112.     ;
  113. noclock ld    hl,msg        ;load the error message address
  114.     call    pr_msg        ;print the message
  115.     exx            ;restore the registers
  116.     jp    nc_ret        ; and return to dbase date routine
  117. ;
  118. buffer    defs    12,0
  119.  
  120.  IF DB243
  121.      org    morfre
  122.      db    0
  123.  ENDIF    ; DB243
  124. ;
  125. msg:    defb    'CLOCK NOT WORKING',CR,LF,0
  126. ;
  127. bcd2bin    ld    b,a        ;save the byte
  128.     and    0f0h        ;clear the low nibble
  129.     rrc    a        ;shift right 1 bit
  130.     ld    c,a        ;and put it into C (hi-nibble *8)
  131.     rrc    a
  132.     rrc    a        ;hi-nibble*2
  133.     add    c        ;hi-nibble * 10
  134.     ld    c,a
  135.     ld    a,b        ;restore the byte
  136.     and    0fh        ;clear the hi-nibble
  137.     add    a,c        ;add to binary hi-nibble
  138.     ret            ; and return
  139. ;
  140. ;---------------------------------------------------------------
  141. ;
  142.     org    jp_date        ;jump to modifiy to reference new routine
  143.     jp    free        ;new instruction
  144. ;
  145.     end
  146.