mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-21 07:17:41 +00:00
Write support for WOZ1/WOZ2 images (#756)
Also: - Allow creation of a blank (WOZ2) image - multi-zip support extended to scan for the first valid image (useful for most woz-a-day zips which have at least 2 entries and were previously failing)
This commit is contained in:
+13
-25
@@ -63,7 +63,7 @@ ImageError_e ImageOpen( const std::string & pszImageFilename,
|
||||
ImageError_e Err = pImageInfo->pImageHelper->Open(pszImageFilename.c_str(), pImageInfo, bCreateIfNecessary, strFilenameInZip);
|
||||
if (Err != eIMAGE_ERROR_NONE)
|
||||
{
|
||||
ImageClose(*ppImageInfo, true);
|
||||
ImageClose(*ppImageInfo);
|
||||
*ppImageInfo = NULL;
|
||||
return Err;
|
||||
}
|
||||
@@ -83,9 +83,6 @@ ImageError_e ImageOpen( const std::string & pszImageFilename,
|
||||
|
||||
pImageInfo->uNumTracks = sg_DiskImageHelper.GetNumTracksInImage(pImageInfo->pImageType);
|
||||
|
||||
for (UINT uTrack = 0; uTrack < pImageInfo->uNumTracks; uTrack++)
|
||||
pImageInfo->ValidTrack[uTrack] = (pImageInfo->uImageSize > 0) ? 1 : 0;
|
||||
|
||||
*pWriteProtected = pImageInfo->bWriteProtected;
|
||||
|
||||
return eIMAGE_ERROR_NONE;
|
||||
@@ -93,25 +90,9 @@ ImageError_e ImageOpen( const std::string & pszImageFilename,
|
||||
|
||||
//===========================================================================
|
||||
|
||||
void ImageClose(ImageInfo* const pImageInfo, const bool bOpenError /*=false*/)
|
||||
void ImageClose(ImageInfo* const pImageInfo)
|
||||
{
|
||||
bool bDeleteFile = false;
|
||||
|
||||
if (!bOpenError)
|
||||
{
|
||||
for (UINT uTrack = 0; uTrack < pImageInfo->uNumTracks; uTrack++)
|
||||
{
|
||||
if (!pImageInfo->ValidTrack[uTrack])
|
||||
{
|
||||
// TODO: Comment using info from this URL:
|
||||
// http://groups.google.de/group/comp.emulators.apple2/msg/7a1b9317e7905152
|
||||
bDeleteFile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pImageInfo->pImageHelper->Close(pImageInfo, bDeleteFile);
|
||||
pImageInfo->pImageHelper->Close(pImageInfo);
|
||||
|
||||
delete pImageInfo;
|
||||
}
|
||||
@@ -162,7 +143,7 @@ void ImageReadTrack( ImageInfo* const pImageInfo,
|
||||
|
||||
const UINT track = pImageInfo->pImageType->PhaseToTrack(phase);
|
||||
|
||||
if (pImageInfo->pImageType->AllowRW() && pImageInfo->ValidTrack[track])
|
||||
if (pImageInfo->pImageType->AllowRW())
|
||||
{
|
||||
pImageInfo->pImageType->Read(pImageInfo, phase, pTrackImageBuffer, pNibbles, pBitCount, enhanceDisk);
|
||||
}
|
||||
@@ -190,7 +171,14 @@ void ImageWriteTrack( ImageInfo* const pImageInfo,
|
||||
if (pImageInfo->pImageType->AllowRW() && !pImageInfo->bWriteProtected)
|
||||
{
|
||||
pImageInfo->pImageType->Write(pImageInfo, phase, pTrackImageBuffer, nNibbles);
|
||||
pImageInfo->ValidTrack[track] = 1;
|
||||
|
||||
eImageType imageType = pImageInfo->pImageType->GetType();
|
||||
if (imageType == eImageWOZ1 || imageType == eImageWOZ2)
|
||||
{
|
||||
DWORD dummy;
|
||||
bool res = sg_DiskImageHelper.WOZUpdateInfo(pImageInfo, dummy);
|
||||
_ASSERT(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +222,7 @@ bool ImageIsWriteProtected(ImageInfo* const pImageInfo)
|
||||
|
||||
bool ImageIsMultiFileZip(ImageInfo* const pImageInfo)
|
||||
{
|
||||
return pImageInfo ? (pImageInfo->uNumEntriesInZip > 1) : false;
|
||||
return pImageInfo ? (pImageInfo->uNumValidImagesInZip > 1) : false;
|
||||
}
|
||||
|
||||
const std::string & ImageGetPathname(ImageInfo* const pImageInfo)
|
||||
|
||||
Reference in New Issue
Block a user