Added an empty 10Mb disk image formatted by PC-DOS 2.0 (currently used by one machine: 5160/cga/640kb); also fixed some issues uncovered in the process of creating the disk image (eg, a bug in the HDC's save logic when no image has been loaded), and made some fixes and optimizations in DiskDump

This commit is contained in:
Jeff Parsons 2017-06-01 15:32:17 -07:00 committed by Jeff Parsons
commit 3e1aa196bd
13 changed files with 1871 additions and 1832 deletions

View file

@ -340,7 +340,8 @@ class FDC extends Component {
var drive = fdc.aDrives[iDriveSelected];
if (drive) {
/*
* Note the similarity (and hence factoring opportunity) between this code and the HDC's "saveHD*" binding.
* Note the similarity (and hence factoring opportunity) between this code and the HDC's
* "saveHD*" binding.
*/
var disk = drive.disk;
if (disk) {

View file

@ -134,11 +134,22 @@ class HDC extends Component {
var drive = hdc.aDrives && hdc.aDrives[iDrive];
if (drive && drive.disk) {
/*
* Note the similarity (and hence factoring opportunity) between this code and the FDC's "saveDisk" binding.
* Note the similarity (and hence factoring opportunity) between this code and the FDC's
* "saveDisk" binding.
*
* One important difference between the FDC and the HDC is that an FDC may or may not contain
* a disk, whereas an HDC always contains a disk. However, the contents of an HDC's disk may
* never have been initialized with the contents of an external disk image, and therefore the
* disk's sDiskFile/sDiskPath properties may be undefined. sDiskName should always be defined
* though, defaulting to the name of the drive (eg, "10Mb Hard Disk").
*/
var disk = drive.disk;
if (DEBUG) hdc.println("saving disk " + disk.sDiskPath + "...");
var sAlert = Web.downloadFile(disk.encodeAsBase64(), "octet-stream", true, disk.sDiskFile.replace(".json", ".img"));
var sDiskName = disk.sDiskFile || disk.sDiskName;
var i = sDiskName.lastIndexOf('.');
if (i >= 0) sDiskName = sDiskName.substr(0, i);
sDiskName += ".img";
if (DEBUG) hdc.println("saving disk " + sDiskName + "...");
var sAlert = Web.downloadFile(disk.encodeAsBase64(), "octet-stream", true, sDiskName);
Component.alertUser(sAlert);
} else {
hdc.notice("Hard drive " + iDrive + " is not available.");