faster compiles (mappers include 1/3 as much code now)
fix some memory leaks by changing the path generation APIs to return std::string.. but it still gets strdupped by a lot of clients. switch over more movie and savestate code to use iostreams instead of stdio remove the temporary savestate stuff for more tasing speed hopefully
This commit is contained in:
parent
1a725b5850
commit
e0a14909f0
|
@ -8,4 +8,3 @@
|
|||
#include "../cart.h"
|
||||
#include "../cheat.h"
|
||||
#include "../unif.h"
|
||||
#include <string.h>
|
||||
|
|
47
src/cart.cpp
47
src/cart.cpp
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/// \file
|
||||
/// \brief This file contains all code for coordinating the mapping in of the address space external to the NES.
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include "types.h"
|
||||
#include "fceu.h"
|
||||
#include "ppu.h"
|
||||
#include "driver.h"
|
||||
|
||||
#include "cart.h"
|
||||
#include "x6502.h"
|
||||
|
@ -432,7 +433,7 @@ static uint8 *GENIEROM=0;
|
|||
|
||||
void FixGenieMap(void);
|
||||
|
||||
/* Called when a game(file) is opened successfully. */
|
||||
// Called when a game(file) is opened successfully.
|
||||
void OpenGenie(void)
|
||||
{
|
||||
FILE *fp;
|
||||
|
@ -444,7 +445,7 @@ void OpenGenie(void)
|
|||
|
||||
if(!(GENIEROM=(uint8 *)FCEU_malloc(4096+1024))) return;
|
||||
|
||||
fn=FCEU_MakeFName(FCEUMKF_GGROM,0,0);
|
||||
fn=strdup(FCEU_MakeFName(FCEUMKF_GGROM,0,0).c_str());
|
||||
fp=FCEUD_UTF8fopen(fn,"rb");
|
||||
if(!fp)
|
||||
{
|
||||
|
@ -455,7 +456,7 @@ void OpenGenie(void)
|
|||
}
|
||||
if(fread(GENIEROM,1,16,fp)!=16)
|
||||
{
|
||||
grerr:
|
||||
grerr:
|
||||
FCEU_PrintError("Error reading from Game Genie ROM image!");
|
||||
free(GENIEROM);
|
||||
GENIEROM=0;
|
||||
|
@ -637,7 +638,7 @@ void FCEU_SaveGameSave(CartInfo *LocalHWInfo)
|
|||
FILE *sp;
|
||||
char *soot;
|
||||
|
||||
soot=FCEU_MakeFName(FCEUMKF_SAV,0,"sav");
|
||||
soot=strdup(FCEU_MakeFName(FCEUMKF_SAV,0,"sav").c_str());
|
||||
if((sp=FCEUD_UTF8fopen(soot,"wb"))==NULL)
|
||||
{
|
||||
FCEU_PrintError("WRAM file \"%s\" cannot be written to.\n",soot);
|
||||
|
@ -667,7 +668,7 @@ void FCEU_LoadGameSave(CartInfo *LocalHWInfo)
|
|||
FILE *sp;
|
||||
char *soot;
|
||||
|
||||
soot=FCEU_MakeFName(FCEUMKF_SAV,0,"sav");
|
||||
soot=strdup(FCEU_MakeFName(FCEUMKF_SAV,0,"sav").c_str());
|
||||
sp=FCEUD_UTF8fopen(soot,"rb");
|
||||
if(sp!=NULL)
|
||||
{
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
|
@ -31,6 +31,7 @@
|
|||
#include "file.h"
|
||||
#include "cart.h"
|
||||
#include "memory.h"
|
||||
#include "driver.h"
|
||||
|
||||
static uint8 *CheatRPtrs[64];
|
||||
|
||||
|
@ -199,7 +200,7 @@ void FCEU_LoadGameCheats(FILE *override)
|
|||
fp = override;
|
||||
else
|
||||
{
|
||||
fn=FCEU_MakeFName(FCEUMKF_CHEAT,0,0);
|
||||
fn=strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str());
|
||||
fp=FCEUD_UTF8fopen(fn,"rb");
|
||||
free(fn);
|
||||
if(!fp) return;
|
||||
|
@ -296,7 +297,7 @@ void FCEU_FlushGameCheats(FILE *override, int nosave)
|
|||
char *fn = 0;
|
||||
|
||||
if(!override)
|
||||
fn = FCEU_MakeFName(FCEUMKF_CHEAT,0,0);
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str());
|
||||
|
||||
if(cheats)
|
||||
{
|
||||
|
@ -782,7 +783,7 @@ void FCEUI_CheatSearchEnd(int type, uint8 v1, uint8 v2)
|
|||
}
|
||||
|
||||
|
||||
if(!type) // Change to a specific value.
|
||||
if(!type) // Change to a specific value.
|
||||
{
|
||||
for(x=0;x<0x10000;x++)
|
||||
if(!(CheatComp[x]&CHEATC_NOSHOW))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "fceu.h"
|
||||
#include "driver.h"
|
||||
|
||||
static char *aboutString = 0;
|
||||
|
||||
|
|
|
@ -386,14 +386,14 @@ int getValue(int type)
|
|||
case 'A': return _A;
|
||||
case 'X': return _X;
|
||||
case 'Y': return _Y;
|
||||
case 'N': return _P & N_FLAG ? 1 : 0;
|
||||
case 'V': return _P & V_FLAG ? 1 : 0;
|
||||
case 'U': return _P & U_FLAG ? 1 : 0;
|
||||
case 'B': return _P & B_FLAG ? 1 : 0;
|
||||
case 'D': return _P & D_FLAG ? 1 : 0;
|
||||
case 'I': return _P & I_FLAG ? 1 : 0;
|
||||
case 'Z': return _P & Z_FLAG ? 1 : 0;
|
||||
case 'C': return _P & C_FLAG ? 1 : 0;
|
||||
case 'N': return __P & N_FLAG ? 1 : 0;
|
||||
case 'V': return __P & V_FLAG ? 1 : 0;
|
||||
case 'U': return __P & U_FLAG ? 1 : 0;
|
||||
case 'B': return __P & B_FLAG ? 1 : 0;
|
||||
case 'D': return __P & D_FLAG ? 1 : 0;
|
||||
case 'I': return __P & I_FLAG ? 1 : 0;
|
||||
case 'Z': return __P & Z_FLAG ? 1 : 0;
|
||||
case 'C': return __P & C_FLAG ? 1 : 0;
|
||||
case 'P': return _PC;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "drawing.h"
|
||||
#include "video.h"
|
||||
#include "movie.h"
|
||||
#include "driver.h"
|
||||
|
||||
static uint8 Font6x5[594] =
|
||||
{
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "types.h"
|
||||
#include "git.h"
|
||||
|
||||
FILE *FCEUD_UTF8fopen(const char *fn, const char *mode);
|
||||
inline FILE *FCEUD_UTF8fopen(const std::string &n, const char *mode) { return FCEUD_UTF8fopen(n.c_str(),mode); }
|
||||
std::fstream* FCEUD_UTF8_fstream(const char *n, const char *m);
|
||||
inline std::fstream* FCEUD_UTF8_fstream(const std::string &n, const char *m) { return FCEUD_UTF8_fstream(n.c_str(),m); }
|
||||
|
||||
|
||||
//mbg 7/23/06
|
||||
|
@ -188,7 +190,7 @@ void FCEUI_LoadMovie(char *fname, bool read_only, int _stopframe);
|
|||
void FCEUI_MoviePlayFromBeginning(void);
|
||||
void FCEUI_StopMovie(void);
|
||||
//int FCEUI_IsMovieActive(void);
|
||||
bool FCEUI_MovieGetInfo(const char* fname, MOVIE_INFO* /* [in, out] */ info, bool skipFrameCount = false);
|
||||
bool FCEUI_MovieGetInfo(const std::string& fname, MOVIE_INFO* /* [in, out] */ info, bool skipFrameCount = false);
|
||||
char* FCEUI_MovieGetCurrentName(int addSlotNumber);
|
||||
void FCEUI_MovieToggleReadOnly(void);
|
||||
bool FCEUI_GetMovieToggleReadOnly();
|
||||
|
|
|
@ -2029,7 +2029,8 @@ static bool SaveBasicBot()
|
|||
ofn.lpstrFile=nameo;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_BBOT);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_BBOT);
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
/*
|
||||
|
@ -2107,11 +2108,11 @@ static bool SaveBasicBotFile(char fn[])
|
|||
error(1005);
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Loads a previously saved file
|
||||
* todo: need to add ensurance that saved file has the same BOT_MAXCODE value
|
||||
* as currently set, or offer some kind of support for this "problem"
|
||||
**/
|
||||
|
||||
// Loads a previously saved file
|
||||
// todo: need to add ensurance that saved file has the same BOT_MAXCODE value
|
||||
// as currently set, or offer some kind of support for this "problem"
|
||||
//
|
||||
static bool LoadBasicBot()
|
||||
{
|
||||
const char filter[]="Basic Bot (*.bot)\0*.bot\0";
|
||||
|
@ -2126,7 +2127,8 @@ static bool LoadBasicBot()
|
|||
ofn.lpstrFile=nameo;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_BBOT);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_BBOT);
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
|
|
|
@ -1460,7 +1460,8 @@ static void PresetExport(int preset)
|
|||
ofn.lpstrFile=nameo;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_INPUT);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_INPUT).c_str();
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
int i;
|
||||
|
@ -1517,7 +1518,8 @@ static void PresetImport(int preset)
|
|||
ofn.lpstrFile=nameo;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_INPUT);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_INPUT);
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <shlobj.h> // For directories configuration dialog.
|
||||
#undef uint8
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "../../types.h"
|
||||
#include "../../fceu.h"
|
||||
#include "../../state.h"
|
||||
|
|
|
@ -363,7 +363,8 @@ static void SaveMemWatch()
|
|||
ofn.lpstrFile=memwLastFilename;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_MEMW);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_MEMW);
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
int i;
|
||||
|
@ -478,7 +479,8 @@ static void LoadMemWatch()
|
|||
ofn.lpstrFile=memwLastFilename;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_MEMW);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_MEMW);
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ static char* GetReplayPath(HWND hwndDlg)
|
|||
|
||||
_splitpath(szChoice, szDrive, szDirectory, szFilename, szExt);
|
||||
if(szDrive[0]=='\0' && szDirectory[0]=='\0')
|
||||
fn=FCEU_MakePath(FCEUMKF_MOVIE, szChoice); // need to make a full path
|
||||
fn=strdup(FCEU_MakePath(FCEUMKF_MOVIE, szChoice).c_str()); // need to make a full path
|
||||
else
|
||||
fn=strdup(szChoice); // given a full path
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ static char* GetRecordPath(HWND hwndDlg)
|
|||
|
||||
_splitpath(szChoice, szDrive, szDirectory, szFilename, szExt);
|
||||
if(szDrive[0]=='\0' && szDirectory[0]=='\0')
|
||||
fn=FCEU_MakePath(FCEUMKF_MOVIE, szChoice); // need to make a full path
|
||||
fn=strdup(FCEU_MakePath(FCEUMKF_MOVIE, szChoice).c_str()); // need to make a full path
|
||||
else
|
||||
fn=strdup(szChoice); // given a full path
|
||||
|
||||
|
@ -89,7 +89,7 @@ static char* GetSavePath(HWND hwndDlg)
|
|||
_splitpath(fn, szDrive, szDirectory, szFilename, szExt);
|
||||
if(szDrive[0]=='\0' && szDirectory[0]=='\0')
|
||||
{
|
||||
char* newfn=FCEU_MakePath(FCEUMKF_STATE, fn); // need to make a full path
|
||||
char* newfn=strdup(FCEU_MakePath(FCEUMKF_STATE, fn).c_str()); // need to make a full path
|
||||
free(fn);
|
||||
fn=newfn;
|
||||
}
|
||||
|
@ -255,11 +255,8 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_SETCHECK, replayReadOnlySetting?BST_CHECKED:BST_UNCHECKED, 0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_CHECK_STOPMOVIE,BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
|
||||
char* findGlob[2] = {FCEU_MakeFName(FCEUMKF_MOVIEGLOB, 0, 0),
|
||||
FCEU_MakeFName(FCEUMKF_MOVIEGLOB2, 0, 0)};
|
||||
|
||||
extern int suppress_scan_chunks;
|
||||
suppress_scan_chunks=1;
|
||||
char* findGlob[2] = {strdup(FCEU_MakeFName(FCEUMKF_MOVIEGLOB, 0, 0).c_str()),
|
||||
strdup(FCEU_MakeFName(FCEUMKF_MOVIEGLOB2, 0, 0).c_str())};
|
||||
|
||||
int i=0, j=0;
|
||||
|
||||
|
@ -372,8 +369,6 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
}
|
||||
}
|
||||
|
||||
suppress_scan_chunks=0;
|
||||
|
||||
free(findGlob[0]);
|
||||
free(findGlob[1]);
|
||||
|
||||
|
@ -427,7 +422,7 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
if(lIndex == lCount-1)
|
||||
{
|
||||
// pop open a file browser...
|
||||
char *pn=FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
char *pn=strdup(FCEU_GetPath(FCEUMKF_MOVIE).c_str());
|
||||
char szFile[MAX_PATH]={0};
|
||||
OPENFILENAME ofn;
|
||||
//int nRet; //mbg merge 7/17/06 removed
|
||||
|
@ -564,7 +559,7 @@ static void UpdateRecordDialog(HWND hwndDlg)
|
|||
|
||||
static void UpdateRecordDialogPath(HWND hwndDlg, const char* fname)
|
||||
{
|
||||
char* baseMovieDir = FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
char* baseMovieDir = strdup(FCEU_GetPath(FCEUMKF_MOVIE).c_str());
|
||||
char* fn=0;
|
||||
|
||||
// display a shortened filename if the file exists in the base movie directory
|
||||
|
@ -603,7 +598,7 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
|
||||
// Populate the "record from..." dialog
|
||||
{
|
||||
char* findGlob=FCEU_MakeFName(FCEUMKF_STATEGLOB, 0, 0);
|
||||
char* findGlob=strdup(FCEU_MakeFName(FCEUMKF_STATEGLOB, 0, 0).c_str());
|
||||
WIN32_FIND_DATA wfd;
|
||||
HANDLE hFind;
|
||||
int i=0;
|
||||
|
@ -731,7 +726,7 @@ static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
void FCEUD_MovieRecordTo()
|
||||
{
|
||||
struct CreateMovieParameters p;
|
||||
p.szFilename = FCEU_MakeFName(FCEUMKF_MOVIE,0,0);
|
||||
p.szFilename = strdup(FCEU_MakeFName(FCEUMKF_MOVIE,0,0).c_str());
|
||||
|
||||
if(DialogBoxParam(fceu_hInstance, "IDD_RECORDINP", hAppWnd, RecordDialogProc, (LPARAM)&p))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <set>
|
||||
#include <fstream>
|
||||
|
||||
#include "common.h"
|
||||
#include "tasedit.h"
|
||||
|
@ -305,7 +306,8 @@ static void Export()
|
|||
ofn.lpstrFilter=filter;
|
||||
ofn.lpstrFile=fname;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.lpstrInitialDir=FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
std::string initdir = FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
ofn.lpstrInitialDir=initdir.c_str();
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
fstream* osRecordingMovie = FCEUD_UTF8_fstream(ofn.lpstrFile, "wb");
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "../../types.h"
|
||||
#include "../../fceu.h"
|
||||
#include "windows.h"
|
||||
#include "driver.h"
|
||||
|
||||
static uint64 tmethod,tfreq;
|
||||
static uint64 desiredfps;
|
||||
|
|
|
@ -504,7 +504,8 @@ void LoadNewGamey(HWND hParent, const char *initialdir)
|
|||
ofn.lpstrFile=nameo;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; //OFN_EXPLORER|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK;
|
||||
ofn.lpstrInitialDir = initialdir ? initialdir : FCEU_GetPath(FCEUMKF_ROMS);
|
||||
std::string stdinitdir =FCEU_GetPath(FCEUMKF_ROMS);
|
||||
ofn.lpstrInitialDir = initialdir ? initialdir : stdinitdir.c_str();
|
||||
|
||||
// Show the Open File dialog
|
||||
if(GetOpenFileName(&ofn))
|
||||
|
|
|
@ -316,7 +316,7 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode)
|
|||
FCEU_printf("Loading %s...\n\n",name);
|
||||
GetFileBase(name);
|
||||
|
||||
ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0);
|
||||
ipsfn=strdup(FCEU_MakeFName(FCEUMKF_IPS,0,0).c_str());
|
||||
fp=FCEU_fopen(name,ipsfn,"rb",0);
|
||||
free(ipsfn);
|
||||
|
||||
|
@ -817,7 +817,7 @@ void UpdateRewind(void)
|
|||
if(RewindCounter == 0)
|
||||
{
|
||||
RewindIndex = (RewindIndex + 1) % 4;
|
||||
f = FCEU_MakeFName(FCEUMKF_REWINDSTATE,RewindIndex,0);
|
||||
f = strdup(FCEU_MakeFName(FCEUMKF_REWINDSTATE,RewindIndex,0).c_str());
|
||||
FCEUSS_Save(f);
|
||||
free(f);
|
||||
RewindStatus[RewindIndex] = 1;
|
||||
|
@ -832,7 +832,7 @@ void FCEUI_Rewind(void)
|
|||
if(RewindStatus[RewindIndex] == 1)
|
||||
{
|
||||
char * f;
|
||||
f = FCEU_MakeFName(FCEUMKF_REWINDSTATE,RewindIndex,0);
|
||||
f = strdup(FCEU_MakeFName(FCEUMKF_REWINDSTATE,RewindIndex,0).c_str());
|
||||
FCEUSS_Load(f);
|
||||
free(f);
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef _FCEUH
|
||||
#define _FCEUH
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
extern int fceuindbg;
|
||||
void ResetGameLoaded(void);
|
||||
|
||||
|
@ -65,7 +62,7 @@ extern int GameAttributes;
|
|||
|
||||
extern uint8 PAL;
|
||||
|
||||
#include "driver.h"
|
||||
//#include "driver.h"
|
||||
|
||||
typedef struct {
|
||||
int PAL;
|
||||
|
|
93
src/fds.cpp
93
src/fds.cpp
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -34,12 +34,13 @@
|
|||
#include "file.h"
|
||||
#include "cart.h"
|
||||
#include "netplay.h"
|
||||
#include "driver.h"
|
||||
|
||||
// TODO: Add code to put a delay in between the time a disk is inserted
|
||||
// and the when it can be successfully read/written to. This should
|
||||
// prevent writes to wrong places OR add code to prevent disk ejects
|
||||
// when the virtual motor is on(mmm...virtual motor).
|
||||
|
||||
/* TODO: Add code to put a delay in between the time a disk is inserted
|
||||
and the when it can be successfully read/written to. This should
|
||||
prevent writes to wrong places OR add code to prevent disk ejects
|
||||
when the virtual motor is on(mmm...virtual motor).
|
||||
*/
|
||||
|
||||
static DECLFR(FDSRead4030);
|
||||
static DECLFR(FDSRead4031);
|
||||
|
@ -165,7 +166,7 @@ void FCEU_FDSInsert(void)
|
|||
/*
|
||||
void FCEU_FDSEject(void)
|
||||
{
|
||||
InDisk=255;
|
||||
InDisk=255;
|
||||
}
|
||||
*/
|
||||
void FCEU_FDSSelect(void)
|
||||
|
@ -201,7 +202,7 @@ static void FDSFix(int a)
|
|||
//IRQCount=IRQLatch; //0xFFFF;
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
//printf("IRQ: %d\n",timestamp);
|
||||
// printf("IRQ: %d\n",scanline);
|
||||
// printf("IRQ: %d\n",scanline);
|
||||
}
|
||||
}
|
||||
if(DiskSeekIRQ>0)
|
||||
|
@ -467,7 +468,7 @@ static INLINE void ClockRise(void)
|
|||
b19shiftreg60<<=1;
|
||||
b8shiftreg88>>=1;
|
||||
}
|
||||
// b24adder66=(b24latch68+b19shiftreg60)&0x3FFFFFF;
|
||||
// b24adder66=(b24latch68+b19shiftreg60)&0x3FFFFFF;
|
||||
b24adder66=(b24latch68+b19shiftreg60)&0x1FFFFFF;
|
||||
}
|
||||
|
||||
|
@ -486,7 +487,7 @@ static INLINE int32 FDSDoSound(void)
|
|||
fdso.count+=fdso.cycles;
|
||||
if(fdso.count>=((int64)1<<40))
|
||||
{
|
||||
dogk:
|
||||
dogk:
|
||||
fdso.count-=(int64)1<<40;
|
||||
ClockRise();
|
||||
ClockFall();
|
||||
|
@ -558,18 +559,18 @@ void FDSSound(int c)
|
|||
/*
|
||||
static DECLFR(FDSBIOSPatch)
|
||||
{
|
||||
if(FDSRegs[5]&0x4)
|
||||
{
|
||||
X.X=FDSRead4031(0x4031);
|
||||
FDSWrite(0x4024,X.A);
|
||||
X.A=X.X;
|
||||
return(0x60);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0x58);
|
||||
//puts("Write");
|
||||
}
|
||||
if(FDSRegs[5]&0x4)
|
||||
{
|
||||
X.X=FDSRead4031(0x4031);
|
||||
FDSWrite(0x4024,X.A);
|
||||
X.A=X.X;
|
||||
return(0x60);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0x58);
|
||||
//puts("Write");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -587,7 +588,7 @@ static void FDS_ESI(void)
|
|||
fdso.cycles/=FSettings.SndRate *16;
|
||||
}
|
||||
}
|
||||
// fdso.cycles=(int64)32768*FDSClock/(FSettings.SndRate *16);
|
||||
// fdso.cycles=(int64)32768*FDSClock/(FSettings.SndRate *16);
|
||||
SetReadHandler(0x4040,0x407f,FDSWaveRead);
|
||||
SetWriteHandler(0x4040,0x407f,FDSWaveWrite);
|
||||
SetWriteHandler(0x4080,0x408A,FDSSWrite);
|
||||
|
@ -616,19 +617,19 @@ static DECLFW(FDSWrite)
|
|||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
IRQLatch&=0xFF00;
|
||||
IRQLatch|=V;
|
||||
// printf("$%04x:$%02x\n",A,V);
|
||||
// printf("$%04x:$%02x\n",A,V);
|
||||
break;
|
||||
case 0x4021:
|
||||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
IRQLatch&=0xFF;
|
||||
IRQLatch|=V<<8;
|
||||
// printf("$%04x:$%02x\n",A,V);
|
||||
// printf("$%04x:$%02x\n",A,V);
|
||||
break;
|
||||
case 0x4022:
|
||||
X6502_IRQEnd(FCEU_IQEXT);
|
||||
IRQCount=IRQLatch;
|
||||
IRQa=V&3;
|
||||
// printf("$%04x:$%02x\n",A,V);
|
||||
// printf("$%04x:$%02x\n",A,V);
|
||||
break;
|
||||
case 0x4023:break;
|
||||
case 0x4024:
|
||||
|
@ -767,7 +768,7 @@ int FDSLoad(const char *name, FCEUFILE *fp)
|
|||
return(0);
|
||||
|
||||
|
||||
fn = FCEU_MakeFName(FCEUMKF_FDSROM,0,0);
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_FDSROM,0,0).c_str());
|
||||
|
||||
if(!(zp=FCEUD_UTF8fopen(fn,"rb")))
|
||||
{
|
||||
|
@ -792,7 +793,7 @@ int FDSLoad(const char *name, FCEUFILE *fp)
|
|||
|
||||
{
|
||||
FCEUFILE *tp;
|
||||
char *fn=FCEU_MakeFName(FCEUMKF_FDS,0,0);
|
||||
char *fn=strdup(FCEU_MakeFName(FCEUMKF_FDS,0,0).c_str());
|
||||
|
||||
int x;
|
||||
for(x=0;x<TotalSides;x++)
|
||||
|
@ -862,7 +863,7 @@ void FDSClose(void)
|
|||
{
|
||||
FILE *fp;
|
||||
int x;
|
||||
char *fn=FCEU_MakeFName(FCEUMKF_FDS,0,0);
|
||||
char *fn=strdup(FCEU_MakeFName(FCEUMKF_FDS,0,0).c_str());
|
||||
|
||||
if(!DiskWritten) return;
|
||||
|
||||
|
|
122
src/file.cpp
122
src/file.cpp
|
@ -635,92 +635,93 @@ void FCEUI_SetDirOverride(int which, char *n)
|
|||
}
|
||||
#endif
|
||||
|
||||
char* FCEU_GetPath(int type)
|
||||
std::string FCEU_GetPath(int type)
|
||||
{
|
||||
char *ret=0;
|
||||
char ret[FILENAME_MAX];
|
||||
switch(type)
|
||||
{
|
||||
case FCEUMKF_STATE:
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
ret=strdup(odirs[FCEUIOD_STATES]);
|
||||
return (odirs[FCEUIOD_STATES]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"fcs",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"fcs",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_MOVIE:
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
ret=strdup(odirs[FCEUIOD_MOVIES]);
|
||||
return (odirs[FCEUIOD_MOVIES]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"movies",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"movies",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_MEMW:
|
||||
if(odirs[FCEUIOD_MEMW])
|
||||
ret=strdup(odirs[FCEUIOD_MEMW]);
|
||||
return (odirs[FCEUIOD_MEMW]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_BBOT:
|
||||
if(odirs[FCEUIOD_BBOT])
|
||||
ret=strdup(odirs[FCEUIOD_BBOT]);
|
||||
return (odirs[FCEUIOD_BBOT]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_ROMS:
|
||||
if(odirs[FCEUIOD_ROMS])
|
||||
ret=strdup(odirs[FCEUIOD_ROMS]);
|
||||
return (odirs[FCEUIOD_ROMS]);
|
||||
else
|
||||
asprintf(&ret,"%s",BaseDirectory);
|
||||
sprintf(ret,"%s",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_INPUT:
|
||||
if(odirs[FCEUIOD_INPUT])
|
||||
ret=strdup(odirs[FCEUIOD_INPUT]);
|
||||
return (odirs[FCEUIOD_INPUT]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_LUA:
|
||||
if(odirs[FCEUIOD_LUA])
|
||||
ret=strdup(odirs[FCEUIOD_LUA]);
|
||||
return (odirs[FCEUIOD_LUA]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"tools",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"tools",BaseDirectory);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *FCEU_MakePath(int type, const char* filebase)
|
||||
std::string FCEU_MakePath(int type, const char* filebase)
|
||||
{
|
||||
char *ret=0;
|
||||
char ret[FILENAME_MAX];
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case FCEUMKF_MOVIE:
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_MOVIES],filebase);
|
||||
sprintf(ret,"%s"PSS"%s",odirs[FCEUIOD_MOVIES],filebase);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"movies"PSS"%s",BaseDirectory,filebase);
|
||||
sprintf(ret,"%s"PSS"movies"PSS"%s",BaseDirectory,filebase);
|
||||
break;
|
||||
case FCEUMKF_STATE:
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_STATES],filebase);
|
||||
sprintf(ret,"%s"PSS"%s",odirs[FCEUIOD_STATES],filebase);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"fcs"PSS"%s",BaseDirectory,filebase);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s",BaseDirectory,filebase);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *FCEU_MakeFName(int type, int id1, char *cd1)
|
||||
std::string FCEU_MakeFName(int type, int id1, char *cd1)
|
||||
{
|
||||
char *ret=0;
|
||||
char ret[FILENAME_MAX];
|
||||
struct stat tmpstat;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case FCEUMKF_NPTEMP: asprintf(&ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break;
|
||||
case FCEUMKF_NPTEMP: sprintf(ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break;
|
||||
case FCEUMKF_MOVIE:
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
asprintf(&ret,"%s"PSS"%s.fm2",odirs[FCEUIOD_MOVIES],FileBase);
|
||||
sprintf(ret,"%s"PSS"%s.fm2",odirs[FCEUIOD_MOVIES],FileBase);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"movies"PSS"%s.fm2",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"movies"PSS"%s.fm2",BaseDirectory,FileBase);
|
||||
break;
|
||||
case FCEUMKF_STATE:
|
||||
{
|
||||
|
@ -736,21 +737,21 @@ char *FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
sprintf(ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
}
|
||||
else
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
|
||||
}
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
sprintf(ret,"%s"PSS"%s%s.fc%d",odirs[FCEUIOD_STATES],FileBase,mfn,id1);
|
||||
}
|
||||
else
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s%s.fc%d",BaseDirectory,FileBase,mfn,id1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -759,89 +760,90 @@ char *FCEU_MakeFName(int type, int id1, char *cd1)
|
|||
if(FSettings.SnapName)
|
||||
{
|
||||
if(odirs[FCEUIOD_SNAPS])
|
||||
asprintf(&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
|
||||
asprintf(&ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1);
|
||||
sprintf(ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(odirs[FCEUIOD_SNAPS])
|
||||
asprintf(&ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1);
|
||||
sprintf(ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1);
|
||||
sprintf(ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1);
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_FDS:
|
||||
if(odirs[FCEUIOD_NV])
|
||||
asprintf(&ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase);
|
||||
sprintf(ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase);
|
||||
break;
|
||||
case FCEUMKF_SAV:
|
||||
if(odirs[FCEUIOD_NV])
|
||||
asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
|
||||
sprintf(ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
if(odirs[FCEUIOD_NV])
|
||||
asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
|
||||
sprintf(ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
|
||||
sprintf(ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1);
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_REWINDSTATE:
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
|
||||
sprintf(ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
|
||||
}
|
||||
else
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
|
||||
}
|
||||
if(stat(ret,&tmpstat)==-1)
|
||||
{
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
|
||||
sprintf(ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATES],id1);
|
||||
}
|
||||
else
|
||||
{
|
||||
asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FCEUMKF_CHEAT:
|
||||
if(odirs[FCEUIOD_CHEATS])
|
||||
asprintf(&ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase);
|
||||
sprintf(ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase);
|
||||
break;
|
||||
case FCEUMKF_IPS:asprintf(&ret,"%s"PSS"%s%s.ips",FileBaseDirectory,FileBase,FileExt);break;
|
||||
case FCEUMKF_GGROM:asprintf(&ret,"%s"PSS"gg.rom",BaseDirectory);break;
|
||||
case FCEUMKF_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_FDSROM:
|
||||
if(odirs[FCEUIOD_FDSROM])
|
||||
asprintf(&ret,"%s"PSS"disksys.rom",odirs[FCEUIOD_FDSROM]);
|
||||
sprintf(ret,"%s"PSS"disksys.rom",odirs[FCEUIOD_FDSROM]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"disksys.rom",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"disksys.rom",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_PALETTE:asprintf(&ret,"%s"PSS"%s.pal",BaseDirectory,FileBase);break;
|
||||
case FCEUMKF_PALETTE:sprintf(ret,"%s"PSS"%s.pal",BaseDirectory,FileBase);break;
|
||||
case FCEUMKF_MOVIEGLOB:
|
||||
//these globs use ??? because we can load multiple formats
|
||||
if(odirs[FCEUIOD_MOVIES])
|
||||
asprintf(&ret,"%s"PSS"*.???",odirs[FCEUIOD_MOVIES]);
|
||||
sprintf(ret,"%s"PSS"*.???",odirs[FCEUIOD_MOVIES]);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"movies"PSS"*.???",BaseDirectory);
|
||||
sprintf(ret,"%s"PSS"movies"PSS"*.???",BaseDirectory);
|
||||
break;
|
||||
case FCEUMKF_MOVIEGLOB2:asprintf(&ret,"%s"PSS"*.???",BaseDirectory);break;
|
||||
case FCEUMKF_MOVIEGLOB2:sprintf(ret,"%s"PSS"*.???",BaseDirectory);break;
|
||||
case FCEUMKF_STATEGLOB:
|
||||
if(odirs[FCEUIOD_STATES])
|
||||
asprintf(&ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATES],FileBase);
|
||||
sprintf(ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATES],FileBase);
|
||||
else
|
||||
asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase);
|
||||
sprintf(ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void GetFileBase(const char *f)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _FCEU_FILE_H_
|
||||
#define _FCEU_FILE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef struct {
|
||||
void *fp; // FILE* or ptr to ZIPWRAP
|
||||
uint32 type; // 0=normal file, 1=gzip, 2=zip
|
||||
|
@ -22,9 +24,9 @@ int FCEU_fisarchive(FCEUFILE*);
|
|||
|
||||
|
||||
void GetFileBase(const char *f);
|
||||
char* FCEU_GetPath(int type);
|
||||
char *FCEU_MakePath(int type, const char* filebase);
|
||||
char *FCEU_MakeFName(int type, int id1, char *cd1);
|
||||
std::string FCEU_GetPath(int type);
|
||||
std::string FCEU_MakePath(int type, const char* filebase);
|
||||
std::string FCEU_MakeFName(int type, int id1, char *cd1);
|
||||
|
||||
#define FCEUMKF_STATE 1
|
||||
#define FCEUMKF_SNAP 2
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "utils/md5.h"
|
||||
#include "cheat.h"
|
||||
#include "vsuni.h"
|
||||
#include "driver.h"
|
||||
|
||||
extern SFORMAT FCEUVSUNI_STATEINFO[];
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "input.h"
|
||||
#include "vsuni.h"
|
||||
#include "fds.h"
|
||||
#include "driver.h"
|
||||
|
||||
// qfox: For UpdateExternalButton(), called when the
|
||||
// botmode state changes, to update a label in gui.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <assert.h>
|
||||
#include <zlib.h>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
|
@ -19,6 +20,7 @@
|
|||
#include "file.h"
|
||||
#include "video.h"
|
||||
#include "movie.h"
|
||||
#include "utils/guid.h"
|
||||
#include "utils/memory.h"
|
||||
#include "utils/memorystream.h"
|
||||
#include "utils/xstring.h"
|
||||
|
@ -338,7 +340,7 @@ bool FCEUMOV_Mode(int modemask)
|
|||
}
|
||||
|
||||
//yuck... another custom text parser.
|
||||
void LoadFM2(MovieData& movieData, std::istream* fp, bool stopAfterHeader = false)
|
||||
static void LoadFM2(MovieData& movieData, std::istream* fp, int size=-1, bool stopAfterHeader = false)
|
||||
{
|
||||
std::string key,value;
|
||||
enum {
|
||||
|
@ -348,6 +350,7 @@ void LoadFM2(MovieData& movieData, std::istream* fp, bool stopAfterHeader = fals
|
|||
for(;;)
|
||||
{
|
||||
bool iswhitespace, isrecchar, isnewline;
|
||||
if(size--==0) goto bail;
|
||||
int c = fp->get();
|
||||
if(c == -1)
|
||||
goto bail;
|
||||
|
@ -506,15 +509,8 @@ void FCEUMOV_ExitTasEdit()
|
|||
|
||||
bool MovieData::loadSavestateFrom(std::vector<char>* buf)
|
||||
{
|
||||
//dump the savestate to disk
|
||||
FILE* fp = tmpfile();
|
||||
fwrite(&(*buf)[0],1,buf->size(),fp);
|
||||
fseek(fp,0,SEEK_SET);
|
||||
|
||||
//and load the state
|
||||
bool success = FCEUSS_LoadFP(fp,SSLOADPARAM_BACKUP);
|
||||
fclose(fp);
|
||||
return success;
|
||||
memorystream ms(buf);
|
||||
return FCEUSS_LoadFP(&ms,SSLOADPARAM_BACKUP);
|
||||
}
|
||||
|
||||
void MovieData::dumpSavestateTo(std::vector<char>* buf, int compressionLevel)
|
||||
|
@ -780,22 +776,22 @@ int FCEUMOV_WriteState(std::ostream* os)
|
|||
|
||||
static bool load_successful;
|
||||
|
||||
bool FCEUMOV_ReadState(FILE* st, uint32 size)
|
||||
bool FCEUMOV_ReadState(std::istream* is, uint32 size)
|
||||
{
|
||||
load_successful = false;
|
||||
|
||||
//write the state to disk so we can reload
|
||||
std::vector<char> buf(size);
|
||||
fread(&buf[0],1,size,st);
|
||||
//---------
|
||||
//(debug)
|
||||
//FILE* wtf = fopen("d:\\wtf.txt","wb");
|
||||
//fwrite(&buf[0],1,size,wtf);
|
||||
//fclose(wtf);
|
||||
//---------
|
||||
memorystream mstemp(&buf);
|
||||
////write the state to disk so we can reload
|
||||
//std::vector<char> buf(size);
|
||||
//fread(&buf[0],1,size,st);
|
||||
////---------
|
||||
////(debug)
|
||||
////FILE* wtf = fopen("d:\\wtf.txt","wb");
|
||||
////fwrite(&buf[0],1,size,wtf);
|
||||
////fclose(wtf);
|
||||
////---------
|
||||
//memorystream mstemp(&buf);
|
||||
MovieData tempMovieData = MovieData();
|
||||
LoadFM2(tempMovieData, &mstemp);
|
||||
LoadFM2(tempMovieData, is);
|
||||
|
||||
//complex TAS logic for when a savestate is loaded:
|
||||
//----------------
|
||||
|
@ -934,7 +930,7 @@ void FCEUI_MoviePlayFromBeginning(void)
|
|||
}
|
||||
|
||||
|
||||
bool FCEUI_MovieGetInfo(const char* fname, MOVIE_INFO* info, bool skipFrameCount)
|
||||
bool FCEUI_MovieGetInfo(const std::string& fname, MOVIE_INFO* info, bool skipFrameCount)
|
||||
{
|
||||
memset(info,0,sizeof(MOVIE_INFO));
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <ostream>
|
||||
|
||||
#include "input/zapper.h"
|
||||
#include "utils/guid.h"
|
||||
|
||||
void FCEUMOV_AddInputState();
|
||||
void FCEUMOV_AddCommand(int cmd);
|
||||
|
@ -33,7 +34,7 @@ bool FCEUMOV_ShouldPause(void);
|
|||
int FCEUMOV_GetFrame(void);
|
||||
|
||||
int FCEUMOV_WriteState(std::ostream* os);
|
||||
bool FCEUMOV_ReadState(FILE* st, uint32 size);
|
||||
bool FCEUMOV_ReadState(std::istream* is, uint32 size);
|
||||
void FCEUMOV_PreLoad();
|
||||
bool FCEUMOV_PostLoad();
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -35,17 +35,17 @@
|
|||
#include "state.h"
|
||||
#include "cheat.h"
|
||||
#include "input.h"
|
||||
#include "driver.h"
|
||||
|
||||
int FCEUnetplay=0;
|
||||
|
||||
static uint8 netjoy[4]; /* Controller cache. */
|
||||
static uint8 netjoy[4]; // Controller cache.
|
||||
static int numlocal;
|
||||
static int netdivisor;
|
||||
static int netdcount;
|
||||
|
||||
/* NetError should only be called after a FCEUD_*Data function returned 0, in the function
|
||||
that called FCEUD_*Data, to prevent it from being called twice.
|
||||
*/
|
||||
//NetError should only be called after a FCEUD_*Data function returned 0, in the function
|
||||
//that called FCEUD_*Data, to prevent it from being called twice.
|
||||
|
||||
static void NetError(void)
|
||||
{
|
||||
|
@ -58,18 +58,17 @@ void FCEUI_NetplayStop(void)
|
|||
if(FCEUnetplay)
|
||||
{
|
||||
FCEUnetplay = 0;
|
||||
FCEU_FlushGameCheats(0,1); /* Don't save netplay cheats. */
|
||||
FCEU_LoadGameCheats(0); /* Reload our original cheats. */
|
||||
FCEU_FlushGameCheats(0,1); //Don't save netplay cheats.
|
||||
FCEU_LoadGameCheats(0); //Reload our original cheats.
|
||||
}
|
||||
else puts("Check your code!");
|
||||
}
|
||||
|
||||
int FCEUI_NetplayStart(int nlocal, int divisor)
|
||||
{
|
||||
FCEU_FlushGameCheats(0, 0); /* Save our pre-netplay cheats. */
|
||||
FCEU_LoadGameCheats(0); /* Load them again, for pre-multiplayer
|
||||
action.
|
||||
*/
|
||||
FCEU_FlushGameCheats(0, 0); //Save our pre-netplay cheats.
|
||||
FCEU_LoadGameCheats(0); // Load them again, for pre-multiplayer action.
|
||||
|
||||
FCEUnetplay = 1;
|
||||
memset(netjoy,0,sizeof(netjoy));
|
||||
numlocal = nlocal;
|
||||
|
@ -165,7 +164,7 @@ static FILE *FetchFile(uint32 remlen)
|
|||
}
|
||||
|
||||
//printf("Receiving file: %d...\n",clen);
|
||||
fn = FCEU_MakeFName(FCEUMKF_NPTEMP,0,0);
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_NPTEMP,0,0).c_str());
|
||||
if((fp = fopen(fn,"w+b")))
|
||||
{
|
||||
cbuf = (char *)malloc(clen); //mbg merge 7/17/06 added cast
|
||||
|
@ -221,6 +220,7 @@ void NetplayUpdate(uint8 *joyp)
|
|||
}
|
||||
|
||||
if(!netdcount)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(!FCEUD_RecvData(buf,5))
|
||||
|
@ -263,7 +263,7 @@ void NetplayUpdate(uint8 *joyp)
|
|||
there might be a frame or two in between the two sendfile
|
||||
commands on the server side.
|
||||
*/
|
||||
fn = FCEU_MakeFName(FCEUMKF_CHEAT,0,0);
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_CHEAT,0,0).c_str());
|
||||
//if(!
|
||||
FCEUNET_SendFile(FCEUNPCMD_LOADCHEATS,fn);
|
||||
|
||||
|
@ -274,7 +274,7 @@ void NetplayUpdate(uint8 *joyp)
|
|||
free(fn);
|
||||
if(!FCEUnetplay) return;
|
||||
|
||||
fn = FCEU_MakeFName(FCEUMKF_NPTEMP,0,0);
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_NPTEMP,0,0).c_str());
|
||||
fp = fopen(fn, "wb");
|
||||
if(FCEUSS_SaveFP(fp,Z_BEST_COMPRESSION))
|
||||
{
|
||||
|
@ -307,7 +307,8 @@ void NetplayUpdate(uint8 *joyp)
|
|||
FCEU_LoadGameCheats(fp);
|
||||
}
|
||||
break;
|
||||
case FCEUNPCMD_LOADSTATE:
|
||||
//mbg 6/16/08 - netplay doesnt work right now anyway
|
||||
/*case FCEUNPCMD_LOADSTATE:
|
||||
{
|
||||
FILE *fp = FetchFile(FCEU_de32lsb(buf));
|
||||
if(!fp) return;
|
||||
|
@ -317,7 +318,7 @@ void NetplayUpdate(uint8 *joyp)
|
|||
FCEU_DispMessage("Remote state loaded.");
|
||||
} else FCEUD_PrintError("File error. (K)ill, (M)aim, (D)estroy?");
|
||||
}
|
||||
break;
|
||||
break;*/
|
||||
}
|
||||
} while(buf[4]);
|
||||
|
||||
|
@ -325,4 +326,5 @@ void NetplayUpdate(uint8 *joyp)
|
|||
|
||||
memcpy(netjoy,buf,4);
|
||||
*(uint32 *)joyp=*(uint32 *)netjoy;
|
||||
}
|
||||
}
|
||||
|
|
85
src/nsf.cpp
85
src/nsf.cpp
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/// \file
|
||||
/// \brief implements a built-in NSF player. This is a perk--not a part of the emu core
|
||||
|
@ -38,6 +38,7 @@
|
|||
#include "fds.h"
|
||||
#include "cart.h"
|
||||
#include "input.h"
|
||||
#include "driver.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
@ -74,28 +75,28 @@ static int vismode=1;
|
|||
*/
|
||||
static uint8 NSFROM[0x30+6]=
|
||||
{
|
||||
/* 0x00 - NMI */
|
||||
0x8D,0xF4,0x3F, /* Stop play routine NMIs. */
|
||||
0xA2,0xFF,0x9A, /* Initialize the stack pointer. */
|
||||
0xAD,0xF0,0x3F, /* See if we need to init. */
|
||||
0xF0,0x09, /* If 0, go to play routine playing. */
|
||||
/* 0x00 - NMI */
|
||||
0x8D,0xF4,0x3F, /* Stop play routine NMIs. */
|
||||
0xA2,0xFF,0x9A, /* Initialize the stack pointer. */
|
||||
0xAD,0xF0,0x3F, /* See if we need to init. */
|
||||
0xF0,0x09, /* If 0, go to play routine playing. */
|
||||
|
||||
0xAD,0xF1,0x3F, /* Confirm and load A */
|
||||
0xAE,0xF3,0x3F, /* Load X with PAL/NTSC byte */
|
||||
0xAD,0xF1,0x3F, /* Confirm and load A */
|
||||
0xAE,0xF3,0x3F, /* Load X with PAL/NTSC byte */
|
||||
|
||||
0x20,0x00,0x00, /* JSR to init routine */
|
||||
0x20,0x00,0x00, /* JSR to init routine */
|
||||
|
||||
0xA9,0x00,
|
||||
0xAA,
|
||||
0xA8,
|
||||
0x20,0x00,0x00, /* JSR to play routine */
|
||||
0x8D,0xF5,0x3F, /* Start play routine NMIs. */
|
||||
0x90,0xFE, /* Loopie time. */
|
||||
0xA9,0x00,
|
||||
0xAA,
|
||||
0xA8,
|
||||
0x20,0x00,0x00, /* JSR to play routine */
|
||||
0x8D,0xF5,0x3F, /* Start play routine NMIs. */
|
||||
0x90,0xFE, /* Loopie time. */
|
||||
|
||||
/* 0x20 */
|
||||
0x8D,0xF3,0x3F, /* Init init NMIs */
|
||||
0x18,
|
||||
0x90,0xFE /* Loopie time. */
|
||||
/* 0x20 */
|
||||
0x8D,0xF3,0x3F, /* Init init NMIs */
|
||||
0x18,
|
||||
0x90,0xFE /* Loopie time. */
|
||||
};
|
||||
|
||||
static DECLFR(NSFROMRead)
|
||||
|
@ -127,17 +128,17 @@ void NSFGI(int h)
|
|||
if(NSFDATA) {free(NSFDATA);NSFDATA=0;}
|
||||
if(ExWRAM) {free(ExWRAM);ExWRAM=0;}
|
||||
if(NSFHeader.SoundChip&1) {
|
||||
// NSFVRC6_Init();
|
||||
// NSFVRC6_Init();
|
||||
} else if(NSFHeader.SoundChip&2) {
|
||||
// NSFVRC7_Init();
|
||||
// NSFVRC7_Init();
|
||||
} else if(NSFHeader.SoundChip&4) {
|
||||
// FDSSoundReset();
|
||||
// FDSSoundReset();
|
||||
} else if(NSFHeader.SoundChip&8) {
|
||||
NSFMMC5_Close();
|
||||
} else if(NSFHeader.SoundChip&0x10) {
|
||||
// NSFN106_Init();
|
||||
// NSFN106_Init();
|
||||
} else if(NSFHeader.SoundChip&0x20) {
|
||||
// NSFAY_Init();
|
||||
// NSFAY_Init();
|
||||
}
|
||||
break;
|
||||
case GI_RESETM2:
|
||||
|
@ -582,7 +583,7 @@ int FCEUI_NSFChange(int amount)
|
|||
return(CurrentSong);
|
||||
}
|
||||
|
||||
/* Returns total songs */
|
||||
//Returns total songs
|
||||
int FCEUI_NSFGetInfo(uint8 *name, uint8 *artist, uint8 *copyright, int maxlen)
|
||||
{
|
||||
strncpy((char*)name,(char*)NSFHeader.SongName,maxlen); //mbg merge 7/17/06 added casts
|
||||
|
|
54
src/ops.inc
54
src/ops.inc
|
@ -22,17 +22,17 @@ case 0x00: /* BRK */
|
|||
_PC++;
|
||||
PUSH(_PC>>8);
|
||||
PUSH(_PC);
|
||||
PUSH(_P|U_FLAG|B_FLAG);
|
||||
_P|=I_FLAG;
|
||||
PUSH(__P|U_FLAG|B_FLAG);
|
||||
__P|=I_FLAG;
|
||||
_PI|=I_FLAG;
|
||||
_PC=RdMem(0xFFFE);
|
||||
_PC|=RdMem(0xFFFF)<<8;
|
||||
break;
|
||||
|
||||
case 0x40: /* RTI */
|
||||
_P=POP();
|
||||
__P=POP();
|
||||
/* _PI=_P; This is probably incorrect, so it's commented out. */
|
||||
_PI = _P;
|
||||
_PI = __P;
|
||||
_PC=POP();
|
||||
_PC|=POP()<<8;
|
||||
break;
|
||||
|
@ -47,14 +47,14 @@ case 0x48: /* PHA */
|
|||
PUSH(_A);
|
||||
break;
|
||||
case 0x08: /* PHP */
|
||||
PUSH(_P|U_FLAG|B_FLAG);
|
||||
PUSH(__P|U_FLAG|B_FLAG);
|
||||
break;
|
||||
case 0x68: /* PLA */
|
||||
_A=POP();
|
||||
X_ZN(_A);
|
||||
break;
|
||||
case 0x28: /* PLP */
|
||||
_P=POP();
|
||||
__P=POP();
|
||||
break;
|
||||
case 0x4C:
|
||||
{
|
||||
|
@ -107,11 +107,11 @@ case 0x98: /* TYA */
|
|||
break;
|
||||
|
||||
case 0xBA: /* TSX */
|
||||
_X=_S;
|
||||
_X=__S;
|
||||
X_ZN(_X);
|
||||
break;
|
||||
case 0x9A: /* TXS */
|
||||
_S=_X;
|
||||
__S=_X;
|
||||
break;
|
||||
|
||||
case 0xCA: /* DEX */
|
||||
|
@ -133,26 +133,26 @@ case 0xC8: /* INY */
|
|||
break;
|
||||
|
||||
case 0x18: /* CLC */
|
||||
_P&=~C_FLAG;
|
||||
__P&=~C_FLAG;
|
||||
break;
|
||||
case 0xD8: /* CLD */
|
||||
_P&=~D_FLAG;
|
||||
__P&=~D_FLAG;
|
||||
break;
|
||||
case 0x58: /* CLI */
|
||||
_P&=~I_FLAG;
|
||||
__P&=~I_FLAG;
|
||||
break;
|
||||
case 0xB8: /* CLV */
|
||||
_P&=~V_FLAG;
|
||||
__P&=~V_FLAG;
|
||||
break;
|
||||
|
||||
case 0x38: /* SEC */
|
||||
_P|=C_FLAG;
|
||||
__P|=C_FLAG;
|
||||
break;
|
||||
case 0xF8: /* SED */
|
||||
_P|=D_FLAG;
|
||||
__P|=D_FLAG;
|
||||
break;
|
||||
case 0x78: /* SEI */
|
||||
_P|=I_FLAG;
|
||||
__P|=I_FLAG;
|
||||
break;
|
||||
|
||||
case 0xEA: /* NOP */
|
||||
|
@ -296,28 +296,28 @@ case 0x94: ST_ZPX(_Y);
|
|||
case 0x8C: ST_AB(_Y);
|
||||
|
||||
/* BCC */
|
||||
case 0x90: JR(!(_P&C_FLAG)); break;
|
||||
case 0x90: JR(!(__P&C_FLAG)); break;
|
||||
|
||||
/* BCS */
|
||||
case 0xB0: JR(_P&C_FLAG); break;
|
||||
case 0xB0: JR(__P&C_FLAG); break;
|
||||
|
||||
/* BEQ */
|
||||
case 0xF0: JR(_P&Z_FLAG); break;
|
||||
case 0xF0: JR(__P&Z_FLAG); break;
|
||||
|
||||
/* BNE */
|
||||
case 0xD0: JR(!(_P&Z_FLAG)); break;
|
||||
case 0xD0: JR(!(__P&Z_FLAG)); break;
|
||||
|
||||
/* BMI */
|
||||
case 0x30: JR(_P&N_FLAG); break;
|
||||
case 0x30: JR(__P&N_FLAG); break;
|
||||
|
||||
/* BPL */
|
||||
case 0x10: JR(!(_P&N_FLAG)); break;
|
||||
case 0x10: JR(!(__P&N_FLAG)); break;
|
||||
|
||||
/* BVC */
|
||||
case 0x50: JR(!(_P&V_FLAG)); break;
|
||||
case 0x50: JR(!(__P&V_FLAG)); break;
|
||||
|
||||
/* BVS */
|
||||
case 0x70: JR(_P&V_FLAG); break;
|
||||
case 0x70: JR(__P&V_FLAG); break;
|
||||
|
||||
//default: printf("Bad %02x at $%04x\n",b1,X.PC);break;
|
||||
//ifdef moo
|
||||
|
@ -327,7 +327,7 @@ case 0x70: JR(_P&V_FLAG); break;
|
|||
|
||||
/* AAC */
|
||||
case 0x2B:
|
||||
case 0x0B: LD_IM(AND;_P&=~C_FLAG;_P|=_A>>7);
|
||||
case 0x0B: LD_IM(AND;__P&=~C_FLAG;__P|=_A>>7);
|
||||
|
||||
/* AAX */
|
||||
case 0x87: ST_ZP(_A&_X);
|
||||
|
@ -338,7 +338,7 @@ case 0x83: ST_IX(_A&_X);
|
|||
/* ARR - ARGH, MATEY! */
|
||||
case 0x6B: {
|
||||
uint8 arrtmp;
|
||||
LD_IM(AND;_P&=~V_FLAG;_P|=(_A^(_A>>1))&0x40;arrtmp=_A>>7;_A>>=1;_A|=(_P&C_FLAG)<<7;_P&=~C_FLAG;_P|=arrtmp;X_ZN(_A));
|
||||
LD_IM(AND;__P&=~V_FLAG;__P|=(_A^(_A>>1))&0x40;arrtmp=_A>>7;_A>>=1;_A|=(__P&C_FLAG)<<7;__P&=~C_FLAG;__P|=arrtmp;X_ZN(_A));
|
||||
}
|
||||
/* ASR */
|
||||
case 0x4B: LD_IM(AND;LSRA);
|
||||
|
@ -404,7 +404,7 @@ case 0xF2:ADDCYC(0xFF);
|
|||
break;
|
||||
|
||||
/* LAR */
|
||||
case 0xBB: RMW_ABY(_S&=x;_A=_X=_S;X_ZN(_X));
|
||||
case 0xBB: RMW_ABY(__S&=x;_A=_X=__S;X_ZN(_X));
|
||||
|
||||
/* LAX */
|
||||
case 0xA7: LD_ZP(LDA;LDX);
|
||||
|
@ -469,7 +469,7 @@ case 0x9C: ST_ABX(_Y&(((A-_X)>>8)+1));
|
|||
case 0x9E: ST_ABY(_X&(((A-_Y)>>8)+1));
|
||||
|
||||
/* XAS */
|
||||
case 0x9B: _S=_A&_X;ST_ABY(_S& (((A-_Y)>>8)+1) );
|
||||
case 0x9B: __S=_A&_X;ST_ABY(__S& (((A-_Y)>>8)+1) );
|
||||
|
||||
/* TOP */
|
||||
case 0x0C: LD_AB(;);
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002,2003 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002,2003 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -50,13 +50,13 @@ uint8 pale=0;
|
|||
|
||||
pal *palo;
|
||||
static pal *palpoint[8]=
|
||||
{
|
||||
{
|
||||
palette,
|
||||
rp2c04001,
|
||||
rp2c04002,
|
||||
rp2c04003,
|
||||
rp2c05004,
|
||||
};
|
||||
};
|
||||
|
||||
void FCEUI_SetPaletteArray(uint8 *pal)
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ void FCEU_LoadGamePalette(void)
|
|||
|
||||
ipalette=0;
|
||||
|
||||
fn=FCEU_MakeFName(FCEUMKF_PALETTE,0,0);
|
||||
fn=strdup(FCEU_MakeFName(FCEUMKF_PALETTE,0,0).c_str());
|
||||
|
||||
if((fp=FCEUD_UTF8fopen(fn,"rb")))
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "state.h"
|
||||
#include "video.h"
|
||||
#include "input.h"
|
||||
#include "driver.h"
|
||||
|
||||
#define VBlankON (PPU[0]&0x80) /* Generate VBlank NMI */
|
||||
#define Sprite16 (PPU[0]&0x20) /* Sprites 8x16/8x8 */
|
||||
|
|
381
src/state.cpp
381
src/state.cpp
|
@ -1,25 +1,24 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* TODO: Add (better) file io error checking */
|
||||
/* TODO: Change save state file format. */
|
||||
// TODO: Add (better) file io error checking
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
@ -28,6 +27,7 @@
|
|||
//#include <unistd.h> //mbg merge 7/17/06 removed
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
#include "types.h"
|
||||
#include "x6502.h"
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include "video.h"
|
||||
#include "input.h"
|
||||
#include "zlib.h"
|
||||
#include "driver.h"
|
||||
|
||||
static void (*SPreSave)(void);
|
||||
static void (*SPostSave)(void);
|
||||
|
@ -112,10 +113,10 @@ static int SubWrite(std::ostream* os, SFORMAT *sf)
|
|||
os->write(sf->desc,4);
|
||||
write32le(sf->s&(~FCEUSTATE_FLAGS),os);
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifndef LSB_FIRST
|
||||
if(sf->s&RLSB)
|
||||
FlipByteOrder(sf->v,sf->s&(~FCEUSTATE_FLAGS));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(sf->s&FCEUSTATE_INDIRECT)
|
||||
os->write(*(char **)sf->v,sf->s&(~FCEUSTATE_FLAGS));
|
||||
|
@ -123,10 +124,10 @@ static int SubWrite(std::ostream* os, SFORMAT *sf)
|
|||
os->write((char*)sf->v,sf->s&(~FCEUSTATE_FLAGS));
|
||||
|
||||
//Now restore the original byte order.
|
||||
#ifndef LSB_FIRST
|
||||
#ifndef LSB_FIRST
|
||||
if(sf->s&RLSB)
|
||||
FlipByteOrder(sf->v,sf->s&(~FCEUSTATE_FLAGS));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
sf++;
|
||||
}
|
||||
|
@ -159,17 +160,17 @@ static int SubWrite(FILE *st, SFORMAT *sf)
|
|||
fwrite(sf->desc,1,4,st);
|
||||
write32le(sf->s&(~FCEUSTATE_FLAGS),st);
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifndef LSB_FIRST
|
||||
if(sf->s&RLSB)
|
||||
FlipByteOrder(sf->v,sf->s&(~FCEUSTATE_FLAGS));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
fwrite((uint8 *)sf->v,1,sf->s&(~FCEUSTATE_FLAGS),st);
|
||||
//Now restore the original byte order.
|
||||
#ifndef LSB_FIRST
|
||||
#ifndef LSB_FIRST
|
||||
if(sf->s&RLSB)
|
||||
FlipByteOrder(sf->v,sf->s&(~FCEUSTATE_FLAGS));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
sf++;
|
||||
}
|
||||
|
@ -210,7 +211,7 @@ static SFORMAT *CheckS(SFORMAT *sf, uint32 tsize, char *desc)
|
|||
{
|
||||
while(sf->v)
|
||||
{
|
||||
if(sf->s==~0) /* Link to another SFORMAT structure. */
|
||||
if(sf->s==~0) // Link to another SFORMAT structure.
|
||||
{
|
||||
SFORMAT *tmp;
|
||||
if((tmp= CheckS((SFORMAT *)sf->v, tsize, desc) ))
|
||||
|
@ -229,101 +230,98 @@ static SFORMAT *CheckS(SFORMAT *sf, uint32 tsize, char *desc)
|
|||
return(0);
|
||||
}
|
||||
|
||||
static int scan_chunks=0;
|
||||
int suppress_scan_chunks=0;
|
||||
|
||||
static int ReadStateChunk(FILE *st, SFORMAT *sf, int size)
|
||||
static bool ReadStateChunk(std::istream* is, SFORMAT *sf, int size)
|
||||
{
|
||||
if(scan_chunks)
|
||||
return fseek(st,size,SEEK_CUR) == 0;
|
||||
|
||||
SFORMAT *tmp;
|
||||
int temp;
|
||||
temp=ftell(st);
|
||||
int temp = is->tellg();
|
||||
|
||||
while(ftell(st)<temp+size)
|
||||
while(is->tellg()<temp+size)
|
||||
{
|
||||
uint32 tsize;
|
||||
char toa[4];
|
||||
if(fread(toa,1,4,st)<=0)
|
||||
return 0;
|
||||
if(is->readsome(toa,4)<4)
|
||||
return false;
|
||||
|
||||
read32le(&tsize,st);
|
||||
read32le(&tsize,is);
|
||||
|
||||
if((tmp=CheckS(sf,tsize,toa)))
|
||||
{
|
||||
if(tmp->s&FCEUSTATE_INDIRECT)
|
||||
fread(*(uint8 **)tmp->v,1,tmp->s&(~FCEUSTATE_FLAGS),st);
|
||||
is->readsome(*(char **)tmp->v,tmp->s&(~FCEUSTATE_FLAGS));
|
||||
else
|
||||
fread((uint8 *)tmp->v,1,tmp->s&(~FCEUSTATE_FLAGS),st);
|
||||
is->readsome((char *)tmp->v,tmp->s&(~FCEUSTATE_FLAGS));
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifndef LSB_FIRST
|
||||
if(tmp->s&RLSB)
|
||||
FlipByteOrder(tmp->v,tmp->s&(~FCEUSTATE_FLAGS));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
fseek(st,tsize,SEEK_CUR);
|
||||
is->seekg(tsize,std::ios::cur);
|
||||
} // while(...)
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int read_sfcpuc=0, read_snd=0;
|
||||
|
||||
void FCEUD_BlitScreen(uint8 *XBuf); //mbg merge 7/17/06 YUCKY had to add
|
||||
void UpdateFCEUWindow(void); //mbg merge 7/17/06 YUCKY had to add
|
||||
static int ReadStateChunks(FILE *st, int32 totalsize)
|
||||
static bool ReadStateChunks(std::istream* is, int32 totalsize)
|
||||
{
|
||||
int t;
|
||||
uint32 size;
|
||||
int ret=1;
|
||||
int warned=0;
|
||||
bool ret=true;
|
||||
bool warned=false;
|
||||
|
||||
read_sfcpuc=0;
|
||||
read_snd=0;
|
||||
|
||||
// int moo=X.mooPI;
|
||||
if(!scan_chunks)
|
||||
X.mooPI=/*X.P*/0xFF;
|
||||
//mbg 6/16/08 - wtf
|
||||
//// int moo=X.mooPI;
|
||||
// if(!scan_chunks)
|
||||
// X.mooPI=/*X.P*/0xFF;
|
||||
|
||||
while(totalsize > 0)
|
||||
{
|
||||
t=fgetc(st);
|
||||
t=is->get();
|
||||
if(t==EOF) break;
|
||||
if(!read32le(&size,st)) break;
|
||||
if(!read32le(&size,is)) break;
|
||||
totalsize -= size + 5;
|
||||
|
||||
switch(t)
|
||||
{
|
||||
case 1:if(!ReadStateChunk(st,SFCPU,size)) ret=0;break;
|
||||
case 3:if(!ReadStateChunk(st,FCEUPPU_STATEINFO,size)) ret=0;break;
|
||||
case 4:if(!ReadStateChunk(st,FCEUCTRL_STATEINFO,size)) ret=0;break;
|
||||
case 7:if(!FCEUMOV_ReadState(st,size)) ret=0;break;
|
||||
case 0x10:if(!ReadStateChunk(st,SFMDATA,size)) ret=0; break;
|
||||
case 1:if(!ReadStateChunk(is,SFCPU,size)) ret=false;break;
|
||||
case 3:if(!ReadStateChunk(is,FCEUPPU_STATEINFO,size)) ret=false;break;
|
||||
case 4:if(!ReadStateChunk(is,FCEUCTRL_STATEINFO,size)) ret=false;break;
|
||||
case 7:if(!FCEUMOV_ReadState(is,size)) ret=false;break;
|
||||
case 0x10:if(!ReadStateChunk(is,SFMDATA,size)) ret=false; break;
|
||||
|
||||
// now it gets hackier:
|
||||
case 5:
|
||||
if(!ReadStateChunk(st,FCEUSND_STATEINFO,size))
|
||||
ret=0;
|
||||
if(!ReadStateChunk(is,FCEUSND_STATEINFO,size))
|
||||
ret=false;
|
||||
else
|
||||
read_snd=1;
|
||||
break;
|
||||
case 6:
|
||||
if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD))
|
||||
{
|
||||
if(!ReadStateChunk(st,FCEUMOV_STATEINFO,size)) ret=0;
|
||||
if(!ReadStateChunk(is,FCEUMOV_STATEINFO,size)) ret=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fseek(st,size,SEEK_CUR)!=0) ret=0;
|
||||
is->seekg(size,std::ios::cur);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
// load back buffer
|
||||
{
|
||||
extern uint8 *XBackBuf;
|
||||
if(size != fread(XBackBuf,1,size,st))
|
||||
ret = 0;
|
||||
if(is->readsome((char*)XBackBuf,size) != size)
|
||||
ret = false;
|
||||
|
||||
//MBG TODO - can this be moved to a better place?
|
||||
//does it even make sense, displaying XBuf when its XBackBuf we just loaded?
|
||||
#ifdef WIN32
|
||||
else
|
||||
{
|
||||
|
@ -331,34 +329,37 @@ static int ReadStateChunks(FILE *st, int32 totalsize)
|
|||
UpdateFCEUWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
if(!ReadStateChunk(st,SFCPUC,size))
|
||||
ret=0;
|
||||
if(!ReadStateChunk(is,SFCPUC,size))
|
||||
ret=false;
|
||||
else
|
||||
read_sfcpuc=1;
|
||||
} break;
|
||||
default:
|
||||
// for somebody's sanity's sake, at least warn about it:
|
||||
if(!warned && !scan_chunks)
|
||||
if(!warned)
|
||||
{
|
||||
char str [256];
|
||||
sprintf(str, "Warning: Found unknown save chunk of type %d.\nThis could indicate the save state is corrupted\nor made with a different (incompatible) emulator version.", t);
|
||||
FCEUD_PrintError(str);
|
||||
warned=1;
|
||||
warned=true;
|
||||
}
|
||||
if(fseek(st,size,SEEK_CUR)<0) goto endo;break;
|
||||
//if(fseek(st,size,SEEK_CUR)<0) goto endo;break;
|
||||
is->seekg(size,std::ios::cur);
|
||||
}
|
||||
}
|
||||
endo:
|
||||
//endo:
|
||||
|
||||
if(X.mooPI==0xFF && !scan_chunks)
|
||||
{
|
||||
// FCEU_PrintError("prevmoo=%d, p=%d",moo,X.P);
|
||||
X.mooPI=X.P; // "Quick and dirty hack." //begone
|
||||
}
|
||||
//mbg 6/16/08 - wtf
|
||||
// if(X.mooPI==0xFF && !scan_chunks)
|
||||
// {
|
||||
//// FCEU_PrintError("prevmoo=%d, p=%d",moo,X.P);
|
||||
// X.mooPI=X.P; // "Quick and dirty hack." //begone
|
||||
// }
|
||||
|
||||
extern int resetDMCacc;
|
||||
if(read_snd)
|
||||
|
@ -479,7 +480,8 @@ void FCEUSS_Save(char *fname)
|
|||
else
|
||||
{
|
||||
//FCEU_PrintError("daCurrentState=%d",CurrentState);
|
||||
st = FCEUD_UTF8_fstream(fn=FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0),"wb");
|
||||
fn = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str());
|
||||
st = FCEUD_UTF8_fstream(fn,"wb");
|
||||
free(fn);
|
||||
}
|
||||
|
||||
|
@ -495,7 +497,6 @@ void FCEUSS_Save(char *fname)
|
|||
else
|
||||
FCEUSS_SaveMS(st,0);
|
||||
|
||||
st->close();
|
||||
delete st;
|
||||
|
||||
if(!fname)
|
||||
|
@ -507,36 +508,9 @@ void FCEUSS_Save(char *fname)
|
|||
|
||||
bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
|
||||
{
|
||||
if(params==SSLOADPARAM_DUMMY && suppress_scan_chunks)
|
||||
return true;
|
||||
|
||||
bool x;
|
||||
uint8 header[16];
|
||||
char* fn=0;
|
||||
|
||||
//Make temporary savestate in case something screws up during the load
|
||||
if(params == SSLOADPARAM_BACKUP)
|
||||
{
|
||||
fn=FCEU_MakeFName(FCEUMKF_NPTEMP,0,0);
|
||||
FILE *fp;
|
||||
|
||||
if((fp=fopen(fn,"wb")))
|
||||
{
|
||||
if(FCEUSS_SaveFP(fp,0))
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(fp);
|
||||
unlink(fn);
|
||||
free(fn);
|
||||
fn=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(params!=SSLOADPARAM_DUMMY)
|
||||
FCEUMOV_PreLoad();
|
||||
|
||||
//read and analyze the header
|
||||
|
@ -547,17 +521,17 @@ bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
|
|||
int stateversion = FCEU_de32lsb(header + 8);
|
||||
int comprlen = FCEU_de32lsb(header + 12);
|
||||
|
||||
std::vector<uint8> buf(totalsize);
|
||||
std::vector<char> buf(totalsize);
|
||||
|
||||
//not compressed:
|
||||
if(comprlen != -1)
|
||||
{
|
||||
//load the compressed chunk and decompress
|
||||
std::vector<uint8> cbuf(comprlen);
|
||||
std::vector<char> cbuf(comprlen);
|
||||
is->read((char*)&cbuf[0],comprlen);
|
||||
|
||||
uLongf uncomprlen = totalsize;
|
||||
int error = uncompress(&buf[0],&uncomprlen,&cbuf[0],comprlen);
|
||||
int error = uncompress((uint8*)&buf[0],&uncomprlen,(uint8*)&cbuf[0],comprlen);
|
||||
if(error != Z_OK || uncomprlen != totalsize)
|
||||
return false;
|
||||
}
|
||||
|
@ -566,24 +540,8 @@ bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
|
|||
is->read((char*)&buf[0],totalsize);
|
||||
}
|
||||
|
||||
//dump it back to a tempfile
|
||||
FILE* tmp = tmpfile();
|
||||
fwrite(&buf[0],1,totalsize,tmp);
|
||||
fseek(tmp,0,SEEK_SET);
|
||||
|
||||
if(params == SSLOADPARAM_DUMMY)
|
||||
{
|
||||
scan_chunks=1;
|
||||
}
|
||||
|
||||
x = ReadStateChunks(tmp,totalsize)!=0;
|
||||
|
||||
if(params == SSLOADPARAM_DUMMY)
|
||||
{
|
||||
scan_chunks=0;
|
||||
fclose(tmp);
|
||||
return true;
|
||||
}
|
||||
memorystream mstemp(&buf);
|
||||
bool x = ReadStateChunks(&mstemp,totalsize)!=0;
|
||||
|
||||
//mbg 5/24/08 - we don't support old states, so this shouldnt matter.
|
||||
//if(read_sfcpuc && stateversion<9500)
|
||||
|
@ -597,153 +555,16 @@ bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params)
|
|||
{
|
||||
FCEUPPU_LoadState(stateversion);
|
||||
FCEUSND_LoadState(stateversion);
|
||||
x=FCEUMOV_PostLoad()!=0;
|
||||
x=FCEUMOV_PostLoad();
|
||||
}
|
||||
|
||||
if(fn)
|
||||
{
|
||||
if(!x || params == SSLOADPARAM_DUMMY) //is make_backup==2 possible?? oh well.
|
||||
{
|
||||
/* Oops! Load the temporary savestate */
|
||||
FILE *fp;
|
||||
|
||||
if((fp=fopen(fn,"rb")))
|
||||
{
|
||||
FCEUSS_LoadFP(fp,SSLOADPARAM_NOBACKUP);
|
||||
fclose(fp);
|
||||
}
|
||||
unlink(fn);
|
||||
}
|
||||
free(fn);
|
||||
}
|
||||
|
||||
fclose(tmp);
|
||||
return x;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FCEUSS_LoadFP(FILE *st, ENUM_SSLOADPARAMS params)
|
||||
{
|
||||
if(params==SSLOADPARAM_DUMMY && suppress_scan_chunks)
|
||||
return true;
|
||||
|
||||
bool x;
|
||||
uint8 header[16];
|
||||
char* fn=0;
|
||||
|
||||
//Make temporary savestate in case something screws up during the load
|
||||
if(params == SSLOADPARAM_BACKUP)
|
||||
{
|
||||
fn=FCEU_MakeFName(FCEUMKF_NPTEMP,0,0);
|
||||
FILE *fp;
|
||||
|
||||
if((fp=fopen(fn,"wb")))
|
||||
{
|
||||
if(FCEUSS_SaveFP(fp,0))
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(fp);
|
||||
unlink(fn);
|
||||
free(fn);
|
||||
fn=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(params!=SSLOADPARAM_DUMMY)
|
||||
FCEUMOV_PreLoad();
|
||||
|
||||
//read and analyze the header
|
||||
fread(&header,1,16,st);
|
||||
if(memcmp(header,"FCSX",4))
|
||||
return false;
|
||||
int totalsize = FCEU_de32lsb(header + 4);
|
||||
int stateversion = FCEU_de32lsb(header + 8);
|
||||
int comprlen = FCEU_de32lsb(header + 12);
|
||||
|
||||
//load the compressed chunk and decompress if necessary
|
||||
std::vector<uint8> buf(totalsize);
|
||||
if(comprlen == -1)
|
||||
{
|
||||
int ret = fread(&buf[0],1,totalsize,st);
|
||||
if(ret != totalsize)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<uint8> cbuf(comprlen);
|
||||
if(fread(&cbuf[0],1,comprlen,st) != comprlen)
|
||||
return false;
|
||||
|
||||
uLongf uncomprlen = totalsize;
|
||||
int error = uncompress(&buf[0],&uncomprlen,&cbuf[0],comprlen);
|
||||
if(error != Z_OK || uncomprlen != totalsize)
|
||||
return false;
|
||||
}
|
||||
|
||||
//dump it back to a tempfile
|
||||
FILE* tmp = tmpfile();
|
||||
fwrite(&buf[0],1,totalsize,tmp);
|
||||
fseek(tmp,0,SEEK_SET);
|
||||
|
||||
if(params == SSLOADPARAM_DUMMY)
|
||||
{
|
||||
scan_chunks=1;
|
||||
}
|
||||
|
||||
x = ReadStateChunks(tmp,totalsize)!=0;
|
||||
|
||||
if(params == SSLOADPARAM_DUMMY)
|
||||
{
|
||||
scan_chunks=0;
|
||||
fclose(tmp);
|
||||
return true;
|
||||
}
|
||||
|
||||
//mbg 5/24/08 - we don't support old states, so this shouldnt matter.
|
||||
//if(read_sfcpuc && stateversion<9500)
|
||||
// X.IRQlow=0;
|
||||
|
||||
if(GameStateRestore)
|
||||
{
|
||||
GameStateRestore(stateversion);
|
||||
}
|
||||
if(x)
|
||||
{
|
||||
FCEUPPU_LoadState(stateversion);
|
||||
FCEUSND_LoadState(stateversion);
|
||||
x=FCEUMOV_PostLoad()!=0;
|
||||
}
|
||||
|
||||
if(fn)
|
||||
{
|
||||
if(!x || params == SSLOADPARAM_DUMMY) //is make_backup==2 possible?? oh well.
|
||||
{
|
||||
/* Oops! Load the temporary savestate */
|
||||
FILE *fp;
|
||||
|
||||
if((fp=fopen(fn,"rb")))
|
||||
{
|
||||
FCEUSS_LoadFP(fp,SSLOADPARAM_NOBACKUP);
|
||||
fclose(fp);
|
||||
}
|
||||
unlink(fn);
|
||||
}
|
||||
free(fn);
|
||||
}
|
||||
|
||||
fclose(tmp);
|
||||
return x;
|
||||
}
|
||||
|
||||
int FCEUSS_Load(char *fname)
|
||||
|
||||
bool FCEUSS_Load(char *fname)
|
||||
{
|
||||
FILE *st;
|
||||
char *fn;
|
||||
std::fstream* st;
|
||||
|
||||
//mbg movie - this needs to be overhauled
|
||||
////this fixes read-only toggle problems
|
||||
|
@ -755,23 +576,22 @@ int FCEUSS_Load(char *fname)
|
|||
if(geniestage==1)
|
||||
{
|
||||
FCEU_DispMessage("Cannot load FCS in GG screen.");
|
||||
return(0);
|
||||
return false;
|
||||
}
|
||||
if(fname)
|
||||
{
|
||||
st=FCEUD_UTF8fopen(fname, "rb");
|
||||
st=FCEUD_UTF8_fstream(fname, "rb");
|
||||
}
|
||||
else
|
||||
{
|
||||
st=FCEUD_UTF8fopen(fn=FCEU_MakeFName(FCEUMKF_STATE,CurrentState,fname),"rb");
|
||||
free(fn);
|
||||
st=FCEUD_UTF8_fstream(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,fname),"rb");
|
||||
}
|
||||
|
||||
if(st == NULL)
|
||||
{
|
||||
FCEU_DispMessage("State %d load error.",CurrentState);
|
||||
SaveStateStatus[CurrentState]=0;
|
||||
return(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//If in bot mode, don't do a backup when loading.
|
||||
|
@ -793,8 +613,8 @@ int FCEUSS_Load(char *fname)
|
|||
FCEU_DispMessage("State %d loaded.",CurrentState);
|
||||
SaveStateStatus[CurrentState]=1;
|
||||
}
|
||||
fclose(st);
|
||||
return(1);
|
||||
delete st;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -803,8 +623,8 @@ int FCEUSS_Load(char *fname)
|
|||
SaveStateStatus[CurrentState]=1;
|
||||
}
|
||||
FCEU_DispMessage("Error(s) reading state %d!",CurrentState);
|
||||
fclose(st);
|
||||
return(0);
|
||||
delete st;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -816,8 +636,7 @@ void FCEUSS_CheckStates(void)
|
|||
|
||||
for(ssel=0;ssel<10;ssel++)
|
||||
{
|
||||
st=FCEUD_UTF8fopen(fn=FCEU_MakeFName(FCEUMKF_STATE,ssel,0),"rb");
|
||||
free(fn);
|
||||
st=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_STATE,ssel,0),"rb");
|
||||
if(st)
|
||||
{
|
||||
SaveStateStatus[ssel]=1;
|
||||
|
@ -920,7 +739,7 @@ void FCEUI_LoadState(char *fname)
|
|||
{
|
||||
if(FCEUnetplay)
|
||||
{
|
||||
char *fn = FCEU_MakeFName(FCEUMKF_NPTEMP, 0, 0);
|
||||
char *fn = strdup(FCEU_MakeFName(FCEUMKF_NPTEMP, 0, 0).c_str());
|
||||
FILE *fp;
|
||||
|
||||
if((fp = fopen(fn," wb")))
|
||||
|
|
|
@ -24,17 +24,16 @@ enum ENUM_SSLOADPARAMS
|
|||
{
|
||||
SSLOADPARAM_NOBACKUP,
|
||||
SSLOADPARAM_BACKUP,
|
||||
SSLOADPARAM_DUMMY
|
||||
};
|
||||
|
||||
void FCEUSS_Save(char *);
|
||||
int FCEUSS_Load(char *);
|
||||
bool FCEUSS_Load(char *);
|
||||
|
||||
//zlib values: 0 (none) through 9 (max) or -1 (default)
|
||||
bool FCEUSS_SaveMS(std::ostream* outstream, int compressionLevel);
|
||||
bool FCEUSS_SaveFP(FILE* fp, int compressionLevel);
|
||||
|
||||
bool FCEUSS_LoadFP(FILE *, ENUM_SSLOADPARAMS);
|
||||
bool FCEUSS_LoadFP(std::istream* is, ENUM_SSLOADPARAMS params);
|
||||
|
||||
extern int CurrentState;
|
||||
void FCEUSS_CheckStates(void);
|
||||
|
|
69
src/types.h
69
src/types.h
|
@ -22,8 +22,8 @@
|
|||
#ifndef __FCEU_TYPES
|
||||
#define __FCEU_TYPES
|
||||
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <iosfwd>
|
||||
|
||||
#define FCEU_VERSION_NUMERIC 19901
|
||||
#define FCEU_NAME "FCE Ultra"
|
||||
|
@ -134,73 +134,6 @@ typedef uint32_t uint32;
|
|||
typedef void (*writefunc)(uint32 A, uint8 V);
|
||||
typedef uint8 (*readfunc)(uint32 A);
|
||||
|
||||
|
||||
template<typename T, int N>
|
||||
struct ValueArray
|
||||
{
|
||||
T data[N];
|
||||
T &operator[](int index) { return data[index]; }
|
||||
static const int size = N;
|
||||
bool operator!=(ValueArray<T,N> &other) { return !operator==(other); }
|
||||
bool operator==(ValueArray<T,N> &other)
|
||||
{
|
||||
for(int i=0;i<size;i++)
|
||||
if(data[i] != other[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#include "utils/endian.h"
|
||||
|
||||
|
||||
struct FCEU_Guid : public ValueArray<uint8,16>
|
||||
{
|
||||
void newGuid()
|
||||
{
|
||||
for(int i=0;i<size;i++)
|
||||
data[i] = rand();
|
||||
}
|
||||
|
||||
std::string toString()
|
||||
{
|
||||
char buf[37];
|
||||
sprintf(buf,"%08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X",
|
||||
FCEU_de32lsb(data),FCEU_de16lsb(data+4),FCEU_de16lsb(data+6),FCEU_de16lsb(data+8),data[10],data[11],data[12],data[13],data[14],data[15]);
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
static FCEU_Guid fromString(std::string str)
|
||||
{
|
||||
FCEU_Guid ret;
|
||||
ret.scan(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8 hexToByte(char** ptrptr)
|
||||
{
|
||||
char a = toupper(**ptrptr);
|
||||
(*ptrptr)++;
|
||||
char b = toupper(**ptrptr);
|
||||
(*ptrptr)++;
|
||||
if(a>='A') a=a-'A'+10;
|
||||
else a-='0';
|
||||
if(b>='A') b=b-'A'+10;
|
||||
else b-='0';
|
||||
return ((unsigned char)a<<4)|(unsigned char)b;
|
||||
}
|
||||
|
||||
void scan(std::string str)
|
||||
{
|
||||
char* endptr = (char*)str.c_str();
|
||||
FCEU_en32lsb(data,strtoul(endptr,&endptr,16));
|
||||
FCEU_en16lsb(data+4,strtoul(endptr+1,&endptr,16));
|
||||
FCEU_en16lsb(data+6,strtoul(endptr+1,&endptr,16));
|
||||
FCEU_en16lsb(data+8,strtoul(endptr+1,&endptr,16));
|
||||
endptr++;
|
||||
for(int i=0;i<6;i++)
|
||||
data[10+i] = hexToByte(&endptr);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
51
src/unif.cpp
51
src/unif.cpp
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* TODO: Battery backup file saving, mirror force */
|
||||
/* **INCOMPLETE** */
|
||||
|
@ -38,6 +38,7 @@
|
|||
#include "state.h"
|
||||
#include "file.h"
|
||||
#include "input.h"
|
||||
#include "driver.h"
|
||||
|
||||
typedef struct {
|
||||
char ID[4];
|
||||
|
@ -315,7 +316,7 @@ static int LoadCHR(FCEUFILE *fp)
|
|||
|
||||
static BMAPPING bmap[] = {
|
||||
|
||||
/* Sachen Carts */
|
||||
/* Sachen Carts */
|
||||
{ "TC-U01-1.5M", TCU01_Init,0},
|
||||
{ "Sachen-8259A", S8259A_Init,0},
|
||||
{ "Sachen-8259B", S8259B_Init,0},
|
||||
|
@ -330,11 +331,11 @@ static BMAPPING bmap[] = {
|
|||
{ "SA-0037", SA0037_Init,0},
|
||||
{ "SA-NROM", TCA01_Init,0},
|
||||
|
||||
// /* AVE carts. */
|
||||
// { "MB-91", MB91_Init,0}, // DeathBots
|
||||
// { "NINA-06", NINA06_Init,0}, // F-15 City War
|
||||
// { "NINA-03", NINA03_Init,0}, // Tiles of Fate
|
||||
// { "NINA-001", NINA001_Init,0}, // Impossible Mission 2
|
||||
// /* AVE carts. */
|
||||
// { "MB-91", MB91_Init,0}, // DeathBots
|
||||
// { "NINA-06", NINA06_Init,0}, // F-15 City War
|
||||
// { "NINA-03", NINA03_Init,0}, // Tiles of Fate
|
||||
// { "NINA-001", NINA001_Init,0}, // Impossible Mission 2
|
||||
|
||||
{ "ANROM", ANROM_Init,0},
|
||||
|
||||
|
@ -565,7 +566,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp)
|
|||
GameInterface=UNIFGI;
|
||||
return 1;
|
||||
|
||||
aborto:
|
||||
aborto:
|
||||
|
||||
FreeUNIF();
|
||||
ResetUNIF();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include "../types.h"
|
||||
#include "endian.h"
|
||||
|
||||
|
@ -91,6 +92,19 @@ int read32le(uint32 *Bufo, FILE *fp)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int read32le(uint32 *Bufo, std::istream *is)
|
||||
{
|
||||
uint32 buf;
|
||||
if(is->readsome((char*)&buf,4) != 4)
|
||||
return 0;
|
||||
#ifdef LSB_FIRST
|
||||
*(uint32*)Bufo=buf;
|
||||
#else
|
||||
*(uint32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
///reads a little endian 16bit value from the specified file
|
||||
int read16le(char *d, FILE *fp)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
#ifndef __FCEU_ENDIAN
|
||||
#define __FCEU_ENDIAN
|
||||
|
||||
//#include <iosfwd>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int write16le(uint16 b, FILE *fp);
|
||||
int write32le(uint32 b, FILE *fp);
|
||||
int write32le(uint32 b, std::ostream* os);
|
||||
int read32le(uint32 *Bufo, std::istream *is);
|
||||
int read32le(uint32 *Bufo, FILE *fp);
|
||||
void FlipByteOrder(uint8 *src, uint32 count);
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#include "guid.h"
|
||||
|
||||
void FCEU_Guid::newGuid()
|
||||
{
|
||||
for(int i=0;i<size;i++)
|
||||
data[i] = rand();
|
||||
}
|
||||
|
||||
std::string FCEU_Guid::toString()
|
||||
{
|
||||
char buf[37];
|
||||
sprintf(buf,"%08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X",
|
||||
FCEU_de32lsb(data),FCEU_de16lsb(data+4),FCEU_de16lsb(data+6),FCEU_de16lsb(data+8),data[10],data[11],data[12],data[13],data[14],data[15]);
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
FCEU_Guid FCEU_Guid::fromString(std::string str)
|
||||
{
|
||||
FCEU_Guid ret;
|
||||
ret.scan(str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8 FCEU_Guid::hexToByte(char** ptrptr)
|
||||
{
|
||||
char a = toupper(**ptrptr);
|
||||
(*ptrptr)++;
|
||||
char b = toupper(**ptrptr);
|
||||
(*ptrptr)++;
|
||||
if(a>='A') a=a-'A'+10;
|
||||
else a-='0';
|
||||
if(b>='A') b=b-'A'+10;
|
||||
else b-='0';
|
||||
return ((unsigned char)a<<4)|(unsigned char)b;
|
||||
}
|
||||
|
||||
void FCEU_Guid::scan(std::string& str)
|
||||
{
|
||||
char* endptr = (char*)str.c_str();
|
||||
FCEU_en32lsb(data,strtoul(endptr,&endptr,16));
|
||||
FCEU_en16lsb(data+4,strtoul(endptr+1,&endptr,16));
|
||||
FCEU_en16lsb(data+6,strtoul(endptr+1,&endptr,16));
|
||||
FCEU_en16lsb(data+8,strtoul(endptr+1,&endptr,16));
|
||||
endptr++;
|
||||
for(int i=0;i<6;i++)
|
||||
data[10+i] = hexToByte(&endptr);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef _guid_h_
|
||||
#define _guid_h_
|
||||
|
||||
#include <string>
|
||||
#include "types.h"
|
||||
#include "valuearray.h"
|
||||
|
||||
struct FCEU_Guid : public ValueArray<uint8,16>
|
||||
{
|
||||
void newGuid();
|
||||
std::string toString();
|
||||
static FCEU_Guid fromString(std::string str);
|
||||
static uint8 hexToByte(char** ptrptr);
|
||||
void scan(std::string& str);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -2,6 +2,7 @@
|
|||
#define _MD5_H
|
||||
|
||||
#include "../types.h"
|
||||
#include "valuearray.h"
|
||||
|
||||
struct md5_context
|
||||
{
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _VALUEARRAY_H_
|
||||
#define _VALUEARRAY_H_
|
||||
|
||||
template<typename T, int N>
|
||||
struct ValueArray
|
||||
{
|
||||
T data[N];
|
||||
T &operator[](int index) { return data[index]; }
|
||||
static const int size = N;
|
||||
bool operator!=(ValueArray<T,N> &other) { return !operator==(other); }
|
||||
bool operator==(ValueArray<T,N> &other)
|
||||
{
|
||||
for(int i=0;i<size;i++)
|
||||
if(data[i] != other[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -478,3 +478,9 @@ unsigned int uintDecFromIstream(std::istream* is)
|
|||
is->unget();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string stditoa(int n)
|
||||
{
|
||||
char tempbuf[16];
|
||||
return itoa(n,tempbuf,10);
|
||||
}
|
|
@ -55,5 +55,7 @@ char *U8ToDecStr(uint8 a);
|
|||
char *U8ToHexStr(uint8 a);
|
||||
char *U16ToHexStr(uint16 a);
|
||||
|
||||
std::string stditoa(int n);
|
||||
|
||||
//extracts a decimal uint from an istream
|
||||
unsigned int uintDecFromIstream(std::istream* is);
|
|
@ -1,22 +1,22 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Xodnizel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef WIN32
|
||||
#include <stdint.h>
|
||||
|
@ -147,9 +147,9 @@ int FCEU_InitVirtualVideo(void)
|
|||
void ShowFPS(void);
|
||||
void FCEU_PutImageDummy(void)
|
||||
{
|
||||
#ifdef SHOWFPS
|
||||
#ifdef SHOWFPS
|
||||
ShowFPS();
|
||||
#endif
|
||||
#endif
|
||||
if(GameInfo->type!=GIT_NSF)
|
||||
{
|
||||
FCEU_DrawNTSCControlBars(XBuf);
|
||||
|
@ -402,7 +402,7 @@ int SaveSnapshot(void)
|
|||
|
||||
for(u=lastu;u<99999;u++)
|
||||
{
|
||||
pp=FCEUD_UTF8fopen((fn=FCEU_MakeFName(FCEUMKF_SNAP,u,"png")),"rb");
|
||||
pp=FCEUD_UTF8fopen((fn=strdup(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str())),"rb");
|
||||
if(pp==NULL) break;
|
||||
fclose(pp);
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ int SaveSnapshot(void)
|
|||
return u+1;
|
||||
|
||||
|
||||
PNGerr:
|
||||
PNGerr:
|
||||
if(compmem)
|
||||
free(compmem);
|
||||
if(pp)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "netplay.h"
|
||||
#include "vsuni.h"
|
||||
#include "state.h"
|
||||
#include "driver.h"
|
||||
|
||||
#define IOPTION_GUN 0x1
|
||||
#define IOPTION_SWAPDIRAB 0x2
|
||||
|
|
|
@ -76,18 +76,18 @@ void X6502_DMW(uint32 A, uint8 V)
|
|||
#define PUSH(V) \
|
||||
{ \
|
||||
uint8 VTMP=V; \
|
||||
WrRAM(0x100+_S,VTMP); \
|
||||
_S--; \
|
||||
WrRAM(0x100+__S,VTMP); \
|
||||
__S--; \
|
||||
}
|
||||
|
||||
#define POP() RdRAM(0x100+(++_S))
|
||||
#define POP() RdRAM(0x100+(++__S))
|
||||
|
||||
static uint8 ZNTable[256];
|
||||
/* Some of these operations will only make sense if you know what the flag
|
||||
constants are. */
|
||||
|
||||
#define X_ZN(zort) _P&=~(Z_FLAG|N_FLAG);_P|=ZNTable[zort]
|
||||
#define X_ZNT(zort) _P|=ZNTable[zort]
|
||||
#define X_ZN(zort) __P&=~(Z_FLAG|N_FLAG);__P|=ZNTable[zort]
|
||||
#define X_ZNT(zort) __P|=ZNTable[zort]
|
||||
|
||||
#define JR(cond); \
|
||||
{ \
|
||||
|
@ -113,24 +113,24 @@ static uint8 ZNTable[256];
|
|||
|
||||
/* All of the freaky arithmetic operations. */
|
||||
#define AND _A&=x;X_ZN(_A)
|
||||
#define BIT _P&=~(Z_FLAG|V_FLAG|N_FLAG);_P|=ZNTable[x&_A]&Z_FLAG;_P|=x&(V_FLAG|N_FLAG)
|
||||
#define BIT __P&=~(Z_FLAG|V_FLAG|N_FLAG);__P|=ZNTable[x&_A]&Z_FLAG;__P|=x&(V_FLAG|N_FLAG)
|
||||
#define EOR _A^=x;X_ZN(_A)
|
||||
#define ORA _A|=x;X_ZN(_A)
|
||||
|
||||
#define ADC { \
|
||||
uint32 l=_A+x+(_P&1); \
|
||||
_P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \
|
||||
_P|=((((_A^x)&0x80)^0x80) & ((_A^l)&0x80))>>1; \
|
||||
_P|=(l>>8)&C_FLAG; \
|
||||
uint32 l=_A+x+(__P&1); \
|
||||
__P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \
|
||||
__P|=((((_A^x)&0x80)^0x80) & ((_A^l)&0x80))>>1; \
|
||||
__P|=(l>>8)&C_FLAG; \
|
||||
_A=l; \
|
||||
X_ZNT(_A); \
|
||||
}
|
||||
|
||||
#define SBC { \
|
||||
uint32 l=_A-x-((_P&1)^1); \
|
||||
_P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \
|
||||
_P|=((_A^l)&(_A^x)&0x80)>>1; \
|
||||
_P|=((l>>8)&C_FLAG)^C_FLAG; \
|
||||
uint32 l=_A-x-((__P&1)^1); \
|
||||
__P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \
|
||||
__P|=((_A^l)&(_A^x)&0x80)>>1; \
|
||||
__P|=((l>>8)&C_FLAG)^C_FLAG; \
|
||||
_A=l; \
|
||||
X_ZNT(_A); \
|
||||
}
|
||||
|
@ -138,16 +138,16 @@ static uint8 ZNTable[256];
|
|||
#define CMPL(a1,a2) { \
|
||||
uint32 t=a1-a2; \
|
||||
X_ZN(t&0xFF); \
|
||||
_P&=~C_FLAG; \
|
||||
_P|=((t>>8)&C_FLAG)^C_FLAG; \
|
||||
__P&=~C_FLAG; \
|
||||
__P|=((t>>8)&C_FLAG)^C_FLAG; \
|
||||
}
|
||||
|
||||
/* Special undocumented operation. Very similar to CMP. */
|
||||
#define AXS { \
|
||||
uint32 t=(_A&_X)-x; \
|
||||
X_ZN(t&0xFF); \
|
||||
_P&=~C_FLAG; \
|
||||
_P|=((t>>8)&C_FLAG)^C_FLAG; \
|
||||
__P&=~C_FLAG; \
|
||||
__P|=((t>>8)&C_FLAG)^C_FLAG; \
|
||||
_X=t; \
|
||||
}
|
||||
|
||||
|
@ -159,26 +159,26 @@ static uint8 ZNTable[256];
|
|||
#define DEC x--;X_ZN(x)
|
||||
#define INC x++;X_ZN(x)
|
||||
|
||||
#define ASL _P&=~C_FLAG;_P|=x>>7;x<<=1;X_ZN(x)
|
||||
#define LSR _P&=~(C_FLAG|N_FLAG|Z_FLAG);_P|=x&1;x>>=1;X_ZNT(x)
|
||||
#define ASL __P&=~C_FLAG;__P|=x>>7;x<<=1;X_ZN(x)
|
||||
#define LSR __P&=~(C_FLAG|N_FLAG|Z_FLAG);__P|=x&1;x>>=1;X_ZNT(x)
|
||||
|
||||
/* For undocumented instructions, maybe for other things later... */
|
||||
#define LSRA _P&=~(C_FLAG|N_FLAG|Z_FLAG);_P|=_A&1;_A>>=1;X_ZNT(_A)
|
||||
#define LSRA __P&=~(C_FLAG|N_FLAG|Z_FLAG);__P|=_A&1;_A>>=1;X_ZNT(_A)
|
||||
|
||||
#define ROL { \
|
||||
uint8 l=x>>7; \
|
||||
x<<=1; \
|
||||
x|=_P&C_FLAG; \
|
||||
_P&=~(Z_FLAG|N_FLAG|C_FLAG); \
|
||||
_P|=l; \
|
||||
x|=__P&C_FLAG; \
|
||||
__P&=~(Z_FLAG|N_FLAG|C_FLAG); \
|
||||
__P|=l; \
|
||||
X_ZNT(x); \
|
||||
}
|
||||
#define ROR { \
|
||||
uint8 l=x&1; \
|
||||
x>>=1; \
|
||||
x|=(_P&C_FLAG)<<7; \
|
||||
_P&=~(Z_FLAG|N_FLAG|C_FLAG); \
|
||||
_P|=l; \
|
||||
x|=(__P&C_FLAG)<<7; \
|
||||
__P&=~(Z_FLAG|N_FLAG|C_FLAG); \
|
||||
__P|=l; \
|
||||
X_ZNT(x); \
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ void X6502_Init(void)
|
|||
|
||||
void X6502_Power(void)
|
||||
{
|
||||
_count=_tcount=_IRQlow=_PC=_A=_X=_Y=_S=_P=_PI=_DB=_jammed=0;
|
||||
_count=_tcount=_IRQlow=_PC=_A=_X=_Y=__S=__P=_PI=_DB=_jammed=0;
|
||||
timestamp=0;
|
||||
X6502_Reset();
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ void X6502_Run(int32 cycles)
|
|||
_PC=RdMem(0xFFFC);
|
||||
_PC|=RdMem(0xFFFD)<<8;
|
||||
_jammed=0;
|
||||
_PI=_P=I_FLAG;
|
||||
_PI=__P=I_FLAG;
|
||||
_IRQlow&=~FCEU_IQRESET;
|
||||
}
|
||||
else if(_IRQlow&FCEU_IQNMI2)
|
||||
|
@ -434,8 +434,8 @@ void X6502_Run(int32 cycles)
|
|||
ADDCYC(7);
|
||||
PUSH(_PC>>8);
|
||||
PUSH(_PC);
|
||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||
_P|=I_FLAG;
|
||||
PUSH((__P&~B_FLAG)|(U_FLAG));
|
||||
__P|=I_FLAG;
|
||||
DEBUG( if(debug_loggingCD) LogCDVectors(1) );
|
||||
_PC=RdMem(0xFFFA);
|
||||
_PC|=RdMem(0xFFFB)<<8;
|
||||
|
@ -449,8 +449,8 @@ void X6502_Run(int32 cycles)
|
|||
ADDCYC(7);
|
||||
PUSH(_PC>>8);
|
||||
PUSH(_PC);
|
||||
PUSH((_P&~B_FLAG)|(U_FLAG));
|
||||
_P|=I_FLAG;
|
||||
PUSH((__P&~B_FLAG)|(U_FLAG));
|
||||
__P|=I_FLAG;
|
||||
DEBUG( if(debug_loggingCD) LogCDVectors(1) );
|
||||
_PC=RdMem(0xFFFE);
|
||||
_PC|=RdMem(0xFFFF)<<8;
|
||||
|
@ -459,7 +459,7 @@ void X6502_Run(int32 cycles)
|
|||
_IRQlow&=~(FCEU_IQTEMP);
|
||||
if(_count<=0)
|
||||
{
|
||||
_PI=_P;
|
||||
_PI=__P;
|
||||
return;
|
||||
} //Should increase accuracy without a
|
||||
//major speed hit.
|
||||
|
@ -468,7 +468,7 @@ void X6502_Run(int32 cycles)
|
|||
//will probably cause a major speed decrease on low-end systems
|
||||
DEBUG( DebugCycle() );
|
||||
|
||||
_PI=_P;
|
||||
_PI=__P;
|
||||
b1=RdMem(_PC);
|
||||
|
||||
ADDCYC(CycTable[b1]);
|
||||
|
|
|
@ -27,8 +27,8 @@ extern X6502 X;
|
|||
#define _A X.A
|
||||
#define _X X.X
|
||||
#define _Y X.Y
|
||||
#define _S X.S
|
||||
#define _P X.P
|
||||
#define __S X.S
|
||||
#define __P X.P
|
||||
#define _PI X.mooPI
|
||||
#define _DB X.DB
|
||||
#define _count X.count
|
||||
|
|
|
@ -358,6 +358,14 @@
|
|||
<File
|
||||
RelativePath="..\src\boards\01-222.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
GeneratePreprocessedFile="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\boards\112.cpp"
|
||||
|
@ -2156,6 +2164,14 @@
|
|||
RelativePath="..\src\utils\general.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\utils\guid.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\utils\guid.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\utils\md5.cpp"
|
||||
>
|
||||
|
@ -2184,6 +2200,10 @@
|
|||
RelativePath="..\src\utils\unzip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\utils\valuearray.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\utils\xstring.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue