2008-08-06 01:09:59 +00:00
|
|
|
/****************************************************************************
|
2010-01-27 22:20:37 +00:00
|
|
|
* Snes9x Nintendo Wii/Gamecube Port
|
2008-08-13 22:44:59 +00:00
|
|
|
*
|
|
|
|
* softdev July 2006
|
|
|
|
* crunchy2 May 2007-July 2007
|
2008-11-12 07:50:39 +00:00
|
|
|
* Michniewski 2008
|
2010-01-27 22:20:37 +00:00
|
|
|
* Tantric 2008-2010
|
2008-08-13 22:44:59 +00:00
|
|
|
*
|
|
|
|
* freeze.cpp
|
2008-09-12 05:28:40 +00:00
|
|
|
***************************************************************************/
|
|
|
|
|
2009-02-07 03:01:10 +00:00
|
|
|
#include <malloc.h>
|
2008-08-06 01:09:59 +00:00
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
2009-03-11 17:28:37 +00:00
|
|
|
|
2010-03-21 23:43:54 +00:00
|
|
|
#include "snes9xgx.h"
|
2008-12-18 18:36:30 +00:00
|
|
|
#include "fileop.h"
|
2009-03-11 17:28:37 +00:00
|
|
|
#include "filebrowser.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "video.h"
|
2010-03-21 23:43:54 +00:00
|
|
|
#include "utils/pngu.h"
|
|
|
|
|
|
|
|
#include "snes9x/snes9x.h"
|
|
|
|
#include "snes9x/port.h"
|
|
|
|
#include "snes9x/memmap.h"
|
|
|
|
#include "snes9x/snapshot.h"
|
|
|
|
#include "snes9x/language.h"
|
2008-08-06 01:09:59 +00:00
|
|
|
|
2010-01-27 22:08:56 +00:00
|
|
|
bool8 S9xOpenSnapshotFile(const char *filepath, bool8 readonly, STREAM *file)
|
2009-11-30 08:14:38 +00:00
|
|
|
{
|
2010-01-27 22:08:56 +00:00
|
|
|
return FALSE;
|
2008-08-06 01:09:59 +00:00
|
|
|
}
|
|
|
|
|
2010-01-27 22:08:56 +00:00
|
|
|
void S9xCloseSnapshotFile(STREAM s)
|
2009-11-30 08:14:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* SaveSnapshot
|
|
|
|
***************************************************************************/
|
2010-01-27 22:08:56 +00:00
|
|
|
|
2008-08-06 01:09:59 +00:00
|
|
|
int
|
2009-11-25 06:35:14 +00:00
|
|
|
SaveSnapshot (char * filepath, bool silent)
|
2008-08-06 01:09:59 +00:00
|
|
|
{
|
2009-10-01 22:35:12 +00:00
|
|
|
int device;
|
2010-06-03 23:15:34 +00:00
|
|
|
|
2009-10-01 22:35:12 +00:00
|
|
|
if(!FindDevice(filepath, &device))
|
2008-11-12 07:50:39 +00:00
|
|
|
return 0;
|
2008-08-07 03:25:02 +00:00
|
|
|
|
2010-06-03 23:15:34 +00:00
|
|
|
// save screenshot
|
|
|
|
if(gameScreenPngSize > 0)
|
2009-04-15 05:55:17 +00:00
|
|
|
{
|
2010-06-03 23:15:34 +00:00
|
|
|
char screenpath[1024];
|
2011-03-20 17:17:51 +00:00
|
|
|
strcpy(screenpath, filepath);
|
2010-06-03 23:15:34 +00:00
|
|
|
screenpath[strlen(screenpath)-4] = 0;
|
|
|
|
sprintf(screenpath, "%s.png", screenpath);
|
|
|
|
SaveFile((char *)gameScreenPng, screenpath, gameScreenPngSize, silent);
|
2009-04-15 05:55:17 +00:00
|
|
|
}
|
|
|
|
|
2010-01-27 22:08:56 +00:00
|
|
|
STREAM fp = OPEN_STREAM(filepath, "wb");
|
|
|
|
|
|
|
|
if(!fp)
|
2008-08-07 03:25:02 +00:00
|
|
|
{
|
2009-11-25 06:35:14 +00:00
|
|
|
if(!silent)
|
2010-01-27 22:08:56 +00:00
|
|
|
ErrorPrompt("Save failed!");
|
|
|
|
return 0;
|
2008-08-07 03:25:02 +00:00
|
|
|
}
|
2010-01-27 22:08:56 +00:00
|
|
|
|
|
|
|
S9xFreezeToStream(fp);
|
|
|
|
CLOSE_STREAM(fp);
|
|
|
|
|
|
|
|
if(!silent)
|
|
|
|
InfoPrompt("Save successful");
|
|
|
|
return 1;
|
2008-08-06 01:09:59 +00:00
|
|
|
}
|
|
|
|
|
2009-03-11 17:28:37 +00:00
|
|
|
int
|
2009-11-25 06:35:14 +00:00
|
|
|
SaveSnapshotAuto (bool silent)
|
2009-03-11 17:28:37 +00:00
|
|
|
{
|
|
|
|
char filepath[1024];
|
|
|
|
|
2009-10-01 22:35:12 +00:00
|
|
|
if(!MakeFilePath(filepath, FILE_SNAPSHOT, Memory.ROMFilename, 0))
|
2009-03-20 08:26:10 +00:00
|
|
|
return false;
|
|
|
|
|
2009-11-25 06:35:14 +00:00
|
|
|
return SaveSnapshot(filepath, silent);
|
2009-03-11 17:28:37 +00:00
|
|
|
}
|
|
|
|
|
2008-09-12 05:28:40 +00:00
|
|
|
/****************************************************************************
|
2009-11-25 06:35:14 +00:00
|
|
|
* LoadSnapshot
|
2008-09-12 05:28:40 +00:00
|
|
|
***************************************************************************/
|
2008-08-06 01:09:59 +00:00
|
|
|
int
|
2009-11-25 06:35:14 +00:00
|
|
|
LoadSnapshot (char * filepath, bool silent)
|
2008-08-06 01:09:59 +00:00
|
|
|
{
|
2009-10-01 22:35:12 +00:00
|
|
|
int device;
|
|
|
|
|
|
|
|
if(!FindDevice(filepath, &device))
|
2009-03-11 17:28:37 +00:00
|
|
|
return 0;
|
2008-08-07 03:25:02 +00:00
|
|
|
|
2010-01-27 22:08:56 +00:00
|
|
|
STREAM fp = OPEN_STREAM(filepath, "rb");
|
2008-08-07 03:25:02 +00:00
|
|
|
|
2010-01-27 22:08:56 +00:00
|
|
|
if(!fp)
|
2008-11-12 07:50:39 +00:00
|
|
|
{
|
2010-01-27 22:08:56 +00:00
|
|
|
if(!silent)
|
|
|
|
ErrorPrompt("Unable to open snapshot!");
|
|
|
|
return 0;
|
2009-11-25 06:35:14 +00:00
|
|
|
}
|
2010-01-27 22:08:56 +00:00
|
|
|
|
|
|
|
int result = S9xUnfreezeFromStream(fp);
|
|
|
|
CLOSE_STREAM(fp);
|
|
|
|
|
|
|
|
if (result == SUCCESS)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch (result)
|
2008-08-12 03:25:16 +00:00
|
|
|
{
|
2010-01-27 22:08:56 +00:00
|
|
|
case WRONG_FORMAT:
|
|
|
|
ErrorPrompt(SAVE_ERR_WRONG_FORMAT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRONG_VERSION:
|
|
|
|
ErrorPrompt(SAVE_ERR_WRONG_VERSION);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SNAPSHOT_INCONSISTENT:
|
|
|
|
ErrorPrompt(MOVIE_ERR_SNAPSHOT_INCONSISTENT);
|
|
|
|
break;
|
2008-08-12 03:25:16 +00:00
|
|
|
}
|
2010-01-27 22:08:56 +00:00
|
|
|
return 0;
|
2008-08-06 01:09:59 +00:00
|
|
|
}
|
2009-03-11 17:28:37 +00:00
|
|
|
|
|
|
|
int
|
2009-11-25 06:35:14 +00:00
|
|
|
LoadSnapshotAuto (bool silent)
|
2009-03-11 17:28:37 +00:00
|
|
|
{
|
|
|
|
char filepath[1024];
|
|
|
|
|
2009-10-01 22:35:12 +00:00
|
|
|
if(!MakeFilePath(filepath, FILE_SNAPSHOT, Memory.ROMFilename, 0))
|
2009-03-16 06:58:50 +00:00
|
|
|
return false;
|
2009-03-11 17:28:37 +00:00
|
|
|
|
2009-11-25 06:35:14 +00:00
|
|
|
return LoadSnapshot(filepath, silent);
|
2009-03-11 17:28:37 +00:00
|
|
|
}
|
2016-02-06 14:40:46 -07:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* SavePreview
|
|
|
|
***************************************************************************/
|
|
|
|
|
2016-12-08 17:51:57 -07:00
|
|
|
int SavePreviewImg (char * filepath, bool silent)
|
2016-02-06 14:40:46 -07:00
|
|
|
{
|
|
|
|
int device;
|
|
|
|
|
|
|
|
if(!FindDevice(filepath, &device))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// save screenshot
|
|
|
|
if(gameScreenPngSize > 0)
|
|
|
|
{
|
|
|
|
char screenpath[1024];
|
|
|
|
strcpy(screenpath, filepath);
|
|
|
|
screenpath[strlen(screenpath)] = 0;
|
|
|
|
sprintf(screenpath, "%s.png", screenpath);
|
|
|
|
SaveFile((char *)gameScreenPng, screenpath, gameScreenPngSize, silent);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|