diff --git a/help/savestate.html b/help/savestate.html index e90740bc..09919567 100644 --- a/help/savestate.html +++ b/help/savestate.html @@ -45,10 +45,12 @@
  • Alternate ROM
  • Alternate video ROM
  • -

    Note: Only the file names of the disk images are stored in the .yaml file (not the - full path). This allows you to move your disk image around or distribute them. - If AppleWin can't locate the disk image(s), then it will prompt for the new - location.

    +

    + Note: Both the file name and absolute path are stored in the .yaml file. + This allows you to move your disk image around or distribute them. + If AppleWin still can't locate the disk image(s), then it will prompt for the new + location. +

    NB. Loading of the old v1 file format (.aws file) is no longer supported. Use AppleWin 1.27.13 to load it at the AppleWin start-up/logo screen, then immediately save it (and it'll be saved in the v2 format).

    diff --git a/source/Disk.cpp b/source/Disk.cpp index 49693501..226457a9 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -2217,7 +2217,8 @@ BYTE __stdcall Disk2InterfaceCard::IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE // 6: Added: Drive Connected & Motor On Cycle // 7: Deprecated SS_YAML_KEY_LSS_RESET_SEQUENCER, SS_YAML_KEY_DISK_ACCESSED // 8: Added: deferred stepper: event, address & cycle -static const UINT kUNIT_VERSION = 8; +// 9: Added: absolute path +static const UINT kUNIT_VERSION = 9; #define SS_YAML_VALUE_CARD_DISK2 "Disk][" @@ -2249,6 +2250,7 @@ static const UINT kUNIT_VERSION = 8; #define SS_YAML_KEY_FLOPPY "Floppy" #define SS_YAML_KEY_FILENAME "Filename" +#define SS_YAML_KEY_ABSOLUTE_PATH "Absolute Path" #define SS_YAML_KEY_BYTE "Byte" #define SS_YAML_KEY_NIBBLES "Nibbles" #define SS_YAML_KEY_BIT_OFFSET "Bit Offset" @@ -2271,6 +2273,7 @@ void Disk2InterfaceCard::SaveSnapshotFloppy(YamlSaveHelper& yamlSaveHelper, UINT { YamlSaveHelper::Label label(yamlSaveHelper, "%s:\n", SS_YAML_KEY_FLOPPY); yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, m_floppyDrive[unit].m_disk.m_fullname); + yamlSaveHelper.SaveString(SS_YAML_KEY_ABSOLUTE_PATH, ImageGetPathname(m_floppyDrive[unit].m_disk.m_imagehandle)); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_BYTE, m_floppyDrive[unit].m_disk.m_byte); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_NIBBLES, m_floppyDrive[unit].m_disk.m_nibbles); yamlSaveHelper.SaveHexUint32(SS_YAML_KEY_BIT_OFFSET, m_floppyDrive[unit].m_disk.m_bitOffset); // v4 @@ -2328,14 +2331,26 @@ void Disk2InterfaceCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper) bool Disk2InterfaceCard::LoadSnapshotFloppy(YamlLoadHelper& yamlLoadHelper, UINT unit, UINT version, std::vector& track) { - std::string filename = yamlLoadHelper.LoadString(SS_YAML_KEY_FILENAME); + const std::string simpleFilename = yamlLoadHelper.LoadString(SS_YAML_KEY_FILENAME); + const std::string absolutePath = version >= 9 ? yamlLoadHelper.LoadString(SS_YAML_KEY_ABSOLUTE_PATH) : ""; + + std::string filename = simpleFilename; bool bImageError = filename.empty(); if (!bImageError) { DWORD dwAttributes = GetFileAttributes(filename.c_str()); + if (dwAttributes == INVALID_FILE_ATTRIBUTES && !absolutePath.empty()) + { + // try the absolute path if present + filename = absolutePath; + dwAttributes = GetFileAttributes(filename.c_str()); + } + if (dwAttributes == INVALID_FILE_ATTRIBUTES) { + // ignore absolute name when opening the file dialog + filename = simpleFilename; // Get user to browse for file UserSelectNewDiskImage(unit, filename.c_str()); diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 077a048a..f7725098 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -1151,7 +1151,8 @@ bool HarddiskInterfaceCard::ImageSwap(void) // 4: Updated $Csnn firmware to fix GH#1264 // 5: Added: SP Status Code, FIFO Index & 256-byte firmware // Units are 1-based (up to v4 they were 0-based) -static const UINT kUNIT_VERSION = 5; +// 6: Added: absolute path +static const UINT kUNIT_VERSION = 6; #define SS_YAML_VALUE_CARD_HDD "Generic HDD" @@ -1160,6 +1161,7 @@ static const UINT kUNIT_VERSION = 5; #define SS_YAML_KEY_HDDUNIT "Unit" #define SS_YAML_KEY_FILENAME "Filename" +#define SS_YAML_KEY_ABSOLUTE_PATH "Absolute Path" #define SS_YAML_KEY_ERROR "Error" #define SS_YAML_KEY_MEMBLOCK "MemBlock" #define SS_YAML_KEY_DISKBLOCK "DiskBlock" @@ -1185,6 +1187,7 @@ void HarddiskInterfaceCard::SaveSnapshotHDDUnit(YamlSaveHelper& yamlSaveHelper, YamlSaveHelper::Label label(yamlSaveHelper, "%s%d:\n", SS_YAML_KEY_HDDUNIT, baseUnitNum + unit); yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, m_hardDiskDrive[unit].m_fullname); + yamlSaveHelper.SaveString(SS_YAML_KEY_ABSOLUTE_PATH, ImageGetPathname(m_hardDiskDrive[unit].m_imagehandle)); yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_ERROR, m_hardDiskDrive[unit].m_error); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_MEMBLOCK, m_hardDiskDrive[unit].m_memblock); yamlSaveHelper.SaveHexUint32(SS_YAML_KEY_DISKBLOCK, m_hardDiskDrive[unit].m_diskblock); @@ -1238,7 +1241,8 @@ bool HarddiskInterfaceCard::LoadSnapshotHDDUnit(YamlLoadHelper& yamlLoadHelper, m_hardDiskDrive[unit].m_status_next = DISK_STATUS_OFF; m_hardDiskDrive[unit].m_status_prev = DISK_STATUS_OFF; - std::string filename = yamlLoadHelper.LoadString(SS_YAML_KEY_FILENAME); + const std::string simpleFilename = yamlLoadHelper.LoadString(SS_YAML_KEY_FILENAME); + const std::string absolutePath = version >= 6 ? yamlLoadHelper.LoadString(SS_YAML_KEY_ABSOLUTE_PATH) : ""; m_hardDiskDrive[unit].m_error = yamlLoadHelper.LoadUint(SS_YAML_KEY_ERROR); m_hardDiskDrive[unit].m_memblock = yamlLoadHelper.LoadUint(SS_YAML_KEY_MEMBLOCK); m_hardDiskDrive[unit].m_diskblock = yamlLoadHelper.LoadUint(SS_YAML_KEY_DISKBLOCK); @@ -1260,11 +1264,21 @@ bool HarddiskInterfaceCard::LoadSnapshotHDDUnit(YamlLoadHelper& yamlLoadHelper, bool userSelectedImageFolder = false; + std::string filename = simpleFilename; if (!filename.empty()) { DWORD dwAttributes = GetFileAttributes(filename.c_str()); + if (dwAttributes == INVALID_FILE_ATTRIBUTES && !absolutePath.empty()) + { + // try the absolute path if present + filename = absolutePath; + dwAttributes = GetFileAttributes(filename.c_str()); + } + if (dwAttributes == INVALID_FILE_ATTRIBUTES) { + // ignore absolute name when opening the file dialog + filename = simpleFilename; // Get user to browse for file userSelectedImageFolder = SelectImage(unit, filename.c_str());