; ; Program: ALIAS0 ; Author: Richard Conn ; Version: 1.1 ; Date: 10 Jun 84 ; Previous Versions: 1.0 (5 Mar 84) ; ; Module: ALIAS1.Z80 ; Author: Joe Wright ; Date: 17 August 90 ; Version: 1.2 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 codend,$memry ext z3init,envptr,qprint,getwhl ext print,sksp,bbline,capine,crlf,pfn2,retud,logud,padc ext sfa,cout,ccout,pstr,zfname ext f$open,f$read,f$close,f$make,f$write,f$exist ext setdma,initfcb ; ; Things we want to know about ALIAS0 ; ext alias0, start, z3eadr ; 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 ; ; Print Banner ; call qprint db 'ALIAS, Version ' db version/10+'0','.',version mod 10+'0',0 ; ; Check for File ; call codend ; Input file buffer ld (oldaline),hl ; Temporarily, in case of no input file xor a ld (hl),a ; No old alias line for the moment ld (flflag),a ; Clear file loaded flag ld hl,fcb+1 ; Pt to file name ld a,(hl) ; Get first char cp ' ' ; No name if space jp z,create ; Create an alias if no name cp '/' ; Help? jp nz,start0 ; ; Help Message ; call print db cr,lf,'ALIAS -- Create Alias Commands' db cr,lf,'Syntax:' db cr,lf,' ALIAS <-- Define New Command' db cr,lf,'or' db cr,lf,' ALIAS dir:cmndname <-- Redefine Old Command' db 0 ret ; ; Load ALIAS File ; start0: call setcom ; Set file type of file in FCB to COM call retud ; Get current DU in BC dec hl ; Pt to disk ld a,(hl) ; Get disk or a ; No current disk? jr z,start1 ; Use current disk dec a ; Set disk (A=0) ld b,a start1: ld (hl),0 ; Set current disk ld de,13 ; Pt to user number push hl ; Save ptr to FCB add hl,de ; Pt to user ld c,(hl) ; Get user pop de ; Pt to FCB call logud ; Log into dir in BC call f$open ; Open alias file for input jr z,load ; Load file ; call print db cr,lf,' Alias File ',0 inc de ; Pt to file name call pfn2 ; Print it call print db ' Not Found',0 ret ; ; Load Alias File ; load: call codend ; Pt to load buffer ld c,9 ; Set block count load1: call setdma ; Set DMAADR ld de,fcb ; Pt to FCB call f$read ; Read next block jr nz,load2 ; End of File ; ld de,128 ; One record length add hl,de ; New DMAADR dec c ; Decrement count jr nz,load1 ; Read another ; ; Error - Not an Alias File if nine records or more ; noalias: call print db cr,lf,' File ',0 ld de,fcb+1 call pfn2 call print db ' is Not an Alias',0 ret ; ; 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 ld a,0ffh ; Set file loaded flag ld (flflag),a ; ; Create New Alias ; create: ld a,(flflag) ; Check for file loaded or a ; 0 if not jr z,cr1 ; ; Display Data on Old Alias ; call print db cr,lf,' Alias Name: ',0 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 call print db cr,lf,' Old Alias Command Line:',0 ld hl,(oldaline) 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: call print db cr,lf db cr,lf,' Input Alias ' db '(RETURN to Abort, ^S to Save)',cr,lf,' --> ',0 ld a,0ffh ; Input line from user call bbline call sksp ; Skip to non-blank ld a,(hl) ; Get char or a ; Any input? ret z ; No, Abort cp 'S'-40h ; ^S jr nz,cr1b ; Not Save command 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,17 ; Pt to buffer at START+17 add hl,de ld b,255 ; Check for overflow (max number of chars) pop de ; Pt to new command ; ; Copy New Command into ALIAS0 File ; cr2: ld a,(de) ; Get char ld (hl),a ; Put char or a ; Done? jr z,cr3 inc hl ; Pt to next inc de djnz cr2 call print db cr,lf,' Command Too Long for Buffer - Reenter',0 jp create ; ; ALIAS Command Line Copied ; cr3: ld a,(flflag) ; File loaded? or a ; 0=no jr nz,write call print db cr,lf,' Name of ALIAS Command (RETURN to Abort)? ',0 ld a,0ffh ; Capitalize call bbline call sksp ; Skip to non-blank ld a,(hl) or a jp z,create ld de,fcb ; Pt to FCB call zfname ; Convert and place in FCB call setcom ; Set file type to COM if not already call retud ; Get current DU ld a,(fcb) ; Get disk or a ; Default? jr z,cr4 dec a ; Disk A = 0 ld b,a cr4: ld a,(fcb+13) ; Get user ld c,a call logud ; ; Write File whose Name is in FCB ; write: ld de,fcb ; Check for file call initfcb ; Clear FCB call f$exist ; Check for existence jr z,write1 ; No file, go for it call print db cr,lf,' File ',0 ld de,fcb+1 call pfn2 call print db ' Exists - Overwrite (Y/N)? ',0 call capine call crlf cp 'Y' ret nz ; Abort if not Y ld de,fcb ; Clear file attributes xor a call sfa ; Set file attributes to R/W DIR ; ; Create New File ; write1: call initfcb ; Init it 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 ld de,fcb ; Write block call f$write jr nz,werr ld de,128 add hl,de ; New DMAADR dec c ; Count down jr nz,write2 ld de,fcb call f$close ; Close file call print db cr,lf,' Alias Created',0 ret werr: call print db cr,lf,' Error in Creating File',0 ret ; ; Set File Type of File in FCB to COM if Not Already Set ; setcom: ld a,(fcb+9) ; Get first char of file type cp ' ' ret nz push hl ld hl,comtyp ; Set COM type ld de,fcb+9 ; Copy into file type ld bc,3 ; 3 bytes ldir pop hl ret ; ; Buffers ; comtyp: db 'COM' ; COM File Type aliasid: db 'Z3 ALIAS' ; ALIAS File ID flflag: ds 1 ; File loaded flag oldaline: ds 2 ; Ptr to old alias line end ; ; End of ALIAS1.Z80