mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-09 22:29:40 +00:00
Fix: Unplugged HDD persisted correctly to Registry.
Fix: Allow growing of HDD image within zip/gzip archives.
This commit is contained in:
parent
80b502dc2b
commit
b3a6b49c50
|
@ -179,8 +179,19 @@ bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlo
|
|||
{
|
||||
if ((UINT)Offset+HD_BLOCK_SIZE > pImageInfo->uImageSize)
|
||||
{
|
||||
_ASSERT(0);
|
||||
return false;
|
||||
// Horribly inefficient! (Unzip to a normal file if you want better performance!)
|
||||
const UINT uNewImageSize = Offset+HD_BLOCK_SIZE;
|
||||
BYTE* pNewImageBuffer = new BYTE [uNewImageSize];
|
||||
_ASSERT(pNewImageBuffer);
|
||||
if (!pNewImageBuffer)
|
||||
return false;
|
||||
|
||||
memcpy(pNewImageBuffer, pImageInfo->pImageBuffer, pImageInfo->uImageSize);
|
||||
memset(&pNewImageBuffer[pImageInfo->uImageSize], 0, uNewImageSize-pImageInfo->uImageSize); // Should always be HD_BLOCK_SIZE (so this is redundant)
|
||||
|
||||
delete [] pImageInfo->pImageBuffer;
|
||||
pImageInfo->pImageBuffer = pNewImageBuffer;
|
||||
pImageInfo->uImageSize = uNewImageSize;
|
||||
}
|
||||
|
||||
memcpy(&pImageInfo->pImageBuffer[Offset], pBlockBuffer, HD_BLOCK_SIZE);
|
||||
|
|
|
@ -145,6 +145,7 @@ static void HD_CleanupDrive(const int iDrive)
|
|||
g_HardDisk[iDrive].hd_imageloaded = false;
|
||||
g_HardDisk[iDrive].imagename[0] = 0;
|
||||
g_HardDisk[iDrive].fullname[0] = 0;
|
||||
g_HardDisk[iDrive].Info.szFilename[0] = 0;
|
||||
}
|
||||
|
||||
static ImageError_e ImageOpen( LPCTSTR pszImageFilename,
|
||||
|
@ -458,9 +459,9 @@ static BYTE __stdcall HD_IO_EMUL(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG
|
|||
const bool bAppendBlocks = (pHDD->hd_diskblock * HD_BLOCK_SIZE) >= pHDD->Info.uImageSize;
|
||||
if (bAppendBlocks)
|
||||
{
|
||||
// TODO: Test this!
|
||||
ZeroMemory(pHDD->hd_buf, HD_BLOCK_SIZE);
|
||||
|
||||
// Inefficient (especially for gzip/zip files!)
|
||||
UINT uBlock = pHDD->Info.uImageSize / HD_BLOCK_SIZE;
|
||||
while (uBlock < pHDD->hd_diskblock)
|
||||
{
|
||||
|
@ -468,7 +469,6 @@ static BYTE __stdcall HD_IO_EMUL(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG
|
|||
_ASSERT(bRes);
|
||||
if (!bRes)
|
||||
break;
|
||||
pHDD->Info.uImageSize += HD_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -487,9 +487,6 @@ static BYTE __stdcall HD_IO_EMUL(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG
|
|||
pHDD->hd_error = 1;
|
||||
r = DEVICE_IO_ERROR;
|
||||
}
|
||||
|
||||
if (bAppendBlocks && bRes)
|
||||
pHDD->Info.uImageSize += HD_BLOCK_SIZE;
|
||||
}
|
||||
break;
|
||||
case 0x03: //format
|
||||
|
|
Loading…
Reference in New Issue
Block a user