--- previous/src/memorySnapShot.c 2018/04/24 19:25:10 1.1 +++ previous/src/memorySnapShot.c 2018/04/24 19:25:26 1.1.1.2 @@ -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; } @@ -219,15 +226,32 @@ void MemorySnapShot_Capture(const char * { /* Capture each files details */ Configuration_MemorySnapShot_Capture(true); +// TOS_MemorySnapShot_Capture(true); // STMemory_MemorySnapShot_Capture(true); +// FDC_MemorySnapShot_Capture(true); +// Floppy_MemorySnapShot_Capture(true); +// GemDOS_MemorySnapShot_Capture(true); +// IKBD_MemorySnapShot_Capture(true); CycInt_MemorySnapShot_Capture(true); Cycles_MemorySnapShot_Capture(true); M68000_MemorySnapShot_Capture(true); +// MFP_MemorySnapShot_Capture(true); +// PSG_MemorySnapShot_Capture(true); +// Sound_MemorySnapShot_Capture(true); Video_MemorySnapShot_Capture(true); +// Blitter_MemorySnapShot_Capture(true); +// DmaSnd_MemorySnapShot_Capture(true); +// Crossbar_MemorySnapShot_Capture(true); +// VIDEL_MemorySnapShot_Capture(true); +// DSP_MemorySnapShot_Capture(true); DebugUI_MemorySnapShot_Capture(pszFileName, true); - +// IoMem_MemorySnapShot_Capture(true); /* And close */ MemorySnapShot_CloseFile(); + } else { + /* just canceled? */ + if (!bCaptureError) + return; } /* Did error */ @@ -248,6 +272,7 @@ void MemorySnapShot_Restore(const char * if (MemorySnapShot_OpenFile(pszFileName, false)) { Configuration_MemorySnapShot_Capture(false); +// TOS_MemorySnapShot_Capture(false); /* Reset emulator to get things running */ IoMem_UnInit(); IoMem_Init(); @@ -255,14 +280,30 @@ void MemorySnapShot_Restore(const char * /* Capture each files details */ // STMemory_MemorySnapShot_Capture(false); +// FDC_MemorySnapShot_Capture(false); +// Floppy_MemorySnapShot_Capture(false); +// GemDOS_MemorySnapShot_Capture(false); +// IKBD_MemorySnapShot_Capture(false); CycInt_MemorySnapShot_Capture(false); Cycles_MemorySnapShot_Capture(false); M68000_MemorySnapShot_Capture(false); +// MFP_MemorySnapShot_Capture(false); +// PSG_MemorySnapShot_Capture(false); +// Sound_MemorySnapShot_Capture(false); Video_MemorySnapShot_Capture(false); +// Blitter_MemorySnapShot_Capture(false); +// DmaSnd_MemorySnapShot_Capture(false); +// Crossbar_MemorySnapShot_Capture(false); +// VIDEL_MemorySnapShot_Capture(false); +// DSP_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? */