diff --git a/plugins/spu2-x/src/Config.h b/plugins/spu2-x/src/Config.h index 05287e5389..9a19f99a65 100644 --- a/plugins/spu2-x/src/Config.h +++ b/plugins/spu2-x/src/Config.h @@ -52,14 +52,12 @@ static __forceinline bool CoresDump() { return _CoresDump & DebugEnabled; } static __forceinline bool MemDump() { return _MemDump & DebugEnabled; } static __forceinline bool RegDump() { return _RegDump & DebugEnabled; } - -extern wchar_t AccessLogFileName[255]; -extern wchar_t WaveLogFileName[255]; -extern wchar_t DMA4LogFileName[255]; -extern wchar_t DMA7LogFileName[255]; -extern wchar_t CoresDumpFileName[255]; -extern wchar_t MemDumpFileName[255]; -extern wchar_t RegDumpFileName[255]; +extern wxString AccessLogFileName; +extern wxString DMA4LogFileName; +extern wxString DMA7LogFileName; +extern wxString CoresDumpFileName; +extern wxString MemDumpFileName; +extern wxString RegDumpFileName; extern int Interpolation; extern int ReverbBoost; diff --git a/plugins/spu2-x/src/ConvertUTF.cpp b/plugins/spu2-x/src/ConvertUTF.cpp deleted file mode 100644 index fd5e089b93..0000000000 --- a/plugins/spu2-x/src/ConvertUTF.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Source code file. - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Sept 2001: fixed const & error conditions per - mods suggested by S. Parent & A. Lillich. - June 2002: Tim Dodd added detection and handling of incomplete - source sequences, enhanced error detection, added casts - to eliminate compiler warnings. - July 2003: slight mods to back out aggressive FFFE detection. - Jan 2004: updated switches in from-UTF8 conversions. - Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. - - See the header file "ConvertUTF.h" for complete documentation. - ------------------------------------------------------------------------- */ - -#include "Global.h" -#include "ConvertUTF.h" - -using std::string; -using std::wstring; - - -#ifdef CVTUTF_DEBUG -#include -#endif - -namespace Unicode -{ - /* Some fundamental constants */ - #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD - #define UNI_MAX_BMP (UTF32)0x0000FFFF - #define UNI_MAX_UTF16 (UTF32)0x0010FFFF - #define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF - #define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF - - #define UNI_SUR_HIGH_START (UTF32)0xD800 - #define UNI_SUR_HIGH_END (UTF32)0xDBFF - #define UNI_SUR_LOW_START (UTF32)0xDC00 - #define UNI_SUR_LOW_END (UTF32)0xDFFF - - static const int halfShift = 10; /* used for shifting by 10 bits */ - - static const UTF32 halfBase = 0x0010000UL; - static const UTF32 halfMask = 0x3FFUL; - - - - /* --------------------------------------------------------------------- */ - - /* - * Index into the table below with the first byte of a UTF-8 sequence to - * get the number of trailing bytes that are supposed to follow it. - * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is - * left as-is for anyone who may want to do such conversion, which was - * allowed in earlier algorithms. - */ - static const char trailingBytesForUTF8[256] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 - }; - - /* - * Magic values subtracted from a buffer value during UTF8 conversion. - * This table contains as many values as there might be trailing bytes - * in a UTF-8 sequence. - */ - static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; - - /* - * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed - * into the first byte, depending on how many bytes follow. There are - * as many entries in this table as there are UTF-8 sequence types. - * (I.e., one byte sequence, two byte... etc.). Remember that sequencs - * for *legal* UTF-8 will be 4 or fewer bytes total. - */ - static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - /* --------------------------------------------------------------------- */ - - /* The interface converts a whole buffer to avoid function-call overhead. - * Constants have been gathered. Loops & conditionals have been removed as - * much as possible for efficiency, in favor of drop-through switches. - * (See "Note A" at the bottom of the file for equivalent code.) - * If your compiler supports it, the "isLegalUTF8" call can be turned - * into an inline function. - */ - - /* --------------------------------------------------------------------- */ - - void Convert( const wstring& src, string& dest ) - { - const UTF16* source = (UTF16*)src.c_str(); - const UTF16* sourceEnd = &source[ src.length() ]; - - // initialize a four-char packet: - std::wstring packet( L" " ); - - while (source < sourceEnd) - { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - //const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ - - ch = *source++; - - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) - { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) - { - UTF32 ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) - { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } - #ifdef UTF_STRICT - else if (flags == strictConversion) - { - /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = SourceIllegal; - break; - } - #endif - } - else - { - /* We don't have the 16 bits following the high surrogate. */ - //--source; /* return to the high surrogate */ - //result = SourceExhausted; - //break; - throw Exception::UTFConversion( dest, "UTF16->UTF8 conversion failure: Unexpected end of source string!" ); - } - } - #ifdef UTF_STRICT - else if (flags == strictConversion) - { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) - { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - #endif - - /* Figure out how many bytes the result will require */ - if (ch < (UTF32)0x80) bytesToWrite = 1; - else if (ch < (UTF32)0x800) bytesToWrite = 2; - else if (ch < (UTF32)0x10000) bytesToWrite = 3; - else if (ch < (UTF32)0x110000) bytesToWrite = 4; - else - { - bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - } - - packet.clear(); - switch( bytesToWrite ) - { - /* note: everything falls through. */ - case 4: packet += (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 3: packet += (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 2: packet += (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 1: packet += (UTF8) (ch | firstByteMark[bytesToWrite]); - } - dest.append( packet.rbegin(), packet.rend() ); - } - } - - /* --------------------------------------------------------------------- */ - - /* - * Utility routine to tell whether a sequence of bytes is legal UTF-8. - * This must be called with the length pre-determined by the first byte. - * If not calling this from ConvertUTF8to*, then the length can be set by: - * length = trailingBytesForUTF8[*source]+1; - * and the sequence is illegal right away if there aren't that many bytes - * available. - * If presented with a length > 4, this returns false. The Unicode - * definition of UTF-8 goes up to 4-byte sequences. - */ - static bool isLegalUTF8(const UTF8 *source, int length) - { - UTF8 a; - const UTF8 *srcptr = source+length; - - switch (length) - { - default: return false; - /* Everything else falls through when "true"... */ - case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 2: if ((a = (*--srcptr)) > 0xBF) return false; - - switch (*source) - { - /* no fall-through in this inner switch */ - case 0xE0: if (a < 0xA0) return false; break; - case 0xED: if (a > 0x9F) return false; break; - case 0xF0: if (a < 0x90) return false; break; - case 0xF4: if (a > 0x8F) return false; break; - default: if (a < 0x80) return false; - } - - case 1: if (*source >= 0x80 && *source < 0xC2) return false; - } - if (*source > 0xF4) return false; - return true; - } - - /* --------------------------------------------------------------------- */ - - /* - * Exported function to return whether a UTF-8 sequence is legal or not. - * This is not used here; it's just exported. - */ - bool isLegalUTF8Sequence( const UTF8 *source, const UTF8 *sourceEnd ) - { - int length = trailingBytesForUTF8[*source]+1; - if (source+length > sourceEnd) - return false; - return isLegalUTF8(source, length); - } - - /* --------------------------------------------------------------------- */ - - void Convert( const std::string& src, std::wstring& dest ) - { - const UTF8* source = (UTF8*)src.c_str(); - const UTF8* sourceEnd = &source[ src.length() ]; - - while (source < sourceEnd) - { - UTF32 ch = 0; - u16 extraBytesToRead = trailingBytesForUTF8[*source]; - - if( source + extraBytesToRead >= sourceEnd ) - { - throw Exception::UTFConversion( dest, "UTF8->UTF16 String Conversion failed: Unexpected end of string data." ); - } - - /* Do this check whether lenient or strict */ - if (!isLegalUTF8(source, extraBytesToRead+1)) - { - throw Exception::UTFConversion( dest, "UTF8->UTF16 String Conversion failed: Illegal UTF8 data encountered!" ); - } - - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) - { - case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ - case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ - case 3: ch += *source++; ch <<= 6; - case 2: ch += *source++; ch <<= 6; - case 1: ch += *source++; ch <<= 6; - case 0: ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; - - if (ch <= UNI_MAX_BMP) - { - /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) - { - #ifdef UTF_STRICT - if (flags == strictConversion) - { - source -= (extraBytesToRead+1); /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - else - #endif - { - dest += UNI_REPLACEMENT_CHAR; - } - } - else - { - dest += (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_UTF16) - { - #ifdef UTF_STRICT - if (flags == strictConversion) - { - result = sourceIllegal; - source -= (extraBytesToRead+1); /* return to the start */ - break; /* Bail out; shouldn't continue */ - } - else - #endif - { - dest += UNI_REPLACEMENT_CHAR; - } - } else - { - ch -= halfBase; - dest += (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - dest += (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); - } - } - } - - - /* --------------------------------------------------------------------- - - Note A. - The fall-through switches in UTF-8 reading code save a - temp variable, some decrements & conditionals. The switches - are equivalent to the following loop: - { - int tmpBytesToRead = extraBytesToRead+1; - do { - ch += *source++; - --tmpBytesToRead; - if (tmpBytesToRead) ch <<= 6; - } while (tmpBytesToRead > 0); - } - In UTF-8 writing code, the switches on "bytesToWrite" are - similarly unrolled loops. - - --------------------------------------------------------------------- */ - - wstring Convert( const string& src ) - { - wstring dest; - Convert( src, dest ); - return dest; - } - - string Convert( const wstring& src ) - { - string dest; - Convert( src, dest ); - return dest; - } -} diff --git a/plugins/spu2-x/src/ConvertUTF.h b/plugins/spu2-x/src/ConvertUTF.h deleted file mode 100644 index a5c240c903..0000000000 --- a/plugins/spu2-x/src/ConvertUTF.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __CONVERTUTF_H__ -#define __CONVERTUTF_H__ - -namespace Unicode -{ - - typedef unsigned long UTF32; /* at least 32 bits */ - typedef wchar_t UTF16; /* at least 16 bits */ - typedef unsigned char UTF8; /* typically 8 bits */ - - enum ConversionResult - { - ConversionOK, /* conversion successful */ - SourceExhausted, /* partial character in source, but hit end */ - SourceIllegal /* source sequence is illegal/malformed */ - }; - - /// - /// Converts from UTF-16 to UTF-8. - /// - void Convert( const std::wstring& src, std::string& dest ); - std::string Convert( const std::wstring& src ); - - /// - /// Converts from UTF-16 to UTF-8. - /// - void Convert( const std::string& src, std::wstring& dest ); - std::wstring Convert( const std::string& src ); -} - -namespace Exception -{ - template< typename ResultType > - class UTFConversion : public std::runtime_error - { - public: - const ResultType PartialResult; - - virtual ~UTFConversion() throw() {} - UTFConversion( const ResultType& result, const std::string& msg ) : - runtime_error( msg ), - PartialResult( result ) {} - }; -} - -#endif // __CONVERTUTF_H__ diff --git a/plugins/spu2-x/src/Debug.cpp b/plugins/spu2-x/src/Debug.cpp index 40a3ca2430..e7787fb34b 100644 --- a/plugins/spu2-x/src/Debug.cpp +++ b/plugins/spu2-x/src/Debug.cpp @@ -21,7 +21,7 @@ int crazy_debug=0; char s[4096]; -FILE *spu2Log; +FILE *spu2Log = NULL; void FileLog(const char *fmt, ...) { #ifdef SPU2_LOG @@ -98,7 +98,7 @@ void DoFullDump() if(MemDump()) { - dump = fopen( Unicode::Convert( MemDumpFileName ).c_str(), "wb" ); + dump = fopen( wxString(MemDumpFileName).ToUTF8(), "wb" ); if (dump) { fwrite(_spu2mem,0x200000,1,dump); @@ -107,7 +107,7 @@ void DoFullDump() } if(RegDump()) { - dump = fopen( Unicode::Convert( RegDumpFileName ).c_str(), "wb" ); + dump = fopen( wxString(RegDumpFileName).ToUTF8(), "wb" ); if (dump) { fwrite(spu2regs,0x2000,1,dump); @@ -116,7 +116,7 @@ void DoFullDump() } if(!CoresDump()) return; - dump = fopen( Unicode::Convert( CoresDumpFileName ).c_str(), "wt" ); + dump = fopen( wxString(CoresDumpFileName).ToUTF8(), "wt" ); if (dump) { for(c=0;c<2;c++) diff --git a/plugins/spu2-x/src/Debug.h b/plugins/spu2-x/src/Debug.h index 01815438d3..ffe5cc2a87 100644 --- a/plugins/spu2-x/src/Debug.h +++ b/plugins/spu2-x/src/Debug.h @@ -21,10 +21,14 @@ extern FILE *spu2Log; -void FileLog(const char *fmt, ...); -void ConLog(const char *fmt, ...); +extern void FileLog(const char *fmt, ...); +extern void ConLog(const char *fmt, ...); -void DoFullDump(); +extern void DoFullDump(); + +extern FILE* OpenBinaryLog( const wxString& logfile ); +extern FILE* OpenLog( const wxString& logfile ); +extern FILE* OpenDump( const wxString& logfile ); namespace WaveDump { diff --git a/plugins/spu2-x/src/Dma.cpp b/plugins/spu2-x/src/Dma.cpp index 5f6407fa55..c1a50cdbe5 100644 --- a/plugins/spu2-x/src/Dma.cpp +++ b/plugins/spu2-x/src/Dma.cpp @@ -26,21 +26,20 @@ static FILE *DMA4LogFile = NULL; static FILE *DMA7LogFile = NULL; static FILE *ADMA4LogFile = NULL; static FILE *ADMA7LogFile = NULL; -static FILE *ADMAOutLogFile = NULL; +static FILE *ADMAOutLogFile = NULL; static FILE *REGWRTLogFile[2] = {0,0}; void DMALogOpen() { if(!DMALog()) return; - DMA4LogFile = fopen( Unicode::Convert( DMA4LogFileName ).c_str(), "wb"); - DMA7LogFile = fopen( Unicode::Convert( DMA7LogFileName ).c_str(), "wb"); - ADMA4LogFile = fopen( "logs/adma4.raw", "wb" ); - ADMA7LogFile = fopen( "logs/adma7.raw", "wb" ); - ADMAOutLogFile = fopen( "logs/admaOut.raw", "wb" ); - //REGWRTLogFile[0]=fopen("logs/RegWrite0.raw","wb"); - //REGWRTLogFile[1]=fopen("logs/RegWrite1.raw","wb"); + DMA4LogFile = OpenBinaryLog( DMA4LogFileName ); + DMA7LogFile = OpenBinaryLog( DMA7LogFileName ); + ADMA4LogFile = OpenBinaryLog( L"adma4.raw" ); + ADMA7LogFile = OpenBinaryLog( L"adma7.raw" ); + ADMAOutLogFile = OpenBinaryLog( L"admaOut.raw" ); } + void DMA4LogWrite(void *lpData, u32 ulSize) { if(!DMALog()) return; if (!DMA4LogFile) return; diff --git a/plugins/spu2-x/src/Global.h b/plugins/spu2-x/src/Global.h index 2b9f972fa0..d7d4d8b3ba 100644 --- a/plugins/spu2-x/src/Global.h +++ b/plugins/spu2-x/src/Global.h @@ -42,9 +42,6 @@ namespace soundtouch #include #include -using std::string; -using std::wstring; - // This will be brought in later anyways, but if we bring it in now, it'll avoid // warnings about redefining __LINUX__. #include "Utilities/Dependencies.h" @@ -105,8 +102,6 @@ extern void SysMessage(const wchar_t *fmt, ...); #include "Utilities/Exceptions.h" #include "Utilities/SafeArray.h" -#include "ConvertUTF.h" - #include "defs.h" #include "regs.h" diff --git a/plugins/spu2-x/src/Linux/CfgHelpers.cpp b/plugins/spu2-x/src/Linux/CfgHelpers.cpp index bb0fab1112..705579508c 100644 --- a/plugins/spu2-x/src/Linux/CfgHelpers.cpp +++ b/plugins/spu2-x/src/Linux/CfgHelpers.cpp @@ -52,7 +52,7 @@ void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value) spuConfig->Write(Name, Value); } -void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data) +void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wxString& Data) { setIni(Section); spuConfig->Write(Name, Data); @@ -90,7 +90,7 @@ void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, int Data = spuConfig->Read(Name, Default); } -void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default) +void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, int DataSize, const wchar_t* Default) { wxString temp; CfgReadStr(Section, Name, temp, DataSize, Default); diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 51245e47f9..2ddfa67328 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -65,8 +65,8 @@ void ReadSettings() EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 ); - wstring temp; - CfgReadStr( L"OUTPUT", L"Output_Module", temp, 127, PortaudioOut->GetIdent() ); + wxString temp; + CfgReadStr( L"OUTPUT", L"Output_Module", temp, PortaudioOut->GetIdent() ); OutputModule = FindOutputModuleById( temp.c_str() );// find the driver index of this module SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 150); diff --git a/plugins/spu2-x/src/Linux/ConfigDebug.cpp b/plugins/spu2-x/src/Linux/ConfigDebug.cpp index 6bc6fdc6e4..0abf4bb64b 100644 --- a/plugins/spu2-x/src/Linux/ConfigDebug.cpp +++ b/plugins/spu2-x/src/Linux/ConfigDebug.cpp @@ -36,30 +36,57 @@ bool _CoresDump=false; bool _MemDump=false; bool _RegDump=false; -wchar_t AccessLogFileName[255]; -wchar_t WaveLogFileName[255]; +// this is set true if PCSX2 invokes the SetLogDir callback, which tells SPU2-X to use that over +// the configured crap in the ini file. +static bool LogLocationSetByPcsx2 = false; -wchar_t DMA4LogFileName[255]; -wchar_t DMA7LogFileName[255]; +static wxDirName LogsFolder; +static wxDirName DumpsFolder; -wchar_t CoresDumpFileName[255]; -wchar_t MemDumpFileName[255]; -wchar_t RegDumpFileName[255]; +wxString AccessLogFileName; +wxString DMA4LogFileName; +wxString DMA7LogFileName; + +wxString CoresDumpFileName; +wxString MemDumpFileName; +wxString RegDumpFileName; namespace DebugConfig { +void CfgSetLogDir( const char* dir ) +{ + LogsFolder = (dir==NULL) ? wxString(L"logs") : fromUTF8(dir); + DumpsFolder = (dir==NULL) ? wxString(L"logs") : fromUTF8(dir); + LogLocationSetByPcsx2 = (dir!=NULL); +} + +FILE* OpenBinaryLog( const wxString& logfile ) +{ + return wxFopen( Path::Combine(LogsFolder, logfile), L"wb" ); +} + +FILE* OpenLog( const wxString& logfile ) +{ + return wxFopen( Path::Combine(LogsFolder, logfile), L"w" ); +} + +FILE* OpenDump( const wxString& logfile ) +{ + return wxFopen( Path::Combine(DumpsFolder, logfile), L"w" ); +} + static const wchar_t* Section = L"DEBUG"; static void set_default_filenames() { - swprintf(AccessLogFileName, 255, L"logs/SPU2Log.txt"); - swprintf(WaveLogFileName, 255, L"logs/SPU2log.wav"); - swprintf(DMA4LogFileName, 255, L"logs/logs/SPU2dma4.dat"); - swprintf(DMA7LogFileName, 255, L"logs/SPU2dma7.dat"); + AccessLogFileName = L"SPU2Log.txt"; + WaveLogFileName = L"SPU2log.wav"; + DMA4LogFileName = L"SPU2dma4.dat"; + DMA7LogFileName = L"SPU2dma7.dat"; - swprintf(CoresDumpFileName, 255, L"logs/SPU2Cores.txt"); - swprintf(MemDumpFileName, 255, L"logs/SPU2mem.dat"); - swprintf(RegDumpFileName, 255, L"logs/SPU2regs.dat"); + CoresDumpFileName = L"SPU2Cores.txt"; + MemDumpFileName = L"SPU2mem.dat"; + RegDumpFileName = L"SPU2regs.dat"; } void ReadSettings() diff --git a/plugins/spu2-x/src/Linux/Dialogs.h b/plugins/spu2-x/src/Linux/Dialogs.h index 3037953fee..f1b3d41fb8 100644 --- a/plugins/spu2-x/src/Linux/Dialogs.h +++ b/plugins/spu2-x/src/Linux/Dialogs.h @@ -29,13 +29,14 @@ namespace DebugConfig } extern void CfgSetSettingsDir(const char* dir); +extern void CfgSetLogDir(const char* dir); extern void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value); extern void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value); -extern void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data); +extern void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wxString& Data); extern bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default); -extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default); +extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, const wchar_t* Default); //extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, int DataSize, const wchar_t* Default); extern int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default); diff --git a/plugins/spu2-x/src/PS2E-spu2.cpp b/plugins/spu2-x/src/PS2E-spu2.cpp index d7cb8d8612..37e9e07313 100644 --- a/plugins/spu2-x/src/PS2E-spu2.cpp +++ b/plugins/spu2-x/src/PS2E-spu2.cpp @@ -197,6 +197,11 @@ EXPORT_C_(void) CALLBACK SPU2setSettingsDir(const char* dir) CfgSetSettingsDir( dir ); } +EXPORT_C_(void) CALLBACK SPU2setLogDir(const char* dir) +{ + CfgSetLogDir( dir ); +} + EXPORT_C_(s32) SPU2dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) { if(channel==4) @@ -299,7 +304,7 @@ EXPORT_C_(s32) SPU2init() #ifdef SPU2_LOG if(AccessLog()) { - spu2Log = fopen( Unicode::Convert( AccessLogFileName ).c_str(), "w" ); + spu2Log = OpenLog( AccessLogFileName ); setvbuf(spu2Log, NULL, _IONBF, 0); FileLog("SPU2init\n"); } @@ -335,7 +340,7 @@ EXPORT_C_(s32) SPU2init() memcpy(regtable, regtable_original, sizeof(regtable)); - for(int mem=0;mem<0x800;mem++) + for(uint mem=0;mem<0x800;mem++) { u16 *ptr = regtable[mem>>1]; if(!ptr) { @@ -349,27 +354,8 @@ EXPORT_C_(s32) SPU2init() Cores[1].Reset(1); DMALogOpen(); - - /*for(v=0;v<16384;v++) - { - logvolume[v]=(s32)(s32)floor(log((double)(v+1))*3376.7); - }*/ - - // Initializes lowpass filter for reverb in mixer.cpp - //LowPassFilterInit(); InitADSR(); -#ifdef STREAM_DUMP - il0=fopen("logs/spu2input0.pcm","wb"); - il1=fopen("logs/spu2input1.pcm","wb"); -#endif - -#ifdef EFFECTS_DUMP - el0=fopen("logs/spu2fx0.pcm","wb"); - el1=fopen("logs/spu2fx1.pcm","wb"); -#endif - - #ifdef S2R_ENABLE if(!replay_mode) s2r_open("replay_dump.s2r"); diff --git a/plugins/spu2-x/src/SndOut_Portaudio.cpp b/plugins/spu2-x/src/SndOut_Portaudio.cpp index 661fcd3abf..383497697a 100644 --- a/plugins/spu2-x/src/SndOut_Portaudio.cpp +++ b/plugins/spu2-x/src/SndOut_Portaudio.cpp @@ -41,7 +41,7 @@ private: // Configuration Vars (unused still) int m_ApiId; - wstring m_Device; + wxString m_Device; bool m_UseHardware; @@ -293,10 +293,10 @@ public: void ReadSettings() { - wstring api=L"EMPTYEMPTYEMPTY"; + wxString api( L"EMPTYEMPTYEMPTY" ); m_Device = L"EMPTYEMPTYEMPTY"; - CfgReadStr( L"PORTAUDIO", L"HostApi", api, 254, L"Unknown" ); - CfgReadStr( L"PORTAUDIO", L"Device", m_Device, 254, L"default" ); + CfgReadStr( L"PORTAUDIO", L"HostApi", api, L"Unknown" ); + CfgReadStr( L"PORTAUDIO", L"Device", m_Device, L"default" ); m_ApiId = -1; if(api == L"InDevelopment") m_ApiId = paInDevelopment; /* use while developing support for a new host API */ @@ -319,7 +319,7 @@ public: void WriteSettings() const { - wstring api; + wxString api; switch(m_ApiId) { case paInDevelopment: api = L"InDevelopment"; break; /* use while developing support for a new host API */ diff --git a/plugins/spu2-x/src/Windows/CfgHelpers.cpp b/plugins/spu2-x/src/Windows/CfgHelpers.cpp index 7cf2bf63db..d9ff3a77c3 100644 --- a/plugins/spu2-x/src/Windows/CfgHelpers.cpp +++ b/plugins/spu2-x/src/Windows/CfgHelpers.cpp @@ -92,9 +92,9 @@ void CfgWriteInt(const TCHAR* Section, const TCHAR* Name, int Value) WritePrivateProfileString( Section, Name, Data, CfgFile ); }*/ -void CfgWriteStr(const TCHAR* Section, const TCHAR* Name, const wstring& Data) +void CfgWriteStr(const TCHAR* Section, const TCHAR* Name, const wxString& Data) { - WritePrivateProfileString( Section, Name, Data.c_str(), CfgFile ); + WritePrivateProfileString( Section, Name, Data, CfgFile ); } /*****************************************************************************/ @@ -143,10 +143,10 @@ void CfgReadStr(const TCHAR* Section, const TCHAR* Name, TCHAR* Data, int DataSi } } -void CfgReadStr(const TCHAR* Section, const TCHAR* Name, wstring& Data, int DataSize, const TCHAR* Default) +void CfgReadStr(const TCHAR* Section, const TCHAR* Name, wxString& Data, const TCHAR* Default) { wchar_t workspace[512]; - GetPrivateProfileString(Section,Name,L"",workspace,DataSize,CfgFile); + GetPrivateProfileString(Section,Name,L"",workspace,ArraySize(workspace),CfgFile); Data = workspace; diff --git a/plugins/spu2-x/src/Windows/Config.cpp b/plugins/spu2-x/src/Windows/Config.cpp index 5440bd16be..644619a14c 100644 --- a/plugins/spu2-x/src/Windows/Config.cpp +++ b/plugins/spu2-x/src/Windows/Config.cpp @@ -78,7 +78,7 @@ void ReadSettings() dspPluginEnabled= CfgReadBool(L"DSP PLUGIN",L"Enabled",false); // Read DSOUNDOUT and WAVEOUT configs: - CfgReadStr( L"WAVEOUT", L"Device", Config_WaveOut.Device, 254, L"default" ); + CfgReadStr( L"WAVEOUT", L"Device", Config_WaveOut.Device, L"default" ); Config_WaveOut.NumBuffers = CfgReadInt( L"WAVEOUT", L"Buffer_Count", 4 ); DSoundOut->ReadSettings(); diff --git a/plugins/spu2-x/src/Windows/ConfigDebug.cpp b/plugins/spu2-x/src/Windows/ConfigDebug.cpp index 0b56b13bb2..af21bfe7ec 100644 --- a/plugins/spu2-x/src/Windows/ConfigDebug.cpp +++ b/plugins/spu2-x/src/Windows/ConfigDebug.cpp @@ -17,6 +17,7 @@ #include "Global.h" #include "Dialogs.h" +#include "Utilities\Path.h" bool DebugEnabled=false; @@ -36,21 +37,49 @@ bool _CoresDump=false; bool _MemDump=false; bool _RegDump=false; +// this is set true if PCSX2 invokes the SetLogDir callback, which tells SPU2-X to use that over +// the configured crap in the ini file. +static bool LogLocationSetByPcsx2 = false; +static wxString CfgLogsFolder; +static wxString CfgDumpsFolder; -wchar_t AccessLogFileName[255]; -wchar_t WaveLogFileName[255]; +static wxDirName LogsFolder; +static wxDirName DumpsFolder; -wchar_t DMA4LogFileName[255]; -wchar_t DMA7LogFileName[255]; +wxString AccessLogFileName; +wxString DMA4LogFileName; +wxString DMA7LogFileName; -wchar_t CoresDumpFileName[255]; -wchar_t MemDumpFileName[255]; -wchar_t RegDumpFileName[255]; +wxString CoresDumpFileName; +wxString MemDumpFileName; +wxString RegDumpFileName; + +void CfgSetLogDir( const char* dir ) +{ + LogsFolder = (dir==NULL) ? wxString(L"logs") : fromUTF8(dir); + DumpsFolder = (dir==NULL) ? wxString(L"logs") : fromUTF8(dir); + LogLocationSetByPcsx2 = (dir!=NULL); +} + +FILE* OpenBinaryLog( const wxString& logfile ) +{ + return wxFopen( Path::Combine(LogsFolder, logfile), L"wb" ); +} + +FILE* OpenLog( const wxString& logfile ) +{ + return wxFopen( Path::Combine(LogsFolder, logfile), L"w" ); +} + +FILE* OpenDump( const wxString& logfile ) +{ + return wxFopen( Path::Combine(DumpsFolder, logfile), L"w" ); +} namespace DebugConfig { -static const TCHAR* Section = L"DEBUG"; +static const wxChar* Section = L"DEBUG"; void ReadSettings() { @@ -71,14 +100,22 @@ void ReadSettings() _MemDump = CfgReadBool(Section, L"Dump_Memory",0); _RegDump = CfgReadBool(Section, L"Dump_Regs",0); - CfgReadStr(Section,L"Access_Log_Filename",AccessLogFileName,255,L"logs\\SPU2Log.txt"); - CfgReadStr(Section,L"WaveLog_Filename", WaveLogFileName, 255,L"logs\\SPU2log.wav"); - CfgReadStr(Section,L"DMA4Log_Filename", DMA4LogFileName, 255,L"logs\\SPU2dma4.dat"); - CfgReadStr(Section,L"DMA7Log_Filename", DMA7LogFileName, 255,L"logs\\SPU2dma7.dat"); + CfgReadStr(Section,L"Logs_Folder", CfgLogsFolder, L"logs"); + CfgReadStr(Section,L"Dumps_Folder",CfgDumpsFolder,L"logs"); - CfgReadStr(Section,L"Info_Dump_Filename",CoresDumpFileName,255,L"logs\\SPU2Cores.txt"); - CfgReadStr(Section,L"Mem_Dump_Filename", MemDumpFileName, 255,L"logs\\SPU2mem.dat"); - CfgReadStr(Section,L"Reg_Dump_Filename", RegDumpFileName, 255,L"logs\\SPU2regs.dat"); + CfgReadStr(Section,L"Access_Log_Filename",AccessLogFileName, L"SPU2Log.txt"); + CfgReadStr(Section,L"DMA4Log_Filename", DMA4LogFileName, L"SPU2dma4.dat"); + CfgReadStr(Section,L"DMA7Log_Filename", DMA7LogFileName, L"SPU2dma7.dat"); + + CfgReadStr(Section,L"Info_Dump_Filename", CoresDumpFileName, L"SPU2Cores.txt"); + CfgReadStr(Section,L"Mem_Dump_Filename", MemDumpFileName, L"SPU2mem.dat"); + CfgReadStr(Section,L"Reg_Dump_Filename", RegDumpFileName, L"SPU2regs.dat"); + + if( !LogLocationSetByPcsx2 ) + { + LogsFolder = CfgLogsFolder; + DumpsFolder = CfgLogsFolder; + } } @@ -102,15 +139,18 @@ void WriteSettings() CfgWriteBool(Section,L"Dump_Memory",_MemDump); CfgWriteBool(Section,L"Dump_Regs", _RegDump); + // None of the logs strings are changable via GUI, so no point in bothering to + // write them back out. + CfgWriteStr(Section,L"Logs_Folder", CfgLogsFolder); + CfgWriteStr(Section,L"Dumps_Folder",CfgDumpsFolder); + CfgWriteStr(Section,L"Access_Log_Filename",AccessLogFileName); - CfgWriteStr(Section,L"WaveLog_Filename", WaveLogFileName); CfgWriteStr(Section,L"DMA4Log_Filename", DMA4LogFileName); CfgWriteStr(Section,L"DMA7Log_Filename", DMA7LogFileName); CfgWriteStr(Section,L"Info_Dump_Filename",CoresDumpFileName); CfgWriteStr(Section,L"Mem_Dump_Filename", MemDumpFileName); CfgWriteStr(Section,L"Reg_Dump_Filename", RegDumpFileName); - } static void EnableMessages( HWND hWnd ) diff --git a/plugins/spu2-x/src/Windows/Dialogs.h b/plugins/spu2-x/src/Windows/Dialogs.h index 4e6de46b73..ea98d410ee 100644 --- a/plugins/spu2-x/src/Windows/Dialogs.h +++ b/plugins/spu2-x/src/Windows/Dialogs.h @@ -48,18 +48,19 @@ extern int GetSliderValue( HWND hWnd, int idc ); extern BOOL DoHandleScrollMessage( HWND hwndDisplay, WPARAM wParam, LPARAM lParam ); extern void CfgSetSettingsDir( const char* dir ); +extern void CfgSetLogDir( const char* dir ); + extern bool CfgFindName( const TCHAR *Section, const TCHAR* Name); extern void CfgWriteBool(const TCHAR* Section, const TCHAR* Name, bool Value); extern void CfgWriteInt(const TCHAR* Section, const TCHAR* Name, int Value); -extern void CfgWriteStr(const TCHAR* Section, const TCHAR* Name, const wstring& Data); +extern void CfgWriteStr(const TCHAR* Section, const TCHAR* Name, const wxString& Data); extern bool CfgReadBool(const TCHAR *Section,const TCHAR* Name, bool Default); -extern void CfgReadStr(const TCHAR* Section, const TCHAR* Name, wstring& Data, int DataSize, const TCHAR* Default); +extern void CfgReadStr(const TCHAR* Section, const TCHAR* Name, wxString& Data, const TCHAR* Default); extern void CfgReadStr(const TCHAR* Section, const TCHAR* Name, TCHAR* Data, int DataSize, const TCHAR* Default); extern int CfgReadInt(const TCHAR* Section, const TCHAR* Name,int Default); - // Items Specific to DirectSound #define STRFY(x) #x #define verifyc(x) Verifyc(x,STRFY(x)) @@ -68,7 +69,7 @@ extern void Verifyc(HRESULT hr, const char* fn); struct ds_device_data { - std::wstring name; + wxString name; GUID guid; bool hasGuid; }; diff --git a/plugins/spu2-x/src/Windows/SndOut_DSound.cpp b/plugins/spu2-x/src/Windows/SndOut_DSound.cpp index ba4ebcd45d..c0c7362b56 100644 --- a/plugins/spu2-x/src/Windows/SndOut_DSound.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_DSound.cpp @@ -33,7 +33,7 @@ private: ////////////////////////////////////////////////////////////////////////////////////////// // Configuration Vars - wstring m_Device; + wxString m_Device; u8 m_NumBuffers; bool m_DisableGlobalFocus; bool m_UseHardware; @@ -455,7 +455,7 @@ public: void ReadSettings() { - CfgReadStr( L"DSOUNDOUT", L"Device", m_Device, 254, L"default" ); + CfgReadStr( L"DSOUNDOUT", L"Device", m_Device, L"default" ); m_NumBuffers = CfgReadInt( L"DSOUNDOUT", L"Buffer_Count", 5 ); m_DisableGlobalFocus = CfgReadBool( L"DSOUNDOUT", L"Disable_Global_Focus", false ); m_UseHardware = CfgReadBool( L"DSOUNDOUT", L"Use_Hardware", false ); diff --git a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp index 69786d53d7..8db3063a61 100644 --- a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp @@ -43,7 +43,7 @@ namespace Exception public: const HRESULT ErrorCode; - string m_Message; + std::string m_Message; const char* CMessage() const { diff --git a/plugins/spu2-x/src/Windows/Spu2-X.def b/plugins/spu2-x/src/Windows/Spu2-X.def index f2b4d4f3cb..06c6b64138 100644 --- a/plugins/spu2-x/src/Windows/Spu2-X.def +++ b/plugins/spu2-x/src/Windows/Spu2-X.def @@ -23,41 +23,41 @@ EXPORTS PS2EgetLibType @2 PS2EgetLibName @3 PS2EgetLibVersion2 @4 + SPU2init @5 SPU2shutdown @6 SPU2open @7 SPU2close @8 - SPU2write @9 - SPU2read @10 - SPU2async @11 - SPU2readDMA4Mem @12 - SPU2writeDMA4Mem @13 - SPU2readDMA7Mem @14 - SPU2writeDMA7Mem @15 - SPU2interruptDMA4 @16 - SPU2interruptDMA7 @17 + SPU2configure @9 + SPU2test @10 + SPU2about @11 + SPU2freeze @12 + + SPU2setSettingsDir @13 + SPU2setLogDir @14 + + SPU2write @15 + SPU2read @16 + SPU2async @17 + SPU2dmaRead @18 + SPU2dmaWrite @19 + SPU2dmaInterrupt @20 + + SPU2readDMA4Mem @21 + SPU2writeDMA4Mem @22 + SPU2readDMA7Mem @23 + SPU2writeDMA7Mem @24 + SPU2interruptDMA4 @25 + SPU2interruptDMA7 @26 + + SPU2irqCallback @27 + SPU2setupRecording @28 - SPU2dmaRead - SPU2dmaWrite - SPU2dmaInterrupt - SPU2setSettingsDir - - SPU2irqCallback @18 + SPU2ReadMemAddr @29 + SPU2WriteMemAddr @30 - SPU2setupRecording @19 - - SPU2configure @20 - SPU2test @21 - SPU2about @22 - - SPU2ReadMemAddr @23 - SPU2WriteMemAddr @24 - - SPU2setClockPtr @25 + SPU2setClockPtr @31 + SPU2setDMABaseAddr @32 - SPU2setDMABaseAddr @26 - - SPU2replay = s2r_replay @27 - - SPU2freeze @28 \ No newline at end of file + SPU2replay = s2r_replay @33 diff --git a/plugins/spu2-x/src/Windows/Spu2-X_vs2008.vcproj b/plugins/spu2-x/src/Windows/Spu2-X_vs2008.vcproj index 95386c422b..f870db3990 100644 --- a/plugins/spu2-x/src/Windows/Spu2-X_vs2008.vcproj +++ b/plugins/spu2-x/src/Windows/Spu2-X_vs2008.vcproj @@ -1,7 +1,7 @@ - - - - diff --git a/plugins/spu2-x/src/Windows/WinConfig.h b/plugins/spu2-x/src/Windows/WinConfig.h index a037c7eadc..04d5b42b55 100644 --- a/plugins/spu2-x/src/Windows/WinConfig.h +++ b/plugins/spu2-x/src/Windows/WinConfig.h @@ -37,7 +37,7 @@ extern HINSTANCE hInstance; struct CONFIG_XAUDIO2 { - std::wstring Device; + wxString Device; s8 NumBuffers; CONFIG_XAUDIO2() : @@ -49,7 +49,7 @@ struct CONFIG_XAUDIO2 struct CONFIG_WAVEOUT { - std::wstring Device; + wxString Device; s8 NumBuffers; CONFIG_WAVEOUT() :