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_CheatSearchShowExcluded(void);
void FCEUI_CheatSearchSetCurrentAsOriginal(void); void FCEUI_CheatSearchSetCurrentAsOriginal(void);
#define FCEUIOD_STATE 0 #define FCEUIOD_ROMS 0
#define FCEUIOD_SNAPS 1 #define FCEUIOD_NV 1
#define FCEUIOD_NV 2 #define FCEUIOD_STATES 2
#define FCEUIOD_CHEATS 3 #define FCEUIOD_FDSROM 3
#define FCEUIOD_MISC 4 #define FCEUIOD_SNAPS 4
#define FCEUIOD_MEMW 5 #define FCEUIOD_CHEATS 5
#define FCEUIOD_BBOT 6 #define FCEUIOD_MOVIES 6
#define FCEUIOD_MACRO 7 #define FCEUIOD_MEMW 7
#define FCEUIOD_FDSROM 8 #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); void FCEUI_SetDirOverride(int which, char *n);

View File

@ -108,16 +108,19 @@ static CFGSTRUCT fceuconfig[] = {
ACS(gfsdir), ACS(gfsdir),
NACS("odcheats",directory_names[0]), NACS("odroms",directory_names[0]),
NACS("odmisc",directory_names[1]), NACS("odnonvol",directory_names[1]),
NACS("odnonvol",directory_names[2]), NACS("odstates",directory_names[2]),
NACS("odstates",directory_names[3]), NACS("odfdsrom",directory_names[3]),
NACS("odsnaps",directory_names[4]), NACS("odsnaps",directory_names[4]),
NACS("odmemwatch",directory_names[5]), NACS("odcheats",directory_names[5]),
NACS("odbasicbot",directory_names[6]), NACS("odmovies",directory_names[6]),
NACS("odmacro",directory_names[7]), NACS("odmemwatch",directory_names[7]),
NACS("odfdsrom",directory_names[8]), NACS("odbasicbot",directory_names[8]),
NACS("odbase",directory_names[9]), NACS("odmacro",directory_names[9]),
NACS("odinput",directory_names[10]),
NACS("odlua",directory_names[11]),
NACS("odbase",directory_names[12]),
AC(winspecial), AC(winspecial),
AC(winsizemulx), 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++) for(unsigned int curr_dir = 0; curr_dir < NUMBER_OF_DIRECTORIES; curr_dir++)
{ {
LONG len; 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) if(len <= 0)
{ {
@ -48,7 +48,7 @@ void CloseDirectoriesDialog(HWND hwndDlg)
continue; 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]); free(directory_names[curr_dir]);
directory_names[curr_dir] = 0; directory_names[curr_dir] = 0;
@ -102,7 +102,7 @@ static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
// Initialize the directories textboxes // Initialize the directories textboxes
for(unsigned int curr_dir = 0; curr_dir < NUMBER_OF_DIRECTORIES; curr_dir++) 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 // 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: case WM_COMMAND:
if( !(wParam >> 16) ) 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 // If a directory selection button was pressed, ask the
// user for a directory. // user for a directory.
static char *helpert[6] = { static char *helpert[13] = {
"Cheats", "Roms",
"Miscellaneous", "Battery Saves",
"Nonvolatile Game Data",
"Save States", "Save States",
"Screen Snapshots", "FDS Bios Rom",
"Screenshots",
"Cheats",
"Movies",
"Memory Watch",
"Basic Bot",
"Macro files",
"Input Presets",
"Lua Scripts",
"Base Directory" "Base Directory"
}; };
char name[MAX_PATH]; 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) else switch(wParam & 0xFFFF)

View File

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

View File

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

View File

@ -39,12 +39,25 @@ static int status_icon = 1;
static int vmod = 0; static int vmod = 0;
static char *gfsdir=0; static char *gfsdir=0;
extern char* directory_names[10]; extern char* directory_names[13];
/** /**
* Contains the names of the default directories. * 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_DIRECTORIES sizeof(directory_names) / sizeof(*directory_names)
#define NUMBER_OF_DEFAULT_DIRECTORIES sizeof(default_directory_names) / sizeof(*default_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 GUI_BOT_VALUES 2
#define BTN_CANCEL 2 #define BTN_CANCEL 2
#define MENU_OPEN_FILE 100 #define MENU_OPEN_FILE 100
#define EDIT_CHEATS 100 #define EDIT_ROMS 100
#define MENU_CLOSE_FILE 101 #define MENU_CLOSE_FILE 101
#define IDI_ICON1 101 #define IDI_ICON1 101
#define CB_DISABLE_SPEED_THROTTLING 101 #define CB_DISABLE_SPEED_THROTTLING 101
@ -42,7 +42,7 @@
#define MENU_STOP_AVI 152 #define MENU_STOP_AVI 152
#define MENU_EXIT 153 #define MENU_EXIT 153
#define MENU_RESET 200 #define MENU_RESET 200
#define BUTTON_CHEATS 200 #define BUTTON_ROMS 200
#define TXT_PAD1 200 #define TXT_PAD1 200
#define BTN_RESTORE_DEFAULTS 200 #define BTN_RESTORE_DEFAULTS 200
#define BTN_CLEAR 200 #define BTN_CLEAR 200

View File

@ -520,7 +520,7 @@ void LoadNewGamey(HWND hParent, const char *initialdir)
ofn.lpstrFile=nameo; ofn.lpstrFile=nameo;
ofn.nMaxFile=256; ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; //OFN_EXPLORER|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK; 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 // Show the Open File dialog
if(GetOpenFileName(&ofn)) if(GetOpenFileName(&ofn))

View File

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

View File

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