home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zpath.lbr / ZPATH.ZZ0 / ZPATH.Z80
Encoding:
Text File  |  1991-02-17  |  20.3 KB  |  746 lines

  1.     TITLE    "Set ZCPR3 and/or ZSDOS Search Path"
  2. ;===============================================================;
  3. ; Z P A T H                            ;
  4. ;---------------------------------------------------------------;
  5. ; Derived from PATH 3.0, 12 Apr 84 by Richard Conn with 3.1    ;
  6. ;    modifications by Joe W. Wright, 12 Mar 85.        ;
  7. ; ZPATH changes Copyright (C) 1988  by Harold F. Bower        ;
  8. ;        All Rights Reserved                ;
  9. ; Source code released for Non-commercial use only.  Commercial    ;
  10. ;  use must be authorized in writing by the author.        ;
  11. ;---------------------------------------------------------------;
  12. ;   ZPATH allows the user to do two things -- display the cur-    ;
  13. ; rent path and set a new path.  Named directories may be used    ;
  14. ; in the definition of the new path.  If operating under ZSDOS,    ;
  15. ; the internal DOS path may also be set independently of the    ;
  16. ; ZCPR3 path.                            ;
  17. ;   A Quiet Flag has been added in conjunction with testing of    ;
  18. ; the ZCPR3 QUIET flag for suppression of messages.  Quiet    ;
  19. ; testing in the HELP request has been deleted.            ;
  20. ;                                ;
  21. ; ZPATH is invoked in the following forms:            ;
  22. ;    ZPATH            <-- Display Path        ;
  23. ;    ZPATH //        <-- Print Help            ;
  24. ;    ZPATH path-expression    <-- Set CPR Path        ;
  25. ;    ZPATH /C=path-expression <--  (alternate form)        ;
  26. ;    ZPATH /Q path-expression <-- Set CPR Path Quietly    ;
  27. ;    ZPATH /D=path-expression <-- Set ZSDOS Internal Path    ;
  28. ;                                ;
  29. ; Assemble as : ZML ZPATH,Z3LIB/,SYSLIB/            ;
  30. ;                                ;
  31. ; Revision:                            ;
  32. ;    1.0 - Release Version            17 Sep 88    ;
  33. ;===============================================================;
  34.  
  35. VERS    EQU    10        ; Initial Release
  36.  
  37. ;  CP/M Constants
  38.  
  39. CPM    EQU    0        ; Base
  40. BDOS    EQU    5        ; Dos Entry point
  41. FCB    EQU    CPM+5CH
  42. TBUFF    EQU    CPM+80H
  43. CR    EQU    0DH
  44. LF    EQU    0AH
  45. TAB    EQU    09H
  46.  
  47. ; ZCPR3 Constants
  48.  
  49. ZPTHOF    EQU    9        ; ZCPR3 Path offset in Environment
  50. QUIEOF    EQU    28H        ; ZCPR3 Quiet flag offset
  51. WHLOF    EQU    29H        ; ZCPR3 Wheel flag offset
  52. MDSKOF    EQU    2CH        ; ZCPR3 Max Disk byte offset
  53. MUSROF    EQU    2DH        ; ZCPR3 Max User byte offset
  54.  
  55. ; ZSDOS Constants
  56.  
  57. PATHOFF    EQU    11H        ; Offset of Path vector from ZSDOS base
  58. IPATH    EQU    0DF1H        ; Internal 3-element path
  59. GETFLG    EQU    100        ; ZSDOS Get Flags Command
  60. SETFLG    EQU    101        ; ZSDOS Set Flags Command
  61.  
  62. ; ..From Z3LIB Get..
  63.  
  64.     EXT    WHRENV, Z3INIT, DIRTDU, DUTDIR
  65.  
  66. ; ..From SYSLIB Get..
  67.  
  68.     EXT    EPSTR, EPRINT, RETUD, CODEND
  69.     EXT    COUT, CRLF, EPSTR, PAFDC
  70.  
  71. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  72. ;        B e g i n    T h e    P r o g r a m
  73. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  74.  
  75.     JP    START
  76.  
  77.     DEFB    'Z3ENV'        ; This is a ZCPR3 Utility
  78.     DEFB    1        ; External Environment Descriptor
  79. Z3EADR:    DEFW    0001        ; Dummy to insure search
  80.  
  81. ; Start of Program -- Initialize Variables and ZCPR3 Environment
  82.  
  83. START:    LD    HL,DATA        ; Insure that variables are nulled
  84.     LD    B,ZMUSER-DATA+1
  85. STARTL:    LD    (HL),0
  86.     INC    HL
  87.     DJNZ    STARTL
  88.     LD    HL,0AAAAH    ; Set a MDISK/MUSER in case no ENV
  89.     LD    (ZMDISK),HL
  90.  
  91.     LD    (STACK),SP    ; Save ptr to original stack
  92.     LD    SP,STACK    ; ..and set local stack
  93.     LD    HL,0001        ; Set environment value to force search
  94.     CALL    WHRENV        ; ..and validate/locate it
  95.     LD    (Z3EADR),HL    ; Save the validate location
  96.     LD    A,H        ; Set flags for a valid ENV
  97.     OR    L
  98.     LD    (ISZENV),A    ; .saving for later tests
  99.     JR    Z,PRBANR    ; Jump to opening if No Z3 ENV
  100.     CALL    Z3INIT        ; Initialize the ZCPR3 Env
  101.     EX    DE,HL        ; ..and get needed values
  102.     LD    HL,ZPTHOF    ; Offset to Path in Environment
  103.     ADD    HL,DE
  104.     LD    C,(HL)        ; Get Path addr from environment
  105.     INC    HL
  106.     LD    B,(HL)
  107.     LD    (CPRPTH),BC    ; ..and save locally
  108.     INC    HL        ; Point to Max # of entries
  109.     LD    A,(HL)
  110.     LD    (CPRLEN),A    ; ..and set our copy
  111.     LD    HL,QUIEOF    ; Point to the Quiet flag
  112.     ADD    HL,DE
  113.     LD    DE,ZQUIET    ; ..and copy to local
  114.     LD    BC,6        ; Move QUIET, WHEEL, 2 unk bytes, MDISK & MUSER
  115.     LDIR
  116.  
  117. ; Print Banner
  118.  
  119. PRBANR:    CALL    PRMUZL        ; Print this only if verbose
  120.     DEFB    CR,LF,'ZPATH  v'
  121.     DEFB    VERS/10+'0','.',[VERS MOD 10]+'0',0
  122.  
  123. ; Determine whether we are running under ZSDOS or not
  124.  
  125.     LD    C,48
  126.     CALL    BDOS
  127.     LD    A,H        ; Get ZSDOS Type
  128.     LD    (DOSTYP),A    ; ..and save for later tests
  129.     CP    'S'
  130.     JR    NZ,START1
  131.  
  132. ; Here we have a validated ZSDOS, now determine base address
  133.  
  134.     LD    HL,(Z3EADR)    ; Is this an extended ENV?
  135.     LD    A,H
  136.     OR    L        ; 0=No Environment
  137.     JR    Z,CALCOF    ; ..Jump if no Env to calculate addr
  138.     LD    DE,8        ; Offset to Extended flag bit
  139.     EX    DE,HL
  140.     ADD    HL,DE
  141.     BIT    7,(HL)        ; Is it extended?
  142.     JR    Z,CALCOF    ; ..jump if not to calculate
  143.     LD    HL,42H        ; Yes, so offset to DOS addr
  144.     ADD    HL,DE
  145.     LD    E,(HL)        ; ..and retrieve DOS starting addr
  146.     INC    HL
  147.     LD    D,(HL)
  148.     EX    DE,HL
  149.     JR    OKDOS        ; Rejoin code
  150.  
  151. CALCOF:    LD    HL,(0001)    ; Get base BIOS addr
  152.     LD    DE,-0E03H    ; Subtract Dos size + Warm Boot offset
  153.     ADD    HL,DE
  154. OKDOS:    LD    (DOSBAS),HL    ; Save DOS base addr
  155.     LD    DE,IPATH    ; Offset to internal path
  156.     ADD    HL,DE
  157.     LD    (DOSPTH),HL    ; .save absolute address
  158.     LD    A,3
  159.     LD    (DOSLEN),A    ; ..and length
  160.  
  161.     CALL    PRMUZL        ; Print additional tag if under ZSDOS
  162.     DEFB    ' (ZSDOS)',0
  163.  
  164. ;.....
  165. ; Check for valid Env and get CPR Path & Wheel if so
  166.  
  167. START1:    CALL    CRLF
  168.     LD    A,(ISZENV)    ; Is there a valid ENV?
  169.     OR    A
  170.     JR    Z,START3    ; ..jump ahead if not
  171.     LD    A,(ZWHEEL)    ; Are we a wheel?
  172.     OR    A
  173.     JP    Z,NOZWHL    ; ..take error exit if not
  174.  
  175. START3:    CALL    CODEND        ; Set temporary ZCPR path Adr past end of code
  176.     INC    H        ; Leave room for Stack
  177.     INC    H
  178.     LD    (CPRPTR),HL    ; point to it
  179.     INC    H        ; Next page for DOS Path Adr
  180.     LD    (DOSPTR),HL
  181.  
  182.     LD    HL,TBUFF+1    ; Point to Command Line for input
  183.     CALL    SBLANK        ; ..skip to non-blank
  184.     LD    (CMDLIN),HL    ; Set ptr to next element
  185.     JP    Z,PDISPX    ; EOL=display..even if ZCPR Quiet flag set
  186.     CP    '/'        ; Are we starting with an option?
  187.     JR    NZ,BLDPTH    ; ..set default mode if not
  188.     INC    HL        ; Point to next char
  189.     SUB    (HL)        ; Were there two slashes for Help Request?
  190.     DEC    HL
  191.     JP    Z,PRHELP    ; ..jump if so
  192.  
  193. ;.....
  194. ;  **** Set New Path ****
  195.  
  196. BLDPTH:    CALL    SBLANK        ; Advance to Non-space char
  197.     LD    (TOKEN),HL    ; Save addr here in case error encountered
  198.     JP    Z,PBDONE    ; ..jump if EOL to Store Path and Display
  199.     CP    '/'        ; Is it a flag marker?
  200.     JR    Z,BLDOPT    ; ..Process options if so
  201.     PUSH    AF        ; Preserve regs
  202.     LD    A,(CURRNT) 
  203.     AND    0011B        ; Are we setting a path already?
  204.     JR    NZ,BLDING    ; ..Exit here if so
  205.     LD    DE,(CPRPTH)    ; Else see if we have valid ZCPR3 path
  206.     LD    A,D
  207.     OR    E
  208.     JR    Z,NOZPTV    ; ..take error exit if no Z3 Path
  209.     CALL    SETZCP        ; Else set values for Z-Path
  210. BLDING:    POP    AF        ; Restore regs..
  211.     JR    BLDP0        ; ..and vector to set Path
  212.  
  213. BLDOPT:    CALL    GETNXT        ; Advance and Get Next Char
  214.     JP    Z,PBDONE    ; ..exit if no more input
  215.     CP    'Q'        ; Is it a quiet request?
  216.     JR    NZ,NXTTST    ; ..jump if not
  217.     LD    (ZQUIET),A    ; Else store non-zero value in Quiet flag
  218.     CALL    GETNXT        ; Advance and Get Next Char
  219.     JP    Z,PBDONE    ; ..quit here if EOL
  220. NXTTST:    LD    (TOKEN),HL    ; Save addr in case of later error
  221.     CP    'C'        ; Is it the explicit start of CPR Path?
  222.     JR    NZ,NXTTS0    ; ..jump if not
  223.     LD    A,(ISZENV)    ; Do we have a ZCPR3 ENV?
  224.     OR    A
  225. NOZPTV:    JP    Z,NOZPTH    ; ..jump error exit if not
  226.     CALL    SETZCP        ; Set CPR Path parms
  227.     JR    NXTTS1        ; ..and rejoin common code
  228.     
  229. NXTTS0:    CP    'D'        ; Is it the start of ZSDOS Path parm?
  230.     JP    NZ,RANGER    ; ..jump to error if not recognizable parm
  231.     LD    A,(DOSTYP)    ; Are we operating under ZSDOS?
  232.     CP    'S'
  233.     JP    NZ,NODPTH    ; ..jump error if Not ZSDOS, No path to set
  234.     LD    DE,(DOSPTR)    ; Else set Dos Path address
  235.     LD    A,0010B        ; Show that Dos Path being set
  236.     CALL    SETCUR        ; Set current path parms
  237. NXTTS1:    CALL    GETNXT        ; Advance and Get Next Char
  238.     JP    Z,PBDONE
  239.     CP    '='        ; Next char must be an equals sign
  240.     JP    NZ,RANGER    ; ..jump error if not Equals sign here
  241.     CALL    GETNXT        ; Advance and Get Next Char
  242.     JP    Z,PBDONE    ; ..and jump to set if EOL
  243.  
  244. BLDP0:    LD    (TOKEN),HL    ; save ptr to first byte
  245.     LD    A,(HL)        ; get first char
  246.     CP    '$'        ; is it current?
  247.     JR    Z,PBDU        ; DU: form
  248.     SUB    'A'        ; convert to number
  249.     JR    C,PBDIR        ; DIR: form
  250.     LD    B,A        ; save number
  251.     LD    A,(ZMDISK)    ; Get Max disk number
  252.     LD    C,A
  253.     LD    A,B
  254.     CP    C        ; in range?
  255.     JR    NC,PBDIR    ; DIR: form if not
  256.     INC    HL        ; pt to next char -- may be DU or DIR
  257.     LD    A,(HL)        ; get next part of element
  258.     CP    '$'        ; current?
  259.     JR    Z,PBDU        ; is a DU: form
  260. DIGTST:    OR    A        ; EOL ends it
  261.     JR    Z,PBDU
  262.     CP    ':'        ; colon ends it
  263.     JR    Z,PBDU        ; ..jump because it is a DU: form
  264.     CALL    WHITSP        ; White Space (space, comma, tab) ends it
  265.     JR    Z,PBDU
  266.     CP    '0'        ; must be a digit
  267.     JR    C,PBDIR        ; DIR: form if not in range
  268.     CP    '9'+1
  269.     JR    NC,PBDIR
  270.     INC    HL        ; pt to next
  271.     LD    A,(HL)        ; get it
  272.     JR    DIGTST
  273.  
  274. ;.....
  275. ; It is a DU: form
  276.  
  277. PBDU:    LD    DE,(PTHPTR)    ; pt DE to path entry
  278.     LD    HL,(TOKEN)    ; pt to token
  279.     LD    A,(HL)        ; current?
  280.     CP    '$'
  281.     JR    Z,PBDU1
  282.     SUB    'A'-1        ; convert to number from 1 to n
  283. PBDU1:    LD    (DE),A        ; save disk element
  284.     INC    HL        ; pt to next
  285.     INC    DE
  286.     LD    A,(HL)        ; current user?
  287.     INC    HL        ; pt to after user in case of match to current
  288.     CP    '$'        ; current?
  289.     JR    Z,PBDU2
  290.     DEC    HL        ; pt to first digit
  291.     PUSH    DE        ; save ptr to path
  292.     CALL    EVAL10        ; convert to number in C
  293.     JR    C,RANGER
  294.     LD    A,(ZMUSER)    ; Check for Max user
  295.     INC    A
  296.     LD    B,A        ; place max in B
  297.     LD    A,C        ; value in A
  298.     CP    B
  299.     JR    NC,RANGER
  300.     POP    DE        ; get ptr to path
  301. PBDU2:    LD    (DE),A        ; store user number
  302.     INC    DE
  303.     XOR    A        ; End path with Null
  304.     LD    (DE),A
  305.     LD    A,(HL)        ; ending with colon?
  306.     CP    ':'
  307.     JR    NZ,PBDU3
  308.     INC    HL        ; skip over colon
  309. PBDU3:    LD    (CMDLIN),HL    ; save ptr to next command line entry
  310.     LD    (PTHPTR),DE    ; save ptr to next path entry
  311. BLDPV0:    JP    BLDPTH        ; continue processing
  312.  
  313. ;.....
  314. ; Build DIR: form
  315.  
  316. PBDIR:    LD    HL,(TOKEN)    ; pt to name
  317.     PUSH    HL
  318.     CALL    DIRTDU        ; convert to DU in BC
  319.     POP    HL        ; ..(restore token addr)
  320.     JR    NZ,PBDIR0    ; ..jump if Ok 
  321.     LD    A,(HL)        ; Else check first char
  322.     CP    '/'        ; ..for option
  323.     JR    Z,BLDPV0    ; Jump main loop if option
  324.             ;..else fall thru to error..
  325. ; Entry not found, print error if not Option flag
  326.  
  327. RANGER:    LD    A,(ZQUIET)    ; Are we operating quietly?
  328.     OR    A
  329.     JR    NZ,Q1        ; ..bypass error messages if so
  330.     CALL    EPRINT
  331.     DEFB    CR,LF,'  Bad Expression at : ',0
  332.     LD    HL,(TOKEN)    ; print string starting at token
  333.     CALL    EPSTR
  334. Q1:    JP    EXIT        ; Jump to main exit point
  335.  
  336. ; Got User and Disk -- Store in Path
  337.  
  338. PBDIR0:    LD    HL,(PTHPTR)    ; get ptr to path
  339.     INC    B        ; disk A = 1
  340.     LD    (HL),B        ; store disk
  341.     INC    HL
  342.     LD    (HL),C        ; store user
  343.     INC    HL        ; pt to next
  344.     LD    (HL),0        ; Properly end the path
  345.     EX    DE,HL        ; ..put pathptr in DE
  346.     LD    HL,(TOKEN)    ; skip over token
  347. GOTUD1:    LD    A,(HL)        ; skip to space or EOL
  348.     INC    HL        ; pt to next
  349.     OR    A        ; EOL?
  350.     JR    Z,GOTUD2
  351.     CALL    WHITSP        ; Is it white space?
  352.     JR    NZ,GOTUD1    ; ..jump if not
  353. GOTUD2:    DEC    HL        ; pt to EOL or space
  354.     JR    PBDU3        ; Jump to save Cmdline and Pathptr..and loop
  355.  
  356. ;.....
  357. ; --- Path Building is Done -- Set pertinent path(s) ---
  358.  
  359. ; Truncate the declared path to its maximum length
  360.  
  361. PBDONE:    LD    HL,(CPRPTR)    ; Point to CPR temp path
  362.     LD    DE,(CPRPTH)    ; ..and to Permanent path
  363.     LD    A,(MODE)    ; Did we set this path?
  364.     PUSH    AF        ; ..save flag for next test
  365.     AND    0001B
  366.     LD    A,(CPRLEN)    ; Get CPR max path length
  367.     CALL    NZ,PBDON0    ; Set CPR Path if we entered one
  368.  
  369.     POP    AF
  370.     AND    0010B        ; Did we set a Dos Path?
  371.     JR    Z,PDISP        ; ..jump if we didn't and display
  372.  
  373.     LD    A,(DOSTYP)    ; Are we operating under ZSDOS?
  374.     CP    'S'
  375.     JR    NZ,PDISP    ; ..jump to display ZCPR path if not
  376.  
  377.     LD    C,GETFLG    ; Get ZSDOS Flags with Function 100
  378.     CALL    BDOS
  379.     LD    E,A        ; ..store flags in case we need to set
  380.     CPL
  381.     AND    00100000B    ; Is the Path Active?
  382.     LD    (PTHFLG),A    ; ..(save status flag)
  383.     JR    Z,PATHON    ; ..jump if so
  384.     SET    5,E        ; Else activate it
  385.     LD    C,SETFLG    ; Set the new byte with Function 101
  386.     CALL    BDOS
  387.  
  388. PATHON:    LD    DE,(DOSBAS)    ; Else calculate offset to Dos Path ptr
  389.     LD    HL,PATHOFF
  390.     ADD    HL,DE        ; ..in HL
  391.     LD    DE,(DOSPTH)    ; Get addr of Dos Path
  392.     LD    (HL),E        ; ..and store at pointer
  393.     INC    HL
  394.     LD    (HL),D
  395.  
  396.     LD    HL,(DOSPTR)    ; Point to Dos temp path
  397.     LD    A,(DOSLEN)    ; Get Dos max path length
  398.     CALL    PBDON0        ; Set Dos path elements
  399.     JR    PDISP        ; ..and jump to display
  400.  
  401. PBDON0:    ADD    A,A        ; double it
  402.     LD    C,A        ; put it in C..
  403.     LD    B,0        ; ..and B
  404.     PUSH    HL        ; Save start
  405.     ADD    HL,BC        ; ..offset to last possible terminator
  406.     LD    (HL),0        ; ...and terminate
  407.     POP    HL
  408. PCOPY:    LD    A,(HL)        ; Get Disk (or end mark)
  409.     LDI            ; Move Disk (or end of string)
  410.     OR    A        ; end of path?
  411.     RET    Z        ; ..return if done
  412.     LDI            ; Not end, so move User
  413.     JR    PCOPY
  414.  
  415. ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  416. ;         D i s p l a y     P a t h ( s )
  417. ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  418.  
  419. PDISP:    LD    A,(ZQUIET)    ; Are we operating quietly?
  420.     OR    A
  421. EXIT0V:    JP    NZ,EXIT0    ; ..quit here if so
  422.  
  423. PDISPX:    CALL    EPRINT
  424.     DEFB    CR,LF,'- ZCPR3 Path...',0
  425.     LD    HL,(CPRPTH)    ; Do we have a ZCPR3 path?
  426.     LD    A,H
  427.     OR    L
  428.     JR    NZ,DSPLY0    ; ..jump if we have one
  429.     CALL    EPRINT
  430.     DEFB    CR,LF,TAB,'- None -',0
  431. DSPLY0:    CALL    NZ,PDISP0    ; ..and display it if there
  432.  
  433.     LD    A,(DOSTYP)    ; Are we operating under ZSDOS?
  434.     CP    'S'
  435.     JR    NZ,EXIT0V    ; ..exit if not
  436.  
  437.     CALL    EPRINT
  438.     DEFB    CR,LF,LF,'- ZSDOS Path...',0
  439.     LD    C,GETFLG
  440.     CALL    BDOS        ; Is the path active?
  441.     BIT    5,A
  442.     JR    NZ,DSPLY1    ; ..jump if it is
  443.     CALL    EPRINT        ; Else print message
  444.     DEFB    CR,LF,TAB,'- Disabled -',0
  445.     JR    EXIT1V        ; ..and exit
  446.  
  447. DSPLY1:    LD    DE,(DOSBAS)    ; Prepare for Dos Path
  448.     LD    A,(PTHFLG)    ; Did we activate the path?
  449.     OR    A
  450.     JR    Z,DSPLY2    ; ..jump if not
  451.     CALL    EPRINT        ; Else notify the user
  452.     DEFB    '(being activated)',0
  453. DSPLY2:    LD    HL,PATHOFF
  454.     ADD    HL,DE
  455.     LD    E,(HL)        ; ..and get it
  456.     INC    HL
  457.     LD    D,(HL)
  458.     EX    DE,HL        ; Put DOS Path addr in HL
  459.     CALL    PDISP0        ; ..and print the path
  460. EXIT1V:    JP    EXIT0        ; Exit with CRLF
  461.  
  462. ; --- Print Symbolic Path ---
  463.  
  464. PDISP0:    LD    A,(HL)        ; Do we have a Null Path?
  465.     OR    A
  466.     JR    NZ,PDISPY    ; ..jump if so
  467.     CALL    EPRINT        ; Else say we have zero-length
  468.     DEFB    CR,LF,TAB,'- Nil -',0
  469.     RET            ; ..and end here
  470.  
  471. PDISPY:    PUSH    HL        ; Save path address for later
  472.     CALL    EPRINT
  473.     DEFB    CR,LF,'   Symbolic : ',0
  474. PDISP1:    LD    A,(HL)        ; get disk
  475.     OR    A        ; done?
  476.     JR    Z,ADISP
  477.     CP    '$'        ; current?
  478.     JR    Z,PDISP2
  479.     ADD    A,'@'        ; convert to letter
  480. PDISP2:    CALL    COUT        ; print disk letter
  481.     INC    HL        ; pt to user
  482.     LD    A,(HL)        ; get user number
  483.     CP    '$'        ; current?
  484.     CALL    Z,COUT        ; print current indicator if '$' or..
  485.     CALL    NZ,PAFDC    ; ..print user number if not
  486.     CALL    COLON
  487.     INC    HL        ; pt to next element
  488.     LD    A,(HL)        ; done?
  489.     OR    A        ; 0=yes
  490.     CALL    NZ,ARROW
  491.     JR    PDISP1
  492.  
  493. ; --- Print Absolute Path ---
  494.  
  495. ADISP:    CALL    EPRINT
  496.     DEFB    CR,LF,'   DU       : ',0
  497.     CALL    RETUD        ; get current user/disk
  498.     POP    HL        ; Get path addr back..
  499.     PUSH    HL        ; ..and keep on stack
  500. ADISP1:    LD    A,(HL)        ; get disk
  501.     OR    A        ; done?
  502.     JR    Z,NDISP
  503.     CP    '$'        ; current?
  504.     JR    NZ,ADISP2
  505.     LD    A,B        ; get current disk
  506.     INC    A        ; adjust to 1 to n
  507. ADISP2:    ADD    A,'@'        ; convert to letter
  508.     CALL    COUT        ; print disk letter
  509.     INC    HL        ; pt to user
  510.     LD    A,(HL)        ; get user
  511.     CP    '$'        ; current?
  512.     JR    NZ,ADISP3
  513.     LD    A,C        ; get current user
  514. ADISP3:    CALL    PAFDC        ; print user
  515.     CALL    COLON
  516.     INC    HL        ; pt to next
  517.     LD    A,(HL)        ; done?
  518.     OR    A
  519.     CALL    NZ,ARROW
  520.     JR    ADISP1
  521.  
  522. ; --- Print Named Path ---
  523.  
  524. NDISP:    CALL    EPRINT
  525.     DEFB    CR,LF,'   Named    : ',0
  526.     POP    HL        ; Get path starting addr back
  527. NDISP1:    CALL    RETUD        ; get current user and disk in C and B
  528.     LD    A,(HL)        ; get disk
  529.     OR    A        ; done?
  530.     RET    Z
  531.     CP    '$'        ; current?
  532.     JR    Z,NDISP2
  533.     LD    B,A        ; disk in B
  534.     DEC    B        ; adjust to 0 to n-1
  535. NDISP2:    INC    HL        ; pt to user
  536.     LD    A,(HL)        ; get it
  537.     CP    '$'        ; current?
  538.     JR    Z,NDISP3
  539.     LD    C,A        ; user in C
  540. NDISP3:    INC    HL        ; pt to next
  541.     PUSH    HL        ; save ptr
  542.     CALL    UDSCAN        ; scan dirs for user/disk and print its name
  543.     POP    HL        ; get ptr
  544.     CALL    COLON
  545.     LD    A,(HL)        ; done?
  546.     OR    A
  547.     CALL    NZ,ARROW
  548.     JR    NDISP1
  549.  
  550. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::
  551. ;        U t i l i t y     R o u t i n e s
  552. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::
  553. ;.....
  554. ; Set current path parameters from preset registers
  555.  
  556. SETZCP:    LD    DE,(CPRPTR)    ; Set values for Z-Path
  557.     LD    A,0001B
  558. SETCUR:    LD    (CURRNT),A    ; This is current..
  559.     PUSH    HL
  560.     LD    HL,MODE
  561.     OR    (HL)        ; ..and being set
  562.     LD    (HL),A
  563.     POP    HL
  564.     LD    (PTHPTR),DE    ; ..and the addr of the candidate path
  565.     XOR    A        ; Start with a null path
  566.     LD    (DE),A
  567.     RET
  568.  
  569. ;.....
  570. ; Print Help message and exit
  571.  
  572. PRHELP:    CALL    EPRINT        ; This not muzzled.  Help always available
  573.     DEFB    CR,LF,'Syntax:'
  574.     DEFB    CR,LF,'    ZPATH [/[Q][o=]] expr [/[Q][o=expr]]'
  575.     DEFB    CR,LF,'Options:'
  576.     DEFB    CR,LF,'    C - ZCPR3 Path Spec    Q - Quiet Mode',0
  577.     LD    HL,(DOSBAS)    ; Are we under ZSDOS?
  578.     LD    A,H
  579.     OR    L
  580.     PUSH    AF        ; ..save flags for later
  581.     JR    Z,NOTZS0
  582.     CALL    EPRINT
  583.     DEFB    CR,LF,'    D - ZSDOS Path Spec',0
  584. NOTZS0:    CALL    EPRINT
  585.     DEFB    CR,LF,'Examples:'
  586.     DEFB    CR,LF,'    ZPATH                <-- Display Path(s)'
  587.     DEFB    CR,LF,'    ZPATH expr -or- ZPATH /C=expr    <-- Set ZCPR Path'
  588.     DEFB    CR,LF,'    ZPATH /Q expr -or- ZPATH /QC=expr <-- ..do it Quietly',0
  589.     POP    AF        ; Get flags for ZSDOS back
  590.     JR    Z,EXIT0        ; ..jump if not ZS
  591.     CALL    EPRINT
  592.     DEFB    CR,LF,'    ZPATH /D=expr            <-- Set ZSDOS Path'
  593.     DEFB    CR,LF,'    ZPATH expr,/D=expr        <-- Set Both Paths',0
  594. EXIT0:    CALL    CRLF
  595. EXIT:    LD    SP,(STACK)    ; Restore user's entry stack
  596.     RET            ; ..and quit
  597.  
  598. NOZPTH:    CALL    PRMUZL        ; Else print error and exit
  599.     DEFB    '- No ZCPR3 Path -',0
  600.     JR    EXIT
  601.  
  602. NOZWHL:    CALL    PRMUZL
  603.     DEFB    '- No Wheel -',0
  604.     JR    EXIT
  605.  
  606. NODPTH:    CALL    PRMUZL        ; Print error if not ZSDOS, No path
  607.     DEFB    '- No DOS Path -',0
  608.     JR    EXIT
  609.  
  610. ;.....
  611. ; Convert Chars pted to by HL to Number in C
  612. ;  Return with Carry Set if Overflow
  613. ;  If OK, Value in C and HL pts to character after last digit
  614.  
  615. EVAL10:    LD    C,0        ; set value
  616. EVAL1:    LD    A,(HL)        ; get first digit
  617.     SUB    '0'        ; convert to binary
  618.     JR    C,EVALX        ; done with value in C
  619.     CP    10        ; range?
  620.     JR    NC,EVALX    ; done with value in C
  621.     LD    B,A        ; digit in B
  622.     LD    A,C        ; multiply by 10
  623.     ADD    A,A        ; *2
  624.     RET    C        ; error abort
  625.     ADD    A,A        ; *4
  626.     RET    C
  627.     ADD    A,C        ; *5
  628.     RET    C
  629.     ADD    A,A        ; *10
  630.     RET    C
  631.     ADD    A,B        ; add value
  632.     RET    C
  633.     LD    C,A        ; value in C
  634.     INC    HL        ; pt to next
  635.     JR    EVAL1
  636.  
  637. EVALX:    OR    A        ; clear carry flag
  638.     RET
  639.  
  640. ;.....
  641. ; Print Colon
  642.  
  643. COLON:    LD    A,':'        ; print colon
  644.     JP    COUT
  645.  
  646. ;.....
  647. ; Print Arrow
  648.  
  649. ARROW:    CALL    EPRINT
  650.     DEFB    ' --> ',0
  651.     RET
  652.  
  653. ;.....
  654. ; Sample for White Space characters
  655.  
  656. WHITSP:    CP    ' '
  657.     RET    Z
  658.     CP    ','
  659.     RET    Z
  660.     CP    TAB
  661.     RET
  662.  
  663. ;.....
  664. ; Advance to next Non-Whitespace char, returning it in A
  665.  
  666. GETNXT:    INC    HL        ; Point to next
  667.             ;..and fall thru to get and test
  668. ;.....
  669. ; Skip to non-blank
  670.  
  671. SBLANK:    LD    A,(HL)        ; get char
  672.     INC    HL        ; pt to next
  673.     CALL    WHITSP        ; White space?
  674.     JR    Z,SBLANK    ; ..loop if so
  675.     DEC    HL        ; Else back up to non-blank
  676.     OR    A        ; Set flags based on char in A
  677.     RET
  678.  
  679. ;.....
  680. ; Scan directories for user and disk in C and B
  681. ;  Print name if found or "Noname" if not
  682.  
  683. UDSCAN:    CALL    DUTDIR        ; convert to name
  684.     JR    Z,UDSCAN1    ; error return if no name
  685.     LD    B,8        ; 8 chars max
  686. UDSPRN:    LD    A,(HL)        ; get name char
  687.     CP    ' '        ; done?
  688.     RET    Z
  689.     CALL    COUT        ; print char
  690.     INC    HL        ; pt to next
  691.     DJNZ    UDSPRN
  692.     RET
  693.  
  694. UDSCAN1: CALL    EPRINT
  695.     DEFB    'Noname',0
  696.     RET
  697.  
  698. ;.....
  699. ; Print only if Quiet Flag not active (Not Muzzled)
  700.  
  701. PRMUZL:    LD    A,(ZQUIET)    ; Are we muzzled?
  702.     OR    A
  703.     JP    Z,EPRINT    ; ..jump to print if not
  704.     POP    HL        ; Else scan around end of line passed
  705. PRMUZ0:    LD    A,(HL)
  706.     INC    HL
  707.     OR    A        ; End of line yet?
  708.     JR    NZ,PRMUZ0    ; ..loop if not
  709.     JP    (HL)        ; Else resume execution
  710.  
  711. ;==============================================
  712. ;        D A T A     A R E A
  713. ;==============================================
  714.     DSEG
  715.  
  716. DATA:    DEFS    0
  717. STACK    EQU    DATA+80H    ; Leave space for library vars & stack
  718.  
  719. DOSTYP    EQU    STACK+2        ; 1 byte - 'S' if ZSDOS, otherwise garbage
  720. PTHFLG    EQU    STACK+3        ; 1 byte - 0=Path Not active, FF=Int Path Activ
  721. DOSBAS    EQU    STACK+4        ; 2 bytes- Address of DOS Base
  722. CMDLIN    EQU    STACK+6        ; 2 bytes- Ptr to next char in command line
  723. TOKEN    EQU    STACK+8        ; 2 bytes- Ptr to current token
  724. MODE    EQU    STACK+10    ; 1 byte - Path Mode, 0001B=CPR, 0010B=Dos
  725.  
  726. DOSLEN    EQU    STACK+11    ; 1 byte - Maximum length of Dos path
  727. DOSPTR    EQU    STACK+12    ; 2 bytes- Pointer to Temp Dos path
  728. DOSPTH    EQU    STACK+14    ; 2 bytes- Pointer to Real Dos path
  729. CPRLEN    EQU    STACK+16    ; 1 byte - Maximum length of ZCPR path
  730. CPRPTR    EQU    STACK+17    ; 2 bytes- Pointer to Temp CPR path
  731. CPRPTH    EQU    STACK+19    ; 2 bytes- Pointer to Real CPR path
  732.  
  733. PTHPTR    EQU    STACK+21    ; 2 bytes- ptr to next path entry
  734. CURRNT    EQU    STACK+23    ; 1 byte - B0=Setting Dos, B1=Setting Z3
  735. ISZENV    EQU    STACK+24    ; 1 byte - 0=No Z3ENV, Non-0=Z3ENV Found
  736.  
  737. ;----- The following 4 bytes MUST remain in this order -------
  738.  
  739. ZQUIET    EQU    STACK+25    ; 1 byte - Z3 Quiet Flag/Local Quiet Flag
  740. ZWHEEL    EQU    STACK+26    ; 1 byte - Z3 Wheel Flag
  741.                 ; 2 bytes- who cares???
  742. ZMDISK    EQU    STACK+29    ; 1 byte - Z3 Maximum Disk Byte
  743. ZMUSER    EQU    STACK+30    ; 1 byte - Z3 Maximum User Byte
  744.  
  745.     END
  746.