; Procedure to return environment descriptor address and a 16 (max) char ; file name to caller. This works in conjunction with the INSTM2Z3 ; program which searches a TM2 generated .COM file for the marker "Z3.3ENV" ; near the end of this procedure and patches this routine as follows: ; The EnvAdr: location and the FilNam: buffer will be patched to 0h ; and the name of a file (TCAP?) if the installation is for CP/M. ; If for ZCPR3 the EnvAdr: location will be patched to the value specified by ; an .ENV file and the FilNam: location will be null. If for ZCPR 3.3, ; FilNam: will be patched to null and the code at the end of this procedure ; will be patched so that register HL (set to point to environment descriptor ; by the ZCPR3.3 loader) will be saved in EnvAdr: before any thing else is ; done and control will return to the TM2 main program to continue the ; initialization of the TM2 .COM program. ; ; By this process a TM2 program can be installed at the binary level and ; gain access to ZCPR3/ZCPR3.3 services. It was intended that in a CP/M ; environment the FilNam: would be used to give the TM2 program access to ; a ZCPR style TCAP file but, in fact, the file name can be used for any ; desired purpose. ; ; FilNam: is large enough (16 char) to accommodate the DU:FILENAME.EXT ; form of file names ; PUBLIC GetEnv GetEnv: POP IY ; save return address POP DE ; array size POP HL ; address of array POP IX ; address of Environment descriptor param PUSH IY ; restore return address LD B, E ; B = Array size; LD A, 0 PUSH HL ; save copy of HL L1: LD (HL), A ; set array to nulls DJNZ L1 LD A, E CP 16 ; test array size JR NC, L2 ; if actual size >= 16 LD B, 16 ; use size of 16 JR L3 L2: LD B, E ; else use actual size L3: LD HL, FilNam ; HL -> source POP DE ; DE -> dest (array address) LDIR ; send file name to caller LD HL, (EnvAdr) ; HL = Environment descriptor address LD (IX), L ; return the environment descriptor to caller LD (IX + 1), H RET ; NOTICE: Modification of the code beyond this point may mean that the ; program INSTM2Z3 will no longer patch it properly!!! DB 'Z3.3ENV' ; ID marker for INSTM2Z3 program EnvAdr: DW 0FE00h ; buffer for environment descriptor address FilNam: DB 0,0,0,0,0,0,0,0 ; file name storage DB 0,0,0,0,0,0,0,0 DB 0 ; marker used by INSTM2Z3. 0 = CP/M, ; 1 = ZCPR3, 2 = ZCPR3.3 LD (EnvAdr), HL ; come here from entry to TM2 program installed ; for ZCPR3.3 only and save HL JP 0 ; return to TM2 program (patched to proper ; address) END