mirror of https://github.com/PCSX2/pcsx2.git
Refactoring: Split FixedPointTypes.h into an h/inl setup.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3302 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
93937901c5
commit
e145f9dd67
|
@ -152,6 +152,7 @@
|
|||
<Unit filename="../../include/Utilities/EventSource.inl" />
|
||||
<Unit filename="../../include/Utilities/Exceptions.h" />
|
||||
<Unit filename="../../include/Utilities/FixedPointTypes.h" />
|
||||
<Unit filename="../../include/Utilities/FixedPointTypes.inl" />
|
||||
<Unit filename="../../include/Utilities/General.h" />
|
||||
<Unit filename="../../include/Utilities/HashMap.h" />
|
||||
<Unit filename="../../include/Utilities/IniInterface.h" />
|
||||
|
|
|
@ -381,6 +381,10 @@
|
|||
RelativePath="..\..\include\Utilities\FixedPointTypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\Utilities\FixedPointTypes.inl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\Utilities\General.h"
|
||||
>
|
||||
|
|
|
@ -18,221 +18,58 @@
|
|||
#include "Dependencies.h"
|
||||
#include "Exceptions.h"
|
||||
|
||||
// Needed for pow().
|
||||
#include <math.h>
|
||||
|
||||
template< int Precision >
|
||||
struct FixedInt
|
||||
{
|
||||
s32 Raw;
|
||||
|
||||
FixedInt()
|
||||
{
|
||||
Raw = 0;
|
||||
}
|
||||
FixedInt();
|
||||
FixedInt( int signedval );
|
||||
FixedInt( double doubval );
|
||||
FixedInt( float floval );
|
||||
|
||||
FixedInt( int signedval )
|
||||
{
|
||||
Raw = signedval * Precision;
|
||||
}
|
||||
bool operator ==( const FixedInt<Precision>& right ) const { return Raw == right.Raw; }
|
||||
bool operator !=( const FixedInt<Precision>& right ) const { return Raw != right.Raw; }
|
||||
|
||||
FixedInt( double doubval )
|
||||
{
|
||||
Raw = (int)(doubval * (double)Precision);
|
||||
}
|
||||
bool operator>( const FixedInt<Precision>& right ) const { return Raw > right.Raw; };
|
||||
bool operator>=( const FixedInt<Precision>& right ) const { return Raw >= right.Raw; };
|
||||
bool operator<( const FixedInt<Precision>& right ) const { return Raw < right.Raw; };
|
||||
bool operator<=( const FixedInt<Precision>& right ) const { return Raw <= right.Raw; };
|
||||
|
||||
FixedInt( float floval )
|
||||
{
|
||||
Raw = (int)(floval * (float)Precision);
|
||||
}
|
||||
FixedInt<Precision> operator+( const FixedInt<Precision>& right ) const;
|
||||
FixedInt<Precision> operator-( const FixedInt<Precision>& right ) const;
|
||||
FixedInt<Precision>& operator+=( const FixedInt<Precision>& right );
|
||||
FixedInt<Precision>& operator-=( const FixedInt<Precision>& right );
|
||||
|
||||
bool operator ==( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
return Raw == right.Raw;
|
||||
}
|
||||
FixedInt<Precision>& ConfineTo( const FixedInt<Precision>& low, const FixedInt<Precision>& high );
|
||||
|
||||
bool operator !=( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
return Raw != right.Raw;
|
||||
}
|
||||
FixedInt<Precision> operator*( const FixedInt<Precision>& right ) const;
|
||||
FixedInt<Precision> operator/( const FixedInt<Precision>& right ) const;
|
||||
FixedInt<Precision>& operator*=( const FixedInt<Precision>& right );
|
||||
FixedInt<Precision>& operator/=( const FixedInt<Precision>& right );
|
||||
|
||||
FixedInt<Precision> operator+( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
return FixedInt<Precision>().SetRaw( Raw + right.Raw );
|
||||
}
|
||||
static bool OverflowCheck( int signedval );
|
||||
static bool OverflowCheck( double signedval );
|
||||
|
||||
FixedInt<Precision> operator-( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
return FixedInt<Precision>().SetRaw( Raw + right.Raw );
|
||||
}
|
||||
int GetWhole() const;
|
||||
int GetFraction() const;
|
||||
|
||||
FixedInt<Precision>& operator+=( const FixedInt<Precision>& right )
|
||||
{
|
||||
return SetRaw( Raw + right.Raw );
|
||||
}
|
||||
FixedInt<Precision>& SetRaw( s32 rawsrc );
|
||||
FixedInt<Precision>& Round();
|
||||
FixedInt<Precision>& SetWhole( s32 wholepart );
|
||||
FixedInt<Precision>& SetFraction( u32 fracpart );
|
||||
|
||||
FixedInt<Precision>& operator-=( const FixedInt<Precision>& right )
|
||||
{
|
||||
return SetRaw( Raw + right.Raw );
|
||||
}
|
||||
wxString ToString() const;
|
||||
wxString ToString( int fracDigits ) const;
|
||||
|
||||
bool operator>( const FixedInt<Precision>& right ) const { return Raw > right.Raw; }
|
||||
bool operator>=( const FixedInt<Precision>& right ) const { return Raw >= right.Raw; }
|
||||
bool operator<( const FixedInt<Precision>& right ) const { return Raw < right.Raw; }
|
||||
bool operator<=( const FixedInt<Precision>& right ) const { return Raw <= right.Raw; }
|
||||
double ToDouble() const;
|
||||
float ToFloat() const;
|
||||
int ToIntTruncated() const;
|
||||
int ToIntRounded() const;
|
||||
|
||||
FixedInt<Precision>& ConfineTo( const FixedInt<Precision>& low, const FixedInt<Precision>& high )
|
||||
{
|
||||
return SetRaw( std::min( std::max( Raw, low.Raw ), high.Raw ) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
FixedInt<Precision> operator*( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
s64 mulres = (s64)Raw * right.Raw;
|
||||
return FixedInt<Precision>().SetRaw( (s32)(mulres / Precision) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
FixedInt<Precision> operator/( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
s64 divres = Raw * Precision;
|
||||
return FixedInt<Precision>().SetRaw( (s32)(divres / right.Raw) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
FixedInt<Precision>& operator*=( const FixedInt<Precision>& right )
|
||||
{
|
||||
s64 mulres = (s64)Raw * right.Raw;
|
||||
return SetRaw( (s32)(mulres / Precision) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
FixedInt<Precision>& operator/=( const FixedInt<Precision>& right )
|
||||
{
|
||||
s64 divres = Raw * Precision;
|
||||
return SetRaw( (s32)(divres / right.Raw) );
|
||||
}
|
||||
|
||||
// returns TRUE if the value overflows the legal integer range of this container.
|
||||
static bool OverflowCheck( int signedval )
|
||||
{
|
||||
return ( signedval >= (INT_MAX / Precision) );
|
||||
}
|
||||
|
||||
// returns TRUE if the value overflows the legal integer range of this container.
|
||||
static bool OverflowCheck( double signedval )
|
||||
{
|
||||
return ( signedval >= (INT_MAX / Precision) );
|
||||
}
|
||||
|
||||
int GetWhole() const { return Raw / Precision; }
|
||||
int GetFraction() const { return Raw % Precision; }
|
||||
|
||||
FixedInt<Precision>& SetRaw( s32 rawsrc )
|
||||
{
|
||||
Raw = rawsrc;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FixedInt<Precision>& Round()
|
||||
{
|
||||
Raw = ToIntRounded();
|
||||
return *this;
|
||||
}
|
||||
|
||||
FixedInt<Precision>& SetWhole( s32 wholepart )
|
||||
{
|
||||
pxAssert( wholepart < (INT_MAX / Precision) );
|
||||
Raw = GetFraction() + (wholepart * Precision);
|
||||
return *this;
|
||||
}
|
||||
|
||||
FixedInt<Precision>& SetFraction( u32 fracpart )
|
||||
{
|
||||
Raw = (GetWhole() * Precision) + fracpart;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxString ToString() const
|
||||
{
|
||||
return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * 100) / Precision );
|
||||
}
|
||||
|
||||
wxString ToString( int fracDigits ) const
|
||||
{
|
||||
if( fracDigits == 0 ) return wxsFormat( L"%d", GetWhole() );
|
||||
|
||||
pxAssert( fracDigits <= 7 ); // higher numbers would just cause overflows and bad mojo.
|
||||
int mulby = (int)pow( 10.0, fracDigits );
|
||||
return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * mulby) / Precision );
|
||||
}
|
||||
|
||||
double ToDouble() const
|
||||
{
|
||||
return ((double)Raw / (double)Precision);
|
||||
}
|
||||
|
||||
float ToFloat() const
|
||||
{
|
||||
return ((float)Raw / (float)Precision);
|
||||
}
|
||||
|
||||
int ToIntTruncated() const
|
||||
{
|
||||
return Raw / Precision;
|
||||
}
|
||||
|
||||
int ToIntRounded() const
|
||||
{
|
||||
return (Raw + (Precision/2)) / Precision;
|
||||
}
|
||||
|
||||
static bool TryFromString( FixedInt<Precision>& dest, const wxString& parseFrom )
|
||||
{
|
||||
long whole=0, frac=0;
|
||||
const wxString beforeFirst( parseFrom.BeforeFirst( L'.' ) );
|
||||
const wxString afterFirst( parseFrom.AfterFirst( L'.' ).Mid(0, 5) );
|
||||
bool success = true;
|
||||
|
||||
if( !beforeFirst.IsEmpty() )
|
||||
success = success && beforeFirst.ToLong( &whole );
|
||||
|
||||
if( !afterFirst.IsEmpty() )
|
||||
success = success && afterFirst.ToLong( &frac );
|
||||
|
||||
if( !success ) return false;
|
||||
|
||||
dest.SetWhole( whole );
|
||||
|
||||
if( afterFirst.Length() != 0 && frac != 0 )
|
||||
{
|
||||
int fracPower = (int)pow( 10.0, (int)afterFirst.Length() );
|
||||
dest.SetFraction( (frac * Precision) / fracPower );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static FixedInt<Precision> FromString( const wxString& parseFrom, const FixedInt<Precision>& defval )
|
||||
{
|
||||
FixedInt<Precision> dest;
|
||||
if( !TryFromString( dest, parseFrom ) ) return defval;
|
||||
return dest;
|
||||
}
|
||||
|
||||
// This version of FromString throws a ParseError exception if the conversion fails.
|
||||
static FixedInt<Precision> FromString( const wxString parseFrom )
|
||||
{
|
||||
FixedInt<Precision> dest;
|
||||
if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError(
|
||||
wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision), wxEmptyString
|
||||
);
|
||||
return dest;
|
||||
}
|
||||
static bool TryFromString( FixedInt<Precision>& dest, const wxString& parseFrom );
|
||||
static FixedInt<Precision> FromString( const wxString& parseFrom, const FixedInt<Precision>& defval );
|
||||
static FixedInt<Precision> FromString( const wxString parseFrom );
|
||||
};
|
||||
|
||||
typedef FixedInt<256> Fixed256;
|
||||
|
|
|
@ -0,0 +1,240 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 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 PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FixedPointTypes.h"
|
||||
#include <cmath> // for pow!
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>::FixedInt()
|
||||
{
|
||||
Raw = 0;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>::FixedInt( int signedval )
|
||||
{
|
||||
Raw = signedval * Precision;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>::FixedInt( double doubval )
|
||||
{
|
||||
Raw = (int)(doubval * (double)Precision);
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>::FixedInt( float floval )
|
||||
{
|
||||
Raw = (int)(floval * (float)Precision);
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision> FixedInt<Precision>::operator+( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
return FixedInt<Precision>().SetRaw( Raw + right.Raw );
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision> FixedInt<Precision>::operator-( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
return FixedInt<Precision>().SetRaw( Raw + right.Raw );
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::operator+=( const FixedInt<Precision>& right )
|
||||
{
|
||||
return SetRaw( Raw + right.Raw );
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::operator-=( const FixedInt<Precision>& right )
|
||||
{
|
||||
return SetRaw( Raw + right.Raw );
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::ConfineTo( const FixedInt<Precision>& low, const FixedInt<Precision>& high )
|
||||
{
|
||||
return SetRaw( std::min( std::max( Raw, low.Raw ), high.Raw ) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
template< int Precision >
|
||||
FixedInt<Precision> FixedInt<Precision>::operator*( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
s64 mulres = (s64)Raw * right.Raw;
|
||||
return FixedInt<Precision>().SetRaw( (s32)(mulres / Precision) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
template< int Precision >
|
||||
FixedInt<Precision> FixedInt<Precision>::operator/( const FixedInt<Precision>& right ) const
|
||||
{
|
||||
s64 divres = Raw * Precision;
|
||||
return FixedInt<Precision>().SetRaw( (s32)(divres / right.Raw) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::operator*=( const FixedInt<Precision>& right )
|
||||
{
|
||||
s64 mulres = (s64)Raw * right.Raw;
|
||||
return SetRaw( (s32)(mulres / Precision) );
|
||||
}
|
||||
|
||||
// Uses 64 bit internally to avoid overflows. For more precise/optimized 32 bit math
|
||||
// you'll need to use the Raw values directly.
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::operator/=( const FixedInt<Precision>& right )
|
||||
{
|
||||
s64 divres = Raw * Precision;
|
||||
return SetRaw( (s32)(divres / right.Raw) );
|
||||
}
|
||||
|
||||
// returns TRUE if the value overflows the legal integer range of this container.
|
||||
template< int Precision >
|
||||
bool FixedInt<Precision>::OverflowCheck( int signedval )
|
||||
{
|
||||
return ( signedval >= (INT_MAX / Precision) );
|
||||
}
|
||||
|
||||
// returns TRUE if the value overflows the legal integer range of this container.
|
||||
template< int Precision >
|
||||
bool FixedInt<Precision>::OverflowCheck( double signedval )
|
||||
{
|
||||
return ( signedval >= (INT_MAX / Precision) );
|
||||
}
|
||||
|
||||
template< int Precision > int FixedInt<Precision>::GetWhole() const { return Raw / Precision; }
|
||||
template< int Precision > int FixedInt<Precision>::GetFraction() const { return Raw % Precision; }
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::SetRaw( s32 rawsrc )
|
||||
{
|
||||
Raw = rawsrc;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::Round()
|
||||
{
|
||||
Raw = ToIntRounded();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::SetWhole( s32 wholepart )
|
||||
{
|
||||
pxAssert( wholepart < (INT_MAX / Precision) );
|
||||
Raw = GetFraction() + (wholepart * Precision);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision>& FixedInt<Precision>::SetFraction( u32 fracpart )
|
||||
{
|
||||
Raw = (GetWhole() * Precision) + fracpart;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
wxString FixedInt<Precision>::ToString() const
|
||||
{
|
||||
return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * 100) / Precision );
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
wxString FixedInt<Precision>::ToString( int fracDigits ) const
|
||||
{
|
||||
if( fracDigits == 0 ) return wxsFormat( L"%d", GetWhole() );
|
||||
|
||||
pxAssert( fracDigits <= 7 ); // higher numbers would just cause overflows and bad mojo.
|
||||
int mulby = (int)pow( 10.0, fracDigits );
|
||||
return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * mulby) / Precision );
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
double FixedInt<Precision>::ToDouble() const
|
||||
{
|
||||
return ((double)Raw / (double)Precision);
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
float FixedInt<Precision>::ToFloat() const
|
||||
{
|
||||
return ((float)Raw / (float)Precision);
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
int FixedInt<Precision>::ToIntTruncated() const
|
||||
{
|
||||
return Raw / Precision;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
int FixedInt<Precision>::ToIntRounded() const
|
||||
{
|
||||
return (Raw + (Precision/2)) / Precision;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
bool FixedInt<Precision>::TryFromString( FixedInt<Precision>& dest, const wxString& parseFrom )
|
||||
{
|
||||
long whole=0, frac=0;
|
||||
const wxString beforeFirst( parseFrom.BeforeFirst( L'.' ) );
|
||||
const wxString afterFirst( parseFrom.AfterFirst( L'.' ).Mid(0, 5) );
|
||||
bool success = true;
|
||||
|
||||
if( !beforeFirst.IsEmpty() )
|
||||
success = success && beforeFirst.ToLong( &whole );
|
||||
|
||||
if( !afterFirst.IsEmpty() )
|
||||
success = success && afterFirst.ToLong( &frac );
|
||||
|
||||
if( !success ) return false;
|
||||
|
||||
dest.SetWhole( whole );
|
||||
|
||||
if( afterFirst.Length() != 0 && frac != 0 )
|
||||
{
|
||||
int fracPower = (int)pow( 10.0, (int)afterFirst.Length() );
|
||||
dest.SetFraction( (frac * Precision) / fracPower );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template< int Precision >
|
||||
FixedInt<Precision> FixedInt<Precision>::FromString( const wxString& parseFrom, const FixedInt<Precision>& defval )
|
||||
{
|
||||
FixedInt<Precision> dest;
|
||||
if( !TryFromString( dest, parseFrom ) ) return defval;
|
||||
return dest;
|
||||
}
|
||||
|
||||
// This version of FromString throws a ParseError exception if the conversion fails.
|
||||
template< int Precision >
|
||||
FixedInt<Precision> FixedInt<Precision>::FromString( const wxString parseFrom )
|
||||
{
|
||||
FixedInt<Precision> dest;
|
||||
if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError(
|
||||
wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision), wxEmptyString
|
||||
);
|
||||
return dest;
|
||||
}
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "FixedPointTypes.h"
|
||||
#include "Path.h"
|
||||
#include "FixedPointTypes.h"
|
||||
#include <wx/config.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,187 +1,188 @@
|
|||
# Check that people use the good file
|
||||
if(NOT TOP_CMAKE_WAS_SOURCED)
|
||||
message(FATAL_ERROR "
|
||||
You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir.
|
||||
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
|
||||
endif(NOT TOP_CMAKE_WAS_SOURCED)
|
||||
|
||||
|
||||
# library name
|
||||
set(UtilitiesName Utilities)
|
||||
|
||||
# Clear default flags
|
||||
set(CMAKE_C_FLAGS "")
|
||||
set(CMAKE_CXX_FLAGS "")
|
||||
set(CMAKE_C_FLAGS_DEBUG "")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
set(CMAKE_C_FLAGS_DEVEL "")
|
||||
set(CMAKE_CXX_FLAGS_DEVEL "")
|
||||
set(CMAKE_C_FLAGS_RELEASE "")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
|
||||
# set common flags
|
||||
set(CommonFlags
|
||||
-pthread
|
||||
-m32
|
||||
-march=i486
|
||||
-msse
|
||||
# Check that people use the good file
|
||||
if(NOT TOP_CMAKE_WAS_SOURCED)
|
||||
message(FATAL_ERROR "
|
||||
You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir.
|
||||
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
|
||||
endif(NOT TOP_CMAKE_WAS_SOURCED)
|
||||
|
||||
|
||||
# library name
|
||||
set(UtilitiesName Utilities)
|
||||
|
||||
# Clear default flags
|
||||
set(CMAKE_C_FLAGS "")
|
||||
set(CMAKE_CXX_FLAGS "")
|
||||
set(CMAKE_C_FLAGS_DEBUG "")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
set(CMAKE_C_FLAGS_DEVEL "")
|
||||
set(CMAKE_CXX_FLAGS_DEVEL "")
|
||||
set(CMAKE_C_FLAGS_RELEASE "")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
|
||||
# set common flags
|
||||
set(CommonFlags
|
||||
-pthread
|
||||
-m32
|
||||
-march=i486
|
||||
-msse
|
||||
-msse2
|
||||
-fno-dse
|
||||
-fno-dse
|
||||
-fno-guess-branch-probability
|
||||
-fno-strict-aliasing
|
||||
-fno-strict-aliasing
|
||||
-fno-tree-dse
|
||||
-pipe
|
||||
-pipe
|
||||
-Wno-format
|
||||
-Wno-unused-parameter
|
||||
-Wno-unused-value
|
||||
-Wunused-variable)
|
||||
|
||||
# set warning flags
|
||||
set(DebugFlags
|
||||
-g
|
||||
-W)
|
||||
|
||||
# set optimization flags
|
||||
set(OptimizationFlags
|
||||
-falign-functions
|
||||
-falign-jumps
|
||||
-falign-labels
|
||||
-falign-loops
|
||||
-fcaller-saves
|
||||
-fcprop-registers
|
||||
-fcrossjumping
|
||||
-fcse-follow-jumps
|
||||
-fcse-skip-blocks
|
||||
-fdefer-pop
|
||||
-fdelete-null-pointer-checks
|
||||
-fgcse
|
||||
-fgcse-lm
|
||||
-fif-conversion
|
||||
-fif-conversion2
|
||||
-fmerge-constants
|
||||
-foptimize-sibling-calls
|
||||
-fpeephole2
|
||||
-fregmove
|
||||
-freorder-blocks
|
||||
-freorder-functions
|
||||
-frerun-cse-after-loop
|
||||
-fsched-interblock
|
||||
-fsched-spec
|
||||
-fstrict-overflow
|
||||
-fthread-jumps
|
||||
-ftree-ccp
|
||||
-ftree-ch
|
||||
-ftree-copyrename
|
||||
-ftree-dce
|
||||
-ftree-dominator-opts
|
||||
-ftree-fre
|
||||
-ftree-lrs
|
||||
-ftree-pre
|
||||
-ftree-sra
|
||||
-ftree-ter
|
||||
-ftree-vrp
|
||||
-funit-at-a-time)
|
||||
|
||||
# Debug - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
# add defines
|
||||
add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEBUG -DPCSX2_DEVBUILD)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
# Devel - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Devel)
|
||||
|
||||
# add defines
|
||||
add_definitions(${CommonFlags} ${OptimizationFlags} -DPCSX2_DEVBUILD)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Devel)
|
||||
|
||||
# Release - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
|
||||
# add defines
|
||||
add_definitions(${CommonFlags} ${OptimizationFlags})
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
|
||||
# variable with all sources of this library
|
||||
set(UtilitiesSources
|
||||
../../include/Utilities/EventSource.inl
|
||||
AlignedMalloc.cpp
|
||||
CheckedStaticBox.cpp
|
||||
Console.cpp
|
||||
EventSource.cpp
|
||||
Exceptions.cpp
|
||||
FastFormatString.cpp
|
||||
HashTools.cpp
|
||||
IniInterface.cpp
|
||||
Linux/LnxHostSys.cpp
|
||||
Linux/LnxMisc.cpp
|
||||
Linux/LnxThreads.cpp
|
||||
Mutex.cpp
|
||||
PathUtils.cpp
|
||||
PrecompiledHeader.cpp
|
||||
pxCheckBox.cpp
|
||||
pxRadioPanel.cpp
|
||||
pxStaticText.cpp
|
||||
pxTextStream.cpp
|
||||
pxWindowTextWriter.cpp
|
||||
Semaphore.cpp
|
||||
StringHelpers.cpp
|
||||
ThreadingDialogs.cpp
|
||||
ThreadTools.cpp
|
||||
vssprintf.cpp
|
||||
wxAppWithHelpers.cpp
|
||||
wxGuiTools.cpp
|
||||
wxHelpers.cpp
|
||||
# x86/MemcpyFast.cpp
|
||||
)
|
||||
|
||||
# collect .S files
|
||||
set(UtilitiesSSources
|
||||
x86/MemcpyFast.S)
|
||||
|
||||
# variable with all headers of this library
|
||||
set(UtilitiesHeaders
|
||||
../../include/Utilities/Assertions.h
|
||||
../../include/Utilities/CheckedStaticBox.h
|
||||
../../include/Utilities/Console.h
|
||||
../../include/Utilities/Dependencies.h
|
||||
../../include/Utilities/EventSource.h
|
||||
../../include/Utilities/Exceptions.h
|
||||
../../include/Utilities/FixedPointTypes.h
|
||||
../../include/Utilities/General.h
|
||||
../../include/Utilities/HashMap.h
|
||||
../../include/Utilities/lnx_memzero.h
|
||||
../../include/Utilities/MemcpyFast.h
|
||||
../../include/Utilities/Path.h
|
||||
../../include/Utilities/pxCheckBox.h
|
||||
../../include/Utilities/pxRadioPanel.h
|
||||
../../include/Utilities/pxStaticText.h
|
||||
../../include/Utilities/RedtapeWindows.h
|
||||
../../include/Utilities/SafeArray.h
|
||||
../../include/Utilities/ScopedPtr.h
|
||||
../../include/Utilities/ScopedPtrMT.h
|
||||
../../include/Utilities/StringHelpers.h
|
||||
../../include/Utilities/Threading.h
|
||||
../../include/Utilities/ThreadingDialogs.h
|
||||
../../include/Utilities/wxAppWithHelpers.h
|
||||
../../include/Utilities/wxBaseTools.h
|
||||
../../include/Utilities/wxGuiTools.h
|
||||
PrecompiledHeader.h)
|
||||
|
||||
# change language of .S-files to c++
|
||||
set_source_files_properties(${UtilitiesSSources} PROPERTIES LANGUAGE CXX)
|
||||
|
||||
# add library
|
||||
add_library(${UtilitiesName} STATIC ${UtilitiesSources} ${UtilitiesHeaders} ${UtilitiesSSources})
|
||||
|
||||
# link target with wx
|
||||
target_link_libraries(${UtilitiesName} ${wxWidgets_LIBRARIES})
|
||||
|
||||
# Force the linker into 32 bits mode
|
||||
target_link_libraries(${UtilitiesName} -m32)
|
||||
|
||||
# Linker strip option
|
||||
if (CMAKE_BUILD_STRIP)
|
||||
target_link_libraries(${UtilitiesName} -s)
|
||||
endif (CMAKE_BUILD_STRIP)
|
||||
|
||||
# set warning flags
|
||||
set(DebugFlags
|
||||
-g
|
||||
-W)
|
||||
|
||||
# set optimization flags
|
||||
set(OptimizationFlags
|
||||
-falign-functions
|
||||
-falign-jumps
|
||||
-falign-labels
|
||||
-falign-loops
|
||||
-fcaller-saves
|
||||
-fcprop-registers
|
||||
-fcrossjumping
|
||||
-fcse-follow-jumps
|
||||
-fcse-skip-blocks
|
||||
-fdefer-pop
|
||||
-fdelete-null-pointer-checks
|
||||
-fgcse
|
||||
-fgcse-lm
|
||||
-fif-conversion
|
||||
-fif-conversion2
|
||||
-fmerge-constants
|
||||
-foptimize-sibling-calls
|
||||
-fpeephole2
|
||||
-fregmove
|
||||
-freorder-blocks
|
||||
-freorder-functions
|
||||
-frerun-cse-after-loop
|
||||
-fsched-interblock
|
||||
-fsched-spec
|
||||
-fstrict-overflow
|
||||
-fthread-jumps
|
||||
-ftree-ccp
|
||||
-ftree-ch
|
||||
-ftree-copyrename
|
||||
-ftree-dce
|
||||
-ftree-dominator-opts
|
||||
-ftree-fre
|
||||
-ftree-lrs
|
||||
-ftree-pre
|
||||
-ftree-sra
|
||||
-ftree-ter
|
||||
-ftree-vrp
|
||||
-funit-at-a-time)
|
||||
|
||||
# Debug - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
# add defines
|
||||
add_definitions(${CommonFlags} ${DebugFlags} -DPCSX2_DEBUG -DPCSX2_DEVBUILD)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
# Devel - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Devel)
|
||||
|
||||
# add defines
|
||||
add_definitions(${CommonFlags} ${OptimizationFlags} -DPCSX2_DEVBUILD)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Devel)
|
||||
|
||||
# Release - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
|
||||
# add defines
|
||||
add_definitions(${CommonFlags} ${OptimizationFlags})
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
|
||||
# variable with all sources of this library
|
||||
set(UtilitiesSources
|
||||
../../include/Utilities/FixedPointTypes.inl
|
||||
../../include/Utilities/EventSource.inl
|
||||
AlignedMalloc.cpp
|
||||
CheckedStaticBox.cpp
|
||||
Console.cpp
|
||||
EventSource.cpp
|
||||
Exceptions.cpp
|
||||
FastFormatString.cpp
|
||||
HashTools.cpp
|
||||
IniInterface.cpp
|
||||
Linux/LnxHostSys.cpp
|
||||
Linux/LnxMisc.cpp
|
||||
Linux/LnxThreads.cpp
|
||||
Mutex.cpp
|
||||
PathUtils.cpp
|
||||
PrecompiledHeader.cpp
|
||||
pxCheckBox.cpp
|
||||
pxRadioPanel.cpp
|
||||
pxStaticText.cpp
|
||||
pxTextStream.cpp
|
||||
pxWindowTextWriter.cpp
|
||||
Semaphore.cpp
|
||||
StringHelpers.cpp
|
||||
ThreadingDialogs.cpp
|
||||
ThreadTools.cpp
|
||||
vssprintf.cpp
|
||||
wxAppWithHelpers.cpp
|
||||
wxGuiTools.cpp
|
||||
wxHelpers.cpp
|
||||
# x86/MemcpyFast.cpp
|
||||
)
|
||||
|
||||
# collect .S files
|
||||
set(UtilitiesSSources
|
||||
x86/MemcpyFast.S)
|
||||
|
||||
# variable with all headers of this library
|
||||
set(UtilitiesHeaders
|
||||
../../include/Utilities/Assertions.h
|
||||
../../include/Utilities/CheckedStaticBox.h
|
||||
../../include/Utilities/Console.h
|
||||
../../include/Utilities/Dependencies.h
|
||||
../../include/Utilities/EventSource.h
|
||||
../../include/Utilities/Exceptions.h
|
||||
../../include/Utilities/FixedPointTypes.h
|
||||
../../include/Utilities/General.h
|
||||
../../include/Utilities/HashMap.h
|
||||
../../include/Utilities/lnx_memzero.h
|
||||
../../include/Utilities/MemcpyFast.h
|
||||
../../include/Utilities/Path.h
|
||||
../../include/Utilities/pxCheckBox.h
|
||||
../../include/Utilities/pxRadioPanel.h
|
||||
../../include/Utilities/pxStaticText.h
|
||||
../../include/Utilities/RedtapeWindows.h
|
||||
../../include/Utilities/SafeArray.h
|
||||
../../include/Utilities/ScopedPtr.h
|
||||
../../include/Utilities/ScopedPtrMT.h
|
||||
../../include/Utilities/StringHelpers.h
|
||||
../../include/Utilities/Threading.h
|
||||
../../include/Utilities/ThreadingDialogs.h
|
||||
../../include/Utilities/wxAppWithHelpers.h
|
||||
../../include/Utilities/wxBaseTools.h
|
||||
../../include/Utilities/wxGuiTools.h
|
||||
PrecompiledHeader.h)
|
||||
|
||||
# change language of .S-files to c++
|
||||
set_source_files_properties(${UtilitiesSSources} PROPERTIES LANGUAGE CXX)
|
||||
|
||||
# add library
|
||||
add_library(${UtilitiesName} STATIC ${UtilitiesSources} ${UtilitiesHeaders} ${UtilitiesSSources})
|
||||
|
||||
# link target with wx
|
||||
target_link_libraries(${UtilitiesName} ${wxWidgets_LIBRARIES})
|
||||
|
||||
# Force the linker into 32 bits mode
|
||||
target_link_libraries(${UtilitiesName} -m32)
|
||||
|
||||
# Linker strip option
|
||||
if (CMAKE_BUILD_STRIP)
|
||||
target_link_libraries(${UtilitiesName} -s)
|
||||
endif (CMAKE_BUILD_STRIP)
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
|
||||
const wxRect wxDefaultRect( wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord );
|
||||
|
||||
// Implement FixedPointTypes (for lack of a better location, for now)
|
||||
|
||||
#include "FixedPointTypes.inl"
|
||||
template FixedInt<100>;
|
||||
template FixedInt<256>;
|
||||
|
||||
static int _calcEnumLength( const wxChar* const* enumArray )
|
||||
{
|
||||
int cnt = 0;
|
||||
|
|
Loading…
Reference in New Issue