diff --git a/applecorn.po b/applecorn.po index 90e981b..d71641c 100644 Binary files a/applecorn.po and b/applecorn.po differ diff --git a/auxmem.hostfs.s b/auxmem.hostfs.s index 35e9afb..ae7ac4e 100644 --- a/auxmem.hostfs.s +++ b/auxmem.hostfs.s @@ -267,30 +267,28 @@ OSFILERET CPY #18 ; 18 bytes in control block BNE :L3 PLA -* BMI :L4 -* JMP :EXIT ; ret<$80, return it to user + + BMI :L4 + PLY ; Discard val of A on entry + JMP :EXIT ; ret<$80, return it to user :L4 PLY ; Value of A on OSFILE entry CPY #$FF ; See if command was LOAD - BNE :NOTLOAD ; Deal with return from SAVE + BNE :NOTLOAD - CMP #$01 ; No file found + CMP #$80 ; No file found BNE :SL1 BRA ERRNOTFND -:SL1 CMP #$02 ; Read error - BNE :SL2 - BRK +:SL1 BRK ; Must be A=$81 DB $CA ; $CA = Premature end, 'Data lost' ASC 'Read error' BRK -:SL2 LDA #$01 ; Return code - file found - BRA :EXIT - :NOTLOAD CPY #$00 ; See if command was SAVE BNE :NOTLS ; Not LOAD or SAVE - CMP #$01 ; Unable to create or open + + CMP #$80 ; Unable to create or open BNE :SS1 BRK DB $C0 ; $C0 = Can't create file to save @@ -299,16 +297,15 @@ OSFILERET ASC 't save file' BRK -:SS1 CMP #$02 ; Unable to write - BNE :SS2 - BRK +:SS1 BRK ; Must be A=$81 DB $CA ; $CA = Premature end, 'Data lost' ASC 'Write error' BRK -:SS2 LDA #$01 ; Return code - file found +:NOTLS CPY #$06 ; See if command was DELETE + BNE :NOTLSD -:NOTLS CMP #$00 ; File was not found + CMP #$80 ; File was not found BNE :SD1 JMP :EXIT * BRK @@ -316,9 +313,7 @@ OSFILERET * ASC 'Not found' * BRK -:SD1 CMP #$FF ; Some other error - BNE :EXIT ; A=0 or 1 already - BRK +:SD1 BRK ; Must be A=$81 DB $D6 ; TODO: Better error code? ASC 'Can' DB $27 @@ -327,10 +322,25 @@ OSFILERET :NOTLSD CPY #$08 ; Was it CDIR? BNE :EXIT - CMP #$00 ; A=0 means dir was created - BNE ERREXISTS -:SC1 LDA #$02 ; A=2 - dir exists or was created + CMP #$80 ; A=80 dir already exists + BEQ :EXISTS + CMP #$81 ; A=81 bad name + BNE :SC1 + + BRK + DB $CC + ASC 'Bad name' + BRK + +:SC1 BRK + DB $C0 + ASC 'Can' + DB 27 + ASC 't create dir' + BRK + +:EXISTS LDA #$02 ; A=2 - dir exists or was created :EXIT PLY PLX diff --git a/mainmem.s b/mainmem.s index 7c2a619..6f06e3e 100644 --- a/mainmem.s +++ b/mainmem.s @@ -143,8 +143,9 @@ COPYAUXBLK RTS * ProDOS file handling to delete a file -* Return A=0 not found, A=FF other err -* A=1 file deleted, A=2 dir deleted +* Called by AppleMOS OSFILE +* Return A=1 file deleted, A=2 dir deleted +* A=80 not found, A=81 can't delete DELFILE >>> ENTMAIN JSR UPDFB ; Update FILEBLK JSR COPYFB ; Copy back to aux mem @@ -156,9 +157,9 @@ DELFILE >>> ENTMAIN BEQ :NOTFND CMP #$46 ; File not found BEQ :NOTFND - LDA #$FF ; Some other error + LDA #$81 ; Some other error BRA :EXIT -:NOTFND LDA #$00 ; 'Not found' +:NOTFND LDA #$80 ; 'Not found' BRA :EXIT :DELETED LDA GINFOPL+7 ; Storage type CMP #$0D ; Directory @@ -178,6 +179,11 @@ DESTROY LDA #>> ENTMAIN LDA #>> ENTMAIN LDA $BF93 STA CREATEPL+11 JSR CRTFILE - LDA #$02 + BCC :OK + CMP #$47 ; Duplicate filename + BEQ :DUPE + CMP #$40 ; Bad pathname + BEQ :BADNAME + LDA #$82 + BRA :EXIT +:DUPE LDA #$80 + BRA :EXIT +:BADNAME LDA #$81 + BRA :EXIT +:OK LDA #$02 :EXIT >>> XF2AUX,OSFILERET * ProDOS file handling to rename a file @@ -454,10 +471,10 @@ TELL >>> ENTMAIN BRA :EXIT * ProDOS file handling for MOS OSFILE LOAD call -* Return A=0 if successful -* A=1 if file not found -* A=2 if read error -* TO DO: change to $01, $80, some other $80+n +* Invoked by AppleMOS OSFILE +* Return A=01 if successful (meaning 'file') +* A=80 if file not found +* A=81 if read error LOADFILE >>> ENTMAIN STZ :BLOCKS LDA #>> ENTMAIN JSR AUXMOVE INC :BLOCKS BRA :L1 -:NOTFND LDA #$01 ; Nothing found +:NOTFND LDA #$80 ; Nothing found PHA BRA :EXIT -:READERR LDA #$02 ; Read error +:READERR LDA #$81 ; Read error PHA BRA :EOF2 -:EOF LDA #$00 ; Success +:EOF LDA #$01 ; Success ('File') + PHA :EOF2 LDA OPENPL+5 ; File ref num STA CLSPL+1 JSR CLSFILE @@ -547,10 +565,10 @@ COPYFB PHA RTS * ProDOS file handling for MOS OSFILE SAVE call -* Return A=0 if successful -* A=1 if unable to create/open -* A=2 if error during save -* TO DO: change to $01, $80, some other $80+n +* Invoked by AppleMOS OSFILE +* Return A=01 if successful (ie: 'file') +* A=80 if unable to create/open +* A=81 if error during save SAVEFILE >>> ENTMAIN LDA #>> ENTMAIN BRA :ENDLOOP :CANTOPEN - LDA #$01 ; Can't open/create + LDA #$80 ; Can't open/create + PHA BRA :EXIT :WRITEERR LDA OPENPL+5 ; File ref num STA CLSPL+1 JSR CLSFILE - LDA #$02 ; Write error + LDA #$81 ; Write error + PHA BRA :EXIT :NORMALEND LDA OPENPL+5 ; File ref num STA CLSPL+1 JSR CLSFILE - LDA #$00 ; Success! - BCC :EXIT ; If close OK - LDA #$02 ; Write error + BCC :OK ; If close OK + LDA #$81 ; Write error + PHA + BRA :EXIT +:OK LDA #$01 ; Success ('File') + PHA :EXIT JSR UPDFB ; Update FILEBLK JSR COPYFB ; Copy FILEBLK to aux mem + PLA >>> XF2AUX,OSFILERET :BLOCKS DB $00 :LENREM DW $0000 ; Remaining length