; Library: ZSLIB ; Version: 1.0 ; Module: ZSGSTIMP ; Version: 1.0 ; Author: Carson Wilson ; Date: February 18, 1989 ; Purpose: Get and Set time under CP/M Plus. ; PUBLIC GTIMEP,STIMEP EXTRN DOSTYP,CPMVER,BCD2JUL,JUL2BIN,BINBCD BDOSPTR equ 5 GTIMEF equ 105 STIMEF equ 104 ; ; GTIMEP - Get current CP/M Plus time to 6-byte buffer ; ; Entry: - points to 6-byte time buffer. ; Exit: - Zero flag set (Z) and A=0 if buffer filled, ; Zero flag reset (NZ) if error. ; Uses: - . ; GTIMEP: push bc push de push hl call CHECKP ; Quit now if not + ex de,hl ; Point DE to buffer inc de ; Pt to BCD "month" to hh,mm go to right spot push de ld c,GTIMEF call BDOSPTR pop hl ld e,(hl) inc hl ld d,(hl) ; DE = Julian date inc hl ; HL --> hh inc hl ; mm inc hl ; ss ld (hl),a ; Save seconds push hl ; Save buffer ptr. ex de,hl ; HL = Julian date call JUL2BIN ; A=day, B=mon, C=yr in binary call BINBCD pop hl ; HL --> ss dec hl ; mm dec hl ; hh dec hl ; dd ld (hl),a ; Store BCD day ld a,b ; Bin. month call BINBCD dec hl ld (hl),a ; Store BCD month ld a,c ; Bin. year call BINBCD dec hl ld (hl),a ; Store BCD year xor a jr EXIT ; Return ok ; ; STIMEP - Set current CP/M Plus time from 6-byte buffer ; ; Entry: - points to 6-byte time buffer. ; Exit: - Zero flag set (Z) and A=0 if clock set, ; Zero flag reset (NZ) if error. ; Uses: - . ; STIMEP: push bc push de push hl call CHECKP ; Ensure CP/M Plus call BCD2JUL ex de,hl ; DE=Julian date pop hl ; HL --> buffer push hl inc hl push hl ; Save ptr for call ld (hl),e ; Store Julian Lo inc hl ld (hl),d ; ..and Hi inc hl inc hl inc hl ld a,(hl) ; Get ss pop de ld c,STIMEF call BDOSPTR xor a ; No error jr EXIT CHECKP: call DOSTYP ; Test if CP/M Plus jr nz,EXIT ; Abort if extended BDOS ld a,(CPMVER) cp 30h ; Plus? ret nc ; Yes pop hl ; No, remove return address & fall through.. EXIT: pop hl pop de pop bc ret end ; End ZSGSTIMP.Z80