; Program: ALIAS ; Author: Richard Conn ; Version: 1.1 ; Date: 10 Jun 84 ; Previous Versions: 1.0 (5 Mar 84) ; ; Module: ALIAS1.Z80 (Second module of ALIAS.COM) ; Author: Joe Wright ; Date: 17 August 90 ; Version: 1.2 version equ 17 ; 21 Jan 91 Reflect change in ALIAS0 ;version equ 16 ; 21 November 90 ; Added '$Rn' command in ALIAS0 to expand Register contents. ; Corrected some coding errors. Thanks Howard Goldstein. ; 8 September 90 ; Back to ZFNAME for testing. Uses PUTUD and GETUD for default ; User/Drive and Z3LOG from Z3LIB. Seems to work. ; Changed ALIAS1-ALIAS0 construct to ALIAS1-100H for ZMAC. ; 5 September 90 ; ZFNAME replaced in favor of ZPRSFN for 'new' filename parsing. ; ZFNAME does not return the current Drive number if only ; U: is specified. Serious error. Thanks Howard Goldstein ;version equ 15 ; 31 August 90 Changes in ALIAS0 ;version equ 14 ; 29 August 90 ; Changed 'look and feel' somewhat and allow file to be renamed ; if it already exists. Other minor changes. ;version equ 13 ; 28 August 90 ; Rob Friefeld teased me into taking another 38 bytes out of ALIAS0 ; and convinced me that Recursive Mode is useful enough to be ; supported. Howard Goldstein, not to be outdone, took yet another ; byte out of ALIAS0 and corrected an arithmetic error. Thanks all. ; I have reworked ALIAS1 for 'Recursive Mode' and to make it a little ; smoother. This is not a replacement for Rob's SALIAS but simply ; an upgrade of Conn's original ALIAS. ;version equ 12 ; Version 1.2 is changed significantly over Conn's 1.1 in that ; the order of the modules is reversed. ALIAS0 is the first module ; and holds the actual alias code. ALIAS1 (this file) follows ; ALIAS0 in the link list. After assembling ALIAS0.Z80 and ALIAS1.Z80 ; to REL, link them as follows: ; ; LINK ALIAS=ALIAS0,ALIAS1[NR] ; or ZML ALIAS=ALIAS0,ALIAS1 ; or SLRNKP ALIAS/N,/A:100/J,ALIAS0,ALIAS1,/E ; ; The purpose of ALIAS1 is to create aliases using the ALIAS0 module. ; ; Basic Equates ; tbuff equ 80h fcb equ 5ch cr equ 0dh lf equ 0ah ; ; External References ; .request z3lib, syslib ; Requesting the Libraries here ; simplifies the Linker command line ext z3init,getwhl,z3log,zfname ext print,sksp,bbline,capine,crlf,pfn2,retud,padc,pafdc ext pstr,sfa,cout,ccout ext f$open,f$read,f$close,f$make,f$write,f$exist ext setdma,initfcb,codend,putud,getud ; ; Things we want to know about ALIAS0 ; ext alias0,start,z3eadr,recur,aclbuf ; Addresses in ALIAS0 ; ; ALIAS0 needs this from us ; public alias1 ; ; This is the start of ALIAS1. ; alias1: ld hl,(z3eadr) ; Pt to ZCPR3 environment call z3init ; Initialize the ZCPR3 Env call putud ; Save default User/Drive ; ; Print Banner ; call print db ' ALIAS, Version ' db version/10+'0','.',version mod 10+'0',0 ; ; Check for File ; over: call codend ; Input file buffer ld (oldaline),hl ; Temporarily, in case of no input file xor a ; Get a null ld (hl),a ; No old alias line for the moment ld (save),a ; Clear the save flag ld de,fcb+1 ; Pt to file name ld a,(de) ; Get first char dec de ; Point to FCB cp ' ' ; No name if space jp z,create ; Create an alias if no name cp '/' ; Help? jp nz,start0 ; We have a file name ; ; Help Message ; call print db ' -- Create and/or Edit Alias Commands',cr,lf db ' Syntax: ALIAS [[dir:]cmndname]',cr,lf,0 ret ; ; Load ALIAS File ; start0: call z3log ; Log into specified directory call initfcb ; Initialize the FCB call setcom ; Set file type of file in FCB to COM call f$open ; Open alias file for input jp nz,create ; Can't find it, create it ; Else fall through to LOAD it ; ; Load Alias File ; call codend ; Pt to load buffer ld c,9 ; Set block count ld de,fcb ; Pt to FCB load1: call setdma ; Set DMAADR call f$read ; Read next record jr nz,load2 ; End of File ; call add128 ; Advance DMAADR dec c ; Decrement count jr nz,load1 ; Read another call f$close ; ; Error - Not an Alias File if nine records or more ; noalias: call print db cr,lf,' File ',0 call pdufn ; Leaves de pointing to FCB+1 call print db ' is Not an Alias',0 ; ; Clear the FCB to spaces ; ld a,' ' ld b,11 clr: ld (de),a ; 'Clear' filename inc de djnz clr jp over ; Try again ; ; Load Complete - Check for Alias File Structure ; load2: call f$close ; Close input file call codend ; Beginning of input file inc hl ; Low order of START address ld l,(hl) ; HL points to START ld de,9 ; Skip to ALIAS ID add hl,de ld de,aliasid ; Compare ld b,8 ; 8 chars acheck: ld a,(de) ; Get char cp (hl) ; Compare jr nz,noalias ; No ID match, not an alias inc hl ; Pt to next inc de djnz acheck ld (oldaline),hl ; Save ptr to old alias command line call codend ; Point to the loaded alias ld de,0bh ; Offset to potential 'F' flag add hl,de ld a,(hl) cp 'F' jr nz,create ; 'F' not found inc hl ; Point to 'recur' flag ld a,(hl) ld (mode),a ; Save it locally ; ; Create New Alias ; create: ; ; Display Data on Old Alias as appropriate ; ld a,(fcb+1) cp ' ' jr z,cr00 ; No name call print db cr,lf,' Alias Name: ',0 call pdu ld hl,fcb+1 ; Pt to name ld b,8 ; 8 chars cr0: ld a,(hl) ; Print name and 7fh call cout inc hl ; Pt to next char djnz cr0 cr00: ld hl,(oldaline) ld a,(hl) or a jr z,cr1 ; No commands yet call print db cr,lf,' Alias Command Line:',0 ld b,1 ; Set line count cr0a: ld a,(hl) ; Check for done or a jr z,cr1 call crlf ; New line ld a,b ; Print line number call padc inc b ; Increment count call print ; Print prompt db ' --> ',0 cr0b: ld a,(hl) ; Get char or a jr z,cr1 call ccout ; Print char with control char processing inc hl ; Pt to next cp ';' ; Next logical line? jr z,cr0a jr cr0b ; ; Input Alias Command from User ; cr1: call getwhl ; Get wheel byte jr nz,cr1a call print db cr,lf,' Modification of Alias Not Permitted',0 ret ; ; Input Alias from User ; cr1a: ld hl,(oldaline) ld a,(hl) or a jr z,cr1aa ; If no commands, no Mode call print db cr,lf,' Mode: ',0 ld hl,nor ; Assume Normal ld a,(mode) or a jr z,cr1a1 ld hl,rec ; Else Recursive cr1a1: call pstr cr1aa: call print db cr,lf,' Input Alias (RETURN to ',0 ld hl,wr ; 'Write, ^C to Quit' ld a,(save) or a jr nz,crp ld hl,ab ; 'Quit' call pstr ld hl,(oldaline) ld a,(hl) or a ld hl,ab1 ; '^W to Write' crp: call nz,pstr call print db ', ^N New alias, ^T toggle Mode)',cr,lf,' --> ',0 ld a,0ffh ; Capitalize call bbline ; Input line from user call sksp ; Skip to non-blank ld a,(hl) ; Get char or a ; Any input? jr z,cr1a2 ; No, check save flag cp 'N'-40h ; ^N Load new alias jp z,newfile cp 'W'-40h ; ^W Write command jr z,cr1a3 ; Write it cp 'T'-40h ; ^T jr nz,creat ; Not Toggle command ld a,(mode) ; Current Mode cpl ; Toggle it ld (mode),a ; New Mode jr crea ; creat: ld de,(oldaline) ; Destination call movit ; Move (hl) to (de) including Null crea: ld a,255 ld (save),a jp create ; Redisplay everything cr1a2: ld a,(save) ; Check Save flag or a ret z ; Nothing to save, abort cr1a3: ld hl,(oldaline) ; Old alias command line ld a,(hl) or a ret z ; No Old alias, Abort ; cr1b: push hl ; Save ptr ; ; Prep to Copy New Command Into ALIAS0 ; ld hl,start ; START address in ALIAS0 ld (alias0+1),hl ; Point ALIAS0 to itself ld de,aclbuf ; Alias0 command line buffer pop hl ; Pt to new command ; ; Copy New Command into ALIAS0 File ; call movit ; Move (hl) to (de) including Null ld a,(mode) ; Local Mode ld (recur),a ; Plug it in ld a,(fcb+1) ; File loaded? cp ' ' jr nz,write ; Write if so, else ask for filename ask: call new ; Get new alias name ret z ; No name specified call getud ; Log default DU before Z3LOG call z3log ; Log into destination directory call initfcb ; Clear the FCB call setcom ; Set file type to COM ; ; Write File whose Name is in FCB ; write: ld de,fcb ; Check for file call f$exist ; Check for existence jr z,write1 ; No file, go for it call print db cr,lf,' File ',0 call pdufn call print db ' Exists - Overwrite (Y/N)? ',0 call capine sub 'Y' jp nz,ask ; If not 'Y', prompt for new name ld de,fcb ; Clear file attributes call sfa ; Set file attributes to R/W DIR ; ; Create New File ; write1: call f$make ; Create file ld hl,alias1-100h ; Length of ALIAS0 in bytes (mod 128) add hl,hl ; Records to H ld c,h ; Now to C ld hl,alias0 ; Beginning of ALIAS0 write2: call setdma ; Set DMAADR for BDOS call f$write jr nz,werr call add128 ; Advance DMAADR dec c ; Count down jr nz,write2 ; ; Write is finished, sign off. ; call f$close ; Close file call print db cr,lf,' Alias ',0 call pdufn call print db ' Created',0 ret werr: call print db cr,lf,' Error in Creating File',0 ret ; newfile: call new ; Ask for new name ret z ; None, Quit jp over ; Start over new: call print db cr,lf,' Name of ALIAS Command (RETURN to Quit)? ',0 ld a,0ffh ; Capitalize call bbline ; Get dir:filename from user call sksp ; Skip to non-blank ld a,(hl) or a ret z ; Quit call getud ; Start with default User/Drive ld de,fcb xor a ; DIR first call zfname ; Parse it into FCB or 255 ; NZ for success ret ; ; Set File Type of File in FCB to COM ; setcom: push hl push de ld hl,comtyp ; Set COM type ld de,fcb+9 ; Copy into file type call movit pop de pop hl ret ; ; Move (hl) to (de) until and including Null terminator ; movit: ld a,(hl) ; Get the byte we are about to move ldi ; (hl) to (de), inc HL and DE or a ; Test byte for Null jr nz,movit ; Move another if not ret ; ; Print DU:NAME.TYP ; pdufn: call pdu ; Print DU: ld de,fcb+1 ; Point to filespec jp pfn2 ; Print it ; ; Print DU: ; pdu: call retud ; Drive (Rel 0) in B, User in C ld a,b ; Get Drive add a,'A' ; Add Ascii call cout ; Print it ld a,c ; Get User call pafdc ; Print it ld a,':' jp cout ; ; Add 128 to HL ; add128: ld a,128 ; ; Add A to HL ; addah: add a,l ; Add A to L ld l,a ; Put it back ret nc ; If LT 256 inc h ; Overflow ret ; ; Buffers ; aliasid: db 'Z3 ALIAS' ; ALIAS File ID comtyp: db 'COM',0 ; COM File Type nor: db 'Normal',0 rec: db 'Recursive',0 ab: db 'Quit',0 ab1: db ', ^W to Write',0 wr: db 'Write, ^C to Quit',0 mode: db 0 ; 0=Normal, 0FFh=Recursive save: ds 1 ; Save flag oldaline: ds 2 ; Ptr to old alias line end ; ; End of ALIAS1.Z80