fix directories configuration stuff

This commit is contained in:
mauzus 2008-05-24 16:25:15 +00:00
parent 437c1f65ec
commit 2dcd90fc6c
11 changed files with 445 additions and 394 deletions

View File

@ -240,17 +240,20 @@ int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int compare
void FCEUI_CheatSearchShowExcluded(void);
void FCEUI_CheatSearchSetCurrentAsOriginal(void);
#define FCEUIOD_STATE 0
#define FCEUIOD_SNAPS 1
#define FCEUIOD_NV 2
#define FCEUIOD_CHEATS 3
#define FCEUIOD_MISC 4
#define FCEUIOD_MEMW 5
#define FCEUIOD_BBOT 6
#define FCEUIOD_MACRO 7
#define FCEUIOD_FDSROM 8
#define FCEUIOD_ROMS 0
#define FCEUIOD_NV 1
#define FCEUIOD_STATES 2
#define FCEUIOD_FDSROM 3
#define FCEUIOD_SNAPS 4
#define FCEUIOD_CHEATS 5
#define FCEUIOD_MOVIES 6
#define FCEUIOD_MEMW 7
#define FCEUIOD_BBOT 8
#define FCEUIOD_MACRO 9
#define FCEUIOD_INPUT 10
#define FCEUIOD_LUA 11
#define FCEUIOD__COUNT 9
#define FCEUIOD__COUNT 12
void FCEUI_SetDirOverride(int which, char *n);

View File

@ -108,16 +108,19 @@ static CFGSTRUCT fceuconfig[] = {
ACS(gfsdir),
NACS("odcheats",directory_names[0]),
NACS("odmisc",directory_names[1]),
NACS("odnonvol",directory_names[2]),
NACS("odstates",directory_names[3]),
NACS("odroms",directory_names[0]),
NACS("odnonvol",directory_names[1]),
NACS("odstates",directory_names[2]),
NACS("odfdsrom",directory_names[3]),
NACS("odsnaps",directory_names[4]),
NACS("odmemwatch",directory_names[5]),
NACS("odbasicbot",directory_names[6]),
NACS("odmacro",directory_names[7]),
NACS("odfdsrom",directory_names[8]),
NACS("odbase",directory_names[9]),
NACS("odcheats",directory_names[5]),
NACS("odmovies",directory_names[6]),
NACS("odmemwatch",directory_names[7]),
NACS("odbasicbot",directory_names[8]),
NACS("odmacro",directory_names[9]),
NACS("odinput",directory_names[10]),
NACS("odlua",directory_names[11]),
NACS("odbase",directory_names[12]),
AC(winspecial),
AC(winsizemulx),

View File

@ -28,7 +28,7 @@ void CloseDirectoriesDialog(HWND hwndDlg)
for(unsigned int curr_dir = 0; curr_dir < NUMBER_OF_DIRECTORIES; curr_dir++)
{
LONG len;
len = SendDlgItemMessage(hwndDlg, EDIT_CHEATS + curr_dir, WM_GETTEXTLENGTH, 0, 0);
len = SendDlgItemMessage(hwndDlg, EDIT_ROMS + curr_dir, WM_GETTEXTLENGTH, 0, 0);
if(len <= 0)
{
@ -48,7 +48,7 @@ void CloseDirectoriesDialog(HWND hwndDlg)
continue;
}
if(!GetDlgItemText(hwndDlg, EDIT_CHEATS + curr_dir, directory_names[curr_dir], len))
if(!GetDlgItemText(hwndDlg, EDIT_ROMS + curr_dir, directory_names[curr_dir], len))
{
free(directory_names[curr_dir]);
directory_names[curr_dir] = 0;
@ -102,7 +102,7 @@ static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
// Initialize the directories textboxes
for(unsigned int curr_dir = 0; curr_dir < NUMBER_OF_DIRECTORIES; curr_dir++)
{
SetDlgItemText(hwndDlg, EDIT_CHEATS + curr_dir, directory_names[curr_dir]);
SetDlgItemText(hwndDlg, EDIT_ROMS + curr_dir, directory_names[curr_dir]);
}
// Check the screenshot naming checkbox if necessary
@ -123,25 +123,32 @@ static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
case WM_COMMAND:
if( !(wParam >> 16) )
{
if( (wParam & 0xFFFF) >= BUTTON_CHEATS && (wParam & 0xFFFF) <= BUTTON_CHEATS + NUMBER_OF_DIRECTORIES)
if( (wParam & 0xFFFF) >= BUTTON_ROMS && (wParam & 0xFFFF) <= BUTTON_ROMS + NUMBER_OF_DIRECTORIES)
{
// If a directory selection button was pressed, ask the
// user for a directory.
static char *helpert[6] = {
"Cheats",
"Miscellaneous",
"Nonvolatile Game Data",
static char *helpert[13] = {
"Roms",
"Battery Saves",
"Save States",
"Screen Snapshots",
"FDS Bios Rom",
"Screenshots",
"Cheats",
"Movies",
"Memory Watch",
"Basic Bot",
"Macro files",
"Input Presets",
"Lua Scripts",
"Base Directory"
};
char name[MAX_PATH];
if(BrowseForFolder(hwndDlg, helpert[ ( (wParam & 0xFFFF) - BUTTON_CHEATS)], name))
if(BrowseForFolder(hwndDlg, helpert[ ( (wParam & 0xFFFF) - BUTTON_ROMS)], name))
{
SetDlgItemText(hwndDlg, EDIT_CHEATS + ((wParam & 0xFFFF) - BUTTON_CHEATS), name);
SetDlgItemText(hwndDlg, EDIT_ROMS + ((wParam & 0xFFFF) - BUTTON_ROMS), name);
}
}
else switch(wParam & 0xFFFF)

View File

@ -1533,7 +1533,7 @@ static void PresetExport(int preset)
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
ofn.lpstrInitialDir=InputPresetDir;
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_INPUT);
if(GetSaveFileName(&ofn))
{
int i;
@ -1590,7 +1590,7 @@ static void PresetImport(int preset)
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.lpstrInitialDir=InputPresetDir;
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_INPUT);
if(GetOpenFileName(&ofn))
{

View File

@ -106,8 +106,8 @@ double winsizemulx = 1, winsizemuly = 1;
// Contains the names of the overridden standard directories
// in the order cheats, misc, nonvol, states, snaps, memwatch, basicbot, macro, fds,..., base
char *directory_names[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// in the order roms, nonvol, states, fdsrom, snaps, cheats, movies, memwatch, basicbot, macro, input presets, lua scripts, base
char *directory_names[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/**
* Handle of the main window.
@ -160,16 +160,19 @@ void SetDirs()
{
int x;
static int jlist[10]= {
FCEUIOD_CHEATS,
FCEUIOD_MISC,
static int jlist[13]= {
FCEUIOD_ROMS,
FCEUIOD_NV,
FCEUIOD_STATE,
FCEUIOD_STATES,
FCEUIOD_FDSROM,
FCEUIOD_SNAPS,
FCEUIOD_CHEATS,
FCEUIOD_MOVIES,
FCEUIOD_MEMW,
FCEUIOD_BBOT,
FCEUIOD_MACRO,
FCEUIOD_FDSROM,
FCEUIOD_INPUT,
FCEUIOD_LUA,
FCEUIOD__COUNT};
FCEUI_SetSnapName(eoptions & EO_SNAPNAME);
@ -179,9 +182,9 @@ void SetDirs()
FCEUI_SetDirOverride(jlist[x], directory_names[x]);
}
if(directory_names[10])
if(directory_names[12])
{
FCEUI_SetBaseDirectory(directory_names[10]);
FCEUI_SetBaseDirectory(directory_names[12]);
}
else
{

View File

@ -39,12 +39,25 @@ static int status_icon = 1;
static int vmod = 0;
static char *gfsdir=0;
extern char* directory_names[10];
extern char* directory_names[13];
/**
* Contains the names of the default directories.
**/
static const char *default_directory_names[9] = {"cheats", "movie", "sav", "fcs", "snaps", "memwatch", "basicbot", "macro", ""};
static const char *default_directory_names[12] = {
"", // roms
"sav", // nonvol
"fcs", // states
"", // fdsrom
"snaps", // snaps
"cheats", // cheats
"movies", // movies
"tools", // memwatch
"tools", // basicbot
"tools", // macro
"tools", // input presets
"tools" // lua scripts
};
#define NUMBER_OF_DIRECTORIES sizeof(directory_names) / sizeof(*directory_names)
#define NUMBER_OF_DEFAULT_DIRECTORIES sizeof(default_directory_names) / sizeof(*default_directory_names)

Binary file not shown.

View File

@ -9,7 +9,7 @@
#define GUI_BOT_VALUES 2
#define BTN_CANCEL 2
#define MENU_OPEN_FILE 100
#define EDIT_CHEATS 100
#define EDIT_ROMS 100
#define MENU_CLOSE_FILE 101
#define IDI_ICON1 101
#define CB_DISABLE_SPEED_THROTTLING 101
@ -42,7 +42,7 @@
#define MENU_STOP_AVI 152
#define MENU_EXIT 153
#define MENU_RESET 200
#define BUTTON_CHEATS 200
#define BUTTON_ROMS 200
#define TXT_PAD1 200
#define BTN_RESTORE_DEFAULTS 200
#define BTN_CLEAR 200

View File

@ -520,7 +520,7 @@ void LoadNewGamey(HWND hParent, const char *initialdir)
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; //OFN_EXPLORER|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK;
ofn.lpstrInitialDir = initialdir ? initialdir : gfsdir;
ofn.lpstrInitialDir = initialdir ? initialdir : FCEU_GetPath(FCEUMKF_ROMS);
// Show the Open File dialog
if(GetOpenFileName(&ofn))

View File

@ -407,7 +407,7 @@ uint64 FCEU_fwrite(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp)
return gzwrite(fp->fp,ptr,size*nmemb);
}
else if(fp->type>=2)
{
{
return 0;
}
else
@ -443,141 +443,141 @@ int FCEU_fseek(FCEUFILE *fp, long offset, int whence)
uint64 FCEU_ftell(FCEUFILE *fp)
{
if(fp->type==1)
{
return gztell(fp->fp);
}
else if(fp->type>=2)
{
return (((MEMWRAP *)(fp->fp))->location);
}
else
return ftell((FILE *)fp->fp);
if(fp->type==1)
{
return gztell(fp->fp);
}
else if(fp->type>=2)
{
return (((MEMWRAP *)(fp->fp))->location);
}
else
return ftell((FILE *)fp->fp);
}
void FCEU_rewind(FCEUFILE *fp)
{
if(fp->type==1)
{
gzrewind(fp->fp);
}
else if(fp->type>=2)
{
((MEMWRAP *)(fp->fp))->location=0;
}
else
/* Rewind */
fseek((FILE*)fp->fp,0,SEEK_SET); //mbg merge 7/17/06 - added cast to FILE*
if(fp->type==1)
{
gzrewind(fp->fp);
}
else if(fp->type>=2)
{
((MEMWRAP *)(fp->fp))->location=0;
}
else
/* Rewind */
fseek((FILE*)fp->fp,0,SEEK_SET); //mbg merge 7/17/06 - added cast to FILE*
}
int FCEU_read16le(uint16 *val, FCEUFILE *fp)
{
uint8 t[4]; //mbg merge 7/17/06 - changed size from 2 to 4 to avoid dangerous problem with uint32* poking
uint8 t[4]; //mbg merge 7/17/06 - changed size from 2 to 4 to avoid dangerous problem with uint32* poking
if(fp->type>=1)
{
if(fp->type>=2)
{
MEMWRAP *wz;
wz=(MEMWRAP *)fp->fp;
if(wz->location+2>wz->size)
{return 0;}
*(uint32 *)t=*(uint32 *)(wz->data+wz->location);
wz->location+=2;
}
else if(fp->type==1)
if(gzread(fp->fp,&t,2)!=2) return(0);
return(1);
}
else
{
if(fread(t,1,2,(FILE *)fp->fp)!=2) return(0);
}
*val=t[0]|(t[1]<<8);
return(1);
if(fp->type>=1)
{
if(fp->type>=2)
{
MEMWRAP *wz;
wz=(MEMWRAP *)fp->fp;
if(wz->location+2>wz->size)
{return 0;}
*(uint32 *)t=*(uint32 *)(wz->data+wz->location);
wz->location+=2;
}
else if(fp->type==1)
if(gzread(fp->fp,&t,2)!=2) return(0);
return(1);
}
else
{
if(fread(t,1,2,(FILE *)fp->fp)!=2) return(0);
}
*val=t[0]|(t[1]<<8);
return(1);
}
int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp)
{
if(fp->type>=1)
{
uint8 t[4];
#ifndef LSB_FIRST
uint8 x[4];
#endif
if(fp->type>=2)
{
MEMWRAP *wz;
wz=(MEMWRAP *)fp->fp;
if(wz->location+4>wz->size)
{return 0;}
*(uint32 *)t=*(uint32 *)(wz->data+wz->location);
wz->location+=4;
}
else if(fp->type==1)
gzread(fp->fp,&t,4);
#ifndef LSB_FIRST
x[0]=t[3];
x[1]=t[2];
x[2]=t[1];
x[3]=t[0];
*(uint32*)Bufo=*(uint32*)x;
#else
*(uint32*)Bufo=*(uint32*)t;
#endif
return 1;
}
else
{
return read32le(Bufo,(FILE *)fp->fp);
}
if(fp->type>=1)
{
uint8 t[4];
#ifndef LSB_FIRST
uint8 x[4];
#endif
if(fp->type>=2)
{
MEMWRAP *wz;
wz=(MEMWRAP *)fp->fp;
if(wz->location+4>wz->size)
{return 0;}
*(uint32 *)t=*(uint32 *)(wz->data+wz->location);
wz->location+=4;
}
else if(fp->type==1)
gzread(fp->fp,&t,4);
#ifndef LSB_FIRST
x[0]=t[3];
x[1]=t[2];
x[2]=t[1];
x[3]=t[0];
*(uint32*)Bufo=*(uint32*)x;
#else
*(uint32*)Bufo=*(uint32*)t;
#endif
return 1;
}
else
{
return read32le(Bufo,(FILE *)fp->fp);
}
}
int FCEU_fgetc(FCEUFILE *fp)
{
if(fp->type==1)
return gzgetc(fp->fp);
else if(fp->type>=2)
{
MEMWRAP *wz;
wz=(MEMWRAP *)fp->fp;
if(wz->location<wz->size)
return wz->data[wz->location++];
return EOF;
}
else
return fgetc((FILE *)fp->fp);
if(fp->type==1)
return gzgetc(fp->fp);
else if(fp->type>=2)
{
MEMWRAP *wz;
wz=(MEMWRAP *)fp->fp;
if(wz->location<wz->size)
return wz->data[wz->location++];
return EOF;
}
else
return fgetc((FILE *)fp->fp);
}
uint64 FCEU_fgetsize(FCEUFILE *fp)
{
if(fp->type==1)
{
int x,t;
t=gztell(fp->fp);
gzrewind(fp->fp);
for(x=0; gzgetc(fp->fp) != EOF; x++);
gzseek(fp->fp,t,SEEK_SET);
return(x);
}
else if(fp->type>=2)
return ((MEMWRAP*)(fp->fp))->size;
else
{
long t,r;
t=ftell((FILE *)fp->fp);
fseek((FILE *)fp->fp,0,SEEK_END);
r=ftell((FILE *)fp->fp);
fseek((FILE *)fp->fp,t,SEEK_SET);
return r;
}
if(fp->type==1)
{
int x,t;
t=gztell(fp->fp);
gzrewind(fp->fp);
for(x=0; gzgetc(fp->fp) != EOF; x++);
gzseek(fp->fp,t,SEEK_SET);
return(x);
}
else if(fp->type>=2)
return ((MEMWRAP*)(fp->fp))->size;
else
{
long t,r;
t=ftell((FILE *)fp->fp);
fseek((FILE *)fp->fp,0,SEEK_END);
r=ftell((FILE *)fp->fp);
fseek((FILE *)fp->fp,t,SEEK_SET);
return r;
}
}
int FCEU_fisarchive(FCEUFILE *fp)
{
if(fp->type==2)
return 1;
return 0;
if(fp->type==2)
return 1;
return 0;
}
@ -599,7 +599,7 @@ void FCEUI_SetBaseDirectory(const char *dir)
BaseDirectory[2047] = 0;
}
static char *odirs[FCEUIOD__COUNT]={0,0,0,0,0}; // odirs, odors. ^_^
static char *odirs[FCEUIOD__COUNT]={0,0,0,0,0,0,0,0,0,0,0,0}; // odirs, odors. ^_^
void FCEUI_SetDirOverride(int which, char *n)
{
@ -611,260 +611,279 @@ void FCEUI_SetDirOverride(int which, char *n)
if(GameInfo) /* Rebuild cache of present states/movies. */
{
if(which==FCEUIOD_STATE)
if(which==FCEUIOD_STATES)
{
FCEUSS_CheckStates();
}
}
}
#ifndef HAVE_ASPRINTF
static int asprintf(char **strp, const char *fmt, ...)
{
va_list ap;
int ret;
#ifndef HAVE_ASPRINTF
static int asprintf(char **strp, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap,fmt);
if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char*
return(0);
ret=vsnprintf(*strp,2048,fmt,ap);
va_end(ap);
return(ret);
}
#endif
va_start(ap,fmt);
if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char*
return(0);
ret=vsnprintf(*strp,2048,fmt,ap);
va_end(ap);
return(ret);
}
#endif
char* FCEU_GetPath(int type)
{
char *ret=0;
switch(type)
{
case FCEUMKF_STATE:if(odirs[FCEUIOD_STATE])
ret=strdup(odirs[FCEUIOD_STATE]);
else
asprintf(&ret,"%s"PSS"fcs",BaseDirectory);
break;
case FCEUMKF_MOVIE:if(odirs[FCEUIOD_MISC])
ret=strdup(odirs[FCEUIOD_MISC]);
else
asprintf(&ret,"%s"PSS"movie",BaseDirectory);
break;
case FCEUMKF_MEMW:if(odirs[FCEUIOD_MEMW])
ret=strdup(odirs[FCEUIOD_MEMW]);
else
asprintf(&ret,"%s"PSS"memwatch",BaseDirectory);
break;
case FCEUMKF_BBOT:if(odirs[FCEUIOD_BBOT])
ret=strdup(odirs[FCEUIOD_BBOT]);
else
asprintf(&ret,"%s"PSS"basicbot",BaseDirectory);
break;
}
return(ret);
char *ret=0;
switch(type)
{
case FCEUMKF_STATE:
if(odirs[FCEUIOD_STATES])
ret=strdup(odirs[FCEUIOD_STATES]);
else
asprintf(&ret,"%s"PSS"fcs",BaseDirectory);
break;
case FCEUMKF_MOVIE:
if(odirs[FCEUIOD_MOVIES])
ret=strdup(odirs[FCEUIOD_MOVIES]);
else
asprintf(&ret,"%s"PSS"movies",BaseDirectory);
break;
case FCEUMKF_MEMW:
if(odirs[FCEUIOD_MEMW])
ret=strdup(odirs[FCEUIOD_MEMW]);
else
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
break;
case FCEUMKF_BBOT:
if(odirs[FCEUIOD_BBOT])
ret=strdup(odirs[FCEUIOD_BBOT]);
else
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
break;
case FCEUMKF_ROMS:
if(odirs[FCEUIOD_ROMS])
ret=strdup(odirs[FCEUIOD_ROMS]);
else
asprintf(&ret,"%s",BaseDirectory);
break;
case FCEUMKF_INPUT:
if(odirs[FCEUIOD_INPUT])
ret=strdup(odirs[FCEUIOD_INPUT]);
else
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
break;
case FCEUMKF_LUA:
if(odirs[FCEUIOD_LUA])
ret=strdup(odirs[FCEUIOD_LUA]);
else
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
break;
}
return(ret);
}
char *FCEU_MakePath(int type, const char* filebase)
{
char *ret=0;
char *ret=0;
switch(type)
{
case FCEUMKF_MOVIE:if(odirs[FCEUIOD_MISC])
asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_MISC],filebase);
else
asprintf(&ret,"%s"PSS"movie"PSS"%s",BaseDirectory,filebase);
break;
case FCEUMKF_STATE:if(odirs[FCEUIOD_STATE])
asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_STATE],filebase);
else
asprintf(&ret,"%s"PSS"fcs"PSS"%s",BaseDirectory,filebase);
break;
}
return(ret);
switch(type)
{
case FCEUMKF_MOVIE:
if(odirs[FCEUIOD_MOVIES])
asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_MOVIES],filebase);
else
asprintf(&ret,"%s"PSS"movies"PSS"%s",BaseDirectory,filebase);
break;
case FCEUMKF_STATE:
if(odirs[FCEUIOD_STATES])
asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_STATES],filebase);
else
asprintf(&ret,"%s"PSS"fcs"PSS"%s",BaseDirectory,filebase);
break;
}
return(ret);
}
char *FCEU_MakeFName(int type, int id1, char *cd1)
{
char *ret=0;
struct stat tmpstat;
char *ret=0;
struct stat tmpstat;
switch(type)
{
case FCEUMKF_NPTEMP: asprintf(&ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break;
case FCEUMKF_MOVIE:if(id1>=0)
{
if(odirs[FCEUIOD_MISC])
asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MISC],FileBase,id1);
else
asprintf(&ret,"%s"PSS"movie"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1);
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_MISC])
asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MISC],FileBase,id1);
else
asprintf(&ret,"%s"PSS"movie"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1);
}
}
else
{
if(odirs[FCEUIOD_MISC])
asprintf(&ret,"%s"PSS"%s.fcm",odirs[FCEUIOD_MISC],FileBase);
else
asprintf(&ret,"%s"PSS"movie"PSS"%s.fcm",BaseDirectory,FileBase);
}
break;
case FCEUMKF_STATE:
if(odirs[FCEUIOD_STATE])
{
asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATE],FileBase,id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1);
}
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_STATE])
switch(type)
{
case FCEUMKF_NPTEMP: asprintf(&ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break;
case FCEUMKF_MOVIE:
if(id1>=0)
{
asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATE],FileBase,id1);
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);
}
}
else
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);
}
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);
}
}
break;
case FCEUMKF_SNAP:
if(FSettings.SnapName)
{
if(odirs[FCEUIOD_SNAPS])
asprintf(&ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
else
asprintf(&ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1);
}
else
{
if(odirs[FCEUIOD_SNAPS])
asprintf(&ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1);
else
asprintf(&ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1);
}
break;
case FCEUMKF_FDS:if(odirs[FCEUIOD_NV])
asprintf(&ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase);
else
asprintf(&ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase);
break;
case FCEUMKF_SAV:if(odirs[FCEUIOD_NV])
asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
else
asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_NV])
asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
else
asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
}
break;
case FCEUMKF_REWINDSTATE:
if(odirs[FCEUIOD_STATE])
{
asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATE],id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
}
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_STATE])
if(stat(ret,&tmpstat)==-1)
{
asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATE],id1);
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);
}
}
break;
case FCEUMKF_SNAP:
if(FSettings.SnapName)
{
if(odirs[FCEUIOD_SNAPS])
asprintf(&ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
else
asprintf(&ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1);
}
else
{
if(odirs[FCEUIOD_SNAPS])
asprintf(&ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1);
else
asprintf(&ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1);
}
break;
case FCEUMKF_FDS:
if(odirs[FCEUIOD_NV])
asprintf(&ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase);
else
asprintf(&ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase);
break;
case FCEUMKF_SAV:
if(odirs[FCEUIOD_NV])
asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
else
asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_NV])
asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
else
asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
}
break;
case FCEUMKF_REWINDSTATE:
if(odirs[FCEUIOD_STATES])
{
asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
}
}
break;
case FCEUMKF_CHEAT:
if(odirs[FCEUIOD_CHEATS])
asprintf(&ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase);
else
asprintf(&ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase);
break;
case FCEUMKF_IPS: asprintf(&ret,"%s"PSS"%s%s.ips",FileBaseDirectory,FileBase,FileExt);
break;
case FCEUMKF_GGROM:asprintf(&ret,"%s"PSS"gg.rom",BaseDirectory);break;
case FCEUMKF_FDSROM:
if(odirs[FCEUIOD_FDSROM])
asprintf(&ret,"%s"PSS"disksys.rom",odirs[FCEUIOD_FDSROM],FileBase);
else
asprintf(&ret,"%s"PSS"disksys.rom",BaseDirectory,FileBase);
break;
case FCEUMKF_PALETTE:
if(odirs[FCEUIOD_MISC])
asprintf(&ret,"%s"PSS"%s.pal",odirs[FCEUIOD_MISC],FileBase);
else
asprintf(&ret,"%s"PSS"%s.pal",BaseDirectory,FileBase);
break;
case FCEUMKF_MOVIEGLOB:
if(odirs[FCEUIOD_MISC])
// asprintf(&ret,"%s"PSS"%s*.fcm",odirs[FCEUIOD_MISC],FileBase);
asprintf(&ret,"%s"PSS"*.???",odirs[FCEUIOD_MISC]);
else
// asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fcm",BaseDirectory,FileBase);
asprintf(&ret,"%s"PSS"movie"PSS"*.???",BaseDirectory);
break;
case FCEUMKF_MOVIEGLOB2:
asprintf(&ret,"%s"PSS"*.???",BaseDirectory);
break;
case FCEUMKF_STATEGLOB:
if(odirs[FCEUIOD_STATE])
asprintf(&ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATE],FileBase);
else
asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase);
break;
}
return(ret);
if(stat(ret,&tmpstat)==-1)
{
if(odirs[FCEUIOD_STATES])
{
asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
}
else
{
asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
}
}
break;
case FCEUMKF_CHEAT:
if(odirs[FCEUIOD_CHEATS])
asprintf(&ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase);
else
asprintf(&ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase);
break;
case FCEUMKF_IPS:asprintf(&ret,"%s"PSS"%s%s.ips",FileBaseDirectory,FileBase,FileExt);break;
case FCEUMKF_GGROM:asprintf(&ret,"%s"PSS"gg.rom",BaseDirectory);break;
case FCEUMKF_FDSROM:
if(odirs[FCEUIOD_FDSROM])
asprintf(&ret,"%s"PSS"disksys.rom",odirs[FCEUIOD_FDSROM],FileBase);
else
asprintf(&ret,"%s"PSS"disksys.rom",BaseDirectory,FileBase);
break;
case FCEUMKF_PALETTE:asprintf(&ret,"%s"PSS"%s.pal",BaseDirectory,FileBase);break;
case FCEUMKF_MOVIEGLOB:
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;
case FCEUMKF_STATEGLOB:
if(odirs[FCEUIOD_STATES])
asprintf(&ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATES],FileBase);
else
asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase);
break;
}
return(ret);
}
void GetFileBase(const char *f)
{
const char *tp1,*tp3;
const char *tp1,*tp3;
#if PSS_STYLE==4
tp1=((char *)strrchr(f,':'));
#elif PSS_STYLE==1
tp1=((char *)strrchr(f,'/'));
#else
tp1=((char *)strrchr(f,'\\'));
#if PSS_STYLE!=3
tp3=((char *)strrchr(f,'/'));
if(tp1<tp3) tp1=tp3;
#endif
#endif
if(!tp1)
{
tp1=f;
strcpy(FileBaseDirectory,".");
}
else
{
memcpy(FileBaseDirectory,f,tp1-f);
FileBaseDirectory[tp1-f]=0;
tp1++;
}
#if PSS_STYLE==4
tp1=((char *)strrchr(f,':'));
#elif PSS_STYLE==1
tp1=((char *)strrchr(f,'/'));
#else
tp1=((char *)strrchr(f,'\\'));
#if PSS_STYLE!=3
tp3=((char *)strrchr(f,'/'));
if(tp1<tp3) tp1=tp3;
#endif
#endif
if(!tp1)
{
tp1=f;
strcpy(FileBaseDirectory,".");
}
else
{
memcpy(FileBaseDirectory,f,tp1-f);
FileBaseDirectory[tp1-f]=0;
tp1++;
}
if(((tp3=strrchr(f,'.'))!=NULL) && (tp3>tp1))
{
memcpy(FileBase,tp1,tp3-tp1);
FileBase[tp3-tp1]=0;
strcpy(FileExt,tp3);
}
else
{
strcpy(FileBase,tp1);
FileExt[0]=0;
}
if(((tp3=strrchr(f,'.'))!=NULL) && (tp3>tp1))
{
memcpy(FileBase,tp1,tp3-tp1);
FileBase[tp3-tp1]=0;
strcpy(FileExt,tp3);
}
else
{
strcpy(FileBase,tp1);
FileExt[0]=0;
}
}

View File

@ -26,22 +26,25 @@ char* FCEU_GetPath(int type);
char *FCEU_MakePath(int type, const char* filebase);
char *FCEU_MakeFName(int type, int id1, char *cd1);
#define FCEUMKF_STATE 1
#define FCEUMKF_SNAP 2
#define FCEUMKF_SAV 3
#define FCEUMKF_CHEAT 4
#define FCEUMKF_FDSROM 5
#define FCEUMKF_PALETTE 6
#define FCEUMKF_GGROM 7
#define FCEUMKF_IPS 8
#define FCEUMKF_FDS 9
#define FCEUMKF_MOVIE 10
#define FCEUMKF_NPTEMP 11
#define FCEUMKF_MOVIEGLOB 12
#define FCEUMKF_STATEGLOB 13
#define FCEUMKF_MOVIEGLOB2 14
#define FCEUMKF_REWINDSTATE 15
#define FCEUMKF_MEMW 16
#define FCEUMKF_BBOT 17
#define FCEUMKF_STATE 1
#define FCEUMKF_SNAP 2
#define FCEUMKF_SAV 3
#define FCEUMKF_CHEAT 4
#define FCEUMKF_FDSROM 5
#define FCEUMKF_PALETTE 6
#define FCEUMKF_GGROM 7
#define FCEUMKF_IPS 8
#define FCEUMKF_FDS 9
#define FCEUMKF_MOVIE 10
#define FCEUMKF_NPTEMP 11
#define FCEUMKF_MOVIEGLOB 12
#define FCEUMKF_STATEGLOB 13
#define FCEUMKF_MOVIEGLOB2 14
#define FCEUMKF_REWINDSTATE 15
#define FCEUMKF_MEMW 16
#define FCEUMKF_BBOT 17
#define FCEUMKF_ROMS 18
#define FCEUMKF_INPUT 19
#define FCEUMKF_LUA 20
#endif