Work-around to detect 615-cylinder hard disks

This commit is contained in:
Jeff Parsons 2015-12-18 14:34:56 -08:00
commit e5a4a050b4
2 changed files with 17 additions and 9 deletions

View file

@ -2142,14 +2142,18 @@ DiskDump.prototype.convertToJSON = function()
var cbDiskData = this.bufDisk.length; var cbDiskData = this.bufDisk.length;
if (cbDiskData >= 3000000) { // arbitrary threshold between diskette image sizes and hard disk image sizes if (cbDiskData >= 3000000) { // arbitrary threshold between diskette image sizes and hard disk image sizes
/* var wSig = this.bufDisk.readUInt16LE(0x1FE);
* In this case, the first sector should be an MBR; find the active partition entry, if (wSig == 0xAA55) {
* then read the LBA of the first partition sector to calculate the boot sector offset. /*
*/ * In this case, the first sector should be an MBR; find the active partition entry,
for (var offEntry = 0x1BE; offEntry <= 0x1EE; offEntry += 0x10) { * then read the LBA of the first partition sector to calculate the boot sector offset.
if (this.bufDisk.readUInt8(offEntry) >= 0x80) { */
offBootSector = this.bufDisk.readUInt16LE(offEntry + 0x08) * cbSector; for (var offEntry = 0x1BE; offEntry <= 0x1EE; offEntry += 0x10) {
break; if (this.bufDisk.readUInt8(offEntry) >= 0x80) {
offBootSector = this.bufDisk.readUInt32LE(offEntry + 0x08) * cbSector;
cbDiskData = this.bufDisk.readUInt32LE(offEntry + 0x0C) * cbSector;
break;
}
} }
} }
/* /*

View file

@ -83,7 +83,11 @@ DiskAPI.DISKETTE_FORMATS = {
737280: [80,2,9], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 9 sectors/track, (1440 total sectors x 512 bytes/sector == 737280) 737280: [80,2,9], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 9 sectors/track, (1440 total sectors x 512 bytes/sector == 737280)
1228800: [80,2,15], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 15 sectors/track, (2400 total sectors x 512 bytes/sector == 1228800) 1228800: [80,2,15], // media type 0xF9: 80 cylinders, 2 heads (double-sided), 15 sectors/track, (2400 total sectors x 512 bytes/sector == 1228800)
1474560: [80,2,18], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 18 sectors/track, (2880 total sectors x 512 bytes/sector == 1474560) 1474560: [80,2,18], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 18 sectors/track, (2880 total sectors x 512 bytes/sector == 1474560)
2949120: [80,2,36] // media type 0xF0: 80 cylinders, 2 heads (double-sided), 36 sectors/track, (5760 total sectors x 512 bytes/sector == 2949120) 2949120: [80,2,36], // media type 0xF0: 80 cylinders, 2 heads (double-sided), 36 sectors/track, (5760 total sectors x 512 bytes/sector == 2949120)
/*
* The following are common early hard disk sizes, which we explicitly map to CHS values, since the BPB can mislead us when attempting to calculate total cylinders
*/
21368320:[615,4,17] // PC AT 20Mb hard disk (type 2)
}; };
DiskAPI.MBR = { DiskAPI.MBR = {