; Program: AFIND -- Alias Finder ; Author: Paul Pomerleau ; Version: 1.4 ; Date: April 13, 1991 ; Previous Versions: 1.1 (Jan 15, 1986) ; Copyright 1986, Paul Pomerleau ; Version 1.4 Bruce Morgen April 13, 1991 ; ; Fixed to properly display high user area numbers for Z33+. ; Global initialization of data space and a few tweaks keep ; AFIND under 1K. ; Version 1.3 Paul Pomerleau Jan 21, 1987 (Parts by Rick Conn) ; ; Took all Jay's suggestions -- 128 bytes more read for command line, ; silly coding mistakes on my part, etc. ; Made source self-complete by STEALING Rick Conn's code thus eliminating ; CODEND and saving many bytes. ; Source now under one kilobyte. ; Version 1.2 Jay Sage January 20, 1987 ; ; Enhanced code so that it would tolerate some variation in the position of ; the 'Z3 ALIAS' ID string (VALIAS puts it in a slightly different place). ; Added initialization code so that program will work with GO command. Fixed ; a bug in file display routine for user numbers above 9. Added some comments ; to give the part of the code I worked on some degree of readability! I left ; all symbols public (two colons) for ease in debugging. VERS equ 14 BDOS equ 5 org 100h jp START TARGET: db 'Z3ENV',1 Z3ENV: dw 00 START: ld hl,ZEROS ; Complete data space init. to zero ld d,h ld e,l inc de ld bc,ZEROED ld (hl),b ldir ; ld hl,0 ; Initialize memory so program will ; ld (COL),hl ; ..work with GO command [jps] ld (STOPLOC),sp call FINDZ3 call DMA call PRINT HEADER: db 'Z3 Alias Finder v ',vers / 10 + '0','.',vers mod 10 + '0' db 13,10,0 ld a,(5dh) cp '/' ld de,HELP ld c,9 jp z,BDOS cp ' ' jr z,NOTEMPTY ld hl,5dh ld de,MASK call MOV8 NOTEMPTY: ld hl,CODEND+256+128 ld (NEXT),hl ld a,(5ch) ; Put specified drive into FCB ld (FCB),a ld a,(6dh) ; See if 'all users' specified cp '?' jr nz,ONEUSER ; Loop through all user numbers up to maxuser call GETMUSER ld b,a inc b LOOP: push bc dec b call FIND pop bc djnz LOOP ; Entry point for termination of program STOP: ld sp,(STOPLOC) ret ; Entry point for error condition (too many files ; for available file name buffer) DIE: call PRINT db 'Too many files.',0 jr STOP ; Entry point for processing a single user number ONEUSER: ld a,(5ch + 13) ; Get the user number from FCB ld b,a ; Keep it in B call FIND jr STOP ; Main routine for identifying aliases and displaying ; their contents FIND: ld e,b ; Log in the specified user area call BDO db 32 ; Get/set user BDOS function ld hl,MASK call FCBMOV8 ld de,FCB call BDO db 17 ; Search-first BDOS function inc a ret z ; If no files, quit jr FIND2 ; Loop for search for additional matching file names FINDL: ld de,FCB call BDO db 18 ; Search-next BDOS function inc a jr z,PROCESS ; If no more found, start processing FIND2: ; Get file name and add to list dec a add a,a add a,a add a,a add a,a add a,a ld hl,CODEND + 1 ld e,a ld d,0 add hl,de xor a push hl ld de,15+3 add hl,de or (hl) jr nz,PFINDL inc hl or (hl) jr nz,PFINDL ld de,(NEXT) ld hl,(5) ld a,h sub 8 jr c,OKFINE ld h,a sbc hl,de jr c,DIE OKFINE: pop hl call MOV8 ld (NEXT),de jr FINDL PFINDL: pop hl jr FINDL ; Process the list of file names PROCESS: ld hl,(NEXT) ; Mark end of list with null ld (hl),0 ld hl,CODEND + 256 + 128 ; Start over at beginning of list ld (NEXT),hl ; Processing loop CLOOP: ld a,(hl) or a ret z ; If end of list, quit call FCBMOV8 inc de inc de inc de push hl ld h,d ld l,e inc de ld (hl),0 ld bc,22 ldir call FCBDO db 15 ; Open-file BDOS function inc a jp z,CONTINUE ; Jump if open failed call FCBDO db 20 ; Read-sequential BDOS function or a jp nz,CONTINUE ; Jump if read failed ; Check to see if this file is an alias ; Code modified by Jay Sage to allow for different offsets to ID in aliases ; produced by VALIAS and other alias programs (VALIAS has additional user ; configuration bytes and flags). This code scans a few extra characters ; looking for the 'Z' in the 'Z3 ALIAS' ID string. The extra offset is 2 ; in the present version of VALIAS, but it could vary in the future. ld de,TTARGET ld hl,CODEND + 14h ; Point to block read in from file ; Nominal offset to 'Z3 ALIAS' ID ld bc,0a00h ; Same as below, only a byte shorter ; ld c,0 ; Keep track of additional offset ; ld b,10 ; Maximum additional offset to search ld a,(de) ; Search for first character in ID CHKL0: cp (hl) ; See if we have possible start of ID jr z,CHKL1 inc c ; Increment offset inc hl ; Increment pointer to file djnz CHKL0 ; Back for more tries CHKL1: ld b,0 ; Make word value for additional offset ld (offset),bc ; Save additional offset ld b,TLENGTH CHKL: ld a,(de) inc de cp (hl) inc hl jr nz,CONTINUE ; Jump if not an alias djnz CHKL call DMA2 ; Read in second record from file call FCBDO ; ..so we have 256 bytes in all db 20 ; ..should read in more [jps] call DMA3 ; And so it shall, Jay. [plp] call FCBDO db 20 call DMA ; Display the name of the alias file xor a ; Null to mark end of name ld (FCB + 12),a call CRLF ld a,(FCB) ; Get drive from FBC or a jr nz,NOTLOG ; Branch if given explicitly call BDO ; ..else get default drive db 25 ; Get-default-drive BDOS function inc a ; Offset so A = 1 NOTLOG: ; dec a ; Why not just ADD 'A'-1 [jps] ; add 'A' add a,'A'-1 ; Quite right, Jay. [plp] call COUT ld e,0ffh ; Retrieve user number (we logged it) call BDO db 32 ; Get/set-user BDOS function push af ; Save user to see if >9 later call PRINTDEC ld a,':' call COUT ;NOPAD: ; Misplaced label [jps] ld hl,FCB + 1 ; Print file name ld b,8 FIRST8: ld a,(hl) call COUT inc hl djnz FIRST8 pop af ; If user <10, pad with extra space cp 10 jr nc,NOPAD ld a,' ' call COUT nopad: ; Moved label to here [jps] call PRINT db ' --> ',0 ld de,CODEND + 1ch ; Point to beginning of alias script ; With nominal offset ld hl,(offset) ; Add additional offset [jps] add hl,de CLPLOOP: ld a,(hl) cp ';' jr nz,PCHAR call CRLF ld b,17 PADLOOP: ld a,' ' call COUT djnz PADLOOP PCHAR: call nz,COUT inc hl ld a,(hl) or a jr nz,CLPLOOP CONTINUE: pop hl jp CLOOP PRINT: pop hl call PRINTHL push hl ret CRLF: push hl call PRINT db 13,10,0 pop hl ret PRINTHL: ld a,(hl) call COUT call GETKEY cp 3 jp z,STOP cp 'S'-'@' call z,HOLD inc hl ld a,(hl) or a jr nz,PRINTHL ret HOLD: call GETKEY cp 3 jp z,STOP or a jr z,HOLD ret COUT: cp ' ' jr c,CTRL push af ld a,(col) inc a ld (col),a pop af CCCOUT: push af push bc push de push hl ld hl,(1) ld de,9 add hl,de ld c,a call jphl call getcrt ex de,hl ld hl,(COL) ld a,(de) dec a dec a dec a cp l jr nc,NOTOPC call CRLF ld hl,(COL) NOTOPC: inc de inc de ld a,(de) dec a dec a cp h jr nc,NOMORE push hl xor a ld h,a ld (COL),hl call PRINT db '[More]',0 call HOLD cp ' ' pop hl jr nz,NOTSPA dec h ld (COL),hl NOTSPA: call PRINT db 13,' ',13,0 NOMORE: pop hl pop de pop bc pop af ret JPHL: jp (hl) CTRL: cp 13 jr z,CTRLM cp 10 jr z,CTRLJ push af ld a,'^' call COUT pop af push af add a,'@' call COUT pop af ret CTRLM: xor a ld (COL),a ld a,13 jr CCCOUT CTRLJ: push hl ld hl,LINE inc (hl) pop hl jr CCCOUT GETKEY: push hl push de push bc ld e,0ffh call BDO db 6 pop bc pop de pop hl ret FCBDO: ld de,FCB BDO: pop hl ld c,(hl) inc hl push hl jp BDOS ; Routine replaced by Bruce Morgen to allow display of user ; numbers >19. PRINTDEC: cp 10 jr nc,DIGIT2 DIGIT1: add a,'0' jp COUT DIGIT2: ld b,'0'-1 DIGITL: inc b sub 10 jr nc,DIGITL add a,10 ld c,a ld a,b call COUT ld a,c jr DIGIT1 DMA3: ld de,CODEND + 256 jr SETSUB DMA2: ld de,CODEND + 128 jr SETSUB DMA: ld de,CODEND SETSUB: ld c,26 jp BDOS FCBMOV8: ld de,FCB+1 MOV8: ld bc,8 ldir ret GETMUSER: push hl push de ld hl,(Z3ENV) ld de,2dh add hl,de ld a,(hl) pop de pop hl ret GETCRT: push bc push af ld hl,(Z3ENV) ld de,2fh add hl,de ld b,(hl) inc hl inc hl ld a,d add a,b add a,b ld e,a ld d,e add hl,de pop af pop bc ret FINDZ3: ld hl,(1) FLOOP: ld de,103h FLOOP1: inc hl ld a,h or l jr z,NOENV ld a,(de) cp (hl) jr nz,FLOOP1 ld b,4 push hl FLOOP2: inc hl inc de ld a,(de) cp (hl) jr nz,NOMATCH djnz FLOOP2 pop de push de dec de dec de dec de ld hl,1bh add hl,de ld c,(hl) inc hl ld b,(hl) ld a,d cp b jr nz,NOMATCH ld a,e cp c jr nz,NOMATCH pop hl ld (Z3ENV),de ret NOMATCH: pop hl jr FLOOP NOENV: pop hl ld c,9 ld de,INVENV jp 5 INVENV: db 10,'Can''t Find Z3ENV.$' HELP: db 10,9,'Shows all ZCPR3 aliases on a specified DU or on entire disk',13,10,10 db 'Syntax:',13,10 db 9,'AFIND [DU: or NDR:][AFN]',13,10 db 'or',13,10 db 9,'AFIND D:[AFN] *',9,'<-- For whole disk.$' TTARGET: db 'Z3 ALIAS' TLENGTH equ $ - TTARGET MASK: db '????????' FCB: db 0,'????????COM' ZEROS: ds 24 COL: ds 1 LINE: ds 1 NEXT: ds 2 OFFSET: ds 2 ; [jps] STOPLOC: ds 2 CODEND: ZEROED EQU STOPLOC-ZEROS end