Writing PRG files to D80 images causes data corruption
Versatile Commodore Emulator
Brought to you by:
blackystardust,
gpz
Odd, indead the "8088.prg" causes problems. The rest of the files can be read properly, even adding "boot.prg" or "6509.prg" again under different file names works, as does reading them back and writing them to the host OS. The problem seems to be the 8088.prg file, trying to write that back to the host causes the "track 0, sector 0 out of bounds" message.
Did a little forensics on the image:
Part of the directory:
So "8088.PRG" has its first sector at (38,5) ($26,$05)
Pointing to (38,11) ($26, $0b):
Pointing to (38,17) ($26,$11):
Pointing to (38,23) ($26,$17):
Which points to (38,6) ($26,$06):
Which is a full sector with 0x00, which isn't how CBM DOS terminates files, If the final block of a CBM file exactly fits in a sector, the T/S link data would be $00, $fe).
We're also left with a 5 block file, not 11 blocks as the original file would be.
I haven't tested d82 images yet, but I think we can conclude vdrive's d80 handling might have a few bugs.
Substituting the 8088.prg file with another file (for example, writing two copies of 6509.prg under different names) will give the same error, as long as the third file is more than 1 sector long.
If you do the same test with D82, you will notice that (38,5) points to (38,12) not to (38,11). It seems that the sectors for this file in D80 image are improperly interleaved, with a value that is off by 1.
To confuse things even more: DirMaster interleaves D80 sectors by 10.
D80 vdrive doesn't write sectors 6 and 9 on track 38. That bug leaves two holes in the "8088" file. If you pre-allocate those blocks, then a good copy of the file is written.
(38, 5) -> (38,11) -> (38,17) -> (38,23) -> (38, 7) -> (38,13) -> (38,19) -> (38,25) -> (38,12) -> (38,18) -> (38,24) -> (38,15) -> (38,21) -> (38,27) -> 44
Last edit: Greg King 2017-11-29
Great, this workaround works well. I suppose I can free the sectors again after all files are placed using the B-D command.
does this work now? i vaguely remember some related fix, perhaps? :)
I also remember a fix for this. I've tested this with trunk and it appears to work: I used the commands in the .bat file to create a d80 and write the three files to it. When I read them back with the
readcommand in c1541 I get all three files back properly (equal content).So I suspect we fixed this but never closed this bug. Closing now.
Fixed by revision 37368.