From ebb53394189174f9d0cddc827e545c2b2d6be772 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 28 Feb 2009 20:55:53 +0000 Subject: [PATCH] Yay more header file cleanup chores! Removed most of the Windows.h dependencies from non-Win32 specific files, and fixed the annoying ARRAYSIZE warnings. Let's say it together: "We all should love C's archaic include system, because it makes Jake and Arcum work really hard for no good reason." git-svn-id: http://pcsx2.googlecode.com/svn/trunk@634 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/PS2Etypes.h | 5 +- pcsx2/CDVD.cpp | 2 +- pcsx2/Linux/LnxMain.cpp | 2 +- pcsx2/Linux/LnxSysExec.cpp | 14 + pcsx2/Linux/LnxThreads.cpp | 7 +- pcsx2/MTGS.cpp | 2 +- pcsx2/Memory.cpp | 15 +- pcsx2/Memory.h | 6 - pcsx2/Misc.cpp | 21 +- pcsx2/Patch.h | 4 - pcsx2/PathUtils.cpp | 13 + pcsx2/Paths.h | 26 +- pcsx2/Plugins.cpp | 3 +- pcsx2/PrecompiledHeader.h | 34 +- pcsx2/RDebug/deci2.h | 6 +- pcsx2/RDebug/deci2_dbgp.cpp | 8 +- pcsx2/RedtapeWindows.h | 45 ++ pcsx2/SamplProf.h | 2 +- pcsx2/System.h | 16 +- pcsx2/ThreadTools.cpp | 9 +- pcsx2/Threading.h | 4 + pcsx2/vtlb.cpp | 3 +- pcsx2/windows/AboutDlg.cpp | 1 - pcsx2/windows/AdvancedDlg.cpp | 2 - pcsx2/windows/ConfigDlg.cpp | 2 - pcsx2/windows/CpuDlg.cpp | 1 - pcsx2/windows/DebugMemory.cpp | 2 - pcsx2/windows/Debugger.cpp | 3 - pcsx2/windows/Debugger.h | 2 +- pcsx2/windows/Debugreg.cpp | 2 - pcsx2/windows/HacksDlg.cpp | 1 - pcsx2/windows/McdConfigDlg.cpp | 2 - pcsx2/windows/McdManagerDlg.cpp | 1 - pcsx2/windows/PatchBrowser.cpp | 2 - pcsx2/windows/RDebugger.cpp | 14 +- pcsx2/windows/RDebugger.h | 2 +- pcsx2/windows/SamplProf.cpp | 6 +- pcsx2/windows/VCprojects/pcsx2_2008.vcproj | 444 ++++++++++++++++-- pcsx2/windows/Win32.h | 8 + pcsx2/windows/WinConsole.cpp | 2 +- pcsx2/windows/WinMain.cpp | 1 - pcsx2/windows/WinSysExec.cpp | 39 +- pcsx2/windows/WinThreads.cpp | 9 +- pcsx2/windows/WindowsPCH.cpp | 1 + pcsx2/windows/cheats/browser.cpp | 2 - pcsx2/windows/cheats/cheats.cpp | 2 - pcsx2/windows/ini.cpp | 3 +- pcsx2/x86/BaseblockEx.h | 2 +- pcsx2/x86/iCore.cpp | 10 +- pcsx2/x86/iR3000A.cpp | 12 +- pcsx2/x86/iVUzerorec.cpp | 40 +- pcsx2/x86/ix86-32/iR5900-32.cpp | 32 +- pcsx2/x86/ix86/ix86_cpudetect.cpp | 2 + pcsx2/x86/ix86/ix86_tools.cpp | 49 -- pcsx2/xmlpatchloader.cpp | 4 - plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj | 4 - plugins/zerogs/dx/Regs.cpp | 14 +- plugins/zerogs/dx/zerogs.cpp | 32 +- plugins/zerogs/dx/zerogs.h | 4 +- plugins/zerospu2/zerospu2.cpp | 32 +- 60 files changed, 683 insertions(+), 355 deletions(-) create mode 100644 pcsx2/RedtapeWindows.h create mode 100644 pcsx2/windows/WindowsPCH.cpp diff --git a/common/include/PS2Etypes.h b/common/include/PS2Etypes.h index f5c11d8d81..2fed163572 100644 --- a/common/include/PS2Etypes.h +++ b/common/include/PS2Etypes.h @@ -26,8 +26,9 @@ #define __LINUX__ #endif -#ifndef ARRAYSIZE -#define ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0])) +// Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air) +#ifndef ArraySize +#define ArraySize(x) (sizeof(x)/sizeof((x)[0])) #endif #ifdef __LINUX__ diff --git a/pcsx2/CDVD.cpp b/pcsx2/CDVD.cpp index 7b171ba648..d3024de674 100644 --- a/pcsx2/CDVD.cpp +++ b/pcsx2/CDVD.cpp @@ -2045,7 +2045,7 @@ void cdvdWrite16(u8 rt) // SCOMMAND break; case 0x8E: // sceMgReadData - SetResultSize( std::min(16, cdvd.mg_size) ); + SetResultSize( min(16, cdvd.mg_size) ); memcpy_fast(cdvd.Result, cdvd.mg_buffer, cdvd.ResultC); cdvd.mg_size -= cdvd.ResultC; memcpy_fast(cdvd.mg_buffer, cdvd.mg_buffer+cdvd.ResultC, cdvd.mg_size); diff --git a/pcsx2/Linux/LnxMain.cpp b/pcsx2/Linux/LnxMain.cpp index b2aeb30bd1..a027d4ccd8 100644 --- a/pcsx2/Linux/LnxMain.cpp +++ b/pcsx2/Linux/LnxMain.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) efile = 0; - getcwd(MAIN_DIR, ARRAYSIZE(MAIN_DIR)); /* store main dir */ + getcwd(MAIN_DIR, ArraySize(MAIN_DIR)); /* store main dir */ Console::Notice("MAIN_DIR is %s", params MAIN_DIR); #ifdef ENABLE_NLS setlocale(LC_ALL, ""); diff --git a/pcsx2/Linux/LnxSysExec.cpp b/pcsx2/Linux/LnxSysExec.cpp index 98b95183b9..d76d015fa1 100644 --- a/pcsx2/Linux/LnxSysExec.cpp +++ b/pcsx2/Linux/LnxSysExec.cpp @@ -920,3 +920,17 @@ void SysMunmap(uptr base, u32 size) munmap((uptr*)base, size); } +void SysMemProtect( void* baseaddr, size_t size, PageProtectionMode mode, bool allowExecution ) +{ + int lnxmode = 0; + + switch( mode ) + { + case Protect_NoAccess: break; + case Protect_ReadOnly: lnxmode = PROT_READ; break; + case Protect_ReadWrite: lnxmode = PROT_READ | PROT_WRITE; break; + } + + if( allowExecution ) lnxmode |= PROT_EXECUTE; + mprotect( baseaddr, size, lnxmode ); +} diff --git a/pcsx2/Linux/LnxThreads.cpp b/pcsx2/Linux/LnxThreads.cpp index b23ceccd45..a3c54ae136 100644 --- a/pcsx2/Linux/LnxThreads.cpp +++ b/pcsx2/Linux/LnxThreads.cpp @@ -52,6 +52,11 @@ namespace Threading usleep(500); } + __forceinline void Sleep( int ms ) + { + usleep( 1000*ms ); + } + // For use in spin/wait loops, Acts as a hint to Intel CPUs and should, in theory // improve performance and reduce cpu power consumption. __forceinline void SpinWait() @@ -60,7 +65,7 @@ namespace Threading // performance hint and isn't required). __asm__ ( "pause" ); } - + void* Thread::_internal_callback( void* itsme ) { jASSUME( itsme != NULL ); diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index c77eb10817..0ca6bec10e 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -449,7 +449,7 @@ void mtgsThreadObject::PostVsyncEnd( bool updategs ) m_QueuedFrames = 0; break; } - Sleep( 2 ); // Sleep off quite a bit of time, since we're obviously *waaay* ahead. + Threading::Sleep( 2 ); // Sleep off quite a bit of time, since we're obviously *waaay* ahead. SpinWait(); } diff --git a/pcsx2/Memory.cpp b/pcsx2/Memory.cpp index 4f59132239..d7f06ca2a4 100644 --- a/pcsx2/Memory.cpp +++ b/pcsx2/Memory.cpp @@ -126,7 +126,7 @@ void loadBiosRom( const char *ext, u8 *dest, long maxSize ) // if we made it this far, we have a successful file found: FILE *fp = fopen(Bios1.c_str(), "rb"); - fread(dest, 1, std::min( maxSize, filesize ), fp); + fread(dest, 1, min( maxSize, filesize ), fp); fclose(fp); } @@ -406,6 +406,7 @@ void __fastcall _ext_memWrite16(u32 mem, u16 value) MEM_LOG("Unknown Memory write16 to address %x with data %4.4x\n", mem, value); cpuTlbMissW(mem, cpuRegs.branch); } + template void __fastcall _ext_memWrite32(u32 mem, u32 value) { @@ -422,6 +423,7 @@ void __fastcall _ext_memWrite32(u32 mem, u32 value) MEM_LOG("Unknown Memory write32 to address %x with data %8.8x\n", mem, value); cpuTlbMissW(mem, cpuRegs.branch); } + template void __fastcall _ext_memWrite64(u32 mem, const u64* value) { @@ -437,6 +439,7 @@ void __fastcall _ext_memWrite64(u32 mem, const u64* value) MEM_LOG("Unknown Memory write64 to address %x with data %8.8x_%8.8x\n", mem, (u32)(*value>>32), (u32)*value); cpuTlbMissW(mem, cpuRegs.branch); } + template void __fastcall _ext_memWrite128(u32 mem, const u64 *value) { @@ -656,13 +659,7 @@ void memReset() { // VTLB Protection Preparations. -#ifdef _WIN32 - DWORD OldProtect; - // make sure can write - VirtualProtect(m_psAllMem, m_allMemSize, PAGE_READWRITE, &OldProtect); -#else - mprotect(m_psAllMem, m_allMemSize, PROT_READ|PROT_WRITE); -#endif + SysMemProtect( m_psAllMem, m_allMemSize, Protect_ReadWrite ); // Note!! Ideally the vtlb should only be initialized once, and then subsequent // resets of the system hardware would only clear vtlb mappings, but since the @@ -810,7 +807,7 @@ void memReset() } 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); BiosVersion = GetBiosVersion(); diff --git a/pcsx2/Memory.h b/pcsx2/Memory.h index 2e6b93f3bc..a6691eca47 100644 --- a/pcsx2/Memory.h +++ b/pcsx2/Memory.h @@ -16,10 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -////////// -// Rewritten by zerofrog to add os virtual memory -////////// - #ifndef __MEMORY_H__ #define __MEMORY_H__ @@ -144,8 +140,6 @@ extern void memMapVUmicro(); void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * ); void __fastcall InstallLinuxExceptionHandler(); void __fastcall ReleaseLinuxExceptionHandler(); -#else -int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps); #endif #include "vtlb.h" diff --git a/pcsx2/Misc.cpp b/pcsx2/Misc.cpp index 81ab5ee5fc..1e33000b31 100644 --- a/pcsx2/Misc.cpp +++ b/pcsx2/Misc.cpp @@ -659,26 +659,7 @@ void ProcessFKeys(int fkey, int shift) break; #ifdef PCSX2_DEVBUILD - case 10: - { - int num; - FILE* f; - BASEBLOCKEX** ppblocks = GetAllBaseBlocks(&num, 0); - - f = fopen("perflog.txt", "w"); - while(num-- > 0 ) { - if( ppblocks[0]->visited > 0 ) { - fprintf(f, "%u %u %u %u\n", ppblocks[0]->startpc, (u32)(ppblocks[0]->ltime.QuadPart / ppblocks[0]->visited), ppblocks[0]->visited, ppblocks[0]->size); - } - ppblocks[0]->visited = 0; - ppblocks[0]->ltime.QuadPart = 0; - ppblocks++; - } - fclose(f); - Console::Status( "perflog.txt written" ); - break; - } - + case 11: if( mtgsThread != NULL ) { Console::Notice( "Cannot make gsstates in MTGS mode" ); diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index d917f6392e..febddf850f 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -18,10 +18,6 @@ #ifndef __PATCH_H__ #define __PATCH_H__ -#ifdef _WIN32 -#include -#endif - #include "PS2Etypes.h" // diff --git a/pcsx2/PathUtils.cpp b/pcsx2/PathUtils.cpp index 85a49b8fa3..467e04526a 100644 --- a/pcsx2/PathUtils.cpp +++ b/pcsx2/PathUtils.cpp @@ -27,6 +27,8 @@ #ifndef _S_IFREG #define _S_IFREG S_IFREG #endif +#else +#include #endif namespace Path @@ -231,4 +233,15 @@ void GetRootDirectory( const string& src, string& dest ) else dest.assign( src.begin(), src.begin()+pos ); } + +void CreateDirectory( const string& src ) +{ +#ifdef _WIN32 + _mkdir( src.c_str() ); +#else + mkdir( src.c_str(), 0755); +#endif } + +} + diff --git a/pcsx2/Paths.h b/pcsx2/Paths.h index 2e94ac9edb..0a02896fa9 100644 --- a/pcsx2/Paths.h +++ b/pcsx2/Paths.h @@ -24,19 +24,21 @@ extern char MAIN_DIR[g_MaxPath]; namespace Path { - void Combine( std::string& dest, const std::string& srcPath, const std::string& srcFile ); - bool isRooted( const std::string& path ); - bool isDirectory( const std::string& path ); - bool isFile( const std::string& path ); - bool Exists( const std::string& path ); - int getFileSize( const std::string& path ); + extern void Combine( std::string& dest, const std::string& srcPath, const std::string& srcFile ); + extern bool isRooted( const std::string& path ); + extern bool isDirectory( const std::string& path ); + extern bool isFile( const std::string& path ); + extern bool Exists( const std::string& path ); + extern int getFileSize( const std::string& path ); - void ReplaceExtension( std::string& dest, const std::string& src, const std::string& ext ); - void ReplaceFilename( std::string& dest, const std::string& src, const std::string& newfilename ); - void GetFilename( const std::string& src, std::string& dest ); - void GetDirectory( const std::string& src, std::string& dest ); - void GetRootDirectory( const std::string& src, std::string& dest ); - void Split( const std::string& src, std::string& destpath, std::string& destfile ); + extern void ReplaceExtension( std::string& dest, const std::string& src, const std::string& ext ); + extern void ReplaceFilename( std::string& dest, const std::string& src, const std::string& newfilename ); + extern void GetFilename( 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 Split( const std::string& src, std::string& destpath, std::string& destfile ); + + extern void CreateDirectory( const std::string& src ); } diff --git a/pcsx2/Plugins.cpp b/pcsx2/Plugins.cpp index 239ddf9006..8764eaaa5b 100644 --- a/pcsx2/Plugins.cpp +++ b/pcsx2/Plugins.cpp @@ -17,6 +17,7 @@ */ #include "PrecompiledHeader.h" +#include "RedtapeWindows.h" #include "Common.h" #include "PsxCommon.h" @@ -48,7 +49,7 @@ _GSsetupRecording GSsetupRecording; _GSreset GSreset; _GSwriteCSR GSwriteCSR; _GSgetDriverInfo GSgetDriverInfo; -#ifdef _WIN32 +#ifdef _WINDOWS_ _GSsetWindowInfo GSsetWindowInfo; #endif _GSfreeze GSfreeze; diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index 9e966cc0f0..e94ffdbcb6 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -7,21 +7,6 @@ #ifndef _WIN32 # include -#else - -// For now Windows headers are needed by all modules, so include it here so -// that it compiles nice and fast... - -// Force availability of to WinNT APIs (change to 0x600 to enable XP-specific APIs) -# define WINVER 0x0501 -# define _WIN32_WINNT 0x0501 - -# include - -// disable Windows versions of min/max -- we'll use the typesafe STL versions instead. -#undef min -#undef max - #endif // Include the STL junk that's actually handy. @@ -59,6 +44,13 @@ using std::string; // we use it enough, so bring it into the global namespace. #include "PS2Etypes.h" #include "StringUtils.h" +typedef int BOOL; + +# undef TRUE +# undef FALSE +# define TRUE 1 +# define FALSE 0 + //////////////////////////////////////////////////////////////////// // Compiler/OS specific macros and defines -- Begin Section @@ -77,11 +69,6 @@ using std::string; // we use it enough, so bring it into the global namespace. # define __declspec(x) # endif -// functions that linux lacks... -// fixme: this should probably be in a __LINUX__ conditional rather than -// a GCC conditional (since GCC on a windows platform would have these functions) -# define Sleep(seconds) usleep(1000*(seconds)) - static __forceinline u32 timeGetTime() { struct timeb t; @@ -89,13 +76,6 @@ static __forceinline u32 timeGetTime() return (u32)(t.time*1000+t.millitm); } -# define BOOL int - -# undef TRUE -# undef FALSE -# define TRUE 1 -# define FALSE 0 - # ifndef strnicmp # define strnicmp strncasecmp # endif diff --git a/pcsx2/RDebug/deci2.h b/pcsx2/RDebug/deci2.h index fb1c93444c..05d545bdac 100644 --- a/pcsx2/RDebug/deci2.h +++ b/pcsx2/RDebug/deci2.h @@ -26,6 +26,8 @@ #include "deci2_netmp.h" #include "deci2_ttyp.h" +#include "Threading.h" + #define PROTO_DCMP 0x0001 #define PROTO_ITTYP 0x0110 #define PROTO_IDBGP 0x0130 @@ -58,9 +60,7 @@ extern int ebrk_count, ibrk_count; extern volatile long runStatus; extern int runCode, runCount; -#ifdef _WIN32 -extern HANDLE runEvent; //i don't like this; -#endif +extern Threading::Semaphore* runEvent; extern int connected; //when add linux code this might change diff --git a/pcsx2/RDebug/deci2_dbgp.cpp b/pcsx2/RDebug/deci2_dbgp.cpp index 0d5436fa53..7a38786ee4 100644 --- a/pcsx2/RDebug/deci2_dbgp.cpp +++ b/pcsx2/RDebug/deci2_dbgp.cpp @@ -379,9 +379,7 @@ void D2_DBGP(const u8 *inbuffer, u8 *outbuffer, char *message, char *eepc, char Sleep(100);//first get the run thread to Wait state runCount=in->count; runCode=in->code; -#ifdef _WIN32 - SetEvent(runEvent);//kick it -#endif + runEvent->Post();//kick it } break; case 0x18://ok [without argc/argv stuff] @@ -400,9 +398,7 @@ void D2_DBGP(const u8 *inbuffer, u8 *outbuffer, char *message, char *eepc, char Sleep(1000);//first get the run thread to Wait state runCount=0; runCode=0xFF; -#ifdef _WIN32 - SetEvent(runEvent);//awake it -#endif + runEvent->Post(); out->h.length=sizeof(DECI2_DBGP_HEADER); break; } diff --git a/pcsx2/RedtapeWindows.h b/pcsx2/RedtapeWindows.h new file mode 100644 index 0000000000..bb8fefd1ed --- /dev/null +++ b/pcsx2/RedtapeWindows.h @@ -0,0 +1,45 @@ +/* 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 +*/ + +////////////////////////////////////////////////////////////////////////////////////////// +// Windows Redtape! No windows.h should be included without it! +// +// This header's purpose is to include windows.h with the correct OS version info, and +// to undefine some of windows.h's more evil macros (min/max). It also does a _WIN32 +// check, so that we don't have to do it explicitly in every instance where it might +// be needed from non-Win32-specific files (ie, ix86_cpudetect.cpp) + +#ifndef _REDTAPE_WINDOWS_H_ +#define _REDTAPE_WINDOWS_H_ + +#ifdef _WIN32 + +// Force availability of to WinNT APIs (change to 0x600 to enable XP-specific APIs) +#ifndef WINVER +#define WINVER 0x0501 +#define _WIN32_WINNT 0x0501 +#endif + +#include + +// disable Windows versions of min/max -- we'll use the typesafe STL versions instead. +#undef min +#undef max + +#endif +#endif diff --git a/pcsx2/SamplProf.h b/pcsx2/SamplProf.h index 9949716c75..465318ac26 100644 --- a/pcsx2/SamplProf.h +++ b/pcsx2/SamplProf.h @@ -6,7 +6,7 @@ // The profiler does not have a Linux version yet. // So for now we turn it into duds for non-Win32 platforms. -#if !defined( _DEBUG ) && defined( WIN32 ) +#ifdef _WIN32 void ProfilerInit(); void ProfilerTerm(); diff --git a/pcsx2/System.h b/pcsx2/System.h index 188d152b13..4ea93f8de9 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -56,15 +56,23 @@ u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnamed"); // Unmaps a block allocated by SysMmap void SysMunmap(uptr base, u32 size); -// Writes text to the console. -// *DEPRECIATED* Use Console namespace methods instead. -void SysPrintf(const char *fmt, ...); // *DEPRECIATED* - static __forceinline void SysMunmap( void* base, u32 size ) { SysMunmap( (uptr)base, size ); } +enum PageProtectionMode +{ + Protect_NoAccess = 0, + Protect_ReadOnly, + Protect_ReadWrite +}; + +void SysMemProtect( void* baseaddr, size_t size, PageProtectionMode mode, bool allowExecution=false ); + +// Writes text to the console. +// *DEPRECIATED* Use Console namespace methods instead. +void SysPrintf(const char *fmt, ...); // *DEPRECIATED* #ifdef _MSC_VER # define PCSX2_MEM_PROTECT_BEGIN() __try { diff --git a/pcsx2/ThreadTools.cpp b/pcsx2/ThreadTools.cpp index da840de66a..47e1665faf 100644 --- a/pcsx2/ThreadTools.cpp +++ b/pcsx2/ThreadTools.cpp @@ -87,16 +87,23 @@ namespace Threading pthread_mutex_unlock( &mutex ); } #endif + Semaphore::Semaphore() { sem_init( &sema, false, 0 ); } - + Semaphore::~Semaphore() { sem_destroy( &sema ); } + void Semaphore::Reset() + { + sem_destroy( &sema ); + sem_init( &sema, false, 0 ); + } + void Semaphore::Post() { sem_post( &sema ); diff --git a/pcsx2/Threading.h b/pcsx2/Threading.h index 5b1f624b86..d0ed296574 100644 --- a/pcsx2/Threading.h +++ b/pcsx2/Threading.h @@ -49,6 +49,7 @@ namespace Threading Semaphore(); ~Semaphore(); + void Reset(); void Post(); void Post( int multiple ); void Wait(); @@ -75,6 +76,9 @@ namespace Threading // For use in spin/wait loops. extern void SpinWait(); + + // sleeps the current thread for the given number of milliseconds. + extern void Sleep( int ms ); class Thread : NoncopyableObject { diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index 6b6021b37b..ede54dbb5f 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -589,8 +589,7 @@ void vtlb_free( void* pmem, uint size ) SafeSysMunmap( pmem, size ); #else // Make sure and unprotect memory first, since CrtDebug will try to write to it. - DWORD old; - VirtualProtect( pmem, size, PAGE_READWRITE, &old ); + SysMemProtect( pmem, size, Protect_ReadWrite ); safe_aligned_free( pmem ); #endif } diff --git a/pcsx2/windows/AboutDlg.cpp b/pcsx2/windows/AboutDlg.cpp index 079f1bd581..f3b07f9efe 100644 --- a/pcsx2/windows/AboutDlg.cpp +++ b/pcsx2/windows/AboutDlg.cpp @@ -16,7 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "Win32.h" #include "AboutDlg.h" diff --git a/pcsx2/windows/AdvancedDlg.cpp b/pcsx2/windows/AdvancedDlg.cpp index 7823fd64c2..4e6b33a02b 100644 --- a/pcsx2/windows/AdvancedDlg.cpp +++ b/pcsx2/windows/AdvancedDlg.cpp @@ -16,8 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" - #include "Win32.h" #include "Common.h" diff --git a/pcsx2/windows/ConfigDlg.cpp b/pcsx2/windows/ConfigDlg.cpp index b6d1815b03..f833ea0dbb 100644 --- a/pcsx2/windows/ConfigDlg.cpp +++ b/pcsx2/windows/ConfigDlg.cpp @@ -16,13 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "Win32.h" #include #include "common.h" #include "plugins.h" -#include "resource.h" struct ComboInitializer { diff --git a/pcsx2/windows/CpuDlg.cpp b/pcsx2/windows/CpuDlg.cpp index af6327a8c9..dc4c97beff 100644 --- a/pcsx2/windows/CpuDlg.cpp +++ b/pcsx2/windows/CpuDlg.cpp @@ -16,7 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "Win32.h" #include "Common.h" diff --git a/pcsx2/windows/DebugMemory.cpp b/pcsx2/windows/DebugMemory.cpp index 0a3469b509..fdd9ab0867 100644 --- a/pcsx2/windows/DebugMemory.cpp +++ b/pcsx2/windows/DebugMemory.cpp @@ -16,8 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" - #include "Win32.h" #include "Common.h" #include "resource.h" diff --git a/pcsx2/windows/Debugger.cpp b/pcsx2/windows/Debugger.cpp index b9f4655e61..9b8d2c8f63 100644 --- a/pcsx2/windows/Debugger.cpp +++ b/pcsx2/windows/Debugger.cpp @@ -16,11 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" - #include "win32.h" -#include "resource.h" #include "R5900OpcodeTables.h" #include "Debugger.h" #include "Common.h" diff --git a/pcsx2/windows/Debugger.h b/pcsx2/windows/Debugger.h index 64226202db..8627ec6917 100644 --- a/pcsx2/windows/Debugger.h +++ b/pcsx2/windows/Debugger.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include "RedtapeWindows.h" #include #include diff --git a/pcsx2/windows/Debugreg.cpp b/pcsx2/windows/Debugreg.cpp index 752cd638c6..a50baf09ca 100644 --- a/pcsx2/windows/Debugreg.cpp +++ b/pcsx2/windows/Debugreg.cpp @@ -16,12 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "Win32.h" #include -#include "resource.h" #include "Debugger.h" #include "DebugTools/Debug.h" #include "R5900.h" diff --git a/pcsx2/windows/HacksDlg.cpp b/pcsx2/windows/HacksDlg.cpp index fd83f89288..045705f6bd 100644 --- a/pcsx2/windows/HacksDlg.cpp +++ b/pcsx2/windows/HacksDlg.cpp @@ -17,7 +17,6 @@ */ -#include "PrecompiledHeader.h" #include "win32.h" BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) diff --git a/pcsx2/windows/McdConfigDlg.cpp b/pcsx2/windows/McdConfigDlg.cpp index d334f11793..bd12435d9a 100644 --- a/pcsx2/windows/McdConfigDlg.cpp +++ b/pcsx2/windows/McdConfigDlg.cpp @@ -16,10 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "Win32.h" -#include #include #include "libintlmsc.h" diff --git a/pcsx2/windows/McdManagerDlg.cpp b/pcsx2/windows/McdManagerDlg.cpp index 20fbfbc5e9..0a808fb773 100644 --- a/pcsx2/windows/McdManagerDlg.cpp +++ b/pcsx2/windows/McdManagerDlg.cpp @@ -19,7 +19,6 @@ #include "PrecompiledHeader.h" #include "Win32.h" -#include #include #include "libintlmsc.h" diff --git a/pcsx2/windows/PatchBrowser.cpp b/pcsx2/windows/PatchBrowser.cpp index 59456b5ab8..0873d70345 100644 --- a/pcsx2/windows/PatchBrowser.cpp +++ b/pcsx2/windows/PatchBrowser.cpp @@ -16,8 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" - /************************** * * patchbrowser.c contains all the src of patchbrowser window diff --git a/pcsx2/windows/RDebugger.cpp b/pcsx2/windows/RDebugger.cpp index f3b5c491d8..8da4d9c8bb 100644 --- a/pcsx2/windows/RDebugger.cpp +++ b/pcsx2/windows/RDebugger.cpp @@ -16,10 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "Win32.h" -#include #include "Debugger.h" #include "RDebugger.h" #include "Common.h" @@ -32,7 +30,7 @@ char message[1024]; //message to add to listbox volatile long runStatus=STOP; int runCode=0, runCount=1; -HANDLE runEvent=NULL; +Threading::Semaphore* runEvent = NULL; DECI2_DBGP_BRK ebrk[32], ibrk[32]; @@ -254,8 +252,8 @@ DWORD WINAPI Run2(LPVOID lpParam){ else{ cpuRegs.CP0.n.EPC=cpuRegs.pc; psxRegs.CP0.n.EPC=psxRegs.pc; - ResetEvent(runEvent); - WaitForSingleObject(runEvent, INFINITE); + runEvent->Wait(); + //WaitForSingleObject(runEvent, INFINITE); runStatus=RUN; } } @@ -282,8 +280,8 @@ LRESULT WINAPI RemoteDebuggerProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP CREATE_SUSPENDED, &thid); runth=CreateThread(NULL, 0, Run2, (LPVOID)hDlg, CREATE_SUSPENDED, &thid); - runEvent=CreateEvent(NULL, TRUE, FALSE, "RunState"); - if (th==NULL || runth==NULL || runEvent==NULL){ + runEvent = new Threading::Semaphore(); + if (th==NULL || runth==NULL ){ MessageBox(hDlg, _("Could not create threads or event"), 0, MB_OK); connected=0; closesocket(serversocket); @@ -329,7 +327,7 @@ LRESULT WINAPI RemoteDebuggerProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP connected=0; CloseHandle(th); CloseHandle(runth); - CloseHandle(runEvent); + safe_delete( runEvent ); closesocket(serversocket); WSACleanup(); ClosePlugins( false ); diff --git a/pcsx2/windows/RDebugger.h b/pcsx2/windows/RDebugger.h index 8e5d8feb43..173c77922e 100644 --- a/pcsx2/windows/RDebugger.h +++ b/pcsx2/windows/RDebugger.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include "RedtapeWindows.h" #include #include diff --git a/pcsx2/windows/SamplProf.cpp b/pcsx2/windows/SamplProf.cpp index 41c44de87b..1067ceaf76 100644 --- a/pcsx2/windows/SamplProf.cpp +++ b/pcsx2/windows/SamplProf.cpp @@ -1,7 +1,5 @@ -#include "PrecompiledHeader.h" - -#ifndef _DEBUG +#include "Win32.h" #include "SamplProf.h" #include @@ -321,5 +319,3 @@ void ProfilerSetEnabled(bool Enabled) else SuspendThread(hProfThread); } - -#endif diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index 38f8cf1267..4d2ad2ab0b 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -277,6 +277,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -857,10 +1145,46 @@ + + + + + + + + + + + + - - @@ -2180,18 +2500,6 @@ /> - - - - - - @@ -2200,42 +2508,36 @@ RelativePath="..\..\Plugins.cpp" > - - - - - - + + + + + + - - - - - - @@ -2247,7 +2549,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#include "PrecompiledHeader.h" + #include #include @@ -27,6 +32,9 @@ #define COMPILEDATE __DATE__ +//Exception handler for the VTLB-based recompilers. +int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps); + // --->> Ini Configuration [ini.c] extern char g_WorkingFolder[g_MaxPath]; diff --git a/pcsx2/windows/WinConsole.cpp b/pcsx2/windows/WinConsole.cpp index c5bb0a2800..e09246a7fa 100644 --- a/pcsx2/windows/WinConsole.cpp +++ b/pcsx2/windows/WinConsole.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" +#include "Win32.h" #include "System.h" #include "DebugTools/Debug.h" diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index 4a4383c0ea..208abfe3dc 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -20,7 +20,6 @@ #include "win32.h" #include -#include #include #include diff --git a/pcsx2/windows/WinSysExec.cpp b/pcsx2/windows/WinSysExec.cpp index 786bd79a96..289d98d63f 100644 --- a/pcsx2/windows/WinSysExec.cpp +++ b/pcsx2/windows/WinSysExec.cpp @@ -16,11 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" -#include "win32.h" - +#include "Win32.h" #include -#include #include "Common.h" //#include "PsxCommon.h" @@ -833,15 +830,14 @@ const char *SysLibError() { return NULL; } -void SysCloseLibrary(void *lib) { +void SysCloseLibrary(void *lib) +{ FreeLibrary((HINSTANCE)lib); } -void *SysMmap(uptr base, u32 size) { - void *mem; - - mem = VirtualAlloc((void*)base, size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - return mem; +void *SysMmap(uptr base, u32 size) +{ + return VirtualAlloc((void*)base, size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); } void SysMunmap(uptr base, u32 size) @@ -850,3 +846,26 @@ void SysMunmap(uptr base, u32 size) VirtualFree((void*)base, size, MEM_DECOMMIT); VirtualFree((void*)base, 0, MEM_RELEASE); } + +void SysMemProtect( void* baseaddr, size_t size, PageProtectionMode mode, bool allowExecution ) +{ + DWORD winmode = 0; + + switch( mode ) + { + case Protect_NoAccess: + winmode = ( allowExecution ) ? PAGE_EXECUTE : PAGE_NOACCESS; + break; + + case Protect_ReadOnly: + winmode = ( allowExecution ) ? PAGE_EXECUTE_READ : PAGE_READONLY; + break; + + case Protect_ReadWrite: + winmode = ( allowExecution ) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; + break; + } + + DWORD OldProtect; // enjoy my uselessness, yo! + VirtualProtect( baseaddr, size, winmode, &OldProtect ); +} diff --git a/pcsx2/windows/WinThreads.cpp b/pcsx2/windows/WinThreads.cpp index f61d2d65c7..9e53802ca8 100644 --- a/pcsx2/windows/WinThreads.cpp +++ b/pcsx2/windows/WinThreads.cpp @@ -17,7 +17,7 @@ */ -#include "PrecompiledHeader.h" +#include "Win32.h" #include "System.h" #include "Threading.h" @@ -58,7 +58,12 @@ namespace Threading __forceinline void Timeslice() { - Sleep(0); + ::Sleep(0); + } + + __forceinline void Sleep( int ms ) + { + ::Sleep( 1000*ms ); } // For use in spin/wait loops, Acts as a hint to Intel CPUs and should, in theory diff --git a/pcsx2/windows/WindowsPCH.cpp b/pcsx2/windows/WindowsPCH.cpp new file mode 100644 index 0000000000..54b74097f6 --- /dev/null +++ b/pcsx2/windows/WindowsPCH.cpp @@ -0,0 +1 @@ +#include "Win32.h" \ No newline at end of file diff --git a/pcsx2/windows/cheats/browser.cpp b/pcsx2/windows/cheats/browser.cpp index bee02cf3a7..f92129853b 100644 --- a/pcsx2/windows/cheats/browser.cpp +++ b/pcsx2/windows/cheats/browser.cpp @@ -16,10 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "../Win32.h" -#include #include using namespace std; diff --git a/pcsx2/windows/cheats/cheats.cpp b/pcsx2/windows/cheats/cheats.cpp index 4b404345d1..c5a7f20d50 100644 --- a/pcsx2/windows/cheats/cheats.cpp +++ b/pcsx2/windows/cheats/cheats.cpp @@ -16,10 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "PrecompiledHeader.h" #include "../Win32.h" -#include #include #include "PS2Edefs.h" diff --git a/pcsx2/windows/ini.cpp b/pcsx2/windows/ini.cpp index f935721d20..371ebee88b 100644 --- a/pcsx2/windows/ini.cpp +++ b/pcsx2/windows/ini.cpp @@ -16,8 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "PrecompiledHeader.h" -#include "win32.h" +#include "Win32.h" #include "Common.h" #include "Paths.h" diff --git a/pcsx2/x86/BaseblockEx.h b/pcsx2/x86/BaseblockEx.h index 5b3757a97c..a67060f3dd 100644 --- a/pcsx2/x86/BaseblockEx.h +++ b/pcsx2/x86/BaseblockEx.h @@ -53,7 +53,7 @@ struct BASEBLOCKEX #ifdef PCSX2_DEVBUILD u32 visited; // number of times called - LARGE_INTEGER ltime; // regs it assumes to have set already + u64 ltime; // regs it assumes to have set already #endif }; diff --git a/pcsx2/x86/iCore.cpp b/pcsx2/x86/iCore.cpp index 1ed5598c5b..b2702a6b38 100644 --- a/pcsx2/x86/iCore.cpp +++ b/pcsx2/x86/iCore.cpp @@ -1076,7 +1076,7 @@ u32 _recIsRegWritten(EEINST* pinst, int size, u8 xmmtype, u8 reg) u32 i, inst = 1; while(size-- > 0) { - for(i = 0; i < ARRAYSIZE(pinst->writeType); ++i) { + for(i = 0; i < ArraySize(pinst->writeType); ++i) { if ((pinst->writeType[i] == xmmtype) && (pinst->writeReg[i] == reg)) return inst; } @@ -1091,11 +1091,11 @@ u32 _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg) { u32 i, inst = 1; while(size-- > 0) { - for(i = 0; i < ARRAYSIZE(pinst->writeType); ++i) { + for(i = 0; i < ArraySize(pinst->writeType); ++i) { if( pinst->writeType[i] == xmmtype && pinst->writeReg[i] == reg ) return inst; } - for(i = 0; i < ARRAYSIZE(pinst->readType); ++i) { + for(i = 0; i < ArraySize(pinst->readType); ++i) { if( pinst->readType[i] == xmmtype && pinst->readReg[i] == reg ) return inst; } @@ -1110,7 +1110,7 @@ void _recFillRegister(EEINST& pinst, int type, int reg, int write) { u32 i = 0; if (write ) { - for(i = 0; i < ARRAYSIZE(pinst.writeType); ++i) { + for(i = 0; i < ArraySize(pinst.writeType); ++i) { if( pinst.writeType[i] == XMMTYPE_TEMP ) { pinst.writeType[i] = type; pinst.writeReg[i] = reg; @@ -1120,7 +1120,7 @@ void _recFillRegister(EEINST& pinst, int type, int reg, int write) assert(0); } else { - for(i = 0; i < ARRAYSIZE(pinst.readType); ++i) { + for(i = 0; i < ArraySize(pinst.readType); ++i) { if( pinst.readType[i] == XMMTYPE_TEMP ) { pinst.readType[i] = type; pinst.readReg[i] = reg; diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index 9fce22bfe9..125f9c93ad 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -164,7 +164,7 @@ static void iIopDumpBlock( int startpc, u8 * ptr ) memzero_obj(used); numused = 0; - for(i = 0; i < ARRAYSIZE(s_pInstCache->regs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->regs); ++i) { if( s_pInstCache->regs[i] & EEINST_USED ) { used[i] = 1; numused++; @@ -172,13 +172,13 @@ static void iIopDumpBlock( int startpc, u8 * ptr ) } fprintf(f, " "); - for(i = 0; i < ARRAYSIZE(s_pInstCache->regs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->regs); ++i) { if( used[i] ) fprintf(f, "%2d ", i); } fprintf(f, "\n"); fprintf(f, " "); - for(i = 0; i < ARRAYSIZE(s_pInstCache->regs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->regs); ++i) { if( used[i] ) fprintf(f, "%s ", disRNameGPR[i]); } fprintf(f, "\n"); @@ -188,7 +188,7 @@ static void iIopDumpBlock( int startpc, u8 * ptr ) fprintf(f, "%2d: %2.2x ", i+1, pcur->info); count = 1; - for(j = 0; j < ARRAYSIZE(s_pInstCache->regs); j++) { + for(j = 0; j < ArraySize(s_pInstCache->regs); j++) { if( used[j] ) { fprintf(f, "%2.2x%s", pcur->regs[j], ((count%8)&&count& blocks, int vuindex) { FILE *f; - char filename[ g_MaxPath ], str[256]; + string filename; + char str[256]; u32 *mem; u32 i; -#ifdef _WIN32 - CreateDirectory("dumps", NULL); - sprintf_s( filename, g_MaxPath, "dumps\\svu%c_%.4X.txt", s_vu?'1':'0', s_pFnHeader->startpc ); -#else - mkdir("dumps", 0755); - sprintf( filename, "dumps/svu%c_%.4X.txt", s_vu?'1':'0', s_pFnHeader->startpc ); -#endif + Path::CreateDirectory( "dumps" ); + ssprintf( filename, "dumps\\svu%cdump%.4X.txt", s_vu?'0':'1', s_pFnHeader->startpc ); + //SysPrintf( "dump1 %x => %s\n", s_pFnHeader->startpc, filename ); - f = fopen( filename, "w" ); + f = fopen( filename.c_str(), "w" ); fprintf(f, "Format: upper_inst lower_inst\ntype f:vf_live_vars vf_used_vars i:vi_live_vars vi_used_vars inst_cycle pq_inst\n"); fprintf(f, "Type: %.2x - qread, %.2x - pread, %.2x - clip_write, %.2x - status_write\n" @@ -649,9 +646,6 @@ void SuperVUDumpBlock(list& blocks, int vuindex) fclose( f ); } -LARGE_INTEGER svubase, svufinal; -static u64 svutime; - // uncomment to count svu exec time //#define SUPERVU_COUNT @@ -2319,9 +2313,6 @@ void SuperVUCleanupProgram(u32 startpc, int vuindex) // entry point of all vu programs from emulator calls __declspec(naked) void SuperVUExecuteProgram(u32 startpc, int vuindex) { -#ifdef SUPERVU_COUNT - QueryPerformanceCounter(&svubase); -#endif __asm { mov eax, dword ptr [esp] mov s_TotalVUCycles, 0 // necessary to be here! @@ -2457,7 +2448,7 @@ static void SuperVURecompile() FORIT(itblock, s_listBlocks) { VuBaseBlock::LISTBLOCKS::iterator itchild; - assert( (*itblock)->blocks.size() <= ARRAYSIZE((*itblock)->pChildJumps) ); + assert( (*itblock)->blocks.size() <= ArraySize((*itblock)->pChildJumps) ); int i = 0; FORIT(itchild, (*itblock)->blocks) { @@ -2537,12 +2528,12 @@ void svudispfntemp() if( ((vudump&8) && g_curdebugvu) || ((vudump&0x80) && !g_curdebugvu) ) { //&& g_vu1lastrec != g_vu1last ) { if( skipparent != g_vu1lastrec ) { - for(i = 0; i < ARRAYSIZE(badaddrs); ++i) { + for(i = 0; i < ArraySize(badaddrs); ++i) { if( s_svulast == badaddrs[i][1] && g_vu1lastrec == badaddrs[i][0] ) break; } - if( i == ARRAYSIZE(badaddrs) ) + if( i == ArraySize(badaddrs) ) { //static int curesp; //__asm mov curesp, esp @@ -3882,19 +3873,6 @@ void recVUMI_JALR( VURegs* vuu, s32 info ) branch |= 4; } -#ifdef SUPERVU_COUNT -void StopSVUCounter() -{ - QueryPerformanceCounter(&svufinal); - svutime += (u32)(svufinal.QuadPart-svubase.QuadPart); -} - -void StartSVUCounter() -{ - QueryPerformanceCounter(&svubase); -} -#endif - #ifdef PCSX2_DEVBUILD void vu1xgkick(u32* pMem, u32 addr) { diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 6e31a17ae3..77685e387f 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -42,6 +42,7 @@ #include "vtlb.h" #include "SamplProf.h" +#include "Paths.h" using namespace R5900; @@ -135,7 +136,7 @@ BASEBLOCKEX* PC_GETBLOCKEX(BASEBLOCK* p) static void iDumpBlock( int startpc, u8 * ptr ) { FILE *f; - char filename[ g_MaxPath ]; + string filename; u32 i, j; EEINST* pcur; u8 used[34]; @@ -143,13 +144,8 @@ static void iDumpBlock( int startpc, u8 * ptr ) int numused, count, fpunumused; Console::Status( "dump1 %x:%x, %x", params startpc, pc, cpuRegs.cycle ); -#ifdef _WIN32 - CreateDirectory("dumps", NULL); - sprintf_s( filename, g_MaxPath, "dumps\\dump%.8X.txt", startpc); -#else - mkdir("dumps", 0755); - sprintf( filename, "dumps/dump%.8X.txt", startpc); -#endif + Path::CreateDirectory( "dumps" ); + ssprintf( filename, "dumps\\R5900dump%.8X.txt", startpc ); fflush( stdout ); // f = fopen( "dump1", "wb" ); @@ -159,7 +155,7 @@ static void iDumpBlock( int startpc, u8 * ptr ) // sprintf( command, "objdump -D --target=binary --architecture=i386 dump1 > %s", filename ); // system( command ); - f = fopen( filename, "w" ); + f = fopen( filename.c_str(), "w" ); std::string output; @@ -177,7 +173,7 @@ static void iDumpBlock( int startpc, u8 * ptr ) memzero_obj(used); numused = 0; - for(i = 0; i < ARRAYSIZE(s_pInstCache->regs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->regs); ++i) { if( s_pInstCache->regs[i] & EEINST_USED ) { used[i] = 1; numused++; @@ -186,7 +182,7 @@ static void iDumpBlock( int startpc, u8 * ptr ) memzero_obj(fpuused); fpunumused = 0; - for(i = 0; i < ARRAYSIZE(s_pInstCache->fpuregs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) { if( s_pInstCache->fpuregs[i] & EEINST_USED ) { fpuused[i] = 1; fpunumused++; @@ -194,19 +190,19 @@ static void iDumpBlock( int startpc, u8 * ptr ) } fprintf(f, " "); - for(i = 0; i < ARRAYSIZE(s_pInstCache->regs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->regs); ++i) { if( used[i] ) fprintf(f, "%2d ", i); } - for(i = 0; i < ARRAYSIZE(s_pInstCache->fpuregs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) { if( fpuused[i] ) fprintf(f, "%2d ", i); } fprintf(f, "\n"); fprintf(f, " "); - for(i = 0; i < ARRAYSIZE(s_pInstCache->regs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->regs); ++i) { if( used[i] ) fprintf(f, "%s ", disRNameGPR[i]); } - for(i = 0; i < ARRAYSIZE(s_pInstCache->fpuregs); ++i) { + for(i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) { if( fpuused[i] ) fprintf(f, "%s ", i<32?"FR":"FA"); } fprintf(f, "\n"); @@ -216,14 +212,14 @@ static void iDumpBlock( int startpc, u8 * ptr ) fprintf(f, "%2d: %2.2x ", i+1, pcur->info); count = 1; - for(j = 0; j < ARRAYSIZE(s_pInstCache->regs); j++) { + for(j = 0; j < ArraySize(s_pInstCache->regs); j++) { if( used[j] ) { fprintf(f, "%2.2x%s", pcur->regs[j], ((count%8)&&countfpuregs); j++) { + for(j = 0; j < ArraySize(s_pInstCache->fpuregs); j++) { if( fpuused[j] ) { fprintf(f, "%2.2x%s", pcur->fpuregs[j], ((count%8)&&count= 1400 extern "C" diff --git a/pcsx2/x86/ix86/ix86_tools.cpp b/pcsx2/x86/ix86/ix86_tools.cpp index 42c9541fe4..6902e98424 100644 --- a/pcsx2/x86/ix86/ix86_tools.cpp +++ b/pcsx2/x86/ix86/ix86_tools.cpp @@ -30,10 +30,6 @@ u8 g_globalXMMSaved = 0; PCSX2_ALIGNED16( static u64 g_globalMMXData[8] ); PCSX2_ALIGNED16( static u64 g_globalXMMData[2*XMMREGS] ); -// performance counter vars. -LARGE_INTEGER lbase = {0}, lfinal = {0}; -u32 s_pCurBlock_ltime; - ///////////////////////////////////////////////////////////////////// // SetCPUState -- for assugnment of SSE roundmodes and clampmodes. @@ -228,48 +224,3 @@ __forceinline void FreezeXMMRegs_(int save) #endif // _MSC_VER } } - -#ifdef PCSX2_DEVBUILD -#ifdef _WIN32 -__declspec(naked) void _StartPerfCounter() -{ - __asm { - push eax - push ebx - push ecx - - rdtsc - mov dword ptr [offset lbase], eax - mov dword ptr [offset lbase + 4], edx - - pop ecx - pop ebx - pop eax - ret - } -} - -__declspec(naked) void _StopPerfCounter() -{ - __asm { - push eax - push ebx - push ecx - - rdtsc - - sub eax, dword ptr [offset lbase] - sbb edx, dword ptr [offset lbase + 4] - mov ecx, s_pCurBlock_ltime - add eax, dword ptr [ecx] - adc edx, dword ptr [ecx + 4] - mov dword ptr [ecx], eax - mov dword ptr [ecx + 4], edx - pop ecx - pop ebx - pop eax - ret - } -} -#endif // WIN32 -#endif // PCSX2_DEVBUILD \ No newline at end of file diff --git a/pcsx2/xmlpatchloader.cpp b/pcsx2/xmlpatchloader.cpp index 82149887a5..33e28f28b2 100644 --- a/pcsx2/xmlpatchloader.cpp +++ b/pcsx2/xmlpatchloader.cpp @@ -28,10 +28,6 @@ using namespace std; #pragma warning(disable:4996) //ignore the stricmp deprecated warning #endif -#ifdef _WIN32 -#include -#endif - #if !defined(_WIN32) #ifndef strnicmp #define strnicmp strncasecmp diff --git a/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj b/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj index 945590d44c..e562c033a3 100644 --- a/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj +++ b/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj @@ -84,7 +84,6 @@ AdditionalDependencies="winmm.lib dsound.lib comctl32.lib soundtouch.lib" OutputFile="$(OutDir)\$(ProjectName)-dev.dll" LinkIncremental="1" - SuppressStartupBanner="true" GenerateManifest="true" ModuleDefinitionFile=".\Spu2-X.def" GenerateDebugInformation="true" @@ -176,7 +175,6 @@ AdditionalDependencies="winmm.lib dsound.lib comctl32.lib soundtouch.lib" OutputFile="$(OutDir)\$(ProjectName)-dbg.dll" LinkIncremental="2" - SuppressStartupBanner="true" ModuleDefinitionFile=".\Spu2-X.def" GenerateDebugInformation="true" RandomizedBaseAddress="1" @@ -275,7 +273,6 @@ AdditionalDependencies="winmm.lib dsound.lib comctl32.lib soundtouch.lib" OutputFile="$(OutDir)\$(ProjectName).dll" LinkIncremental="1" - SuppressStartupBanner="true" ModuleDefinitionFile=".\Spu2-X.def" GenerateDebugInformation="true" ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb" @@ -372,7 +369,6 @@ AdditionalDependencies="winmm.lib dsound.lib comctl32.lib soundtouch.lib" OutputFile="$(OutDir)\$(ProjectName)-dbg.dll" LinkIncremental="2" - SuppressStartupBanner="true" ModuleDefinitionFile=".\Spu2-X.def" GenerateDebugInformation="true" RandomizedBaseAddress="1" diff --git a/plugins/zerogs/dx/Regs.cpp b/plugins/zerogs/dx/Regs.cpp index 2ae3b8e464..7f4673a5e6 100644 --- a/plugins/zerogs/dx/Regs.cpp +++ b/plugins/zerogs/dx/Regs.cpp @@ -124,7 +124,7 @@ void __forceinline KICK_VERTEX3() { /* tri fans need special processing */ if (gs.nTriFanVert == gs.primIndex) - gs.primIndex = (gs.primIndex+1) % ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1) % ArraySize(gs.gsvertex); } } } @@ -136,7 +136,7 @@ void __fastcall GIFPackedRegHandlerXYZF2(u32* data) gs.vertexregs.z = (data[2] >> 4) & 0xffffff; gs.vertexregs.f = (data[3] >> 4) & 0xff; gs.gsvertex[gs.primIndex] = gs.vertexregs; - gs.primIndex = (gs.primIndex+1) % ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1) % ArraySize(gs.gsvertex); if( data[3] & 0x8000 ) { KICK_VERTEX3(); @@ -152,7 +152,7 @@ void __fastcall GIFPackedRegHandlerXYZ2(u32* data) gs.vertexregs.y = (data[1] >> 0) & 0xffff; gs.vertexregs.z = data[2]; gs.gsvertex[gs.primIndex] = gs.vertexregs; - gs.primIndex = (gs.primIndex+1) % ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1) % ArraySize(gs.gsvertex); if( data[3] & 0x8000 ) { KICK_VERTEX3(); @@ -420,7 +420,7 @@ void __fastcall GIFRegHandlerXYZF2(u32* data) gs.vertexregs.z = data[1] & 0xffffff; gs.vertexregs.f = data[1] >> 24; gs.gsvertex[gs.primIndex] = gs.vertexregs; - gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1)%ArraySize(gs.gsvertex); KICK_VERTEX2(); } @@ -431,7 +431,7 @@ void __fastcall GIFRegHandlerXYZ2(u32* data) gs.vertexregs.y = (data[0] >> (16)) & 0xffff; gs.vertexregs.z = data[1]; gs.gsvertex[gs.primIndex] = gs.vertexregs; - gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1)%ArraySize(gs.gsvertex); KICK_VERTEX2(); } @@ -481,7 +481,7 @@ void __fastcall GIFRegHandlerXYZF3(u32* data) gs.vertexregs.z = data[1] & 0xffffff; gs.vertexregs.f = data[1] >> 24; gs.gsvertex[gs.primIndex] = gs.vertexregs; - gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1)%ArraySize(gs.gsvertex); KICK_VERTEX3(); } @@ -492,7 +492,7 @@ void __fastcall GIFRegHandlerXYZ3(u32* data) gs.vertexregs.y = (data[0] >> (16)) & 0xffff; gs.vertexregs.z = data[1]; gs.gsvertex[gs.primIndex] = gs.vertexregs; - gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1)%ArraySize(gs.gsvertex); KICK_VERTEX3(); } diff --git a/plugins/zerogs/dx/zerogs.cpp b/plugins/zerogs/dx/zerogs.cpp index a138928da3..af7ffadfa6 100644 --- a/plugins/zerogs/dx/zerogs.cpp +++ b/plugins/zerogs/dx/zerogs.cpp @@ -1055,13 +1055,13 @@ void ZeroGS::Destroy(BOOL bD3D) vb[0].Destroy(); vb[1].Destroy(); - for(int i = 0; i < ARRAYSIZE(pvs); ++i) { + for(int i = 0; i < ArraySize(pvs); ++i) { SAFE_RELEASE(pvs[i]); } - for(int i = 0; i < ARRAYSIZE(ppsRegular); ++i) { + for(int i = 0; i < ArraySize(ppsRegular); ++i) { SAFE_RELEASE(ppsRegular[i]); } - for(int i = 0; i < ARRAYSIZE(ppsTexture); ++i) { + for(int i = 0; i < ArraySize(ppsTexture); ++i) { SAFE_RELEASE(ppsTexture[i]); } @@ -1279,7 +1279,7 @@ HRESULT ZeroGS::LoadEffects() } // clear the textures - for(int i = 0; i < ARRAYSIZE(ppsTexture); ++i) { + for(int i = 0; i < ArraySize(ppsTexture); ++i) { SAFE_RELEASE(ppsTexture[i]); } memset(ppsTexture, 0, sizeof(ppsTexture)); @@ -1351,7 +1351,7 @@ LPD3DPS ZeroGS::LoadShadeEffect(int type, int texfilter, int fog, int testaem, i int index = GET_SHADER_INDEX(type, texfilter, texwrap, fog, s_bWriteDepth, testaem, exactcolor, context, 0); - assert( index < ARRAYSIZE(ppsTexture) ); + assert( index < ArraySize(ppsTexture) ); LPD3DPS* pps = ppsTexture+index; if( *pps != NULL ) @@ -1461,7 +1461,7 @@ public: HRESULT ZeroGS::LoadEffects() { // clear the textures - for(int i = 0; i < ARRAYSIZE(ppsTexture); ++i) { + for(int i = 0; i < ArraySize(ppsTexture); ++i) { SAFE_RELEASE(ppsTexture[i]); } memset(ppsTexture, 0, sizeof(ppsTexture)); @@ -1790,7 +1790,7 @@ int GetTexFilter(const tex1Info& tex1) void ZeroGS::ReloadEffects() { #ifndef RELEASE_TO_PUBLIC - for(int i = 0; i < ARRAYSIZE(ppsTexture); ++i) { + for(int i = 0; i < ArraySize(ppsTexture); ++i) { SAFE_RELEASE(ppsTexture[i]); } memset(ppsTexture, 0, sizeof(ppsTexture)); @@ -3457,12 +3457,12 @@ void ZeroGS::RenderCRTC(int interlace) if( g_GameSettings & GAME_AUTORESET ) { s_nResolveCounts[s_nCurResolveIndex] = s_nResolved; - s_nCurResolveIndex = (s_nCurResolveIndex+1)%ARRAYSIZE(s_nResolveCounts); + s_nCurResolveIndex = (s_nCurResolveIndex+1)%ArraySize(s_nResolveCounts); int total = 0; - for(int i = 0; i < ARRAYSIZE(s_nResolveCounts); ++i) total += s_nResolveCounts[i]; + for(int i = 0; i < ArraySize(s_nResolveCounts); ++i) total += s_nResolveCounts[i]; - if( total / ARRAYSIZE(s_nResolveCounts) > 3 ) { + if( total / ArraySize(s_nResolveCounts) > 3 ) { if( s_nLastResolveReset > (int)(fFPS * 8) ) { // reset DEBUG_LOG("ZeroGS: video mem reset\n"); @@ -3566,7 +3566,7 @@ void ZeroGS::KickPoint() Flush(prim->ctxt); curvb.Lock(); - int last = (gs.primIndex+2)%ARRAYSIZE(gs.gsvertex); + int last = (gs.primIndex+2)%ArraySize(gs.gsvertex); VertexGPU* p = curvb.pbuf+curvb.dwCount; SET_VERTEX(&p[0], last, curvb); @@ -3594,8 +3594,8 @@ void ZeroGS::KickLine() Flush(prim->ctxt); curvb.Lock(); - int next = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); - int last = (gs.primIndex+2)%ARRAYSIZE(gs.gsvertex); + int next = (gs.primIndex+1)%ArraySize(gs.gsvertex); + int last = (gs.primIndex+2)%ArraySize(gs.gsvertex); VertexGPU* p = curvb.pbuf+curvb.dwCount*2; SET_VERTEX(&p[0], next, curvb); @@ -3664,7 +3664,7 @@ void ZeroGS::KickTriangleFan() // add 1 to skip the first vertex if( gs.primIndex == gs.nTriFanVert ) - gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); + gs.primIndex = (gs.primIndex+1)%ArraySize(gs.gsvertex); #ifdef PRIM_LOG OUTPUT_VERT(PRIM_LOG, p[0], 0); @@ -3696,8 +3696,8 @@ void ZeroGS::KickSprite() if (curvb.dwCount >= POINT_BUFFERFLUSH/3) Flush(prim->ctxt); curvb.Lock(); - int next = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); - int last = (gs.primIndex+2)%ARRAYSIZE(gs.gsvertex); + int next = (gs.primIndex+1)%ArraySize(gs.gsvertex); + int last = (gs.primIndex+2)%ArraySize(gs.gsvertex); // sprite is too small and AA shows lines (tek4) if( s_AAx ) diff --git a/plugins/zerogs/dx/zerogs.h b/plugins/zerogs/dx/zerogs.h index c4fc3c86b5..1104b329c2 100644 --- a/plugins/zerogs/dx/zerogs.h +++ b/plugins/zerogs/dx/zerogs.h @@ -74,8 +74,8 @@ typedef D3DXMATRIX DXMAT; #endif #define SETRS(state, val) pd3dDevice->SetRenderState(state, val) -#ifndef ARRAYSIZE -#define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0])) +#ifndef ArraySize +#define ArraySize(x) (sizeof(x) / sizeof((x)[0])) #endif // all textures have this width diff --git a/plugins/zerospu2/zerospu2.cpp b/plugins/zerospu2/zerospu2.cpp index bd5aeb1f0a..337b7828b8 100644 --- a/plugins/zerospu2/zerospu2.cpp +++ b/plugins/zerospu2/zerospu2.cpp @@ -243,7 +243,7 @@ s32 CALLBACK SPU2init() voices[i+24].memoffset = 0x400; // init each channel - for (u32 i = 0; i < ARRAYSIZE(voices); ++i) { + for (u32 i = 0; i < ArraySize(voices); ++i) { voices[i].chanid = i; voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem; @@ -294,7 +294,7 @@ s32 CALLBACK SPU2open(void *pDsp) if ( g_bPlaySound ) { // initialize the audio buffers - for (u32 i = 0; i < ARRAYSIZE(s_pAudioBuffers); ++i) + for (u32 i = 0; i < ArraySize(s_pAudioBuffers); ++i) { s_pAudioBuffers[i].pbuf = (u8*)_aligned_malloc(4*NSSIZE*NSFRAMES, 16); // 4 bytes for each sample s_pAudioBuffers[i].len = 0; @@ -305,11 +305,11 @@ s32 CALLBACK SPU2open(void *pDsp) s_pCurOutput = (s16*)s_pAudioBuffers[0].pbuf; assert( s_pCurOutput != NULL); - for (int i = 0; i < ARRAYSIZE(s_nDurations); ++i) + for (int i = 0; i < ArraySize(s_nDurations); ++i) { s_nDurations[i] = NSFRAMES*1000; } - s_nTotalDuration = ARRAYSIZE(s_nDurations)*NSFRAMES*1000; + s_nTotalDuration = ArraySize(s_nDurations)*NSFRAMES*1000; s_nCurDuration = 0; // launch the thread @@ -355,7 +355,7 @@ void CALLBACK SPU2close() delete g_pWavRecord; g_pWavRecord = NULL; delete pSoundTouch; pSoundTouch = NULL; - for (u32 i = 0; i < ARRAYSIZE(s_pAudioBuffers); ++i) + for (u32 i = 0; i < ArraySize(s_pAudioBuffers); ++i) { _aligned_free(s_pAudioBuffers[i].pbuf); } @@ -793,7 +793,7 @@ ENDX: LogRawSound(s_pAudioBuffers[s_nCurBuffer].pbuf, 4, s_pAudioBuffers[s_nCurBuffer].pbuf+2, 4, NSSIZE*NSFRAMES); } - if ( s_nQueuedBuffers >= ARRAYSIZE(s_pAudioBuffers)-1 ) + if ( s_nQueuedBuffers >= ArraySize(s_pAudioBuffers)-1 ) { //ZeroSPU2: dropping packets! game too fast s_nDropPacket += NSFRAMES; @@ -820,16 +820,16 @@ ENDX: u32 duration = (u32)(newtime-s_GlobalTimeStamp); s_nDurations[s_nCurDuration] = duration; s_nTotalDuration = newtotal + duration; - s_nCurDuration = (s_nCurDuration+1)%ARRAYSIZE(s_nDurations); + s_nCurDuration = (s_nCurDuration+1)%ArraySize(s_nDurations); s_GlobalTimeStamp = newtime; s_pAudioBuffers[s_nCurBuffer].timestamp = timeGetTime(); - s_pAudioBuffers[s_nCurBuffer].avgtime = s_nTotalDuration/ARRAYSIZE(s_nDurations); + s_pAudioBuffers[s_nCurBuffer].avgtime = s_nTotalDuration/ArraySize(s_nDurations); } s_pAudioBuffers[s_nCurBuffer].len = 4*NSSIZE*NSFRAMES; InterlockedExchangeAdd((long*)&s_nQueuedBuffers, 1); - s_nCurBuffer = (s_nCurBuffer+1)%ARRAYSIZE(s_pAudioBuffers); + s_nCurBuffer = (s_nCurBuffer+1)%ArraySize(s_pAudioBuffers); s_pAudioBuffers[s_nCurBuffer].newchannels = 0; // reset } @@ -959,7 +959,7 @@ void* SPU2ThreadProc(void* lpParam) SoundFeedVoiceData(s_pAudioBuffers[nReadBuf].pbuf, s_pAudioBuffers[nReadBuf].len); // don't go to the next buffer unless there is more data buffered - nReadBuf = (nReadBuf+1)%ARRAYSIZE(s_pAudioBuffers); + nReadBuf = (nReadBuf+1)%ArraySize(s_pAudioBuffers); InterlockedExchangeAdd((long*)&s_nQueuedBuffers, -1); if ( s_bThreadExit ) break; @@ -1493,16 +1493,16 @@ void save_data(freezeData *data) memcpy(spud->SPUStartCycle, SPUStartCycle, sizeof(SPUStartCycle)); memcpy(spud->SPUTargetCycle, SPUTargetCycle, sizeof(SPUTargetCycle)); - for (i = 0; i < ARRAYSIZE(s_nDurations); ++i) + for (i = 0; i < ArraySize(s_nDurations); ++i) { s_nDurations[i] = NSFRAMES*1000; } - s_nTotalDuration = ARRAYSIZE(s_nDurations)*NSFRAMES*1000; + s_nTotalDuration = ArraySize(s_nDurations)*NSFRAMES*1000; s_nCurDuration = 0; spud->voicesize = SPU_VOICE_STATE_SIZE; - for (i = 0; i < ARRAYSIZE(voices); ++i) + for (i = 0; i < ArraySize(voices); ++i) { memcpy(&spud->voices[i], &voices[i], SPU_VOICE_STATE_SIZE); spud->voices[i].pStart = (u8*)((uptr)voices[i].pStart-(uptr)spu2mem); @@ -1554,7 +1554,7 @@ void load_data(freezeData *data) memcpy(SPUStartCycle, spud->SPUStartCycle, sizeof(SPUStartCycle)); memcpy(SPUTargetCycle, spud->SPUTargetCycle, sizeof(SPUTargetCycle)); - for (i = 0; i < ARRAYSIZE(voices); ++i) + for (i = 0; i < ArraySize(voices); ++i) { memcpy(&voices[i], &spud->voices[i], min((int)SPU_VOICE_STATE_SIZE, spud->voicesize)); voices[i].pStart = (u8*)((uptr)spud->voices[i].pStart+(uptr)spu2mem); @@ -1565,12 +1565,12 @@ void load_data(freezeData *data) s_GlobalTimeStamp = 0; g_startcount = 0xffffffff; - for (int i = 0; i < ARRAYSIZE(s_nDurations); ++i) + for (int i = 0; i < ArraySize(s_nDurations); ++i) { s_nDurations[i] = NSFRAMES*1000; } - s_nTotalDuration = ARRAYSIZE(s_nDurations)*NSFRAMES*1000; + s_nTotalDuration = ArraySize(s_nDurations)*NSFRAMES*1000; s_nCurDuration = 0; s_nQueuedBuffers = 0; s_nDropPacket = 0;