change extensions to fm2 (but we still claim we'll load fcm; even though it is not supported now)

added dialog accelerator framework
support new improved savestate-with-movie-running naming convention
This commit is contained in:
zeromus 2008-05-26 07:34:40 +00:00
parent ac025d7d65
commit d998a3c015
10 changed files with 164 additions and 101 deletions

View File

@ -280,10 +280,12 @@ int BlockingCheck()
{
if( GetMessage( &msg, 0, 0, 0)>0 )
{
//other accelerator capable dialogs could be added here
extern HWND hwndMemWatch;
int accelerated = 0;
/*if(hwndMemWatch)
accelerated = TranslateAccelerator(hwndMemWatch,fceu_hAccel,&msg);*/
if(IsChild(hwndMemWatch,msg.hwnd))
accelerated = TranslateAccelerator(hwndMemWatch,fceu_hAccel,&msg);
if(!accelerated)
{
TranslateMessage(&msg);
@ -567,7 +569,7 @@ int main(int argc,char *argv[])
ApplyDefaultCommandMapping();
fceu_hInstance = GetModuleHandle(0);
LoadAccelerators(fceu_hInstance,"IDR_ACCELERATOR1");
fceu_hAccel = LoadAccelerators(fceu_hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1));
// Get the base directory
GetBaseDirectory();

View File

@ -771,9 +771,6 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
//Menu Items
switch(LOWORD(wParam))
{
case ID_ACCELERATOR_CTRL_O:
MessageBox(hwndDlg,"Someone hit ctrl+o","test",0);
break;
case 600: //First item in recent menu
OpenMemwatchRecentFile(0);
break;
@ -793,7 +790,7 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
case MEMW_FILE_CLOSE:
CloseMemoryWatch();
break;
case MEMW_FILE_OPEN:
LoadMemWatch();
break;

View File

@ -149,46 +149,52 @@ void UpdateReplayDialog(HWND hwndDlg)
SendDlgItemMessage(hwndDlg,IDC_CHECK_READONLY,BM_SETCHECK,info.read_only ? BST_CHECKED : (ReplayDialogReadOnlyStatus ? BST_CHECKED : BST_UNCHECKED), 0);
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),info.poweron ? "Power-On" : (info.reset?"Soft-Reset":"Savestate"));
if(info.movie_version > 1)
{
//-----------
//mbg 5/26/08 - getting rid of old movie formats
//if(info.movie_version > 1)
//{
char emuStr[128];
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),info.name_of_rom_used.c_str());
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),md5_asciistr(info.md5_of_rom_used));
if(info.emu_version_used > 64)
//if(info.emu_version_used > 64)
sprintf(emuStr, "FCEU %d.%02d.%02d%s", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100, info.emu_version_used < 9813 ? " (blip)" : "");
else
{
if(info.emu_version_used == 1)
strcpy(emuStr, "Famtasia");
else if(info.emu_version_used == 2)
strcpy(emuStr, "Nintendulator");
else if(info.emu_version_used == 3)
strcpy(emuStr, "VirtuaNES");
else
{
strcpy(emuStr, "(unknown)");
char* dot = strrchr(fn,'.');
if(dot)
{
if(!stricmp(dot,".fmv"))
strcpy(emuStr, "Famtasia? (unknown version)");
else if(!stricmp(dot,".nmv"))
strcpy(emuStr, "Nintendulator? (unknown version)");
else if(!stricmp(dot,".vmv"))
strcpy(emuStr, "VirtuaNES? (unknown version)");
else if(!stricmp(dot,".fcm"))
strcpy(emuStr, "FCEU? (unknown version)");
}
}
}
//else
//{
// if(info.emu_version_used == 1)
// strcpy(emuStr, "Famtasia");
// else if(info.emu_version_used == 2)
// strcpy(emuStr, "Nintendulator");
// else if(info.emu_version_used == 3)
// strcpy(emuStr, "VirtuaNES");
// else
// {
// strcpy(emuStr, "(unknown)");
// char* dot = strrchr(fn,'.');
// if(dot)
// {
// if(!stricmp(dot,".fmv"))
// strcpy(emuStr, "Famtasia? (unknown version)");
// else if(!stricmp(dot,".nmv"))
// strcpy(emuStr, "Nintendulator? (unknown version)");
// else if(!stricmp(dot,".vmv"))
// strcpy(emuStr, "VirtuaNES? (unknown version)");
// else if(!stricmp(dot,".fcm"))
// strcpy(emuStr, "FCEU? (unknown version)");
// }
// }
//}
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),emuStr);
}
else
{
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),"unknown");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),"unknown");
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),"FCEU 0.98.10 (blip)");
}
//}
//else
//{
// SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),"unknown");
// SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),"unknown");
// SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),"FCEU 0.98.10 (blip)");
//}
//--------------------
SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_CURRCHECKSUM),md5_asciistr(GameInfo->MD5));
EnableWindow(GetDlgItem(hwndDlg,1),TRUE); // enable OK
@ -314,7 +320,7 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
// filter out everything that's not *.fcm, *.fmv, *.vmv, or *.nmv
// filter out everything that's not *.fcm, *.fm2
// (because FindFirstFile is too dumb to do that)
{
char* dot=strrchr(wfd.cFileName,'.');
@ -325,7 +331,7 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
int k, extlen=strlen(ext);
for(k=0;k<extlen;k++)
ext[k]=tolower(ext[k]);
if(strcmp(ext,"fcm") && strcmp(ext,"fmv") && strcmp(ext,"vmv") && strcmp(ext,"nmv"))
if(strcmp(ext,"fcm") && strcmp(ext,"fm2"))
continue;
}
@ -339,25 +345,25 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
sprintf(filename, "%s%s", globBase, wfd.cFileName);
char* dot = strrchr(filename, '.');
int fcm = (dot && tolower(dot[1]) == 'f' && tolower(dot[2]) == 'c' && tolower(dot[3]) == 'm');
if(fcm && !FCEUI_MovieGetInfo(filename, &info))
if(!FCEUI_MovieGetInfo(filename, &info))
continue;
//------------
//attempt to match the movie with the rom
//first, try matching md5
//then try matching base name
char md51 [256];
char md52 [256];
if(fcm) strcpy(md51, md5_asciistr(GameInfo->MD5));
if(fcm) strcpy(md52, md5_asciistr(info.md5_of_rom_used));
if(!fcm || strcmp(md51, md52))
strcpy(md51, md5_asciistr(GameInfo->MD5));
strcpy(md52, md5_asciistr(info.md5_of_rom_used));
if(strcmp(md51, md52))
{
if(fcm)
{
unsigned int k, count1=0, count2=0; //mbg merge 7/17/06 changed to uint
for(k=0;k<strlen(md51);k++) count1 += md51[k]-'0';
for(k=0;k<strlen(md52);k++) count2 += md52[k]-'0';
if(count1 && count2)
continue;
}
unsigned int k, count1=0, count2=0; //mbg merge 7/17/06 changed to uint
for(k=0;k<strlen(md51);k++) count1 += md51[k]-'0';
for(k=0;k<strlen(md52);k++) count2 += md52[k]-'0';
if(count1 && count2)
continue;
char* tlen1=strstr(wfd.cFileName, " (");
char* tlen2=strstr(FileBase, " (");
@ -373,6 +379,8 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
continue;
}
}
//-------------
//if we get here, then we had a match
char relative[MAX_PATH];
AbsoluteToRelative(relative, filename, BaseDirectory);
@ -445,12 +453,12 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFilter = "Supported Movie Files (*.fcm|*.fmv|*.nmv|*.vmv)\0*.fcm;*.fmv;*.nmv;*.vmv\0FCEU Movie Files (*.fcm)\0*.fcm\0Famtasia Movie Files (*.fmv)\0*.fmv\0Nintendulator Movie Files (*.nmv)\0*.nmv\0VirtuaNES Movie Files (*.vmv)\0*.vmv\0All files(*.*)\0*.*\0\0";
ofn.lpstrFilter = "Supported Movie Files (*.fcm|*.fm2)\0*.fcm;*.fm2\0FCEUX Movie Files (*.fm2)\0*.fm2\0FCEU Movie Files (*.fcm)\0*.fcm\0All files(*.*)\0*.*\0\0";
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrInitialDir = pn;
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "fcm";
ofn.lpstrDefExt = "fm2";
ofn.lpstrTitle = "Replay Movie from File";
if(GetOpenFileName(&ofn))
@ -612,7 +620,7 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
free(p->szFilename);
p->szFilename = 0;
/* Populate the "record from..." dialog */
// Populate the "record from..." dialog
{
char* findGlob=FCEU_MakeFName(FCEUMKF_STATEGLOB, 0, 0);
WIN32_FIND_DATA wfd;
@ -633,7 +641,7 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
continue;
if (strlen(wfd.cFileName) < 4 ||
!strcmp(wfd.cFileName + (strlen(wfd.cFileName) - 4), ".fcm"))
!strcmp(wfd.cFileName + (strlen(wfd.cFileName) - 4), ".fm2"))
continue;
SendDlgItemMessage(hwndDlg, IDC_COMBO_RECORDFROM, CB_INSERTSTRING, i++, (LPARAM)wfd.cFileName);
@ -674,7 +682,7 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFilter = "FCE Ultra Save State(*.fc?)\0*.fc?\0\0";
ofn.lpstrFilter = "FCEU Save State(*.fc?)\0*.fc?\0\0";
ofn.lpstrFile = szChoice;
ofn.lpstrDefExt = "fcs";
ofn.nMaxFile = MAX_PATH;
@ -721,9 +729,9 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFilter = "FCE Ultra Movie File(*.fcm)\0*.fcm\0All files(*.*)\0*.*\0\0";
ofn.lpstrFilter = "FCEUX Movie File (*.fm2)\0*.fm2\0FCEU Movie File(*.fcm)\0*.fcm\0All files(*.*)\0*.*\0\0";
ofn.lpstrFile = szChoice;
ofn.lpstrDefExt = "fcm";
ofn.lpstrDefExt = "fm2";
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn))

Binary file not shown.

View File

@ -338,7 +338,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 109
#define _APS_NEXT_COMMAND_VALUE 40121
#define _APS_NEXT_COMMAND_VALUE 40123
#define _APS_NEXT_CONTROL_VALUE 1130
#define _APS_NEXT_SYMED_VALUE 101
#endif

View File

@ -19,6 +19,7 @@
*/
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
@ -39,6 +40,7 @@
#include "state.h"
#include "movie.h"
#include "driver.h"
#include "utils/xstring.h"
typedef struct {
uint8 *data;
@ -715,46 +717,41 @@ char *FCEU_MakeFName(int type, int id1, char *cd1)
{
case FCEUMKF_NPTEMP: asprintf(&ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break;
case FCEUMKF_MOVIE:
if(id1>=0)
{
if(odirs[FCEUIOD_MOVIES])
asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MOVIES],FileBase,id1);
else
asprintf(&ret,"%s"PSS"movies"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1);
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_MOVIES])
asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MOVIES],FileBase,id1);
else
asprintf(&ret,"%s"PSS"movies"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1);
}
}
if(odirs[FCEUIOD_MOVIES])
asprintf(&ret,"%s"PSS"%s.fm2",odirs[FCEUIOD_MOVIES],FileBase);
else
{
if(odirs[FCEUIOD_MOVIES])
asprintf(&ret,"%s"PSS"%s.fcm",odirs[FCEUIOD_MOVIES],FileBase);
else
asprintf(&ret,"%s"PSS"movies"PSS"%s.fcm",BaseDirectory,FileBase);
}
asprintf(&ret,"%s"PSS"movies"PSS"%s.fm2",BaseDirectory,FileBase);
break;
case FCEUMKF_STATE:
if(odirs[FCEUIOD_STATES])
{
asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATES],FileBase,id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1);
}
if(stat(ret,&tmpstat)==-1)
{
std::string movieFilenamePart;
extern char curMovieFilename[512];
if(*curMovieFilename)
{
char drv[PATH_MAX], dir[PATH_MAX], name[PATH_MAX], ext[PATH_MAX];
splitpath(curMovieFilename,drv,dir,name,ext);
movieFilenamePart = std::string(".") + name;
}
const char* mfn = movieFilenamePart.c_str();
if(odirs[FCEUIOD_STATES])
{
asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATES],FileBase,id1);
asprintf(&ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1);
asprintf(&ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
}
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_STATES])
{
asprintf(&ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
}
}
}
break;
@ -830,11 +827,10 @@ char *FCEU_MakeFName(int type, int id1, char *cd1)
break;
case FCEUMKF_PALETTE:asprintf(&ret,"%s"PSS"%s.pal",BaseDirectory,FileBase);break;
case FCEUMKF_MOVIEGLOB:
//these globs use ??? because we can load multiple formats
if(odirs[FCEUIOD_MOVIES])
// asprintf(&ret,"%s"PSS"%s*.fcm",odirs[FCEUIOD_MOVIES],FileBase);
asprintf(&ret,"%s"PSS"*.???",odirs[FCEUIOD_MOVIES]);
else
// asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fcm",BaseDirectory,FileBase);
asprintf(&ret,"%s"PSS"movies"PSS"*.???",BaseDirectory);
break;
case FCEUMKF_MOVIEGLOB2:asprintf(&ret,"%s"PSS"*.???",BaseDirectory);break;

View File

@ -65,7 +65,7 @@ SFORMAT FCEUMOV_STATEINFO[]={
{ 0 }
};
char curMovieFilename[512];
char curMovieFilename[512] = {0};
class MovieRecord
{
@ -382,6 +382,8 @@ void FCEUI_StopMovie()
StopPlayback();
else if(movieMode == MOVIEMODE_RECORD)
StopRecording();
curMovieFilename[0] = 0;
}
@ -460,7 +462,8 @@ void FCEUI_LoadMovie(char *fname, bool _read_only, int _pauseframe)
//TODO - handle reset flag
//...why do we have to do this. isnt it setup by the rom?
//if there is no savestate, we won't have this crucial piece of information at the start of the movie.
//so, we have to include it with the movie
if(currMovieData.palFlag)
FCEUI_SetVidSystem(1);
else

View File

@ -60,6 +60,7 @@ typedef signed int int32;
#define R_OK 2
#define X_OK 1
#define F_OK 0
#define PATH_MAX 260
#else
//mingw32 doesnt prototype this for some reason

View File

@ -309,3 +309,58 @@ std::vector<std::string> tokenize_str(const std::string & str,
return tokens;
}
//this code was taken from WINE (LGPL)
//http://google.com/codesearch?hl=en&q=+lang:c+splitpath+show:CPvw9Z-euls:_RSotQzmLeU:KGzljMEYFbY&sa=N&cd=9&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/Wine-20050524.tar.gz&cs_f=wine-20050524/programs/winefile/splitpath.c
void splitpath(const char* path, char* drv, char* dir, char* name, char* ext)
{
const char* end; /* end of processed string */
const char* p; /* search pointer */
const char* s; /* copy pointer */
/* extract drive name */
if (path[0] && path[1]==':') {
if (drv) {
*drv++ = *path++;
*drv++ = *path++;
*drv = '\0';
}
} else if (drv)
*drv = '\0';
/* search for end of string or stream separator */
for(end=path; *end && *end!=':'; )
end++;
/* search for begin of file extension */
for(p=end; p>path && *--p!='\\' && *p!='/'; )
if (*p == '.') {
end = p;
break;
}
if (ext)
for(s=end; (*ext=*s++); )
ext++;
/* search for end of directory name */
for(p=end; p>path; )
if (*--p=='\\' || *p=='/') {
p++;
break;
}
if (name) {
for(s=p; s<end; )
*name++ = *s++;
*name = '\0';
}
if (dir) {
for(s=path; s<p; )
*dir++ = *s++;
*dir = '\0';
}
}

View File

@ -42,4 +42,5 @@ int HexStringToBytesLength(std::string& str);
std::string BytesToString(void* data, int len);
bool StringToBytes(std::string& str, void* data, int len);
std::vector<std::string> tokenize_str(const std::string & str,const std::string & delims);
std::vector<std::string> tokenize_str(const std::string & str,const std::string & delims);
void splitpath(const char* path, char* drv, char* dir, char* name, char* ext);