home *** CD-ROM | disk | FTP | other *** search
- ; Library: ZSLIB
- ; Version: 3.6
- ; Module: ZSLIBDEM
- ; Version: 3.2
- ; Author: Gene Pizzetta
- ; Date: March 11, 1992
- ; Changes: Now works without direct cursor addressing on non-ZCPR3
- ; systems (albeit, a lot less neatly), initializes and
- ; de-initializes terminal (like it should have done all
- ; along), and uses invocation name on help screen, if
- ; possible.
- ;
- ; Version: 3.1
- ; Author: Gene Pizzetta
- ; Date: January 31, 1992
- ; Changes: Now uses dual format date and time routines instead of
- ; now obsolete single format modules. Several minor display
- ; changes.
- ;
- ; Version: 3.0
- ; Author: Gene Pizzetta
- ; Date: July 21, 1991
- ; Changes: Display extensively modified. Requires cursor addressing.
- ; Added displays for new ZSLIB 3.0 routines which now require
- ; two screens.
- ;
- ; Version: 2.1
- ; Author: Gene Pizzetta
- ; Date: January 20, 1991
- ; Changes: Removed file stamp routines.
- ;
- ; Version: 2.0
- ; Author: Carson Wilson
- ; Date: January 21, 1990
- ; Changes: Added tests for ZSLIB memory routines. Added test for ZSLIB
- ; datespec parse routine.
- ;
- ; Version: 1.0
- ; Author: Carson Wilson
- ; Date: February 19, 1989
- ; Changes: Added CP/M Plus compatibility.
- ;
- ; Version: 0.1
- ; Author: Carson Wilson
- ; Date: August 22, 1988
- ;
- ; ZSLIBDEM -- Tests time and date output modules in ZSLIB.
- ;
- Vers equ 32
- SubVers equ ' '
- ;
- ; Usage:
- ;
- ; ZSLIBDEM {{date} {time}}
- ;
- ; Displays current time and date using time and date display routines from
- ; ZSLIB. If date and time is given, repeats displays using given date and
- ; time.
- ;
- ; System addresses
- ;
- CpmDma equ 80h ; default DMA buffer (command line)
- ;
- ; ASCII
- ;
- HON equ 1 ; highlighting on (^A)
- HOF equ 2 ; highlighting off (^B)
- CtrlC equ 3 ; ^C
- TAB equ 9
- CR equ 13
- LF equ 10
- ;
- ; Constants
- ;
- ColD1 equ 4 ; first date display column
- ColD2 equ 40 ; second date display column
- ColT1 equ 4 ; first time display column
- ColT2 equ 26 ; second time display column
- ColT3 equ 40 ; third time display column
- ColT4 equ 64 ; fourth time display column
- ;
- ; Externals:
- ;
- .request zslib,vlib,z3lib,syslib
- ;
- extrn cin,cout,crlf ; SYSLIB
- ;
- extrn z3vinit,gotoxy ; VLIB
- ;
- extrn zcheck,hvtinit,hvdinit,hvprint,hvpstr ; ZSLIB
- extrn hvcls,isbcdt,gcomnam,comnam
- extrn gettim,gtimep,parsdt,eatspc,mout
- extrn pdats1,pdats2,pdats3,pdats4,pdats5 ; ZSLIB print routines
- extrn ptims1,ptims2,ptims3,ptims4,ptims5,ptims6
- extrn ptimx1,ptimx2,ptimx3,ptimx4,ptimx5,ptimx6
- extrn pwday1,pwday2
- extrn mdats1,mdats2,mdats3,mdats4,mdats5 ; ZSLIB memory routines
- extrn mtims1,mtims2,mtims3,mtims4,mtims5,mtims6
- extrn mtimx1,mtimx2,mtimx3,mtimx4,mtimx5,mtimx6
- extrn mwday1,mwday2
- ;
- Entry: jp Start ; must use relative jump
- db 'Z3ENV',1
- Z3EAdr: dw 0 ; filled in by Z33
- ;
- ; Configuration
- ;
- ; Sets date order entry for command line
- ;
- EurDat: db 0 ; 0=American date; non-zero=European
- ;
- ; Program begins
- ;
- Start: ld hl,(Z3EAdr) ; initialize environment
- call zcheck ; check for ZCPR3
- call z3vinit
- ld (Stack),sp ; set up stack
- ld sp,Stack
- call hvtinit ; initialize terminal
- ld hl,DftNam ; point to default name
- call gcomnam ; get disk name, if available
- ld hl,CpmDma+1 ; check tail for help request
- call eatspc ; move to first character
- cp '/' ; slash?
- jp nz,Run ; (no)
- inc hl ; check next character
- ld a,(hl)
- cp '/' ; slash?
- jp nz,Run ; (no)
- inc hl ; we have two slashes, but
- call eatspc ; ..do we have anything else?
- jp nz,Run ; (yes, it's not a help request)
- ;
- call hvprint
- db HON
- DftNam: db 'ZSLIBDEM',HOF,' Version '
- db VERS/10+'0','.',VERS MOD 10+'0',SubVers,CR,LF
- db 'Demonstrates ZSLIB date and time output routines.',CR,LF
- db 'Usage:',CR,LF
- db ' ',0
- ld hl,comnam
- call hvpstr
- call hvprint
- db ' {{',HON,'date',HOF,'} {',HON,'time',HOF,'}}',CR,LF
- db 'Uses current date and, if any, given date.',CR,LF
- db 'Date entry:',CR,LF
- db ' {',HON,'mm',HOF,'}/{',HON,'dd',HOF,'}/{',HON,'yy',HOF
- db '} {',HON,'time',HOF,'}',CR,LF
- db 'Time entry:',CR,LF
- db ' {',HON,'hh',HOF,'}:{',HON,'mm',HOF,'}:{',HON,'ss',HOF
- db '} - real',CR,LF
- db ' +',HON,'nnnn',HOF,' - relative',0
- jp Exit
- ;
- ; Get current date and time
- ;
- Run: ld hl,TimBuf ; Point to buffer
- call GETTIM ; ZSDOS time?
- jr z,GotTim ; Yes
- call GTIMEP ; CP/M Plus time?
- jr z,GotTim
- call hvprint ; No
- db 'Clock read error.',CR,LF,0
- jp Exit
- ;
- ; Display current date and time in various formats
- ;
- GotTim: call ISBCDT
- jp nz,BadClk
- ex de,hl ; Save time buffer pointer in DE
- call hvcls
- ld h,1
- ld l,1
- call gotoxy
- call z,crlf
- call hvprint
- db HON,'Current Day of Week',HOF,0
- call PrintW
- inc h ; cursor row in H
- inc h
- ld l,1
- call gotoxy
- call z,crlf
- call hvprint
- db HON,'Current Date (American Format)'
- db ' (European Format)',HOF,0
- call PrintD
- inc h ; cursor row in H
- inc h
- ld l,1 ; column in L
- call gotoxy
- call z,crlf
- call hvprint
- db HON,'Current Time (Military) (Civilian)'
- db ' (Military) (Civilian)',HOF,0
- call PrintT
- call PrintS
- ld a,(CpmDma)
- or a ; Datespec?
- jp z,FilMem ; No
- ld hl,CpmDma+1
- call eatspc ; a datespec?
- jp z,FilMem ; (no)
- ;
- ; ShSpec -- Show datespec from command line. On entry, HL points to
- ; datespec and DE points to initialized buffer.
- ;
- ShSpec: ld a,(EurDat) ; set date format mode
- call PARSDT
- jp nz,BadPrs
- call hvprint
- db CR,LF,HON,'Any key for parsed time and date . . . ',HOF,0
- call cin
- cp CtrlC
- jp z,Exit
- call hvcls
- ld h,1
- ld l,1
- call gotoxy
- call z,crlf
- call hvprint
- db HON,'Parsed Day of Week',HOF,0
- call PrintW
- inc h ; cursor row in H
- inc h
- ld l,1
- call gotoxy
- call z,crlf
- call hvprint
- db HON,'Parsed Date (American Format)'
- db ' (European Format)',HOF,0
- call PrintD ; DE = time buffer, H = cursor row
- inc h ; cursor row in H
- inc h
- ld l,1
- call gotoxy
- call z,crlf
- call hvprint
- db HON,'Parsed Time (Military) (Civilian)'
- db ' (Military) (Civilian)',HOF,0
- call PrintT
- call PrintS
- jp FilMem
- ;
- ; FilMem -- Test memory routines. On entry, DE points to time string buffer.
- ;
- FilMem: ex de,hl ; HL = address of time buffer
- ld de,3000h ; Output location
- call MSep
- call MWDAY1
- call MSep
- call MWDAY2
- xor a ; American date format
- call MSep
- call MDATS1
- call MSep
- call MDATS2
- call MSep
- call MDATS3
- call MSep
- call MDATS4
- call MSep
- call MDATS5
- or 0FFh ; European date format
- call MSep
- call MDATS1
- call MSep
- call MDATS2
- call MSep
- call MDATS3
- call MSep
- call MDATS4
- call MSep
- call MDATS5
- or 0FFh ; military time format
- call MSep
- call MTIMS1
- call MSep
- call MTIMS2
- call MSep
- call MTIMS3
- call MSep
- call MTIMS4
- call MSep
- call MTIMS5
- call MSep
- call MTIMS6
- xor a ; civilian time format
- call MSep
- call MTIMS1
- call MSep
- call MTIMS2
- call MSep
- call MTIMS3
- call MSep
- call MTIMS4
- call MSep
- call MTIMS5
- call MSep
- call MTIMS6
- or 0FFh ; military am/pm format
- call MSep
- call MTIMX1
- call MSep
- call MTIMX2
- call MSep
- call MTIMX3
- call MSep
- call MTIMX4
- call MSep
- call MTIMX5
- call MSep
- call MTIMX6
- xor a ; military am/pm format
- call MSep
- call MTIMX1
- call MSep
- call MTIMX2
- call MSep
- call MTIMX3
- call MSep
- call MTIMX4
- call MSep
- call MTIMX5
- call MSep
- call MTIMX6
- call MSep
- ld hl,IniStr ; Set following memory for clarity
- ld bc,IniLen
- ldir
- call hvprint
- db HON,'Memory at 3000h initialized to last displayed '
- db 'date and time.',HOF,0
- ;
- Exit: call hvdinit ; de-initialize terminal
- ld sp,(Stack)
- ret ; Quit
- ;
- ; Time and/or date invalid error
- ;
- BadClk: call hvprint
- db ' Clock',0
- jr BadTD
- ;
- BadPrs: call hvprint
- db CR,LF,' Parsed',0
- BadTD: call hvprint
- db ' Time and date invalid.',0
- jp Exit ; Quit
- ;
- ; Subroutines
- ;
- ; PrintD -- Print date at HL in several formats
- ;
- PrintD: call DSep11
- call hvprint
- db 'PDATS1: "',0
- xor a ; American format
- call PDATS1 ; Print date format 1
- ;
- call DSep20
- call quote1
- or 0FFh ; European format
- call PDATS1
- ;
- call DSep10
- call hvprint
- db 'PDATS2: "',0
- xor a ; American format
- call PDATS2 ; Print format 2
- ;
- call DSep20
- call quote1
- or 0FFh ; European format
- call PDATS2
- ;
- call DSep10
- call hvprint
- db 'PDATS3: "',0
- xor a ; American format
- call PDATS3 ; Print format 3
- ;
- call DSep20
- call quote1
- or 0FFh ; European format
- call PDATS3
- ;
- call DSep10
- call hvprint
- db 'PDATS4: "',0
- xor a ; American format
- call PDATS4 ; print format 4
- ;
- call DSep20
- call quote1
- or 0FFh ; European format
- call PDATS4
- ;
- call DSep10
- call hvprint
- db 'PDATS5: "',0
- xor a ; American format
- call PDATS5
- ;
- call DSep20
- call quote1
- or 0FFh ; European format
- call PDATS5
- call Quote
- ;
- ret
- ;
- ; PrintT -- Print time at HL+4 in several formats
- ;
- PrintT: call TSep11
- call hvprint
- db 'PTIMS1: "',0
- or 0FFh ; military format 1
- call PTIMS1
- ;
- call TSep20
- call quote1
- xor a ; civilian format 1
- call PTIMS1
- ;
- call TSep30
- call hvprint
- db 'PTIMX1: "',0
- or 0FFh ; military am/pm format 1
- call PTIMX1
- ;
- call TSep40
- call quote1
- xor a ; civilian am/pm format 1
- call PTIMX1
- ;
- call TSep10
- call hvprint
- db 'PTIMS2: "',0
- or 0FFh ; military format 2
- call PTIMS2
- ;
- call TSep20
- call quote1
- xor a ; civilian format 2
- call PTIMS2
- ;
- call TSep30
- call hvprint
- db 'PTIMX2: "',0
- or 0FFh ; military am/pm format 2
- call PTIMX2
- ;
- call TSep40
- call quote1
- xor a
- call PTIMX2 ; civilian am/pm format 2
- ;
- call TSep10
- call hvprint
- db 'PTIMS3: "',0
- or 0FFh ; military format 3
- call PTIMS3
- ;
- call TSep20
- call quote1
- xor a ; civilian format 3
- call PTIMS3
- ;
- call TSep30
- call hvprint
- db 'PTIMX3: "',0
- or 0FFh ; military am/pm format 3
- call PTIMX3
- ;
- call TSep40
- call quote1
- xor a ; civilian am/pm format 3
- call PTIMX3
- ;
- call TSep10
- call hvprint
- db 'PTIMS4: "',0
- or 0FFh ; military format 4
- call PTIMS4
- ;
- call TSep20
- call quote1
- xor a ; civilian format 4
- call PTIMS4
- ;
- call TSep30
- call hvprint
- db 'PTIMX4: "',0
- or 0FFh ; military am/pm format 4
- call PTIMX4
- ;
- call TSep40
- call quote1
- xor a ; civilian am/pm format 4
- call PTIMX4
- ;
- call TSep10
- call hvprint
- db 'PTIMS5: "',0
- or 0FFh ; military format 5
- call PTIMS5
- ;
- call TSep20
- call quote1
- xor a ; civilian format 5
- call PTIMS5
- ;
- call TSep30
- call hvprint
- db 'PTIMX5: "',0
- or 0FFh ; military am/pm format 5
- call PTIMX5
- ;
- call TSep40
- call quote1
- xor a ; civilian am/pm format 5
- call PTIMX5
- ;
- call TSep10
- call hvprint
- db 'PTIMS6: "',0
- or 0FFh ; military format 6
- call PTIMS6
- ;
- call TSep20
- call quote1
- xor a ; civilian format 6
- call PTIMS6
- ;
- call TSep30
- call hvprint
- db 'PTIMX6: "',0
- or 0FFh ; military am/pm format 6
- call PTIMX6
- ;
- call TSep40
- call quote1
- xor a ; civilian am/pm format 6
- call PTIMX6
- call Quote
- ;
- ret
- ;
- PrintW: call DSep11
- call hvprint
- db 'PWDAY1: "',0
- call PWDAY1 ; Print day of week long form
- ;
- call DSep20
- call hvprint
- db 'PWDAY2: "',0
- call PWDAY2 ; Print day of week short form
- call Quote
- ;
- ret
- ;
- ; Separators between calls to date and time printing routines
- ;
- TSep10: call Quote ; prints time left
- TSep11: inc h
- ld l,ColT1
- jr SepLft
- ;
- TSep20: call Quote ; prints time left-middle
- ld l,ColT2
- jr SepRgt
- ;
- TSep30: call Quote ; prints time right-middle
- ld l,ColT3
- jr SepRgt
- ;
- TSep40: call Quote ; prints time right
- ld l,ColT4
- jr SepRgt
- ;
- DSep10: call Quote ; prints date left
- DSep11: inc h
- ld l,ColD1
- SepLft: call gotoxy
- call z,crlf
- jr SepRgt
- ;
- DSep20: call Quote ; prints date right
- ld l,ColD2
- SepRgt:
- call gotoxy
- call z,SepSpc
- ex de,hl
- ret
- ;
- SepSpc: call hvprint
- db ' ',0
- ret
- ;
- MSep: push af ; preserve AF
- ld a,'|' ; memory separator
- call mout
- pop af
- ret
- ;
- ; Quote - Print a quote mark after exchanging DE and HL
- ;
- Quote: ex de,hl
- quote1: ld a,'"'
- jp cout ; print it and return
- ;
- ; PrintS -- prints equivalency information for switchable routines.
- ;
- PrintS: call hvprint
- db CR,LF,LF
- db HON,'Older routines:',HOF,CR,LF
- db ' PDATAx ',HON,'same as',HOF,' PDATSx (American), ',HON
- db 'and',HOF,' PDATEx ',HON,'same as',HOF,' PDATSx (European).'
- db CR,LF
- db ' PTIMMx ',HON,'same as',HOF,' PTIMSx (military), ',HON
- db 'and',HOF,' PTIMCx ',HON,'same as',HOF,' PTIMSx (civilian).'
- db CR,LF
- db ' PTIMFx ',HON,'same as',HOF,' PTIMXx (civilian).'
- db CR,LF
- db 0
- ret
- ;
- ; Data area
- ;
- IniStr: db '<<=== End of ZSLIB Initialized Memory '
- IniLen equ $-IniStr
- ;
- DSEG
- ;
- TimBuf: ds 6
- ds 50 ; stack
- Stack: ds 2
- ;
- end