home *** CD-ROM | disk | FTP | other *** search
- .printx Reading ZFSUBS6.Z80
- ;==========================================================================
- ;
- ; ZFSUBS6.Z80 - Tagged File List Read/Write Routines
- ;
- ;==========================================================================
-
- ; In order to preserve the list of tagged files between ZFILER shell
- ; invocations, the name of each tagged file is written to a temporary
- ; text file, ZFILER.TAG. When ZFILER is re-invoked, it looks for the
- ; tag file and, if possible, soft tags all previously tagged files. The
- ; tag file is then erased.
-
- ; ZFILER.TAG text file lines are 13 character long -- an 11 character file
- ; name and <cr><lf>. EOF is 1Ah.
-
-
- ; READTAGS -
- ; Read temporary file with previously tagged file names, then softag files
- ; which still exist. This routine is called when ZFILER invoked as a shell
- ; by ZCPR3.
- ;
- ; Since these operations are (ideally) transparent to the user,
- ; they quit without comment on i/o errors.
- ;
- readtags:
- ld a,(savtfla) ; Option enabled?
- or a
- ret z ; No
-
- call retud ; Save current DIR
- ld (dirsav),bc
- call gettagdu ; Log in ZFILER.TAG DIR and point to FCB1
- call fi0$open ; Open file for byte input
- jr nz,rdtex ; No file
-
- ld hl,(ring) ; Init to start of ring
- ld (ringpos),hl
- rdtloop:
- call tagget ; Get next name
- jr z,rdtloop1 ; EOF
- call rdtmat ; Match to current file ring
- jr rdtloop ; Keep going to EOF
- rdtloop1:
- call fi0$close ; Close input file
- ld de,fcb ; Delete it
- call f$delete ; Yes
- rdtex:
- ld bc,(dirsav) ; Get back DIR we started in
- call logud
- ret
-
- ;
- ; Get next name
- ;
- tagget:
- ld hl,namebuf ; Buffer to receive name
- ld b,13 ; Get FilenameTyp<CR><LF>
- tagget1:
- call f0$get
- cp 1ah
- ret z
- call caps ; In case file not made by ZFILER
- ld (hl),a
- inc hl
- djnz tagget1
- ret
-
- ;
- ; Match saved tagged file name to ring.
- ; Since ring may have changed, there is no guarantee of a match.
- ; Search starts at last matched position and wraps around.
- ; If match found, softag it.
- ;
- rdtmat:
- ld hl,(ringpos) ; Keep starting position
- ld (sringpos),hl
- ex de,hl ; To DE
- jr rdt2
-
- rdtend:
- ld hl,(ring) ; Wrap search to start of ring
- ld (ringpos),hl
- jr rdt1a
- rdt1:
- call incringpos ; Advance to next element
- rdt1a: ex de,hl ; Ring pointer to DE
- ld hl,(sringpos) ; Are we back to starting position?
- call cmpdehl
- ret z ; If so, quit with no match
-
- rdt2:
- ld hl,(ringend)
- call cmpdehl ; End of ring?
- jr z,rdtend ; Yes, reset to start
- ld hl,namebuf-1 ; Point to current file name from list
- call fmatch ; Do we have a match?
- jr nz,rdt1 ; No, try again
-
- ; We found it
- ld hl,tagoff ; Offset to tag byte
- add hl,de ; DE still has ring position
- ld (hl),stagch ; Soft tag this file
- call incringpos ; Ready for next
- ret
-
- ;--------------------------------------------------------------------------
-
- ; WRITETAGS - Write tagged file names to temporary file
- ; This routine is called on Z command or Macro run.
- ; If tag save option on ..
- ; If any files tagged ..
- ; Make output file
- ; Write each tagged file name to it
- ; Close file
- ;
- writetags:
- ld a,(savtfla) ; Option enabled?
- or a
- ret z ; No
-
- xor a
- ld (wtagflag),a ; Reset output flag
-
- ld hl,(ringpos) ; Save entry ring pos
- ld (sringpos),hl
- ld hl,(ring) ; Init to start of ring
- ld de,-eltsiz ; Back up one
- add hl,de
- ld (ringpos),hl
- call wtagloop ; Put tagged file names
- ld hl,(sringpos) ; Restore entry ring pos
- ld (ringpos),hl
- ld a,(wtagflag) ; Anything written?
- or a
- call nz,fo0$close ; ..close output file
- ret
- ;
- wtagloop:
- call ringinc ; Advance pointer, get possible tag
- ret z ; End of ring
- cp tagch ; Tagged?
- jr nz,wtagloop ; No
- call tagput ; Yes, write name to output
- jr z,wtagloop ; Write OK
- ret ; Write error
-
- ;
- ; Write a tagged file's name to output
- ; RET NZ on write error
- ;
- tagput:
- ld a,(wtagflag) ; Have we opened file?
- or a
- jr nz,tagput1 ; Yes
-
- call gettagdu ; Log in ZFILER.TAG DU
- call fo0$open ; Open for byte output
- ret nz ; No room
- or -1
- ld (wtagflag),a ; Set output open flag
- tagput1:
- ld b,11 ; Put FilenameTyp
- ld hl,(ringpos)
- inc hl ; ->first char of name
- tagput2:
- ld a,(hl)
- and 7fh ; No need to incude attribits
- call f0$put
- ret nz ; Output error
- inc hl
- djnz tagput2
-
- ld a,cr ; Append <CR><LF>
- call f0$put
- ret nz
- ld a,lf
- call f0$put
- ret
-
- ;--------------------------------------------------------------------------
- ; Common Subroutines
- ;
- ; Locate DIR for .TAG file
- ; Here we just use the same DIR as for ZEX batch file
- ; Move tag file name to fcb1 and init
- ; RET DE .FCB1
- ;
- gettagdu:
- ld bc,(batdu) ; Fixed DU for batch file
- ld a,(batrootadr) ; See if using root instead
- or a
- call nz,root ; If using root directory, find it
- call logud
- call resdma ; Make sure DMA at TBUF
- ld hl,tagfile ; Move tag file to an fcb
- ld de,fcb+1
- ld bc,11
- ldir
- ld de,fcb
- call initfcb ; Initialize it
- ret
-
- ;
- dseg
- namebuf ds 13 ; Filename input buffer
- wtagflag ds 1 ; Output open flag
- dirsav ds 2 ; DU on entry
- cseg
- ;
-