home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
F
/
NAME12.LBR
/
NAME12.ZZ0
/
NAME12.Z80
Wrap
Text File
|
1991-06-29
|
6KB
|
207 lines
;Program: NAME
;Author: Bruce Morgen
;Date: May 21, 1988
;Purpose:
;Inspired by Jay Sage's ARUNZ script for the same function.
;Jay's script invoked A.E.Hawley's wonderful EDITND tool to
;simply rename the current directory. EDITND is a powerful
;program with lots of features - it also weighs in at about
;6 1/2 K. NAME is under 1K and it does on-the-fly renaming
;and deletion of directory names very quickly and safely.
;It's really quite nice on a ramdisk or in COMMAND.LBR and
;makes a good team with PWD and A.E.'s SAVNDR tool. The
;syntax is simple enough to be thoroughly understood by
;viewing the help screen - invoked without a new directory
;name, it just deletes the NDR entry for the current or
;specified DU:/DIR:.
;Version 1.2 modifications by Bruce Morgen, 6/29/91
;Deleted and re-coded parts of NAME to take advantage of
;the fact that SUBNDR and ADDNDR now work as documented.
;Used new GETND0 routine in place of old, errant GETNDR.
;Thanks to Howard Schwartz for spotting problems and to
;Hal Bower and Howard Goldstein for repairing Z3LIB.
;Hallelujah!
;Version 1.1 modifications by Bruce Morgen, 6/12/91
;Improved help screen and Type 4 executable implemented,
;trival code tweaks. The Type 3 version now exceeds 1K
;-- the price of progress? Perhaps....
public print ; To fool prttyp
extrn z3init,addndr,subndr,dirndr,dundr,getnd0
extrn getwhl,puter2,prtnam,prttyp,z33chk,fcb1chk
extrn eprint,epstr,retud
fcb equ 5ch
fcb2 equ 6ch
tbuff equ 80h
usroff equ 13
bdose equ 5
prnstr equ 9
cr equ 0dh
lf equ 0ah
bel equ 07h
blank equ 20h
; TYPE 3 HEADER
; Code modified as suggested by Charles Irvine to function correctly with
; interrupts enabled. Program will abort with an error message when not
; loaded to the correct address (attempt to run it under CP/M or Z30).
entry:
jr start0 ; Must use relative jump
ds 1
db 'Z3ENV',3 ; Type-3 environment
z3eadr:
dw 00 ; Filled in by Z33
dw entry ; Intended load address
start0:
ld hl,0 ; Point to warmboot entry
ld a,(hl) ; Save the byte there
di ; Protect against interrupts
ld (hl),0c9h ; Replace warmboot with a return opcode
rst 0 ; Call address 0, pushing RETADDR
; Onto stack
retaddr:
ld (hl),a ; Restore byte at 0
dec sp ; Get stack pointer to point
dec sp ; To the value of RETADDR
pop hl ; Get it into HL and restore stack
ei ; We can allow interrupts again
ld de,retaddr ; This is where we should be
xor a ; Clear carry flag
sbc hl,de ; Subtract -- we should have 0 now
jr z,start ; If addresses matched, begin real code
add hl,de ; Restore value of RETADDR
ld de,notz33msg-retaddr ; Offset to message
add hl,de
ex de,hl ; Switch pointer to message into DE
ld c,prnstr
jp bdose ; Return via BDOS print string function
notz33msg:
db 'Not Z33+$' ; Abort message if not Z33-compatible
start: ld hl,(z3eadr)
call z3init
xor a
call puter2
call getwhl ; NAME is for wheels only,
jr z,failed ; so reject the unempowered
call getnd0 ; NDR implemented?
jr z,fail3 ; Nope, failure...
ld hl,entry-0100h ; Get load address-100h in HL
ld a,l ; Test for 100h load address
or h
jr nz,chkfcb ; If not, assume Z33+ parsing
call z33chk ; Otherwise check for Z33+ CCP
jr nz,nocfcb ; If not, handle as Z30
chkfcb: call fcb1chk ; Test for invalid directory
jr nz,fail4 ; Error is it's invalid
nocfcb: ld de,fcb+1 ; Point to new name
ld a,(de) ; First character
cp '/' ; Give help if requested
jp z,help
ld h,d ; Scan for illegal wildcards
ld l,e
ld bc,18h+1 ; Range over both FCBs
ld a,'?' ; Doubles as wildcard error code
cpir
jp pe,fail1
ld l,e ; Name pointer into HL (H = 0)
call dirndr ; See if name is taken
ex de,hl ; Get back pointer
call nz,subndr ; Get rid of the old one if so
dec hl ; Point to FCB drive byte
ld b,(hl) ; Into B
inc b ; Cleverly test for zero
djnz gotdsk ; indicating current drive
call retud ; Ask BDOS what disk this is
inc b ; Translate to FCBese
ld (hl),b ; Poke it in
gotdsk:
push hl ; FCB pointer to stack
ld de,usroff ; Offset to Z3-parsed user code
add hl,de ; Add it in
ld c,(hl) ; User number in C
call dundr ; See if it already has a name
jr z,nosub2 ; Branch ahead if not
inc hl ; Bump past old DU bytes
inc hl
ld e,tbuff ; Our work buffer is TBUFF (D=0)
ld bc,8 ; Longest name length
push de ; Save buffer pointer
ldir ; Move name to buffer
pop hl ; Get back buffer pointer
call subndr ; Delete entry, sort NDR
nosub2: pop hl ; Pointer to FCB1 in HL
inc hl ; Get back first FCB character
ld a,(hl)
cp blank ; Blank means removal only,
ret z ; so we're done
dec hl ; Otherwise, point to FCB again
ld de,fcb2+1 ; Pointer to password in DE
ld a,(de) ; Get first password character
sub blank ; A=0 if it's blank
call addndr ; Add entry, sort NDR
ret nz ; All done if no error
; fall through ; Only on error
fail2: ld hl,string2 ; Error #2, "no room"
ld a,2
jr prstr2
fail3: ld hl,string3 ; Error #3, "no NDR buffer"
ld a,3
jr prstr2
fail4: ld hl,string4 ; Error #4, "bad Z3 d/u"
ld a,4
prstr2:
call prstrg
xor a
cpl
failed: ld hl,string ; Jump to here with A = 0
inc a ; is Error #1, "no wheel"
prstrg: or a
call nz,puter2
jp epstr ; Errors and help exit via SYSLIB
fail1: ld hl,string1 ; Error #"?", "wildcard n/g"
jr prstr2
string1:
db 'Illegal wildcard characters',0
string2:
db 'No room for any new names',0
string3:
db 'NDR buffer not implemented',0
string4:
db 'Invalid ZCPR3 drive/user',0
string:
db bel,',',cr,lf,'directory change failed.',0
help:
call eprint
db 'NAME, Version 1.2 ',0
ld a,((z3eadr-1))
ld hl,entry
call prttyp
call eprint
db cr,lf,'Syntax:',cr,lf,' ',0
call prtnam
call eprint
db ' [du: or dir:][newname] [password]',cr,lf
db 'Changes the directory name of the',cr,lf
db 'specified or default directory.',cr,lf
db 'Execution without "newname"',cr,lf
db 'deletes the current name, if any.',cr,lf,0
ret
print: jp eprint
end