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

View File

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

View File

@ -4,6 +4,10 @@
* Code for handling Applecorn paths and converting them to * Code for handling Applecorn paths and converting them to
* ProDOS paths. Runs in main memory. * ProDOS paths. Runs in main memory.
* TO DO: check range in :sd * 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: * Preprocess path in MOSFILE, handles:
* 1) ':sd' type slot and drive prefix (s,d are digits) * 1) ':sd' type slot and drive prefix (s,d are digits)

View File

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

View File

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