File Command Errors

Basic and Machine Language

Moderator: Moderators

User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

File Command Errors

Post by chysn »

Specifically, I'm looking for something akin to "file not found," but any failure indication will do. If you run something like

Code: Select all

OPEN15,8,15,"S:DOES-NOT-EXIST":CLOSE15
you just get back READY. There's no ?FILE NOT FOUND or any other indication that the command failed.

When I'm running a command using KERNAL routines, like this:

Code: Select all

disk_cmd:   ldx DEVICE
            ldy #15
            lda #15
            pha
            jsr SETLFS
            jsr OPEN
            ldx #15
            jsr CHKOUT
            ldy #0
-loop:      lda INBUFFER,y
            beq dcmd_r
            jsr CHROUT
            iny 
            bne loop
EOF:        jsr CLRCHN 
            pla
            jmp CLOSE
I don't see any opportunity for getting an error condition back from the drive (1541, SD2EIC, VICE's emulator, etc.). It seems like a command isn't executed until CLOSE, and CLOSE returns no errors. So there simply isn't an obvious mechanism to catch things that go wrong during disk commands, which is why BASIC merrily reports READY no matter what. This is fine, but I just want to make sure I'm not missing some super-secret bat-cave thing.

(I know I could check for the existence of a specific file before running a command, but parsing commands is off the table with the memory I have left.)
Last edited by chysn on Fri Oct 20, 2023 5:08 am, edited 1 time in total.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: File Command Errors

Post by wimoos »

Hello chysn,

I looked for this when adding the ' autostart' function to WimBasic. First to check for the existence of the file WBSTART by trying to open and when found, load and run it. Any error (checked in $90) leads to the conclusion that file doesn't exist.

So, when trying to scratch a file: just assume that it is no longer there. You could use the status channel of the device to go get a textual status, but hey, the file would be gone anyway.

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

wimoos wrote: Fri Oct 20, 2023 5:07 am So, when trying to scratch a file: just assume that it is no longer there. You could use the status channel of the device to go get a textual status, but hey, the file would be gone anyway.
I suppose using "scratch" wasn't the best example, as you want the file gone :D

But, let's say, a "copy" operation that runs out of space, or a "new" failure due to bad or missing media. What do you mean by "status channel of the device?" I'm not finding that command failure sets any value for $90.
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: File Command Errors

Post by wimoos »

Hello chysn,

(I believe) the following code queries the device at #8 for the last status text and prints it.
Not quite sure as I don't have the resources at hand to check it.

Regards,

Wim.

Code: Select all

	LDA  #$08      	 
	JSR  $FFB4     	 
	LDA  #$6F      	 
	JSR  $FF96     	 
LAE3C	JSR  $FFA5     	 
	JSR  $E742     	 
	CMP  #$0D      	 
	BNE  LAE3C     	 
	JMP  $FFAB     	 

VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: File Command Errors

Post by Mike »

chysn wrote:[...] I don't see any opportunity for getting an error condition back from the drive [...]
wimoos wrote:[...] You could use the status channel of the device [...]
This.

Especially you should read the status from the drive after each relevant operation when successful operation of your program depends on it.

Regarding the 'responsibilities': as with the creation of the directory listing, execution of the disk commands is the business of CBM DOS, located in the disk drive itself. The VIC-20 KERNAL has no idea what happens in the drive, BASIC has so even less and that is mainly the reason the user program continues to run. The advantage in this is you can decide for yourself how to handle disk operation errors (either just report to the user, or close all files and terminate the program).

For your example of the scratch command, CBM DOS returns "01, FILES SCRATCHED, XX, 00" with XX being the number of files scratched, with XX=0 when no file had been scratched (because it was not there or had been write protected(!)) or XX>1 in case the scratch command had wildcards and matched more than one file name.

The command channel to the drive should be opened as first one, before all file channels and be closed as last one. Closing the command channel with file channels open will automatically close these as well, which you likely do not want.

Note there had been some deviant behaviour with the command channel in the VDrive emulation (i.e. TDE off) with older versions of VICE. Basically, sending multiple scratch commands could hang the emulated command channel (that had been discussed in the German Forum64 some months ago).
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

wimoos wrote: Fri Oct 20, 2023 5:32 am (I believe) the following code queries the device at #8 for the last status text and prints it.
Not quite sure as I don't have the resources at hand to check it.
Holy $#!*, this is exactly what I'm looking for, thank you! Those are some KERNAL routines that I've never, ever, used before, so it's neat to see them in action.

Sometimes its output is weird in VICE. For example, it reports S=filename as a syntax error despite deleting the file. But I'm going to play around a bit with the settings in VICE, as well as make sure SD2IEC works properly. I might have to finally buy a 1541.
Mike wrote: Fri Oct 20, 2023 5:51 am The command channel to the drive should be opened as first one, before all file channels
By opening a "command channel," I think you're talking about calling TALK and TALKSA. By opening a "file channel," I think you mean opening a file with SETLFS and OPEN. Is that right? I may have the terminology backwards...?

I'm going to experiment with various configurations, but this is definitely the right track! Thanks, all!
Screen Shot 2023-10-20 at 9.41.53 AM.png
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: File Command Errors

Post by Mike »

chysn wrote:By opening a "command channel," I think you're talking about calling TALK and TALKSA. By opening a "file channel," I think you mean opening a file with SETLFS and OPEN. Is that right?
Not quite. The command channel is accessed by opening a file with secondary address 15 on the drive. This can be done both via the high level KERNAL API (OPEN, CHROUT, CHRIN, CLOSE) or the low level IEC calls (TALK and TALKSA being examples of those). In the latter case, there exists not necessarily an entry in the list of open files in the $02xx area.

All other secondary addresses involve data transfer to or from files or buffers, for simplicity I called them "file channels" here to distinct them from the command channel.
If so, I'm finding that the file channel must be open first, or the command channel always reports a syntax error, [...]
A syntax error as report on the command channel is mostly the result of a malformed (or unknown) command. As I wrote, you would normally open the command channel first as an action in a program that involves disk drive access.
[...] and commands don't get run. Also, the file channel must be closed first, or the status string is inaccurate.
You can read out the status from the command channel at any time, not only when the file channel(s) is/are closed. Of course the successful operation on a complete file can only be asserted upon file close. But you can also get the information from the drive, during file write, that the disk is nearly full - while the file is open, CBM DOS then sends a "72,DISK FULL,00,00" to indicate that only two blocks are free and left to fill up the whole disk, which is still sufficient to close the file regularily without incurring a splat file (marked with "*"). Whether that incomplete file is of any use, is another matter.

Again, the command channel should be closed last, as on the drive all other regular file channels will be closed alongside it. The KERNAL will not notice this situation, and any subsequent data transfer regarding these files will go into the void.

You can go like this to 'supervise' the whole activity of the drive during file operations - the example below first deletes a file with given name and then writes a new file under the same name, and finally reads it back again.

Code: Select all

10 N$="TEST"
11 PRINT"OPEN CMD CHANNEL":OPEN15,8,15:GOSUB25:PRINTDS$:IFNOT(DS=0 OR DS=73)THEN23
12 PRINT"DELETE FILE":PRINT#15,"S0:"+N$:GOSUB25:PRINTDS$:IFDS<>1THEN23
13 PRINT"OPEN FILE FOR WRITE":OPEN2,8,2,N$+",S,W":GOSUB25:PRINTDS$:IFDS<>0THEN22
14 FORT=1TO100
15 PRINT#2,"LINE"+STR$(T):GOSUB25:PRINT DS$:IFDS<>0THEN22
16 NEXT
17 PRINT"CLOSE FILE":CLOSE2:GOSUB25:PRINT DS$:IFDS<>0THEN22
18 PRINT"OPEN FILE FOR READ":OPEN2,8,2,N$+",S,R":GOSUB25:PRINT DS$:IFDS<>0THEN22
19 FORT=1TO100
20 INPUT#2,A$:PRINTA$:GOSUB25:IFDS<>0THENPRINT DS$:GOTO22
21 NEXT
22 PRINT"CLOSE FILE":CLOSE2:GOSUB25:PRINT DS$
23 PRINT"CLOSE CMD CHANNEL":CLOSE15:END
24 :
25 DS$="":FORP=-1TO0:GET#15,A$:DS$=DS$+A$:P=ST=0:NEXT:DS=VAL(DS$):RETURN
During file re-read, the status channel is only printed when there is an error. The scratch command normally returns with "01,..." which itself does not constitute an error but is merely informatory. Upon anything else than 0, 1 (for scratch) or 73 (possible CBM DOS startup message upon OPEN ...,15), the program terminates by jumping forward to either line 22 or 23.

As you see, properly checking the disk status incurs quite some code overhead. Many people just don't bother. :wink:


P.S. please note "CD:xxx" is not a regular CBM DOS command. It is a CMD extension supported by their harddisks, VICE VDrive and SD2IECs, but does not work on "regular" CBM DOS drives (or with TDE on in VICE).
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

OK, thanks. Yeah, I was interpreting your terminology wrong. Yes, I am opening the command channel first thing with SETLFS, OPEN, and CHKIN.

The thing that's driving me nuts right now is that VICE's "Virtual Device" and "True Drive Emulation" seem to require different close techniques after the command for status to be reported properly. TDE works if I use CLALL, and VDrive does not. VDrive works if I use CLOSE/CLRCHN, and TDE does not.

OK, let me go back to basics for a second. When a command is sent to a drive, at what point does the drive know that the CHROUT is done and the command should be executed? Is when the command channel is CLOSEd? Is it when CHROUT sends $00 or $0d or something else?
Mike wrote: Fri Oct 20, 2023 9:39 am P.S. please note "CD:xxx" is not a regular CBM DOS command. It is a CMD extension supported by their harddisks, VICE VDrive and SD2IECs, but does not work on "regular" CBM DOS drives (or with TDE on in VICE).
I know that. I'm only testing CD on VICE VDrive. For TDE, I'm testing primarily S, R, and C. VDrive, meanwhile, does not support C (at least, I've never gotten it to work). I can't wait to move to SD2IEC! :roll:
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: File Command Errors

Post by Mike »

chysn wrote:When a command is sent to a drive, at what point does the drive know that the CHROUT is done and the command should be executed?
The command is completed upon restoring KERNAL I/O with CLRCHN. Sending a $00 or $0D (at the end of the command string) is of no relevance, unless you have a command accepting binary data like the "M-W" command.
VDrive does not support C (at least, I've never gotten it to work). I can't wait to move to SD2IEC! :roll:
Well, VDrive should. Maybe did you get the file names the wrong way round? Sending "C0:new_file=old_file" should create a copy of 'old_file' under the new name 'new_file'.
TDE works if I use CLALL, and VDrive does not. VDrive works if I use CLOSE/CLRCHN, and TDE does not.
As I wrote, some older VICE versions have a broken implementation of VDrive especially in that matter. If in doubt in emulation, the only thing that counts is TDE on.

I have stated my concerns about CLALL at another place: besides doing a CLRCHN, it rudely purges the file descriptor table on the computer without closing the files on the drive, with all chances to produce splat files afterwards.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

Mike wrote: Fri Oct 20, 2023 10:06 am
chysn wrote:When a command is sent to a drive, at what point does the drive know that the CHROUT is done and the command should be executed?
The command is completed upon restoring KERNAL I/O with CLRCHN. Sending a $00 or $0D is of no relevance, unless you have a command accepting binary data like the "M-W" command.
OK, that's quite helpful.
Well, VDrive should. Maybe did you get the file names the wrong way round? Sending "C0:new_file=old_file" should create a copy of 'old_file' under the new name 'new_file'.
#8 is the VDrive, #9 is the TDE. Using C0: doesn't change anything.
Screen Shot 2023-10-20 at 12.13.12 PM.png
Last edited by chysn on Fri Oct 20, 2023 10:26 am, edited 1 time in total.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: File Command Errors

Post by Mike »

chysn wrote:#8 is the VDrive, #9 is the TDE. Using C0: doesn't change anything.
You should cross-check the VDrive directory with LOAD"$",8 and LIST. IIRC, there was also some problem with file wildcard matching.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

Mike wrote: Fri Oct 20, 2023 10:18 am
chysn wrote:#8 is the VDrive, #9 is the TDE. Using C0: doesn't change anything.
You should cross-check the VDrive directory with LOAD"$",8 and LIST. IIRC, there was also some problem with file wildcard matching.
I did that, the file does not get created. This partial-name search system does not use wildcard matching, it just parses the incoming ersatz BASIC file. Also, the device reports SYNTAX ERROR when copy is attempted.
Last edited by chysn on Fri Oct 20, 2023 11:10 am, edited 1 time in total.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

All right, I think I'm getting close. The order that I was missing was that it needs to be:

Code: Select all

jsr CLRCHN
lda #15
jsr CLOSE
whereas I was doing the CLRCHN after the CLOSE before. This way, the commands are executed as expected. They are not, however, reported as expected. For example, scratches are reported as OK rather than FILES SCRATCHED. I'd actually be willing to live with this peculiarity, but that now VDrive reports that everything is OK, even when files aren't found, or already exist (in the case of rename).

If failures are going to be reported as successes, I might as well not report. I'm starting to think that BASIC had the right idea.

I'm going to look closely at CLALL, and try to find out why that magically makes all the reporting in TDE perfect, but kills VDrive's reporting.

Incidentally, VDrive's "rename" allows an existing target file to be overwritten, whereas TDE reports "FILE EXISTS" and prevents the destructive action.

Other random limitations: TDE does not allow the most-recently-created file to be scratched. SD2IEC does not support rename (but admittedly, my SD2IEC unit is super old).
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: File Command Errors

Post by chysn »

Mike wrote: Fri Oct 20, 2023 10:06 am As I wrote, some older VICE versions have a broken implementation of VDrive especially in that matter. If in doubt in emulation, the only thing that counts is TDE on.
I haven't had luck specifying a local filesystem with TDE on, though. The TDE checkbox seems to disable VDrive. I'm not sure why they're even allowed to both be checked.
I have stated my concerns about CLALL at another place: besides doing a CLRCHN, it rudely purges the file descriptor table on the computer without closing the files on the drive, with all chances to produce splat files afterwards.
I've been able to purge CLALL from the codebase. I was trying it experimentally, and it's the only way I've found to make TDE's error reporting 100% reliable. Unfortunately, it totally breaks VDrive's reporting. Here's where I am at the moment, with the three CLOSE scenarios commented:

Code: Select all

disk_cmd:   ldx DEVICE
            ldy #15
            lda #15
            jsr SETLFS
            jsr OPEN
            ldx #15
            jsr CHKOUT
            ldy #0
-loop:      lda INBUFFER,y
            beq show_st
            jsr CHROUT
            iny 
            bne loop
show_st:    jsr CLRCHN          ; Commands work for both systems, but
            lda #15             ; do not get reported correctly for
            jsr CLOSE           ; VDrive; failures reported as OK in VDrive.
                                ; Scratch command reported as OK in TDE
                                ; instead of SCRATCHED.
            
            ;jsr CLALL          ; Works for TDE, all reporting OK, but
                                ; reports syntax errors for VDrive
                                ; ,,
                                        
            ;lda #15            ; Works for VDrive, all reporting OK, but
            ;jsr CLOSE          ; commands don't get executed for 
            ;jsr CLRCHN         ; TDE at all
            
            lda DEVICE
            jsr TALK
            lda #$6f
            jsr TALKSA     
-loop:      jsr IECIN
            jsr $e742
            cmp #$0d
            bne loop    
            jmp UNTALK
 
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: File Command Errors

Post by Mike »

chysn wrote:I haven't had luck specifying a local filesystem with TDE on, though.
TDE on implies the use of disk images and specifying a given CBM drive (1541, 1571, 1581, etc.). A native PC directory can't be a true drive.
The TDE checkbox seems to disable VDrive. I'm not sure why they're even allowed to both be checked.
IIRC, that has been sanitized in current versions of VICE.
Incidentally, VDrive's "rename" allows an existing target file to be overwritten, whereas TDE reports "FILE EXISTS" and prevents the destructive action.
This scenario is so unsettling I had to write a test program to be able to reproduce this behaviour in a test environment.

In the test program below, all the command channel operations (send command, read status) operate with a previously opened logical file with secondary address 15, which is never closed in-between. Doing the latter not only would close the open file channels on the drive (throwing gears into the file write and read operations), but also lose the current drive status. Upon re-opening channel 15, one would only ever see "00, OK,00,00" as status. PRINT# uses CHKOUT, CHROUT and CLRCHN; INPUT# and GET# use CHKIN, CHRIN and CLRCHN. No single instance of CLALL is involved.

Note: I only included 62 in lines 18 and 22 (and 0 in line 54) as 'allowed' error numbers, so the program would continue in some of the scenarios nonetheless - but these are actually examples of 'programming around an emulator fault' which should not be there in production code.

For the record, I am currently (still) using WinVICE 3.1 x86 r34289 (built 2018-01-06):

Code: Select all

10 DN=PEEK(186)
11 :
12 PRINT"OPEN CMD CHANNEL"
13 OPEN15,DN,15
14 GOSUB87:PRINTDS$:IFNOT(DS=0ORDS=73)THEN82
15 :
16 PRINT"SCRATCH FILE1"
17 PRINT#15,"S0:FILE1"
18 GOSUB87:PRINTDS$:PRINT:IFNOT(DS=1ORDS=62)THEN82
19 :
20 PRINT"SCRATCH FILE2"
21 PRINT#15,"S0:FILE2"
22 GOSUB87:PRINTDS$:PRINT:IFNOT(DS=1ORDS=62)THEN82
23 :
24 PRINT"OPEN FILE1 FOR WRITE"
25 OPEN2,DN,2,"FILE1,S,W"
26 GOSUB87:PRINTDS$:PRINT:IFDS<>0THENCLOSE2:GOTO82
27 :
28 PRINT"WRITE FILE1"
29 FORT=1TO10:PRINT#2,"FILE1 LINE"+STR$(T):NEXT
30 GOSUB87:PRINTDS$:PRINT:IFDS<>0THENCLOSE2:GOTO82
31 :
32 PRINT"CLOSE FILE1"
33 CLOSE2
34 GOSUB87:PRINTDS$:PRINT:IFDS<>0THEN82
35 :
36 PRINT"OPEN FILE2 FOR WRITE"
37 OPEN2,DN,2,"FILE2,S,W"
38 GOSUB87:PRINTDS$:PRINT:IFDS<>0THENCLOSE2:GOTO82
39 :
40 PRINT"WRITE FILE2"
41 FORT=1TO10:PRINT#2,"FILE2 LINE"+STR$(T):NEXT
42 GOSUB87:PRINTDS$:PRINT:IFDS<>0THENCLOSE2:GOTO82
43 :
44 PRINT"CLOSE FILE2"
45 CLOSE2
46 GOSUB87:PRINTDS$:PRINT:IFDS<>0THEN82
47 :
48 PRINT"REN. FILE2 INTO FILE1"
49 REM ** THIS SHOULD UNDER NORMAL
50 REM    CIRCUMSTANCES BE REJECTED
51 REM    BY THE DOS, AS FILE1
52 REM    ALREADY EXISTS!
53 PRINT#15,"R0:FILE1=FILE2"
54 GOSUB87:PRINTDS$:PRINT:IFNOT(DS=0ORDS=63)THEN82
55 :
56 PRINT"OPEN FILE1 FOR READ"
57 OPEN2,DN,2,"FILE1,S,R"
58 GOSUB87:PRINTDS$:PRINT:IFDS<>0THENCLOSE2:GOTO82
59 :
60 PRINT"FILE1 CONTENTS:"
61 INPUT#2,A$:PRINTA$:Q=ST
62 GOSUB87:IFDS<>0THENPRINTDS$:PRINT:CLOSE2:GOTO82
63 IFQ=0THEN61
64 :
65 PRINT"CLOSE FILE1"
66 CLOSE2
67 GOSUB87:PRINTDS$:PRINT:IFDS<>0THEN82
68 :
69 PRINT"OPEN FILE2 FOR READ"
70 OPEN2,DN,2,"FILE2,S,R"
71 GOSUB87:PRINTDS$:PRINT:IFDS<>0THENCLOSE2:GOTO82
72 :
73 PRINT"FILE2 CONTENTS:"
74 INPUT#2,A$:PRINTA$:Q=ST
75 GOSUB87:IFDS<>0THENPRINTDS$:PRINT:CLOSE2:GOTO82
76 IFQ=0THEN74
77 :
78 PRINT"CLOSE FILE2"
79 CLOSE2
80 GOSUB87:PRINTDS$:PRINT:IFDS<>0THEN82
81 :
82 PRINT"CLOSE CMD CHANNEL"
83 CLOSE15
84 END
85 :
86 :
87 DS$="":FORP=-1TO0:GET#15,A$:DS$=DS$+A$:P=ST=0:NEXT:DS=VAL(DS$):RETURN
  • With True Drive Emulation OFF and Virtual Device Traps ON, in a PC directory, with FILE1 and FILE2 missing, VDrive errorneously reports "62,FILE NOT FOUND,00,00" for both Scratch commands (should be 01,FILES SCRATCHED,00,00) and writes FILE1 and FILE2. Renaming FILE2 into FILE1 results in FILE2 overwriting FILE1. FILE1 now contains the contents of FILE2, FILE2 is evidently missing and the test program bails out at line 71 with "62, FILE NOT FOUND,00,00".
  • With True Drive Emulation OFF and Virtual Device Traps ON, in a PC directory, with FILE1 and FILE2 present, VDrive errorneously reports "01,FILES SCRATCHED,00,00" (should be "01,FILES SCRATCHED,01,00"), and later bails out again at line 71 for the same reasons as above.
  • With True Drive Emulation OFF and Virtual Device Traps ON, in a *.d64 disk image, with FILE1 and FILE2 missing, VDrive dies either on the first or second Scratch command: reading the status does not terminate, with a ?STRING TOO LONG error in line 87.
  • With True Drive Emulation ON (1541) and Virtual Device Traps OFF, in a *.d64 disk image, with FILE1 and FILE2 missing, VICE correctly reports "01,FILES SCRATCHED,00,00" for both Scratch commands and writes FILE1 and FILE2. Renaming FILE2 into FILE1 is correctly faulted with "63,FILE EXISTS,00,00". Both FILE1 and FILE2 are retained and read and display the expected contents.
  • With True Drive Emulation ON (1541) and Virtual Device Traps OFF, in a *.d64 disk image, with FILE1 and FILE2 present, VICE correctly reports "01,FILES SCRATCHED,01,00" for both Scratch commands and writes FILE1 and FILE2. The rest of the program positively continues as expected.
I did not test the two combinations "TDE off and VDT OFF" and "TDE on and VDT on" (the latter which is, IMO, an oxymoron).

Only the behaviour with True Drive Emulation ON and Virtual Device Traps OFF is correct. You see the same behaviour on real hardware, with a 1541. I will test with my SD2IEC in a directory and in a disk image later the day.

In short - as I wrote in the previous posts -, at least with older versions of VICE, VDrive is seriously broken. It doesn't make much sense to (try to) guard own programs against that (i.e. "program around" a fault in emulation). Neither is it a good idea to let a file management program intended for CBM DOS disks operate on the contents of a PC directory. The native OS does a better job at that.
Post Reply