home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zslsrc36.lbr / ZSLIBDEM.ZZ0 / ZSLIBDEM.Z80
Encoding:
Text File  |  1992-03-11  |  12.6 KB  |  641 lines

  1. ; Library:    ZSLIB
  2. ; Version:    3.6
  3. ; Module:    ZSLIBDEM
  4. ; Version:    3.2
  5. ; Author:    Gene Pizzetta
  6. ; Date:        March 11, 1992
  7. ; Changes:    Now works without direct cursor addressing on non-ZCPR3
  8. ;        systems (albeit, a lot less neatly), initializes and
  9. ;        de-initializes terminal (like it should have done all
  10. ;        along), and uses invocation name on help screen, if
  11. ;        possible.
  12. ;
  13. ; Version:    3.1
  14. ; Author:    Gene Pizzetta
  15. ; Date:        January 31, 1992
  16. ; Changes:    Now uses dual format date and time routines instead of
  17. ;        now obsolete single format modules.  Several minor display
  18. ;        changes.
  19. ;
  20. ; Version:    3.0
  21. ; Author:    Gene Pizzetta
  22. ; Date:        July 21, 1991
  23. ; Changes:    Display extensively modified.  Requires cursor addressing.
  24. ;        Added displays for new ZSLIB 3.0 routines which now require
  25. ;        two screens.
  26. ;
  27. ; Version:    2.1
  28. ; Author:    Gene Pizzetta
  29. ; Date:        January 20, 1991
  30. ; Changes:    Removed file stamp routines.
  31. ;
  32. ; Version:    2.0
  33. ; Author:    Carson Wilson
  34. ; Date:        January 21, 1990
  35. ; Changes:    Added tests for ZSLIB memory routines.  Added test for ZSLIB
  36. ;        datespec parse routine.
  37. ;
  38. ; Version:    1.0
  39. ; Author:    Carson Wilson
  40. ; Date:        February 19, 1989
  41. ; Changes:    Added CP/M Plus compatibility.
  42. ;
  43. ; Version:    0.1
  44. ; Author:    Carson Wilson
  45. ; Date:        August 22, 1988
  46. ;
  47. ; ZSLIBDEM -- Tests time and date output modules in ZSLIB.
  48. ;
  49. Vers    equ    32
  50. SubVers    equ    ' '
  51. ;
  52. ; Usage:
  53. ;
  54. ;    ZSLIBDEM {{date} {time}}
  55. ;
  56. ; Displays current time and date using time and date display routines from
  57. ; ZSLIB.  If date and time is given, repeats displays using given date and
  58. ; time.
  59. ;
  60. ; System addresses
  61. ;
  62. CpmDma    equ    80h        ; default DMA buffer (command line)
  63. ;
  64. ; ASCII
  65. ;
  66. HON    equ    1        ; highlighting on (^A)
  67. HOF    equ    2        ; highlighting off (^B)
  68. CtrlC    equ    3        ; ^C
  69. TAB    equ    9
  70. CR    equ    13
  71. LF    equ    10
  72. ;
  73. ; Constants
  74. ;
  75. ColD1    equ    4        ; first date display column
  76. ColD2    equ    40        ; second date display column
  77. ColT1    equ    4        ; first time display column
  78. ColT2    equ    26        ; second time display column
  79. ColT3    equ    40        ; third time display column
  80. ColT4    equ    64        ; fourth time display column
  81. ;
  82. ; Externals:
  83. ;
  84.     .request zslib,vlib,z3lib,syslib
  85. ;
  86.     extrn    cin,cout,crlf                ; SYSLIB
  87. ;
  88.     extrn    z3vinit,gotoxy                ; VLIB
  89. ;
  90.     extrn    zcheck,hvtinit,hvdinit,hvprint,hvpstr    ; ZSLIB
  91.     extrn    hvcls,isbcdt,gcomnam,comnam
  92.     extrn    gettim,gtimep,parsdt,eatspc,mout
  93.     extrn    pdats1,pdats2,pdats3,pdats4,pdats5    ; ZSLIB print routines
  94.     extrn    ptims1,ptims2,ptims3,ptims4,ptims5,ptims6
  95.     extrn    ptimx1,ptimx2,ptimx3,ptimx4,ptimx5,ptimx6
  96.     extrn    pwday1,pwday2
  97.     extrn    mdats1,mdats2,mdats3,mdats4,mdats5    ; ZSLIB memory routines
  98.     extrn    mtims1,mtims2,mtims3,mtims4,mtims5,mtims6
  99.     extrn    mtimx1,mtimx2,mtimx3,mtimx4,mtimx5,mtimx6
  100.     extrn    mwday1,mwday2
  101. ;
  102. Entry:    jp    Start        ; must use relative jump
  103.     db    'Z3ENV',1
  104. Z3EAdr:    dw    0        ; filled in by Z33
  105. ;
  106. ; Configuration
  107. ;
  108. ; Sets date order entry for command line
  109. ;
  110. EurDat:    db    0        ; 0=American date; non-zero=European
  111. ;
  112. ; Program begins
  113. ;
  114. Start:    ld    hl,(Z3EAdr)    ; initialize environment
  115.     call    zcheck        ; check for ZCPR3
  116.     call    z3vinit
  117.     ld    (Stack),sp    ; set up stack
  118.     ld    sp,Stack
  119.     call    hvtinit        ; initialize terminal
  120.     ld    hl,DftNam    ; point to default name
  121.     call    gcomnam        ; get disk name, if available
  122.     ld    hl,CpmDma+1    ; check tail for help request
  123.     call    eatspc        ; move to first character
  124.     cp    '/'        ; slash?
  125.     jp    nz,Run        ; (no)
  126.     inc    hl        ; check next character
  127.     ld    a,(hl)
  128.     cp    '/'        ; slash?
  129.     jp    nz,Run        ; (no)
  130.     inc    hl        ; we have two slashes, but
  131.     call    eatspc        ; ..do we have anything else?
  132.     jp    nz,Run        ; (yes, it's not a help request)
  133. ;
  134.     call    hvprint
  135.     db    HON
  136. DftNam:    db    'ZSLIBDEM',HOF,'    Version '
  137.     db    VERS/10+'0','.',VERS MOD 10+'0',SubVers,CR,LF
  138.     db    'Demonstrates ZSLIB date and time output routines.',CR,LF
  139.     db    'Usage:',CR,LF
  140.     db    '   ',0
  141.     ld    hl,comnam
  142.     call    hvpstr
  143.     call    hvprint
  144.     db    ' {{',HON,'date',HOF,'} {',HON,'time',HOF,'}}',CR,LF
  145.     db    'Uses current date and, if any, given date.',CR,LF
  146.     db    'Date entry:',CR,LF
  147.     db    '   {',HON,'mm',HOF,'}/{',HON,'dd',HOF,'}/{',HON,'yy',HOF
  148.     db    '} {',HON,'time',HOF,'}',CR,LF
  149.     db    'Time entry:',CR,LF
  150.     db    '   {',HON,'hh',HOF,'}:{',HON,'mm',HOF,'}:{',HON,'ss',HOF
  151.     db    '} - real',CR,LF
  152.     db    '   +',HON,'nnnn',HOF,'          - relative',0
  153.     jp    Exit
  154. ;
  155. ; Get current date and time
  156. ;
  157. Run:    ld    hl,TimBuf    ; Point to buffer
  158.     call    GETTIM        ; ZSDOS time?
  159.     jr    z,GotTim    ; Yes
  160.     call    GTIMEP        ; CP/M Plus time?
  161.     jr    z,GotTim    
  162.     call    hvprint        ; No
  163.     db    'Clock read error.',CR,LF,0
  164.     jp    Exit
  165. ;
  166. ; Display current date and time in various formats
  167. ;
  168. GotTim:    call    ISBCDT
  169.     jp    nz,BadClk
  170.     ex    de,hl        ; Save time buffer pointer in DE
  171.     call    hvcls
  172.     ld    h,1
  173.     ld    l,1
  174.     call    gotoxy
  175.     call    z,crlf
  176.     call    hvprint
  177.     db    HON,'Current Day of Week',HOF,0
  178.     call    PrintW
  179.     inc    h        ; cursor row in H
  180.     inc    h
  181.     ld    l,1
  182.     call    gotoxy
  183.     call    z,crlf
  184.     call    hvprint
  185.     db    HON,'Current Date (American Format)'
  186.     db    '         (European Format)',HOF,0
  187.     call    PrintD
  188.     inc    h        ; cursor row in H
  189.     inc    h
  190.     ld    l,1        ; column in L
  191.     call    gotoxy
  192.     call    z,crlf
  193.     call    hvprint
  194.     db    HON,'Current Time (Military)  (Civilian)'
  195.     db    '              (Military)    (Civilian)',HOF,0
  196.     call    PrintT
  197.     call    PrintS
  198.     ld    a,(CpmDma)
  199.     or    a        ; Datespec?
  200.     jp    z,FilMem    ; No
  201.     ld    hl,CpmDma+1
  202.     call    eatspc        ; a datespec?
  203.     jp    z,FilMem    ; (no)
  204. ;
  205. ; ShSpec -- Show datespec from command line.  On entry, HL points to
  206. ; datespec and DE points to initialized buffer.
  207. ;
  208. ShSpec:    ld    a,(EurDat)    ; set date format mode
  209.     call    PARSDT
  210.     jp    nz,BadPrs
  211.     call    hvprint
  212.     db    CR,LF,HON,'Any key for parsed time and date . . . ',HOF,0
  213.     call    cin
  214.     cp    CtrlC
  215.     jp    z,Exit
  216.     call    hvcls
  217.     ld    h,1
  218.     ld    l,1
  219.     call    gotoxy
  220.     call    z,crlf
  221.     call    hvprint
  222.     db    HON,'Parsed Day of Week',HOF,0
  223.     call    PrintW
  224.     inc    h        ; cursor row in H
  225.     inc    h
  226.     ld    l,1
  227.     call    gotoxy
  228.     call    z,crlf
  229.     call    hvprint
  230.     db    HON,'Parsed Date  (American Format)'
  231.     db    '         (European Format)',HOF,0
  232.     call    PrintD        ; DE = time buffer, H = cursor row
  233.     inc    h        ; cursor row in H
  234.     inc    h
  235.     ld    l,1
  236.     call    gotoxy
  237.     call    z,crlf
  238.     call    hvprint
  239.     db    HON,'Parsed Time  (Military)  (Civilian)'
  240.     db    '              (Military)    (Civilian)',HOF,0
  241.     call    PrintT
  242.     call    PrintS
  243.     jp    FilMem
  244. ;
  245. ; FilMem -- Test memory routines.  On entry, DE points to time string buffer.
  246. ;
  247. FilMem:    ex    de,hl        ; HL = address of time buffer
  248.     ld    de,3000h    ; Output location
  249.     call    MSep
  250.     call    MWDAY1
  251.     call    MSep
  252.     call    MWDAY2
  253.     xor    a        ; American date format
  254.     call    MSep
  255.     call    MDATS1
  256.     call    MSep
  257.     call    MDATS2
  258.     call    MSep
  259.     call    MDATS3
  260.     call    MSep
  261.     call    MDATS4
  262.     call    MSep
  263.     call    MDATS5
  264.     or    0FFh        ; European date format
  265.     call    MSep
  266.     call    MDATS1
  267.     call    MSep
  268.     call    MDATS2
  269.     call    MSep
  270.     call    MDATS3
  271.     call    MSep
  272.     call    MDATS4
  273.     call    MSep
  274.     call    MDATS5
  275.     or    0FFh        ; military time format
  276.     call    MSep
  277.     call    MTIMS1
  278.     call    MSep
  279.     call    MTIMS2
  280.     call    MSep
  281.     call    MTIMS3
  282.     call    MSep
  283.     call    MTIMS4
  284.     call    MSep
  285.     call    MTIMS5
  286.     call    MSep
  287.     call    MTIMS6
  288.     xor    a        ; civilian time format
  289.     call    MSep
  290.     call    MTIMS1
  291.     call    MSep
  292.     call    MTIMS2
  293.     call    MSep
  294.     call    MTIMS3
  295.     call    MSep
  296.     call    MTIMS4
  297.     call    MSep
  298.     call    MTIMS5
  299.     call    MSep
  300.     call    MTIMS6
  301.     or    0FFh        ; military am/pm format
  302.     call    MSep
  303.     call    MTIMX1
  304.     call    MSep
  305.     call    MTIMX2
  306.     call    MSep
  307.     call    MTIMX3
  308.     call    MSep
  309.     call    MTIMX4
  310.     call    MSep
  311.     call    MTIMX5
  312.     call    MSep
  313.     call    MTIMX6
  314.     xor    a        ; military am/pm format
  315.     call    MSep
  316.     call    MTIMX1
  317.     call    MSep
  318.     call    MTIMX2
  319.     call    MSep
  320.     call    MTIMX3
  321.     call    MSep
  322.     call    MTIMX4
  323.     call    MSep
  324.     call    MTIMX5
  325.     call    MSep
  326.     call    MTIMX6
  327.     call    MSep
  328.     ld    hl,IniStr    ; Set following memory for clarity
  329.     ld    bc,IniLen
  330.     ldir
  331.     call    hvprint
  332.     db    HON,'Memory at 3000h initialized to last displayed '
  333.     db    'date and time.',HOF,0
  334. ;
  335. Exit:    call    hvdinit        ; de-initialize terminal
  336.     ld    sp,(Stack)
  337.     ret            ; Quit
  338. ;
  339. ; Time and/or date invalid error
  340. ;
  341. BadClk:    call    hvprint
  342.     db    ' Clock',0
  343.     jr    BadTD
  344. ;
  345. BadPrs:    call    hvprint
  346.     db    CR,LF,' Parsed',0
  347. BadTD:    call    hvprint
  348.     db    ' Time and date invalid.',0
  349.     jp    Exit        ; Quit
  350. ;
  351. ; Subroutines
  352. ;
  353. ; PrintD -- Print date at HL in several formats
  354. ;
  355. PrintD:    call    DSep11
  356.     call    hvprint
  357.     db    'PDATS1:   "',0
  358.     xor    a        ; American format
  359.     call    PDATS1        ; Print date format 1
  360. ;
  361.     call    DSep20
  362.     call    quote1
  363.     or    0FFh        ; European format
  364.     call    PDATS1
  365. ;
  366.     call    DSep10
  367.     call    hvprint
  368.     db    'PDATS2:   "',0
  369.     xor    a        ; American format
  370.     call    PDATS2        ; Print format 2
  371. ;
  372.     call    DSep20
  373.     call    quote1
  374.     or    0FFh        ; European format
  375.     call    PDATS2
  376. ;
  377.     call    DSep10
  378.     call    hvprint
  379.     db    'PDATS3:   "',0
  380.     xor    a        ; American format
  381.     call    PDATS3        ; Print format 3
  382. ;
  383.     call    DSep20
  384.     call    quote1
  385.     or    0FFh        ; European format
  386.     call    PDATS3
  387. ;
  388.     call    DSep10
  389.     call    hvprint
  390.     db    'PDATS4:   "',0
  391.     xor    a        ; American format
  392.     call    PDATS4        ; print format 4
  393. ;
  394.     call    DSep20
  395.     call    quote1
  396.     or    0FFh        ; European format
  397.     call    PDATS4
  398. ;
  399.     call    DSep10
  400.     call    hvprint
  401.     db    'PDATS5:   "',0
  402.     xor    a        ; American format
  403.     call    PDATS5
  404. ;
  405.     call    DSep20
  406.     call    quote1
  407.     or    0FFh        ; European format
  408.     call    PDATS5
  409.     call    Quote
  410. ;
  411.     ret
  412. ;
  413. ; PrintT -- Print time at HL+4 in several formats
  414. ;
  415. PrintT:    call    TSep11
  416.     call    hvprint
  417.     db    'PTIMS1:   "',0
  418.     or    0FFh        ; military format 1
  419.     call    PTIMS1
  420. ;
  421.     call    TSep20
  422.     call    quote1
  423.     xor    a        ; civilian format 1
  424.     call    PTIMS1
  425. ;
  426.     call    TSep30
  427.     call    hvprint
  428.     db    'PTIMX1:   "',0
  429.     or    0FFh        ; military am/pm format 1
  430.     call    PTIMX1
  431. ;
  432.     call    TSep40
  433.     call    quote1
  434.     xor    a        ; civilian am/pm format 1
  435.     call    PTIMX1
  436. ;
  437.     call    TSep10
  438.     call    hvprint
  439.     db    'PTIMS2:   "',0
  440.     or    0FFh        ; military format 2
  441.     call    PTIMS2
  442. ;
  443.     call    TSep20
  444.     call    quote1
  445.     xor    a        ; civilian format 2
  446.     call    PTIMS2
  447. ;
  448.     call    TSep30
  449.     call    hvprint
  450.     db    'PTIMX2:   "',0
  451.     or    0FFh        ; military am/pm format 2
  452.     call    PTIMX2
  453. ;
  454.     call    TSep40
  455.     call    quote1
  456.     xor    a
  457.     call    PTIMX2        ; civilian am/pm format 2
  458. ;
  459.     call    TSep10
  460.     call    hvprint
  461.     db    'PTIMS3:   "',0
  462.     or    0FFh        ; military format 3
  463.     call    PTIMS3
  464. ;
  465.     call    TSep20
  466.     call    quote1
  467.     xor    a        ; civilian format 3
  468.     call    PTIMS3
  469. ;
  470.     call    TSep30
  471.     call    hvprint
  472.     db    'PTIMX3:   "',0
  473.     or    0FFh        ; military am/pm format 3
  474.     call    PTIMX3
  475. ;
  476.     call    TSep40
  477.     call    quote1
  478.     xor    a        ; civilian am/pm format 3
  479.     call    PTIMX3
  480. ;
  481.     call    TSep10
  482.     call    hvprint
  483.     db    'PTIMS4:   "',0
  484.     or    0FFh        ; military format 4
  485.     call    PTIMS4
  486. ;
  487.     call    TSep20
  488.     call    quote1
  489.     xor    a        ; civilian format 4
  490.     call    PTIMS4
  491. ;
  492.     call    TSep30
  493.     call    hvprint
  494.     db    'PTIMX4:   "',0
  495.     or    0FFh        ; military am/pm format 4
  496.     call    PTIMX4
  497. ;
  498.     call    TSep40
  499.     call    quote1
  500.     xor    a        ; civilian am/pm format 4
  501.     call    PTIMX4
  502. ;
  503.     call    TSep10
  504.     call    hvprint
  505.     db    'PTIMS5:   "',0
  506.     or    0FFh        ; military format 5
  507.     call    PTIMS5
  508. ;
  509.     call    TSep20
  510.     call    quote1
  511.     xor    a        ; civilian format 5
  512.     call    PTIMS5
  513. ;
  514.     call    TSep30
  515.     call    hvprint
  516.     db    'PTIMX5:   "',0
  517.     or    0FFh        ; military am/pm format 5
  518.     call    PTIMX5
  519. ;
  520.     call    TSep40
  521.     call    quote1
  522.     xor    a        ; civilian am/pm format 5
  523.     call    PTIMX5
  524. ;
  525.     call    TSep10
  526.     call    hvprint
  527.     db    'PTIMS6:   "',0
  528.     or    0FFh        ; military format 6
  529.     call    PTIMS6
  530. ;
  531.     call    TSep20
  532.     call    quote1
  533.     xor    a        ; civilian format 6
  534.     call    PTIMS6
  535. ;
  536.     call    TSep30
  537.     call    hvprint
  538.     db    'PTIMX6:   "',0
  539.     or    0FFh        ; military am/pm format 6
  540.     call    PTIMX6
  541. ;
  542.     call    TSep40
  543.     call    quote1
  544.     xor    a        ; civilian am/pm format 6
  545.     call    PTIMX6
  546.     call    Quote
  547. ;
  548.     ret
  549. ;
  550. PrintW:    call    DSep11
  551.     call    hvprint
  552.     db    'PWDAY1:   "',0
  553.     call    PWDAY1        ; Print day of week long form
  554. ;
  555.     call    DSep20
  556.     call    hvprint
  557.     db    'PWDAY2:   "',0
  558.     call    PWDAY2        ; Print day of week short form
  559.     call    Quote
  560. ;
  561.     ret
  562. ;
  563. ; Separators between calls to date and time printing routines
  564. ;
  565. TSep10:    call    Quote        ; prints time left
  566. TSep11:    inc    h
  567.     ld    l,ColT1
  568.     jr    SepLft
  569. ;
  570. TSep20:    call    Quote        ; prints time left-middle
  571.     ld    l,ColT2
  572.     jr    SepRgt
  573. ;
  574. TSep30:    call    Quote        ; prints time right-middle
  575.     ld    l,ColT3
  576.     jr    SepRgt
  577. ;
  578. TSep40:    call    Quote        ; prints time right
  579.     ld    l,ColT4
  580.     jr    SepRgt
  581. ;
  582. DSep10:    call    Quote        ; prints date left
  583. DSep11:    inc    h
  584.     ld    l,ColD1
  585. SepLft:    call    gotoxy
  586.     call    z,crlf
  587.     jr    SepRgt
  588. ;
  589. DSep20:    call    Quote        ; prints date right
  590.     ld    l,ColD2
  591. SepRgt:
  592.     call    gotoxy
  593.     call    z,SepSpc
  594.     ex    de,hl
  595.     ret
  596. ;
  597. SepSpc:    call    hvprint
  598.     db    '  ',0
  599.     ret
  600. MSep:    push    af        ; preserve AF
  601.     ld    a,'|'        ; memory separator
  602.     call    mout
  603.     pop    af
  604.     ret
  605. ;
  606. ; Quote - Print a quote mark after exchanging DE and HL
  607. ;
  608. Quote:    ex    de,hl
  609. quote1:    ld    a,'"'
  610.     jp    cout        ; print it and return
  611. ;
  612. ; PrintS -- prints equivalency information for switchable routines.
  613. ;
  614. PrintS:    call    hvprint
  615.     db    CR,LF,LF
  616.     db    HON,'Older routines:',HOF,CR,LF
  617.     db    '   PDATAx ',HON,'same as',HOF,' PDATSx (American), ',HON
  618.     db    'and',HOF,' PDATEx ',HON,'same as',HOF,' PDATSx (European).'
  619.     db    CR,LF
  620.     db    '   PTIMMx ',HON,'same as',HOF,' PTIMSx (military), ',HON
  621.     db    'and',HOF,' PTIMCx ',HON,'same as',HOF,' PTIMSx (civilian).'
  622.     db    CR,LF
  623.     db    '   PTIMFx ',HON,'same as',HOF,' PTIMXx (civilian).'
  624.     db    CR,LF
  625.     db    0
  626.     ret
  627. ;
  628. ; Data area
  629. ;
  630. IniStr:    db    '<<=== End of ZSLIB Initialized Memory    '
  631. IniLen    equ    $-IniStr    
  632. ;
  633.     DSEG
  634. ;
  635. TimBuf:    ds    6
  636.     ds    50        ; stack
  637. Stack:    ds    2
  638. ;
  639.     end
  640.