;*************************************************** ; ; AR9QOZ8D.Z80 ; 3/19/88 ; Gene Nolan ; ; ; AR9QOZ8D is an overlay file for ARUNZ09Q ; that provides support of Z80DOS type of ; date storage for recall with the $D parameter ; of ARUNZ09Q. It supports Y,M,D,H,C,N,A requests. ; ; If you are overlaying the .3OM file, select ; the second definition of BIAS1 below, and ; if you are overlaying the .COM file, select ; the first definition. Sorry, no support for ; the .4OM file. ; ; Assemble to a .HEX file and overlay using: ; ; MLOAD CMDRUN.COM=ARUNZ09Q.COM,AR9QOZ8D ; ; OR ; ; MLOAD CMDRUN.COM=ARUNZ09Q.3OM,AR9QOZ8D ; bias equ 100h bias1 equ 0 ; 0 for .COM ;bias1 equ 8000h-bias ; 8000-bias for .3OM org bias+1f1h nop ; Patch out a Ret Z org bias+0b0ch ; Was AC3 in AR9NOZ8D.Z80 ex de,hl ld hl,(z8dcall+1+bias1) ld a,h or l nop ; patch out Ret Z ex de,hl z8dcall: call getdate+bias1 hlchk: ld a,h or a,l ret z8dchk: ld e,44h ld c,0ch call 5 cp 22h jr nz,not22 ld a,h nop ; Patch out check for Datestamper nop jr z,z8dhere not22: ld de,0 z8dhere: ex de,hl nop nop nop jr hlchk org bias+1680h ; New routines to above ARUNZ stack getdate: push bc ; Save push hl ; BCD Y/M/D/H/M/S goes here ld de,jday+bias1 ; Use BDOS call to put time here ld c,105 CALL 5 ld hl,jday+bias1 ; Point to data base ld e,(hl) ; Get JD in DE inc hl ld d,(hl) ex de,hl ; to HL call datehl+bias1 push hl ; Month and Year in L,H pop de ; Now in DE pop hl ; And put them here push af ; Day in A ld (hl),d ; Year in inc hl ld (hl),e ; Month in inc hl pop af ld (hl),a ; And day in inc hl ld a,(hrs+bias1) ; Get BCD hours ld (hl),a inc hl ld a,(mins+bias1) ; BCD mins ld (hl),a pop bc ret ; Module Name: DATEHL ; Author: Carson Wilson ; Version: 1.0 ; Date: 25 Sept 87 ; ; DATEHL converts the value in HL to BCD year, month, day ; for use with Z80DOS time stamps. ; ; Inputs: HL contains hex days since December 31, 1977 ; ; Outputs: H contains BCD 20th century year ; L contains BCD month ; A contains BCD day ; ; Zero flag set (Z) and A=0 if invalid date (zero) detected, ; Zero flag reset (NZ) and A=0ffh otherwise. ; Adapted from B5C-CPM3.INS DateHL: ld a,h or l ; Test blank date (zero) ret z ; Return Z and A=0 if so ld (days+bias1),hl ; Save initial value ld b,78 ; Set years counter loop: call ckleap+bias1 ld de,-365 ; Set up for subtract jr nz,nolpy ; Skip if no leap year dec de ; Set for leap year nolpy: add hl,de ; Subtract jr nc,ydone ; Continue if years done ld a,h or l jr z,ydone ld (days+bias1),hl ; Else save days count inc b ; Increment years count jr loop ; And do again ; ; The years are now finished, the years count is in 'B' (HL is invalid) ; ydone: ld a,b call binbcd+bias1 ld (year+bias1),a ; save BCD year ; call ckleap+bias1 ; Check if leap year ld a,-28 jr nz,febno ; February not 29 days ld a,-29 ; Leap year febno: ld (feb+bias1),a ; Set february ld hl,(days+bias1) ; Get days count ld de,mtable+bias1 ; Point to months table ld b,0ffh ; Set up 'B' for subtract ld a,0 ; Set a for # of months mloop: push af ld a,(de) ; Get month ld c,a ; Put in 'C' for subtract pop af ld (days+bias1),hl ; save days count add hl,bc ; Subtract inc de ; Increment months counter inc a jr c,mloop ; Loop for next month ; ; The months are finished, days count is on stack. First, calculate ; month. ; mdone: ld b,a ; Save months ld hl,(days+bias1) ld a,h or l jr nz,nzd dec de dec de ld a,(de) cpl inc a ld l,a dec b nzd: ld a,l ; Retrieve binary day of month call binbcd+bias1 ; Convert to BCD push af ; Save day in A ; ld a,b ; Retrieve the binary month call binbcd+bias1 ; Convert binary month to BCD ld l,a ; Return month in L ; ld a,(year+bias1) ld h,a ; Return year in H ; or 0ffh ; Return no error pop af ; Restore day ret ; ; Support Routines: ; ; ; Check for leap years. ; ckleap: ld a,b and 0fch cp b ret ; ; Convert A to BCD & store back in A ; BinBCD: or a ret z push bc ld b,a xor a BinBCD1: add a,1 daa djnz BinBCD1 pop bc ret ; ; Buffers: ; ; ; Months table ; mtable: db -31 ;January feb: db -28 ;February db -31,-30,-31,-30 ;Mar-Jun db -31,-31,-30 ;Jul-Sep db -31,-30,-31 ;Oct-Dec days: ds 2 ; temporary buffers year: ds 1 ; END DATEHL.Z80 JDAY: DS 2 HRS: DS 1 MINS: DS 1 SECS: DS 1 END