mirror of https://github.com/PCSX2/pcsx2.git
* Added subdivided content to the u128 type (changed it from a struct to a union, added _u32[4], _u16[8], etc).
* Added ToString methods to the u128 type. * Bugfixes for the FastFormat string utilities, namely when writing UTF8 content via the UTF16 formatter. * MSVC: Removed obsolete disabling of unsigned/signed mismatch warning (4018) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3703 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
393333456c
commit
1cac8d3948
|
@ -16,16 +16,23 @@
|
||||||
#ifndef __PCSX2TYPES_H__
|
#ifndef __PCSX2TYPES_H__
|
||||||
#define __PCSX2TYPES_H__
|
#define __PCSX2TYPES_H__
|
||||||
|
|
||||||
/*
|
// --------------------------------------------------------------------------------------
|
||||||
* Based on PS2E Definitions by
|
// Forward declarations
|
||||||
linuzappz@hotmail.com,
|
// --------------------------------------------------------------------------------------
|
||||||
* shadowpcsx2@yahoo.gr,
|
// Forward declarations for wxWidgets-supporting features.
|
||||||
* and florinsasu@hotmail.com
|
// If you aren't linking against wxWidgets libraries, then functions that
|
||||||
*/
|
// depend on these types will not be usable (they will yield linker errors).
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
class wxString;
|
||||||
|
class FastFormatAscii;
|
||||||
|
class FastFormatUnicode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
// --------------------------------------------------------------------------------------
|
||||||
// Basic Atomic Types
|
// Basic Atomic Types
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
|
||||||
|
@ -111,19 +118,27 @@ typedef s32 sptr;
|
||||||
// performing explicit conversion from 64 and 32 bit values are provided instead.
|
// performing explicit conversion from 64 and 32 bit values are provided instead.
|
||||||
//
|
//
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
struct u128
|
union u128
|
||||||
{
|
{
|
||||||
u64 lo;
|
struct
|
||||||
u64 hi;
|
{
|
||||||
|
u64 lo;
|
||||||
|
u64 hi;
|
||||||
|
};
|
||||||
|
|
||||||
// Explicit conversion from u64
|
u64 _u64[2];
|
||||||
|
u32 _u32[4];
|
||||||
|
u16 _u16[8];
|
||||||
|
u8 _u8[16];
|
||||||
|
|
||||||
|
// Explicit conversion from u64. Zero-extends the source through 128 bits.
|
||||||
static u128 From64( u64 src )
|
static u128 From64( u64 src )
|
||||||
{
|
{
|
||||||
u128 retval = { src, 0 };
|
u128 retval = { src, 0 };
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit conversion from u32
|
// Explicit conversion from u32. Zero-extends the source through 128 bits.
|
||||||
static u128 From32( u32 src )
|
static u128 From32( u32 src )
|
||||||
{
|
{
|
||||||
u128 retval = { src, 0 };
|
u128 retval = { src, 0 };
|
||||||
|
@ -143,6 +158,17 @@ struct u128
|
||||||
{
|
{
|
||||||
return (lo != right.lo) && (hi != right.hi);
|
return (lo != right.lo) && (hi != right.hi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In order for the following ToString() and WriteTo methods to be available, you must
|
||||||
|
// be linking to both wxWidgets and the pxWidgets extension library. If you are not
|
||||||
|
// using them, then you will need to provide your own implementations of these methods.
|
||||||
|
wxString ToString() const;
|
||||||
|
wxString ToString64() const;
|
||||||
|
wxString ToString8() const;
|
||||||
|
|
||||||
|
void WriteTo( FastFormatAscii& dest ) const;
|
||||||
|
void WriteTo8( FastFormatAscii& dest ) const;
|
||||||
|
void WriteTo64( FastFormatAscii& dest ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct s128
|
struct s128
|
||||||
|
@ -183,13 +209,21 @@ struct s128
|
||||||
|
|
||||||
typedef union _u128_t
|
typedef union _u128_t
|
||||||
{
|
{
|
||||||
u64 lo;
|
struct
|
||||||
u64 hi;
|
{
|
||||||
|
u64 lo;
|
||||||
|
u64 hi;
|
||||||
|
};
|
||||||
|
|
||||||
|
u64 _u64[2];
|
||||||
|
u32 _u32[4];
|
||||||
|
u16 _u16[8];
|
||||||
|
u8 _u8[16];
|
||||||
} u128;
|
} u128;
|
||||||
|
|
||||||
typedef union _s128_t
|
typedef union _s128_t
|
||||||
{
|
{
|
||||||
s64 lo;
|
u64 lo;
|
||||||
s64 hi;
|
s64 hi;
|
||||||
} s128;
|
} s128;
|
||||||
|
|
||||||
|
|
|
@ -127,11 +127,11 @@ public:
|
||||||
FastFormatAscii& Write( const char* fmt, ... );
|
FastFormatAscii& Write( const char* fmt, ... );
|
||||||
FastFormatAscii& WriteV( const char* fmt, va_list argptr );
|
FastFormatAscii& WriteV( const char* fmt, va_list argptr );
|
||||||
|
|
||||||
const char* GetResult() const;
|
const char* c_str() const { return m_dest->GetPtr(); }
|
||||||
operator const char*() const;
|
operator const char*() const { return m_dest->GetPtr(); }
|
||||||
|
|
||||||
const wxString GetString() const;
|
const wxString GetString() const;
|
||||||
operator wxString() const;
|
//operator wxString() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FastFormatUnicode
|
class FastFormatUnicode
|
||||||
|
@ -149,18 +149,9 @@ public:
|
||||||
FastFormatUnicode& WriteV( const char* fmt, va_list argptr );
|
FastFormatUnicode& WriteV( const char* fmt, va_list argptr );
|
||||||
FastFormatUnicode& WriteV( const wxChar* fmt, va_list argptr );
|
FastFormatUnicode& WriteV( const wxChar* fmt, va_list argptr );
|
||||||
|
|
||||||
const wxChar* GetResult() const;
|
const wxChar* c_str() const { return (const wxChar*)m_dest->GetPtr(); }
|
||||||
const wxString GetString() const;
|
operator const wxChar*() const { return (const wxChar*)m_dest->GetPtr(); }
|
||||||
|
operator wxString() const { return (const wxChar*)m_dest->GetPtr(); }
|
||||||
operator const wxChar*() const
|
|
||||||
{
|
|
||||||
return (const wxChar*)m_dest->GetPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
operator wxString() const
|
|
||||||
{
|
|
||||||
return (const wxChar*)m_dest->GetPtr();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest );
|
extern bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest );
|
||||||
|
|
|
@ -298,7 +298,7 @@ const IConsoleWriter ConsoleWriter_wxError =
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================================================================
|
// =====================================================================================================
|
||||||
// IConsoleWriter Implementations
|
// IConsoleWriter (implementations)
|
||||||
// =====================================================================================================
|
// =====================================================================================================
|
||||||
// (all non-virtual members that do common work and then pass the result through DoWrite
|
// (all non-virtual members that do common work and then pass the result through DoWrite
|
||||||
// or DoWriteLn)
|
// or DoWriteLn)
|
||||||
|
@ -569,14 +569,14 @@ const NullConsoleWriter NullCon = {};
|
||||||
bool ConsoleLogSource::WriteV( ConsoleColors color, const char *fmt, va_list list ) const
|
bool ConsoleLogSource::WriteV( ConsoleColors color, const char *fmt, va_list list ) const
|
||||||
{
|
{
|
||||||
ConsoleColorScope cs(color);
|
ConsoleColorScope cs(color);
|
||||||
DoWrite( pxsFmtV(fmt,list).GetResult() );
|
DoWrite( pxsFmtV(fmt,list).c_str() );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConsoleLogSource::WriteV( ConsoleColors color, const wxChar *fmt, va_list list ) const
|
bool ConsoleLogSource::WriteV( ConsoleColors color, const wxChar *fmt, va_list list ) const
|
||||||
{
|
{
|
||||||
ConsoleColorScope cs(color);
|
ConsoleColorScope cs(color);
|
||||||
DoWrite( pxsFmtV(fmt,list) );
|
DoWrite( pxsFmtV(fmt,list).c_str() );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,21 +49,20 @@ pxDoAssertFnType* pxDoAssert = pxAssertImpl_LogIt;
|
||||||
// response times from the Output window...
|
// response times from the Output window...
|
||||||
wxString DiagnosticOrigin::ToString( const wxChar* msg ) const
|
wxString DiagnosticOrigin::ToString( const wxChar* msg ) const
|
||||||
{
|
{
|
||||||
wxString message;
|
FastFormatUnicode message;
|
||||||
message.reserve( 2048 );
|
|
||||||
|
|
||||||
message.Printf( L"%s(%d) : assertion failed:\n", srcfile, line );
|
message.Write( L"%s(%d) : assertion failed:\n", srcfile, line );
|
||||||
|
|
||||||
if( function != NULL )
|
if( function != NULL )
|
||||||
message += L" Function: " + fromUTF8(function) + L"\n";
|
message.Write( " Function: %s\n", function );
|
||||||
|
|
||||||
message += L" Thread: " + Threading::pxGetCurrentThreadName() + L"\n";
|
message.Write(L" Thread: %s\n", Threading::pxGetCurrentThreadName().c_str() );
|
||||||
|
|
||||||
if( condition != NULL )
|
if( condition != NULL )
|
||||||
message += L" Condition: " + wxString(condition) + L"\n";
|
message.Write(L" Condition: %s\n", condition);
|
||||||
|
|
||||||
if( msg != NULL )
|
if( msg != NULL )
|
||||||
message += L" Message: " + wxString(msg) + L"\n";
|
message.Write(L" Message: %s\n", msg);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ class FastFormatBuffers
|
||||||
protected:
|
protected:
|
||||||
typedef SafeAlignedArray<CharType,16> BufferType;
|
typedef SafeAlignedArray<CharType,16> BufferType;
|
||||||
|
|
||||||
static const uint BufferCount = 3;
|
static const uint BufferCount = 4;
|
||||||
|
|
||||||
BufferType m_buffers[BufferCount];
|
BufferType m_buffers[BufferCount];
|
||||||
uint m_curslot;
|
uint m_curslot;
|
||||||
|
@ -63,8 +63,8 @@ public:
|
||||||
{
|
{
|
||||||
m_buffers[i].Name = wxsFormat(L"%s Formatting Buffer (slot%d)",
|
m_buffers[i].Name = wxsFormat(L"%s Formatting Buffer (slot%d)",
|
||||||
(sizeof(CharType)==1) ? L"Ascii" : L"Unicode", i);
|
(sizeof(CharType)==1) ? L"Ascii" : L"Unicode", i);
|
||||||
m_buffers[i].MakeRoomFor(1024);
|
m_buffers[i].MakeRoomFor(512);
|
||||||
m_buffers[i].ChunkSize = 4096;
|
m_buffers[i].ChunkSize = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_curslot = 0;
|
m_curslot = 0;
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
|
|
||||||
bool HasFreeBuffer() const
|
bool HasFreeBuffer() const
|
||||||
{
|
{
|
||||||
return m_curslot < BufferCount;
|
return m_curslot < BufferCount-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferType& GrabBuffer()
|
BufferType& GrabBuffer()
|
||||||
|
@ -176,7 +176,7 @@ static __ri void format_that_unicode_mess( SafeArray<char>& buffer, uint writepo
|
||||||
while( true )
|
while( true )
|
||||||
{
|
{
|
||||||
int size = buffer.GetLength() / sizeof(wxChar);
|
int size = buffer.GetLength() / sizeof(wxChar);
|
||||||
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos), size-writepos, fmt, argptr);
|
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos*2), size-writepos, fmt, argptr);
|
||||||
|
|
||||||
// some implementations of vsnprintf() don't NUL terminate
|
// some implementations of vsnprintf() don't NUL terminate
|
||||||
// the string if there is not enough space for it so
|
// the string if there is not enough space for it so
|
||||||
|
@ -266,11 +266,6 @@ FastFormatUnicode& FastFormatUnicode::Write( const wxChar* fmt, ... )
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxChar* FastFormatUnicode::GetResult() const
|
|
||||||
{
|
|
||||||
return (wxChar*)m_dest->GetPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// FastFormatAscii (implementations)
|
// FastFormatAscii (implementations)
|
||||||
|
@ -294,10 +289,10 @@ const wxString FastFormatAscii::GetString() const
|
||||||
return fromAscii(m_dest->GetPtr());
|
return fromAscii(m_dest->GetPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
FastFormatAscii::operator wxString() const
|
/*FastFormatAscii::operator wxString() const
|
||||||
{
|
{
|
||||||
return fromAscii(m_dest->GetPtr());
|
return fromAscii(m_dest->GetPtr());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
FastFormatAscii& FastFormatAscii::WriteV( const char* fmt, va_list argptr )
|
FastFormatAscii& FastFormatAscii::WriteV( const char* fmt, va_list argptr )
|
||||||
{
|
{
|
||||||
|
@ -314,13 +309,3 @@ FastFormatAscii& FastFormatAscii::Write( const char* fmt, ... )
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* FastFormatAscii::GetResult() const
|
|
||||||
{
|
|
||||||
return m_dest->GetPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
FastFormatAscii::operator const char*() const
|
|
||||||
{
|
|
||||||
return m_dest->GetPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,42 @@ __fi wxString fromAscii( const char* src )
|
||||||
return wxString::FromAscii( src );
|
return wxString::FromAscii( src );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString u128::ToString() const
|
||||||
|
{
|
||||||
|
return pxsFmt( L"0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString u128::ToString64() const
|
||||||
|
{
|
||||||
|
return pxsFmt( L"0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString u128::ToString8() const
|
||||||
|
{
|
||||||
|
FastFormatUnicode result;
|
||||||
|
result.Write( L"0x%02X.%02X", _u8[0], _u8[1] );
|
||||||
|
for (uint i=2; i<16; i+=2)
|
||||||
|
result.Write( L".%02X.%02X", _u8[i], _u8[i+1] );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void u128::WriteTo( FastFormatAscii& dest ) const
|
||||||
|
{
|
||||||
|
dest.Write( "0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||||
|
}
|
||||||
|
|
||||||
|
void u128::WriteTo64( FastFormatAscii& dest ) const
|
||||||
|
{
|
||||||
|
dest.Write( "0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||||
|
}
|
||||||
|
|
||||||
|
void u128::WriteTo8( FastFormatAscii& dest ) const
|
||||||
|
{
|
||||||
|
dest.Write( "0x%02X.%02X", _u8[0], _u8[1] );
|
||||||
|
for (uint i=2; i<16; i+=2)
|
||||||
|
dest.Write( ".%02X.%02X", _u8[i], _u8[i+1] );
|
||||||
|
}
|
||||||
|
|
||||||
// Splits a string into parts and adds the parts into the given SafeList.
|
// Splits a string into parts and adds the parts into the given SafeList.
|
||||||
// This list is not cleared, so concatenating many splits into a single large list is
|
// This list is not cleared, so concatenating many splits into a single large list is
|
||||||
// the 'default' behavior, unless you manually clear the SafeList prior to subsequent calls.
|
// the 'default' behavior, unless you manually clear the SafeList prior to subsequent calls.
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
#ifndef __CDVD_ISO_READER_H__
|
#ifndef __CDVD_ISO_READER_H__
|
||||||
#define __CDVD_ISO_READER_H__
|
#define __CDVD_ISO_READER_H__
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4018)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "IopCommon.h"
|
#include "IopCommon.h"
|
||||||
|
|
|
@ -29,10 +29,6 @@
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(disable:4018) // disable signed/unsigned mismatch error
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "IopCommon.h"
|
#include "IopCommon.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -524,7 +524,7 @@ union tDMAC_ADDR
|
||||||
|
|
||||||
wxCharBuffer ToUTF8(bool sprIsValid=true) const
|
wxCharBuffer ToUTF8(bool sprIsValid=true) const
|
||||||
{
|
{
|
||||||
return FastFormatAscii().Write((sprIsValid && SPR) ? "0x%04X(SPR)" : "0x%08X", ADDR).GetResult();
|
return FastFormatAscii().Write((sprIsValid && SPR) ? "0x%04X(SPR)" : "0x%08X", ADDR).c_str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue