Merge PR 144 'Updated Access Cat/Info Destroy'

This commit is contained in:
Bobbi Webber-Manners 2021-11-04 18:59:04 -04:00
parent 9347de8059
commit 087c9fc4e1
6 changed files with 157 additions and 135 deletions

Binary file not shown.

View File

@ -21,7 +21,7 @@
* 01-Oct-2021 DRIVE, CHDIR shares same code, checking moved to maincode.
* 02-Oct-2021 ACCESS uses generic access byte parsing.
* PRACCESS shares code with ACCESS.
* *BUG* PARSNAME should check len<64.
* 03-Oct-2021 PARSNAME checks filename length<64.
* $B0-$BF Temporary filing system workspace
@ -29,14 +29,14 @@
FSXREG EQU $C0
FSYREG EQU $C1
FSAREG EQU $C2
FSZPC3 EQU $C3
FSCTRL EQU FSXREG
FSPTR1 EQU $C4
FSPTR2 EQU $C6
FSNUM EQU $C8
FSACCBYTE EQU FSNUM+1
FSZPCC EQU $CC
FSCMDLINE EQU $CE
FSZPC3 EQU $C3 ; (unused so far)
FSCTRL EQU FSXREG ; =>control block
FSPTR1 EQU $C4 ; =>directory entry
FSPTR2 EQU $C6 ; (unused so far)
FSNUM EQU $C8 ; 32-bit number, cat file count
FSACCBYTE EQU FSNUM+1 ; access bits
FSZPCC EQU $CC ; (unused so far)
FSCMDLINE EQU $CE ; command line address
* OSFIND - open/close a file for byte access
@ -319,11 +319,16 @@ FSCHND CMP #13
FSCNULL LDA FSAREG
LDY FSYREG
LDX FSXREG ; Set EQ/NE from X
RTS
FSCUKN
FSCRET RTS
* OSFSC 00 - *OPT function
* Entered with A=$00 and EQ/NE from X
FSCOPT BEQ :OPT0
CPX #$05
BCS :OPTNULL
CPY #$04
BCS :OPTNULL
LDA FSFLAG2
AND :OPTMSK-1,X
EOR :OPTSET-0,Y
@ -334,19 +339,19 @@ FSCOPT BEQ :OPT0
:OPTMSK DB $3F,$CF,$F3,$FC
:OPTSET DB $00,$55,$AA,$FF
FSCUKN
DO DEBUG
PHA
LDA #<OSFSCM
LDY #>OSFSCM
JSR PRSTR
PLA
FIN
FSCRET RTS
DO DEBUG
OSFSCM ASC 'OSFSC.'
DB $00
FIN
*FSCUKN
* DO DEBUG
* PHA
* LDA #<OSFSCM
* LDY #>OSFSCM
* JSR PRSTR
* PLA
* FIN
* RTS
* DO DEBUG
*OSFSCM ASC 'OSFSC.'
* DB $00
* FIN
* OSFSC 01 - Read EOF function
@ -447,8 +452,8 @@ PRONEBLK >>> ENTAUX
LDY #>:DIRM
JSR PRSTR
SEC
:NOTKEY JSR PRONEENT ; CC=entry, CS=header
CLC ; Step to next entry
:NOTKEY JSR PRONEENT ; CC=entry, CS=header
CLC ; Step to next entry
LDA FSPTR1+0
ADC #$27
STA FSPTR1+0
@ -456,7 +461,7 @@ PRONEBLK >>> ENTAUX
ADC #$00
STA FSPTR1+1
DEC FSNUM
BNE :CATLP ; Loop for all entries
BNE :CATLP ; Loop for all entries
>>> XF2MAIN,CATALOGRET
:DIRM ASC 'Directory: '
DB $00
@ -817,7 +822,10 @@ PARSLPTR CLC ; Means parsing a filename
STA MOSFILE+1,X
STA $C005 ; Write to aux mem
INX
BNE :L1
CPX #$40
BNE :L1 ; Name not too long
TXA ; $40=Bad filename
JMP MKERROR
:DONE STA $C004 ; Write to main mem
STX MOSFILE ; Length byte (Pascal)
STA $C005 ; Back to aux
@ -840,7 +848,10 @@ PARSLPTR2 CLC ; Means parsing a filename
STA MOSFILE2+1,X
STA $C005 ; Write to aux mem
INX
BNE :L1
CPX #$40
BNE :L1 ; Name not too long
TXA ; $40=Bad filename
JMP MKERROR
:DONE STA $C004 ; Write to main mem
STX MOSFILE2 ; Length byte (Pascal)
STA $C005 ; Back to aux
@ -857,7 +868,7 @@ ERRNOTFND LDA #$46 ; File not found
CHKERROR CMP #$20
BCC NOTERROR
MKERROR
* IF FALSE
DO DEBUG
BIT $E0
BPL MKERROR1 ; *DEBUG*
PHA
@ -888,7 +899,7 @@ ERRMSG BRK
DB $FF
ASC 'ERR: $00'
BRK
* FIN
FIN
* Translate ProDOS error code into BBC error
MKERROR1 CMP #$40

View File

@ -204,7 +204,7 @@ BYTE00 BEQ BYTE00A ; OSBYTE 0,0 - generate error
RTS ; %000x1xxx host type, 'A'pple
BYTE00A BRK
DB $F7
HELLO ASC 'Applecorn MOS 2021-11-03'
HELLO ASC 'Applecorn MOS 2021-11-04'
DB $00 ; Unify MOS messages

View File

@ -4,6 +4,10 @@
* Code for handling Applecorn paths and converting them to
* ProDOS paths. Runs in main memory.
* TO DO: check range in :sd
* TO DO: need separate reference to current root and drive by name
* TO DO: check for pathname too long
* ie /filename should be filename in root
* Preprocess path in MOSFILE, handles:
* 1) ':sd' type slot and drive prefix (s,d are digits)

View File

@ -20,6 +20,9 @@
* DELETE returns 'Dir not empty' when appropriate.
* 29-Oct-2021 DRVINFO reads current drive if "".
* 01-Nov-2021 DRVINFO checks reading info on a root directory.
* 02-Nov-2021 SETPERMS passed parsed access byte.
* 03-Nov-2021 Optimised CAT/EX/INFO, DESTROY.
* *BUG* RENAME won't rename between directories, eg RENAME CHARS VDU/CHARS.
* ProDOS file handling to rename a file
@ -868,77 +871,74 @@ CATALOG >>> ENTMAIN
JSR PREPATH ; Preprocess pathname
JSR WILDONE ; Handle any wildcards
JSR EXISTS ; See if path exists ...
CMP #$01 ; ... and is a file
BNE :NOTFILE
LDA #$46 ; Not found (TO DO: err code?)
BRA CATEXIT
:NOTFILE LDA #<MOSFILE
STA OPENPL+1
LDA #>MOSFILE
STA OPENPL+2
BRA :OPEN
BEQ :NOTFND ; Not found
CMP #$02
BEQ :DIRFOUND
LDA #$0D ; Becomes Not a directory
:NOTFND EOR #$46 ; $00->$46, $xx->$4B
BNE CATEXIT
:NOPATH JSR GETPREF ; Fetch prefix into PREFIX
LDA #<PREFIX
STA OPENPL+1
LDA #>PREFIX
STA OPENPL+2
:OPEN JSR OPENFILE
LDX #<PREFIX ; XY=>prefix
LDY #>PREFIX
BRA :OPEN
:DIRFOUND LDX #<MOSFILE ; XY=>specified directory
LDY #>MOSFILE
:OPEN STX OPENPL+1 ; Open the specified directory
STY OPENPL+2
JSR OPENFILE
BCS CATEXIT ; Can't open dir
CATREENTRY
LDA OPENPL+5 ; File ref num
CATREENTRY LDA OPENPL+5 ; File ref num
STA READPL+1
JSR RDFILE
BCC :S1
CMP #$4C ; EOF
BEQ :EOF
BRA :READERR
:S1 JSR COPYAUXBLK
BCS :CATERR
JSR COPYAUXBLK
>>> XF2AUX,PRONEBLK
:READERR
:EOF LDA OPENPL+5 ; File ref num
:CATERR CMP #$4C ; EOF
BNE :NOTEOF
LDA #$00
:NOTEOF PHA
LDA OPENPL+5 ; File ref num
STA CLSPL+1
JSR CLSFILE
PLA
CATEXIT >>> XF2AUX,STARCATRET
* PRONEBLK call returns here ...
CATALOGRET
>>> ENTMAIN
LDA CATARG
CMP #$80 ; Is this an *INFO call?
BEQ INFOREENTRY
BRA CATREENTRY
CATARG DB $00
* Handle *INFO
INFO JSR PREPATH ; Preprocess pathname
SEC
JSR WILDCARD ; Handle any wildcards
JSR EXISTS ; Check matches something
CMP #$00
BNE INFOFIRST
JSR CLSDIR
LDA #$46 ; Not found (TO DO: err code?)
BNE INFOFIRST ; Match found, start listing
LDA #$46 ; No match, error Not found
INFOEXIT CMP #$4C ; EOF
BNE INFOCLS
LDA #$00 ; EOF is not an error
INFOCLS PHA
JSR CLSDIR ; Be sure to close it!
PLA
BRA CATEXIT
INFOREENTRY
JSR WILDNEXT2 ; Start of new block
* PRONEBLK call returns here ...
CATALOGRET >>> ENTMAIN
LDA CATARG
CMP #$80 ; Is this an *INFO call?
BNE CATREENTRY ; No, go back and do another CAT/EX
INFOREENTRY JSR WILDNEXT2 ; Start of new block
BCS INFOEXIT ; No more matches
INFOFIRST LDA WILDIDX
CMP #$FF ; Is WILDNEXT about to read new blk?
BEQ :DONEBLK ; If so, print this blk first
JSR WILDNEXT2
BCS :DONEBLK ; If no more matches
BRA INFOFIRST
BCC INFOFIRST ; Find more entries
:DONEBLK JSR COPYAUXBLK
>>> XF2AUX,PRONEBLK
INFOEXIT CMP #$4C ; EOF
BNE INFOCLS
LDA #$00 ; EOF is not an error
INFOCLS JSR CLSDIR ; Be sure to close it!
BRA CATEXIT
CATARG DB $00
* Set prefix. Used by *CHDIR/*DRIVE to change directory
@ -1004,34 +1004,38 @@ DRVINFO >>> ENTMAIN
* Change file permissions, for *ACCESS
* Filename in MOSFILE, flags in MOSFILE2
* Filename in MOSFILE, access mask in A
*
SETPERM >>> ENTMAIN
PHA ; Save access mask
JSR PREPATH ; Preprocess pathname
BCS :SYNERR
CLC
JSR WILDCARD ; Handle any wildcards
BCS :NONE
STZ :LFLAG
STZ :WFLAG
STZ :RFLAG
LDX MOSFILE2 ; Length of arg2
INX
:L1 DEX
CPX #$00
BEQ :MAINLOOP
LDA MOSFILE2,X ; Read arg2 char
CMP #'L' ; L=Locked
BNE :S1
STA :LFLAG
BRA :L1
:S1 CMP #'R' ; R=Readable
BNE :S2
STA :RFLAG
BRA :L1
:S2 CMP #'W' ; W=Writable
BNE :ERR2 ; Bad attribute
STA :WFLAG
BRA :L1
BCC :MAINLOOP
* STZ :LFLAG
* STZ :WFLAG
* STZ :RFLAG
* LDX MOSFILE2 ; Length of arg2
* INX
*:L1 DEX
* CPX #$00
* BEQ :MAINLOOP
* LDA MOSFILE2,X ; Read arg2 char
* CMP #'L' ; L=Locked
* BNE :S1
* STA :LFLAG
* BRA :L1
*:S1 CMP #'R' ; R=Readable
* BNE :S2
* STA :RFLAG
* BRA :L1
*:S2 CMP #'W' ; W=Writable
* BNE :ERR2 ; Bad attribute
* STA :WFLAG
* BRA :L1
:SYNERR LDA #$40 ; Invalid pathname syn
BRA :EXIT
:NONE JSR CLSDIR
@ -1043,60 +1047,61 @@ SETPERM >>> ENTMAIN
STA GINFOPL+2
JSR GETINFO ; GET_FILE_INFO
BCS :EXIT
LDA GINFOPL+3 ; Access byte
AND #$03 ; Start with R, W off
ORA #$C0 ; Start with dest/ren on
LDX :RFLAG
BEQ :S3
ORA #$01 ; Turn on read enable
:S3 LDX :WFLAG
BEQ :S4
ORA #$02 ; Turn on write enable
:S4 LDX :LFLAG
BEQ :S5
AND #$3D ; Turn off destroy/ren/write
PLA ; Access byte
PHA
* LDA GINFOPL+3 ; Access byte
* AND #$03 ; Start with R, W off
* ORA #$C0 ; Start with dest/ren on
* LDX :RFLAG
* BEQ :S3
* ORA #$01 ; Turn on read enable
*:S3 LDX :WFLAG
* BEQ :S4
* ORA #$02 ; Turn on write enable
*:S4 LDX :LFLAG
* BEQ :S5
* AND #$3D ; Turn off destroy/ren/write
:S5 STA GINFOPL+3 ; Access byte
JSR SETINFO ; SET_FILE_INFO
JSR WILDNEXT
BCS :NOMORE
BRA :MAINLOOP
:EXIT >>> XF2AUX,ACCRET
BCC :MAINLOOP
* BCS :NOMORE
:NOMORE JSR CLSDIR
LDA #$00
BRA :EXIT
* BRA :EXIT
:EXIT PLX ; Drop access byte
>>> XF2AUX,ACCRET
:ERR2 LDA #$53 ; Invalid parameter
BRA :EXIT
:LFLAG DB $00 ; 'L' attribute
:WFLAG DB $00 ; 'W' attribute
:RFLAG DB $00 ; 'R' attribute
*:LFLAG DB $00 ; 'L' attribute
*:WFLAG DB $00 ; 'W' attribute
*:RFLAG DB $00 ; 'R' attribute
* Multi file delete, for *DESTROY
* Filename in MOSFILE
*
MULTIDEL >>> ENTMAIN
JSR PREPATH ; Preprocess pathname
BCS :SYNERR
CLC
BCS :EXIT
* CLC ; CC already set
JSR WILDCARD ; Handle any wildcards
BCS :NONE
BRA :MAINLOOP
:SYNERR LDA #$40 ; Invalid pathname syn
BRA :EXIT
:NONE JSR CLSDIR
BCC :MAINLOOP
LDA #$46 ; 'File not found'
BRA :EXIT
BRA :DELERR
:MAINLOOP JSR DODELETE
BCS :DELERR
JSR WILDNEXT
BCS :NOMORE
BRA :MAINLOOP
:EXIT >>> XF2AUX,DESTRET
BCC :MAINLOOP ; More to do
LDA #$00 ; $00=Done
:DELERR PHA
JSR CLSDIR
PLA
BRA :EXIT
:NOMORE JSR CLSDIR
LDA #$00
BRA :EXIT
:EXIT >>> XF2AUX,DESTRET
* Read machid from auxmem
MACHRD LDA $C081

View File

@ -237,14 +237,16 @@ SRCHBLK LDA WILDIDX
RTS
* Close directory, if it was open
* Preserves flags
* Preserves A and flags
CLSDIR PHP
PHA
LDA WILDFILE ; File ref num for open dir
BEQ :ALREADY ; Already been closed
STA CLSPL+1
JSR CLSFILE
STZ WILDFILE ; Not strictly necessary
:ALREADY PLP
:ALREADY PLA
PLP
RTS
* Apply wildcard match to a directory block