diff --git a/pcsx2/HwRead.cpp b/pcsx2/HwRead.cpp index 046cede311..ae37239eb9 100644 --- a/pcsx2/HwRead.cpp +++ b/pcsx2/HwRead.cpp @@ -196,6 +196,8 @@ mem32_t __fastcall hwRead32_page_0F(u32 mem) switch( mem ) { case 0xf000: + if( CHECK_INTC_STAT_HACK ) + cpuRegs.cycle = g_nextBranchCycle; // This one is checked alot, so leave it commented out unless you love 600 meg logfiles. //HW_LOG("INTC_STAT Read 32bit %x\n", psHu32(0xf010)); break; @@ -325,6 +327,9 @@ void __fastcall hwRead64_page_02(u32 mem, mem64_t* result ) void __fastcall hwRead64_generic(u32 mem, mem64_t* result ) { + if( mem == INTC_STAT && CHECK_INTC_STAT_HACK ) + cpuRegs.cycle = g_nextBranchCycle; + *result = psHu64(mem); HW_LOG("Unknown Hardware Read 64 at %x\n",mem); } diff --git a/pcsx2/MemoryCard.cpp b/pcsx2/MemoryCard.cpp index 96a70d7e1e..db5bb80e58 100644 --- a/pcsx2/MemoryCard.cpp +++ b/pcsx2/MemoryCard.cpp @@ -23,65 +23,67 @@ #include "Paths.h" #ifdef WIN32 -extern void NTFS_CompressFile( const char* file ); +extern void NTFS_CompressFile( const char* file, bool compressMode ); #endif -static FILE* MemoryCard[2] = { NULL, NULL }; +FILE* MemoryCard::cardfile[2] = { NULL, NULL }; + // Ensures memory card files are created/initialized. -void MemoryCard_Init() +void MemoryCard::Init() { for( int i=0; i<2; i++ ) { - if( MemoryCard[i] == NULL ) - MemoryCard[i] = LoadMcd(i); + if( Config.Mcd[i].Enabled && cardfile[i] == NULL ) + cardfile[i] = Load(i); } } -void MemoryCard_Shutdown() +void MemoryCard::Shutdown() { for( int i=0; i<2; i++ ) { - if(MemoryCard[0]) fclose(MemoryCard[i]); - MemoryCard[0] = NULL; + if(cardfile[0] == NULL) continue; + fclose( cardfile[i] ); + cardfile[0] = NULL; } } -bool TestMcdIsPresent( int mcd ) +bool MemoryCard::IsPresent( uint mcd ) { - jASSUME( mcd == 0 || mcd == 1 ); - return MemoryCard[mcd] != NULL; + jASSUME( mcd < 2 ); + return cardfile[mcd] != NULL; } -FILE *LoadMcd(int mcd) +FILE *MemoryCard::Load( uint mcd ) { - string str; FILE *f; - jASSUME( mcd == 0 || mcd == 1 ); - str = (mcd == 0) ? Config.Mcd1 : Config.Mcd2; + jASSUME( mcd < 2 ); + string str( Config.Mcd[mcd].Filename ); if( str.empty() ) Path::Combine( str, MEMCARDS_DIR, fmt_string( "Mcd00%d.ps2", mcd ) ); if( !Path::Exists(str) ) - CreateMcd(str.c_str()); + Create( str.c_str() ); #ifdef WIN32 - NTFS_CompressFile( str.c_str() ); + NTFS_CompressFile( str.c_str(), Config.McdEnableNTFS ); #endif - f = fopen(str.c_str(), "r+b"); + f = fopen( str.c_str(), "r+b" ); - if (f == NULL) { - Msgbox::Alert("Failed loading MemCard from file: %hs", params &str); + if (f == NULL) + { + Msgbox::Alert("Failed loading MemoryCard from file: %hs", params &str); return NULL; } return f; } -void SeekMcd(FILE *f, u32 adr) +void MemoryCard::Seek( FILE *f, u32 adr ) { u32 size; @@ -94,65 +96,97 @@ void SeekMcd(FILE *f, u32 adr) fseek(f, adr, SEEK_SET); } -void ReadMcd(int mcd, u8 *data, u32 adr, int size) +void MemoryCard::Read( uint mcd, u8 *data, u32 adr, int size ) { - jASSUME( mcd == 0 || mcd == 1 ); - FILE* const mcfp = MemoryCard[mcd]; + jASSUME( mcd < 2 ); + FILE* const mcfp = cardfile[mcd]; - if (mcfp == NULL) { + if( mcfp == NULL ) + { + Console::Error( "MemoryCard > Ignoring attempted read from disabled card." ); memset(data, 0, size); return; } - SeekMcd(mcfp, adr); + Seek(mcfp, adr); fread(data, 1, size, mcfp); } -void SaveMcd(int mcd, const u8 *data, u32 adr, int size) +void MemoryCard::Save( uint mcd, const u8 *data, u32 adr, int size ) { - jASSUME( mcd == 0 || mcd == 1 ); - FILE* const mcfp = MemoryCard[mcd]; + jASSUME( mcd < 2 ); + FILE* const mcfp = cardfile[mcd]; - SeekMcd(mcfp, adr); + if( mcfp == NULL ) + { + Console::Error( "MemoryCard > Ignoring attempted save/write to disabled card." ); + return; + } + + Seek(mcfp, adr); u8 *currentdata = (u8 *)malloc(size); fread(currentdata, 1, size, mcfp); + for (int i=0; i(data); // clears to -1's - jASSUME( mcd == 0 || mcd == 1 ); - FILE* const mcfp = MemoryCard[mcd]; - SeekMcd(mcfp, adr); + jASSUME( mcd < 2 ); + FILE* const mcfp = cardfile[mcd]; + + if( mcfp == NULL ) + { + DevCon::Notice( "MemoryCard > Ignoring seek for disabled card." ); + return; + } + + Seek(mcfp, adr); fwrite(data, 1, 528*16, mcfp); } -void CreateMcd(const char *mcd) +void MemoryCard::Create( const char *mcdFile ) { - FILE *fp; - int i=0, j=0; //int enc[16] = {0x77,0x7f,0x7f,0x77,0x7f,0x7f,0x77,0x7f,0x7f,0x77,0x7f,0x7f,0,0,0,0}; - fp = fopen(mcd, "wb"); - if (fp == NULL) return; - for(i=0; i < 16384; i++) + FILE* fp = fopen( mcdFile, "wb" ); + if( fp == NULL ) return; + for( uint i=0; i<16384; i++ ) { - for(j=0; j < 528; j++) fputc(0xFF,fp); - // for(j=0; j < 16; j++) fputc(enc[j],fp); + for( uint j=0; j<528; j++ ) fputc( 0xFF,fp ); + // for(j=0; j<16; j++) fputc(enc[j],fp); } - fclose(fp); + fclose( fp ); } +u64 MemoryCard::GetCRC( uint mcd ) +{ + jASSUME( mcd < 2 ); + + FILE* const mcfp = cardfile[mcd]; + if( mcfp == NULL ) return 0; + + Seek( mcfp, 0 ); + + u64 retval = 0; + for( uint i=MC2_SIZE/sizeof(u64); i; --i ) + { + u64 temp; fread( &temp, sizeof(temp), 1, mcfp ); + retval ^= temp; + } + + return retval; +} \ No newline at end of file diff --git a/pcsx2/MemoryCard.h b/pcsx2/MemoryCard.h index 5a54a541c6..2569c0c50e 100644 --- a/pcsx2/MemoryCard.h +++ b/pcsx2/MemoryCard.h @@ -22,15 +22,26 @@ static const int MCD_SIZE = 1024 * 8 * 16; static const int MC2_SIZE = 1024 * 528 * 16; -extern void MemoryCard_Init(); -extern void MemoryCard_Shutdown(); +class MemoryCard +{ +protected: + static FILE* cardfile[2]; -extern bool TestMcdIsPresent(int mcd); -extern FILE *LoadMcd(int mcd); -extern void ReadMcd(int mcd, u8 *data, u32 adr, int size); -extern void SaveMcd(int mcd, const u8 *data, u32 adr, int size); -extern void EraseMcd(int mcd, u32 adr); -extern void CreateMcd(const char *mcd); + static FILE* Load( uint mcdId ); + static void Seek( FILE* mcdfp, u32 adr ); + static void Create( const char *mcd ); + +public: + static void Init(); + static void Shutdown(); + static bool IsPresent( uint mcdId ); + static void Read( uint mcdId, u8 *data, u32 adr, int size ); + static void Save( uint mcdId, const u8 *data, u32 adr, int size ); + static void Erase( uint mcdId, u32 adr ); + + static bool HasChanged( uint mcdId ); + static u64 GetCRC( uint mcdId ); +}; #if 0 // unused code? struct McdBlock diff --git a/pcsx2/Misc.h b/pcsx2/Misc.h index 7fa0fe8cbc..34e595abde 100644 --- a/pcsx2/Misc.h +++ b/pcsx2/Misc.h @@ -85,6 +85,7 @@ extern SessionOverrideFlags g_Session; #define CHECK_EE_CYCLERATE (Config.Hacks & 0x03) #define CHECK_IOP_CYCLERATE (Config.Hacks & (1<<3)) #define CHECK_WAITCYCLE_HACK (Config.Hacks & (1<<4)) +#define CHECK_INTC_STAT_HACK (Config.Hacks & (1<<5)) #define CHECK_ESCAPE_HACK (Config.Hacks & 0x400) //------------ SPECIAL GAME FIXES!!! --------------- #define CHECK_VUADDSUBHACK (Config.GameFixes & 0x1) // Special Fix for Tri-ace games, they use an encryption algorithm that requires VU addi opcode to be bit-accurate. @@ -110,9 +111,21 @@ extern SessionOverrideFlags g_Session; #define CHECK_VU0REC (!g_Session.ForceDisableVU0rec && Config.Options&PCSX2_VU0REC) #define CHECK_VU1REC (!g_Session.ForceDisableVU1rec && (Config.Options&PCSX2_VU1REC)) +// Memory Card configuration, per slot. +struct McdConfig +{ + // filename of the memory card for this slot. + // If the string is empty characters long then the default is used. + char Filename[g_MaxPath]; + + // Enables the memory card at the emulation level. When false, games will treat this + // slot as if the memory card has been physically removed from the PS2. + bool Enabled; +}; struct PcsxConfig { +public: char Bios[g_MaxPath]; char GS[g_MaxPath]; char PAD1[g_MaxPath]; @@ -122,12 +135,15 @@ struct PcsxConfig char DEV9[g_MaxPath]; char USB[g_MaxPath]; char FW[g_MaxPath]; - char Mcd1[g_MaxPath]; - char Mcd2[g_MaxPath]; char PluginsDir[g_MaxPath]; char BiosDir[g_MaxPath]; char Lang[g_MaxPath]; + McdConfig Mcd[2]; + + bool McdEnableNTFS; // enables NTFS compression on cards and the mcd folder. + bool McdEnableEject; // enables auto-ejection of cards after loading savestates. + u32 Options; // PCSX2_X options bool PsxOut; diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index eb021b1ddc..df5fa8c51e 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -39,8 +39,6 @@ extern int g_psxWriteOk; extern void recResetEE(); extern void recResetIOP(); -// STATES - static void PreLoadPrep() { SysResetExecutionState(); diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index 8edd4e5307..0bbe9436ac 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -29,7 +29,7 @@ // Savestate Versioning! // If you make changes to the savestate version, please increment the value below. -static const u32 g_SaveVersion = 0x8b400002; +static const u32 g_SaveVersion = 0x8b400003; // this function is meant to be sued in the place of GSfreeze, and provides a safe layer // between the GS saving function and the MTGS's needs. :) diff --git a/pcsx2/Sio.cpp b/pcsx2/Sio.cpp index 69c7e4f82a..a35b6bc041 100644 --- a/pcsx2/Sio.cpp +++ b/pcsx2/Sio.cpp @@ -46,15 +46,15 @@ __forceinline void SIO_INT() #endif static void _ReadMcd(u8 *data, u32 adr, int size) { - ReadMcd(sio.GetMemcardIndex(), data, adr, size); + MemoryCard::Read(sio.GetMemcardIndex(), data, adr, size); } static void _SaveMcd(const u8 *data, u32 adr, int size) { - SaveMcd(sio.GetMemcardIndex(), data, adr, size); + MemoryCard::Save(sio.GetMemcardIndex(), data, adr, size); } static void _EraseMCDBlock(u32 adr) { - EraseMcd(sio.GetMemcardIndex(), adr); + MemoryCard::Erase(sio.GetMemcardIndex(), adr); } u8 sio_xor(u8 *buf, uint length){ @@ -74,12 +74,12 @@ void sioInit() sio.packetsize = 0; sio.terminator =0x55; // Command terminator 'U' - MemoryCard_Init(); + MemoryCard::Init(); } void psxSIOShutdown() { - MemoryCard_Shutdown(); + MemoryCard::Shutdown(); } u8 sioRead8() { @@ -506,13 +506,13 @@ void InitializeSIO(u8 value) { m_PostSavestateCards[mcidx]--; sio2.packet.recvVal1 = 0x1D100; - PAD_LOG( "START MEMCARD[%d] - post-savestate - reported as missing!\n", sio.GetMemcardIndex() ); + PAD_LOG( "START MEMCARD[%d] - post-savestate ejection - reported as missing!\n", sio.GetMemcardIndex() ); } else { - sio2.packet.recvVal1 = TestMcdIsPresent( sio.GetMemcardIndex() ) ? 0x1100 : 0x1D100; + sio2.packet.recvVal1 = MemoryCard::IsPresent( sio.GetMemcardIndex() ) ? 0x1100 : 0x1D100; PAD_LOG("START MEMCARD [%d] - %s\n", - sio.GetMemcardIndex(), TestMcdIsPresent( sio.GetMemcardIndex() ) ? "Present" : "Missing" ); + sio.GetMemcardIndex(), MemoryCard::IsPresent( sio.GetMemcardIndex() ) ? "Present" : "Missing" ); } SIO_INT(); @@ -548,18 +548,59 @@ void SIO_FORCEINLINE sioInterrupt() { psxHu32(0x1070)|=0x80; } +// Signals the sio to eject the specified memory card. +// Called from the memory card configuration when a user changes memory cards. +void sioEjectCard( uint mcdId ) +{ + jASSUME( mcdId < 2 ); + m_PostSavestateCards[mcdId] = 64; +} + void SaveState::sioFreeze() { + // CRCs for memory cards. + u64 m_mcdCRCs[2]; + Freeze( sio ); - if( IsLoading() ) + // versions prior to 13 didn't have CRCs. + if( GetVersion() >= 0x13 ) + { + if( IsSaving() ) + { + for( int i=0; i<2; ++i ) + m_mcdCRCs[i] = MemoryCard::GetCRC( i ); + } + Freeze( m_mcdCRCs ); + } + else + { + m_mcdCRCs[0] = m_mcdCRCs[1] = 0; + } + + if( IsLoading() && Config.McdEnableEject ) { // Note: TOTA works with values as low as 20 here. // It "times out" with values around 1800 (forces user to check the memcard // twice to find it). Other games could be different. :| + + // At 64: Disgaea 1 and 2, and Grandia 2 end up displaying a quick "no memcard!" + // notice before finding the memorycard and re-enumerating it. A very minor + // annoyance, but no breakages. + + // GuitarHero will break completely with almost any value here, by design, because + // it has a "rule" that the memcard should never be ejected during a song. So by + // ejecting it, the game freezes (which is actually good emulation, but annoying!) - m_PostSavestateCards[0] = 64; - m_PostSavestateCards[1] = 64; + for( int i=0; i<2; ++i ) + { + uint newCRC = MemoryCard::GetCRC( i ); + if( newCRC != m_mcdCRCs[i] ) + { + m_PostSavestateCards[i] = 64; + m_mcdCRCs[i] = newCRC; + } + } } } diff --git a/pcsx2/Sio.h b/pcsx2/Sio.h index ddf2ed79b9..18fff308b5 100644 --- a/pcsx2/Sio.h +++ b/pcsx2/Sio.h @@ -98,6 +98,7 @@ extern void sioWrite8(u8 value); extern void sioWriteCtrl16(u16 value); extern void sioInterrupt(); extern void InitializeSIO(u8 value); +extern void sioEjectCard( uint mcdId ); #ifdef _MSC_VER #pragma pack(1) diff --git a/pcsx2/windows/HacksDlg.cpp b/pcsx2/windows/HacksDlg.cpp index 3bc5d67671..fd83f89288 100644 --- a/pcsx2/windows/HacksDlg.cpp +++ b/pcsx2/windows/HacksDlg.cpp @@ -29,6 +29,7 @@ BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if(CHECK_IOP_CYCLERATE) CheckDlgButton(hDlg, IDC_IOPSYNC, TRUE); if(CHECK_WAITCYCLE_HACK) CheckDlgButton(hDlg, IDC_WAITCYCLES, TRUE); + if(CHECK_INTC_STAT_HACK) CheckDlgButton(hDlg, IDC_INTCSTATHACK, TRUE); if(CHECK_ESCAPE_HACK) CheckDlgButton(hDlg, IDC_ESCHACK, TRUE); return TRUE; @@ -50,6 +51,7 @@ BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) newhacks |= IsDlgButtonChecked(hDlg, IDC_IOPSYNC) << 3; newhacks |= IsDlgButtonChecked(hDlg, IDC_WAITCYCLES) << 4; + newhacks |= IsDlgButtonChecked(hDlg, IDC_INTCSTATHACK) << 5; newhacks |= IsDlgButtonChecked(hDlg, IDC_ESCHACK) << 10; EndDialog(hDlg, TRUE); diff --git a/pcsx2/windows/McdConfigDlg.cpp b/pcsx2/windows/McdConfigDlg.cpp new file mode 100644 index 0000000000..f1cd218d02 --- /dev/null +++ b/pcsx2/windows/McdConfigDlg.cpp @@ -0,0 +1,224 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 Pcsx2 Team + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "PrecompiledHeader.h" +#include "Win32.h" + +#include +#include +#include "libintlmsc.h" + +#include "System.h" +#include "McdsDlg.h" + +#include "Sio.h" + +HWND mcdDlg; + +#define SET_CHECK(idc,value) SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,((value)==0)?BST_UNCHECKED:BST_CHECKED,0) +#define ENABLE_CONTROL(idc,value) EnableWindow(GetDlgItem(hWnd,idc),value) + +#define HANDLE_CHECK(idc,hvar) case idc: (hvar) = !(hvar); SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,(hvar)?BST_CHECKED:BST_UNCHECKED,0); break +#define HANDLE_CHECKNB(idc,hvar) case idc: (hvar) = !(hvar); SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,(hvar)?BST_CHECKED:BST_UNCHECKED,0) + +void DlgItem_GetText( HWND hwnd, int dlgId, string& dest ) +{ + HWND dlg = GetDlgItem( hwnd, dlgId ); + int length = GetWindowTextLength( dlg ); + + if( length <= 0 ) + { + dest.clear(); + return; + } + + char* outstr = new char[length+2]; + if( outstr != NULL ) + { + GetWindowText( dlg, outstr, length+1 ); + dest = outstr; + safe_delete_array( outstr ); + } +} + + +void MemcardConfig::Open_Mcd_Proc(HWND hW, int mcd) +{ + OPENFILENAME ofn; + char szFileName[256]; + char szFileTitle[256]; + char szFilter[1024]; + char *str; + + memzero_obj( szFileName ); + memzero_obj( szFileTitle ); + memzero_obj( szFilter ); + + strcpy(szFilter, _("Ps2 Memory Card (*.ps2)")); + str = szFilter + strlen(szFilter) + 1; + strcpy(str, "*.ps2"); + + str += strlen(str) + 1; + strcpy(str, _("All Files")); + str += strlen(str) + 1; + strcpy(str, "*.*"); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hW; + ofn.lpstrFilter = szFilter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 1; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = 256; + ofn.lpstrInitialDir = MEMCARDS_DIR; + ofn.lpstrFileTitle = szFileTitle; + ofn.nMaxFileTitle = 256; + ofn.lpstrTitle = NULL; + ofn.lpstrDefExt = "PS2"; + ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER; + + if (GetOpenFileName ((LPOPENFILENAME)&ofn)) + Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD_FILE1 : IDC_MCD_FILE2), szFileName); +} + +BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + + mcdDlg = hWnd; + SetWindowText(hWnd, _("MemoryCard Config - Pcsx2")); + + Button_SetText(GetDlgItem(hWnd, IDOK), _("OK")); + Button_SetText(GetDlgItem(hWnd, IDCANCEL), _("Cancel")); + + Button_SetText(GetDlgItem(hWnd, IDC_MCDSEL1), _("Browse...")); + Button_SetText(GetDlgItem(hWnd, IDC_MCDSEL2), _("Browse...")); + + Static_SetText(GetDlgItem(hWnd, IDC_MCD_ENABLE1), _("Memory Card Slot 1")); + Static_SetText(GetDlgItem(hWnd, IDC_MCD_ENABLE2), _("Memory Card Slot 2")); + + if( Config.Mcd[0].Filename[0] == 0 ) strcpy( Config.Mcd[0].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 ); + if( Config.Mcd[1].Filename[1] == 0 ) strcpy( Config.Mcd[1].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 ); + + Edit_SetText(GetDlgItem(hWnd,IDC_MCD_FILE1), Config.Mcd[0].Filename); + Edit_SetText(GetDlgItem(hWnd,IDC_MCD_FILE2), Config.Mcd[1].Filename); + + SET_CHECK( IDC_MCD_ENABLE1, Config.Mcd[0].Enabled ); + SET_CHECK( IDC_MCD_ENABLE2, Config.Mcd[1].Enabled ); + + SET_CHECK( IDC_NTFS_ENABLE, Config.McdEnableNTFS ); + SET_CHECK( IDC_MCD_EJECT_ENABLE, Config.McdEnableEject ); + + break; + + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + int wmEvent = HIWORD(wParam); + + switch (LOWORD(wmId)) + { + case IDC_MCD_BROWSE1: + Open_Mcd_Proc(hWnd, 1); + return TRUE; + + case IDC_MCD_BROWSE2: + Open_Mcd_Proc(hWnd, 2); + return TRUE; + + case IDCANCEL: + EndDialog(hWnd,FALSE); + return TRUE; + + case IDOK: + { + //DlgItem_GetText( hWnd, IDC_MCD_FILE1, Config.Mcd[0].Filename ); + //DlgItem_GetText( hWnd, IDC_MCD_FILE2, Config.Mcd[1].Filename ); + + string oldone( Config.Mcd[0].Filename ), oldtwo( Config.Mcd[1].Filename ); + + GetWindowText( GetDlgItem( hWnd, IDC_MCD_FILE1 ), Config.Mcd[0].Filename, g_MaxPath ); + GetWindowText( GetDlgItem( hWnd, IDC_MCD_FILE2 ), Config.Mcd[1].Filename, g_MaxPath ); + + if( g_EmulationInProgress ) + { + if( !Config.Mcd[0].Enabled || oldone != Config.Mcd[0].Filename ) + sioEjectCard( 0 ); + + if( !Config.Mcd[1].Enabled || oldtwo != Config.Mcd[1].Filename ) + sioEjectCard( 1 ); + } + + IniFileSaver().MemcardSettings( Config ); + EndDialog( hWnd, TRUE ); + } + return TRUE; + + HANDLE_CHECKNB( IDC_MCD_ENABLE1, Config.Mcd[0].Enabled ); + ENABLE_CONTROL( IDC_MCD_BROWSE1, Config.Mcd[0].Enabled ); + ENABLE_CONTROL( IDC_MCD_FILE1, Config.Mcd[0].Enabled ); + ENABLE_CONTROL( IDC_MCD_LABEL1, Config.Mcd[0].Enabled ); + break; + + HANDLE_CHECKNB( IDC_MCD_ENABLE2, Config.Mcd[1].Enabled ); + ENABLE_CONTROL( IDC_MCD_BROWSE2, Config.Mcd[1].Enabled ); + ENABLE_CONTROL( IDC_MCD_FILE2, Config.Mcd[1].Enabled ); + ENABLE_CONTROL( IDC_MCD_LABEL2, Config.Mcd[1].Enabled ); + break; + + HANDLE_CHECK( IDC_NTFS_ENABLE, Config.McdEnableNTFS ); + HANDLE_CHECK( IDC_MCD_EJECT_ENABLE, Config.McdEnableEject ); + + default: + return FALSE; + } + } + break; + + default: + return FALSE; + } + return TRUE; +} + +// Both loads and saves as a single unified settings function! :D +void IniFile::MemcardSettings( PcsxConfig& conf ) +{ + SetCurrentSection( "Memorycards" ); + + Entry( "Slot1_Path", conf.Mcd[0].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 ); + Entry( "Slot2_Path", conf.Mcd[1].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 ); + + Entry( "Slot1_Enabled", conf.Mcd[0].Enabled, true ); + Entry( "Slot2_Enabled", conf.Mcd[1].Enabled, true ); + + Entry( "EnableNTFS", conf.McdEnableNTFS, true ); + Entry( "EnableEjection", conf.McdEnableEject, true ); +} + +// Creates the MemoryCard configuration dialog box +void MemcardConfig::OpenDialog() +{ + DialogBox( gApp.hInstance, MAKEINTRESOURCE(IDD_CONF_MEMCARD), gApp.hWnd, (DLGPROC)DialogProc ); + + // Re-loads old config if the user canceled. + IniFileLoader().MemcardSettings( Config ); +} \ No newline at end of file diff --git a/pcsx2/windows/McdsDlg.cpp b/pcsx2/windows/McdManagerDlg.cpp similarity index 100% rename from pcsx2/windows/McdsDlg.cpp rename to pcsx2/windows/McdManagerDlg.cpp diff --git a/pcsx2/windows/McdsDlg.c b/pcsx2/windows/McdsDlg.c deleted file mode 100644 index 5ebcb4c483..0000000000 --- a/pcsx2/windows/McdsDlg.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Pcsx2 - Pc Ps2 Emulator - * Copyright (C) 2002-2008 Pcsx2 Team - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include - -#include "Common.h" -#include "PsxCommon.h" -#include "plugins.h" -#include "resource.h" -#include "Win32.h" - -#include "Paths.h" - - -HWND mcdDlg; - - -void Open_Mcd_Proc(HWND hW, int mcd) { - OPENFILENAME ofn; - char szFileName[256]; - char szFileTitle[256]; - char szFilter[1024]; - char *str; - - memset(szFileName, 0, sizeof(szFileName)); - memset(szFileTitle, 0, sizeof(szFileTitle)); - memset(szFilter, 0, sizeof(szFilter)); - - - strcpy(szFilter, _("Ps2 Memory Card (*.ps2)")); - str = szFilter + strlen(szFilter) + 1; - strcpy(str, "*.ps2"); - - str+= strlen(str) + 1; - strcpy(str, _("All Files")); - str+= strlen(str) + 1; - strcpy(str, "*.*"); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hW; - ofn.lpstrFilter = szFilter; - ofn.lpstrCustomFilter = NULL; - ofn.nMaxCustFilter = 0; - ofn.nFilterIndex = 1; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = 256; - ofn.lpstrInitialDir = MEMCARDS_DIR; - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = 256; - ofn.lpstrTitle = NULL; - ofn.lpstrDefExt = "MC2"; - ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR; - - if (GetOpenFileName ((LPOPENFILENAME)&ofn)) { - Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD1 : IDC_MCD2), szFileName); - } -} - -BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { - case WM_INITDIALOG: - mcdDlg = hW; - - SetWindowText(hW, _("Memcard Manager")); - - Button_SetText(GetDlgItem(hW, IDOK), _("OK")); - Button_SetText(GetDlgItem(hW, IDCANCEL), _("Cancel")); - Button_SetText(GetDlgItem(hW, IDC_MCDSEL1), _("Select Mcd")); - Button_SetText(GetDlgItem(hW, IDC_MCDSEL2), _("Select Mcd")); - - Static_SetText(GetDlgItem(hW, IDC_FRAMEMCD1), _("Memory Card 1")); - Static_SetText(GetDlgItem(hW, IDC_FRAMEMCD2), _("Memory Card 2")); - - if (!strlen(Config.Mcd1)) strcpy(Config.Mcd1, "memcards\\Mcd001.ps2"); - if (!strlen(Config.Mcd2)) strcpy(Config.Mcd2, "memcards\\Mcd002.ps2"); - Edit_SetText(GetDlgItem(hW,IDC_MCD1), Config.Mcd1); - Edit_SetText(GetDlgItem(hW,IDC_MCD2), Config.Mcd2); - - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_MCDSEL1: - Open_Mcd_Proc(hW, 1); - return TRUE; - case IDC_MCDSEL2: - Open_Mcd_Proc(hW, 2); - return TRUE; - case IDCANCEL: - EndDialog(hW,FALSE); - - return TRUE; - case IDOK: - Edit_GetText(GetDlgItem(hW,IDC_MCD1), Config.Mcd1, 256); - Edit_GetText(GetDlgItem(hW,IDC_MCD2), Config.Mcd2, 256); - - SaveConfig(); - - EndDialog(hW,TRUE); - - return TRUE; - } - case WM_DESTROY: - return TRUE; - } - return FALSE; -} - diff --git a/pcsx2/windows/McdsDlg.h b/pcsx2/windows/McdsDlg.h index fa323a5da2..dc1ba09c12 100644 --- a/pcsx2/windows/McdsDlg.h +++ b/pcsx2/windows/McdsDlg.h @@ -19,6 +19,19 @@ #ifndef __MCDSDLG_H__ #define __MCDSDLG_H__ -BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam); +// Old school memcard manager that never got finished/working :( +//BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam); -#endif /* __MCDSDLG_H__ */ +class MemcardConfig +{ +protected: + static void Open_Mcd_Proc(HWND hW, int mcd); + static BOOL CALLBACK DialogProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam); + +public: + static void OpenDialog(); + static void LoadSettings(); +}; + + +#endif diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index 2a6db861a3..221357d797 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -301,9 +301,37 @@ > + + + + + + + + + + + diff --git a/pcsx2/windows/Win32.h b/pcsx2/windows/Win32.h index 91ceb6039d..1213debe2b 100644 --- a/pcsx2/windows/Win32.h +++ b/pcsx2/windows/Win32.h @@ -53,6 +53,61 @@ struct AppData HMENU hMenu; // Main window menu }; +class IniFile +{ +protected: + string m_filename; + string m_section; + +public: + virtual ~IniFile(); + IniFile(); + + void SetCurrentSection( const string& newsection ); + + virtual void Entry( const string& var, string& value, const string& defvalue=string() )=0; + virtual void Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue=string() )=0; + virtual void Entry( const string& var, int& value, const int defvalue=0 )=0; + virtual void Entry( const string& var, uint& value, const uint defvalue=0 )=0; + virtual void Entry( const string& var, bool& value, const bool defvalue=0 )=0; + virtual void EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue=0 )=0; + + void DoConfig( PcsxConfig& Conf ); + void MemcardSettings( PcsxConfig& Conf ); +}; + +class IniFileLoader : public IniFile +{ +protected: + SafeArray m_workspace; + +public: + virtual ~IniFileLoader(); + IniFileLoader(); + + void Entry( const string& var, string& value, const string& defvalue=string() ); + void Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue=string() ); + void Entry( const string& var, int& value, const int defvalue=0 ); + void Entry( const string& var, uint& value, const uint defvalue=0 ); + void Entry( const string& var, bool& value, const bool defvalue=false ); + void EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue=0 ); +}; + +class IniFileSaver : public IniFile +{ +public: + virtual ~IniFileSaver(); + IniFileSaver(); + + void Entry( const string& var, const string& value, const string& defvalue=string() ); + void Entry( const string& var, string& value, const string& defvalue=string() ); + void Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue=string() ); + void Entry( const string& var, int& value, const int defvalue=0 ); + void Entry( const string& var, uint& value, const uint defvalue=0 ); + void Entry( const string& var, bool& value, const bool defvalue=false ); + void EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue=0 ); +}; + LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); void CreateMainWindow(int nCmdShow); void RunGui(); @@ -112,9 +167,10 @@ extern void StreamException_ThrowFromErrno( const string& streamname, errno_t er extern bool StreamException_LogFromErrno( const string& streamname, const char* action, errno_t result ); extern bool StreamException_LogLastError( const string& streamname, const char* action, HANDLE result=INVALID_HANDLE_VALUE ); -// Sets the NTFS compression flag for a directory or file. -// This function does not operate recursively. If the given directory -extern void NTFS_CompressFile( const char* file ); +// Sets the NTFS compression flag for a directory or file. This function does not operate +// recursively. Set compressStatus to false to decompress compressed files (and do nothing +// to already decompressed files). +extern void NTFS_CompressFile( const char* file, bool compressStatus=true ); #endif diff --git a/pcsx2/windows/WinCompressNTFS.cpp b/pcsx2/windows/WinCompressNTFS.cpp index 997ed40db4..4e6b60d86d 100644 --- a/pcsx2/windows/WinCompressNTFS.cpp +++ b/pcsx2/windows/WinCompressNTFS.cpp @@ -97,7 +97,7 @@ bool StreamException_LogLastError( const string& streamname, const char* action, } // Exceptions thrown: None. Errors are logged to console. Failures are considered non-critical -void NTFS_CompressFile( const char* file ) +void NTFS_CompressFile( const char* file, bool compressStatus ) { bool isFile = Path::isFile( file ); @@ -117,7 +117,7 @@ void NTFS_CompressFile( const char* file ) if( !StreamException_LogLastError( file, "NTFS Compression Enable", bloated_crap ) ) { DWORD bytesReturned = 0; - DWORD compressMode = COMPRESSION_FORMAT_DEFAULT; + DWORD compressMode = compressStatus ? COMPRESSION_FORMAT_DEFAULT : COMPRESSION_FORMAT_NONE; BOOL result = DeviceIoControl( bloated_crap, FSCTL_SET_COMPRESSION, diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index 61786027a3..114f3bb803 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -766,9 +766,9 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return FALSE; case ID_CONFIG_MEMCARDS: - DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_MCDCONF), hWnd, (DLGPROC)ConfigureMcdsDlgProc); - SaveConfig(); + MemcardConfig::OpenDialog(); return FALSE; + case ID_PROCESSLOW: Config.ThPriority = THREAD_PRIORITY_LOWEST; SaveConfig(); @@ -776,6 +776,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(gApp.hMenu,ID_PROCESSNORMAL,MF_UNCHECKED); CheckMenuItem(gApp.hMenu,ID_PROCESSHIGH,MF_UNCHECKED); return FALSE; + case ID_PROCESSNORMAL: Config.ThPriority = THREAD_PRIORITY_NORMAL; SaveConfig(); @@ -783,6 +784,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(gApp.hMenu,ID_PROCESSLOW,MF_UNCHECKED); CheckMenuItem(gApp.hMenu,ID_PROCESSHIGH,MF_UNCHECKED); return FALSE; + case ID_PROCESSHIGH: Config.ThPriority = THREAD_PRIORITY_HIGHEST; SaveConfig(); diff --git a/pcsx2/windows/WinSysExec.cpp b/pcsx2/windows/WinSysExec.cpp index f4fa1461fb..75ef25234c 100644 --- a/pcsx2/windows/WinSysExec.cpp +++ b/pcsx2/windows/WinSysExec.cpp @@ -760,7 +760,7 @@ bool SysInit() // Set the compression attribute on the Memcards folder. // Memcards generally compress very well via NTFS compression. - NTFS_CompressFile( MEMCARDS_DIR ); + NTFS_CompressFile( MEMCARDS_DIR, Config.McdEnableNTFS ); if( IsDevBuild && emuLog == NULL && g_TestRun.plogname != NULL ) emuLog = fopen(g_TestRun.plogname, "w"); diff --git a/pcsx2/windows/ini.cpp b/pcsx2/windows/ini.cpp index 1cf1ac6419..9f7948c7af 100644 --- a/pcsx2/windows/ini.cpp +++ b/pcsx2/windows/ini.cpp @@ -22,7 +22,7 @@ #include "Common.h" #include "Paths.h" -static const u32 IniVersion = 100; +static const u32 IniVersion = 101; const char* g_CustomConfigFile; char g_WorkingFolder[g_MaxPath]; // Working folder at application startup @@ -53,210 +53,193 @@ static void GetConfigFilename( string& dest ) } } -class IniFile +////////////////////////////////////////////////////////////////////////////////////////// +// InitFileLoader + +IniFileLoader::~IniFileLoader() {} +IniFileLoader::IniFileLoader() : IniFile(), + m_workspace( 4096, "IniFileLoader Workspace" ) { -protected: - string m_filename; - string m_section; +} -public: - virtual ~IniFile() {} - IniFile() : m_filename(), m_section("Misc") +void IniFileLoader::Entry( const string& var, string& value, const string& defvalue ) +{ + int retval = GetPrivateProfileString( + m_section.c_str(), var.c_str(), defvalue.c_str(), m_workspace.GetPtr(), m_workspace.GetLength(), m_filename.c_str() + ); + + if( retval >= m_workspace.GetLength() - 2 ) + Console::Notice( "Loadini Warning > Possible truncated value on key '%hs'", params &var ); + //Console::WriteLn( "WTF!! %s ", params m_workspace.GetPtr() ); + value = m_workspace.GetPtr(); +} + +void IniFileLoader::Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue ) +{ + int retval = GetPrivateProfileString( + m_section.c_str(), var.c_str(), defvalue.c_str(), value, sizeof( value ), m_filename.c_str() + ); + + if( retval >= sizeof(value) - 2 ) + Console::Notice( "Loadini Warning > Possible truncated value on key '%hs'", params &var ); +} + +void IniFileLoader::Entry( const string& var, int& value, const int defvalue ) +{ + string retval; + Entry( var, retval, to_string( defvalue ) ); + value = atoi( retval.c_str() ); +} + +void IniFileLoader::Entry( const string& var, uint& value, const uint defvalue ) +{ + string retval; + Entry( var, retval, to_string( defvalue ) ); + value = atoi( retval.c_str() ); +} + +void IniFileLoader::Entry( const string& var, bool& value, const bool defvalue ) +{ + string retval; + Entry( var, retval, defvalue ? "enabled" : "disabled" ); + value = (retval == "enabled"); +} + +void IniFileLoader::EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue ) +{ + string retval; + Entry( var, retval, enumArray[defvalue] ); + + int i=0; + while( enumArray[i] != NULL && ( retval != enumArray[i] ) ) i++; + + if( enumArray[i] == NULL ) { - GetConfigFilename( m_filename ); + Console::Notice( "Loadini Warning > Unrecognized value '%hs' on key '%hs'\n\tUsing the default setting of '%s'.", + params &retval, &var, enumArray[defvalue] ); + value = defvalue; } + else + value = i; +} - void SetCurrentSection( const string& newsection ) - { - m_section = newsection; - } +////////////////////////////////////////////////////////////////////////////////////////// +// InitFileSaver - virtual void Entry( const string& var, string& value, const string& defvalue=string() )=0; - virtual void Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue=string() )=0; - virtual void Entry( const string& var, int& value, const int defvalue=0 )=0; - virtual void Entry( const string& var, uint& value, const uint defvalue=0 )=0; - virtual void Entry( const string& var, bool& value, const bool defvalue=0 )=0; - virtual void EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue=0 )=0; +IniFileSaver::~IniFileSaver() {} - void DoConfig( PcsxConfig& Conf ) - { - SetCurrentSection( "Misc" ); +IniFileSaver::IniFileSaver() : IniFile() +{ + char versionStr[20]; + _itoa( IniVersion, versionStr, 10 ); + WritePrivateProfileString( "Misc", "IniVersion", versionStr, m_filename.c_str() ); +} - Entry( "Patching", Conf.Patch, false ); - Entry( "GameFixes", Conf.GameFixes); +void IniFileSaver::Entry( const string& var, const string& value, const string& defvalue ) +{ + WritePrivateProfileString( m_section.c_str(), var.c_str(), value.c_str(), m_filename.c_str() ); +} + +void IniFileSaver::Entry( const string& var, string& value, const string& defvalue ) +{ + WritePrivateProfileString( m_section.c_str(), var.c_str(), value.c_str(), m_filename.c_str() ); +} + +void IniFileSaver::Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue ) +{ + WritePrivateProfileString( m_section.c_str(), var.c_str(), value, m_filename.c_str() ); +} + +void IniFileSaver::Entry( const string& var, int& value, const int defvalue ) +{ + Entry( var, to_string( value ) ); +} + +void IniFileSaver::Entry( const string& var, uint& value, const uint defvalue ) +{ + Entry( var, to_string( value ) ); +} + +void IniFileSaver::Entry( const string& var, bool& value, const bool defvalue ) +{ + Entry( var, value ? "enabled" : "disabled" ); +} + +void IniFileSaver::EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue ) +{ + Entry( var, enumArray[value] ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// InitFile -- Base class implementation. + +IniFile::~IniFile() {} +IniFile::IniFile() : m_filename(), m_section("Misc") +{ + GetConfigFilename( m_filename ); +} + +void IniFile::SetCurrentSection( const string& newsection ) +{ + m_section = newsection; +} + +void IniFile::DoConfig( PcsxConfig& Conf ) +{ + SetCurrentSection( "Misc" ); + + Entry( "Patching", Conf.Patch, false ); + Entry( "GameFixes", Conf.GameFixes); #ifdef PCSX2_DEVBUILD - Entry( "DevLogFlags", varLog ); + Entry( "DevLogFlags", varLog ); #endif - //interface - SetCurrentSection( "Interface" ); - Entry( "Bios", Conf.Bios ); - Entry( "Language", Conf.Lang ); - Entry( "PluginsDir", Conf.PluginsDir, DEFAULT_PLUGINS_DIR ); - Entry( "BiosDir", Conf.BiosDir, DEFAULT_BIOS_DIR ); - Entry( "CloseGsOnEscape", Conf.closeGSonEsc, true ); + //interface + SetCurrentSection( "Interface" ); + Entry( "Bios", Conf.Bios ); + Entry( "Language", Conf.Lang ); + Entry( "PluginsDir", Conf.PluginsDir, DEFAULT_PLUGINS_DIR ); + Entry( "BiosDir", Conf.BiosDir, DEFAULT_BIOS_DIR ); + Entry( "CloseGsOnEscape", Conf.closeGSonEsc, true ); - SetCurrentSection( "Console" ); - Entry( "ConsoleWindow", Conf.PsxOut, true ); - Entry( "Profiler", Conf.Profiler, false ); - Entry( "CdvdVerbose", Conf.cdvdPrint, false ); + SetCurrentSection( "Console" ); + Entry( "ConsoleWindow", Conf.PsxOut, true ); + Entry( "Profiler", Conf.Profiler, false ); + Entry( "CdvdVerbose", Conf.cdvdPrint, false ); - Entry( "ThreadPriority", Conf.ThPriority, THREAD_PRIORITY_NORMAL ); - Entry( "Memorycard1", Conf.Mcd1, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 ); - Entry( "Memorycard2", Conf.Mcd2, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 ); + Entry( "ThreadPriority", Conf.ThPriority, THREAD_PRIORITY_NORMAL ); - SetCurrentSection( "Framelimiter" ); - Entry( "CustomFps", Conf.CustomFps ); - Entry( "FrameskipMode", Conf.CustomFrameSkip ); - Entry( "ConsecutiveFramesToRender", Conf.CustomConsecutiveFrames ); - Entry( "ConsecutiveFramesToSkip", Conf.CustomConsecutiveSkip ); + SetCurrentSection( "Framelimiter" ); + Entry( "CustomFps", Conf.CustomFps ); + Entry( "FrameskipMode", Conf.CustomFrameSkip ); + Entry( "ConsecutiveFramesToRender", Conf.CustomConsecutiveFrames ); + Entry( "ConsecutiveFramesToSkip", Conf.CustomConsecutiveSkip ); - // Plugins are saved from the winConfig struct. - // It contains the user config settings and not the - // runtime cmdline overrides. + MemcardSettings( Conf ); - SetCurrentSection( "Plugins" ); + SetCurrentSection( "Plugins" ); - Entry( "GS", Conf.GS ); - Entry( "SPU2", Conf.SPU2 ); - Entry( "CDVD", Conf.CDVD ); - Entry( "PAD1", Conf.PAD1 ); - Entry( "PAD2", Conf.PAD2 ); - Entry( "DEV9", Conf.DEV9 ); - Entry( "USB", Conf.USB ); - Entry( "FW", Conf.FW ); + Entry( "GS", Conf.GS ); + Entry( "SPU2", Conf.SPU2 ); + Entry( "CDVD", Conf.CDVD ); + Entry( "PAD1", Conf.PAD1 ); + Entry( "PAD2", Conf.PAD2 ); + Entry( "DEV9", Conf.DEV9 ); + Entry( "USB", Conf.USB ); + Entry( "FW", Conf.FW ); - //cpu - SetCurrentSection( "Cpu" ); - Entry( "Options", Conf.Options, PCSX2_EEREC|PCSX2_VU0REC|PCSX2_VU1REC|PCSX2_GSMULTITHREAD|PCSX2_FRAMELIMIT_LIMIT ); - Entry( "sseMXCSR", Conf.sseMXCSR, DEFAULT_sseMXCSR ); - Entry( "sseVUMXCSR", Conf.sseVUMXCSR, DEFAULT_sseVUMXCSR ); - Entry( "eeOptions", Conf.eeOptions, DEFAULT_eeOptions ); - Entry( "vuOptions", Conf.vuOptions, DEFAULT_vuOptions ); - Entry( "SpeedHacks", Conf.Hacks ); - } -}; + //cpu + SetCurrentSection( "Cpu" ); + Entry( "Options", Conf.Options, PCSX2_EEREC|PCSX2_VU0REC|PCSX2_VU1REC|PCSX2_GSMULTITHREAD|PCSX2_FRAMELIMIT_LIMIT ); + Entry( "sseMXCSR", Conf.sseMXCSR, DEFAULT_sseMXCSR ); + Entry( "sseVUMXCSR", Conf.sseVUMXCSR, DEFAULT_sseVUMXCSR ); + Entry( "eeOptions", Conf.eeOptions, DEFAULT_eeOptions ); + Entry( "vuOptions", Conf.vuOptions, DEFAULT_vuOptions ); + Entry( "SpeedHacks", Conf.Hacks ); +} -class IniFileLoader : public IniFile -{ -protected: - SafeArray m_workspace; - -public: - virtual ~IniFileLoader() {} - IniFileLoader() : IniFile(), - m_workspace( 4096, "IniFileLoader Workspace" ) - { - } - - void Entry( const string& var, string& value, const string& defvalue=string() ) - { - int retval = GetPrivateProfileString( - m_section.c_str(), var.c_str(), defvalue.c_str(), m_workspace.GetPtr(), m_workspace.GetLength(), m_filename.c_str() - ); - - if( retval >= m_workspace.GetLength() - 2 ) - Console::Notice( "Loadini Warning > Possible truncated value on key '%hs'", params &var ); - value = m_workspace.GetPtr(); - } - - void Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue=string() ) - { - int retval = GetPrivateProfileString( - m_section.c_str(), var.c_str(), defvalue.c_str(), value, sizeof( value ), m_filename.c_str() - ); - - if( retval >= sizeof(value) - 2 ) - Console::Notice( "Loadini Warning > Possible truncated value on key '%hs'", params &var ); - } - - void Entry( const string& var, int& value, const int defvalue=0 ) - { - string retval; - Entry( var, retval, to_string( defvalue ) ); - value = atoi( retval.c_str() ); - } - - void Entry( const string& var, uint& value, const uint defvalue=0 ) - { - string retval; - Entry( var, retval, to_string( defvalue ) ); - value = atoi( retval.c_str() ); - } - - void Entry( const string& var, bool& value, const bool defvalue=false ) - { - string retval; - Entry( var, retval, defvalue ? "enabled" : "disabled" ); - value = (retval == "enabled"); - } - - void EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue=0 ) - { - string retval; - Entry( var, retval, enumArray[defvalue] ); - - int i=0; - while( enumArray[i] != NULL && ( retval != enumArray[i] ) ) i++; - - if( enumArray[i] == NULL ) - { - Console::Notice( "Loadini Warning > Unrecognized value '%hs' on key '%hs'\n\tUsing the default setting of '%s'.", - params &retval, &var, enumArray[defvalue] ); - value = defvalue; - } - else - value = i; - } - -}; - -class IniFileSaver : public IniFile -{ -public: - virtual ~IniFileSaver() {} - IniFileSaver() : IniFile() - { - char versionStr[20]; - _itoa( IniVersion, versionStr, 10 ); - WritePrivateProfileString( "Misc", "IniVersion", versionStr, m_filename.c_str() ); - } - - void Entry( const string& var, const string& value, const string& defvalue=string() ) - { - WritePrivateProfileString( m_section.c_str(), var.c_str(), value.c_str(), m_filename.c_str() ); - } - - void Entry( const string& var, string& value, const string& defvalue=string() ) - { - WritePrivateProfileString( m_section.c_str(), var.c_str(), value.c_str(), m_filename.c_str() ); - } - - void Entry( const string& var, char (&value)[g_MaxPath], const string& defvalue=string() ) - { - WritePrivateProfileString( m_section.c_str(), var.c_str(), value, m_filename.c_str() ); - } - - void Entry( const string& var, int& value, const int defvalue=0 ) - { - Entry( var, to_string( value ) ); - } - - void Entry( const string& var, uint& value, const uint defvalue=0 ) - { - Entry( var, to_string( value ) ); - } - - void Entry( const string& var, bool& value, const bool defvalue=false ) - { - Entry( var, value ? "enabled" : "disabled" ); - } - - void EnumEntry( const string& var, int& value, const char* const* enumArray, const int defvalue=0 ) - { - Entry( var, enumArray[value] ); - } -}; +////////////////////////////////////////////////////////////////////////////////////////// +// Public API -- LoadConfig / SaveConfig bool LoadConfig() { diff --git a/pcsx2/windows/pcsx2.rc b/pcsx2/windows/pcsx2.rc index 8b262ab4e2..36d8486a7a 100644 --- a/pcsx2/windows/pcsx2.rc +++ b/pcsx2/windows/pcsx2.rc @@ -8,6 +8,8 @@ // Generated from the TEXTINCLUDE 2 resource. // #include "afxresmw.h" + + ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -938,6 +940,34 @@ BEGIN LTEXT "None - No clamping. (Fastest Mode)\nNormal - Clamps the result.\nExtra - Clamps the operands, the result, and anywhere in between.\nExtra + Preserve Sign - Same as ""Extra"", except preserves NaN's sign when clamping the operands. (Slowest Mode)",IDC_STATIC,286,114,224,45 END +IDD_CONF_MEMCARD DIALOGEX 0, 0, 451, 215 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Memorycard Config - Pcsx2" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + GROUPBOX "",IDC_MCD_GROUP1,6,6,223,49 + GROUPBOX "",IDC_MCD_GROUP2,6,62,223,49 + GROUPBOX "Advanced Options",IDC_STATIC,237,6,206,129 + CONTROL "Memory Card Slot 1",IDC_MCD_ENABLE1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,6,82,11 + EDITTEXT IDC_MCD_FILE1,14,32,160,15,ES_MULTILINE | ES_AUTOHSCROLL + PUSHBUTTON "Browse...",IDC_MCD_BROWSE1,176,32,46,15 + CONTROL "Memory Card Slot 2",IDC_MCD_ENABLE2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,62,82,11 + EDITTEXT IDC_MCD_FILE2,14,88,160,15,ES_AUTOHSCROLL + PUSHBUTTON "Browse...",IDC_MCD_BROWSE2,176,88,46,15 + CONTROL "Enable NTFS Compression",IDC_NTFS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,245,20,119,12 + CONTROL "Eject Mcds when loading SaveStates",IDC_MCD_EJECT_ENABLE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,244,72,154,10 + DEFPUSHBUTTON "OK",IDOK,337,195,50,14 + PUSHBUTTON "Cancel",IDCANCEL,395,195,50,14 + LTEXT "Filename:",IDC_MCD_LABEL1,10,21,150,9 + LTEXT "Filename:",IDC_MCD_LABEL2,10,76,150,9 + LTEXT "Sets the NTFS compression flag on the MCD folder and files. (Recommended!) If unset, files and folders will be returned to normal.",IDC_STATIC,257,35,182,26 + LTEXT "This feature tells games when the mcd contents have changed so that they re-index the new Mcd contents. WARNING: Disabling this option is NOT recommended, and could lead to MemCard corruption if you also use SaveStates.",IDC_STATIC,255,86,184,45 + LTEXT "MemoryCard slots can be enabled or disabled above. Disabling a slot is the same as removing the card from your PS2 in emulation terms.",IDC_STATIC,6,120,224,17 + LTEXT "Remember to make backups of your MemoryCards reguarly. Mcd support in Pcsx is pretty reliable, but not foolproof. Cards could get corrupted.",IDC_STATIC,6,183,224,26 + LTEXT "You can hot-swap memory cards at any time during emulation. Just press escape, open up this dialog box, select a new memory card (or two!), and return to the action. :)",IDC_STATIC,6,147,224,27 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -1011,6 +1041,14 @@ BEGIN HORZGUIDE, 214 HORZGUIDE, 232 END + + IDD_CONF_MEMCARD, DIALOG + BEGIN + LEFTMARGIN, 6 + RIGHTMARGIN, 445 + TOPMARGIN, 6 + BOTTOMMARGIN, 209 + END END #endif // APSTUDIO_INVOKED @@ -1053,7 +1091,7 @@ BEGIN CONTROL 132,IDC_PS2SILVER_RECT,"Static",SS_BITMAP,2,183,70,74 END -IDD_HACKS DIALOGEX 0, 0, 328, 263 +IDD_HACKS DIALOGEX 0, 0, 335, 263 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "PCSX2 Speed Hacks" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -1062,22 +1100,24 @@ BEGIN CONTROL "Use x1.5 Cycle Rate",IDC_EESYNC1,"Button",BS_AUTORADIOBUTTON,13,79,87,10 CONTROL "Use x2 Cycle Rate",IDC_EESYNC2,"Button",BS_AUTORADIOBUTTON,13,113,83,10 CONTROL "Use x3 Cycle Rate",IDC_EESYNC3,"Button",BS_AUTORADIOBUTTON,13,147,80,10 - CONTROL "Enable IOP x2 Cycle Rate",IDC_IOPSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,41,98,10 - CONTROL "WaitCycles Sync Hack",IDC_WAITCYCLES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,82,90,10 + CONTROL "Enable IOP x2 Cycle Rate",IDC_IOPSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,97,98,10 + CONTROL "WaitCycles Sync Hack",IDC_WAITCYCLES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,138,90,10 CONTROL "Escape Hack - Use Esc key to fully exit PCSX2.",IDC_ESCHACK, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,234,180,10 DEFPUSHBUTTON "OK",IDOK,217,242,50,14 - PUSHBUTTON "Cancel",IDCANCEL,271,242,50,14 + PUSHBUTTON "Cancel",IDCANCEL,278,242,50,14 CTEXT "These hacks will speed up emulation but reduce emulation compatibility or cause visual errors. If you have problems, disable all these and try again!",IDC_HACKDESC,18,7,286,19 GROUPBOX "EmotionEngine (EE) Sync Hacks",IDC_STATIC,7,31,159,180 GROUPBOX "Miscellaneous",IDC_STATIC,7,220,194,33 LTEXT "Important: X2 and X3 sync hacks *will* cause choppy/skippy audio on many FMV movies.",IDC_STATIC,13,183,149,25 - LTEXT "Bigger speedup, but causes flickering or missing geometry on many games.",IDC_STATIC,25,158,133,19 + LTEXT "*OBSOLETE* Better off using the INTC Sync Hack instead.",IDC_STATIC,25,158,133,19 LTEXT "Big speedup! Works well with many games.",IDC_STATIC,25,124,125,19 LTEXT "Most compatible option - recommended for everyone with high-end machines.",IDC_STATIC,25,55,136,19 - LTEXT "Small speedup and works well with most games.",IDC_STATIC,186,53,134,22 - LTEXT "Small speedup. Works well with most games, but may cause certain games to crash or freeze up during bootup or stage changes.",IDC_STATIC,186,94,134,39 + LTEXT "Small speedup and works well with most games.",IDC_STATIC,186,109,134,22 + LTEXT "Small speedup. Works well with most games, but may cause certain games to crash or freeze up during bootup or stage changes.",IDC_STATIC,186,150,141,39 LTEXT "Moderate speedup and works well with most games.",IDC_STATIC,25,90,129,19 + CONTROL "INTC Sync Hack (experimental)",IDC_INTCSTATHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,43,127,10 + LTEXT "Huge speedup! And few negative side effects in most games. When enabling this it might be best to leave the EE sync hack set to Default.",IDC_STATIC,186,55,140,36 END @@ -1098,7 +1138,7 @@ BEGIN IDD_HACKS, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 321 + RIGHTMARGIN, 328 VERTGUIDE, 13 TOPMARGIN, 7 BOTTOMMARGIN, 256 @@ -1354,7 +1394,7 @@ END 3 TEXTINCLUDE BEGIN - "\r\0" + "\0" END #endif // APSTUDIO_INVOKED @@ -1692,7 +1732,7 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" + "#include ""afxresmw.h""\r\n" "\0" END @@ -1707,3 +1747,4 @@ END #endif // Greek resources ///////////////////////////////////////////////////////////////////////////// + diff --git a/pcsx2/windows/resource.h b/pcsx2/windows/resource.h index 764d13cc99..1901b44b3c 100644 --- a/pcsx2/windows/resource.h +++ b/pcsx2/windows/resource.h @@ -45,6 +45,7 @@ #define IDD_EDITPATCH 177 #define IDD_ADDRAW 178 #define IDD_PNACHWRITER 179 +#define IDD_CONF_MEMCARD 180 #define IDC_MEM_SCROLL 1001 #define IDC_EXECBP 1001 #define IDC_CNTBP 1002 @@ -587,14 +588,26 @@ #define IDC_VU_ROUNDMODE2 1313 #define IDC_CHECK2 1313 #define IDC_WAITCYCLES 1313 +#define IDC_MCD_ENABLE1 1313 #define IDC_VU_ROUNDMODE3 1314 #define IDC_VU_CLAMPMODE0 1315 +#define IDC_MCD_GROUP1 1315 #define IDC_VU_CLAMPMODE1 1316 +#define IDC_MCD_ENABLE2 1316 #define IDC_VU_CLAMPMODE2 1317 #define IDC_VU_CLAMPMODE3 1318 +#define IDC_NTFS_ENABLE 1318 #define IDC_EE_CLAMPMODE0 1319 +#define IDC_MCD_EJECT_ENABLE 1319 #define IDC_EE_CLAMPMODE1 1320 +#define IDC_MCD_BROWSE1 1320 #define IDC_EE_CLAMPMODE2 1321 +#define IDC_INTCSTATHACK 1326 +#define IDC_MCD_BROWSE2 1321 +#define IDC_MCD_FILE1 1322 +#define IDC_MCD_FILE2 1323 +#define IDC_MCD_LABEL1 1324 +#define IDC_MCD_LABEL2 1325 #define IDC_CPULOG 1500 #define IDC_MEMLOG 1501 #define IDC_HWLOG 1502 @@ -641,6 +654,7 @@ #define IDC_FW 1716 #define IDC_FRAMELIMIT 1716 #define IDC_ADDRESS 1716 +#define IDC_MCD_GROUP2 1716 #define IDC_UNSIGNED 1717 #define IDC_8B 1718 #define IDC_16B 1719 @@ -730,7 +744,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 141 #define _APS_NEXT_COMMAND_VALUE 40018 -#define _APS_NEXT_CONTROL_VALUE 1314 +#define _APS_NEXT_CONTROL_VALUE 1326 #define _APS_NEXT_SYMED_VALUE 104 #endif #endif diff --git a/plugins/spu2-x/src/Win32/ConfigDebug.cpp b/plugins/spu2-x/src/Win32/ConfigDebug.cpp index 5060c6cf20..9650f7ec96 100644 --- a/plugins/spu2-x/src/Win32/ConfigDebug.cpp +++ b/plugins/spu2-x/src/Win32/ConfigDebug.cpp @@ -221,9 +221,8 @@ static BOOL CALLBACK DialogProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) void OpenDialog() { - INT_PTR ret; - ret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_CONFIG_DEBUG),GetActiveWindow(),(DLGPROC)DialogProc,1); - if(ret==-1) + INT_PTR ret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_CONFIG_DEBUG),GetActiveWindow(),(DLGPROC)DialogProc,1); + if(ret == -1) { MessageBoxEx(GetActiveWindow(),_T("Error Opening the debug configuration dialog."),_T("OMG ERROR!"),MB_OK,0); return;