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