Files
RomWBW/Source/BPBIOS/Z34RCP11/rcpprot.lib
2020-02-14 17:22:56 -08:00

130 lines
2.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
page
; Library: RCPPROT for Z34RCP
; Author: Carson Wilson
; Version: 1.1
; Date: August 12, 1989
; Changes: Now responds dynamically to QUIET flag, eliminating "noise."
; Author: Carson Wilson
; Version: 1.0
; Date: June 15, 1988
;
; Command: PROT
; Function: To set the attributes of a file (R/O, SYS, and ARC)
; Form: PROT afn RSAI
; Comments: If R, S, or A are omitted, the file is made R/W, DIR, or
; modified, respectively. R, S, A, and I may be in any order.
; If I is present, Inspection is enabled.
att:
call retsave
call dirchek ; Test bad directory
xor a ; Set no inspect
ld (inspect),a
ld hl,0 ; Set r/o and sys attributes off
ld c,0 ; Set Arc attribute off
ld de,fcb2+1 ; Pt to attributes
ld b,4 ; 4 chars max
att1:
ld a,(de) ; Get char
inc de ; Pt to next
cp 'I' ; Inspect?
jr z,atti
cp 'R' ; Set r/o?
jr z,attr
cp 'S' ; Set sys?
jr z,atts
cp 'A'
jr z,atta
att2:
djnz att1
jr att3
atti:
ld (inspect),a ; Set flag
jr att2
attr:
ld h,a ; Save R/O flag
jr att2
atts:
ld l,a ; Save SYS flag
jr att2
atta:
ld c,a ; Save ARC
jr att2
att3:
ld (fatt2),hl ; Save file attributes
ld a,c
ld (fatt1),a ; Save Arc attribute
ld a,1 ; Select dir and sys files
call getdir ; Load directory
jp z,noflerr ; Tell error handler no file
jr att5
att4:
ld hl,(nxtfile) ; Pt to next file
ld a,(hl) ; End of list?
or a
jp z,exit
call crlf ; New line
att5: call break ; Check for possible abort
call qplug ; Turn off output if quiet
push hl ; Save ptr to current file
call prfn ; Print its name
ld (nxtfile),hl ; Save ptr to next file
call print
db ' Set to R','/'+80h
ld hl,(fatt2) ; Get attributes
ld c,'W' ; Assume r/w
ld a,h ; Get r/o bit
or a
jr z,att6
ld c,'O' ; Set r/o
att6: ld a,c ; Get char
call conout
ld a,l ; Get sys flag
or a ; Set flag
jr z,att7
call print
db ', SY','S'+80h
att7: ld a,(fatt1)
or a
jr z,att7a
call print
db ', AR','C'+80h
att7a: call unplug ; Turn output on
inspect equ $+1 ; Ptr for in-the-code modification
ld a,0 ; Get inspect flag
or a ; Z=no
pop hl ; Get ptr to current file
jr z,att8
call eraq1 ; Ask for y/n
jr nz,att4 ; Advance to next file if not y
att8: ld de,fcb1+1 ; Copy into fcb1
ld b,11 ; 11 bytes
call blkmov
ex de,hl
dec hl ; Pt to archive byte
fatt1 equ $+1
ld a,0
call attset
dec hl ; Pt to sys byte
fatt2 equ $+1 ; Ptr for in-the-code modification
ld de,0 ; Get attributes
ld a,e ; Get sys flag
call attset ; Set attribute correctly
dec hl ; Pt to r/o byte
ld a,d ; Get r/o flag
call attset
ld de,fcb1 ; Pt to fcb
ld c,30 ; Set attributes
call bdos
jp att4
attset:
res 7,(hl) ; Clear attribute
or a
ret z ; 0=clear attribute
set 7,(hl) ; Set attribute
ret
; End RCPPROT.LIB