Merge PR #122 'LOADFILE updated'

This commit is contained in:
Bobbi Webber-Manners 2021-10-15 13:01:25 -04:00
parent 8e2967e87a
commit e955be07e6
4 changed files with 191 additions and 122 deletions

Binary file not shown.

View File

@ -877,10 +877,10 @@ MKERRLP
LSR A
LSR A
JSR ERRHEX
STA $109
STA $108
PLA
JSR ERRHEX
STA $10A
STA $109
JMP $100
ERRHEX
AND #15
@ -923,16 +923,16 @@ MKERROR4 DW ERROR27
* $27 - I/O error (disk not formatted)
* $28 - No device con'd (drive not present) Disk not present
* $29 - (GEOS Driver is busy)
* $29 -(GSOS Driver is busy)
* $2A -
* $2B - Disk write protected. Disk write protected
* $2C - (GEOS bad byte count)
* $2D - (GEOS bad block number)
* $2C -(GSOS bad byte count)
* $2D -(GSOS bad block number)
* $2E - Disk switched Disk changed
* $2F - Device is offline (drive empty)
* $40 - Invalid pathname syntax. Bad filename
* $41 - Duplicate filename. (split from $47) Directory exists
* $41 -(Duplicate filename. (split from $47) Is a directory)
* $42 - File Control Block table full. Too many open
* $43 - Invalid reference number. Channel not open
* $44 - Path not found. (Dir not found) File not found
@ -945,32 +945,32 @@ MKERROR4 DW ERROR27
* $4B - Unsupported storage_type. Disk not recognised
* $4C - End of file has been encountered. End of file
* $4D - Position out of range. Past end of file
* $4E - Access error. (see also $4F) RD/WR: Insufficient access
* $4F - Access error. (split from $4E) REN/DEL: Locked
* $4E - Access error. (see also $4F) RD/WR: Insufficient access, also Dir not empty
* $4F - (GSOS Buffer too small) (Access error. (split from $4E) REN/DEL: Locked)
* $50 - File already open. Can't - file open
* $51 - Directory count error. Broken directory
* $52 - Not a ProDOS disk. Disk not recognised
* $53 - Invalid parameter. Invalid parameter
* $54 - (Dir not empty when deleting) Dir not empty
* $54 - (GSOS Out of memory) (Dir not empty when deleting) Dir not empty
* $55 - Volume Control Block table full.
* $56 - Bad buffer address.
* $57 - Duplicate volume.
* $58 - Bad volume bitmap.
* $59 - (GEOS File level out of range)
* $59 -(GSOS File level out of range)
* $5A - Bit map disk address is impossible. Sector not found
* $5B - (GEOS Bad ChangePath pathname)
* $5C - (GEOS Not executable file)
* $5D - (EOF during load or save) Data lost
* $5E - (Couldn't open to save) Can't save
* $5F - (GEOS Too many applications)
* $60+ - (GEOS)
* $5B -(GSOS Bad ChangePath pathname)
* $5C -(GSOS Not executable file)
* $5D -(GSOS OS/FS not found) (EOF during load or save) Data lost
* $5E -(Couldn't open to save) Can't save
* $5F -(GSOS Too many applications)
* $60+ - (GSOS)
* AcornOS ProDOS
ERROR40 DW $CC00
ASC 'Bad filename' ; $40 - Invalid pathname syntax
ERROR41 DW $C400
ASC 'Directory exists' ; $41 - Duplicate filename (split from $47)
ASC 'Is a directory' ; $41 - Duplicate filename (split from $47)
ERROR42 DW $C000
ASC 'Too many open' ; $42 - File Control Block table full
ERROR43 DW $DE00
@ -1032,4 +1032,3 @@ ERROR5E DW $C000
ERROR2E DW $C800
ASC 'Disk changed' ; $2E - Disk switched
DB $00

View File

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

View File

@ -15,6 +15,7 @@
* 13-Oct-2021 OSFIND implementes CLOSE#0.
* 13-Oct-2021 FIND, BGET, BPUT optimised passing registers to main.
* 13-Oct-2021 ARGS, EOF returns errors, optimised.
* 15-Oct-2021 LOADFILE updated.
INFOFILE >>> ENTMAIN
@ -49,6 +50,9 @@ DODELETE LDA #<MOSFILE ; Attempt to destroy file
DB DESTCMD
DW DESTPL
RTS
* Returns $4E for 'Dir is not empty'
* Need to separate from 'Dir is locked'
* ProDOS file handling to create a directory
* Invoked by AppleMOS OSFILE
@ -538,82 +542,152 @@ LOADFILE >>> ENTMAIN
JSR PREPATH ; Preprocess pathname
JSR WILDONE ; Handle any wildcards
JSR EXISTS ; See if it exists ...
* BCS :EXIT2
CMP #$01 ; ... and is a file
BEQ :ISFILE
JMP :NOTFND
:ISFILE STZ :BLOCKS
ROL A ; 0->0, 2->5
EOR #$05 ; 0->5, 2->0
ADC #$41 ; 0->$46, 2->$41
JMP :EXIT2 ; Return error
* EXISTS has done GETINFO, so file info already loaded
:ISFILE LDA FBEXEC ; If FBEXEC is zero, use addr
BEQ :CBADDR ; in the control block
LDA GINFOPL+5 ; Otherwise, use file's address
STA FBLOAD+0 ; Aux type LSB
LDA GINFOPL+6 ; Aux type MSB
STA FBLOAD+1
:CBADDR LDA #$60 ; *TO DO* Error=file too long
LDX GINFOPL+9
BNE :EXIT2 ; size>128K, too big to load
LDX GINFOPL+8
BMI :EXIT2 ; size>64K, too big to load
BEQ :EXITOK ; size=0, nothing to load
STX :BLOCKS
LDA #<MOSFILE
STA OPENPL+1
LDA #>MOSFILE
STA OPENPL+2
JSR OPENFILE
BCS :NOTFND ; File not found
BCS :EXIT2 ; File not opened
* LDA FBLOAD+0 ; A4=>start address to load to
* STA A4L
* LDA FBLOAD+1
* STA A4H
:L1 LDA OPENPL+5 ; File ref number
STA READPL+1
JSR RDFILE
BCC :S1
CMP #$4C ; EOF
BEQ :EOF
BRA :READERR
:S1 LDA #<BLKBUF
STA A1L
* BCC :S1
* CMP #$4C ; EOF
* BEQ :EXITOK
* BEQ :EOF
* BRA :READERR
BCS :READERR ; Close file and return error
:S1
* CLC
LDA #<BLKBUF ; LSB of start of data buffer
STA A1L ; A1=>start of data buffer
ADC READPL+6 ; LSB of trans count
STA A2L ; A2=>end of data buffer
LDA #>BLKBUF
STA A1H
CLC
LDA #<BLKBUF
ADC READPL+6 ; LSB of trans count
STA A2L
LDA #>BLKBUF
ADC READPL+7 ; MSB of trans count
STA A2H
LDA FBEXEC ; If FBEXEC is zero, use addr
CMP #$00 ; in the control block
BEQ :CBADDR
LDA #<MOSFILE ; Otherwise use file addr
STA GINFOPL+1
LDA #>MOSFILE
STA GINFOPL+2
JSR GETINFO ; GET_FILE_INFO
BCS :READERR
LDA GINFOPL+5 ; Aux type LSB
STA FBLOAD+0
LDA GINFOPL+6 ; Aux type MSB
STA FBLOAD+1
:CBADDR LDA FBLOAD
LDA FBLOAD+0 ; A4=>address to load to
STA A4L
STA FBEXEC ; EXEC = LOAD
LDA FBLOAD+1
STA A4H
STA FBEXEC+1
LDX :BLOCKS
:L2 CPX #$00
BEQ :S2
INC
INC
DEX
BRA :L2
:S2 STA A4H
INC FBLOAD+1 ; Step to next block
INC FBLOAD+1
* CLC
* LDA A1L ; A2=>end of data buffer
* ADC READPL+6 ; LSB of trans count
* STA A2L
* LDA A1H
* ADC READPL+7 ; MSB of trans count
* STA A2H
* LDA FBEXEC ; If FBEXEC is zero, use addr
* CMP #$00 ; in the control block
* BEQ :CBADDR
* LDA #<MOSFILE ; Otherwise use file addr
* STA GINFOPL+1
* LDA #>MOSFILE
* STA GINFOPL+2
* JSR GETINFO ; GET_FILE_INFO
* BCS :READERR
* LDA GINFOPL+5 ; Aux type LSB
* STA FBLOAD+0
* LDA GINFOPL+6 ; Aux type MSB
* STA FBLOAD+1
*:CBADDR LDA FBLOAD
* STA A4L
* STA FBEXEC ; EXEC = LOAD
* LDA FBLOAD+1
* STA A4H
* STA FBEXEC+1
* LDX :BLOCKS
*:L2 CPX #$00
* BEQ :S2
* INC
* INC
* DEX
* BRA :L2
*:S2 STA A4H
SEC ; Main -> AUX
JSR AUXMOVE
INC :BLOCKS
BRA :L1
:NOTFND LDA #$46 ; Nothing found
PHA
BRA :EXIT
:READERR LDA #$5D ; Read error
PHA
BRA :EOF2
:EOF LDA #$01 ; Success ('File')
PHA
:EOF2 LDA OPENPL+5 ; File ref num
JSR AUXMOVE ; A4 updated to next address
DEC :BLOCKS
BNE :L1
BEQ :EXITOK
* INC :BLOCKS
* BRA :L1
:READERR CMP #$4C
BNE :EXITERR
:EXITOK LDA #$01 ; Success ('File')
:EXITERR PHA
LDA OPENPL+5 ; File ref num
STA CLSPL+1
JSR CLSFILE
:EXIT JSR UPDFB ; Update FILEBLK
PLA
CMP #$01
BNE :EXIT2
PHA
JSR UPDFB ; Update FILEBLK
JSR COPYFB ; Copy FILEBLK to auxmem
PLA ; Get return code back
>>> XF2AUX,OSFILERET
:EXIT2 >>> XF2AUX,OSFILERET
:BLOCKS DB $00
*:NOTFILE ROL A ; 0->0, 2->5
* EOR #$05 ; 0->5, 2->0
* ADC #$41 ; 0->$46, 2->$41
*:NOTFND PHA
* BRA :EXIT
*:READERR LDA #$5D ; Read error
* PHA
* BRA :EOF2
*:EXITOK
*:EOF LDA #$01 ; Success ('File')
* PHA
*:EOF2 LDA OPENPL+5 ; File ref num
* STA CLSPL+1
* JSR CLSFILE
*:EXIT JSR UPDFB ; Update FILEBLK
* JSR COPYFB ; Copy FILEBLK to auxmem
* PLA ; Get return code back
*:EXIT2 >>> XF2AUX,OSFILERET
*:BLOCKS DB $00
* ProDOS file handling for MOS OSFILE SAVE call
* Invoked by AppleMOS OSFILE
* Return A=01 if successful (ie: 'file')
@ -1115,7 +1189,3 @@ MAINRDEXIT >>> XF2AUX,NULLRTS ; Back to an RTS