; ****************************************** ; * * ; * READ DATESTAMPER FOR DBASE II * ; * May 14, 1987, Bruce Morgen * ; * * ; ****************************************** ; ; Version 1.1 by Rick Charnes and Bruce Morgen. XOR A ; added after RETURN: label -- DateStamper doesn't ; necessarily return a 0 -- see UPD file. Works fine ; with dBaseII version 2.40. Feb. 20, 1988 ; ; This code has been tested with dBaseII Version 2.41 ONLY! ; It is based on TM-DS10.Z80 by Jim Lill and KP4CLOCK.Z80 ; by Ulrich Steinberg. Note that no self-modifying code is ; employed to read the DateStamper "clock" - this is of no ; particular consequence on today's Z80-compatible CPUs but ; is a good habit to get into for pipelined chips like the ; upcoming Z280. DBFREE EQU 0A400H ; First free memory above dBase BDOS EQU 5 ; DOS call vector CPMVER EQU 12 ; Get CP/M version function # DSCLUE EQU 'D' ; Returned by DateStamper ORG DBFREE ; Entry "vector" JR DATE JR WDAY ; Dummy for day-of-week JR TIME DATE: CALL READRTC ; Read real time clock RET NZ LD A,(MONTH) CALL STORE ; Store month in memory variable INC HL LD (HL),'/' LD A,(DAY) CALL STORE ; Store day in memory variable INC HL LD (HL),'/' LD A,(YEAR) JR STORE ; Return to dBase via STORE TIME: CALL READRTC RET NZ LD A,(HOUR) CALL STORE INC HL LD (HL),':' LD A,(MINUTE) JR STORE ; Return to dBase via STORE ; Read The DateStamper's "real time clock" READRTC: PUSH HL ; Save pointer LD E,DSCLUE LD C,CPMVER CALL BDOS CP 22H ; MUST be Version 2.2 RET NZ LD A,H CP DSCLUE RET NZ LD HL,RETURN ; Avoids self-modifying code: PUSH HL ; DS's RET will get back there PUSH DE ; Our 1st RET will get to DS LD HL,COUNTERS ; Point to our data space RET ; "CALL"ing The DateStamper RETURN: POP HL ; Recover pointer to dBaseII XOR A ; NEW LINE ADDED 2/20/88 WDAY: RET ; Doubles as dummy routine ; Store ASCII in dBaseII's memory variables STORE: LD B,A ; Stash BCD in B RRCA ; Exchange nybbles RRCA RRCA RRCA AND 0FH ; Mask ADD A,'0' ; ASCII INC HL ; Bump pointer LD (HL),A ; Store LD A,B ; Get other nybble AND 0FH ; Mask ADD A,'0' ; ASCII INC HL ; Bump pointer LD (HL),A ; Store RET ; BCD counter storage COUNTERS: YEAR: DS 1 MONTH: DS 1 DAY: DS 1 HOUR: DS 1 MINUTE: DS 1 SECOND: DS 1 END DBFREE