mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-02-21 18:29:07 +00:00
InsertDisk and HD_Insert refactored to take an optional ImageInfo*
This commit is contained in:
parent
f27db49bd9
commit
524a03f071
@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "CPU.h"
|
#include "CPU.h"
|
||||||
#include "DiskImage.h"
|
#include "DiskImage.h"
|
||||||
|
#include "DiskImageHelper.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
#include "Registry.h"
|
#include "Registry.h"
|
||||||
@ -655,7 +656,7 @@ void Disk2InterfaceCard::GetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
// Pre: pszImageFilename is *not* qualified with path
|
// Pre: pszImageFilename is *not* qualified with path
|
||||||
ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary)
|
ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary, ImageInfo* pImageInfo /* = NULL */)
|
||||||
{
|
{
|
||||||
FloppyDrive* pDrive = &m_floppyDrive[drive];
|
FloppyDrive* pDrive = &m_floppyDrive[drive];
|
||||||
FloppyDisk* pFloppy = &pDrive->m_disk;
|
FloppyDisk* pFloppy = &pDrive->m_disk;
|
||||||
@ -689,11 +690,22 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageError_e Error = ImageOpen(pszImageFilename,
|
ImageError_e Error = eIMAGE_ERROR_NONE;
|
||||||
&pFloppy->m_imagehandle,
|
if (pImageInfo)
|
||||||
&pFloppy->m_bWriteProtected,
|
{
|
||||||
bCreateIfNecessary,
|
// Use already opened image
|
||||||
pFloppy->m_strFilenameInZip);
|
pFloppy->m_imagehandle = pImageInfo;
|
||||||
|
pFloppy->m_bWriteProtected = pImageInfo->bWriteProtected;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Open new image
|
||||||
|
ImageError_e Error = ImageOpen(pszImageFilename,
|
||||||
|
&pFloppy->m_imagehandle,
|
||||||
|
&pFloppy->m_bWriteProtected,
|
||||||
|
bCreateIfNecessary,
|
||||||
|
pFloppy->m_strFilenameInZip);
|
||||||
|
}
|
||||||
|
|
||||||
if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle))
|
if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle))
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ public:
|
|||||||
void GetFilenameAndPathForSaveState(std::string& filename, std::string& path);
|
void GetFilenameAndPathForSaveState(std::string& filename, std::string& path);
|
||||||
void GetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status);
|
void GetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status);
|
||||||
|
|
||||||
ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary);
|
ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary, ImageInfo* pImageInfo = NULL);
|
||||||
void EjectDisk(const int drive);
|
void EjectDisk(const int drive);
|
||||||
void UnplugDrive(const int drive);
|
void UnplugDrive(const int drive);
|
||||||
|
|
||||||
|
@ -207,8 +207,6 @@ static void NotifyInvalidImage(TCHAR* pszImageFilename)
|
|||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename);
|
|
||||||
|
|
||||||
void HD_LoadLastDiskImage(const int iDrive)
|
void HD_LoadLastDiskImage(const int iDrive)
|
||||||
{
|
{
|
||||||
_ASSERT(iDrive == HARDDISK_1 || iDrive == HARDDISK_2);
|
_ASSERT(iDrive == HARDDISK_1 || iDrive == HARDDISK_2);
|
||||||
@ -385,7 +383,7 @@ void HD_Destroy(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pre: pszImageFilename is qualified with path
|
// Pre: pszImageFilename is qualified with path
|
||||||
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
|
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename, ImageInfo* pImageInfo /* = NULL */)
|
||||||
{
|
{
|
||||||
if (pszImageFilename.empty())
|
if (pszImageFilename.empty())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -409,15 +407,26 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool bCreateIfNecessary = false; // NB. Don't allow creation of HDV files
|
ImageError_e Error = eIMAGE_ERROR_NONE;
|
||||||
const bool bExpectFloppy = false;
|
if (pImageInfo)
|
||||||
const bool bIsHarddisk = true;
|
{
|
||||||
ImageError_e Error = ImageOpen(pszImageFilename,
|
// Use already opened image
|
||||||
&g_HardDisk[iDrive].imagehandle,
|
g_HardDisk[iDrive].imagehandle = pImageInfo;
|
||||||
&g_HardDisk[iDrive].bWriteProtected,
|
g_HardDisk[iDrive].bWriteProtected = pImageInfo->bWriteProtected;
|
||||||
bCreateIfNecessary,
|
}
|
||||||
g_HardDisk[iDrive].strFilenameInZip, // TODO: Use this
|
else
|
||||||
bExpectFloppy);
|
{
|
||||||
|
// Open new image
|
||||||
|
const bool bCreateIfNecessary = false; // NB. Don't allow creation of HDV files
|
||||||
|
const bool bExpectFloppy = false;
|
||||||
|
const bool bIsHarddisk = true;
|
||||||
|
Error = ImageOpen(pszImageFilename,
|
||||||
|
&g_HardDisk[iDrive].imagehandle,
|
||||||
|
&g_HardDisk[iDrive].bWriteProtected,
|
||||||
|
bCreateIfNecessary,
|
||||||
|
g_HardDisk[iDrive].strFilenameInZip, // TODO: Use this
|
||||||
|
bExpectFloppy);
|
||||||
|
}
|
||||||
|
|
||||||
g_HardDisk[iDrive].hd_imageloaded = (Error == eIMAGE_ERROR_NONE);
|
g_HardDisk[iDrive].hd_imageloaded = (Error == eIMAGE_ERROR_NONE);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
void HD_Reset(void);
|
void HD_Reset(void);
|
||||||
void HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot);
|
void HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot);
|
||||||
bool HD_Select(const int iDrive);
|
bool HD_Select(const int iDrive);
|
||||||
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename);
|
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename, ImageInfo* pImageInfo = NULL);
|
||||||
void HD_Unplug(const int iDrive);
|
void HD_Unplug(const int iDrive);
|
||||||
bool HD_IsDriveUnplugged(const int iDrive);
|
bool HD_IsDriveUnplugged(const int iDrive);
|
||||||
void HD_LoadLastDiskImage(const int iDrive);
|
void HD_LoadLastDiskImage(const int iDrive);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user