--- previous/src/memorySnapShot.c 2018/04/24 19:25:10 1.1 +++ previous/src/memorySnapShot.c 2018/04/24 19:27:28 1.1.1.3 @@ -34,17 +34,19 @@ const char MemorySnapShot_fileid[] = "Ha #include "reset.h" #include "str.h" #include "nextMemory.h" +#include "screen.h" #include "video.h" +#include "statusbar.h" #define VERSION_STRING "0.0.1" /* Version number of compatible memory snapshots - Always 6 bytes (inc' NULL) */ -#define VERSION_STRING_SIZE 6 /* Size of above (inc' NULL) */ - #define COMPRESS_MEMORYSNAPSHOT /* Compress snapshots to reduce disk space used */ #ifdef COMPRESS_MEMORYSNAPSHOT +/* Remove possible conflicting mkdir declaration from cpu/sysdeps.h */ +#undef mkdir #include typedef gzFile MSS_File; @@ -122,14 +124,19 @@ static int MemorySnapShot_fwrite(MSS_Fil */ static bool MemorySnapShot_OpenFile(const char *pszFileName, bool bSave) { - char VersionString[VERSION_STRING_SIZE]; + char VersionString[] = VERSION_STRING; /* Set error */ bCaptureError = false; - /* Open file, set flag so 'MemorySnapShot_Store' can load to/save from file */ + /* after opening file, set bCaptureSave to indicate whether + * 'MemorySnapShot_Store' should load from or save to a file + */ if (bSave) { + if (!File_QueryOverwrite(pszFileName)) + return false; + /* Save */ CaptureFile = MemorySnapShot_fopen(pszFileName, "wb"); if (!CaptureFile) @@ -141,8 +148,7 @@ static bool MemorySnapShot_OpenFile(cons } bCaptureSave = true; /* Store version string */ - strcpy(VersionString, VERSION_STRING); - MemorySnapShot_Store(VersionString, VERSION_STRING_SIZE); + MemorySnapShot_Store(VersionString, sizeof(VersionString)); } else { @@ -157,13 +163,14 @@ static bool MemorySnapShot_OpenFile(cons } bCaptureSave = false; /* Restore version string */ - MemorySnapShot_Store(VersionString, VERSION_STRING_SIZE); + MemorySnapShot_Store(VersionString, sizeof(VersionString)); /* Does match current version? */ if (strcasecmp(VersionString, VERSION_STRING)) { /* No, inform user and error */ - Log_AlertDlg(LOG_ERROR, "Unable to Restore Memory State.\nFile is " - "only compatible with Hatari v%s", VersionString); + Log_AlertDlg(LOG_ERROR, "Unable to restore Hatari memory state. File\n" + "is compatible only with Hatari version %s.", + VersionString); bCaptureError = true; return false; } @@ -225,9 +232,13 @@ void MemorySnapShot_Capture(const char * M68000_MemorySnapShot_Capture(true); Video_MemorySnapShot_Capture(true); DebugUI_MemorySnapShot_Capture(pszFileName, true); - +// IoMem_MemorySnapShot_Capture(true); /* And close */ MemorySnapShot_CloseFile(); + } else { + /* just canceled? */ + if (!bCaptureError) + return; } /* Did error */ @@ -260,9 +271,13 @@ void MemorySnapShot_Restore(const char * M68000_MemorySnapShot_Capture(false); Video_MemorySnapShot_Capture(false); DebugUI_MemorySnapShot_Capture(pszFileName, false); +// IoMem_MemorySnapShot_Capture(false); /* And close */ MemorySnapShot_CloseFile(); + + /* changes may affect also info shown in statusbar */ + Statusbar_UpdateInfo(); } /* Did error? */