; ; Program: SETFILE ; Author: Richard Conn ; Version: 1.0 ; Date: 5 Mar 84 ; version equ 11 ; Version 1.1 modifications by Bruce Morgen, February 11, 1989: ; Type 3 format with safety header, standard help message implemented, ; minor code tightening to keep COM file to four records. ;version equ 10 ; ; SETFILE defines the name of a ZCPR3 File Name or displays it. ; ; ; Equates for Key Values ; z3env defl 0f400h ; Address of ZCPR3 environment fnum equ 5ch+1 ; File number in 1st FCB fcb equ 6ch ; 2nd FCB cr equ 0dh lf equ 0ah ; ; External Z3LIB and SYSLIB Routines ; ext z3init,getfn1,getquiet,pfn1,eprint,cout ; 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 nop ; Filler db 'Z3ENV',3 ; Type-3 environment z3eadr: dw z3env ; 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 push hl ; Save address again sbc hl,de ; Subtract -- we should have 0 now pop hl ; Restore value of RETADDR jr z,start ; If addresses matched, begin real code ld de,notz33msg-retaddr ; Offset to message add hl,de ex de,hl ; Switch pointer to message into DE ld c,9 jp 0005h ; Return via BDOS print string function notz33msg: db 'Not Z33+$' ; Abort message if not Z33-compatible ; ; Environment Definition ; start: ld hl,(z3eadr) ; Pt to ZCPR3 environment ; ; ; Start of Program -- Initialize ZCPR3 Environment and Print Banner ; call z3init ; Initialize the ZCPR3 Environment call getquiet ; Z3 muzzling us? jr nz,notqui ; If so, limit verbiage call eprint ; Otherwise, do a banner db 'SETFILE, Version ' db (version/10)+'0','.',(version mod 10)+'0',cr,lf,0 ; ; Check Number of File ; notqui: ld a,(fnum) ; Get potential number cp '/' ; Help requested? jr z,help ; Comply if so cp ' ' ; User naive? jp nz,nohelp ; Proceed if not help: call eprint ; Otherwise give help db 'Sets/displays the selected ZCPR3 System File Name',cr,lf db 'Syntax:',cr,lf db ' SETFILE n [filename.typ]',cr,lf db ' where "n" is a digit from 1 to 4.',cr,lf,0 ret nohelp: ld hl,0 ; Init count ld de,11 ; Size of each file name sub '0' ; Convert to binary jr c,error jr z,error cp 5 ; Range? jr c,selfile ; ; Print Error Message ; error: call eprint db ' Invalid File Name Number (not 1-4)',0 ret ; ; Set Name of File ; selfile: add hl,de ; Compute offset from file name 1 dec a ; Count down jr nz,selfile ex de,hl ; DE contains offset call getfn1 ; Get ptr to shell file name add hl,de ; Get ptr to file name selected ld de,fcb+1 ; Pt to name in FCB ex de,hl ; Copy from FCB ld a,(hl) ; Get first char cp ' ' ; Don't define if no name jr z,prnnam ld bc,11 ; 11 bytes push de ldir ; Define name if name given pop de ; ; Print Name of Shell Variable File ; prnnam: call eprint db ' File Name ',0 ld a,(fnum) ; Get number call cout ; Print it call eprint ; Print file's name & go home db ' is ',0 jp pfn1 end