diff options
Diffstat (limited to 'fenders.c')
-rw-r--r-- | fenders.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -380,9 +380,33 @@ int main(int argc, char **argv) { } if(dens == SD) { - /* single density can just use a simple copy loop */ - while( (c = getc(in)) != EOF ) + int offs = 0, sectorcount = 0, fixcount = 0; + /* single density can just use a simple copy loop... except we want + to make DOS 2.5 extended files visible. <FILE> in the dir listing + means the status byte is $03, change it to normal file ($42). */ + while( (c = getc(in)) != EOF ) { + if(offs == 45569) { /* LSB of number-of-sectors, VTOC offset 1 */ + sectorcount = c; + } else if(offs == 45570) { /* MSB of number-of-sectors, VTOC offset 2 */ + sectorcount |= (c << 8); + if(sectorcount == 1010) + fprintf(stderr, SELF ": DOS 2.5 disk detected, fixing extended files.\n"); + } else if(offs >= 45696 && offs < 46720 && (offs % 16 == 0)) { + if(sectorcount == 1010 && c == 0x03) { + c = 0x42; + fixcount++; + } + } putc(c, out); + offs++; + } + if(sectorcount == 1010) { + if(fixcount) + fprintf(stderr, SELF ": fixed %d extended file%s.\n", + fixcount, (fixcount == 1 ? "" : "s")); + else + fprintf(stderr, SELF ": no extended files to fix.\n"); + } } else { /* double density: copy sectors 4-719 as-is... */ for(c=4; c<720; c++) { @@ -413,8 +437,6 @@ int main(int argc, char **argv) { density images. */ /* TODO: examine directory sectors, look for: - - DOS 2.5 extended files. Either warn about them, or clear the - extended flag (which causes the bootloader to load them just fine). - MyDOS subdirectories. It's probably best to abort in that case. - Non-DOS-compatible disk formats (boot disks, SpartaDOS, Atari DOS 3 or 4). |