summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-08-07 21:50:15 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2012-08-07 21:52:20 (GMT)
commit989900bc216dab07bfc3a83f028c39a20ac5fa5c (patch)
tree2820c70b7687fe65e0fcdd1486213c6c0b606a31
parent8588a8c706818780f70577e0eefb3a8cbb996724 (diff)
downloadabcdisk-989900bc216dab07bfc3a83f028c39a20ac5fa5c.zip
abcdisk-989900bc216dab07bfc3a83f028c39a20ac5fa5c.tar.gz
abcdisk-989900bc216dab07bfc3a83f028c39a20ac5fa5c.tar.bz2
abcdisk-989900bc216dab07bfc3a83f028c39a20ac5fa5c.tar.xz
Handle pre-UFD-DOS formats with system at sector 6
Pre-UFD-DOS tended to have the system starting at sector 6, with bad block map at sector 7, and the MFD at sectors 8-15. ABC832+ and UFD-DOS inexplicably changed that to sectors 14-31 instead, for no obvious reason, thus causing incompatibility.
-rw-r--r--formats.c15
-rw-r--r--util.c8
-rw-r--r--util.h1
3 files changed, 13 insertions, 11 deletions
diff --git a/formats.c b/formats.c
index 6acd5a3..104b62b 100644
--- a/formats.c
+++ b/formats.c
@@ -5,13 +5,14 @@
static const struct diskfmt formats[] =
{
- { "fd2", 40, 3, 0 },
- { "abc830", 80, 3, 0 },
- { "abc832", 80, 5, 2 },
- { "abc834", 80, 5, 2 },
- { "hd", 238, 8, 5 },
- { "", 238, 8, 5 },
- { NULL, 0, 0, 0 }
+ { "fd2", 40, 3, 0, 6 },
+ { "abc830", 80, 3, 0, 6 },
+ { "abc830-ufd", 80, 3, 0, 14 },
+ { "abc832", 80, 5, 2, 14 },
+ { "abc834", 80, 5, 2, 14 },
+ { "hd", 238, 8, 5, 14 },
+ { "", 238, 8, 5, 14 },
+ { NULL, 0, 0, 0, 0 }
};
const struct diskfmt *get_format(const char *name)
diff --git a/util.c b/util.c
index 9c445b5..675050c 100644
--- a/util.c
+++ b/util.c
@@ -27,10 +27,10 @@ struct disk *allocate_disk(const struct diskfmt *fmt)
disk->fmt = fmt;
disk->image = xmalloc(size);
- disk->bitmap = disk->image + 14*256;
+ disk->bitmap = disk->image + (fmt->syssec << 8);
disk->mfd.disk = disk;
- disk->mfd.bitmap = disk->image + 14*256;
- disk->mfd.dirsec = disk->image + 16*256;
+ disk->mfd.bitmap = disk->bitmap;
+ disk->mfd.dirsec = disk->bitmap + 2*256;
disk->mfd.block = 0; /* This is the MFD */
/* Post-formatting content? */
@@ -47,7 +47,7 @@ struct disk *allocate_disk(const struct diskfmt *fmt)
for (i = 0; i < starter; i++)
mark_used(disk, i);
- /* Copy bitmap to backup empty bitmap */
+ /* Copy bitmap to backup empty bitmap (= bad block map) */
memcpy(disk->bitmap + 256, disk->bitmap, 256);
/* Create MFD directory sectors */
diff --git a/util.h b/util.h
index bd2dcf3..7cac824 100644
--- a/util.h
+++ b/util.h
@@ -8,6 +8,7 @@ struct diskfmt {
int ntracks; /* Total tracks (max 238) */
unsigned int track_shift; /* Size of a track in sectors (max 256) */
unsigned int cluster_shift; /* Size of a cluster (typically track/8) */
+ int syssec; /* First system sector (bitmap) */
};
struct disk;