; Program: IMP2Z ; Authors: Bruce Morgen and Jay Sage ; Version: 1.1 adapted by Fred Haines from MEX+2Z11 ; Date: 3 Jun 87 ; Previous Versions: IMP2Z v1.0 (14 Apr 87), MEX+2Z v1.1 ; (8 Dec 86), v1.0, and MEX2Z ; ;______________________________________________________________________ ; ; IMP2Z: IMP-to-ZCPR3 Chaining Program ; ; This program was derived from Bruce Morgen's and Jay Sage's MEX+2Z to ; provide a similar feature to IMP v2.44 or v2.45. ; ; IMP2Z gives the IMP command 'CPM' a shell capability like the SHELL ; command of the 16-bit version of MEX+. To use IMP2Z: ; ; 1) Set the real IMP.COM file so that it will not be invoked by a command ; of the form "IMP". This can be done by renaming it (e.g., to REALIMP) ; or by putting it in a directory that is not along the search path. ; ; 2) Create a standalone or ARUNZ alias called IMP with a script such as ; either of the following: ; ; REALIMP;IMP2Z (for renamed IMP) ; DIR:IMP;IMP2Z (if IMP in DIR:) ; ; On exit from IMP, IMP2Z runs and looks for the IMP command line left in ; memory. It scans for the CPM command, takes anything in the command after ; that, and puts it into the ZCPR3 command line with ";IMP" after it so that ; the IMP alias will be run again after the other commands are finished. Thus, ; if you leave IMP with the command "CPM CRUNCH FN.FT", the file will be ; crunched and then you will return to IMP. ; ; If you are using an ARUNZ alias (or you want to use a name other than IMP), ; you can patch a string at the beginning of IMP2Z. Just make sure that you ; leave at least on byte of 00 after the command line. Replacing the string ; ";IMP<0>" with ";ARUNZ IMP<0>" will speed up command processing, as will the ; string with a leading space, "; IMP<0>", if you are using ZCPR v3.3. ;============================================================================= ; ; R E V I S I O N H I S T O R Y ; ;============================================================================= VERSION EQU 11 ; Version 1.1 for IMP June 3, 1987, Fred Haines ; This version has been modified to permit conditional assembly for ; versions 2.44 or 2.45 of IMP. Set the V245 equate below for the ; correct version. The only difference is in the address of the IMP ; command line buffer. ; Version 1.0a for IMP April 14, 1987, Fred Haines ; This is the first test version of this program for IMP rather than ; MEX. It has been modified from the MEX version to account for the ; fact that there's only one version of IMP in use and for the different ; way IMP handles its command line, which is apparently more like MEX+ ; than MEX in that it keeps track of the length of the command line with ; a character count byte at the beginning of the command line buffer, ; IMPCL. ; ; The versions described below are for MEX rather than IMP. ; Version 1.1 December 11, 1986, Jay Sage ; Improved processing of the IMP command line to make it more reliable ; and make it work with multiple commands in MEX-PLUS. The code makes ; use of the way MEX-PLUS maintains the command line. With MEX114 the ; command line length is not stored at the beginning of the command ; line; a value of zero is stored there. Bruce's original technique of ; scanning for the terminating carriage return must be used. The MEXPLUS ; equate takes care of this. ; Version 1.0 December 8. 1986, Bruce Morgen ; Original version for MEX114. ;============================================================================= ; ; C O N F I G U R A T I O N S E C T I O N ; ;============================================================================= NO EQU 0 YES EQU NOT NO BIHELP EQU YES ; YES to include built-in help facility AUTOINS EQU YES ; YES if using auto-install ZCPR3 CMDRUN EQU NO ; YES if using an ARUNZ alias called by CMDRUN, ; ..NO otherwise or for standalone alias V244 EQU NO V255 EQU YES IMPPTR EQU 0509H ; Address of pointer to command buffer IF V244 IMPCL EQU 48BAH ; IMP 2.44 command buffer address IMPVER MACRO ; Macro with IMP version name DB 'IMP Version 2.44' ENDM ENDIF ; V244 IF V255 IMPCL EQU 49EBH IMPVER MACRO DB 'IMP Version 2.55' ENDM ENDIF ; V255 CR EQU 0DH ; ASCII characters LF EQU 0AH TAB EQU 9 BELL EQU 7 PRINTF EQU 9 ; BDOS print string function BDOS EQU 0005 ; BDOS entry point TBUFF EQU 80H ; Command tail buffer ;============================================================================= ; ; E X T E R N A L R E F E R E N C E S ; ;============================================================================= EXTRN Z3INIT,PUTCL,$MEMRY IF NOT AUTOINS EXTRN FENV ENDIF ;============================================================================= ; ; C O D E ; ;============================================================================= JP START DB 'Z3ENV',1 Z3ENV: DW 0FE00H ; Filled in at installation ; Command-line shell-making suffix (here for easy patching) IMPNAM: DB ';' ; Separator IF CMDRUN ; If using ARUNZ (CMDRUN) alias DB 'CMDRUN' ENDIF ; CMDRUN DB ' IMP' ; Command name DB 0,0,0,0,0,0,0,0,0,0 ; Room for patching NAMELEN EQU $ - IMPNAM START: LD (STACK),SP LD SP,$MEMRY+64 ; Establish stack (so we can be sloppy later) IF AUTOINS ; Initialize ZCPR3 LD HL,(Z3ENV) ELSE ; NOT AUTOINS CALL FENV ; Find environment. LD DE,NOTZ3 ; Point to error message. JR Z,ENDIT ; Barf if not ZCPR3. ENDIF ; AUTOINS CALL Z3INIT ; Initialize Z3LIB. ; ------------------------- Display built-in help if anything in command tail IF BIHELP ; Built-in help enabled LD A,(TBUFF) ; Get count of characters in tail OR A ; If nonzero, display built-in help JP NZ,HELP ENDIF ; BIHELP ; ------------------------- Check for IMP command line in memory LD HL,(IMPPTR) ; Get pointer to command line LD BC,IMPCL ; Correct value of pointer LD DE,IMPERR1 ; Point to possible error message LD A,B ; Check for agreement CP H JR NZ,ENDIT ; Error message if different LD A,C CP L JR NZ,ENDIT ; ------------------------- Quit if Imp command is only three bytes ld hl,impcl ; Point to CL char count in CL buffer ld a,3 ; Is Imp command longer than 3 letters? cp (hl) ; Compare to char count in memory jr nc,done ; ; ------------------------ Determine whether command is CPM exit command LD B,(HL) ; Put character count into B INC HL ; Point to first character of command line LD DE,EXITCMD ; Point to exit command to scan for EX DE,HL ; Outer loop: look for initial character SCAN1: LD A,(DE) ; Get character from command line CP (HL) ; See if it matches exit command first char JR Z,SCAN3 ; Go to check for rest of characters SCAN2: INC DE ; Point to next character in command line DJNZ SCAN1 ; Continue scan JR DONE ; If not found, we are done ; Inner loop: check rest of characters SCAN3: PUSH HL ; Save registers PUSH DE PUSH BC LD B,EXITLEN-2 ; Characters in exit command less one SCAN4: INC HL ; Bump pointers INC DE LD A,(DE) CP (HL) JR NZ,SCAN5 ; Commands do not match DJNZ SCAN4 JR FOUND ; Exit command found SCAN5: POP BC ; Restore the registers POP DE POP HL JR SCAN2 ; Resume outer scan loop ; ------------------------- Build ZCPR3 command line ; Skip to any tail after exit command FOUND: ld hl,impcl ; Put HL back to character count byte ld c,(hl) ; Put char count in C, ld b,0 ; ..zero out B, add hl,bc ; ..and add character count to HL inc hl ; ..to point to location after comand line ; Add IMP reinvocation command to end of existing ; command in IMP command buffer EX DE,HL ; To DE as destination pointer. LD HL,IMPNAM ; Source pointer to HL. LD BC,NAMELEN ; Length of line as counter to BC. LDIR ; Move 'em out. ; Store Z command in Z MCL buffer ld hl,impcl+5 ; Point hl at beginning of Z command tail CALL PUTCL ; Stuff command line via Z3LIB. JR NZ,DONE ; Trap command line failures. LD DE,MCLERR ; Point at cmd line error msg. ; ------------------------- ENDIT: LD C,PRINTF ; BDOS print string function #. LD SP,(STACK) ; Restore incoming stack pointer. JP BDOS ; Return via BDOS entry vector. IF BIHELP ; Built-in help enabled HELP: LD DE,HELPMSG ; Point to help message JR ENDIT ENDIF ; BIHELP DONE: LD SP,(STACK) ; Restore incoming stack pointer. RET ; All done, go to Z3. ; ------------------------- Messages EXITCMD: DB 'CPM',0 EXITLEN EQU $ - EXITCMD NOTZ3: DB LF DB 'For ZCPR3 only (Z3ENV not found)!' DB bell,'$' IMPERR1: DB LF IMPVER ; Imp version name macro DB ' image not found in memory!' DB bell,'$' IMPERR2: DB LF DB 'Defect in IMP command line!' DB bell,'$' MCLERR: DB 'ZCPR3 command line error!',bell,'$' IF BIHELP ; Built-in help enabled HELPMSG: DB LF DB TAB,'IMP2Z Version ' DB VERSION/10+'0','.',VERSION MOD 10 +'0' DB ' [ZSIG]' DB CR,LF,LF DB 'For ' IMPVER DB ', gives a virtual shell capability' DB CR,LF DB 'to the exit command CPM.' DB CR,LF,LF DB 'Any tail after the IMP command "CPM" will be detected by' DB CR,LF DB 'IMP2Z and run as a command by ZCPR3. Then IMP will be' DB CR,LF DB 'reinvoked.' DB CR,LF,LF DB 'To use IMP2Z you must make an alias named IMP with a script' DB CR,LF DB 'such as "REALIMP;IMP2Z", where the real IMP.COM file has' DB CR,LF DB 'been renamed (e.g., to REALIMP) or kept off the path and' DB CR,LF DB 'invoked with an explicit DIR: prefix.' DB '$' ENDIF ; BIHELP STACK: DS 2 END