Bug fix: Loading save-state file (.aws) wasn't Win32-closing .dsk images in drives. Problem if Drive1 contained eg. Skyfox.dsk and you attempt to load a .aws with the same Skyfox.dsk.

Also change F11/F12 behaviour, now:
- Load save-state tries to load Prop Sheet's .aws filename first
- Save save-state tries to save as <Drive1-Filename>.aws first
This commit is contained in:
tomch 2010-08-01 19:51:11 +00:00
parent c76d1db0cd
commit 09a89c55d7
2 changed files with 31 additions and 11 deletions

View File

@ -1020,6 +1020,8 @@ DWORD DiskSetSnapshot(SS_CARD_DISK2* pSS, DWORD /*dwSlot*/)
{
bool bImageError = false;
DiskEject(i); // Remove any disk & update Registry to reflect empty drive
ZeroMemory(&g_aFloppyDisk[i], sizeof(Disk_t ));
if(pSS->Unit[i].szFileName[0] == 0x00)
continue;

View File

@ -1162,27 +1162,45 @@ static void SaveStateUpdate()
}
}
static void GetDiskBaseNameWithAWS(TCHAR* pszFilename)
{
LPCTSTR pDiskName = DiskGetBaseName(DRIVE_1);
if (pDiskName && pDiskName[0])
{
strcpy(pszFilename, pDiskName);
strcpy(&pszFilename[strlen(pDiskName)], ".aws");
}
}
// NB. OK'ing this property sheet will call Snapshot_SetFilename() with this new filename
static int SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bool bSave)
{
TCHAR szDirectory[MAX_PATH] = TEXT("");
TCHAR szFilename[MAX_PATH];
// Attempt to use drive1's image name as the name for the .aws file
LPCTSTR pDiskName0 = DiskGetBaseName(DRIVE_1);
if (pDiskName0 && pDiskName0[0])
TCHAR szFilename[MAX_PATH] = {0};
if (bSave)
{
strcpy(szFilename, pDiskName0);
strcpy(&szFilename[strlen(pDiskName0)], ".aws");
// NB. OK'ing this property sheet will call Snapshot_SetFilename() with this new filename
// Attempt to use drive1's image name as the name for the .aws file
// Else Attempt to use the Prop Sheet's filename
GetDiskBaseNameWithAWS(szFilename);
if (szFilename[0] == 0)
{
strcpy(szFilename, Snapshot_GetFilename());
}
}
else
else // Load
{
// Attempt to use the Prop Sheet's filename first
// Else attempt to use drive1's image name as the name for the .aws file
strcpy(szFilename, Snapshot_GetFilename());
if (szFilename[0] == 0)
{
GetDiskBaseNameWithAWS(szFilename);
}
}
RegLoadString(TEXT("Preferences"),REGVALUE_PREF_START_DIR,1,szDirectory,MAX_PATH);
//
OPENFILENAME ofn;