improved SaveSnapshot performance ($552)

[[Split portion of a mixed commit.]]
This commit is contained in:
ansstuff 2012-11-12 12:21:59 +00:00
parent caf491317d
commit 80bd1aaf02
5 changed files with 13 additions and 5 deletions

Binary file not shown.

View File

@ -507,6 +507,8 @@ endlseq:
DoDebuggerDataReload(); // Reloads data without reopening window DoDebuggerDataReload(); // Reloads data without reopening window
#endif #endif
ResetScreenshotsCounter();
return GameInfo; return GameInfo;
} }

View File

@ -69,6 +69,8 @@ extern uint32 cur_input_display;
bool oldInputDisplay = false; bool oldInputDisplay = false;
unsigned int lastu = 0;
std::string AsSnapshotName =""; //adelikat:this will set the snapshot name when for s savesnapshot as function std::string AsSnapshotName =""; //adelikat:this will set the snapshot name when for s savesnapshot as function
void FCEUI_SetSnapshotAsName(std::string name) { AsSnapshotName = name; } void FCEUI_SetSnapshotAsName(std::string name) { AsSnapshotName = name; }
@ -544,8 +546,6 @@ int GetScreenPixelPalette(int x, int y, bool usebackup) {
int SaveSnapshot(void) int SaveSnapshot(void)
{ {
unsigned int lastu=0;
int totallines=FSettings.LastSLine-FSettings.FirstSLine+1; int totallines=FSettings.LastSLine-FSettings.FirstSLine+1;
int x,u,y; int x,u,y;
FILE *pp=NULL; FILE *pp=NULL;
@ -555,14 +555,13 @@ int SaveSnapshot(void)
if(!(compmem=(uint8 *)FCEU_malloc(compmemsize))) if(!(compmem=(uint8 *)FCEU_malloc(compmemsize)))
return 0; return 0;
for(u=lastu;u<99999;u++) for (u = lastu; u < 99999; ++u)
{ {
pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"rb"); pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"rb");
if(pp==NULL) break; if(pp==NULL) break;
fclose(pp); fclose(pp);
} }
lastu = u;
lastu=u;
if(!(pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"wb"))) if(!(pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"wb")))
{ {
@ -737,6 +736,12 @@ PNGerr:
fclose(pp); fclose(pp);
return(0); return(0);
} }
// called when another ROM is opened
void ResetScreenshotsCounter()
{
lastu = 0;
}
uint64 FCEUD_GetTime(void); uint64 FCEUD_GetTime(void);
uint64 FCEUD_GetTimeFreq(void); uint64 FCEUD_GetTimeFreq(void);
bool Show_FPS = false; bool Show_FPS = false;

View File

@ -4,6 +4,7 @@ int FCEU_InitVirtualVideo(void);
void FCEU_KillVirtualVideo(void); void FCEU_KillVirtualVideo(void);
int SaveSnapshot(void); int SaveSnapshot(void);
int SaveSnapshot(char[]); int SaveSnapshot(char[]);
void ResetScreenshotsCounter();
uint32 GetScreenPixel(int x, int y, bool usebackup); uint32 GetScreenPixel(int x, int y, bool usebackup);
int GetScreenPixelPalette(int x, int y, bool usebackup); int GetScreenPixelPalette(int x, int y, bool usebackup);
extern uint8 *XBuf; extern uint8 *XBuf;

Binary file not shown.