Re-re-fixed the Windows.h mess. PsxCommon.h still had a win32 include, and cdvd.cpp and misc.cpp had some win/linux code which I relocated. Also, cleaned up the vtlb's SysExceptionHandler stuff -- moved the platform-specific portions to WinSysExec and LnxSysExec, and moved the shared code portion to a new function in Memory.cpp.

(Yes, Linux is probably broken again.)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@636 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-03-01 03:30:19 +00:00
parent 0acef23784
commit da25976c6b
34 changed files with 492 additions and 374 deletions

View File

@ -121,7 +121,7 @@ _CRTIMP extern int errno;
#define EILSEQ 42 #define EILSEQ 42
/* /*
* Support EDEADLOCK for compatibiity with older MS-C versions. * Support EDEADLOCK for compatibility with older MS-C versions.
*/ */
#define EDEADLOCK EDEADLK #define EDEADLOCK EDEADLK

View File

@ -19,11 +19,6 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include <ctype.h> #include <ctype.h>
#include <time.h>
#ifndef _WIN32
#include <sys/time.h>
#endif
#include "PsxCommon.h" #include "PsxCommon.h"
#include "CDVDiso.h" #include "CDVDiso.h"
@ -224,11 +219,10 @@ FILE *_cdvdOpenMechaVer() {
char *ptr; char *ptr;
int i; int i;
char file[g_MaxPath]; char file[g_MaxPath];
string Bios;
FILE* fd; FILE* fd;
// get the name of the bios file // get the name of the bios file
Path::Combine( Bios, Config.BiosDir, Config.Bios ); string Bios( Path::Combine( Config.BiosDir, Config.Bios ) );
// use the bios filename to get the name of the mecha ver file // use the bios filename to get the name of the mecha ver file
// [TODO] : Upgrade this to use std::string! // [TODO] : Upgrade this to use std::string!
@ -269,12 +263,11 @@ s32 cdvdGetMechaVer(u8* ver)
FILE *_cdvdOpenNVM() { FILE *_cdvdOpenNVM() {
char *ptr; char *ptr;
int i; int i;
string Bios;
char file[g_MaxPath]; char file[g_MaxPath];
FILE* fd; FILE* fd;
// get the name of the bios file // get the name of the bios file
Path::Combine( Bios, Config.BiosDir, Config.Bios ); string Bios( Path::Combine( Config.BiosDir, Config.Bios ) );
// use the bios filename to get the name of the nvm file // use the bios filename to get the name of the nvm file
// [TODO] : Upgrade this to use std::string! // [TODO] : Upgrade this to use std::string!
@ -743,17 +736,6 @@ static uint cdvdBlockReadTime( CDVD_MODE_TYPE mode )
void cdvdReset() void cdvdReset()
{ {
#ifdef _WIN32
SYSTEMTIME st;
//Get and set the internal clock to time
GetSystemTime(&st);
#else
time_t traw;
struct tm* ptlocal;
time(&traw);
ptlocal = localtime(&traw);
#endif
memzero_obj(cdvd); memzero_obj(cdvd);
cdvd.Type = CDVD_TYPE_NODISC; cdvd.Type = CDVD_TYPE_NODISC;
@ -772,25 +754,6 @@ void cdvdReset()
cdvd.RTC.day = 25; cdvd.RTC.day = 25;
cdvd.RTC.month = 5; cdvd.RTC.month = 5;
cdvd.RTC.year = 7; //2007 cdvd.RTC.year = 7; //2007
#ifndef _DEBUG
#ifdef _WIN32
cdvd.RTC.second = (u8)(st.wSecond);
cdvd.RTC.minute = (u8)(st.wMinute);
cdvd.RTC.hour = (u8)(st.wHour+1)%24;
cdvd.RTC.day = (u8)(st.wDay);
cdvd.RTC.month = (u8)(st.wMonth);
cdvd.RTC.year = (u8)(st.wYear - 2000);
#else
cdvd.RTC.second = ptlocal->tm_sec;
cdvd.RTC.minute = ptlocal->tm_min;
cdvd.RTC.hour = ptlocal->tm_hour;
cdvd.RTC.day = ptlocal->tm_mday;
cdvd.RTC.month = ptlocal->tm_mon;
cdvd.RTC.year = ptlocal->tm_year;
#endif
#endif
} }
struct Freeze_v10Compat struct Freeze_v10Compat

View File

@ -141,4 +141,7 @@ void cdvdWrite17(u8 rt);
void cdvdWrite18(u8 rt); void cdvdWrite18(u8 rt);
void cdvdWrite3A(u8 rt); void cdvdWrite3A(u8 rt);
// Platform dependent system time assignment (see WinMisc / LnxMisc)
extern void cdvdSetSystemTime( cdvdStruct& setme );
#endif /* __CDVD_H__ */ #endif /* __CDVD_H__ */

56
pcsx2/Linux/LnxMisc.cpp Normal file
View File

@ -0,0 +1,56 @@
/* 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 <ctype.h>
#include <time.h>
#include <sys/time.h>
#include "cdvd.h"
void InitCPUTicks()
{
}
u64 GetTickFrequency()
{
return 1000000; // unix measures in microseconds
}
u64 GetCPUTicks()
{
struct timeval t;
gettimeofday(&t, NULL);
return ((u64)t.tv_sec*GetTickFrequency())+t.tv_usec;
}
void cdvdSetSystemTime( cdvdStruct& cdvd )
{
time_t traw;
struct tm* ptlocal;
time(&traw);
ptlocal = localtime(&traw);
cdvd.RTC.second = ptlocal->tm_sec;
cdvd.RTC.minute = ptlocal->tm_min;
cdvd.RTC.hour = ptlocal->tm_hour;
cdvd.RTC.day = ptlocal->tm_mday;
cdvd.RTC.month = ptlocal->tm_mon;
cdvd.RTC.year = ptlocal->tm_year;
}

View File

@ -19,6 +19,9 @@
#include "Linux.h" #include "Linux.h"
#include "LnxSysExec.h" #include "LnxSysExec.h"
#include <sys/mman.h> // needed here? (air)
bool UseGui = true; bool UseGui = true;
SafeArray<u8>* g_RecoveryState = NULL; SafeArray<u8>* g_RecoveryState = NULL;
@ -30,6 +33,45 @@ bool g_EmulationInProgress = false; // Set TRUE if a game is actively running (s
static bool sinit = false; static bool sinit = false;
GtkWidget *FileSel; GtkWidget *FileSel;
void InstallLinuxExceptionHandler()
{
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = &SysPageFaultExceptionFilter;
sigaction(SIGSEGV, &sa, NULL);
}
void ReleaseLinuxExceptionHandler()
{
// Code this later.
}
// Linux implementation of SIGSEGV handler. Bind it using sigaction().
// This is my shot in the dark. Probably needs some work. Good luck! (air)
void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * )
{
int err;
//DevCon::Error("SysPageFaultExceptionFilter!");
// get bad virtual address
u32 offset = (u8*)info->si_addr - psM;
DevCon::Status( "Protected memory cleanup. Offset 0x%x", params offset );
if (offset>=Ps2MemSize::Base)
{
// Bad mojo! Completely invalid address.
// Instigate a crash or abort emulation or something.
assert( false );
}
mmap_ClearCpuBlock( offset );
}
// For issuing notices to both the status bar and the console at the same time. // For issuing notices to both the status bar and the console at the same time.
// Single-line text only please! Mutli-line msgs should be directed to the // Single-line text only please! Mutli-line msgs should be directed to the
// console directly, thanks. // console directly, thanks.
@ -521,8 +563,7 @@ void States_Save(int num)
// have likely been cleared out. So save from the Recovery buffer instead of // have likely been cleared out. So save from the Recovery buffer instead of
// doing a "standard" save: // doing a "standard" save:
string text; string text( SaveState::GetFilename( num ) );
SaveState::GetFilename( text, num );
gzFile fileptr = gzopen( text.c_str(), "wb" ); gzFile fileptr = gzopen( text.c_str(), "wb" );
if( fileptr == NULL ) if( fileptr == NULL )
{ {
@ -920,10 +961,15 @@ void SysMunmap(uptr base, u32 size)
munmap((uptr*)base, size); munmap((uptr*)base, size);
} }
static const int m_pagemask = getpagesize()-1;
void SysMemProtect( void* baseaddr, size_t size, PageProtectionMode mode, bool allowExecution ) void SysMemProtect( void* baseaddr, size_t size, PageProtectionMode mode, bool allowExecution )
{ {
int lnxmode = 0; int lnxmode = 0;
// make sure size is aligned to the system page size:
size = (size + m_pagemask) & ~m_pagemask;
switch( mode ) switch( mode )
{ {
case Protect_NoAccess: break; case Protect_NoAccess: break;

View File

@ -24,6 +24,13 @@
#include <sys/mman.h> #include <sys/mman.h>
#include "x86/iR5900.h" #include "x86/iR5900.h"
void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * );
void __fastcall InstallLinuxExceptionHandler();
void __fastcall ReleaseLinuxExceptionHandler();
#define PCSX2_MEM_PROTECT_BEGIN() InstallLinuxExceptionHandler()
#define PCSX2_MEM_PROTECT_END() ReleaseLinuxExceptionHandler()
extern void StartGui(); extern void StartGui();
extern void CheckSlots(); extern void CheckSlots();

View File

@ -5,7 +5,7 @@ bin_PROGRAMS = pcsx2
# the application source, library search path, and link libraries # the application source, library search path, and link libraries
pcsx2_SOURCES = \ pcsx2_SOURCES = \
interface.c support.c LnxMain.cpp LnxThreads.cpp LnxConsole.cpp LnxSysExec.cpp \ interface.c support.c LnxMain.cpp LnxThreads.cpp LnxConsole.cpp LnxSysExec.cpp LnxMisc.cpp \
AboutDlg.cpp ConfigDlg.cpp DebugDlg.cpp AdvancedDlg.cpp CpuDlg.cpp HacksDlg.cpp McdDlgs.cpp Pref.cpp \ AboutDlg.cpp ConfigDlg.cpp DebugDlg.cpp AdvancedDlg.cpp CpuDlg.cpp HacksDlg.cpp McdDlgs.cpp Pref.cpp \
GtkGui.h Linux.h LnxMain.h ConfigDlg.h DebugDlg.h McdDlgs.h interface.h callbacks.h memzero.h support.h GtkGui.h Linux.h LnxMain.h ConfigDlg.h DebugDlg.h McdDlgs.h interface.h callbacks.h memzero.h support.h

View File

@ -49,7 +49,6 @@ BIOS
#include "PsxCommon.h" #include "PsxCommon.h"
#include "VUmicro.h" #include "VUmicro.h"
#include "GS.h" #include "GS.h"
#include "vtlb.h"
#include "IPU/IPU.h" #include "IPU/IPU.h"
@ -57,11 +56,6 @@ BIOS
#include "Cache.h" #include "Cache.h"
#endif #endif
#ifdef __LINUX__
#include <sys/mman.h>
#endif
//#define FULLTLB
int MemMode = 0; // 0 is Kernel Mode, 1 is Supervisor Mode, 2 is User Mode int MemMode = 0; // 0 is Kernel Mode, 1 is Supervisor Mode, 2 is User Mode
void memSetKernelMode() { void memSetKernelMode() {
@ -95,22 +89,20 @@ u16 ba0R16(u32 mem)
void loadBiosRom( const char *ext, u8 *dest, long maxSize ) void loadBiosRom( const char *ext, u8 *dest, long maxSize )
{ {
string Bios1; string Bios1;
string Bios;
long filesize; long filesize;
Path::Combine( Bios, Config.BiosDir, Config.Bios ); string Bios( Path::Combine( Config.BiosDir, Config.Bios ) );
// Try first a basic extension concatenation (normally results in something like name.bin.rom1) // Try first a basic extension concatenation (normally results in something like name.bin.rom1)
ssprintf(Bios1, "%hs.%s", &Bios, ext); ssprintf(Bios1, "%hs.%s", &Bios, ext);
if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 ) if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 )
{ {
// Try the name properly extensioned next (name.rom1) // Try the name properly extensioned next (name.rom1)
Path::ReplaceExtension( Bios1, Bios, ext ); Bios1 = Path::ReplaceExtension( Bios, ext );
if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 ) if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 )
{ {
// Try for the old-style method (rom1.bin) // Try for the old-style method (rom1.bin)
Path::Combine( Bios1, Config.BiosDir, ext ); Bios1 = Path::Combine( Config.BiosDir, ext ) + ".bin";
Bios1 += ".bin";
if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 ) if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 )
{ {
Console::Error( "\n\n\n" Console::Error( "\n\n\n"
@ -126,12 +118,12 @@ void loadBiosRom( const char *ext, u8 *dest, long maxSize )
// if we made it this far, we have a successful file found: // if we made it this far, we have a successful file found:
FILE *fp = fopen(Bios1.c_str(), "rb"); FILE *fp = fopen(Bios1.c_str(), "rb");
fread(dest, 1, std::min( maxSize, filesize ), fp); fread(dest, 1, min( maxSize, filesize ), fp);
fclose(fp); fclose(fp);
} }
u32 psMPWC[(Ps2MemSize::Base/32)>>12]; static u32 psMPWC[(Ps2MemSize::Base/32)>>12];
std::vector<u32> psMPWVA[Ps2MemSize::Base>>12]; static std::vector<u32> psMPWVA[Ps2MemSize::Base>>12];
u8 *psM = NULL; //32mb Main Ram u8 *psM = NULL; //32mb Main Ram
u8 *psR = NULL; //4mb rom area u8 *psR = NULL; //4mb rom area
@ -793,10 +785,8 @@ void memReset()
vtlb_VMap(0x00000000,0x00000000,0x20000000); vtlb_VMap(0x00000000,0x00000000,0x20000000);
vtlb_VMapUnmap(0x20000000,0x60000000); vtlb_VMapUnmap(0x20000000,0x60000000);
string Bios;
FILE *fp; FILE *fp;
string Bios( Path::Combine( Config.BiosDir, Config.Bios ) );
Path::Combine( Bios, Config.BiosDir, Config.Bios );
long filesize; long filesize;
if( ( filesize = Path::getFileSize( Bios ) ) <= 0 ) if( ( filesize = Path::getFileSize( Bios ) ) <= 0 )
@ -807,7 +797,7 @@ void memReset()
} }
fp = fopen(Bios.c_str(), "rb"); fp = fopen(Bios.c_str(), "rb");
fread(PS2MEM_ROM, 1, std::min( (long)Ps2MemSize::Rom, filesize ), fp); fread(PS2MEM_ROM, 1, min( (long)Ps2MemSize::Rom, filesize ), fp);
fclose(fp); fclose(fp);
BiosVersion = GetBiosVersion(); BiosVersion = GetBiosVersion();
@ -831,15 +821,8 @@ int mmap_GetRamPageInfo(void* ptr)
void mmap_MarkCountedRamPage(void* ptr,u32 vaddr) void mmap_MarkCountedRamPage(void* ptr,u32 vaddr)
{ {
#ifdef _WIN32 SysMemProtect( ptr, 1, Protect_ReadOnly );
DWORD old;
VirtualProtect(ptr,1,PAGE_READONLY,&old);
#else
// fixed? mprotect needs input and size to be aligned to 4096 bytes pagesize.
// 'ptr' should be aligned properly, but a size of 1 was invalid. (air)
mprotect(ptr, getpagesize(), PROT_READ);
#endif
u32 offset=((u8*)ptr-psM); u32 offset=((u8*)ptr-psM);
offset>>=12; offset>>=12;
@ -859,86 +842,12 @@ void mmap_ResetBlockTracking()
{ {
psMPWVA[i].clear(); psMPWVA[i].clear();
} }
#ifdef _WIN32 SysMemProtect( psM, Ps2MemSize::Base, Protect_ReadWrite );
DWORD old;
VirtualProtect(psM,Ps2MemSize::Base,PAGE_READWRITE,&old);
#else
mprotect(psM,Ps2MemSize::Base, PROT_READ|PROT_WRITE);
#endif
} }
#ifdef _WIN32 void mmap_ClearCpuBlock( uint offset )
int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps)
{ {
const _EXCEPTION_RECORD& ExceptionRecord = *eps->ExceptionRecord; SysMemProtect( &psM[offset], 1, Protect_ReadWrite );
//const _CONTEXT& ContextRecord = *eps->ContextRecord;
if (ExceptionRecord.ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
{
return EXCEPTION_CONTINUE_SEARCH;
}
// get bad virtual address
u32 offset = (u8*)ExceptionRecord.ExceptionInformation[1]-psM;
if (offset>=Ps2MemSize::Base)
return EXCEPTION_CONTINUE_SEARCH;
DWORD old;
VirtualProtect(&psM[offset],1,PAGE_READWRITE,&old);
offset>>=12;
psMPWC[(offset/32)]|=(1<<(offset&31));
for (u32 i=0;i<psMPWVA[offset].size();i++)
{
Cpu->Clear(psMPWVA[offset][i],0x1000);
}
psMPWVA[offset].clear();
return EXCEPTION_CONTINUE_EXECUTION;
}
#else
#include "errno.h"
void InstallLinuxExceptionHandler()
{
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = &SysPageFaultExceptionFilter;
sigaction(SIGSEGV, &sa, NULL);
}
void ReleaseLinuxExceptionHandler()
{
// Code this later.
}
// Linux implementation of SIGSEGV handler. Bind it using sigaction().
// This is my shot in the dark. Probably needs some work. Good luck! (air)
void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * )
{
int err;
u32 pagesize = getpagesize();
//DevCon::Error("SysPageFaultExceptionFilter!");
// get bad virtual address
u32 offset = (u8*)info->si_addr - psM;
uptr pageoffset = ( offset / pagesize ) * pagesize;
DevCon::Status( "Protected memory cleanup. Offset 0x%x", params offset );
if (offset>=Ps2MemSize::Base)
{
// Bad mojo! Completly invalid address.
// Instigate a crash or abort emulation or something.
assert( false );
}
err = mprotect( &psM[pageoffset], pagesize, PROT_READ | PROT_WRITE );
if (err) DevCon::Error("SysPageFaultExceptionFilter: %s", params strerror(errno));
offset>>=12; offset>>=12;
psMPWC[(offset/32)]|=(1<<(offset&31)); psMPWC[(offset/32)]|=(1<<(offset&31));
@ -948,5 +857,4 @@ void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * )
Cpu->Clear(psMPWVA[offset][i],0x1000); Cpu->Clear(psMPWVA[offset][i],0x1000);
} }
psMPWVA[offset].clear(); psMPWVA[offset].clear();
} }
#endif

View File

@ -136,17 +136,12 @@ extern void memClearPageAddr(u32 vaddr);
extern void memMapVUmicro(); extern void memMapVUmicro();
#ifdef __LINUX__
void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * );
void __fastcall InstallLinuxExceptionHandler();
void __fastcall ReleaseLinuxExceptionHandler();
#endif
#include "vtlb.h" #include "vtlb.h"
int mmap_GetRamPageInfo(void* ptr); extern int mmap_GetRamPageInfo(void* ptr);
void mmap_MarkCountedRamPage(void* ptr,u32 vaddr); extern void mmap_MarkCountedRamPage(void* ptr,u32 vaddr);
void mmap_ResetBlockTracking(); extern void mmap_ResetBlockTracking();
extern void mmap_ClearCpuBlock( uint offset );
extern void __fastcall memRead8(u32 mem, u8 *out); extern void __fastcall memRead8(u32 mem, u8 *out);
extern void __fastcall memRead16(u32 mem, u16 *out); extern void __fastcall memRead16(u32 mem, u16 *out);

View File

@ -68,7 +68,7 @@ FILE *MemoryCard::Load( uint mcd )
string str( Config.Mcd[mcd].Filename ); string str( Config.Mcd[mcd].Filename );
if( str.empty() ) if( str.empty() )
Path::Combine( str, MEMCARDS_DIR, fmt_string( "Mcd00%d.ps2", mcd ) ); str = Path::Combine( MEMCARDS_DIR, fmt_string( "Mcd00%d.ps2", mcd ) );
if( !Path::Exists(str) ) if( !Path::Exists(str) )
Create( str.c_str() ); Create( str.c_str() );

View File

@ -191,13 +191,12 @@ u32 GetBiosVersion() {
//2002-09-22 (Florin) //2002-09-22 (Florin)
int IsBIOS(char *filename, char *description) int IsBIOS(char *filename, char *description)
{ {
string Bios;
char ROMVER[14+1], zone[12+1]; char ROMVER[14+1], zone[12+1];
FILE *fp; FILE *fp;
unsigned int fileOffset=0, found=FALSE; unsigned int fileOffset=0, found=FALSE;
struct romdir rd; struct romdir rd;
Path::Combine( Bios, Config.BiosDir, filename ); string Bios( Path::Combine( Config.BiosDir, filename ) );
int biosFileSize = Path::getFileSize( Bios ); int biosFileSize = Path::getFileSize( Bios );
if( biosFileSize <= 0) return FALSE; if( biosFileSize <= 0) return FALSE;
@ -415,8 +414,7 @@ void LoadGSState(const string& file)
// file not found? try prefixing with sstates folder: // file not found? try prefixing with sstates folder:
if( !Path::isRooted( file ) ) if( !Path::isRooted( file ) )
{ {
string strfile; string strfile( Path::Combine( SSTATES_DIR, file ) );
Path::Combine( strfile, SSTATES_DIR, file );
f = new gzLoadingState( strfile.c_str() ); f = new gzLoadingState( strfile.c_str() );
// If this load attempt fails, then let the exception bubble up to // If this load attempt fails, then let the exception bubble up to
@ -509,11 +507,11 @@ char* mystrlwr( char* string )
return string; return string;
} }
static void GetGSStateFilename( string& dest ) static string GetGSStateFilename()
{ {
string gsText; string gsText;
ssprintf( gsText, "/%8.8X.%d.gs", ElfCRC, StatesC); ssprintf( gsText, "/%8.8X.%d.gs", ElfCRC, StatesC);
Path::Combine( dest, SSTATES_DIR, gsText ); return Path::Combine( SSTATES_DIR, gsText );
} }
void CycleFrameLimit(int dir) void CycleFrameLimit(int dir)
@ -578,16 +576,13 @@ void CycleFrameLimit(int dir)
void ProcessFKeys(int fkey, int shift) void ProcessFKeys(int fkey, int shift)
{ {
string Text;
assert(fkey >= 1 && fkey <= 12 ); assert(fkey >= 1 && fkey <= 12 );
switch(fkey) { switch(fkey) {
case 1: case 1:
try try
{ {
SaveState::GetFilename( Text, StatesC ); gzSavingState( SaveState::GetFilename( StatesC ) ).FreezeAll();
gzSavingState( Text ).FreezeAll();
} }
catch( Exception::BaseException& ex ) catch( Exception::BaseException& ex )
{ {
@ -607,17 +602,14 @@ void ProcessFKeys(int fkey, int shift)
Console::Notice( _( " > Selected savestate slot %d" ), params StatesC); Console::Notice( _( " > Selected savestate slot %d" ), params StatesC);
if( GSchangeSaveState != NULL ) { if( GSchangeSaveState != NULL )
SaveState::GetFilename(Text, StatesC); GSchangeSaveState(StatesC, SaveState::GetFilename(StatesC).c_str());
GSchangeSaveState(StatesC, Text.c_str());
}
break; break;
case 3: case 3:
try try
{ {
SaveState::GetFilename( Text, StatesC ); gzLoadingState joe( SaveState::GetFilename( StatesC ) ); // throws exception on version mismatch
gzLoadingState joe( Text ); // throws exception on version mismatch
cpuReset(); cpuReset();
SysResetExecutionState(); SysResetExecutionState();
joe.FreezeAll(); joe.FreezeAll();
@ -664,7 +656,9 @@ void ProcessFKeys(int fkey, int shift)
if( mtgsThread != NULL ) { if( mtgsThread != NULL ) {
Console::Notice( "Cannot make gsstates in MTGS mode" ); Console::Notice( "Cannot make gsstates in MTGS mode" );
} }
else { else
{
string Text;
if( strgametitle[0] != 0 ) { if( strgametitle[0] != 0 ) {
// only take the first two words // only take the first two words
char name[256], *tok; char name[256], *tok;
@ -676,10 +670,10 @@ void ProcessFKeys(int fkey, int shift)
if( tok != NULL ) strcat(name, tok); if( tok != NULL ) strcat(name, tok);
ssprintf( gsText, "%s.%d.gs", name, StatesC); ssprintf( gsText, "%s.%d.gs", name, StatesC);
Path::Combine( Text, SSTATES_DIR, gsText ); Text = Path::Combine( SSTATES_DIR, gsText );
} }
else else
GetGSStateFilename( Text ); Text = GetGSStateFilename();
SaveGSState(Text); SaveGSState(Text);
} }
@ -709,7 +703,6 @@ void ProcessFKeys(int fkey, int shift)
void injectIRX(const char *filename) void injectIRX(const char *filename)
{ {
string path;
char name[260], *p, *q; char name[260], *p, *q;
struct romdir *rd; struct romdir *rd;
int iROMDIR=-1, iIOPBTCONF=-1, iBLANK=-1, i, filesize; int iROMDIR=-1, iIOPBTCONF=-1, iBLANK=-1, i, filesize;
@ -749,7 +742,7 @@ void injectIRX(const char *filename)
strcpy(p, name);p[strlen(name)]=0xA; strcpy(p, name);p[strlen(name)]=0xA;
//phase 4: find file //phase 4: find file
Path::Combine( path, Config.BiosDir, filename ); string path( Path::Combine( Config.BiosDir, filename ) );
if( !Path::isFile( path ) ) if( !Path::isFile( path ) )
{ {
@ -775,43 +768,6 @@ void injectIRX(const char *filename)
} }
// [TODO] I'd like to move the following functions to their own module eventually.
// It might even be a good idea to just go ahead and move them into Win32/Linux
// specific files since they're all #ifdef'd that way anyways.
#ifdef _WIN32
static LARGE_INTEGER lfreq;
#endif
void InitCPUTicks()
{
#ifdef _WIN32
QueryPerformanceFrequency(&lfreq);
#endif
}
u64 GetTickFrequency()
{
#ifdef _WIN32
return lfreq.QuadPart;
#else
return 1000000; // unix measures in microseconds
#endif
}
u64 GetCPUTicks()
{
#ifdef _WIN32
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
return count.QuadPart;
#else
struct timeval t;
gettimeofday(&t, NULL);
return ((u64)t.tv_sec*GetTickFrequency())+t.tv_usec;
#endif
}
void _memset16_unaligned( void* dest, u16 data, size_t size ) void _memset16_unaligned( void* dest, u16 data, size_t size )
{ {
jASSUME( (size & 0x1) == 0 ); jASSUME( (size & 0x1) == 0 );

View File

@ -26,13 +26,6 @@
#include "Patch.h" #include "Patch.h"
#include "VU.h" #include "VU.h"
#ifdef _WIN32
#include "windows/cheats/cheats.h"
#else
#include <stdio.h>
#include <ctype.h>
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4996) //ignore the stricmp deprecated warning #pragma warning(disable:4996) //ignore the stricmp deprecated warning
#endif #endif

View File

@ -92,23 +92,21 @@ bool isRooted( const string& path )
// Concatenates two pathnames together, inserting delimiters (backslash on win32) // Concatenates two pathnames together, inserting delimiters (backslash on win32)
// as needed! Assumes the 'dest' is allocated to at least g_MaxPath length. // as needed! Assumes the 'dest' is allocated to at least g_MaxPath length.
void Combine( string& dest, const string& srcPath, const string& srcFile ) string Combine( const string& srcPath, const string& srcFile )
{ {
int pathlen, guesslen; int pathlen, guesslen;
if( srcFile.empty() ) if( srcFile.empty() )
{ {
// No source filename? Return the path unmodified. // No source filename? Return the path unmodified.
dest = srcPath; return srcPath;
return;
} }
if( isRooted( srcFile ) || srcPath.empty() ) if( isRooted( srcFile ) || srcPath.empty() )
{ {
// No source path? Or source filename is rooted? // No source path? Or source filename is rooted?
// Return the filename unmodified. // Return the filename unmodified.
dest = srcFile; return srcFile;
return;
} }
// strip off the srcPath's trailing backslashes (if any) // strip off the srcPath's trailing backslashes (if any)
@ -127,14 +125,17 @@ void Combine( string& dest, const string& srcPath, const string& srcFile )
// Concatenate! // Concatenate!
dest.assign( srcPath.begin(), srcPath.begin()+pathlen ); string dest( srcPath.begin(), srcPath.begin()+pathlen );
dest += Separator; dest += Separator;
dest += srcFile; dest += srcFile;
return dest;
} }
// Replaces the extension of the file with the one given. // Replaces the extension of the file with the one given.
void ReplaceExtension( string& dest, const string& src, const string& ext ) string ReplaceExtension( const string& src, const string& ext )
{ {
string dest;
int pos = src.find_last_of( '.' ); int pos = src.find_last_of( '.' );
if( pos == string::npos || pos == 0 ) if( pos == string::npos || pos == 0 )
dest = src; dest = src;
@ -146,6 +147,8 @@ void ReplaceExtension( string& dest, const string& src, const string& ext )
dest += '.'; dest += '.';
dest += ext; dest += ext;
} }
return dest;
} }
// finds the starting character position of a filename for the given source path. // finds the starting character position of a filename for the given source path.
@ -176,10 +179,11 @@ static int _findFilenamePosition( const string& src)
return pos; return pos;
} }
void ReplaceFilename( string& dest, const string& src, const string& newfilename ) string ReplaceFilename( const string& src, const string& newfilename )
{ {
string dest;
int pos = _findFilenamePosition( src ); int pos = _findFilenamePosition( src );
if( pos == 0 ) if( pos == 0 )
dest = src; dest = src;
else else
@ -190,6 +194,7 @@ void ReplaceFilename( string& dest, const string& src, const string& newfilename
dest += '.'; dest += '.';
dest += newfilename; dest += newfilename;
} }
return dest;
} }
void GetFilename( const string& src, string& dest ) void GetFilename( const string& src, string& dest )

View File

@ -24,15 +24,15 @@ extern char MAIN_DIR[g_MaxPath];
namespace Path namespace Path
{ {
extern void Combine( std::string& dest, const std::string& srcPath, const std::string& srcFile );
extern bool isRooted( const std::string& path ); extern bool isRooted( const std::string& path );
extern bool isDirectory( const std::string& path ); extern bool isDirectory( const std::string& path );
extern bool isFile( const std::string& path ); extern bool isFile( const std::string& path );
extern bool Exists( const std::string& path ); extern bool Exists( const std::string& path );
extern int getFileSize( const std::string& path ); extern int getFileSize( const std::string& path );
extern void ReplaceExtension( std::string& dest, const std::string& src, const std::string& ext ); extern std::string Combine( const std::string& srcPath, const std::string& srcFile );
extern void ReplaceFilename( std::string& dest, const std::string& src, const std::string& newfilename ); extern std::string ReplaceExtension( const std::string& src, const std::string& ext );
extern std::string ReplaceFilename( const std::string& src, const std::string& newfilename );
extern void GetFilename( const std::string& src, std::string& dest ); extern void GetFilename( const std::string& src, std::string& dest );
extern void GetDirectory( const std::string& src, std::string& dest ); extern void GetDirectory( const std::string& src, std::string& dest );
extern void GetRootDirectory( const std::string& src, std::string& dest ); extern void GetRootDirectory( const std::string& src, std::string& dest );

View File

@ -594,31 +594,14 @@ int LoadPlugins()
{ {
if( loadp ) return 0; if( loadp ) return 0;
string Plugin; if (LoadGSplugin( Path::Combine( Config.PluginsDir, Config.GS )) == -1) return -1;
if (LoadPAD1plugin( Path::Combine( Config.PluginsDir, Config.PAD1 )) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.GS ); if (LoadPAD2plugin( Path::Combine( Config.PluginsDir, Config.PAD2 )) == -1) return -1;
if (LoadGSplugin(Plugin) == -1) return -1; if (LoadSPU2plugin( Path::Combine( Config.PluginsDir, Config.SPU2 )) == -1) return -1;
if (LoadCDVDplugin( Path::Combine( Config.PluginsDir, Config.CDVD )) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.PAD1 ); if (LoadDEV9plugin( Path::Combine( Config.PluginsDir, Config.DEV9 )) == -1) return -1;
if (LoadPAD1plugin(Plugin) == -1) return -1; if (LoadUSBplugin( Path::Combine( Config.PluginsDir, Config.USB )) == -1) return -1;
if (LoadFWplugin( Path::Combine( Config.PluginsDir, Config.FW )) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.PAD2);
if (LoadPAD2plugin(Plugin) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.SPU2);
if (LoadSPU2plugin(Plugin) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.CDVD);
if (LoadCDVDplugin(Plugin) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.DEV9);
if (LoadDEV9plugin(Plugin) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.USB);
if (LoadUSBplugin(Plugin) == -1) return -1;
Path::Combine( Plugin, Config.PluginsDir, Config.FW);
if (LoadFWplugin(Plugin) == -1) return -1;
loadp = true; loadp = true;

View File

@ -1,6 +1,8 @@
#ifndef _PCSX2_PRECOMPILED_HEADER_ #ifndef _PCSX2_PRECOMPILED_HEADER_
#define _PCSX2_PRECOMPILED_HEADER_ #define _PCSX2_PRECOMPILED_HEADER_
#define NOMINMAX // Disables other libs inclusion of their own min/max macros (we use std instead)
#if defined (__linux__) // some distributions are lower case #if defined (__linux__) // some distributions are lower case
# define __LINUX__ # define __LINUX__
#endif #endif
@ -39,6 +41,8 @@
#endif #endif
using std::string; // we use it enough, so bring it into the global namespace. using std::string; // we use it enough, so bring it into the global namespace.
using std::min;
using std::max;
#include "zlib/zlib.h" #include "zlib/zlib.h"
#include "PS2Etypes.h" #include "PS2Etypes.h"

View File

@ -18,10 +18,6 @@
#ifndef __PSXCOMMON_H__ #ifndef __PSXCOMMON_H__
#define __PSXCOMMON_H__ #define __PSXCOMMON_H__
#ifdef _WIN32
#include <windows.h>
#endif
#include "PS2Etypes.h" #include "PS2Etypes.h"
#include <assert.h> #include <assert.h>

View File

@ -27,6 +27,8 @@
#ifndef _REDTAPE_WINDOWS_H_ #ifndef _REDTAPE_WINDOWS_H_
#define _REDTAPE_WINDOWS_H_ #define _REDTAPE_WINDOWS_H_
#define NOMINMAX // Disables other libs inclusion of their own min/max macros (we use std instead)
#ifdef _WIN32 #ifdef _WIN32
// Force availability of to WinNT APIs (change to 0x600 to enable XP-specific APIs) // Force availability of to WinNT APIs (change to 0x600 to enable XP-specific APIs)

View File

@ -51,21 +51,11 @@ static void PostLoadPrep()
for(int i=0; i<48; i++) MapTLB(i); for(int i=0; i<48; i++) MapTLB(i);
} }
void SaveState::GetFilename( string& dest, int slot )
{
string elfcrcText;
ssprintf( elfcrcText, "%8.8X.%3.3d", ElfCRC, slot );
Path::Combine( dest, SSTATES_DIR, elfcrcText );
}
string SaveState::GetFilename( int slot ) string SaveState::GetFilename( int slot )
{ {
string elfcrcText, dest; return Path::Combine( SSTATES_DIR, fmt_string( "%8.8X.%3.3d", ElfCRC, slot ) );
GetFilename( dest, slot );
return dest;
} }
SaveState::SaveState( const char* msg, const string& destination ) : m_version( g_SaveVersion ) SaveState::SaveState( const char* msg, const string& destination ) : m_version( g_SaveVersion )
{ {
Console::WriteLn( "%s %hs", params msg, &destination ); Console::WriteLn( "%s %hs", params msg, &destination );

View File

@ -46,7 +46,6 @@ public:
SaveState( const char* msg, const string& destination ); SaveState( const char* msg, const string& destination );
virtual ~SaveState() { } virtual ~SaveState() { }
static void GetFilename( string& dest, int slot );
static string GetFilename( int slot ); static string GetFilename( int slot );
// Gets the version of savestate that this object is acting on. // Gets the version of savestate that this object is acting on.

View File

@ -74,15 +74,6 @@ void SysMemProtect( void* baseaddr, size_t size, PageProtectionMode mode, bool a
// *DEPRECIATED* Use Console namespace methods instead. // *DEPRECIATED* Use Console namespace methods instead.
void SysPrintf(const char *fmt, ...); // *DEPRECIATED* void SysPrintf(const char *fmt, ...); // *DEPRECIATED*
#ifdef _MSC_VER
# define PCSX2_MEM_PROTECT_BEGIN() __try {
# define PCSX2_MEM_PROTECT_END() } __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
#else
# define PCSX2_MEM_PROTECT_BEGIN() InstallLinuxExceptionHandler()
# define PCSX2_MEM_PROTECT_END() ReleaseLinuxExceptionHandler()
#endif
// Console Namespace -- Replacements for SysPrintf. // Console Namespace -- Replacements for SysPrintf.
// SysPrintf is depreciated -- We should phase these in over time. // SysPrintf is depreciated -- We should phase these in over time.
namespace Console namespace Console

View File

@ -46,9 +46,7 @@ struct ComboInitializer
, PS2E_GetLibName( NULL ) , PS2E_GetLibName( NULL )
, PS2E_GetLibVersion2( NULL ) , PS2E_GetLibVersion2( NULL )
{ {
string tmpStr; Find = FindFirstFile( Path::Combine( Config.PluginsDir, "*.dll" ).c_str(), &FindData);
Path::Combine( tmpStr, Config.PluginsDir, "*.dll" );
Find = FindFirstFile(tmpStr.c_str(), &FindData);
} }
~ComboInitializer() ~ComboInitializer()
@ -64,9 +62,8 @@ struct ComboInitializer
bool LoadNextLibrary() bool LoadNextLibrary()
{ {
string tmpStr; string tmpStr( Path::Combine( Config.PluginsDir, FindData.cFileName ) );
Path::Combine( tmpStr, Config.PluginsDir, FindData.cFileName ); Lib = LoadLibrary( tmpStr.c_str() );
Lib = LoadLibrary(tmpStr.c_str());
if (Lib == NULL) if (Lib == NULL)
{ {
Console::Error( "Plugin load failure: %hs\n\tSysLibError Message: %s", params &tmpStr, SysLibError() ); Console::Error( "Plugin load failure: %hs\n\tSysLibError Message: %s", params &tmpStr, SysLibError() );
@ -180,10 +177,7 @@ BOOL OnConfigureDialog(HWND hW) {
HANDLE Find; HANDLE Find;
WIN32_FIND_DATA FindData; WIN32_FIND_DATA FindData;
string tmpStr; Find = FindFirstFile( Path::Combine( Config.BiosDir, "*" ).c_str(), &FindData);
Path::Combine( tmpStr, Config.BiosDir, "*" );
Find=FindFirstFile(tmpStr.c_str(), &FindData);
do do
{ {
@ -309,12 +303,10 @@ static void ConfPlugin( HWND hW, int confs, const char* name )
void *drv; void *drv;
void (*conf)(); void (*conf)();
char * pDLL = GetComboSel(hW, confs); char * pDLL = GetComboSel(hW, confs);
string file;
if(pDLL==NULL) return; if(pDLL==NULL) return;
Path::Combine( file, Config.PluginsDir, pDLL );
drv = SysLoadLibrary(file.c_str()); drv = SysLoadLibrary( Path::Combine( Config.PluginsDir, pDLL ).c_str() );
if (drv == NULL) return; if (drv == NULL) return;
conf = (void (*)()) SysLoadSym(drv, name); conf = (void (*)()) SysLoadSym(drv, name);
@ -390,12 +382,10 @@ static void TestPlugin( HWND hW, int confs, const char* name )
int (*conf)(); int (*conf)();
int ret = 0; int ret = 0;
char * pDLL = GetComboSel(hW, confs); char * pDLL = GetComboSel(hW, confs);
string file;
if (pDLL== NULL) return; if (pDLL== NULL) return;
Path::Combine( file, Config.PluginsDir, pDLL );
drv = SysLoadLibrary(file.c_str()); drv = SysLoadLibrary( Path::Combine( Config.PluginsDir, pDLL ).c_str() );
if (drv == NULL) return; if (drv == NULL) return;
conf = (int (*)()) SysLoadSym(drv, name); conf = (int (*)()) SysLoadSym(drv, name);

View File

@ -18,7 +18,6 @@
#include "Win32.h" #include "Win32.h"
#include "Common.h" #include "Common.h"
#include "resource.h"
unsigned long memory_addr; unsigned long memory_addr;
BOOL mem_inupdate = FALSE; BOOL mem_inupdate = FALSE;

View File

@ -110,12 +110,17 @@ void MemcardConfig::Open_Mcd_Proc(HWND hW, int mcd)
if (GetOpenFileName ((LPOPENFILENAME)&ofn)) if (GetOpenFileName ((LPOPENFILENAME)&ofn))
{ {
string confusion; Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD_FILE1 : IDC_MCD_FILE2),
Path::Combine( confusion, g_WorkingFolder, szFileName ); _stripPathInfo( Path::Combine( g_WorkingFolder, szFileName ).c_str() ) );
Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD_FILE1 : IDC_MCD_FILE2), _stripPathInfo( confusion.c_str() ) );
} }
} }
static string m_Default_MemcardsDir[2] =
{
Path::Combine( MEMCARDS_DIR, DEFAULT_MEMCARD1 ),
Path::Combine( MEMCARDS_DIR, DEFAULT_MEMCARD2 )
};
BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch(uMsg) switch(uMsg)
@ -136,16 +141,14 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
if( Config.Mcd[0].Filename[0] == 0 ) if( Config.Mcd[0].Filename[0] == 0 )
{ {
string mcdpath; strcpy_s( Config.Mcd[0].Filename,
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 ); Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[0] ).c_str() );
mcdpath._Copy_s( Config.Mcd[1].Filename, g_MaxPath, mcdpath.length() );
} }
if( Config.Mcd[1].Filename[1] == 0 ) if( Config.Mcd[1].Filename[1] == 0 )
{ {
string mcdpath; strcpy_s( Config.Mcd[1].Filename,
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 ); Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[1] ).c_str() );
mcdpath._Copy_s( Config.Mcd[1].Filename, g_MaxPath, mcdpath.length() );
} }
Edit_SetText( GetDlgItem(hWnd,IDC_MCD_FILE1), _stripPathInfo( Config.Mcd[0].Filename ) ); Edit_SetText( GetDlgItem(hWnd,IDC_MCD_FILE1), _stripPathInfo( Config.Mcd[0].Filename ) );
@ -190,13 +193,8 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
// reassign text with the extra unnecessary path info stripped out. // reassign text with the extra unnecessary path info stripped out.
string confusion; _tcscpy( Config.Mcd[0].Filename, _stripPathInfo( Path::Combine( g_WorkingFolder, Config.Mcd[0].Filename ).c_str() ) );
_tcscpy( Config.Mcd[1].Filename, _stripPathInfo( Path::Combine( g_WorkingFolder, Config.Mcd[1].Filename ).c_str() ) );
Path::Combine( confusion, g_WorkingFolder, Config.Mcd[0].Filename );
_tcscpy( Config.Mcd[0].Filename, _stripPathInfo( confusion.c_str() ) );
Path::Combine( confusion, g_WorkingFolder, Config.Mcd[1].Filename );
_tcscpy( Config.Mcd[1].Filename, _stripPathInfo( confusion.c_str() ) );
if( g_EmulationInProgress ) if( g_EmulationInProgress )
{ {
@ -244,13 +242,11 @@ void IniFile::MemcardSettings( PcsxConfig& conf )
{ {
SetCurrentSection( "Memorycards" ); SetCurrentSection( "Memorycards" );
string mcdpath; Entry( "Slot1_Path", conf.Mcd[0].Filename,
Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[0] ) );
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 ); Entry( "Slot2_Path", conf.Mcd[1].Filename,
Entry( "Slot1_Path", conf.Mcd[0].Filename, mcdpath ); Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[0] ) );
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 );
Entry( "Slot2_Path", conf.Mcd[1].Filename, mcdpath );
Entry( "Slot1_Enabled", conf.Mcd[0].Enabled, true ); Entry( "Slot1_Enabled", conf.Mcd[0].Enabled, true );
Entry( "Slot2_Enabled", conf.Mcd[1].Enabled, true ); Entry( "Slot2_Enabled", conf.Mcd[1].Enabled, true );

View File

@ -24,7 +24,6 @@
#include "Win32.h" #include "Win32.h"
#include "Common.h" #include "Common.h"
#include "resource.h"
/* /*
* TODO: * TODO:

View File

@ -295,6 +295,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\AboutDlg.h" RelativePath="..\AboutDlg.h"
@ -321,6 +330,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\ConfigDlg.cpp" RelativePath="..\ConfigDlg.cpp"
@ -343,6 +361,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\CpuDlg.cpp" RelativePath="..\CpuDlg.cpp"
@ -365,6 +392,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\HacksDlg.cpp" RelativePath="..\HacksDlg.cpp"
@ -387,6 +423,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\ini.cpp" RelativePath="..\ini.cpp"
@ -431,6 +476,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\McdManagerDlg.cpp" RelativePath="..\McdManagerDlg.cpp"
@ -461,6 +515,8 @@
> >
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
@ -511,6 +567,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\RDebugger.h" RelativePath="..\RDebugger.h"
@ -541,6 +606,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\WindowsPCH.cpp" RelativePath="..\WindowsPCH.cpp"
@ -594,6 +668,8 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
BufferSecurityCheck="false" BufferSecurityCheck="false"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration <FileConfiguration
@ -641,6 +717,8 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
BufferSecurityCheck="false" BufferSecurityCheck="false"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration <FileConfiguration
@ -867,6 +945,28 @@
RelativePath="..\..\vssprintf.cpp" RelativePath="..\..\vssprintf.cpp"
> >
</File> </File>
<File
RelativePath="..\WinMisc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File>
<Filter <Filter
Name="TinyXML" Name="TinyXML"
> >
@ -1430,6 +1530,34 @@
RelativePath="..\..\Linux\LnxMain.h" RelativePath="..\..\Linux\LnxMain.h"
> >
</File> </File>
<File
RelativePath="..\..\Linux\LnxMisc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\..\Linux\LnxSysExec.cpp" RelativePath="..\..\Linux\LnxSysExec.cpp"
> >
@ -2529,6 +2657,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\..\SaveState.cpp" RelativePath="..\..\SaveState.cpp"
@ -2545,6 +2682,33 @@
<File <File
RelativePath="..\WinCompressNTFS.cpp" RelativePath="..\WinCompressNTFS.cpp"
> >
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\WinThreads.cpp" RelativePath="..\WinThreads.cpp"
@ -2567,6 +2731,15 @@
PrecompiledHeaderFile="$(IntDir)\win32.pch" PrecompiledHeaderFile="$(IntDir)\win32.pch"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PrecompiledHeaderThrough="Win32.h"
PrecompiledHeaderFile="$(IntDir)\win32.pch"
/>
</FileConfiguration>
</File> </File>
<Filter <Filter
Name="Include" Name="Include"

View File

@ -35,6 +35,10 @@
//Exception handler for the VTLB-based recompilers. //Exception handler for the VTLB-based recompilers.
int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps); int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps);
#define PCSX2_MEM_PROTECT_BEGIN() __try {
#define PCSX2_MEM_PROTECT_END() } __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
// --->> Ini Configuration [ini.c] // --->> Ini Configuration [ini.c]
extern char g_WorkingFolder[g_MaxPath]; extern char g_WorkingFolder[g_MaxPath];

View File

@ -1,6 +1,21 @@
/* 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 "Win32.h"
// Translates an Errno code into an exception. // Translates an Errno code into an exception.

52
pcsx2/windows/WinMisc.cpp Normal file
View File

@ -0,0 +1,52 @@
/* 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 "Win32.h"
#include "cdvd.h"
static LARGE_INTEGER lfreq;
void InitCPUTicks()
{
QueryPerformanceFrequency( &lfreq );
}
u64 GetTickFrequency()
{
return lfreq.QuadPart;
}
u64 GetCPUTicks()
{
LARGE_INTEGER count;
QueryPerformanceCounter( &count );
return count.QuadPart;
}
void cdvdSetSystemTime( cdvdStruct& cdvd )
{
SYSTEMTIME st;
GetSystemTime(&st);
cdvd.RTC.second = (u8)(st.wSecond);
cdvd.RTC.minute = (u8)(st.wMinute);
cdvd.RTC.hour = (u8)(st.wHour+1)%24;
cdvd.RTC.day = (u8)(st.wDay);
cdvd.RTC.month = (u8)(st.wMonth);
cdvd.RTC.year = (u8)(st.wYear - 2000);
}

View File

@ -45,9 +45,30 @@ AppData gApp;
const char* g_pRunGSState = NULL; const char* g_pRunGSState = NULL;
#define CmdSwitchIs( text ) ( stricmp( command, text ) == 0 ) #define CmdSwitchIs( text ) ( stricmp( command, text ) == 0 )
int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps )
{
const _EXCEPTION_RECORD& ExceptionRecord = *eps->ExceptionRecord;
//const _CONTEXT& ContextRecord = *eps->ContextRecord;
if (ExceptionRecord.ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
{
return EXCEPTION_CONTINUE_SEARCH;
}
// get bad virtual address
u32 offset = (u8*)ExceptionRecord.ExceptionInformation[1]-psM;
if (offset>=Ps2MemSize::Base)
return EXCEPTION_CONTINUE_SEARCH;
mmap_ClearCpuBlock( offset );
return EXCEPTION_CONTINUE_EXECUTION;
}
// For issuing notices to both the status bar and the console at the same time. // For issuing notices to both the status bar and the console at the same time.
// Single-line text only please! Mutli-line msgs should be directed to the // Single-line text only please! Mutli-line msgs should be directed to the
// console directly, thanks. // console directly, thanks.
@ -517,8 +538,7 @@ void States_Save(int num)
// have likely been cleared out. So save from the Recovery buffer instead of // have likely been cleared out. So save from the Recovery buffer instead of
// doing a "standard" save: // doing a "standard" save:
string text; string text( SaveState::GetFilename( num ) );
SaveState::GetFilename( text, num );
gzFile fileptr = gzopen( text.c_str(), "wb" ); gzFile fileptr = gzopen( text.c_str(), "wb" );
if( fileptr == NULL ) if( fileptr == NULL )
{ {

View File

@ -18,22 +18,11 @@
#ifndef CHEATS_H_INCLUDED #ifndef CHEATS_H_INCLUDED
#define CHEATS_H_INCLUDED #define CHEATS_H_INCLUDED
#ifndef __cplusplus
//typedef enum ebool
//{
// false,
// true
//} bool;
#define bool unsigned __int8
#define false 0
#define true 1
#endif
extern HINSTANCE pInstance; extern HINSTANCE pInstance;
extern bool FirstShow; extern bool FirstShow;
void AddCheat(HINSTANCE hInstance, HWND hParent); extern void AddCheat(HINSTANCE hInstance, HWND hParent);
void ShowFinder(HINSTANCE hInstance, HWND hParent); extern void ShowFinder(HINSTANCE hInstance, HWND hParent);
void ShowCheats(HINSTANCE hInstance, HWND hParent); extern void ShowCheats(HINSTANCE hInstance, HWND hParent);
#endif//CHEATS_H_INCLUDED #endif//CHEATS_H_INCLUDED

View File

@ -33,23 +33,12 @@ static bool hasCustomConfig()
} }
// Returns the FULL (absolute) path and filename of the configuration file. // Returns the FULL (absolute) path and filename of the configuration file.
static void GetConfigFilename( string& dest ) static string GetConfigFilename()
{ {
if( hasCustomConfig() ) // Load a user-specified configuration, or use the ini relative to the application's working directory.
{ // (Our current working directory can change, so we use the one we detected at startup)
// Load a user-specified configuration.
// If the configuration isn't found, fail outright (see below)
Path::Combine( dest, g_WorkingFolder, g_CustomConfigFile ); return Path::Combine( g_WorkingFolder, hasCustomConfig() ? g_CustomConfigFile : (CONFIG_DIR "\\pcsx2.ini") );
}
else
{
// use the ini relative to the application's working directory.
// Our current working directory can change, so we use the one we detected
// at startup:
Path::Combine( dest, g_WorkingFolder, CONFIG_DIR "\\pcsx2.ini" );
}
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
@ -173,9 +162,8 @@ void IniFileSaver::EnumEntry( const string& var, int& value, const char* const*
// InitFile -- Base class implementation. // InitFile -- Base class implementation.
IniFile::~IniFile() {} IniFile::~IniFile() {}
IniFile::IniFile() : m_filename(), m_section("Misc") IniFile::IniFile() : m_filename( GetConfigFilename() ), m_section("Misc")
{ {
GetConfigFilename( m_filename );
} }
void IniFile::SetCurrentSection( const string& newsection ) void IniFile::SetCurrentSection( const string& newsection )
@ -244,10 +232,9 @@ void IniFile::DoConfig( PcsxConfig& Conf )
bool LoadConfig() bool LoadConfig()
{ {
string szIniFile;
bool status = true; bool status = true;
GetConfigFilename( szIniFile ); string szIniFile( GetConfigFilename() );
if( !Path::Exists( szIniFile ) ) if( !Path::Exists( szIniFile ) )
{ {

View File

@ -133,7 +133,6 @@ using namespace R3000A;
static void iIopDumpBlock( int startpc, u8 * ptr ) static void iIopDumpBlock( int startpc, u8 * ptr )
{ {
FILE *f; FILE *f;
char filename[ g_MaxPath ];
#ifdef __LINUX__ #ifdef __LINUX__
char command[256]; char command[256];
#endif #endif
@ -143,17 +142,13 @@ static void iIopDumpBlock( int startpc, u8 * ptr )
int numused, count; int numused, count;
SysPrintf( "dump1 %x:%x, %x\n", startpc, psxpc, psxRegs.cycle ); SysPrintf( "dump1 %x:%x, %x\n", startpc, psxpc, psxRegs.cycle );
#ifdef _WIN32 Path::CreateDirectory( "dumps" );
CreateDirectory("dumps", NULL);
sprintf_s( filename, g_MaxPath, "dumps\\psxdump%.8X.txt", startpc); string filename( Path::Combine( "dumps", fmt_string( "psxdump%.8X.txt", startpc ) ) );
#else
mkdir("dumps", 0755);
sprintf( filename, "dumps/psxdump%.8X.txt", startpc);
#endif
fflush( stdout ); fflush( stdout );
f = fopen( filename, "w" ); f = fopen( filename.c_str(), "w" );
assert( f != NULL ); assert( f != NULL );
for ( i = startpc; i < s_nEndBlock; i += 4 ) { for ( i = startpc; i < s_nEndBlock; i += 4 ) {
fprintf( f, "%s\n", disR3000Fasm( iopMemRead32( i ), i ) ); fprintf( f, "%s\n", disR3000Fasm( iopMemRead32( i ), i ) );

View File

@ -525,7 +525,9 @@ void SuperVUDumpBlock(list<VuBaseBlock*>& blocks, int vuindex)
u32 i; u32 i;
Path::CreateDirectory( "dumps" ); Path::CreateDirectory( "dumps" );
ssprintf( filename, "dumps\\svu%cdump%.4X.txt", s_vu?'0':'1', s_pFnHeader->startpc ); ssprintf( filename, "svu%cdump%.4X.txt", s_vu?'0':'1', s_pFnHeader->startpc );
filename = Path::Combine( "dumps", filename );
//SysPrintf( "dump1 %x => %s\n", s_pFnHeader->startpc, filename ); //SysPrintf( "dump1 %x => %s\n", s_pFnHeader->startpc, filename );