vicist wrote:Not sure if this belongs here or 'Programming'.
Most probably, yes.
Between the drive number and device name and ID in the first line, and the block count and file names in the following lines, there are a variant number of spaces to pad out different digit counts. You can't rely on a fixed position of the file name string within a directory line. A more robust method is to scan for the quotes themselves.
You might want to compare your routine against another implementation of a directory scan that I used to copy an entire floppy with a file based method:
Code: Select all
10 POKE55,195:POKE56,28:CLR:GOTO19
11 GET#4,A$,B$,C$,D$:F=1
12 GET#4,A$:IFA$=""THENRETURN
13 IFA$<>CHR$(34)THEN12
14 N$="":T$="":F=0
15 GET#4,A$:IFA$<>CHR$(34)THENN$=N$+A$:GOTO15
16 GET#4,A$:IFA$=""THENRETURN
17 IFA$>="A"ANDA$<="Z"THENT$=T$+A$
18 GOTO16
19 FORT=0TO60:READA:POKE7363+T,A:NEXT:POKE5,0:POKE6,29
20 INPUT"SRC DEV.";SD:INPUT"DST DEV.";DD
21 OPEN4,SD,0,"$":GET#4,A$,B$:GOSUB11
22 GOSUB11:ONFGOTO25:IFNOT(T$="PRG"ORT$="SEQ"ORT$="USR")THEN22
23 F$=N$+","+LEFT$(T$,1):PRINTF$:OPEN2,SD,2,F$+",R"
24 OPEN3,DD,3,F$+",W":SYS7363:CLOSE2:CLOSE3:GOTO22
25 CLOSE4:POKE55,PEEK(643):POKE56,PEEK(644):CLR:END
26 DATA 162,2,32,198,255,160,0,132,3,32,207,255,72,165,144,201,1
27 DATA 104,164,3,145,5,200,132,3,176,2,208,236,8,32,204,255,162
28 DATA 3,32,201,255,160,0,177,5,132,4,32,210,255,164,4,200,196
29 DATA 3,208,242,32,204,255,40,144,196,96
(
download)
See lines 11 to 18. Line 21 reads in the fake load address and then throws away the header line before proceeding with all file names.
I also notice that when listing a directory in Vice (load"$",8), the first character printed is a '0' before the disk name. On sd2iec/1541 it is a '1'.
As I wrote above, this is the drive number you're reading. If you get a '1' on a 1541, *that* would be rather strange, as the 1541 is a single drive and is supposed to only return 0 there. A 8250 dual drive for example can return either 0 or 1, depending which drive is being read (and you can explicitly ask for the directory of a certain drive by loading "$0" or "$1").