ADDED support for .ips .ups .ppf files to the GUI.

This commit is contained in:
spacy51 2008-10-16 15:29:53 +00:00
parent 400418b1d3
commit 80b5a685f1
8 changed files with 40 additions and 22 deletions

View File

@ -138,7 +138,7 @@ struct {
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR }, { "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K }, { "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M }, { "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorAutoIPSPatch", ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH }, { "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT }, { "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK }, { "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL }, { "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },

View File

@ -69,6 +69,12 @@ MainWnd::~MainWnd()
{ {
} }
bool MainWnd::fileExists( LPCTSTR lpFileName )
{
// check if file exists
return GetFileAttributes( lpFileName ) != INVALID_FILE_ATTRIBUTES;
}
BEGIN_MESSAGE_MAP(MainWnd, CWnd) BEGIN_MESSAGE_MAP(MainWnd, CWnd)
//{{AFX_MSG_MAP(MainWnd) //{{AFX_MSG_MAP(MainWnd)
@ -173,8 +179,8 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnUpdateOptionsEmulatorSynchronize) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnUpdateOptionsEmulatorSynchronize)
ON_COMMAND(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnOptionsEmulatorSpeeduptoggle) ON_COMMAND(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnOptionsEmulatorSpeeduptoggle)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnUpdateOptionsEmulatorSpeeduptoggle) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnUpdateOptionsEmulatorSpeeduptoggle)
ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnOptionsEmulatorAutomaticallyipspatch) ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES, OnOptionsEmulatorAutomaticallyApplyPatchFiles)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnUpdateOptionsEmulatorAutomaticallyipspatch) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES, OnUpdateOptionsEmulatorAutomaticallyipspatch)
ON_COMMAND(ID_OPTIONS_EMULATOR_AGBPRINT, OnOptionsEmulatorAgbprint) ON_COMMAND(ID_OPTIONS_EMULATOR_AGBPRINT, OnOptionsEmulatorAgbprint)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AGBPRINT, OnUpdateOptionsEmulatorAgbprint) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AGBPRINT, OnUpdateOptionsEmulatorAgbprint)
ON_COMMAND(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnOptionsEmulatorRealtimeclock) ON_COMMAND(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnOptionsEmulatorRealtimeclock)
@ -455,8 +461,19 @@ bool MainWnd::FileRun()
gbCheatRemoveAll(); gbCheatRemoveAll();
} }
CString ipsname; CString patchName;
ipsname.Format("%s.ips", theApp.filename); patchName.Format("%s.ips", theApp.filename);
if( !fileExists( patchName ) ) {
patchName.Format("%s.ups", theApp.filename);
if( !fileExists( patchName ) ) {
patchName.Format("%s.ppf", theApp.filename);
if( !fileExists( patchName ) ) {
// don't use any patches
patchName.Empty();
}
}
}
if(!theApp.dir.GetLength()) { if(!theApp.dir.GetLength()) {
int index = theApp.filename.ReverseFind('\\'); int index = theApp.filename.ReverseFind('\\');
@ -495,9 +512,9 @@ bool MainWnd::FileRun()
theApp.romSize = gbRomSize; theApp.romSize = gbRomSize;
if(theApp.autoIPS) { if(theApp.autoPatch && !patchName.IsEmpty()) {
int size = gbRomSize; int size = gbRomSize;
utilApplyIPS(ipsname, &gbRom, &size); utilApplyIPS(patchName, &gbRom, &size);
if(size != gbRomSize) { if(size != gbRomSize) {
extern bool gbUpdateSizes(); extern bool gbUpdateSizes();
gbUpdateSizes(); gbUpdateSizes();
@ -562,9 +579,9 @@ bool MainWnd::FileRun()
} }
*/ */
if(theApp.autoIPS) { if(theApp.autoPatch && !patchName.IsEmpty()) {
int size = 0x2000000; int size = 0x2000000;
utilApplyIPS(ipsname, &rom, &size); utilApplyIPS(patchName, &rom, &size);
if(size != 0x2000000) { if(size != 0x2000000) {
CPUReset(); CPUReset();
} }
@ -1151,9 +1168,7 @@ void MainWnd::screenCapture(int captureNumber)
captureNumber, captureNumber,
ext); ext);
// check if file exists if( fileExists( buffer ) ) {
DWORD dwAttr = GetFileAttributes( buffer );
if( dwAttr != INVALID_FILE_ATTRIBUTES ) {
// screenshot file already exists // screenshot file already exists
screenCapture(++captureNumber); screenCapture(++captureNumber);
// this will recursively use the first non-existent screenshot number // this will recursively use the first non-existent screenshot number

View File

@ -49,6 +49,9 @@ public:
void winSaveCheatList(const char *name); void winSaveCheatList(const char *name);
void winSaveCheatListDefault(); void winSaveCheatListDefault();
private:
bool fileExists( LPCTSTR lpFileName );
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
@ -176,7 +179,7 @@ protected:
afx_msg void OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI); afx_msg void OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSpeeduptoggle(); afx_msg void OnOptionsEmulatorSpeeduptoggle();
afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI); afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAutomaticallyipspatch(); afx_msg void OnOptionsEmulatorAutomaticallyApplyPatchFiles();
afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI); afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAgbprint(); afx_msg void OnOptionsEmulatorAgbprint();
afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI); afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI);

View File

@ -536,14 +536,14 @@ void MainWnd::OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI)
pCmdUI->SetCheck(theApp.speedupToggle); pCmdUI->SetCheck(theApp.speedupToggle);
} }
void MainWnd::OnOptionsEmulatorAutomaticallyipspatch() void MainWnd::OnOptionsEmulatorAutomaticallyApplyPatchFiles()
{ {
theApp.autoIPS = !theApp.autoIPS; theApp.autoPatch = !theApp.autoPatch;
} }
void MainWnd::OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI) void MainWnd::OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI)
{ {
pCmdUI->SetCheck(theApp.autoIPS); pCmdUI->SetCheck(theApp.autoPatch);
} }
void MainWnd::OnOptionsEmulatorAgbprint() void MainWnd::OnOptionsEmulatorAgbprint()

View File

@ -257,7 +257,7 @@ VBA::VBA()
autoSaveLoadCheatList = false; autoSaveLoadCheatList = false;
winout = NULL; winout = NULL;
removeIntros = false; removeIntros = false;
autoIPS = true; autoPatch = true;
winGbBorderOn = 0; winGbBorderOn = 0;
winFlashSize = 0x20000; winFlashSize = 0x20000;
winRtcEnable = false; winRtcEnable = false;
@ -1635,7 +1635,7 @@ void VBA::loadSettings()
recentFreeze = regQueryDwordValue("recentFreeze", false) ? true : false; recentFreeze = regQueryDwordValue("recentFreeze", false) ? true : false;
autoIPS = regQueryDwordValue("autoIPS", true) ? true : false; autoPatch = regQueryDwordValue("autoPatch", 1) == 1 ? true : false;
cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false; cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false;
@ -2616,7 +2616,7 @@ void VBA::saveSettings()
regSetDwordValue("recentFreeze", recentFreeze); regSetDwordValue("recentFreeze", recentFreeze);
regSetDwordValue("autoIPS", autoIPS); regSetDwordValue("autoPatch", autoPatch ? 1 : 0);
regSetDwordValue("disableSfx", cpuDisableSfx); regSetDwordValue("disableSfx", cpuDisableSfx);

View File

@ -124,7 +124,7 @@ class VBA : public CWinApp
bool autoSaveLoadCheatList; bool autoSaveLoadCheatList;
FILE *winout; FILE *winout;
bool removeIntros; bool removeIntros;
bool autoIPS; bool autoPatch;
int winGbBorderOn; int winGbBorderOn;
int winFlashSize; int winFlashSize;
bool winRtcEnable; bool winRtcEnable;

View File

@ -1859,7 +1859,7 @@ BEGIN
MENUITEM "&Below Normal", ID_OPTIONS_PRIORITY_BELOWNORMAL MENUITEM "&Below Normal", ID_OPTIONS_PRIORITY_BELOWNORMAL
END END
MENUITEM "&Remove intros (GBA)", ID_OPTIONS_EMULATOR_REMOVEINTROSGBA MENUITEM "&Remove intros (GBA)", ID_OPTIONS_EMULATOR_REMOVEINTROSGBA
MENUITEM "Automatic IPS patching", ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH MENUITEM "Auto-apply IPS/UPS/PPF", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES
MENUITEM "AGB Print", ID_OPTIONS_EMULATOR_AGBPRINT MENUITEM "AGB Print", ID_OPTIONS_EMULATOR_AGBPRINT
MENUITEM "Real Time Clock", ID_OPTIONS_EMULATOR_REALTIMECLOCK MENUITEM "Real Time Clock", ID_OPTIONS_EMULATOR_REALTIMECLOCK
MENUITEM "&Game Overrides...", ID_OPTIONS_EMULATOR_GAMEOVERRIDES MENUITEM "&Game Overrides...", ID_OPTIONS_EMULATOR_GAMEOVERRIDES

View File

@ -718,7 +718,7 @@
#define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR 40173 #define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR 40173
#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K 40174 #define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K 40174
#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M 40175 #define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M 40175
#define ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH 40176 #define ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES 40176
#define ID_TOOLS_RECORD_STARTAVIRECORDING 40178 #define ID_TOOLS_RECORD_STARTAVIRECORDING 40178
#define ID_TOOLS_RECORD_STOPAVIRECORDING 40179 #define ID_TOOLS_RECORD_STOPAVIRECORDING 40179
#define ID_OPTIONS_FILTER_BILINEAR 40186 #define ID_OPTIONS_FILTER_BILINEAR 40186