added obj/bg display toggle

much cleanups
fix memwatch configuration saving
This commit is contained in:
zeromus 2008-06-22 02:38:00 +00:00
parent 79de2d8295
commit 69bc4b3f72
17 changed files with 1601 additions and 1624 deletions

View File

@ -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.

View File

@ -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}

View File

@ -54,9 +54,8 @@ 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]),

View File

@ -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);

View File

@ -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(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?"
};
KillDebugger(); //mbg merge 7/19/06 added
if(exiting) /* Eh, oops. I'll need to try to fix this later. */
return;
if(goptions & GOO_CONFIRMEXIT)
{
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();

View File

@ -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;

View File

@ -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);

View File

@ -583,13 +583,15 @@ fileChanged = false;
}
void CloseMemoryWatch()
{
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)
{
if(MessageBox(hwndMemWatch, "Save Changes?", "Save", MB_YESNO)==IDYES)
if(MessageBox(hwndMemWatch, "Save Changes?", "Memory Watch Settings", MB_YESNO)==IDYES)
{
SaveMemWatch();
}
@ -597,6 +599,7 @@ void CloseMemoryWatch()
DestroyWindow(hwndMemWatch);
hwndMemWatch=0;
}
}

View File

@ -1,5 +1,6 @@
void UpdateMemWatch();
void CreateMemWatch();
void CloseMemoryWatch();
void AddMemWatch(char memaddress[32]);
extern char * MemWatchDir;
extern bool MemWatchLoadOnStart;

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -166,16 +166,24 @@ void updateGameDependentMenus(unsigned int enable)
//Updates menu items which need to be checked or unchecked.
void UpdateCheckedMenuItems()
{
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));

View File

@ -42,6 +42,8 @@
#include "driver.h"
#include "utils/xstring.h"
using namespace std;
typedef struct {
uint8 *data;
uint32 size;
@ -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;
}

View File

@ -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

View File

@ -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);
}

View File

@ -40,14 +40,14 @@
#include "input.h"
#include "driver.h"
#define VBlankON (PPU[0]&0x80) /* Generate VBlank NMI */
#define Sprite16 (PPU[0]&0x20) /* Sprites 8x16/8x8 */
#define BGAdrHI (PPU[0]&0x10) /* BG pattern adr $0000/$1000 */
#define SpAdrHI (PPU[0]&0x08) /* Sprite pattern adr $0000/$1000 */
#define INC32 (PPU[0]&0x04) /* auto increment 1/32 */
#define VBlankON (PPU[0]&0x80) //Generate VBlank NMI
#define Sprite16 (PPU[0]&0x20) //Sprites 8x16/8x8
#define BGAdrHI (PPU[0]&0x10) //BG pattern adr $0000/$1000
#define SpAdrHI (PPU[0]&0x08) //Sprite pattern adr $0000/$1000
#define INC32 (PPU[0]&0x04) //auto increment 1/32
#define SpriteON (PPU[1]&0x10) /* Show Sprite */
#define ScreenON (PPU[1]&0x08) /* Show screen */
#define SpriteON (PPU[1]&0x10) //Show Sprite
#define ScreenON (PPU[1]&0x08) //Show screen
#define PPU_status (PPU[2])
@ -119,7 +119,7 @@ uint8 *vnapage[4];
uint8 PPUNTARAM=0;
uint8 PPUCHRRAM=0;
/* Color deemphasis emulation. Joy... */
//Color deemphasis emulation. Joy...
static uint8 deemp=0;
static int deempcnt[8];
@ -133,8 +133,7 @@ uint32 TempAddr=0,RefreshAddr=0;
static int maxsprites=8;
/* scanline is equal to the current visible scanline we're on. */
//scanline is equal to the current visible scanline we're on.
int scanline;
static uint32 scanlines_per_frame;
@ -409,53 +408,53 @@ void FCEUPPU_LineUpdate(void)
}
}
static int tileview=0;
static int rendis = 0;
static bool rendersprites=true, renderbg=true;
void FCEUI_ToggleTileView(void)
void FCEUI_SetRenderPlanes(bool sprites, bool bg)
{
tileview^=1;
rendersprites = sprites;
renderbg = bg;
}
void FCEUI_SetRenderDisable(int sprites, int bg)
void FCEUI_GetRenderPlanes(bool& sprites, bool& bg)
{
//printf("%d, %d\n",sprites,bg);
if(sprites >= 0)
{
if(sprites == 2) rendis ^= 1;
else rendis = (rendis &~1) | sprites?1:0;
sprites = rendersprites;
bg = renderbg;
}
if(bg >= 0)
{
if(bg == 2) rendis ^= 2;
else rendis = (rendis &~2) | bg?2:0;
}
}
/*
static void TileView(void)
{
uint8 *P=XBuf+16*256;
int bgh;
int y;
int X1;
for(bgh=0;bgh<2;bgh++)
for(y=0;y<16*8;y++)
for(P=XBuf+bgh*128+(16+y)*256,X1=16;X1;X1--,P+=8)
{
uint8 *C;
register uint8 cc;
uint32 vadr;
vadr=((((16-X1)|((y>>3)<<4))<<4)|(y&7))+bgh*0x1000;
//C= ROM+vadr+turt*8192;
C = VRAMADR(vadr);
//if((vadr+turt*8192)>=524288)
//printf("%d ",vadr+turt*8192);
cc=0;
//#include "pputile.h"
}
}
*/
//mbg 6/21/08 - tileview is being ripped out since i dont know how long its been since it worked
//static int tileview=1;
//void FCEUI_ToggleTileView(void)
//{
// tileview^=1;
//}
//mbg 6/21/08 - tileview is being ripped out since i dont know how long its been since it worked
//static void TileView(void)
//{
// uint8 *P=XBuf+16*256;
// int bgh;
// int y;
// int X1;
// for(bgh=0;bgh<2;bgh++)
// for(y=0;y<16*8;y++)
// for(P=XBuf+bgh*128+(16+y)*256,X1=16;X1;X1--,P+=8)
// {
// uint8 *C;
// register uint8 cc;
// uint32 vadr;
//
// vadr=((((16-X1)|((y>>3)<<4))<<4)|(y&7))+bgh*0x1000;
// //C= ROM+vadr+turt*8192;
// C = VRAMADR(vadr);
// //if((vadr+turt*8192)>=524288)
// //printf("%d ",vadr+turt*8192);
// cc=0;
// //#include "pputile.h"
// }
//}
static void CheckSpriteHit(int p);
static void EndRL(void)
@ -491,10 +490,10 @@ static void CheckSpriteHit(int p)
}
}
}
static int spork=0; /* spork the world. Any sprites on this line?
Then this will be set to 1. Needed for zapper
emulation and *gasp* sprite emulation.
*/
//spork the world. Any sprites on this line? Then this will be set to 1.
//Needed for zapper emulation and *gasp* sprite emulation.
static int spork=0;
// lasttile is really "second to last tile."
static void RefreshLine(int lastpixel)
@ -563,16 +562,14 @@ static void RefreshLine(int lastpixel)
return;
}
/* Priority bits, needed for sprite emulation. */
//Priority bits, needed for sprite emulation.
Pal[0]|=64;
Pal[4]|=64;
Pal[8]|=64;
Pal[0xC]|=64;
/* This high-level graphics MMC5 emulation code was written
for MMC5 carts in "CL" mode. It's probably not totally
correct for carts in "SL" mode.
*/
//This high-level graphics MMC5 emulation code was written for MMC5 carts in "CL" mode.
//It's probably not totally correct for carts in "SL" mode.
#define PPUT_MMC5
if(MMC5Hack && geniestage!=1)
@ -650,7 +647,7 @@ static void RefreshLine(int lastpixel)
#undef vofs
#undef RefreshAddr
/* Reverse changes made before. */
//Reverse changes made before.
Pal[0]&=63;
Pal[4]&=63;
Pal[8]&=63;
@ -692,9 +689,9 @@ static void RefreshLine(int lastpixel)
//CheckSpriteHit(lasttile*8); //lasttile*8); //lastpixel);
CheckSpriteHit(lastpixel); /* This only works right because
of a hack earlier in this function.
*/
//This only works right because of a hack earlier in this function.
CheckSpriteHit(lastpixel);
if((lastpixel-16)>=0)
{
InputScanlineHook(Plinef,spork?sprlinebuf:0,linestartts,lasttile*8-16);
@ -744,7 +741,7 @@ static void Fixit1(void)
}
}
void MMC5_hb(int); /* Ugh ugh ugh. */
void MMC5_hb(int); //Ugh ugh ugh.
static void DoLine(void)
{
int x;
@ -755,7 +752,7 @@ static void DoLine(void)
X6502_Run(256);
EndRL();
if(rendis & 2) /* User asked to not display background data. */
if(!renderbg) // User asked to not display background data.
{
uint32 tem;
tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24);
@ -976,8 +973,9 @@ static void FetchSpriteData(void)
}
//if(ns>=7)
//printf("%d %d\n",scanline,ns);
if(ns>8) PPU_status|=0x20; /* Handle case when >8 sprites per
scanline option is enabled. */
//Handle case when >8 sprites per scanline option is enabled.
if(ns>8) PPU_status|=0x20;
else if(PPU_hook)
{
for(n=0;n<(8-ns);n++)
@ -1121,7 +1119,7 @@ static void CopySprites(uint8 *target)
if(!spork) return;
spork=0;
if(rendis & 1) return; /* User asked to not display sprites. */
if(!rendersprites) return; //User asked to not display sprites.
loopskie:
{
@ -1209,9 +1207,7 @@ void FCEUPPU_SetVideoSystem(int w)
}
}
/**
* Initializes the PPU
**/
//Initializes the PPU
void FCEUPPU_Init(void)
{
makeppulut();
@ -1264,7 +1260,8 @@ void FCEUPPU_Power(void)
int FCEUPPU_Loop(int skip)
{
if(ppudead) /* Needed for Knight Rider, possibly others. */
//Needed for Knight Rider, possibly others.
if(ppudead)
{
memset(XBuf, 0x80, 256*240);
X6502_Run(scanlines_per_frame*(256+85));
@ -1274,13 +1271,13 @@ int FCEUPPU_Loop(int skip)
{
X6502_Run(256+85);
PPU_status |= 0x80;
PPU[3]=PPUSPL=0; /* Not sure if this is correct. According
to Matt Conte and my own tests, it is. Timing is probably
off, though. NOTE: Not having this here
breaks a Super Donkey Kong game. */
/* I need to figure out the true nature and length
of this delay.
*/
//Not sure if this is correct. According to Matt Conte and my own tests, it is.
//Timing is probably off, though.
//NOTE: Not having this here breaks a Super Donkey Kong game.
PPU[3]=PPUSPL=0;
//I need to figure out the true nature and length of this delay.
X6502_Run(12);
if(GameInfo->type==GIT_NSF)
DoNSFFrame();
@ -1312,7 +1309,7 @@ int FCEUPPU_Loop(int skip)
if(PPU_hook) PPU_hook(RefreshAddr&0x3fff);
}
/* Clean this stuff up later. */
//Clean this stuff up later.
spork=numsprites=0;
ResetRL(XBuf);
@ -1376,7 +1373,7 @@ int FCEUPPU_Loop(int skip)
//memset(deempcnt,0,sizeof(deempcnt));
SetNESDeemph(maxref,0);
}
} /* else... to if(ppudead) */
} //else... to if(ppudead)
#ifdef FRAMESKIP
if(skip)
@ -1387,6 +1384,7 @@ int FCEUPPU_Loop(int skip)
else
#endif
{
//mbg 6/21/08 - tileview is being ripped out since i dont know how long its been since it worked
//if(tileview) TileView();
FCEU_PutImage();
return(1);