From 8221db255f9cc66af2a9356e5ab68c6fd555ad3a Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 8 May 2024 15:09:16 -0400 Subject: fenders: add -I, -d, -b options. --- atr2xfd.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'atr2xfd.c') diff --git a/atr2xfd.c b/atr2xfd.c index bed24fe..5929433 100644 --- a/atr2xfd.c +++ b/atr2xfd.c @@ -255,12 +255,23 @@ int main(int argc, char **argv) { unsigned char dos1_sig[] = "\x00\x01\x00\x07\x00\x13\x4c\x12"; unsigned char dos2_sig[] = "\x00\x03\x00\x07\x40\x15\x4c\x14"; unsigned char dos3_sig[] = "\x01\x09\x00\x32\x06\x32"; -unsigned char mydos3_sig[] = "\x00\x03\x00\x07\xe0\x07\x4c\x14"; +unsigned char dos4_sig[] = "\x00\x21\x01\x07\xf8\x07\x4c\xd9"; +unsigned char dos4_noboot_sig[] = "\x00\x00\x00\x01\x00\x01\x01\x01"; +unsigned char mydos30_sig[] = "\x00\x03\x00\x07\xd8\x17\x4c\x14"; +unsigned char mydos31_sig[] = "\x00\x03\x00\x07\xe0\x07\x4c\x14"; unsigned char mydos4_sig[] = "\x4d\x03\x00\x07\xe0\x07\x4c\x14"; unsigned char topdos11_sig[] = "\xc0\x03\x00\x07\x40\x15\x4c\x24"; unsigned char topdos15_sig[] = "\x80\x03\x00\x07\x40\x15\x4c\x24"; unsigned char blank_sig[] = "\x00\x00\x00\x00\x00\x00\x00\x00"; unsigned char pico_sig[] = "\x00\x03\x00\x10\x10\x4c"; +unsigned char superdos2_sig[] = "\x29\x03\x00\x07\x40\x15\xa0"; +unsigned char superdos5_sig[] = "\x64\x03\x00\x07\x40\x15\xa9\x07"; +unsigned char smartdos_sig[] = "\x00\x03\x00\x07\xd4\x15\x4c\x14"; +unsigned char dosxe_sig[] = "\x58\x03\x00\x07\xca\x0c\x4c\x30"; + +/* both of these claim to be "Turbo DOS XE version 2.1" */ +unsigned char turbodos_sig[] = "\x04\x03\x00\x07\x40\x15\x4c\x16"; +unsigned char turbodosxe_sig[] = "\x01\x03\x00\x07\x40\x15\x4c\x16"; /* these signatures are for offset $18 of sector 1. */ unsigned char dos2_code_sig[] = "\x36\xad\x12\x07"; @@ -272,7 +283,7 @@ void classify_boot_sector(FILE *f) { unsigned char buf[128]; char *dos_type = "Unknown", *boot_text = ""; int bootable = -1; /* -1 = unknown, 0 = no, 1 = yes */ - int i; + int dos2_bootable, i; /* read 1st sector... */ if( (fread(buf, 1, 128, f) < 128) ) { @@ -285,11 +296,22 @@ void classify_boot_sector(FILE *f) { fputc('\n', stderr); #endif + dos2_bootable = (buf[14] != 0); + /* now figure out what kind of boot sector this is */ if(SIG_MATCH(buf, dos1_sig)) { dos_type = "DOS 1.0"; + bootable = dos2_bootable; } else if(SIG_MATCH(buf, dos3_sig)) { dos_type = "DOS 3.0"; + /* can't tell if bootable from just the boot sector, would have + to search for FMS.SYS */ + } else if(SIG_MATCH(buf, dos4_sig)) { + dos_type = "DOS 4.0"; + bootable = 1; + } else if(SIG_MATCH(buf, dos4_noboot_sig)) { + dos_type = "DOS 4.0"; + bootable = 0; } else if(SIG_MATCH(buf, dos2_sig)) { if(SIG_MATCH(buf + 0x18, dos2_code_sig)) dos_type = "DOS 2.0"; @@ -297,7 +319,7 @@ void classify_boot_sector(FILE *f) { dos_type = "DOS 2.5"; else dos_type = "DOS 2.0 compatible"; - bootable = (buf[14] != 0); + bootable = dos2_bootable; } else if(buf[0] == 0x00 && buf[1] == 0x03 && (buf[32] == 0x11 || buf[32] == 0x20) && buf[6] == 0x4c && buf[7] == 0x80) { @@ -305,12 +327,37 @@ void classify_boot_sector(FILE *f) { dos_type = "SpartaDOS 1.1"; else dos_type = "SpartaDOS >= 2"; - } else if(SIG_MATCH(buf, mydos3_sig)) { - dos_type = "MyDOS 3.x"; + } else if(SIG_MATCH(buf, mydos30_sig)) { + dos_type = "MyDOS 3.0x"; + bootable = dos2_bootable; + } else if(SIG_MATCH(buf, mydos31_sig)) { + dos_type = "MyDOS 3.1x"; + bootable = dos2_bootable; } else if(SIG_MATCH(buf, mydos4_sig)) { dos_type = "MyDOS 4.x"; + bootable = dos2_bootable; } else if(SIG_MATCH(buf, pico_sig)) { dos_type = "MyPicoDOS 4.x"; + } else if(SIG_MATCH(buf, topdos11_sig)) { + dos_type = "Top DOS 1.1"; + bootable = !(buf[15] == 0 && buf[16] == 0); + } else if(SIG_MATCH(buf, topdos15_sig)) { + dos_type = "Top DOS 1.5"; + bootable = dos2_bootable; + } else if(SIG_MATCH(buf, superdos2_sig)) { + dos_type = "SuperDOS 2.9"; + bootable = (buf[7] != 0); + } else if(SIG_MATCH(buf, superdos5_sig)) { + dos_type = "SuperDOS 5.1"; + } else if(SIG_MATCH(buf, turbodos_sig)) { + dos_type = "Turbo DOS XE"; + } else if(SIG_MATCH(buf, turbodosxe_sig)) { + dos_type = "Turbo DOS XE"; + } else if(SIG_MATCH(buf, dosxe_sig)) { + dos_type = "DOS XE"; + } else if(SIG_MATCH(buf, smartdos_sig)) { + dos_type = "Smart DOS"; + bootable = dos2_bootable; } else if(SIG_MATCH(buf, blank_sig)) { dos_type = "None (empty boot sector)"; bootable = 0; -- cgit v1.2.3