/** * Eject all disk image from floppy drives - call when quit. * Return true if there was something to eject. */ static bool Floppy_EjectBothDrives(void) { bool bEjectedA, bEjectedB; /* Eject disk images from drives 'A' and 'B' */ bEjectedA = Floppy_EjectDiskFromDrive(0); bEjectedB = Floppy_EjectDiskFromDrive(1); return bEjectedA || bEjectedB; }
/** * Insert previously set disk file image into floppy drive. * The WHOLE image is copied into Hatari drive buffers, and * uncompressed if necessary. * Return TRUE on success, false otherwise. */ bool Floppy_InsertDiskIntoDrive(int Drive) { long nImageBytes = 0; char *filename; /* Eject disk, if one is inserted (doesn't inform user) */ assert(Drive >= 0 && Drive < MAX_FLOPPYDRIVES); Floppy_EjectDiskFromDrive(Drive); filename = ConfigureParams.DiskImage.szDiskFileName[Drive]; if (!filename[0]) { return true; /* only do eject */ } if (!File_Exists(filename)) { Log_AlertDlg(LOG_INFO, "Image '%s' not found", filename); return false; } /* Check disk image type and read the file: */ if (MSA_FileNameIsMSA(filename, true)) EmulationDrives[Drive].pBuffer = MSA_ReadDisk(filename, &nImageBytes); else if (ST_FileNameIsST(filename, true)) EmulationDrives[Drive].pBuffer = ST_ReadDisk(filename, &nImageBytes); else if (DIM_FileNameIsDIM(filename, true)) EmulationDrives[Drive].pBuffer = DIM_ReadDisk(filename, &nImageBytes); else if (ZIP_FileNameIsZIP(filename)) { const char *zippath = ConfigureParams.DiskImage.szDiskZipPath[Drive]; EmulationDrives[Drive].pBuffer = ZIP_ReadDisk(filename, zippath, &nImageBytes); } if (EmulationDrives[Drive].pBuffer == NULL) { return false; } /* Store image filename (required for ejecting the disk later!) */ strcpy(EmulationDrives[Drive].sFileName, filename); /* Store size and set drive states */ EmulationDrives[Drive].nImageBytes = nImageBytes; EmulationDrives[Drive].bDiskInserted = true; EmulationDrives[Drive].bContentsChanged = false; EmulationDrives[Drive].bOKToSave = Floppy_IsBootSectorOK(Drive); Floppy_DriveTransitionSetState ( Drive , FLOPPY_DRIVE_TRANSITION_STATE_INSERT ); Log_Printf(LOG_INFO, "Inserted disk '%s' to drive %c:.", filename, 'A'+Drive); return true; }