added obj/bg display toggle
much cleanups fix memwatch configuration saving
This commit is contained in:
parent
79de2d8295
commit
69bc4b3f72
|
@ -86,8 +86,8 @@ void FCEUI_SetSnapName(int a);
|
|||
//0 to keep 8-sprites limitation, 1 to remove it
|
||||
void FCEUI_DisableSpriteLimitation(int a);
|
||||
|
||||
//-1 = no change, 0 = show, 1 = hide, 2 = internal toggle
|
||||
void FCEUI_SetRenderDisable(int sprites, int bg);
|
||||
void FCEUI_SetRenderPlanes(bool sprites, bool bg);
|
||||
void FCEUI_GetRenderPlanes(bool& sprites, bool& bg);
|
||||
|
||||
//name=path and file to load. returns 0 on failure, 1 on success
|
||||
FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode);
|
||||
|
@ -125,7 +125,7 @@ void FCEUI_FrameSkip(int x);
|
|||
void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall);
|
||||
|
||||
//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory.
|
||||
void FCEUI_SetBaseDirectory(const char *dir);
|
||||
void FCEUI_SetBaseDirectory(std::string const & dir);
|
||||
|
||||
//Tells FCE Ultra to copy the palette data pointed to by pal and use it.
|
||||
//Data pointed to by pal needs to be 64*3 bytes in length.
|
||||
|
|
|
@ -8,31 +8,29 @@ typedef struct {
|
|||
void SaveFCEUConfig(const char *filename, const CFGSTRUCT *cfgst);
|
||||
void LoadFCEUConfig(const char *filename, CFGSTRUCT *cfgst);
|
||||
|
||||
/* Macros for building CFGSTRUCT structures. */
|
||||
//Macros for building CFGSTRUCT structures.
|
||||
|
||||
/* CFGSTRUCT structures must always end with ENDCFGSTRUCT */
|
||||
// CFGSTRUCT structures must always end with ENDCFGSTRUCT
|
||||
#define ENDCFGSTRUCT { 0,0,0 }
|
||||
|
||||
/* When this macro is used, the config loading/saving code will parse
|
||||
the new config structure until the end of it is detected, then it
|
||||
will continue parsing the original config structure.
|
||||
*/
|
||||
//When this macro is used, the config loading/saving code will parse
|
||||
//the new config structure until the end of it is detected, then it
|
||||
//will continue parsing the original config structure.
|
||||
#define ADDCFGSTRUCT(x) { 0,&x,0 }
|
||||
|
||||
/* Oops. The NAC* macros shouldn't have the # in front of the w, but
|
||||
fixing this would break configuration files of previous versions and it
|
||||
isn't really hurting much.
|
||||
*/
|
||||
// Oops. The NAC* macros shouldn't have the # in front of the w, but
|
||||
// fixing this would break configuration files of previous versions and it
|
||||
// isn't really hurting much.
|
||||
|
||||
/* Single piece of data(integer). */
|
||||
// Single piece of data(integer).
|
||||
#define AC(x) { #x,&x,sizeof(x)}
|
||||
#define NAC(w,x) { #w,&x,sizeof(x)}
|
||||
|
||||
/* Array. */
|
||||
// Array.
|
||||
#define ACA(x) {#x,x,sizeof(x)}
|
||||
#define NACA(w,x) {#w,x,sizeof(x)}
|
||||
|
||||
/* String(pointer) with automatic memory allocation. */
|
||||
// String(pointer) with automatic memory allocation.
|
||||
#define ACS(x) {#x,&x,0}
|
||||
#define NACS(w,x) {#w,&x,0}
|
||||
|
||||
|
|
|
@ -54,71 +54,70 @@ extern int Tracer_wndx, Tracer_wndy;
|
|||
extern int CDLogger_wndx, CDLogger_wndy;
|
||||
extern int GGConv_wndx, GGConv_wndy;
|
||||
|
||||
/**
|
||||
* Structure that contains configuration information
|
||||
**/
|
||||
|
||||
//Structure that contains configuration information
|
||||
static CFGSTRUCT fceuconfig[] = {
|
||||
|
||||
ACS(recent_files[0]),
|
||||
ACS(recent_files[1]),
|
||||
ACS(recent_files[2]),
|
||||
ACS(recent_files[3]),
|
||||
ACS(recent_files[4]),
|
||||
ACS(recent_files[5]),
|
||||
ACS(recent_files[6]),
|
||||
ACS(recent_files[7]),
|
||||
ACS(recent_files[8]),
|
||||
ACS(recent_files[9]),
|
||||
ACS(recent_files[0]),
|
||||
ACS(recent_files[1]),
|
||||
ACS(recent_files[2]),
|
||||
ACS(recent_files[3]),
|
||||
ACS(recent_files[4]),
|
||||
ACS(recent_files[5]),
|
||||
ACS(recent_files[6]),
|
||||
ACS(recent_files[7]),
|
||||
ACS(recent_files[8]),
|
||||
ACS(recent_files[9]),
|
||||
|
||||
ACS(memw_recent_files[0]),
|
||||
ACS(memw_recent_files[1]),
|
||||
ACS(memw_recent_files[2]),
|
||||
ACS(memw_recent_files[3]),
|
||||
ACS(memw_recent_files[4]),
|
||||
ACS(memw_recent_files[0]),
|
||||
ACS(memw_recent_files[1]),
|
||||
ACS(memw_recent_files[2]),
|
||||
ACS(memw_recent_files[3]),
|
||||
ACS(memw_recent_files[4]),
|
||||
|
||||
|
||||
AC(ntsccol),AC(ntsctint),AC(ntschue),
|
||||
AC(ntsccol),AC(ntsctint),AC(ntschue),
|
||||
|
||||
NAC("palyo",pal_emulation),
|
||||
NAC("palyo",pal_emulation),
|
||||
NAC("genie",genie),
|
||||
NAC("fs",fullscreen),
|
||||
NAC("vgamode",vmod),
|
||||
NAC("sound",soundo),
|
||||
NAC("sicon",status_icon),
|
||||
NAC("sicon",status_icon),
|
||||
|
||||
ACS(gfsdir),
|
||||
ACS(gfsdir),
|
||||
|
||||
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("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]),
|
||||
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("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),
|
||||
AC(winsizemuly),
|
||||
NAC("saspectw987",saspectw),
|
||||
NAC("saspecth987",saspecth),
|
||||
AC(winspecial),
|
||||
AC(winsizemulx),
|
||||
AC(winsizemuly),
|
||||
NAC("saspectw987",saspectw),
|
||||
NAC("saspecth987",saspecth),
|
||||
|
||||
AC(soundrate),
|
||||
AC(soundbuftime),
|
||||
AC(soundbuftime),
|
||||
AC(soundoptions),
|
||||
AC(soundquality),
|
||||
AC(soundvolume),
|
||||
AC(soundvolume),
|
||||
|
||||
AC(goptions),
|
||||
AC(goptions),
|
||||
NAC("eoptions",eoptions),
|
||||
NACA("cpalette",cpalette),
|
||||
NACA("cpalette",cpalette),
|
||||
|
||||
NACA("InputType",InputType),
|
||||
NACA("InputType",InputType),
|
||||
|
||||
NAC("vmcx",vmodes[0].x),
|
||||
NAC("vmcy",vmodes[0].y),
|
||||
|
@ -126,24 +125,24 @@ static CFGSTRUCT fceuconfig[] = {
|
|||
NAC("vmcf",vmodes[0].flags),
|
||||
NAC("vmcxs",vmodes[0].xscale),
|
||||
NAC("vmcys",vmodes[0].yscale),
|
||||
NAC("vmspecial",vmodes[0].special),
|
||||
NAC("vmspecial",vmodes[0].special),
|
||||
|
||||
NAC("srendline",srendlinen),
|
||||
NAC("erendline",erendlinen),
|
||||
NAC("srendlinep",srendlinep),
|
||||
NAC("erendlinep",erendlinep),
|
||||
NAC("srendline",srendlinen),
|
||||
NAC("erendline",erendlinen),
|
||||
NAC("srendlinep",srendlinep),
|
||||
NAC("erendlinep",erendlinep),
|
||||
|
||||
AC(disvaccel),
|
||||
AC(disvaccel),
|
||||
AC(winsync),
|
||||
NAC("988fssync",fssync),
|
||||
NAC("988fssync",fssync),
|
||||
|
||||
AC(ismaximized),
|
||||
AC(maxconbskip),
|
||||
AC(ffbskip),
|
||||
AC(ismaximized),
|
||||
AC(maxconbskip),
|
||||
AC(ffbskip),
|
||||
|
||||
ADDCFGSTRUCT(NetplayConfig),
|
||||
ADDCFGSTRUCT(InputConfig),
|
||||
ADDCFGSTRUCT(HotkeyConfig),
|
||||
ADDCFGSTRUCT(NetplayConfig),
|
||||
ADDCFGSTRUCT(InputConfig),
|
||||
ADDCFGSTRUCT(HotkeyConfig),
|
||||
|
||||
AC(autoHoldKey),
|
||||
AC(autoHoldClearKey),
|
||||
|
@ -188,7 +187,7 @@ static CFGSTRUCT fceuconfig[] = {
|
|||
AC(pauseAfterPlayback),
|
||||
|
||||
//ACS(memwLastfile[2048]),
|
||||
ENDCFGSTRUCT
|
||||
ENDCFGSTRUCT
|
||||
};
|
||||
|
||||
void SaveConfig(const char *filename)
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
#include "window.h"
|
||||
#include "gui.h"
|
||||
|
||||
/**
|
||||
* Processes information from the Directories selection dialog after
|
||||
* the dialog was closed.
|
||||
*
|
||||
* @param hwndDlg Handle of the dialog window.
|
||||
**/
|
||||
///Processes information from the Directories selection dialog after the dialog was closed.
|
||||
///@param hwndDlg Handle of the dialog window.
|
||||
void CloseDirectoriesDialog(HWND hwndDlg)
|
||||
{
|
||||
// Update the information from the screenshot naming checkbox
|
||||
|
@ -90,9 +86,7 @@ void CloseDirectoriesDialog(HWND hwndDlg)
|
|||
EndDialog(hwndDlg, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for the directories configuration dialog.
|
||||
**/
|
||||
///Callback function for the directories configuration dialog.
|
||||
static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(uMsg)
|
||||
|
@ -167,9 +161,7 @@ static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the dialog for configuring the standard directories.
|
||||
**/
|
||||
//Shows the dialog for configuring the standard directories.
|
||||
void ConfigDirectories()
|
||||
{
|
||||
DialogBox(fceu_hInstance, "DIRCONFIG", hAppWnd, DirConCallB);
|
||||
|
|
|
@ -121,23 +121,21 @@ double winsizemulx = 1, winsizemuly = 1;
|
|||
int genie = 0;
|
||||
int pal_emulation = 0;
|
||||
int ntsccol = 0, ntsctint, ntschue;
|
||||
char BaseDirectory[2048];
|
||||
std::string BaseDirectory;
|
||||
|
||||
|
||||
// Contains the names of the overridden standard directories
|
||||
// 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.
|
||||
**/
|
||||
//Handle of the main window.
|
||||
HWND hAppWnd = 0;
|
||||
|
||||
uint32 goptions = GOO_DISABLESS;
|
||||
|
||||
/* Some timing-related variables (now ignored). */
|
||||
int maxconbskip = 32; /* Maximum consecutive blit skips. */
|
||||
int ffbskip = 32; /* Blit skips per blit when FF-ing */
|
||||
// Some timing-related variables (now ignored).
|
||||
int maxconbskip = 32; //Maximum consecutive blit skips.
|
||||
int ffbskip = 32; //Blit skips per blit when FF-ing
|
||||
|
||||
HINSTANCE fceu_hInstance;
|
||||
HACCEL fceu_hAccel;
|
||||
|
@ -165,18 +163,16 @@ int srendlinep = 0;
|
|||
int erendlinep = 239;
|
||||
|
||||
//mbg 6/30/06 - indicates that the main loop should close the game as soon as it can
|
||||
int closeGame = 0;
|
||||
bool closeGame = false;
|
||||
|
||||
|
||||
// qfox 09/17/06: moved the skipcount outside because it was completely pointless
|
||||
// in there.
|
||||
/**
|
||||
* Counts the number of frames that have not been displayed
|
||||
* Used for the bot, to skip frames (and save time).
|
||||
**/
|
||||
//Counts the number of frames that have not been displayed
|
||||
//Used for the bot, to skip frames (and save time).
|
||||
int skipcount = 0;
|
||||
|
||||
// Internal functions
|
||||
|
||||
void SetDirs()
|
||||
{
|
||||
int x;
|
||||
|
@ -213,31 +209,22 @@ void SetDirs()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a directory.
|
||||
*
|
||||
* @param dirname Name of the directory to create.
|
||||
**/
|
||||
/// Creates a directory.
|
||||
/// @param dirname Name of the directory to create.
|
||||
void DirectoryCreator(const char* dirname)
|
||||
{
|
||||
CreateDirectory(dirname, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a directory.
|
||||
*
|
||||
* @param dirname Name of the directory to remove.
|
||||
**/
|
||||
/// Removes a directory.
|
||||
/// @param dirname Name of the directory to remove.
|
||||
void DirectoryRemover(const char* dirname)
|
||||
{
|
||||
RemoveDirectory(dirname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to walk over the default directories array.
|
||||
*
|
||||
* @param callback Callback function that's called for every default directory name.
|
||||
**/
|
||||
/// Used to walk over the default directories array.
|
||||
/// @param callback Callback function that's called for every default directory name.
|
||||
void DefaultDirectoryWalker(void (*callback)(const char*))
|
||||
{
|
||||
unsigned int curr_dir;
|
||||
|
@ -249,7 +236,7 @@ void DefaultDirectoryWalker(void (*callback)(const char*))
|
|||
sprintf(
|
||||
TempArray,
|
||||
"%s\\%s",
|
||||
directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] ? directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] : BaseDirectory,
|
||||
directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] ? directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] : BaseDirectory.c_str(),
|
||||
default_directory_names[curr_dir]
|
||||
);
|
||||
|
||||
|
@ -258,40 +245,31 @@ void DefaultDirectoryWalker(void (*callback)(const char*))
|
|||
}
|
||||
}
|
||||
|
||||
/* Remove empty, unused directories. */
|
||||
/// Remove empty, unused directories.
|
||||
void RemoveDirs()
|
||||
{
|
||||
DefaultDirectoryWalker(DirectoryRemover);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default directories.
|
||||
**/
|
||||
///Creates the default directories.
|
||||
void CreateDirs()
|
||||
{
|
||||
DefaultDirectoryWalker(DirectoryCreator);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fills the BaseDirectory string
|
||||
*
|
||||
* TODO: Potential buffer overflow caused by limited size of BaseDirectory?
|
||||
**/
|
||||
|
||||
//Fills the BaseDirectory string
|
||||
//TODO: Potential buffer overflow caused by limited size of BaseDirectory?
|
||||
void GetBaseDirectory(void)
|
||||
{
|
||||
unsigned int i;
|
||||
GetModuleFileName(0, (LPTSTR)BaseDirectory, sizeof(BaseDirectory) - 1);
|
||||
char temp[2048];
|
||||
GetModuleFileName(0, temp, 2048);
|
||||
BaseDirectory = temp;
|
||||
|
||||
// Search for the last / or \ in the directory and terminate the string there
|
||||
for(i = strlen(BaseDirectory); i >= 0 ; i--)
|
||||
{
|
||||
if(BaseDirectory[i]=='\\' || BaseDirectory[i]=='/')
|
||||
{
|
||||
BaseDirectory[i] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
size_t truncate_at = BaseDirectory.find_last_of("\\/");
|
||||
if(truncate_at != std::string::npos)
|
||||
BaseDirectory = BaseDirectory.substr(0,truncate_at);
|
||||
}
|
||||
|
||||
int BlockingCheck()
|
||||
|
@ -348,11 +326,8 @@ void UpdateRendBounds()
|
|||
FCEUI_SetRenderedLines(srendlinen, erendlinen, srendlinep, erendlinep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an error message in a message box.
|
||||
*
|
||||
* @param errormsg Text of the error message.
|
||||
**/
|
||||
/// Shows an error message in a message box.
|
||||
///@param errormsg Text of the error message.
|
||||
void FCEUD_PrintError(const char *errormsg)
|
||||
{
|
||||
AddLogText(errormsg, 1);
|
||||
|
@ -370,54 +345,49 @@ void FCEUD_PrintError(const char *errormsg)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a compiler identification string.
|
||||
*
|
||||
* @return Compiler identification string
|
||||
**/
|
||||
///Generates a compiler identification string.
|
||||
/// @return Compiler identification string
|
||||
const char *FCEUD_GetCompilerString()
|
||||
{
|
||||
return __COMPILER__STRING__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the about box
|
||||
**/
|
||||
//Displays the about box
|
||||
void ShowAboutBox()
|
||||
{
|
||||
MessageBox(hAppWnd, FCEUI_GetAboutString(), FCEU_NAME, MB_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits FCE Ultra
|
||||
**/
|
||||
//Exits FCE Ultra
|
||||
void DoFCEUExit()
|
||||
{
|
||||
/* Wolfenstein 3D had cute exit messages. */
|
||||
char *emsg[4]={"Are you sure you want to leave? I'll become lonely!",
|
||||
"If you exit, I'll... EAT YOUR MOUSE.",
|
||||
"You can never really exit, you know.",
|
||||
"E-x-i-t?"
|
||||
};
|
||||
|
||||
KillDebugger(); //mbg merge 7/19/06 added
|
||||
|
||||
if(exiting) /* Eh, oops. I'll need to try to fix this later. */
|
||||
if(exiting) //Eh, oops. I'll need to try to fix this later.
|
||||
return;
|
||||
|
||||
if(goptions & GOO_CONFIRMEXIT)
|
||||
{
|
||||
//Wolfenstein 3D had cute exit messages.
|
||||
const char * const emsg[4]={"Are you sure you want to leave? I'll become lonely!",
|
||||
"If you exit, I'll... EAT YOUR MOUSE.",
|
||||
"You can never really exit, you know.",
|
||||
"E-x-i-t?"
|
||||
};
|
||||
|
||||
if(IDYES != MessageBox(hAppWnd, emsg[rand() & 3], "Exit FCE Ultra?", MB_ICONQUESTION | MB_YESNO) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CloseMemoryWatch();
|
||||
|
||||
KillDebugger(); //mbg merge 7/19/06 added
|
||||
|
||||
FCEUI_StopMovie();
|
||||
FCEUD_AviStop();
|
||||
|
||||
exiting = 1;
|
||||
closeGame = 1;//mbg 6/30/06 - for housekeeping purposes we need to exit after the emulation cycle finishes
|
||||
closeGame = true;//mbg 6/30/06 - for housekeeping purposes we need to exit after the emulation cycle finishes
|
||||
}
|
||||
|
||||
void FCEUD_OnCloseGame()
|
||||
|
@ -459,7 +429,7 @@ int DriverInitialize()
|
|||
static void DriverKill(void)
|
||||
{
|
||||
// Save config file
|
||||
sprintf(TempArray, "%s/fceu98.cfg", BaseDirectory);
|
||||
sprintf(TempArray, "%s/fceu98.cfg", BaseDirectory.c_str());
|
||||
SaveConfig(TempArray);
|
||||
|
||||
DestroyInput();
|
||||
|
@ -551,10 +521,7 @@ void do_exit()
|
|||
FCEUI_Kill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the default directory names into the elements of the directory_names array
|
||||
* that aren't already defined.
|
||||
**/
|
||||
//Puts the default directory names into the elements of the directory_names array that aren't already defined.
|
||||
void initDirectories()
|
||||
{
|
||||
for (unsigned int i = 0; i < NUMBER_OF_DEFAULT_DIRECTORIES; i++)
|
||||
|
@ -564,7 +531,7 @@ void initDirectories()
|
|||
sprintf(
|
||||
TempArray,
|
||||
"%s\\%s",
|
||||
directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] ? directory_names[NUMBER_OF_DEFAULT_DIRECTORIES] : BaseDirectory,
|
||||
directory_names[i] ? directory_names[i] : BaseDirectory.c_str(),
|
||||
default_directory_names[i]
|
||||
);
|
||||
|
||||
|
@ -575,8 +542,8 @@ void initDirectories()
|
|||
|
||||
if (directory_names[NUMBER_OF_DIRECTORIES - 1] == 0)
|
||||
{
|
||||
directory_names[NUMBER_OF_DIRECTORIES - 1] = (char*)malloc(strlen(BaseDirectory) + 1);
|
||||
strcpy(directory_names[NUMBER_OF_DIRECTORIES - 1], BaseDirectory);
|
||||
directory_names[NUMBER_OF_DIRECTORIES - 1] = (char*)malloc(BaseDirectory.size() + 1);
|
||||
strcpy(directory_names[NUMBER_OF_DIRECTORIES - 1], BaseDirectory.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +574,7 @@ int main(int argc,char *argv[])
|
|||
GetBaseDirectory();
|
||||
|
||||
// Load the config information
|
||||
sprintf(TempArray,"%s\\fceu98.cfg",BaseDirectory);
|
||||
sprintf(TempArray,"%s\\fceu98.cfg",BaseDirectory.c_str());
|
||||
LoadConfig(TempArray);
|
||||
|
||||
initDirectories();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define WIN_MAIN_H
|
||||
|
||||
#include "common.h"
|
||||
#include <string>
|
||||
|
||||
// #defines
|
||||
|
||||
|
@ -44,9 +45,7 @@ static char *gfsdir=0;
|
|||
|
||||
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[12] = {
|
||||
"", // roms
|
||||
"sav", // nonvol
|
||||
|
@ -88,10 +87,8 @@ extern int ntsccol, ntsctint, ntschue;
|
|||
|
||||
static int changerecursive=0;
|
||||
|
||||
/**
|
||||
* Contains the base directory of FCE
|
||||
**/
|
||||
extern char BaseDirectory[2048];
|
||||
/// Contains the base directory of FCE
|
||||
extern std::string BaseDirectory;
|
||||
|
||||
extern int soundo;
|
||||
extern int eoptions;
|
||||
|
|
|
@ -646,9 +646,12 @@ void InputData(char *input){
|
|||
if(EditingMode == 0)BWrite[addr](addr,data[i]);
|
||||
if(EditingMode == 1){
|
||||
addr &= 0x3FFF;
|
||||
if(addr < 0x2000)VPage[addr>>10][addr] = data[i]; //todo: detect if this is vrom and turn it red if so
|
||||
if((addr > 0x2000) && (addr < 0x3F00))vnapage[(addr>>10)&0x3][addr&0x3FF] = data[i]; //todo: this causes 0x3000-0x3f00 to mirror 0x2000-0x2f00, is this correct?
|
||||
if((addr > 0x3F00) && (addr < 0x3FFF))PALRAM[addr&0x1F] = data[i];
|
||||
if(addr < 0x2000)
|
||||
VPage[addr>>10][addr] = data[i]; //todo: detect if this is vrom and turn it red if so
|
||||
if((addr >= 0x2000) && (addr < 0x3F00))
|
||||
vnapage[(addr>>10)&0x3][addr&0x3FF] = data[i]; //todo: this causes 0x3000-0x3f00 to mirror 0x2000-0x2f00, is this correct?
|
||||
if((addr >= 0x3F00) && (addr < 0x3FFF))
|
||||
PALRAM[addr&0x1F] = data[i];
|
||||
}
|
||||
if(EditingMode == 2){
|
||||
ApplyPatch(addr,datasize,data);
|
||||
|
|
|
@ -584,19 +584,22 @@ fileChanged = false;
|
|||
|
||||
void CloseMemoryWatch()
|
||||
{
|
||||
SaveStrings();
|
||||
if(hwndMemWatch)
|
||||
{
|
||||
SaveStrings();
|
||||
|
||||
//TODO: save window x,y and last file opened to some variables then save them to config when fceu closes
|
||||
if (fileChanged==true)
|
||||
//TODO: save window x,y and last file opened to some variables then save them to config when fceu closes
|
||||
if (fileChanged==true)
|
||||
{
|
||||
if(MessageBox(hwndMemWatch, "Save Changes?", "Memory Watch Settings", MB_YESNO)==IDYES)
|
||||
{
|
||||
if(MessageBox(hwndMemWatch, "Save Changes?", "Save", MB_YESNO)==IDYES)
|
||||
{
|
||||
SaveMemWatch();
|
||||
}
|
||||
SaveMemWatch();
|
||||
}
|
||||
}
|
||||
|
||||
DestroyWindow(hwndMemWatch);
|
||||
hwndMemWatch=0;
|
||||
DestroyWindow(hwndMemWatch);
|
||||
hwndMemWatch=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
void UpdateMemWatch();
|
||||
void CreateMemWatch();
|
||||
void CloseMemoryWatch();
|
||||
void AddMemWatch(char memaddress[32]);
|
||||
extern char * MemWatchDir;
|
||||
extern bool MemWatchLoadOnStart;
|
||||
|
|
|
@ -40,7 +40,7 @@ static char* GetReplayPath(HWND hwndDlg)
|
|||
else
|
||||
strcpy(szChoice, szTemp);
|
||||
|
||||
SetCurrentDirectory(BaseDirectory);
|
||||
SetCurrentDirectory(BaseDirectory.c_str());
|
||||
|
||||
_splitpath(szChoice, szDrive, szDirectory, szFilename, szExt);
|
||||
if(szDrive[0]=='\0' && szDirectory[0]=='\0')
|
||||
|
@ -374,7 +374,7 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
//if we get here, then we had a match
|
||||
|
||||
char relative[MAX_PATH];
|
||||
AbsoluteToRelative(relative, filename, BaseDirectory);
|
||||
AbsoluteToRelative(relative, filename, BaseDirectory.c_str());
|
||||
SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_INSERTSTRING, i++, (LPARAM)relative);
|
||||
} while(FindNextFile(hFind, &wfd));
|
||||
FindClose(hFind);
|
||||
|
@ -453,7 +453,7 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
char relative[MAX_PATH];
|
||||
AbsoluteToRelative(relative, szFile, BaseDirectory);
|
||||
AbsoluteToRelative(relative, szFile, BaseDirectory.c_str());
|
||||
|
||||
LONG lOtherIndex = SendDlgItemMessage(hwndDlg, IDC_COMBO_FILENAME, CB_FINDSTRING, (WPARAM)-1, (LPARAM)relative);
|
||||
if(lOtherIndex != CB_ERR)
|
||||
|
|
|
@ -67,6 +67,9 @@ BEGIN
|
|||
MENUITEM "&Switch Disk Side", MENU_SWITCH_DISK
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Insert Coin", MENU_INSERT_COIN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Display BG", MENU_DISPLAY_BG
|
||||
MENUITEM "Display OBJ", MENU_DISPLAY_OBJ
|
||||
END
|
||||
POPUP "&Config"
|
||||
BEGIN
|
||||
|
|
|
@ -518,6 +518,11 @@
|
|||
#define ID_FILE_OOADFM2 40141
|
||||
#define ID_FILE_OPENFM2 40142
|
||||
#define ID_FILE_SAVEFM2 40143
|
||||
#define ID_TWEAKS_DISPLAYBG 40144
|
||||
#define ID_TWEAKS_DISPLAYOBJ 40145
|
||||
#define ID_ 40146
|
||||
#define MENU_DISPLAY_BG 40147
|
||||
#define MENU_DISPLAY_OBJ 40148
|
||||
#define MW_ValueLabel2 65423
|
||||
#define MW_ValueLabel1 65426
|
||||
#define GUI_BOT_DEBUG 65436
|
||||
|
@ -528,7 +533,7 @@
|
|||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 114
|
||||
#define _APS_NEXT_COMMAND_VALUE 40144
|
||||
#define _APS_NEXT_COMMAND_VALUE 40149
|
||||
#define _APS_NEXT_CONTROL_VALUE 1132
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
@ -166,16 +166,24 @@ void updateGameDependentMenus(unsigned int enable)
|
|||
//Updates menu items which need to be checked or unchecked.
|
||||
void UpdateCheckedMenuItems()
|
||||
{
|
||||
static int *polo[] = { &genie, &pal_emulation, &status_icon };
|
||||
bool spr, bg;
|
||||
FCEUI_GetRenderPlanes(spr,bg);
|
||||
|
||||
static int *polo[] = { &genie, &pal_emulation, &status_icon};
|
||||
static int polo2[]={ MENU_GAME_GENIE, MENU_PAL, MENU_SHOW_STATUS_ICON };
|
||||
int x;
|
||||
|
||||
|
||||
|
||||
// Check or uncheck the necessary menu items
|
||||
for(x = 0; x < sizeof(polo) / sizeof(*polo); x++)
|
||||
{
|
||||
CheckMenuItem(fceumenu, polo2[x], *polo[x] ? MF_CHECKED : MF_UNCHECKED);
|
||||
}
|
||||
|
||||
CheckMenuItem(fceumenu, MENU_DISPLAY_BG, bg?MF_CHECKED:MF_UNCHECKED);
|
||||
CheckMenuItem(fceumenu, MENU_DISPLAY_OBJ, spr?MF_CHECKED:MF_UNCHECKED);
|
||||
|
||||
CheckMenuItem(fceumenu, MENU_PAUSEAFTERPLAYBACK, pauseAfterPlayback ? MF_CHECKED : MF_UNCHECKED);
|
||||
CheckMenuItem(fceumenu, MENU_RUN_IN_BACKGROUND, eoptions & EO_BGRUN ? MF_CHECKED : MF_UNCHECKED);
|
||||
|
||||
|
@ -872,6 +880,20 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
SetMainWindowStuff();
|
||||
break;
|
||||
|
||||
case MENU_DISPLAY_BG:
|
||||
case MENU_DISPLAY_OBJ:
|
||||
{
|
||||
bool spr, bg;
|
||||
FCEUI_GetRenderPlanes(spr,bg);
|
||||
if(LOWORD(wParam)==MENU_DISPLAY_BG)
|
||||
bg = !bg;
|
||||
else
|
||||
spr = !spr;
|
||||
FCEUI_SetRenderPlanes(spr,bg);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case MENU_CHEATS:
|
||||
ConfigCheats(hWnd);
|
||||
break;
|
||||
|
@ -1108,6 +1130,8 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
}
|
||||
goto proco;
|
||||
case WM_ENTERMENULOOP:
|
||||
UpdateCheckedMenuItems();
|
||||
|
||||
EnableMenuItem(fceumenu,MENU_RESET,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_RESET)?MF_ENABLED:MF_GRAYED));
|
||||
EnableMenuItem(fceumenu,MENU_POWER,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_POWER)?MF_ENABLED:MF_GRAYED));
|
||||
EnableMenuItem(fceumenu,MENU_TASEDIT,MF_BYCOMMAND | (FCEU_IsValidUI(FCEUI_TASEDIT)?MF_ENABLED:MF_GRAYED));
|
||||
|
|
738
src/file.cpp
738
src/file.cpp
|
@ -42,6 +42,8 @@
|
|||
#include "driver.h"
|
||||
#include "utils/xstring.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct {
|
||||
uint8 *data;
|
||||
uint32 size;
|
||||
|
@ -50,397 +52,397 @@ typedef struct {
|
|||
|
||||
void ApplyIPS(FILE *ips, MEMWRAP *dest)
|
||||
{
|
||||
uint8 header[5];
|
||||
uint32 count=0;
|
||||
uint8 header[5];
|
||||
uint32 count=0;
|
||||
|
||||
FCEU_printf(" Applying IPS...\n");
|
||||
if(fread(header,1,5,ips)!=5)
|
||||
{
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
if(memcmp(header,"PATCH",5))
|
||||
{
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
FCEU_printf(" Applying IPS...\n");
|
||||
if(fread(header,1,5,ips)!=5)
|
||||
{
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
if(memcmp(header,"PATCH",5))
|
||||
{
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
|
||||
while(fread(header,1,3,ips)==3)
|
||||
{
|
||||
uint32 offset=(header[0]<<16)|(header[1]<<8)|header[2];
|
||||
uint16 size;
|
||||
while(fread(header,1,3,ips)==3)
|
||||
{
|
||||
uint32 offset=(header[0]<<16)|(header[1]<<8)|header[2];
|
||||
uint16 size;
|
||||
|
||||
if(!memcmp(header,"EOF",3))
|
||||
{
|
||||
FCEU_printf(" IPS EOF: Did %d patches\n\n",count);
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
if(!memcmp(header,"EOF",3))
|
||||
{
|
||||
FCEU_printf(" IPS EOF: Did %d patches\n\n",count);
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
|
||||
size=fgetc(ips)<<8;
|
||||
size|=fgetc(ips);
|
||||
if(!size) /* RLE */
|
||||
{
|
||||
uint8 *start;
|
||||
uint8 b;
|
||||
size=fgetc(ips)<<8;
|
||||
size|=fgetc(ips);
|
||||
size=fgetc(ips)<<8;
|
||||
size|=fgetc(ips);
|
||||
if(!size) /* RLE */
|
||||
{
|
||||
uint8 *start;
|
||||
uint8 b;
|
||||
size=fgetc(ips)<<8;
|
||||
size|=fgetc(ips);
|
||||
|
||||
//FCEU_printf(" Offset: %8d Size: %5d RLE\n",offset,size);
|
||||
//FCEU_printf(" Offset: %8d Size: %5d RLE\n",offset,size);
|
||||
|
||||
if((offset+size)>dest->size)
|
||||
{
|
||||
uint8 *tmp;
|
||||
if((offset+size)>dest->size)
|
||||
{
|
||||
uint8 *tmp;
|
||||
|
||||
// Probably a little slow.
|
||||
tmp=(uint8 *)realloc(dest->data,offset+size);
|
||||
if(!tmp)
|
||||
{
|
||||
FCEU_printf(" Oops. IPS patch %d(type RLE) goes beyond end of file. Could not allocate memory.\n",count);
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
dest->size=offset+size;
|
||||
dest->data=tmp;
|
||||
memset(dest->data+dest->size,0,offset+size-dest->size);
|
||||
}
|
||||
b=fgetc(ips);
|
||||
start=dest->data+offset;
|
||||
do
|
||||
{
|
||||
*start=b;
|
||||
start++;
|
||||
} while(--size);
|
||||
}
|
||||
else /* Normal patch */
|
||||
{
|
||||
//FCEU_printf(" Offset: %8d Size: %5d\n",offset,size);
|
||||
if((offset+size)>dest->size)
|
||||
{
|
||||
uint8 *tmp;
|
||||
// Probably a little slow.
|
||||
tmp=(uint8 *)realloc(dest->data,offset+size);
|
||||
if(!tmp)
|
||||
{
|
||||
FCEU_printf(" Oops. IPS patch %d(type RLE) goes beyond end of file. Could not allocate memory.\n",count);
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
dest->size=offset+size;
|
||||
dest->data=tmp;
|
||||
memset(dest->data+dest->size,0,offset+size-dest->size);
|
||||
}
|
||||
b=fgetc(ips);
|
||||
start=dest->data+offset;
|
||||
do
|
||||
{
|
||||
*start=b;
|
||||
start++;
|
||||
} while(--size);
|
||||
}
|
||||
else /* Normal patch */
|
||||
{
|
||||
//FCEU_printf(" Offset: %8d Size: %5d\n",offset,size);
|
||||
if((offset+size)>dest->size)
|
||||
{
|
||||
uint8 *tmp;
|
||||
|
||||
// Probably a little slow.
|
||||
tmp=(uint8 *)realloc(dest->data,offset+size);
|
||||
if(!tmp)
|
||||
{
|
||||
FCEU_printf(" Oops. IPS patch %d(type normal) goes beyond end of file. Could not allocate memory.\n",count);
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
dest->data=tmp;
|
||||
memset(dest->data+dest->size,0,offset+size-dest->size);
|
||||
}
|
||||
fread(dest->data+offset,1,size,ips);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
fclose(ips);
|
||||
FCEU_printf(" Hard IPS end!\n");
|
||||
// Probably a little slow.
|
||||
tmp=(uint8 *)realloc(dest->data,offset+size);
|
||||
if(!tmp)
|
||||
{
|
||||
FCEU_printf(" Oops. IPS patch %d(type normal) goes beyond end of file. Could not allocate memory.\n",count);
|
||||
fclose(ips);
|
||||
return;
|
||||
}
|
||||
dest->data=tmp;
|
||||
memset(dest->data+dest->size,0,offset+size-dest->size);
|
||||
}
|
||||
fread(dest->data+offset,1,size,ips);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
fclose(ips);
|
||||
FCEU_printf(" Hard IPS end!\n");
|
||||
}
|
||||
|
||||
static MEMWRAP *MakeMemWrap(void *tz, int type)
|
||||
{
|
||||
MEMWRAP *tmp;
|
||||
MEMWRAP *tmp;
|
||||
|
||||
if(!(tmp=(MEMWRAP *)FCEU_malloc(sizeof(MEMWRAP))))
|
||||
goto doret;
|
||||
tmp->location=0;
|
||||
if(!(tmp=(MEMWRAP *)FCEU_malloc(sizeof(MEMWRAP))))
|
||||
goto doret;
|
||||
tmp->location=0;
|
||||
|
||||
if(type==0)
|
||||
{
|
||||
fseek((FILE *)tz,0,SEEK_END);
|
||||
tmp->size=ftell((FILE *)tz);
|
||||
fseek((FILE *)tz,0,SEEK_SET);
|
||||
if(!(tmp->data=(uint8*)FCEU_malloc(tmp->size)))
|
||||
{
|
||||
free(tmp);
|
||||
tmp=0;
|
||||
goto doret;
|
||||
}
|
||||
fread(tmp->data,1,tmp->size,(FILE *)tz);
|
||||
}
|
||||
else if(type==1)
|
||||
{
|
||||
/* Bleck. The gzip file format has the size of the uncompressed data,
|
||||
but I can't get to the info with the zlib interface(?). */
|
||||
for(tmp->size=0; gzgetc(tz) != EOF; tmp->size++);
|
||||
gzseek(tz,0,SEEK_SET);
|
||||
if(!(tmp->data=(uint8 *)FCEU_malloc(tmp->size)))
|
||||
{
|
||||
free(tmp);
|
||||
tmp=0;
|
||||
goto doret;
|
||||
}
|
||||
gzread(tz,tmp->data,tmp->size);
|
||||
}
|
||||
else if(type==2)
|
||||
{
|
||||
unz_file_info ufo;
|
||||
unzGetCurrentFileInfo(tz,&ufo,0,0,0,0,0,0);
|
||||
if(type==0)
|
||||
{
|
||||
fseek((FILE *)tz,0,SEEK_END);
|
||||
tmp->size=ftell((FILE *)tz);
|
||||
fseek((FILE *)tz,0,SEEK_SET);
|
||||
if(!(tmp->data=(uint8*)FCEU_malloc(tmp->size)))
|
||||
{
|
||||
free(tmp);
|
||||
tmp=0;
|
||||
goto doret;
|
||||
}
|
||||
fread(tmp->data,1,tmp->size,(FILE *)tz);
|
||||
}
|
||||
else if(type==1)
|
||||
{
|
||||
/* Bleck. The gzip file format has the size of the uncompressed data,
|
||||
but I can't get to the info with the zlib interface(?). */
|
||||
for(tmp->size=0; gzgetc(tz) != EOF; tmp->size++);
|
||||
gzseek(tz,0,SEEK_SET);
|
||||
if(!(tmp->data=(uint8 *)FCEU_malloc(tmp->size)))
|
||||
{
|
||||
free(tmp);
|
||||
tmp=0;
|
||||
goto doret;
|
||||
}
|
||||
gzread(tz,tmp->data,tmp->size);
|
||||
}
|
||||
else if(type==2)
|
||||
{
|
||||
unz_file_info ufo;
|
||||
unzGetCurrentFileInfo(tz,&ufo,0,0,0,0,0,0);
|
||||
|
||||
tmp->size=ufo.uncompressed_size;
|
||||
if(!(tmp->data=(uint8 *)FCEU_malloc(ufo.uncompressed_size)))
|
||||
{
|
||||
free(tmp);
|
||||
tmp=0;
|
||||
goto doret;
|
||||
}
|
||||
unzReadCurrentFile(tz,tmp->data,ufo.uncompressed_size);
|
||||
}
|
||||
tmp->size=ufo.uncompressed_size;
|
||||
if(!(tmp->data=(uint8 *)FCEU_malloc(ufo.uncompressed_size)))
|
||||
{
|
||||
free(tmp);
|
||||
tmp=0;
|
||||
goto doret;
|
||||
}
|
||||
unzReadCurrentFile(tz,tmp->data,ufo.uncompressed_size);
|
||||
}
|
||||
|
||||
doret:
|
||||
if(type==0)
|
||||
{
|
||||
fclose((FILE *)tz);
|
||||
}
|
||||
else if(type==1)
|
||||
{
|
||||
gzclose(tz);
|
||||
}
|
||||
else if(type==2)
|
||||
{
|
||||
unzCloseCurrentFile(tz);
|
||||
unzClose(tz);
|
||||
}
|
||||
return tmp;
|
||||
doret:
|
||||
if(type==0)
|
||||
{
|
||||
fclose((FILE *)tz);
|
||||
}
|
||||
else if(type==1)
|
||||
{
|
||||
gzclose(tz);
|
||||
}
|
||||
else if(type==2)
|
||||
{
|
||||
unzCloseCurrentFile(tz);
|
||||
unzClose(tz);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define strcasecmp strcmp
|
||||
#define strcasecmp strcmp
|
||||
#endif
|
||||
|
||||
|
||||
FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext)
|
||||
{
|
||||
FILE *ipsfile=0;
|
||||
FCEUFILE *fceufp;
|
||||
void *t;
|
||||
FILE *ipsfile=0;
|
||||
FCEUFILE *fceufp;
|
||||
void *t;
|
||||
|
||||
if(ipsfn && strchr(mode,'r'))
|
||||
ipsfile=FCEUD_UTF8fopen(ipsfn,"rb");
|
||||
if(ipsfn && strchr(mode,'r'))
|
||||
ipsfile=FCEUD_UTF8fopen(ipsfn,"rb");
|
||||
|
||||
fceufp=(FCEUFILE *)malloc(sizeof(FCEUFILE));
|
||||
fceufp=(FCEUFILE *)malloc(sizeof(FCEUFILE));
|
||||
|
||||
{
|
||||
unzFile tz;
|
||||
if((tz=unzOpen(path))) // If it's not a zip file, use regular file handlers.
|
||||
// Assuming file type by extension usually works,
|
||||
// but I don't like it. :)
|
||||
{
|
||||
if(unzGoToFirstFile(tz)==UNZ_OK)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
char tempu[512]; // Longer filenames might be possible, but I don't
|
||||
// think people would name files that long in zip files...
|
||||
unzGetCurrentFileInfo(tz,0,tempu,512,0,0,0,0);
|
||||
tempu[511]=0;
|
||||
if(strlen(tempu)>=4)
|
||||
{
|
||||
char *za=tempu+strlen(tempu)-4;
|
||||
{
|
||||
unzFile tz;
|
||||
if((tz=unzOpen(path))) // If it's not a zip file, use regular file handlers.
|
||||
// Assuming file type by extension usually works,
|
||||
// but I don't like it. :)
|
||||
{
|
||||
if(unzGoToFirstFile(tz)==UNZ_OK)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
char tempu[512]; // Longer filenames might be possible, but I don't
|
||||
// think people would name files that long in zip files...
|
||||
unzGetCurrentFileInfo(tz,0,tempu,512,0,0,0,0);
|
||||
tempu[511]=0;
|
||||
if(strlen(tempu)>=4)
|
||||
{
|
||||
char *za=tempu+strlen(tempu)-4;
|
||||
|
||||
if(!ext)
|
||||
{
|
||||
if(!strcasecmp(za,".nes") || !strcasecmp(za,".fds") ||
|
||||
!strcasecmp(za,".nsf") || !strcasecmp(za,".unf") ||
|
||||
!strcasecmp(za,".nez"))
|
||||
break;
|
||||
}
|
||||
else if(!strcasecmp(za,ext))
|
||||
break;
|
||||
}
|
||||
if(strlen(tempu)>=5)
|
||||
{
|
||||
if(!strcasecmp(tempu+strlen(tempu)-5,".unif"))
|
||||
break;
|
||||
}
|
||||
if(unzGoToNextFile(tz)!=UNZ_OK)
|
||||
{
|
||||
if(unzGoToFirstFile(tz)!=UNZ_OK) goto zpfail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(unzOpenCurrentFile(tz)!=UNZ_OK)
|
||||
goto zpfail;
|
||||
}
|
||||
else
|
||||
{
|
||||
zpfail:
|
||||
free(fceufp);
|
||||
unzClose(tz);
|
||||
return 0;
|
||||
}
|
||||
if(!(fceufp->fp=MakeMemWrap(tz,2)))
|
||||
{
|
||||
free(fceufp);
|
||||
return(0);
|
||||
}
|
||||
fceufp->type=2;
|
||||
if(ipsfile)
|
||||
ApplyIPS(ipsfile,(MEMWRAP *)fceufp->fp);
|
||||
return(fceufp);
|
||||
}
|
||||
}
|
||||
if(!ext)
|
||||
{
|
||||
if(!strcasecmp(za,".nes") || !strcasecmp(za,".fds") ||
|
||||
!strcasecmp(za,".nsf") || !strcasecmp(za,".unf") ||
|
||||
!strcasecmp(za,".nez"))
|
||||
break;
|
||||
}
|
||||
else if(!strcasecmp(za,ext))
|
||||
break;
|
||||
}
|
||||
if(strlen(tempu)>=5)
|
||||
{
|
||||
if(!strcasecmp(tempu+strlen(tempu)-5,".unif"))
|
||||
break;
|
||||
}
|
||||
if(unzGoToNextFile(tz)!=UNZ_OK)
|
||||
{
|
||||
if(unzGoToFirstFile(tz)!=UNZ_OK) goto zpfail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(unzOpenCurrentFile(tz)!=UNZ_OK)
|
||||
goto zpfail;
|
||||
}
|
||||
else
|
||||
{
|
||||
zpfail:
|
||||
free(fceufp);
|
||||
unzClose(tz);
|
||||
return 0;
|
||||
}
|
||||
if(!(fceufp->fp=MakeMemWrap(tz,2)))
|
||||
{
|
||||
free(fceufp);
|
||||
return(0);
|
||||
}
|
||||
fceufp->type=2;
|
||||
if(ipsfile)
|
||||
ApplyIPS(ipsfile,(MEMWRAP *)fceufp->fp);
|
||||
return(fceufp);
|
||||
}
|
||||
}
|
||||
|
||||
if((t=FCEUD_UTF8fopen(path,"rb")))
|
||||
{
|
||||
uint32 magic;
|
||||
if((t=FCEUD_UTF8fopen(path,"rb")))
|
||||
{
|
||||
uint32 magic;
|
||||
|
||||
magic=fgetc((FILE *)t);
|
||||
magic|=fgetc((FILE *)t)<<8;
|
||||
magic|=fgetc((FILE *)t)<<16;
|
||||
magic=fgetc((FILE *)t);
|
||||
magic|=fgetc((FILE *)t)<<8;
|
||||
magic|=fgetc((FILE *)t)<<16;
|
||||
|
||||
if(magic!=0x088b1f) /* Not gzip... */
|
||||
fclose((FILE *)t);
|
||||
else /* Probably gzip */
|
||||
{
|
||||
int fd;
|
||||
if(magic!=0x088b1f) /* Not gzip... */
|
||||
fclose((FILE *)t);
|
||||
else /* Probably gzip */
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = dup(fileno( (FILE *)t));
|
||||
fd = dup(fileno( (FILE *)t));
|
||||
|
||||
fclose((FILE*)t); //mbg merge 7/17/06 - cast to FILE*
|
||||
fclose((FILE*)t); //mbg merge 7/17/06 - cast to FILE*
|
||||
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
if((t=gzdopen(fd,mode)))
|
||||
{
|
||||
fceufp->type=1;
|
||||
fceufp->fp=t;
|
||||
if(ipsfile)
|
||||
{
|
||||
fceufp->fp=MakeMemWrap(t,1);
|
||||
gzclose(t);
|
||||
if((t=gzdopen(fd,mode)))
|
||||
{
|
||||
fceufp->type=1;
|
||||
fceufp->fp=t;
|
||||
if(ipsfile)
|
||||
{
|
||||
fceufp->fp=MakeMemWrap(t,1);
|
||||
gzclose(t);
|
||||
|
||||
if(fceufp->fp)
|
||||
{
|
||||
free(fceufp);
|
||||
return(0);
|
||||
}
|
||||
if(fceufp->fp)
|
||||
{
|
||||
free(fceufp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
fceufp->type=3;
|
||||
ApplyIPS(ipsfile,(MEMWRAP *)fceufp->fp);
|
||||
}
|
||||
return(fceufp);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
fceufp->type=3;
|
||||
ApplyIPS(ipsfile,(MEMWRAP *)fceufp->fp);
|
||||
}
|
||||
return(fceufp);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if((t=FCEUD_UTF8fopen(path,mode)))
|
||||
{
|
||||
fseek((FILE *)t,0,SEEK_SET);
|
||||
fceufp->type=0;
|
||||
fceufp->fp=t;
|
||||
if(ipsfile)
|
||||
{
|
||||
if(!(fceufp->fp=MakeMemWrap(t,0)))
|
||||
{
|
||||
free(fceufp);
|
||||
return(0);
|
||||
}
|
||||
fceufp->type=3;
|
||||
ApplyIPS(ipsfile,(MEMWRAP *)fceufp->fp);
|
||||
}
|
||||
return(fceufp);
|
||||
}
|
||||
if((t=FCEUD_UTF8fopen(path,mode)))
|
||||
{
|
||||
fseek((FILE *)t,0,SEEK_SET);
|
||||
fceufp->type=0;
|
||||
fceufp->fp=t;
|
||||
if(ipsfile)
|
||||
{
|
||||
if(!(fceufp->fp=MakeMemWrap(t,0)))
|
||||
{
|
||||
free(fceufp);
|
||||
return(0);
|
||||
}
|
||||
fceufp->type=3;
|
||||
ApplyIPS(ipsfile,(MEMWRAP *)fceufp->fp);
|
||||
}
|
||||
return(fceufp);
|
||||
}
|
||||
|
||||
free(fceufp);
|
||||
return 0;
|
||||
free(fceufp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FCEU_fclose(FCEUFILE *fp)
|
||||
{
|
||||
if(fp->type==1)
|
||||
{
|
||||
gzclose(fp->fp);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
free(((MEMWRAP*)(fp->fp))->data);
|
||||
free(fp->fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose((FILE *)fp->fp);
|
||||
}
|
||||
free(fp);
|
||||
return 1;
|
||||
if(fp->type==1)
|
||||
{
|
||||
gzclose(fp->fp);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
free(((MEMWRAP*)(fp->fp))->data);
|
||||
free(fp->fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose((FILE *)fp->fp);
|
||||
}
|
||||
free(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp)
|
||||
{
|
||||
if(fp->type==1)
|
||||
{
|
||||
return gzread(fp->fp,ptr,size*nmemb);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
MEMWRAP *wz;
|
||||
uint32 total=size*nmemb;
|
||||
if(fp->type==1)
|
||||
{
|
||||
return gzread(fp->fp,ptr,size*nmemb);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
MEMWRAP *wz;
|
||||
uint32 total=size*nmemb;
|
||||
|
||||
wz=(MEMWRAP*)fp->fp;
|
||||
if(wz->location>=wz->size) return 0;
|
||||
wz=(MEMWRAP*)fp->fp;
|
||||
if(wz->location>=wz->size) return 0;
|
||||
|
||||
if((wz->location+total)>wz->size)
|
||||
{
|
||||
int ak=wz->size-wz->location;
|
||||
memcpy((uint8*)ptr,wz->data+wz->location,ak);
|
||||
wz->location=wz->size;
|
||||
return(ak/size);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((uint8*)ptr,wz->data+wz->location,total);
|
||||
wz->location+=total;
|
||||
return nmemb;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return fread(ptr,size,nmemb,(FILE *)fp->fp);
|
||||
}
|
||||
if((wz->location+total)>wz->size)
|
||||
{
|
||||
int ak=wz->size-wz->location;
|
||||
memcpy((uint8*)ptr,wz->data+wz->location,ak);
|
||||
wz->location=wz->size;
|
||||
return(ak/size);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((uint8*)ptr,wz->data+wz->location,total);
|
||||
wz->location+=total;
|
||||
return nmemb;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return fread(ptr,size,nmemb,(FILE *)fp->fp);
|
||||
}
|
||||
}
|
||||
|
||||
uint64 FCEU_fwrite(void *ptr, size_t size, size_t nmemb, FCEUFILE *fp)
|
||||
{
|
||||
if(fp->type==1)
|
||||
{
|
||||
return gzwrite(fp->fp,ptr,size*nmemb);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return fwrite(ptr,size,nmemb,(FILE *)fp->fp);
|
||||
if(fp->type==1)
|
||||
{
|
||||
return gzwrite(fp->fp,ptr,size*nmemb);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return fwrite(ptr,size,nmemb,(FILE *)fp->fp);
|
||||
}
|
||||
|
||||
int FCEU_fseek(FCEUFILE *fp, long offset, int whence)
|
||||
{
|
||||
if(fp->type==1)
|
||||
{
|
||||
return( (gzseek(fp->fp,offset,whence)>0)?0:-1);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
MEMWRAP *wz;
|
||||
wz=(MEMWRAP*)fp->fp;
|
||||
if(fp->type==1)
|
||||
{
|
||||
return( (gzseek(fp->fp,offset,whence)>0)?0:-1);
|
||||
}
|
||||
else if(fp->type>=2)
|
||||
{
|
||||
MEMWRAP *wz;
|
||||
wz=(MEMWRAP*)fp->fp;
|
||||
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:if(offset>=(long)wz->size) //mbg merge 7/17/06 - added cast to long
|
||||
return(-1);
|
||||
wz->location=offset;break;
|
||||
case SEEK_CUR:if(offset+wz->location>wz->size)
|
||||
return (-1);
|
||||
wz->location+=offset;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return fseek((FILE *)fp->fp,offset,whence);
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:if(offset>=(long)wz->size) //mbg merge 7/17/06 - added cast to long
|
||||
return(-1);
|
||||
wz->location=offset;break;
|
||||
case SEEK_CUR:if(offset+wz->location>wz->size)
|
||||
return (-1);
|
||||
wz->location+=offset;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return fseek((FILE *)fp->fp,offset,whence);
|
||||
}
|
||||
|
||||
uint64 FCEU_ftell(FCEUFILE *fp)
|
||||
|
@ -584,21 +586,16 @@ int FCEU_fisarchive(FCEUFILE *fp)
|
|||
|
||||
|
||||
|
||||
static char BaseDirectory[2048];
|
||||
static std::string BaseDirectory;
|
||||
char FileBase[2048];
|
||||
static char FileExt[2048]; /* Includes the . character, as in ".nes" */
|
||||
static char FileExt[2048]; //Includes the . character, as in ".nes"
|
||||
|
||||
static char FileBaseDirectory[2048];
|
||||
|
||||
/**
|
||||
* Updates the base directory
|
||||
**/
|
||||
void FCEUI_SetBaseDirectory(const char *dir)
|
||||
/// Updates the base directory
|
||||
void FCEUI_SetBaseDirectory(std::string const & dir)
|
||||
{
|
||||
strncpy(BaseDirectory, dir, sizeof(BaseDirectory));
|
||||
|
||||
// TODO: Necessary?
|
||||
BaseDirectory[2047] = 0;
|
||||
BaseDirectory = dir;
|
||||
}
|
||||
|
||||
static char *odirs[FCEUIOD__COUNT]={0,0,0,0,0,0,0,0,0,0,0,0}; // odirs, odors. ^_^
|
||||
|
@ -644,43 +641,43 @@ std::string FCEU_GetPath(int type)
|
|||
if(odirs[FCEUIOD_STATES])
|
||||
return (odirs[FCEUIOD_STATES]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"fcs",BaseDirectory);
|
||||
return BaseDirectory + PSS + "fcs";
|
||||
break;
|
||||
case FCEUMKF_MOVIE:
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
return (odirs[FCEUIOD_MOVIES]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"movies",BaseDirectory);
|
||||
return BaseDirectory + PSS + "movies";
|
||||
break;
|
||||
case FCEUMKF_MEMW:
|
||||
if(odirs[FCEUIOD_MEMW])
|
||||
return (odirs[FCEUIOD_MEMW]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
return BaseDirectory + PSS + "tools";
|
||||
break;
|
||||
case FCEUMKF_BBOT:
|
||||
if(odirs[FCEUIOD_BBOT])
|
||||
return (odirs[FCEUIOD_BBOT]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
return BaseDirectory + PSS + "tools";
|
||||
break;
|
||||
case FCEUMKF_ROMS:
|
||||
if(odirs[FCEUIOD_ROMS])
|
||||
return (odirs[FCEUIOD_ROMS]);
|
||||
else
|
||||
sprintf(ret,"%s",BaseDirectory);
|
||||
return BaseDirectory;
|
||||
break;
|
||||
case FCEUMKF_INPUT:
|
||||
if(odirs[FCEUIOD_INPUT])
|
||||
return (odirs[FCEUIOD_INPUT]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
return BaseDirectory + PSS + "tools";
|
||||
break;
|
||||
case FCEUMKF_LUA:
|
||||
if(odirs[FCEUIOD_LUA])
|
||||
return (odirs[FCEUIOD_LUA]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
return BaseDirectory + PSS + "tools";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -695,15 +692,15 @@ std::string FCEU_MakePath(int type, const char* filebase)
|
|||
{
|
||||
case FCEUMKF_MOVIE:
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
sprintf(ret,"%s"PSS"%s",odirs[FCEUIOD_MOVIES],filebase);
|
||||
return (string)odirs[FCEUIOD_MOVIES] + PSS + filebase;
|
||||
else
|
||||
sprintf(ret,"%s"PSS"movies"PSS"%s",BaseDirectory,filebase);
|
||||
return BaseDirectory + PSS + "movies" + PSS + filebase;
|
||||
break;
|
||||
case FCEUMKF_STATE:
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
sprintf(ret,"%s"PSS"%s",odirs[FCEUIOD_STATES],filebase);
|
||||
return (string)odirs[FCEUIOD_STATES] + PSS + filebase;
|
||||
else
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s",BaseDirectory,filebase);
|
||||
return BaseDirectory + PSS + "fcs" + PSS + filebase;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
|
@ -716,12 +713,11 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
|
||||
switch(type)
|
||||
{
|
||||
case FCEUMKF_NPTEMP: sprintf(ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break;
|
||||
case FCEUMKF_MOVIE:
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
sprintf(ret,"%s"PSS"%s.fm2",odirs[FCEUIOD_MOVIES],FileBase);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"movies"PSS"%s.fm2",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"movies"PSS"%s.fm2",BaseDirectory.c_str(),FileBase);
|
||||
break;
|
||||
case FCEUMKF_STATE:
|
||||
{
|
||||
|
@ -741,7 +737,7 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
}
|
||||
else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1);
|
||||
}
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
|
@ -751,7 +747,7 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
}
|
||||
else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory.c_str(),FileBase,mfn,id1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -762,33 +758,33 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
if(odirs[FCEUIOD_SNAPS])
|
||||
sprintf(ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1);
|
||||
sprintf(ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory.c_str(),FileBase,id1,cd1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(odirs[FCEUIOD_SNAPS])
|
||||
sprintf(ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1);
|
||||
sprintf(ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory.c_str(),id1,cd1);
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_FDS:
|
||||
if(odirs[FCEUIOD_NV])
|
||||
sprintf(ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory.c_str(),FileBase);
|
||||
break;
|
||||
case FCEUMKF_SAV:
|
||||
if(odirs[FCEUIOD_NV])
|
||||
sprintf(ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory.c_str(),FileBase,cd1);
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
if(odirs[FCEUIOD_NV])
|
||||
sprintf(ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory.c_str(),FileBase,cd1);
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_REWINDSTATE:
|
||||
|
@ -798,7 +794,7 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
}
|
||||
else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory.c_str(),id1);
|
||||
}
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
|
@ -808,7 +804,7 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
}
|
||||
else
|
||||
{
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory.c_str(),id1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -816,30 +812,30 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
if(odirs[FCEUIOD_CHEATS])
|
||||
sprintf(ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory.c_str(),FileBase);
|
||||
break;
|
||||
case FCEUMKF_IPS:sprintf(ret,"%s"PSS"%s%s.ips",FileBaseDirectory,FileBase,FileExt);break;
|
||||
case FCEUMKF_GGROM:sprintf(ret,"%s"PSS"gg.rom",BaseDirectory);break;
|
||||
case FCEUMKF_GGROM:sprintf(ret,"%s"PSS"gg.rom",BaseDirectory.c_str());break;
|
||||
case FCEUMKF_FDSROM:
|
||||
if(odirs[FCEUIOD_FDSROM])
|
||||
sprintf(ret,"%s"PSS"disksys.rom",odirs[FCEUIOD_FDSROM]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"disksys.rom",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"disksys.rom",BaseDirectory.c_str());
|
||||
break;
|
||||
case FCEUMKF_PALETTE:sprintf(ret,"%s"PSS"%s.pal",BaseDirectory,FileBase);break;
|
||||
case FCEUMKF_PALETTE:sprintf(ret,"%s"PSS"%s.pal",BaseDirectory.c_str(),FileBase);break;
|
||||
case FCEUMKF_MOVIEGLOB:
|
||||
//these globs use ??? because we can load multiple formats
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
sprintf(ret,"%s"PSS"*.???",odirs[FCEUIOD_MOVIES]);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"movies"PSS"*.???",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"movies"PSS"*.???",BaseDirectory.c_str());
|
||||
break;
|
||||
case FCEUMKF_MOVIEGLOB2:sprintf(ret,"%s"PSS"*.???",BaseDirectory);break;
|
||||
case FCEUMKF_MOVIEGLOB2:sprintf(ret,"%s"PSS"*.???",BaseDirectory.c_str());break;
|
||||
case FCEUMKF_STATEGLOB:
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
sprintf(ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATES],FileBase);
|
||||
else
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory.c_str(),FileBase);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1);
|
|||
#define FCEUMKF_IPS 8
|
||||
#define FCEUMKF_FDS 9
|
||||
#define FCEUMKF_MOVIE 10
|
||||
#define FCEUMKF_NPTEMP 11
|
||||
//#define FCEUMKF_NPTEMP 11 //mbg 6/21/08 - who needs this..?
|
||||
#define FCEUMKF_MOVIEGLOB 12
|
||||
#define FCEUMKF_STATEGLOB 13
|
||||
#define FCEUMKF_MOVIEGLOB2 14
|
||||
|
|
|
@ -155,7 +155,6 @@ static FILE *FetchFile(uint32 remlen)
|
|||
uLongf len;
|
||||
char *buf;
|
||||
FILE *fp;
|
||||
char *fn;
|
||||
|
||||
if(clen > 500000) // Sanity check
|
||||
{
|
||||
|
@ -164,17 +163,14 @@ static FILE *FetchFile(uint32 remlen)
|
|||
}
|
||||
|
||||
//printf("Receiving file: %d...\n",clen);
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_NPTEMP,0,0).c_str());
|
||||
if((fp = fopen(fn,"w+b")))
|
||||
if(fp = tmpfile())
|
||||
{
|
||||
cbuf = (char *)malloc(clen); //mbg merge 7/17/06 added cast
|
||||
if(!FCEUD_RecvData(cbuf, clen))
|
||||
{
|
||||
NetError();
|
||||
unlink(fn);
|
||||
fclose(fp);
|
||||
free(cbuf);
|
||||
free(fn);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -182,10 +178,8 @@ static FILE *FetchFile(uint32 remlen)
|
|||
if(len > 500000) // Another sanity check
|
||||
{
|
||||
NetError();
|
||||
unlink(fn);
|
||||
fclose(fp);
|
||||
free(cbuf);
|
||||
free(fn);
|
||||
return(0);
|
||||
}
|
||||
buf = (char *)malloc(len); //mbg merge 7/17/06 added cast
|
||||
|
@ -194,11 +188,8 @@ static FILE *FetchFile(uint32 remlen)
|
|||
fwrite(buf, 1, len, fp);
|
||||
free(buf);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
unlink(fn);
|
||||
free(fn);
|
||||
return(fp);
|
||||
}
|
||||
free(fn);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
2020
src/ppu.cpp
2020
src/ppu.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue